2011-01-07 09:35:27 +08:00
|
|
|
/****************************************************************************
|
|
|
|
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 __CC_PLATFORM_MACROS_H__
|
|
|
|
#define __CC_PLATFORM_MACROS_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
* define some platform specific macros
|
|
|
|
*/
|
2011-01-15 18:05:35 +08:00
|
|
|
#include "ccConfig.h"
|
2011-03-07 17:11:57 +08:00
|
|
|
#include "CCPlatformConfig.h"
|
2011-01-07 09:35:27 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#define MacGLView void
|
|
|
|
#define NSWindow void
|
2011-01-07 09:35:27 +08:00
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
/** @def CC_ENABLE_CACHE_TEXTTURE_DATA
|
|
|
|
Enable it if you want to cache the texture data.
|
|
|
|
Basically,it's only enabled in android
|
|
|
|
|
|
|
|
It's new in cocos2d-x since v0.99.5
|
|
|
|
*/
|
2012-01-09 11:07:45 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
2011-03-09 11:38:36 +08:00
|
|
|
#define CC_ENABLE_CACHE_TEXTTURE_DATA 1
|
|
|
|
#else
|
|
|
|
#define CC_ENABLE_CACHE_TEXTTURE_DATA 0
|
2011-01-10 17:54:44 +08:00
|
|
|
#endif
|
|
|
|
|
2012-04-13 17:24:50 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
2012-04-19 14:35:52 +08:00
|
|
|
/* 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.
|
2012-04-13 17:24:50 +08:00
|
|
|
*/
|
|
|
|
#define CC_REBIND_INDICES_BUFFER 1
|
|
|
|
#else
|
|
|
|
#define CC_REBIND_INDICES_BUFFER 0
|
|
|
|
#endif
|
2011-03-09 11:38:36 +08:00
|
|
|
|
|
|
|
// generic macros
|
|
|
|
|
|
|
|
// namespace cocos2d {}
|
|
|
|
#define NS_CC_BEGIN namespace cocos2d {
|
|
|
|
#define NS_CC_END }
|
|
|
|
#define USING_NS_CC using namespace cocos2d
|
|
|
|
|
|
|
|
/** 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" is 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);
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
#define CC_PROPERTY_READONLY_PASS_BY_REF(varType, varName, funName)\
|
|
|
|
protected: varType varName;\
|
|
|
|
public: virtual const varType& get##funName(void);
|
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
/** 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" is the name of the getter.
|
|
|
|
"set + funName" is 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;\
|
2012-01-09 11:07:45 +08:00
|
|
|
public: virtual varType get##funName(void);\
|
|
|
|
public: virtual void set##funName(varType var);
|
2011-03-09 11:38:36 +08:00
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
#define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)\
|
|
|
|
protected: varType varName;\
|
2012-01-09 11:07:45 +08:00
|
|
|
public: virtual const varType& get##funName(void);\
|
|
|
|
public: virtual void set##funName(const varType& var);
|
2011-08-17 21:19:57 +08:00
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
/** 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" is 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;\
|
2012-01-09 11:07:45 +08:00
|
|
|
public: virtual varType get##funName(void) const { return varName; }
|
2011-03-09 11:38:36 +08:00
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
#define CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)\
|
|
|
|
protected: varType varName;\
|
2012-01-09 11:07:45 +08:00
|
|
|
public: virtual const varType& get##funName(void) const { return varName; }
|
2011-08-17 21:19:57 +08:00
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
/** 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" is the name of the getter.
|
|
|
|
"set + funName" is 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;\
|
2012-01-09 11:07:45 +08:00
|
|
|
public: virtual varType get##funName(void) const { return varName; }\
|
|
|
|
public: virtual void set##funName(varType var){ varName = var; }
|
2011-03-09 11:38:36 +08:00
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
#define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)\
|
|
|
|
protected: varType varName;\
|
2012-01-09 11:07:45 +08:00
|
|
|
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) \
|
2012-03-16 13:42:53 +08:00
|
|
|
private: varType varName; \
|
2012-01-09 11:07:45 +08:00
|
|
|
public: virtual varType get##funName(void) const { return varName; } \
|
|
|
|
public: virtual void set##funName(varType var) \
|
|
|
|
{ \
|
2012-04-19 14:35:52 +08:00
|
|
|
if (varName != var) \
|
|
|
|
{ \
|
|
|
|
CC_SAFE_RETAIN(var); \
|
|
|
|
CC_SAFE_RELEASE(varName); \
|
|
|
|
varName = var; \
|
|
|
|
} \
|
2012-01-09 11:07:45 +08:00
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#define CC_SAFE_DELETE(p) do { if(p) { delete (p); (p) = 0; } } while(0)
|
2012-03-16 13:42:53 +08:00
|
|
|
#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = 0; } } while(0)
|
2012-04-19 14:35:52 +08:00
|
|
|
#define CC_SAFE_FREE(p) do { if(p) { free(p); (p) = 0; } } 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) = 0; } } while(0)
|
|
|
|
#define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0)
|
|
|
|
#define CC_BREAK_IF(cond) if(cond) break
|
2011-03-09 11:38:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
// cocos2d debug
|
|
|
|
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
|
2011-06-10 17:51:37 +08:00
|
|
|
#define CCLOG(...)
|
|
|
|
#define CCLOGINFO(...)
|
|
|
|
#define CCLOGERROR(...)
|
2011-03-09 11:38:36 +08:00
|
|
|
|
|
|
|
#elif COCOS2D_DEBUG == 1
|
|
|
|
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
|
|
|
#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
|
|
|
#define CCLOGINFO(format,...) do {} while (0)
|
|
|
|
|
|
|
|
#elif COCOS2D_DEBUG > 1
|
|
|
|
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
|
|
|
#define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
|
|
|
#define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
|
|
|
#endif // COCOS2D_DEBUG
|
|
|
|
|
2012-02-02 10:37:21 +08:00
|
|
|
// Lua engine debug
|
|
|
|
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 || CC_LUA_ENGINE_DEBUG == 0
|
|
|
|
#define LUALOG(...)
|
|
|
|
#else
|
|
|
|
#define LUALOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
|
|
|
|
#endif // Lua engine debug
|
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
// shared library declartor
|
2011-11-24 17:26:04 +08:00
|
|
|
#define CC_DLL
|
2011-03-09 11:38:36 +08:00
|
|
|
|
2011-09-19 17:53:45 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
|
2011-03-09 11:38:36 +08:00
|
|
|
// assertion
|
|
|
|
#include <assert.h>
|
|
|
|
#define CC_ASSERT(cond) assert(cond)
|
2011-09-19 17:53:45 +08:00
|
|
|
#else
|
2011-11-10 16:44:58 +08:00
|
|
|
// bada platform
|
2011-11-24 17:26:04 +08:00
|
|
|
|
2011-11-10 16:44:58 +08:00
|
|
|
#include <FBaseConfig.h>
|
|
|
|
#include <FBaseSys.h>
|
|
|
|
|
|
|
|
#undef CC_DLL
|
|
|
|
#define CC_DLL _EXPORT_
|
|
|
|
|
|
|
|
#include "CCPlatformFunc_bada.h"
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2011-11-28 18:05:38 +08:00
|
|
|
#define CC_ASSERT(cond) (void)( (!!(cond)) || (badaAssert(__PRETTY_FUNCTION__ , __LINE__ , #cond),0) )
|
2011-11-10 16:44:58 +08:00
|
|
|
#else
|
2011-11-28 14:27:48 +08:00
|
|
|
#define CC_ASSERT(cond) void(0)
|
2011-11-10 16:44:58 +08:00
|
|
|
#endif /* _DEBUG */
|
2011-09-19 17:53:45 +08:00
|
|
|
#endif
|
2011-11-10 16:44:58 +08:00
|
|
|
|
2011-08-10 22:39:02 +08:00
|
|
|
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
2011-06-10 17:51:37 +08:00
|
|
|
|
2011-08-17 11:18:58 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
|
|
|
#undef CC_UNUSED_PARAM
|
|
|
|
#define CC_UNUSED_PARAM(unusedparam) //unusedparam
|
|
|
|
#endif
|
2011-06-10 17:51:37 +08:00
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
|
|
|
|
// platform depended macros
|
|
|
|
|
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
|
|
|
|
|
|
|
#undef CC_DLL
|
|
|
|
#if defined(_USRDLL)
|
|
|
|
#define CC_DLL __declspec(dllexport)
|
2012-04-19 14:35:52 +08:00
|
|
|
#else /* use a DLL library */
|
2011-03-09 11:38:36 +08:00
|
|
|
#define CC_DLL __declspec(dllimport)
|
|
|
|
#endif
|
2011-11-14 11:35:04 +08:00
|
|
|
|
2011-03-09 11:38:36 +08:00
|
|
|
#endif // CC_PLATFORM_WIN32
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-07 09:35:27 +08:00
|
|
|
#endif // __CC_PLATFORM_MACROS_H__
|