mirror of https://github.com/axmolengine/axmol.git
154 lines
6.1 KiB
C
154 lines
6.1 KiB
C
/****************************************************************************
|
|
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 __CCX_MACROS_H_YANGWS_20110111__
|
|
#define __CCX_MACROS_H_YANGWS_20110111__
|
|
|
|
#include "ccxConfig.h"
|
|
|
|
// generic macros
|
|
|
|
// namespace cocos2d {}
|
|
#define NS_CC_BEGIN namespace cocos2d {
|
|
#define NS_CC_END }
|
|
#define USING_NS_CC using namespace cocos2d
|
|
|
|
/** CCX_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 CCX_PROPERTY_READONLY are all public.
|
|
If you need protected or private, please declare.
|
|
*/
|
|
#define CCX_PROPERTY_READONLY(varType, varName, funName)\
|
|
protected: varType varName;\
|
|
public: virtual varType get##funName(void);
|
|
|
|
/** CCX_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 CCX_PROPERTY are all public.
|
|
If you need protected or private, please declare.
|
|
*/
|
|
#define CCX_PROPERTY(varType, varName, funName)\
|
|
protected: varType varName;\
|
|
public: virtual varType get##funName(void);\
|
|
public: virtual void set##funName(varType var);
|
|
|
|
/** CCX_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 CCX_SYNTHESIZE_READONLY are all public.
|
|
If you need protected or private, please declare.
|
|
*/
|
|
#define CCX_SYNTHESIZE_READONLY(varType, varName, funName)\
|
|
protected: varType varName;\
|
|
public: inline varType get##funName(void) const { return varName; }
|
|
|
|
/** CCX_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 CCX_SYNTHESIZE are all public.
|
|
If you need protected or private, please declare.
|
|
*/
|
|
#define CCX_SYNTHESIZE(varType, varName, funName)\
|
|
protected: varType varName;\
|
|
public: inline varType get##funName(void) const { return varName; }\
|
|
public: inline void set##funName(varType var){ varName = var; }
|
|
|
|
#define CCX_SAFE_DELETE(p) if(p) { delete p; p = 0; }
|
|
#define CCX_SAFE_DELETE_ARRAY(p) if(p) { delete[] p; p = 0; }
|
|
#define CCX_SAFE_FREE(p) if(p) { free(p); p = 0; }
|
|
#define CCX_SAFE_RELEASE(p) if(p) { p->release(); }
|
|
#define CCX_SAFE_RELEASE_NULL(p) if(p) { p->release(); p = 0; }
|
|
#define CCX_SAFE_RETAIN(p) if(p) { p->retain(); }
|
|
#define CCX_BREAK_IF(cond) if(cond) break;
|
|
|
|
|
|
// cocos2d debug
|
|
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
|
|
#define CCLOG(...) do {} while (0)
|
|
#define CCLOGINFO(...) do {} while (0)
|
|
#define CCLOGERROR(...) do {} while (0)
|
|
|
|
#elif COCOS2D_DEBUG == 1
|
|
#define CCLOG(format, ...) cocos2d::CCXLog(format, ##__VA_ARGS__)
|
|
#define CCLOGERROR(format,...) cocos2d::CCXLog(format, ##__VA_ARGS__)
|
|
#define CCLOGINFO(format,...) do {} while (0)
|
|
|
|
#elif COCOS2D_DEBUG > 1
|
|
#define CCLOG(format, ...) cocos2d::CCXLog(format, ##__VA_ARGS__)
|
|
#define CCLOGERROR(format,...) cocos2d::CCXLog(format, ##__VA_ARGS__)
|
|
#define CCLOGINFO(format,...) cocos2d::CCXLog(format, ##__VA_ARGS__)
|
|
#endif // COCOS2D_DEBUG
|
|
|
|
// shared library declartor
|
|
#define CCX_DLL
|
|
|
|
// assertion
|
|
#include <assert.h>
|
|
#define CCX_ASSERT(cond) assert(cond)
|
|
|
|
// platform depended macros
|
|
|
|
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_WIN32)
|
|
|
|
#undef CCX_DLL
|
|
#if defined(_USRDLL)
|
|
#define CCX_DLL __declspec(dllexport)
|
|
#else /* use a DLL library */
|
|
#define CCX_DLL __declspec(dllimport)
|
|
#endif
|
|
|
|
#endif // CCX_PLATFORM_WIN32
|
|
|
|
#if (CCX_TARGET_PLATFORM == CCX_PLATFORM_UPHONE && defined(_TRANZDA_VM_))
|
|
|
|
#undef CCX_DLL
|
|
#if defined(SS_MAKEDLL)
|
|
#define CCX_DLL __declspec(dllexport)
|
|
#else /* use a DLL library */
|
|
#define CCX_DLL __declspec(dllimport)
|
|
#endif
|
|
|
|
#endif // uphone VM
|
|
|
|
// shared library declator for platform_support project
|
|
#define CCX_DLL_PS CCX_DLL
|
|
|
|
#endif // __CCX_MACROS_H_YANGWS_20110111__
|