mirror of https://github.com/axmolengine/axmol.git
Update comments of some header files
This commit is contained in:
parent
1eb1057875
commit
865aa886a9
|
@ -55,6 +55,7 @@ typedef LuaValueDict::const_iterator LuaValueDictIterator;
|
|||
typedef std::list<LuaValue> LuaValueArray;
|
||||
typedef LuaValueArray::const_iterator LuaValueArrayIterator;
|
||||
|
||||
/// @cond
|
||||
typedef enum {
|
||||
LuaValueTypeInt,
|
||||
LuaValueTypeFloat,
|
||||
|
@ -64,7 +65,9 @@ typedef enum {
|
|||
LuaValueTypeArray,
|
||||
LuaValueTypeObject
|
||||
} LuaValueType;
|
||||
/// @endcond
|
||||
|
||||
/// @cond
|
||||
typedef union {
|
||||
int intValue;
|
||||
float floatValue;
|
||||
|
@ -74,62 +77,197 @@ typedef union {
|
|||
LuaValueArray* arrayValue;
|
||||
Ref* ccobjectValue;
|
||||
} LuaValueField;
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
* Wrap different general types of data into a same specific type named LuaValue.
|
||||
* The general types supported as follows:int,float,bool,std::string,const char*,LuaValueDict,LuaValueArray,Ref.
|
||||
*
|
||||
* @lua NA
|
||||
* @js NA
|
||||
*/
|
||||
class LuaValue
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a int value.
|
||||
*
|
||||
* @param intValue a int value.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue intValue(const int intValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a float value.
|
||||
*
|
||||
* @param floatValue a float value.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue floatValue(const float floatValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a boolean value.
|
||||
*
|
||||
* @param booleanValue a bool value.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue booleanValue(const bool booleanValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a string pointer.
|
||||
*
|
||||
* @param stringValue a string pointer.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue stringValue(const char* stringValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a std::string object.
|
||||
*
|
||||
* @param stringValue a std::string object.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue stringValue(const std::string& stringValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a LuaValueDict value.
|
||||
*
|
||||
* @param dictValue a LuaValueDict object.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue dictValue(const LuaValueDict& dictValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a LuaValueArray value.
|
||||
*
|
||||
* @param arrayValue a LuaValueArray object.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue arrayValue(const LuaValueArray& arrayValue);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a Ref object.
|
||||
*
|
||||
* @param ccobjectValue a Ref object.
|
||||
* @param objectTypename a string pointer point to the typename of object.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue ccobjectValue(Ref* ccobjectValue, const char* objectTypename);
|
||||
|
||||
/**
|
||||
* Construct a LuaValue object by a Ref object.
|
||||
*
|
||||
* @param ccobjectValue a Ref object.
|
||||
* @param objectTypename a std::string object represent the typename of object.
|
||||
* @return a LuaValue object.
|
||||
*/
|
||||
static const LuaValue ccobjectValue(Ref* ccobjectValue, const std::string& objectTypename);
|
||||
|
||||
|
||||
/**
|
||||
* Default constuctor of LuaValue.
|
||||
* Set the default value for _type(LuaValueTypeInt) and _ccobjectType(nullptr),and init the _field.
|
||||
*/
|
||||
LuaValue(void)
|
||||
: _type(LuaValueTypeInt)
|
||||
, _ccobjectType(nullptr)
|
||||
{
|
||||
memset(&_field, 0, sizeof(_field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor of Data.
|
||||
*/
|
||||
LuaValue(const LuaValue& rhs);
|
||||
|
||||
/**
|
||||
* Override of operator=
|
||||
*/
|
||||
LuaValue& operator=(const LuaValue& rhs);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~LuaValue(void);
|
||||
|
||||
/**
|
||||
* Get the type of LuaValue object.
|
||||
*
|
||||
* @return the type of LuaValue object.
|
||||
*/
|
||||
const LuaValueType getType(void) const {
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the typename of the Ref object.
|
||||
*
|
||||
* @return the refrence of _ccobjectType
|
||||
*/
|
||||
const std::string& getObjectTypename(void) const {
|
||||
return *_ccobjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the int value of LuaValue object.
|
||||
*
|
||||
* @return the int value.
|
||||
*/
|
||||
int intValue(void) const {
|
||||
return _field.intValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the float value of LuaValue object.
|
||||
*
|
||||
* @return the float value.
|
||||
*/
|
||||
float floatValue(void) const {
|
||||
return _field.floatValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the boolean value of LuaValue object.
|
||||
*
|
||||
* @return the boolean value.
|
||||
*/
|
||||
bool booleanValue(void) const {
|
||||
return _field.booleanValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the boolean value of LuaValue object.
|
||||
*
|
||||
* @return the refrence about string value.
|
||||
*/
|
||||
const std::string& stringValue(void) const {
|
||||
return *_field.stringValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LuaValueDict value of LuaValue object.
|
||||
*
|
||||
* @return the LuaValueDict value.
|
||||
*/
|
||||
const LuaValueDict& dictValue(void) const {
|
||||
return *_field.dictValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LuaValueArray value of LuaValue object.
|
||||
*
|
||||
* @return the LuaValueArray value.
|
||||
*/
|
||||
const LuaValueArray& arrayValue(void) const {
|
||||
return *_field.arrayValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Ref object of LuaValue object.
|
||||
*
|
||||
* @return the pointer point to a Ref object.
|
||||
*/
|
||||
Ref* ccobjectValue(void) const {
|
||||
return _field.ccobjectValue;
|
||||
}
|
||||
|
|
|
@ -35,17 +35,28 @@ extern "C" {
|
|||
#include "2d/CCNode.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
|
||||
/**
|
||||
* The GLNode is wrapped to call the callback function about draw in the Lua.
|
||||
*/
|
||||
class GLNode:public cocos2d::Node
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destrutor.
|
||||
*
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~GLNode(){}
|
||||
|
||||
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
|
||||
protected:
|
||||
cocos2d::CustomCommand _renderCmd;
|
||||
void onDraw(const cocos2d::Mat4 &transform, uint32_t flags);
|
||||
};
|
||||
|
||||
/// @cond
|
||||
TOLUA_API int tolua_opengl_open(lua_State* tolua_S);
|
||||
TOLUA_API int register_glnode_manual(lua_State* tolua_S);
|
||||
/// @endcond
|
||||
|
||||
#endif //__LUA_OPENGL_H__
|
||||
|
|
|
@ -40,7 +40,7 @@ NS_CC_BEGIN
|
|||
|
||||
class ScheduleHandlerDelegate;
|
||||
|
||||
|
||||
/// @cond
|
||||
typedef std::vector<ScheduleHandlerDelegate*> VecShedule;
|
||||
typedef std::map<cocos2d::Node*,VecShedule> MapNodeSchedules;
|
||||
|
||||
|
@ -63,16 +63,41 @@ public:
|
|||
private:
|
||||
bool _isUpdateSchedule;
|
||||
};
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
* The LuaCallFunc is wrapped to call the callback function in the Lua Conveniently and don't insert useless code to processing the lua in the CallFuncN.
|
||||
*
|
||||
* @js NA.
|
||||
*/
|
||||
class LuaCallFunc:public cocos2d::CallFuncN
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default construtor.
|
||||
*/
|
||||
LuaCallFunc():_functionLua(nullptr)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Destrutor.
|
||||
*/
|
||||
virtual ~LuaCallFunc()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Create a LuaCallFunc object by a function pointer for callback.
|
||||
*
|
||||
* @param func a function pointer for callback.
|
||||
*/
|
||||
static LuaCallFunc* create(const std::function<void(void* self,Node*)>& func);
|
||||
|
||||
/**
|
||||
* Init a LuaCallFunc object by a function pointer for callback.
|
||||
*
|
||||
* @param func a function pointer for callback.
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithFunction(const std::function<void(void* self,Node*)>& func);
|
||||
virtual LuaCallFunc* clone() const override;
|
||||
virtual void execute() override;
|
||||
|
@ -83,9 +108,21 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* In order to reduce the coupling of lua script engine and native c++ engine.
|
||||
* In the current mechanism, for the class derived frome the Ref, we constuct a mapping relationship among c++ Ref object ,HandlerType and the refrence index corresponding to the pointer of Lua function.Then, using the ScriptHandlerMgr to manager uniformly.
|
||||
* By this mechanism,when native c++ Ref object wants to call the Lua function, we didn't insert the processing code in the native c++ class.
|
||||
*
|
||||
* @js NA.
|
||||
*/
|
||||
class ScriptHandlerMgr
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* HandlerType enum.
|
||||
* This enum class represent the processing type for c++ call the Lua function.
|
||||
*/
|
||||
enum class HandlerType: int
|
||||
{
|
||||
NODE = 0,
|
||||
|
@ -179,20 +216,84 @@ public:
|
|||
EVENT_CUSTOM_ENDED = 11000,
|
||||
};
|
||||
|
||||
///! @cond
|
||||
typedef int Handler;
|
||||
typedef std::pair<HandlerType, Handler> HandlerPair;
|
||||
typedef std::vector<HandlerPair> VecHandlerPairs;
|
||||
typedef std::map<void*,VecHandlerPairs> MapObjectHandlers;
|
||||
/// @endcond
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @lua NA
|
||||
*/
|
||||
ScriptHandlerMgr(void);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* @lua NA
|
||||
*/
|
||||
virtual ~ScriptHandlerMgr(void);
|
||||
|
||||
/**
|
||||
* Get the instance of the ScriptHandlerMgr.
|
||||
*
|
||||
* @return the instance of the ScriptHandlerMgr.
|
||||
*/
|
||||
static ScriptHandlerMgr* getInstance(void);
|
||||
|
||||
/**
|
||||
* Destroy the instance of the ScriptHandlerMgr.
|
||||
*/
|
||||
static void destroyInstance(void);
|
||||
|
||||
/**
|
||||
* Construct or update the mapping relationship among c++ Ref object ,HandlerType and the refrence index corresponding to the pointer of Lua function.
|
||||
*
|
||||
* @param object a Ref object.
|
||||
* @param handler a refrence index corresponding to the pointer of Lua function.
|
||||
* @param handlerType ScriptHandlerMgr::HandlerType.
|
||||
*/
|
||||
void addObjectHandler(void* object,int handler,ScriptHandlerMgr::HandlerType handlerType);
|
||||
|
||||
/**
|
||||
* By the handlerType and object, find the correct refrence index corresponding to the pointer of Lua function.
|
||||
* If found, remove the refrence of Lua function corresponding to this index in the 'toluafix_refid_function_mapping' table.
|
||||
*
|
||||
* @param object a Ref object.
|
||||
* @param handlerType ScriptHandlerMgr::HandlerType.
|
||||
*/
|
||||
void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
||||
|
||||
/**
|
||||
* By the handlerType and object, find the correct refrence index corresponding to the pointer of Lua function.
|
||||
*
|
||||
* @param object a Ref object.
|
||||
* @param handlerType ScriptHandlerMgr::HandlerType.
|
||||
* @return index corresponding to the pointer of Lua function,otherwise 0.
|
||||
*/
|
||||
int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
||||
|
||||
/**
|
||||
* Remove the all relationship among the object, HandlerType and the refrence index corresponding to the pointer of Lua function.
|
||||
* Meanwhile, remove the refrence of Lua function corresponding to the indexs the object has in the 'toluafix_refid_function_mapping' table.
|
||||
*
|
||||
* @param object the Ref object.
|
||||
*/
|
||||
void removeObjectAllHandlers(void* object);
|
||||
|
||||
/**
|
||||
* Add customizable relationship among c++ Ref object, HandlerType and the refrence index corresponding to the pointer of Lua function.
|
||||
* In the customizable relationship, we don't pass the HandlerType, it will obtain the HandlerType by auto-increasing.
|
||||
* The HandlerTypes used to customizable relationship are between EVENT_CUSTOM_BEGAN(10000) and EVENT_CUSTOM_ENDED(11000).
|
||||
* If the HandlerType increased more than 12,it would trigger assert.
|
||||
*
|
||||
* @param object the Ref object.
|
||||
* @param handler a refrence index corresponding to the pointer of Lua function.
|
||||
* @return ScriptHandlerMgr::HandlerType the value of current ScriptHandlerMgr::HandlerType after adding.
|
||||
*/
|
||||
ScriptHandlerMgr::HandlerType addCustomHandler(void* object, int handler);
|
||||
|
||||
private:
|
||||
|
|
|
@ -11,15 +11,57 @@ USING_NS_CC;
|
|||
USING_NS_CC_EXT;
|
||||
using namespace cocosbuilder;
|
||||
|
||||
|
||||
/**
|
||||
* CCBProxy is a proxy for cocosbuilder.
|
||||
* By using CCBProxy we could create a CCBReader object conveniently and set the Lua callback function when some events triggered should be passed onto Lua.
|
||||
*
|
||||
* @js NA
|
||||
*/
|
||||
class CCBProxy : public Layer{
|
||||
public:
|
||||
/**
|
||||
* Default constructor,do nothing.
|
||||
*/
|
||||
CCBProxy() { }
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ CCBProxy(){ }
|
||||
|
||||
/**
|
||||
* Create a CCBProxy object.
|
||||
*
|
||||
* @return a CCBProxy object.
|
||||
*/
|
||||
CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBProxy, create);
|
||||
|
||||
/**
|
||||
* Createa a CCBReader object.
|
||||
*
|
||||
* @return a CCBReader object.
|
||||
*/
|
||||
CCBReader* createCCBReader();
|
||||
Node* readCCBFromFile(const char *pszFileName,CCBReader* pCCBReader,bool bSetOwner = false);
|
||||
|
||||
/**
|
||||
* Get the true type name of pNode.
|
||||
* By using the dynamic_cast function, we coulde get the true type name of pNode.
|
||||
*
|
||||
* @Node pNode the Node object used to query.
|
||||
* @return a string pointer point to the true type name otherwise return "No Support".
|
||||
*/
|
||||
const char* getNodeTypeName(Node* pNode);
|
||||
|
||||
/**
|
||||
* Set relationship between the Lua callback function refrence index handle and the node.
|
||||
* According to the different controlEvents values,we would choose different ScriptHandlerMgr::HandlerTyp.
|
||||
* When node receive the events information should be passed on to Lua, it would find the Lua callback funtion by the Lua callback function refrence index.
|
||||
*
|
||||
* @param node the node object should pass on the events information to Lua,when the events are triggered.
|
||||
* @param handle the Lua callback function refrence index.
|
||||
* @param controlEvents the combination value of Control::EventType, default 0.
|
||||
*/
|
||||
void setCallback(Node* node,int handle, int controlEvents = 0);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue