cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCPlatformMacros.h File Reference

Macros

#define CREATE_FUNC(__TYPE__)
 Define some platform specific macros. More...
 
#define NODE_FUNC(__TYPE__)
 Define a node function for a specific type, such as Layer. More...
 
#define CC_ENABLE_CACHE_TEXTURE_DATA   1
 Enable it if you want to cache the texture data. More...
 
#define CC_REBIND_INDICES_BUFFER   1
 Application will crash in glDrawElements function on some win32 computers and some android devices. More...
 
#define CC_PROPERTY_READONLY(varType, varName, funName)
 It is used to declare a protected variable. More...
 
#define CC_PROPERTY_READONLY_PASS_BY_REF(varType, varName, funName)
#define CC_PROPERTY(varType, varName, funName)
 It is used to declare a protected variable. More...
 
#define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)
#define CC_SYNTHESIZE_READONLY(varType, varName, funName)
 It is used to declare a protected variable. More...
 
#define CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)
#define CC_SYNTHESIZE(varType, varName, funName)
 It is used to declare a protected variable. More...
 
#define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)
#define CC_SYNTHESIZE_RETAIN(varType, varName, funName)
#define CC_SAFE_DELETE(p)   do { delete (p); (p) = nullptr; } while(0)
#define CC_SAFE_DELETE_ARRAY(p)   do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
#define CC_SAFE_FREE(p)   do { if(p) { free(p); (p) = nullptr; } } while(0)
#define CC_SAFE_RELEASE(p)   do { if(p) { (p)->release(); } } while(0)
#define CC_SAFE_RELEASE_NULL(p)   do { if(p) { (p)->release(); (p) = nullptr; } } while(0)
#define CC_SAFE_RETAIN(p)   do { if(p) { (p)->retain(); } } while(0)
#define CC_BREAK_IF(cond)   if(cond) break
#define __CCLOGWITHFUNCTION(s,...)   log("%s : %s",__FUNCTION__, StringUtils::format(s, ##__VA_ARGS__).c_str())
#define CC_DISALLOW_COPY_AND_ASSIGN(TypeName)
 A macro to disallow the copy constructor and operator= functions. More...
 
#define CC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
 A macro to disallow all the implicit constructors, namely the default constructor, copy constructor and operator= functions. More...
 
#define CC_DEPRECATED_ATTRIBUTE
 Only certain compilers support attribute((deprecated)). More...
 
#define CC_DEPRECATED(...)   CC_DEPRECATED_ATTRIBUTE
 Macro to mark things deprecated as of a particular version can be used with artibrary parameters which are thrown away. More...
 
#define CC_FORMAT_PRINTF(formatPos, argPos)
 Only certain compiler support attribute((format)) More...
 
#define CC_FORMAT_PRINTF_SIZE_T   "%08zX"
#define CC_UNUSED
#define CC_REQUIRES_NULL_TERMINATION
namespace cocos2d
#define NS_CC_BEGIN
#define NS_CC_END
#define USING_NS_CC
#define NS_CC
Cocos2d debug
#define CCLOG(...)   do {} while (0)
#define CCLOGINFO(...)   do {} while (0)
#define CCLOGERROR(...)   do {} while (0)
#define CCLOGWARN(...)   do {} while (0)
#define LUALOG(...)
 Lua engine debug. More...
 

Macro Definition Documentation

#define __CCLOGWITHFUNCTION (   s,
  ... 
)    log("%s : %s",__FUNCTION__, StringUtils::format(s, ##__VA_ARGS__).c_str())
#define CC_BREAK_IF (   cond)    if(cond) break
var CC_BREAK_IF (   var)    if(cond) break
local CC_BREAK_IF (   local)    if(cond) break
#define CC_DEPRECATED (   ...)    CC_DEPRECATED_ATTRIBUTE

Macro to mark things deprecated as of a particular version can be used with artibrary parameters which are thrown away.

e.g. CC_DEPRECATED(4.0) or CC_DEPRECATED(4.0, "not going to need this anymore") etc.

var CC_DEPRECATED (   ...)    CC_DEPRECATED_ATTRIBUTE

Macro to mark things deprecated as of a particular version can be used with artibrary parameters which are thrown away.

e.g. CC_DEPRECATED(4.0) or CC_DEPRECATED(4.0, "not going to need this anymore") etc.

local CC_DEPRECATED (   ...)    CC_DEPRECATED_ATTRIBUTE

Macro to mark things deprecated as of a particular version can be used with artibrary parameters which are thrown away.

e.g. CC_DEPRECATED(4.0) or CC_DEPRECATED(4.0, "not going to need this anymore") etc.

#define CC_DEPRECATED_ATTRIBUTE

Only certain compilers support attribute((deprecated)).

var CC_DEPRECATED_ATTRIBUTE

Only certain compilers support attribute((deprecated)).

local CC_DEPRECATED_ATTRIBUTE

Only certain compilers support attribute((deprecated)).

#define CC_DISALLOW_COPY_AND_ASSIGN (   TypeName)
Value:
TypeName(const TypeName &); \
TypeName &operator =(const TypeName &);

A macro to disallow the copy constructor and operator= functions.

This should be used in the private: declarations for a class

var CC_DISALLOW_COPY_AND_ASSIGN (   var)
Value:
TypeName(const TypeName &); \
TypeName &operator =(const TypeName &);

A macro to disallow the copy constructor and operator= functions.

This should be used in the private: declarations for a class

local CC_DISALLOW_COPY_AND_ASSIGN (   local)
Value:
TypeName(const TypeName &); \
TypeName &operator =(const TypeName &);

A macro to disallow the copy constructor and operator= functions.

This should be used in the private: declarations for a class

#define
CC_DISALLOW_IMPLICIT_CONSTRUCTORS
(   TypeName)
Value:
TypeName(); \
#define CC_DISALLOW_COPY_AND_ASSIGN(TypeName)
A macro to disallow the copy constructor and operator= functions.
Definition: CCPlatformMacros.h:266

A macro to disallow all the implicit constructors, namely the default constructor, copy constructor and operator= functions.

This should be used in the private: declarations for a class that wants to prevent anyone from instantiating it. This is especially useful for classes containing only static methods.

var
CC_DISALLOW_IMPLICIT_CONSTRUCTORS
(   var)
Value:
TypeName(); \
#define CC_DISALLOW_COPY_AND_ASSIGN(TypeName)
A macro to disallow the copy constructor and operator= functions.
Definition: CCPlatformMacros.h:266

A macro to disallow all the implicit constructors, namely the default constructor, copy constructor and operator= functions.

This should be used in the private: declarations for a class that wants to prevent anyone from instantiating it. This is especially useful for classes containing only static methods.

local
CC_DISALLOW_IMPLICIT_CONSTRUCTORS
(   local)
Value:
TypeName(); \
#define CC_DISALLOW_COPY_AND_ASSIGN(TypeName)
A macro to disallow the copy constructor and operator= functions.
Definition: CCPlatformMacros.h:266

A macro to disallow all the implicit constructors, namely the default constructor, copy constructor and operator= functions.

This should be used in the private: declarations for a class that wants to prevent anyone from instantiating it. This is especially useful for classes containing only static methods.

#define
CC_ENABLE_CACHE_TEXTURE_DATA   1

Enable it if you want to cache the texture data.

Not enabling for Emscripten any more – doesn't seem necessary and don't want to be different from other platforms unless there's a good reason.

Since
v0.99.5
var CC_ENABLE_CACHE_TEXTURE_DATA   1

Enable it if you want to cache the texture data.

Not enabling for Emscripten any more – doesn't seem necessary and don't want to be different from other platforms unless there's a good reason.

Since
v0.99.5
local CC_ENABLE_CACHE_TEXTURE_DATA   1

Enable it if you want to cache the texture data.

Not enabling for Emscripten any more – doesn't seem necessary and don't want to be different from other platforms unless there's a good reason.

Since
v0.99.5
#define CC_FORMAT_PRINTF (   formatPos,
  argPos 
)

Only certain compiler support attribute((format))

Parameters
formatPos1-based position of format string argument.
argPos1-based position of first format-dependent argument.
var CC_FORMAT_PRINTF (   var,
  var 
)

Only certain compiler support attribute((format))

Parameters
formatPos1-based position of format string argument.
argPos1-based position of first format-dependent argument.
local CC_FORMAT_PRINTF (   local,
  local 
)

Only certain compiler support attribute((format))

Parameters
formatPos1-based position of format string argument.
argPos1-based position of first format-dependent argument.
#define CC_FORMAT_PRINTF_SIZE_T   "%08zX"
var CC_FORMAT_PRINTF_SIZE_T   "%08zX"
local CC_FORMAT_PRINTF_SIZE_T   "%08zX"
#define CC_PROPERTY (   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual varType get##funName(void);\
public: virtual void set##funName(varType var);

It is used to declare a protected variable.

We can use getter to read the variable, and use the setter to change the variable.

Parameters
varTypeThe type of variable.
varNameVariable name.
funName"get + funName" will be the name of the getter. "set + funName" will be the name of the setter.
Warning
The getter and setter are public virtual functions, you should rewrite them first. The variables and methods declared after CC_PROPERTY are all public. If you need protected or private, please declare.
#define CC_PROPERTY_PASS_BY_REF (   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const;\
public: virtual void set##funName(const varType& var);
var CC_PROPERTY_PASS_BY_REF (   var,
  var,
  var 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const;\
public: virtual void set##funName(const varType& var);
local CC_PROPERTY_PASS_BY_REF (   local,
  local,
  local 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const;\
public: virtual void set##funName(const varType& var);
#define CC_PROPERTY_READONLY (   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual varType get##funName(void) const;

It is used to declare a protected variable.

We can use getter to read the variable.

Parameters
varTypethe type of variable.
varNamevariable name.
funName"get + funName" will be the name of the getter.
Warning
The getter is a public virtual function, you should rewrite it first. The variables and methods declared after CC_PROPERTY_READONLY are all public. If you need protected or private, please declare.
var CC_PROPERTY_READONLY (   var,
  var,
  var 
)
Value:
protected: varType varName;\
public: virtual varType get##funName(void) const;

It is used to declare a protected variable.

We can use getter to read the variable.

Parameters
varTypethe type of variable.
varNamevariable name.
funName"get + funName" will be the name of the getter.
Warning
The getter is a public virtual function, you should rewrite it first. The variables and methods declared after CC_PROPERTY_READONLY are all public. If you need protected or private, please declare.
local CC_PROPERTY_READONLY (   local,
  local,
  local 
)
Value:
protected: varType varName;\
public: virtual varType get##funName(void) const;

It is used to declare a protected variable.

We can use getter to read the variable.

Parameters
varTypethe type of variable.
varNamevariable name.
funName"get + funName" will be the name of the getter.
Warning
The getter is a public virtual function, you should rewrite it first. The variables and methods declared after CC_PROPERTY_READONLY are all public. If you need protected or private, please declare.
#define
CC_PROPERTY_READONLY_PASS_BY_REF
(   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const;
var
CC_PROPERTY_READONLY_PASS_BY_REF
(   var,
  var,
  var 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const;
local
CC_PROPERTY_READONLY_PASS_BY_REF
(   local,
  local,
  local 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const;
#define CC_REBIND_INDICES_BUFFER   1

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.

var CC_REBIND_INDICES_BUFFER   1

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.

local CC_REBIND_INDICES_BUFFER   1

Application will crash in glDrawElements function on some win32 computers and some android devices.

Indices should be bound again while drawing to avoid this bug.

#define
CC_REQUIRES_NULL_TERMINATION
var CC_REQUIRES_NULL_TERMINATION
local CC_REQUIRES_NULL_TERMINATION
#define CC_SAFE_DELETE (   p)    do { delete (p); (p) = nullptr; } while(0)
#define CC_SAFE_DELETE_ARRAY (   p)    do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
#define CC_SAFE_FREE (   p)    do { if(p) { free(p); (p) = nullptr; } } while(0)
var CC_SAFE_FREE (   var)    do { if(p) { free(p); (p) = nullptr; } } while(0)
local CC_SAFE_FREE (   local)    do { if(p) { free(p); (p) = nullptr; } } while(0)
#define CC_SAFE_RELEASE (   p)    do { if(p) { (p)->release(); } } while(0)
var CC_SAFE_RELEASE (   var)    do { if(p) { (p)->release(); } } while(0)
local CC_SAFE_RELEASE (   local)    do { if(p) { (p)->release(); } } while(0)
#define CC_SAFE_RELEASE_NULL (   p)    do { if(p) { (p)->release(); (p) = nullptr; } } while(0)
var CC_SAFE_RELEASE_NULL (   var)    do { if(p) { (p)->release(); (p) = nullptr; } } while(0)
local CC_SAFE_RELEASE_NULL (   local)    do { if(p) { (p)->release(); (p) = nullptr; } } while(0)
#define CC_SAFE_RETAIN (   p)    do { if(p) { (p)->retain(); } } while(0)
var CC_SAFE_RETAIN (   var)    do { if(p) { (p)->retain(); } } while(0)
#define CC_SYNTHESIZE (   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual varType get##funName(void) const { return varName; }\
public: virtual void set##funName(varType var){ varName = var; }

It is used to declare a protected variable.

We can use getter to read the variable, and use the setter to change the variable.

Parameters
varTypeThe type of variable.
varNameVariable name.
funName"get + funName" will be the name of the getter. "set + funName" will be the name of the setter.
Warning
The getter and setter are public inline functions. The variables and methods declared after CC_SYNTHESIZE are all public. If you need protected or private, please declare.
#define CC_SYNTHESIZE_PASS_BY_REF (   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }\
public: virtual void set##funName(const varType& var){ varName = var; }
var CC_SYNTHESIZE_PASS_BY_REF (   var,
  var,
  var 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }\
public: virtual void set##funName(const varType& var){ varName = var; }
local CC_SYNTHESIZE_PASS_BY_REF (   local,
  local,
  local 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }\
public: virtual void set##funName(const varType& var){ varName = var; }
#define CC_SYNTHESIZE_READONLY (   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual varType get##funName(void) const { return varName; }

It is used to declare a protected variable.

We can use getter to read the variable.

Parameters
varTypeThe type of variable.
varNameVariable name.
funName"get + funName" will be the name of the getter.
Warning
The getter is a public inline function. The variables and methods declared after CC_SYNTHESIZE_READONLY are all public. If you need protected or private, please declare.
#define
CC_SYNTHESIZE_READONLY_PASS_BY_REF
(   varType,
  varName,
  funName 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }
var
CC_SYNTHESIZE_READONLY_PASS_BY_REF
(   var,
  var,
  var 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }
local
CC_SYNTHESIZE_READONLY_PASS_BY_REF
(   local,
  local,
  local 
)
Value:
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }
#define CC_SYNTHESIZE_RETAIN (   varType,
  varName,
  funName 
)
Value:
private: varType varName; \
public: virtual varType get##funName(void) const { return varName; } \
public: virtual void set##funName(varType var) \
{ \
if (varName != var) \
{ \
CC_SAFE_RELEASE(varName); \
varName = var; \
} \
}
#define CC_SAFE_RELEASE(p)
Definition: CCPlatformMacros.h:217
#define CC_SAFE_RETAIN(p)
Definition: CCPlatformMacros.h:219
var CC_SYNTHESIZE_RETAIN (   var,
  var,
  var 
)
Value:
private: varType varName; \
public: virtual varType get##funName(void) const { return varName; } \
public: virtual void set##funName(varType var) \
{ \
if (varName != var) \
{ \
CC_SAFE_RELEASE(varName); \
varName = var; \
} \
}
#define CC_SAFE_RELEASE(p)
Definition: CCPlatformMacros.h:217
#define CC_SAFE_RETAIN(p)
Definition: CCPlatformMacros.h:219
local CC_SYNTHESIZE_RETAIN (   local,
  local,
  local 
)
Value:
private: varType varName; \
public: virtual varType get##funName(void) const { return varName; } \
public: virtual void set##funName(varType var) \
{ \
if (varName != var) \
{ \
CC_SAFE_RELEASE(varName); \
varName = var; \
} \
}
#define CC_SAFE_RELEASE(p)
Definition: CCPlatformMacros.h:217
#define CC_SAFE_RETAIN(p)
Definition: CCPlatformMacros.h:219
#define CC_UNUSED
var CC_UNUSED
local CC_UNUSED
#define CCLOG (   ...)    do {} while (0)
var CCLOG (   ...)    do {} while (0)
local CCLOG (   ...)    do {} while (0)
#define CCLOGERROR (   ...)    do {} while (0)
var CCLOGERROR (   ...)    do {} while (0)
local CCLOGERROR (   ...)    do {} while (0)
#define CCLOGINFO (   ...)    do {} while (0)
var CCLOGINFO (   ...)    do {} while (0)
local CCLOGINFO (   ...)    do {} while (0)
#define CCLOGWARN (   ...)    do {} while (0)
#define CREATE_FUNC (   __TYPE__)
Value:
static __TYPE__* create() \
{ \
__TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
#define NULL
Definition: CCPlatformDefine-android.h:61
Ref * autorelease()
Releases the ownership sometime soon automatically.
static Sprite * create()
Creates an empty sprite without texture.

Define some platform specific macros.

Define a create function for a specific type, such as Layer.

Parameters
<strong>TYPE</strong>class type to add create(), such as Layer.
var CREATE_FUNC (   var)
Value:
static __TYPE__* create() \
{ \
__TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
#define NULL
Definition: CCPlatformDefine-android.h:61
Ref * autorelease()
Releases the ownership sometime soon automatically.
static Sprite * create()
Creates an empty sprite without texture.

Define some platform specific macros.

Define a create function for a specific type, such as Layer.

Parameters
<strong>TYPE</strong>class type to add create(), such as Layer.
local CREATE_FUNC (   local)
Value:
static __TYPE__* create() \
{ \
__TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
#define NULL
Definition: CCPlatformDefine-android.h:61
Ref * autorelease()
Releases the ownership sometime soon automatically.
static Sprite * create()
Creates an empty sprite without texture.

Define some platform specific macros.

Define a create function for a specific type, such as Layer.

Parameters
<strong>TYPE</strong>class type to add create(), such as Layer.
#define LUALOG (   ...)

Lua engine debug.

var LUALOG (   ...)

Lua engine debug.

local LUALOG (   ...)

Lua engine debug.

#define NODE_FUNC (   __TYPE__)
Value:
CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \
{ \
__TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
#define NULL
Definition: CCPlatformDefine-android.h:61
#define CC_DEPRECATED_ATTRIBUTE
Only certain compilers support attribute((deprecated)).
Definition: CCPlatformMacros.h:291

Define a node function for a specific type, such as Layer.

Parameters
<strong>TYPE</strong>class type to add node(), such as Layer.
Deprecated:
This interface will be deprecated sooner or later.
var NODE_FUNC (   var)
Value:
CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \
{ \
__TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
#define NULL
Definition: CCPlatformDefine-android.h:61
#define CC_DEPRECATED_ATTRIBUTE
Only certain compilers support attribute((deprecated)).
Definition: CCPlatformMacros.h:291

Define a node function for a specific type, such as Layer.

Parameters
<strong>TYPE</strong>class type to add node(), such as Layer.
Deprecated:
This interface will be deprecated sooner or later.
local NODE_FUNC (   local)
Value:
CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \
{ \
__TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}
#define NULL
Definition: CCPlatformDefine-android.h:61
#define CC_DEPRECATED_ATTRIBUTE
Only certain compilers support attribute((deprecated)).
Definition: CCPlatformMacros.h:291

Define a node function for a specific type, such as Layer.

Parameters
<strong>TYPE</strong>class type to add node(), such as Layer.
Deprecated:
This interface will be deprecated sooner or later.
#define NS_CC
#define NS_CC_BEGIN
var NS_CC_BEGIN
local NS_CC_BEGIN
#define NS_CC_END
#define USING_NS_CC
var USING_NS_CC
local USING_NS_CC