diff --git a/AUTHORS b/AUTHORS index 039f330dc4..888814e7de 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,6 +24,7 @@ Developers: carlomorgantinizynga CCLabelTTF supports for shadow and stroke + Adding CCLabelTTF::createWithFontDefinition. James Gregory (j4m3z0r, Zynga) Maintainer of Emscripten port. @@ -183,6 +184,7 @@ Developers: 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. Nicolas Gramlich (nicolasgramlich, Zynga) fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF diff --git a/CHANGELOG b/CHANGELOG index 4002d73d77..9584fc46ef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +cocos2d-x-3.0alpha0-pre @Jul.24 2013 +[all platforms] + Feature #XXXX: Add support for std::function<> in CCMemuItem and CCCallFunc + + cocos2d-2.1rc0-x-2.1.3 @May.01 2013 [all platforms] Bug #1853: use SHELLOPTS instead of "-o igncr" for Android Eclipse project diff --git a/CocosDenshion/android/opensl/OpenSLEngine.cpp b/CocosDenshion/android/opensl/OpenSLEngine.cpp index 101bf59790..28d83fe448 100644 --- a/CocosDenshion/android/opensl/OpenSLEngine.cpp +++ b/CocosDenshion/android/opensl/OpenSLEngine.cpp @@ -289,7 +289,8 @@ bool initAudioPlayer(AudioPlayer* player, const char* filename) if(fp){ SLDataLocator_URI loc_fd = {SL_DATALOCATOR_URI , (SLchar*)filename}; SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED}; - (player->audioSrc) = {&loc_fd, &format_mime}; + player->audioSrc.pLocator = &loc_fd; + player->audioSrc.pFormat = &format_mime; return createAudioPlayerBySource(player); } LOGD("file not found! Stop preload file: %s", filename); diff --git a/CocosDenshion/proj.tizen/.cproject b/CocosDenshion/proj.tizen/.cproject index 255f35d585..fde412fa0d 100644 --- a/CocosDenshion/proj.tizen/.cproject +++ b/CocosDenshion/proj.tizen/.cproject @@ -24,12 +24,12 @@ - + @@ -57,14 +56,15 @@ + - + @@ -89,12 +88,11 @@ - + diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 4bc1822687..be9918f8a8 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include +#include "CCStdC.h" #include "ccTypeInfo.h" #include "CCAction.h" @@ -213,7 +214,7 @@ public: : m_pSelectorTarget(NULL) , m_nScriptHandler(0) , m_pCallFunc(NULL) - , _function(NULL) + , _function(nullptr) { } virtual ~CCCallFunc(); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index f7750540e0..d0b066cf8e 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -103,7 +103,7 @@ CCNode::CCNode(void) CCNode::~CCNode(void) { - CCLOGINFO( "cocos2d: deallocing" ); + CCLOGINFO( "cocos2d: deallocing: %p", this ); unregisterScriptHandler(); if (m_nUpdateScriptHandler) diff --git a/cocos2dx/cocoa/CCData.h b/cocos2dx/cocoa/CCData.h index 6fa2657ce7..1279b9839a 100644 --- a/cocos2dx/cocoa/CCData.h +++ b/cocos2dx/cocoa/CCData.h @@ -7,7 +7,7 @@ NS_CC_BEGIN -class CCData : public CCObject +class CC_DLL CCData : public CCObject { public: CCData(unsigned char *pBytes, const unsigned long nSize); diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 2a8e582497..d109164fe1 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "2.1rc0-x-2.1.3"; + return "3.0-alpha0-pre"; } NS_CC_END diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 6d7fd93436..c5a0a7684f 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -142,7 +142,7 @@ CCBMFontConfiguration::CCBMFontConfiguration() CCBMFontConfiguration::~CCBMFontConfiguration() { - CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration" ); + CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration %p", this ); this->purgeFontDefDictionary(); this->purgeKerningDictionary(); m_sAtlasName.clear(); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index b96cf7d3f8..436094bef6 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -96,6 +96,18 @@ CCLabelTTF* CCLabelTTF::create(const char *string, const char *fontName, float f return NULL; } +CCLabelTTF * CCLabelTTF::createWithFontDefinition(const char *string, ccFontDefinition &textDefinition) +{ + CCLabelTTF *pRet = new CCLabelTTF(); + if(pRet && pRet->initWithStringAndTextDefinition(string, textDefinition)) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; +} + bool CCLabelTTF::init() { return this->initWithString("", "Helvetica", 12); @@ -355,7 +367,7 @@ void CCLabelTTF::enableShadow(const CCSize &shadowOffset, float shadowOpacity, f } #else - CCAssert(false, "Currently only supported on iOS and Android!"); + CCLOGERROR("Currently only supported on iOS and Android!"); #endif } @@ -374,7 +386,7 @@ void CCLabelTTF::disableShadow(bool updateTexture) } #else - CCAssert(false, "Currently only supported on iOS and Android!"); + CCLOGERROR("Currently only supported on iOS and Android!"); #endif } @@ -408,7 +420,7 @@ void CCLabelTTF::enableStroke(const ccColor3B &strokeColor, float strokeSize, bo } #else - CCAssert(false, "Currently only supported on iOS and Android!"); + CCLOGERROR("Currently only supported on iOS and Android!"); #endif } @@ -426,7 +438,7 @@ void CCLabelTTF::disableStroke(bool updateTexture) } #else - CCAssert(false, "Currently only supported on iOS and Android!"); + CCLOGERROR("Currently only supported on iOS and Android!"); #endif } @@ -442,7 +454,7 @@ void CCLabelTTF::setFontFillColor(const ccColor3B &tintColor, bool updateTexture this->updateTexture(); } #else - CCAssert(false, "Currently only supported on iOS and Android!"); + CCLOGERROR("Currently only supported on iOS and Android!"); #endif } diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index a5f950d5c3..487a89b0c2 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -70,6 +70,10 @@ public: const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment); + + /** Create a lable with string and a font definition*/ + static CCLabelTTF * createWithFontDefinition(const char *string, ccFontDefinition &textDefinition); + /** initializes the CCLabelTTF with a font name and font size */ bool initWithString(const char *string, const char *fontName, float fontSize); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index c828c62a8a..03512418bf 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -52,7 +52,7 @@ const unsigned int kDisableTag = 0x3; CCMenuItem* CCMenuItem::create() { - return CCMenuItem::create((const ccMenuCallback&)NULL); + return CCMenuItem::create((const ccMenuCallback&)nullptr); } // XXX deprecated @@ -161,6 +161,7 @@ bool CCMenuItem::isSelected() return m_bSelected; } +// XXX deprecated void CCMenuItem::setTarget(CCObject *target, SEL_MenuHandler selector) { _target = target; @@ -227,7 +228,7 @@ CCMenuItemLabel * CCMenuItemLabel::create(CCNode*label, const ccMenuCallback& ca CCMenuItemLabel* CCMenuItemLabel::create(CCNode *label) { CCMenuItemLabel *pRet = new CCMenuItemLabel(); - pRet->initWithLabel(label, (const ccMenuCallback&) NULL); + pRet->initWithLabel(label, (const ccMenuCallback&) nullptr); pRet->autorelease(); return pRet; } @@ -334,7 +335,7 @@ void CCMenuItemLabel::setEnabled(bool enabled) CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) { - return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)NULL); + return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)nullptr); } // XXX: deprecated @@ -427,11 +428,12 @@ CCMenuItemFont * CCMenuItemFont::create(const char *value, const ccMenuCallback& CCMenuItemFont * CCMenuItemFont::create(const char *value) { CCMenuItemFont *pRet = new CCMenuItemFont(); - pRet->initWithString(value, (const ccMenuCallback&)NULL); + pRet->initWithString(value, (const ccMenuCallback&)nullptr); pRet->autorelease(); return pRet; } +// XXX: deprecated bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_MenuHandler selector) { CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0"); @@ -571,7 +573,7 @@ void CCMenuItemSprite::setDisabledImage(CCNode* pImage) CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) { - return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)NULL); + return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)nullptr); } // XXX deprecated @@ -726,12 +728,12 @@ CCMenuItemImage* CCMenuItemImage::create() bool CCMenuItemImage::init(void) { - return initWithNormalImage(NULL, NULL, NULL, (const ccMenuCallback&)NULL); + return initWithNormalImage(NULL, NULL, NULL, (const ccMenuCallback&)nullptr); } CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage) { - return CCMenuItemImage::create(normalImage, selectedImage, NULL, (const ccMenuCallback&)NULL); + return CCMenuItemImage::create(normalImage, selectedImage, NULL, (const ccMenuCallback&)nullptr); } // XXX deprecated @@ -773,7 +775,7 @@ CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *s CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage) { CCMenuItemImage *pRet = new CCMenuItemImage(); - if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)NULL)) + if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)nullptr)) { pRet->autorelease(); return pRet; @@ -846,6 +848,7 @@ CCArray* CCMenuItemToggle::getSubItems() return m_pSubItems; } +// XXX: deprecated CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems) { CCMenuItemToggle *pRet = new CCMenuItemToggle(); @@ -864,6 +867,25 @@ CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_Menu return pRet; } +CCMenuItemToggle * CCMenuItemToggle::createWithCallback(const ccMenuCallback &callback, CCArray* menuItems) +{ + CCMenuItemToggle *pRet = new CCMenuItemToggle(); + pRet->CCMenuItem::initWithCallback(callback); + pRet->m_pSubItems = CCArray::create(); + pRet->m_pSubItems->retain(); + + for (unsigned int z=0; z < menuItems->count(); z++) + { + CCMenuItem* menuItem = (CCMenuItem*)menuItems->objectAtIndex(z); + pRet->m_pSubItems->addObject(menuItem); + } + + pRet->m_uSelectedIndex = UINT_MAX; + pRet->setSelectedIndex(0); + return pRet; +} + +// XXX: deprecated CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) { va_list args; @@ -875,6 +897,17 @@ CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_Menu return pRet; } +CCMenuItemToggle * CCMenuItemToggle::createWithCallback(const ccMenuCallback &callback, CCMenuItem* item, ...) +{ + va_list args; + va_start(args, item); + CCMenuItemToggle *pRet = new CCMenuItemToggle(); + pRet->initWithCallback(callback, item, args); + pRet->autorelease(); + va_end(args); + return pRet; +} + CCMenuItemToggle * CCMenuItemToggle::create() { CCMenuItemToggle *pRet = new CCMenuItemToggle(); @@ -883,14 +916,22 @@ CCMenuItemToggle * CCMenuItemToggle::create() return pRet; } +// XXX: deprecated bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args) { - CCMenuItem::initWithTarget(target, selector); + _target = target; + CC_SAFE_RETAIN(_target); + return initWithCallback(std::bind( selector, target, std::placeholders::_1), item, args); +} + +bool CCMenuItemToggle::initWithCallback(const ccMenuCallback &callback, CCMenuItem *item, va_list args) +{ + CCMenuItem::initWithCallback(callback); this->m_pSubItems = CCArray::create(); this->m_pSubItems->retain(); int z = 0; CCMenuItem *i = item; - while(i) + while(i) { z++; m_pSubItems->addObject(i); @@ -911,7 +952,7 @@ CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item) bool CCMenuItemToggle::initWithItem(CCMenuItem *item) { - CCMenuItem::initWithCallback((const ccMenuCallback&)NULL); + CCMenuItem::initWithCallback((const ccMenuCallback&)nullptr); setSubItems(CCArray::create()); if (item) diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index ca34e8d08c..1ed8c52def 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -71,7 +71,7 @@ public: , m_bEnabled(false) , m_nScriptTapHandler(0) , _target(NULL) - , _callback(NULL) + , _callback(nullptr) {} virtual ~CCMenuItem(); @@ -374,12 +374,12 @@ public: /** creates a menu item from a CCArray with a target selector */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle * createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems); /** creates a menu item from a CCArray with a callable object */ - static CCMenuItemToggle * createWithTarget(const ccMenuCallback& callback, CCArray* menuItems); + static CCMenuItemToggle * createWithCallback(const ccMenuCallback& callback, CCArray* menuItems); /** creates a menu item from a list of items with a target/selector */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); /** creates a menu item from a list of items with a callable object */ - static CCMenuItemToggle* createWithTarget(const ccMenuCallback& callback, CCMenuItem* item, ...); + static CCMenuItemToggle* createWithCallback(const ccMenuCallback& callback, CCMenuItem* item, ...); /** creates a menu item with no target/selector and no items */ static CCMenuItemToggle* create(); @@ -387,7 +387,7 @@ public: /** initializes a menu item from a list of items with a target selector */ CC_DEPRECATED_ATTRIBUTE bool initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args); /** initializes a menu item from a list of items with a callable object */ - bool initWithTarget(const ccMenuCallback& callback, CCMenuItem* item, va_list args); + bool initWithCallback(const ccMenuCallback& callback, CCMenuItem* item, va_list args); /** creates a menu item with a item */ static CCMenuItemToggle* create(CCMenuItem *item); diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index 976684246f..458a814561 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -166,7 +166,7 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h bool CCEGLViewProtocol::isScissorEnabled() { - return glIsEnabled(GL_SCISSOR_TEST); + return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true; } CCRect CCEGLViewProtocol::getScissorRect() diff --git a/cocos2dx/platform/android/CCFileUtilsAndroid.cpp b/cocos2dx/platform/android/CCFileUtilsAndroid.cpp index 2bcf2397ea..5340f61d78 100644 --- a/cocos2dx/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos2dx/platform/android/CCFileUtilsAndroid.cpp @@ -118,10 +118,11 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch return 0; } - if (pszFileName[0] != '/') + string fullPath = fullPathForFilename(pszFileName); + + if (fullPath[0] != '/') { //CCLOG("GETTING FILE RELATIVE DATA: %s", pszFileName); - string fullPath = fullPathForFilename(pszFileName); pData = s_pZipFile->getFileData(fullPath.c_str(), pSize); } else @@ -130,7 +131,7 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch { // read rrom other path than user set it //CCLOG("GETTING FILE ABSOLUTE DATA: %s", pszFileName); - FILE *fp = fopen(pszFileName, pszMode); + FILE *fp = fopen(fullPath.c_str(), pszMode); CC_BREAK_IF(!fp); unsigned long size; diff --git a/cocos2dx/platform/android/java/project.properties b/cocos2dx/platform/android/java/project.properties index 4a46b9d1c9..cd0ca122a3 100644 --- a/cocos2dx/platform/android/java/project.properties +++ b/cocos2dx/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-17 +target=android-8 diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java index a21cd23af2..fd4cd81954 100644 --- a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java +++ b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxETCLoader.java @@ -65,7 +65,6 @@ public class Cocos2dxETCLoader { texture = ETC1Util.createTexture(inputStream); inputStream.close(); - assetManager.close(); } catch (Exception e) { Log.d("Cocos2dx", "Unable to create texture for " + filePath); @@ -73,24 +72,29 @@ public class Cocos2dxETCLoader { } if (texture != null) { + boolean ret = true; + try { - int width = texture.getWidth(); - int height = texture.getHeight(); + final int width = texture.getWidth(); + final int height = texture.getHeight(); + final int length = texture.getData().remaining(); - final byte[] data = new byte[width * height * 3]; + final byte[] data = new byte[length]; final ByteBuffer buf = ByteBuffer.wrap(data); buf.order(ByteOrder.nativeOrder()); buf.put(texture.getData()); nativeSetTextureInfo(width, height, - data); + data, + length); } catch (Exception e) { Log.d("invoke native function error", e.toString()); + ret = false; } - return true; + return ret; } else { return false; } @@ -100,5 +104,6 @@ public class Cocos2dxETCLoader { Cocos2dxETCLoader.context = context; } - private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data); + private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data, + final int dataLength); } diff --git a/cocos2dx/platform/mac/CCDirectorCaller.mm b/cocos2dx/platform/mac/CCDirectorCaller.mm index 46309ee5b0..424528612a 100755 --- a/cocos2dx/platform/mac/CCDirectorCaller.mm +++ b/cocos2dx/platform/mac/CCDirectorCaller.mm @@ -59,7 +59,7 @@ static id s_sharedDirectorCaller; -(void) dealloc { s_sharedDirectorCaller = nil; - CCLOG("cocos2d: deallocing CCDirectorCaller %x", self); + CCLOG("cocos2d: deallocing CCDirectorCaller %p", self); if (displayLink) { CVDisplayLinkRelease(displayLink); } diff --git a/cocos2dx/platform/mac/CCEGLView.mm b/cocos2dx/platform/mac/CCEGLView.mm index b098e8a1f8..d709a3d5d8 100755 --- a/cocos2dx/platform/mac/CCEGLView.mm +++ b/cocos2dx/platform/mac/CCEGLView.mm @@ -47,7 +47,7 @@ CCEGLView::CCEGLView(void) CCEGLView::~CCEGLView(void) { - CCLOG("cocos2d: deallocing CCEGLView %0x", this); + CCLOG("cocos2d: deallocing CCEGLView %p", this); s_sharedView = NULL; } diff --git a/cocos2dx/platform/marmalade/CCImage.cpp b/cocos2dx/platform/marmalade/CCImage.cpp index 96e6da535d..930fe578b9 100644 --- a/cocos2dx/platform/marmalade/CCImage.cpp +++ b/cocos2dx/platform/marmalade/CCImage.cpp @@ -579,7 +579,7 @@ bool CCImage::initWithImageData(void * pData, } else if (kFmtRawData == eFmt) { - bRet = _initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent); + bRet = _initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); break; } else @@ -1074,7 +1074,7 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) return bRet; } -bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent) +bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti) { bool bRet = false; do diff --git a/cocos2dx/platform/tizen/CCGL.h b/cocos2dx/platform/tizen/CCGL.h index b034370bd8..5bbffbf198 100644 --- a/cocos2dx/platform/tizen/CCGL.h +++ b/cocos2dx/platform/tizen/CCGL.h @@ -29,8 +29,6 @@ THE SOFTWARE. #include using namespace Tizen::Graphics::Opengl; -typedef char GLchar; - #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #define glClearDepth glClearDepthf diff --git a/cocos2dx/platform/tizen/CCStdC.h b/cocos2dx/platform/tizen/CCStdC.h index 8e983e6f74..92c5eafdac 100644 --- a/cocos2dx/platform/tizen/CCStdC.h +++ b/cocos2dx/platform/tizen/CCStdC.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include #include +#include #include #ifndef MIN @@ -40,4 +41,6 @@ THE SOFTWARE. #define MAX(x,y) (((x) < (y)) ? (y) : (x)) #endif // MAX +#define nullptr __null + #endif // __CC_STD_C_H__ diff --git a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id index 4bb1923ca5..f27e968293 100644 --- a/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2dx/proj.mac/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -125800bcfe2802d3c6a965a3aa337147d20bf187 \ No newline at end of file +5b8ea64c349dcc515312773df1d8d0d5d20abfbe \ No newline at end of file diff --git a/cocos2dx/proj.tizen/.cproject b/cocos2dx/proj.tizen/.cproject index 987b801a5b..476d53feb0 100644 --- a/cocos2dx/proj.tizen/.cproject +++ b/cocos2dx/proj.tizen/.cproject @@ -30,12 +30,12 @@ - + @@ -65,14 +64,15 @@ + - + @@ -102,12 +101,11 @@ - + diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index 85c11e51fa..e0b48e4cad 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -57,7 +57,7 @@ CCGLProgram::CCGLProgram() CCGLProgram::~CCGLProgram() { - CCLOGINFO("cocos2d: %s %d deallocing 0x%X", __FUNCTION__, __LINE__, this); + CCLOGINFO("cocos2d: %s %d deallocing %p", __FUNCTION__, __LINE__, this); // there is no need to delete the shaders. They should have been already deleted. CCAssert(m_uVertShader == 0, "Vertex Shaders should have been already deleted"); diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index 2a07de9a52..dcf155f77f 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -71,7 +71,7 @@ CCShaderCache::CCShaderCache() CCShaderCache::~CCShaderCache() { - CCLOGINFO("cocos2d deallocing 0x%X", this); + CCLOGINFO("cocos2d deallocing %p", this); m_pPrograms->release(); } diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 96076ea83b..46ed14050c 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -51,7 +51,7 @@ bool CCAnimationFrame::initWithSpriteFrame(CCSpriteFrame* spriteFrame, float del CCAnimationFrame::~CCAnimationFrame() { - CCLOGINFO( "cocos2d: deallocing %s", this); + CCLOGINFO( "cocos2d: deallocing %p", this); CC_SAFE_RELEASE(m_pSpriteFrame); CC_SAFE_RELEASE(m_pUserInfo); diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index b0dea7ca5a..336130abe5 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -153,8 +153,6 @@ bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect, bool r if (CCNodeRGBA::init()) { m_pobBatchNode = NULL; - // shader program - setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor)); m_bRecursiveDirty = false; setDirty(false); @@ -556,17 +554,13 @@ void CCSprite::draw(void) if (m_pobTexture != NULL) { ccGLBindTexture2D( m_pobTexture->getName() ); + ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex ); } else { ccGLBindTexture2D(0); + ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color ); } - - // - // Attributes - // - - ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex ); #define kQuadSize sizeof(m_sQuad.bl) #ifdef EMSCRIPTEN @@ -580,10 +574,13 @@ void CCSprite::draw(void) int diff = offsetof( ccV3F_C4B_T2F, vertices); glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - // texCoods - diff = offsetof( ccV3F_C4B_T2F, texCoords); - glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - + if (m_pobTexture != NULL) + { + // texCoods + diff = offsetof( ccV3F_C4B_T2F, texCoords); + glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + } + // color diff = offsetof( ccV3F_C4B_T2F, colors); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); @@ -1085,6 +1082,16 @@ void CCSprite::setTexture(CCTexture2D *texture) // accept texture==nil as argument CCAssert( !texture || dynamic_cast(texture), "setTexture expects a CCTexture2D. Invalid argument"); + // shader program + if (texture) + { + setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor)); + } + else + { + setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionColor)); + } + if (!m_pobBatchNode && m_pobTexture != texture) { CC_SAFE_RETAIN(texture); diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index a70d6e47bc..c22207f1d9 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -207,7 +207,7 @@ CCTextureCache::CCTextureCache() CCTextureCache::~CCTextureCache() { - CCLOGINFO("cocos2d: deallocing CCTextureCache."); + CCLOGINFO("cocos2d: deallocing CCTextureCache: %p", this); need_quit = true; pthread_cond_signal(&s_SleepCondition); @@ -232,6 +232,7 @@ CCDictionary* CCTextureCache::snapshotTextures() { pRet->setObject(pElement->getObject(), pElement->getStrKey()); } + pRet->autorelease(); return pRet; } diff --git a/cocos2dx/textures/CCTextureETC.cpp b/cocos2dx/textures/CCTextureETC.cpp index a6189aa19b..bd3464b408 100644 --- a/cocos2dx/textures/CCTextureETC.cpp +++ b/cocos2dx/textures/CCTextureETC.cpp @@ -81,11 +81,11 @@ static unsigned int sLength = 0; extern "C" { - JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data) + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data, jint dataLength) { sWidth = (unsigned int)width; sHeight = (unsigned int)height; - sLength = sWidth * sHeight * 3; + sLength = dataLength; sData = new unsigned char[sLength]; env->GetByteArrayRegion(data, 0, sLength, (jbyte*)sData); } diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 73282426c8..c9ac84a89d 100644 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -242,7 +242,7 @@ CCTexturePVR::CCTexturePVR() CCTexturePVR::~CCTexturePVR() { - CCLOGINFO( "cocos2d: deallocing CCTexturePVR" ); + CCLOGINFO( "cocos2d: deallocing CCTexturePVR: %p", this ); if (m_uName != 0 && ! m_bRetainName) { diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp index 806b7673a6..f4a68ae684 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp @@ -41,7 +41,7 @@ CCTMXObjectGroup::CCTMXObjectGroup() } CCTMXObjectGroup::~CCTMXObjectGroup() { - CCLOGINFO( "cocos2d: deallocing."); + CCLOGINFO( "cocos2d: deallocing: %p", this); CC_SAFE_RELEASE(m_pObjects); CC_SAFE_RELEASE(m_pProperties); } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp index 09986b6783..f0f7df6b5a 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXXMLParser.cpp @@ -78,7 +78,7 @@ CCTMXLayerInfo::CCTMXLayerInfo() CCTMXLayerInfo::~CCTMXLayerInfo() { - CCLOGINFO("cocos2d: deallocing."); + CCLOGINFO("cocos2d: deallocing: %p", this); CC_SAFE_RELEASE(m_pProperties); if( m_bOwnTiles && m_pTiles ) { @@ -108,7 +108,7 @@ CCTMXTilesetInfo::CCTMXTilesetInfo() } CCTMXTilesetInfo::~CCTMXTilesetInfo() { - CCLOGINFO("cocos2d: deallocing."); + CCLOGINFO("cocos2d: deallocing: %p", this); } CCRect CCTMXTilesetInfo::rectForGID(unsigned int gid) { @@ -208,7 +208,7 @@ CCTMXMapInfo::CCTMXMapInfo() CCTMXMapInfo::~CCTMXMapInfo() { - CCLOGINFO("cocos2d: deallocing."); + CCLOGINFO("cocos2d: deallocing: %p", this); CC_SAFE_RELEASE(m_pTilesets); CC_SAFE_RELEASE(m_pLayers); CC_SAFE_RELEASE(m_pProperties); diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 42a5efd1d5..44df950e6b 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -621,7 +621,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { // Read properties ccNodeLoader->parseProperties(node, pParent, this); - bool isCCBFileNode = dynamic_cast(node); + bool isCCBFileNode = (NULL == dynamic_cast(node)) ? false : true; // Handle sub ccb files (remove middle node) if (isCCBFileNode) { diff --git a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp index e96ddbdf58..984f459b5b 100644 --- a/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp +++ b/extensions/GUI/CCControlExtension/CCControlColourPicker.cpp @@ -46,24 +46,9 @@ CCControlColourPicker::CCControlColourPicker() CCControlColourPicker::~CCControlColourPicker() { - if (m_background) - { - m_background->removeFromParentAndCleanup(true); - } - - if (m_huePicker) - { - m_huePicker->removeFromParentAndCleanup(true); - } - - if (m_colourPicker) - { - m_colourPicker->removeFromParentAndCleanup(true); - } - - m_background = NULL; - m_huePicker = NULL; - m_colourPicker = NULL; + CC_SAFE_RELEASE(m_background); + CC_SAFE_RELEASE(m_huePicker); + CC_SAFE_RELEASE(m_colourPicker); } bool CCControlColourPicker::init() @@ -94,7 +79,8 @@ bool CCControlColourPicker::init() // Add image m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPointZero, ccp(0.5f, 0.5f)); - + CC_SAFE_RETAIN(m_background); + CCPoint backgroundPointZero = ccpSub(m_background->getPosition(), ccp (m_background->getContentSize().width / 2, m_background->getContentSize().height / 2)); // Setup panels diff --git a/extensions/network/WebSocket.cpp b/extensions/network/WebSocket.cpp index 93ecea4157..6c34de6e88 100644 --- a/extensions/network/WebSocket.cpp +++ b/extensions/network/WebSocket.cpp @@ -21,6 +21,10 @@ LIABILITY, WHETHER IN AN ACTION 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" @@ -553,6 +557,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, CC_SAFE_DELETE(data); CC_SAFE_DELETE_ARRAY(buf); } + + CC_SAFE_DELETE(subThreadMsg); } _wsHelper->_subThreadWsMessageQueue->clear(); diff --git a/extensions/network/WebSocket.h b/extensions/network/WebSocket.h index 068f341d60..e764e16704 100644 --- a/extensions/network/WebSocket.h +++ b/extensions/network/WebSocket.h @@ -21,6 +21,10 @@ LIABILITY, WHETHER IN AN ACTION 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__ diff --git a/extensions/proj.tizen/.cproject b/extensions/proj.tizen/.cproject index 67b2850444..ccbb1ef2f5 100644 --- a/extensions/proj.tizen/.cproject +++ b/extensions/proj.tizen/.cproject @@ -30,18 +30,19 @@ - + @@ -69,14 +69,15 @@ + - + @@ -108,12 +108,11 @@ - + diff --git a/extensions/spine/spine-cocos2dx.cpp b/extensions/spine/spine-cocos2dx.cpp index bcb2394116..bfbc93d99d 100644 --- a/extensions/spine/spine-cocos2dx.cpp +++ b/extensions/spine/spine-cocos2dx.cpp @@ -35,8 +35,11 @@ void _AtlasPage_createTexture (AtlasPage* self, const char* path) { CCTextureAtlas* textureAtlas = CCTextureAtlas::createWithTexture(texture, 4); textureAtlas->retain(); self->rendererObject = textureAtlas; - self->width = texture->getPixelsWide(); - self->height = texture->getPixelsHigh(); + // 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 _AtlasPage_disposeTexture (AtlasPage* self) { diff --git a/external/libwebsockets/tizen/include/libwebsockets.h b/external/libwebsockets/tizen/include/libwebsockets.h new file mode 100644 index 0000000000..28e649c67e --- /dev/null +++ b/external/libwebsockets/tizen/include/libwebsockets.h @@ -0,0 +1,977 @@ +/* + * 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; + +#ifdef LWS_DLL +#ifdef LWS_INTERNAL +#define LWS_EXTERN extern __declspec(dllexport) +#else +#define LWS_EXTERN extern __declspec(dllimport) +#endif +#endif + +#else // NOT WIN32 +#include +#include +#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_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_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_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_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_EXTERN +void lws_set_log_level(int level, + void (*log_emit_function)(int level, const char *line)); + +LWS_EXTERN void +lwsl_emit_syslog(int level, const char *line); + +LWS_EXTERN struct libwebsocket_context * +libwebsocket_create_context(struct lws_context_creation_info *info); + +LWS_EXTERN void +libwebsocket_context_destroy(struct libwebsocket_context *context); + +LWS_EXTERN int +libwebsocket_service(struct libwebsocket_context *context, int timeout_ms); + +LWS_EXTERN int +libwebsocket_service_fd(struct libwebsocket_context *context, + struct pollfd *pollfd); + +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); + * + * 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_EXTERN int +libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len, + enum libwebsocket_write_protocol protocol); + +LWS_EXTERN int +libwebsockets_serve_http_file(struct libwebsocket_context *context, + struct libwebsocket *wsi, const char *file, + const char *content_type); +LWS_EXTERN int +libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +LWS_EXTERN const struct libwebsocket_protocols * +libwebsockets_get_protocol(struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_callback_on_writable(struct libwebsocket_context *context, + struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_callback_on_writable_all_protocol( + const struct libwebsocket_protocols *protocol); + +LWS_EXTERN int +libwebsocket_get_socket_fd(struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_is_final_fragment(struct libwebsocket *wsi); + +LWS_EXTERN unsigned char +libwebsocket_get_reserved_bits(struct libwebsocket *wsi); + +LWS_EXTERN int +libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable); + +LWS_EXTERN size_t +libwebsockets_remaining_packet_payload(struct libwebsocket *wsi); + +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_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_EXTERN const char * +libwebsocket_canonical_hostname(struct libwebsocket_context *context); + + +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_EXTERN int +libwebsockets_get_random(struct libwebsocket_context *context, + void *buf, int len); + +LWS_EXTERN int +lws_daemonize(const char *_lock_path); + +LWS_EXTERN int +lws_send_pipe_choked(struct libwebsocket *wsi); + +LWS_EXTERN int +lws_frame_is_binary(struct libwebsocket *wsi); + +LWS_EXTERN unsigned char * +libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md); + +LWS_EXTERN int +lws_b64_encode_string(const char *in, int in_len, char *out, int out_size); + +LWS_EXTERN int +lws_b64_decode_string(const char *in, char *out, int out_size); + +LWS_EXTERN const char * +lws_get_library_version(void); + +/* access to headers... only valid while headers valid */ + +LWS_EXTERN int +lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h); + +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_EXTERN int +libwebsocket_read(struct libwebsocket_context *context, + struct libwebsocket *wsi, + unsigned char *buf, size_t len); + +#ifndef LWS_NO_EXTENSIONS +LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/external/libwebsockets/tizen/lib/x86/libwebsockets.a.REMOVED.git-id b/external/libwebsockets/tizen/lib/x86/libwebsockets.a.REMOVED.git-id new file mode 100644 index 0000000000..7e29b6b4fa --- /dev/null +++ b/external/libwebsockets/tizen/lib/x86/libwebsockets.a.REMOVED.git-id @@ -0,0 +1 @@ +2e9ff412352827591ef1389f336b01d179260293 \ No newline at end of file diff --git a/plugin/samples/HelloSocial/proj.ios/HelloSocial.xcodeproj/project.pbxproj b/plugin/samples/HelloSocial/proj.ios/HelloSocial.xcodeproj/project.pbxproj index 56870434aa..17749feeef 100644 --- a/plugin/samples/HelloSocial/proj.ios/HelloSocial.xcodeproj/project.pbxproj +++ b/plugin/samples/HelloSocial/proj.ios/HelloSocial.xcodeproj/project.pbxproj @@ -551,8 +551,6 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CODE_SIGN_IDENTITY = "iPhone Developer: 彬 张 (BE3QDJTL78)"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: 彬 张 (BE3QDJTL78)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -568,8 +566,6 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - CODE_SIGN_IDENTITY = "iPhone Developer: 彬 张 (BE3QDJTL78)"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: 彬 张 (BE3QDJTL78)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; diff --git a/samples/Cpp/HelloCpp/proj.tizen/.cproject b/samples/Cpp/HelloCpp/proj.tizen/.cproject index c145fac350..c6b75243bc 100644 --- a/samples/Cpp/HelloCpp/proj.tizen/.cproject +++ b/samples/Cpp/HelloCpp/proj.tizen/.cproject @@ -25,12 +25,12 @@ - + @@ -58,14 +57,15 @@ + - + @@ -96,7 +95,7 @@ - + + - + @@ -99,7 +98,7 @@ - + @@ -65,14 +66,15 @@ + - + @@ -103,7 +104,7 @@ - + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index 3a4146d74a..5509d36bce 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -129,6 +129,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + @@ -226,6 +227,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index 68a799d585..bbb5b046cf 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -513,6 +513,9 @@ Classes\ExtensionsTest\NetworkTest + + Classes + @@ -980,5 +983,8 @@ Classes\ExtensionsTest\NetworkTest + + Classes + \ No newline at end of file diff --git a/samples/Javascript/MoonWarriors/proj.ios/MoonWarriors.xcodeproj/project.pbxproj b/samples/Javascript/MoonWarriors/proj.ios/MoonWarriors.xcodeproj/project.pbxproj index 55e4fcb618..7ef6a64af7 100644 --- a/samples/Javascript/MoonWarriors/proj.ios/MoonWarriors.xcodeproj/project.pbxproj +++ b/samples/Javascript/MoonWarriors/proj.ios/MoonWarriors.xcodeproj/project.pbxproj @@ -633,7 +633,7 @@ PUBLIC_HEADERS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/Headers"; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; - VALID_ARCHS = "armv7 armv7s"; + VALID_ARCHS = "armv7 armv7s i386"; WRAPPER_EXTENSION = app; }; name = Debug; @@ -680,7 +680,7 @@ TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = ""; VALIDATE_PRODUCT = YES; - VALID_ARCHS = "armv7 armv7s"; + VALID_ARCHS = "armv7 armv7s i386"; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/samples/Javascript/TestJavascript/proj.ios/AppController.mm b/samples/Javascript/TestJavascript/proj.ios/AppController.mm index 3e3e5c9474..55052cbae8 100644 --- a/samples/Javascript/TestJavascript/proj.ios/AppController.mm +++ b/samples/Javascript/TestJavascript/proj.ios/AppController.mm @@ -35,6 +35,8 @@ static AppDelegate s_sharedApplication; multiSampling: NO numberOfSamples: 0 ]; + [__glView setMultipleTouchEnabled:YES]; + // Use RootViewController manage EAGLView viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; viewController.wantsFullScreenLayout = YES; diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index d24fac5c54..6aef63aacc 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -1984,15 +1984,16 @@ void* serverEntryPoint(void*) struct addrinfo hints, *result, *rp; int s; memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; // TCP + 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 - int err; stringstream portstr; portstr << JSB_DEBUGGER_PORT; - const char* tmp = portstr.str().c_str(); - if ((err = getaddrinfo(NULL, tmp, &hints, &result)) != 0) { - printf("error: %s\n", gai_strerror(err)); + + int err; + 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) { diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 71562d8f33..5d0f36f011 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 71562d8f336df63d6d2dc01fbe0d04e8619ecf62 +Subproject commit 5d0f36f011c4b9ed067fb42dc6529bdb58deb9a5 diff --git a/template/multi-platform-cpp/proj.ios/AppController.mm b/template/multi-platform-cpp/proj.ios/AppController.mm index 18674885a0..0ed0be670a 100644 --- a/template/multi-platform-cpp/proj.ios/AppController.mm +++ b/template/multi-platform-cpp/proj.ios/AppController.mm @@ -35,7 +35,6 @@ static AppDelegate s_sharedApplication; sharegroup: nil multiSampling: NO numberOfSamples: 0]; - [__glView setMultipleTouchEnabled:YES]; // Use RootViewController manage EAGLView viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; diff --git a/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 8c59a7ab7b..2e2ea8802b 100644 --- a/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/template/multi-platform-cpp/proj.ios/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -2a27890e1483789f1497834fc5492f39f55d826b \ No newline at end of file +87923a8737ed83b909261c3468098a1c46753969 \ No newline at end of file diff --git a/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id b/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id index 4e56c68fc2..71bb7258c2 100644 --- a/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/template/multi-platform-cpp/proj.mac/HelloCpp.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -f9f78f7848a9ee31f7c4c919fca1555101c48767 \ No newline at end of file +0422f35db193be5e4c66e50b80ced4175aea416c \ No newline at end of file diff --git a/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj b/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj index 28ec791200..a68139f692 100644 --- a/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj +++ b/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj @@ -77,7 +77,7 @@ 4267;4251;4244;%(DisableSpecificWarnings) - libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;pthreadVCE2.lib;%(AdditionalDependencies) + libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;pthreadVCE2.lib;websockets.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -88,6 +88,10 @@ + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" + @@ -104,7 +108,7 @@ 4267;4251;4244;%(DisableSpecificWarnings) - libcocos2d.lib;libCocosDenshion.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libExtensions.lib;pthreadVCE2.lib;%(AdditionalDependencies) + libExtensions.lib;libcocos2d.lib;libCocosDenshion.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;pthreadVCE2.lib;websockets.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -117,6 +121,10 @@ + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" + diff --git a/template/multi-platform-js/proj.ios/AppController.mm b/template/multi-platform-js/proj.ios/AppController.mm index ce9bb75462..5910da0d35 100644 --- a/template/multi-platform-js/proj.ios/AppController.mm +++ b/template/multi-platform-js/proj.ios/AppController.mm @@ -28,6 +28,8 @@ static AppDelegate s_sharedApplication; sharegroup: nil multiSampling: NO numberOfSamples: 0 ]; + + [__glView setMultipleTouchEnabled:YES]; // Use RootViewController manage EAGLView viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj index 7e7788bdf3..4011e819b9 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj +++ b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj @@ -94,10 +94,10 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" - +xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;pthreadVCE2.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;pthreadVCE2.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -148,10 +148,10 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" xcopy /Y /Q "$(ProjectDir)..\..\..\scripting\javascript\spidermonkey-win32\lib\*.*" "$(OutDir)" - +xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" - libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;pthreadVCE2.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;libchipmunk.lib;libJSBinding.lib;libcurl_imp.lib;mozjs.lib;ws2_32.lib;sqlite3.lib;pthreadVCE2.lib;websockets.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/template/multi-platform-lua/proj.ios/AppController.mm b/template/multi-platform-lua/proj.ios/AppController.mm index cbccc23254..2218aac5e4 100644 --- a/template/multi-platform-lua/proj.ios/AppController.mm +++ b/template/multi-platform-lua/proj.ios/AppController.mm @@ -51,6 +51,7 @@ static AppDelegate s_sharedApplication; multiSampling: NO numberOfSamples: 0 ]; + [__glView setMultipleTouchEnabled:YES]; // Use RootViewController manage EAGLView viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; viewController.wantsFullScreenLayout = YES; diff --git a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj index ccb952cd36..90da9385fe 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj +++ b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj @@ -79,7 +79,7 @@ MachineX86 true $(OutDir);%(AdditionalLibraryDirectories) - libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) 0x0409 @@ -104,6 +104,10 @@ + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" + @@ -123,7 +127,7 @@ Windows MachineX86 $(OutDir);%(AdditionalLibraryDirectories) - libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;%(AdditionalDependencies) + libcocos2d.lib;libExtensions.lib;opengl32.lib;glew32.lib;libBox2d.lib;libchipmunk.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;websockets.lib;%(AdditionalDependencies) 0x0409 @@ -148,20 +152,16 @@ + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\..\..\external\libwebsockets\win32\lib\*.*" "$(OutDir)" + - - - - - - - - diff --git a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj.filters b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj.filters index 99c727af38..593b960878 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj.filters +++ b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj.filters @@ -15,10 +15,6 @@ win32 - - - - @@ -27,9 +23,5 @@ win32 - - - - \ No newline at end of file diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 4b47d76c41..8d1da651d5 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -47,7 +47,7 @@ skip = CCNode::[convertToWindowSpace ^setPosition$ getGrid setGLServerState desc CCDirector::[getAccelerometer getKeypadDispatcher getTouchDispatcher setWatcherCallbackFun getOpenGLView getProjection getClassTypeInfo], CCLayer.*::[didAccelerate (g|s)etBlendFunc], CCMenu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns], - CCMenuItem.*::[create setCallback], + CCMenuItem.*::[create setCallback initWithCallback], CCCopying::[*], CC.*Protocol::[*], CC.*Delegate::[*],