2016-11-17 05:18:35 +00:00
|
|
|
#ifndef SCRIPTFUNCTION_HPP
|
|
|
|
#define SCRIPTFUNCTION_HPP
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
#include <boost/any.hpp>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#if defined (ENABLE_LUA)
|
2016-12-16 15:46:30 +00:00
|
|
|
#include "LangLua/LangLua.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef unsigned long long(*ScriptFunc)();
|
|
|
|
#if defined (ENABLE_LUA)
|
|
|
|
typedef std::string ScriptFuncLua;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class ScriptFunction
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
union
|
|
|
|
{
|
|
|
|
ScriptFunc fCpp;
|
|
|
|
#if defined (ENABLE_LUA)
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
lua_State *lua;
|
|
|
|
ScriptFuncLua name;
|
|
|
|
} fLua;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
char ret_type;
|
2016-07-27 02:09:56 +00:00
|
|
|
std::string def;
|
2016-01-12 03:41:44 +00:00
|
|
|
int script_type;
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCRIPT_CPP,
|
|
|
|
SCRIPT_LUA
|
|
|
|
};
|
|
|
|
|
|
|
|
ScriptFunction(ScriptFunc fCpp, char ret_type, const std::string &def);
|
|
|
|
#if defined (ENABLE_LUA)
|
|
|
|
ScriptFunction(const ScriptFuncLua &fPawn, lua_State *lua, char ret_type, const std::string &def);
|
|
|
|
#endif
|
|
|
|
virtual ~ScriptFunction();
|
|
|
|
|
|
|
|
boost::any Call(const std::vector<boost::any> &args);
|
|
|
|
};
|
|
|
|
|
2016-11-17 05:18:35 +00:00
|
|
|
#endif //SCRIPTFUNCTION_HPP
|