1 #ifndef _library__lua_function__hpp__included__
2 #define _library__lua_function__hpp__included__
26 * Add a function to group.
28 void do_register(const std::string
& name
, function
& fun
);
30 * Drop a function from group.
32 void do_unregister(const std::string
& name
, function
& dummy
);
34 * Request callbacks on all currently registered functions.
36 void request_callback(std::function
<void(std::string
, function
*)> cb
);
40 * Callbacks for all registered functions are immediately called.
42 int add_callback(std::function
<void(std::string
, function
*)> cb
,
43 std::function
<void(function_group
*)> dcb
);
47 void drop_callback(int handle
);
53 * Function implemented in C++ exported to Lua.
61 function(function_group
& group
, const std::string
& name
);
63 * Unregister function.
65 virtual ~function() throw();
70 virtual int invoke(state
& L
) = 0;
73 function_group
& group
;
77 * Register multiple functions at once.
87 const std::string
& name
;
88 std::function
<int(state
& L
, parameters
& P
)> func
;
91 * Create new functions.
93 * Parameter grp: The group to put the functions to.
94 * Parameter basetable: The base table to interpret function names relative to.
95 * Parameter fnlist: The list of functions to register.
97 functions(function_group
& grp
, const std::string
& basetable
, std::initializer_list
<entry
> fnlist
);
103 class fn
: public function
106 fn(function_group
& grp
, const std::string
& name
, std::function
<int(state
& L
, parameters
& P
)> _func
);
108 int invoke(state
& L
);
110 std::function
<int(state
& L
, parameters
& P
)> func
;
112 functions(const functions
&);
113 functions
& operator=(const functions
&);