2010-07-06 17:27:05 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
2010-07-06 20:55:05 +08:00
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
2010-07-06 17:27:05 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-07-06 17:20:53 +08:00
|
|
|
#ifndef __COCOS2D_DEFINE_H__
|
|
|
|
#define __COCOS2D_DEFINE_H__
|
2010-07-09 15:34:16 +08:00
|
|
|
|
2010-07-09 17:02:00 +08:00
|
|
|
/** CCX_PROPERTY_READONLY is used to declare a protected variable.
|
2010-07-09 18:24:08 +08:00
|
|
|
We can use getter to read the variable.
|
2010-07-09 15:34:16 +08:00
|
|
|
@param varType : the type of variable.
|
|
|
|
@param varName : variable name.
|
2010-07-09 18:24:08 +08:00
|
|
|
@param funName : "get + funName" is the name of the getter.
|
|
|
|
@warning : The getter is a public virtual function, you should rewrite it first.
|
2010-07-09 17:02:00 +08:00
|
|
|
The variables and methods declared after CCX_PROPERTY_READONLY are all public.
|
2010-07-09 15:34:16 +08:00
|
|
|
If you need protected or private, please declare.
|
|
|
|
*/
|
2010-07-09 17:02:00 +08:00
|
|
|
#define CCX_PROPERTY_READONLY(varType, varName, funName)\
|
2010-07-08 10:25:52 +08:00
|
|
|
protected: varType varName;\
|
|
|
|
public: virtual varType get##funName(void);
|
2010-07-09 15:34:16 +08:00
|
|
|
|
2010-07-09 17:02:00 +08:00
|
|
|
/** CCX_PROPERTY is used to declare a protected variable.
|
2010-07-09 18:24:08 +08:00
|
|
|
We can use getter to read the variable, and use the setter to change the variable.
|
2010-07-09 15:34:16 +08:00
|
|
|
@param varType : the type of variable.
|
|
|
|
@param varName : variable name.
|
2010-07-09 18:24:08 +08:00
|
|
|
@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.
|
2010-07-09 17:02:00 +08:00
|
|
|
The variables and methods declared after CCX_PROPERTY are all public.
|
2010-07-09 15:34:16 +08:00
|
|
|
If you need protected or private, please declare.
|
|
|
|
*/
|
2010-07-09 17:02:00 +08:00
|
|
|
#define CCX_PROPERTY(varType, varName, funName)\
|
2010-07-08 10:25:52 +08:00
|
|
|
protected: varType varName;\
|
|
|
|
public: virtual varType get##funName(void);\
|
|
|
|
public: virtual void set##funName(varType var);
|
|
|
|
|
2010-07-09 17:02:00 +08:00
|
|
|
/** CCX_SYNTHESIZE_READONLY is used to declare a protected variable.
|
2010-07-09 18:24:08 +08:00
|
|
|
We can use getter to read the variable.
|
2010-07-09 15:34:16 +08:00
|
|
|
@param varType : the type of variable.
|
|
|
|
@param varName : variable name.
|
2010-07-09 18:24:08 +08:00
|
|
|
@param funName : "get + funName" is the name of the getter.
|
|
|
|
@warning : The getter is a public inline function.
|
2010-07-09 17:02:00 +08:00
|
|
|
The variables and methods declared after CCX_SYNTHESIZE_READONLY are all public.
|
2010-07-09 15:34:16 +08:00
|
|
|
If you need protected or private, please declare.
|
|
|
|
*/
|
2010-07-09 17:02:00 +08:00
|
|
|
#define CCX_SYNTHESIZE_READONLY(varType, varName, funName)\
|
2010-07-07 15:15:30 +08:00
|
|
|
protected: varType varName;\
|
2010-07-08 12:20:58 +08:00
|
|
|
public: inline varType get##funName(void){ return varName; }
|
2010-07-07 09:41:29 +08:00
|
|
|
|
2010-07-09 17:02:00 +08:00
|
|
|
/** CCX_SYNTHESIZE is used to declare a protected variable.
|
2010-07-09 18:24:08 +08:00
|
|
|
We can use getter to read the variable, and use the setter to change the variable.
|
2010-07-09 15:34:16 +08:00
|
|
|
@param varType : the type of variable.
|
|
|
|
@param varName : variable name.
|
2010-07-09 18:24:08 +08:00
|
|
|
@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.
|
2010-07-09 17:02:00 +08:00
|
|
|
The variables and methods declared after CCX_SYNTHESIZE are all public.
|
2010-07-09 15:34:16 +08:00
|
|
|
If you need protected or private, please declare.
|
|
|
|
*/
|
2010-07-09 17:02:00 +08:00
|
|
|
#define CCX_SYNTHESIZE(varType, varName, funName)\
|
2010-07-07 15:15:30 +08:00
|
|
|
protected: varType varName;\
|
2010-07-08 12:20:58 +08:00
|
|
|
public: inline varType get##funName(void){ return varName; }\
|
|
|
|
public: inline void set##funName(varType var){ varName = var; }
|
2010-07-06 17:20:53 +08:00
|
|
|
|
2010-07-14 10:36:26 +08:00
|
|
|
#define CCX_SAFE_DELETE(p) if(p) { delete p; p=NULL; }
|
|
|
|
#define CCX_BREAK_IF(cond) if(cond) break;
|
|
|
|
#define CCX_SAFE_RELEASE(p) if(p) { p->release(); p = NULL; }
|
|
|
|
#define CCX_SAFE_RETAIN(p) if(p) { p->retain(); }
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2010-07-13 14:21:06 +08:00
|
|
|
#ifdef _DEBUG
|
|
|
|
#include "assert.h"
|
|
|
|
#define NSAssert(_CONDITION, _TXT)\
|
|
|
|
if(! (_CONDITION) ) \
|
|
|
|
{ \
|
|
|
|
printf( (_TXT) ); \
|
|
|
|
assert( (_CONDITION) ); \
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define NSAssert(_CONDITION, _TXT)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
#endif // __COCOS2D_DEFINE_H__
|
2010-07-09 17:02:00 +08:00
|
|
|
|