1 #ifndef _library__lua_function__hpp__included__
2 #define _library__lua_function__hpp__included__
24 * Add a function to group.
26 void do_register(const std::string
& name
, function
& fun
);
28 * Drop a function from group.
30 void do_unregister(const std::string
& name
, function
& dummy
);
32 * Request callbacks on all currently registered functions.
34 void request_callback(std::function
<void(std::string
, function
*)> cb
);
38 * Callbacks for all registered functions are immediately called.
40 int add_callback(std::function
<void(std::string
, function
*)> cb
,
41 std::function
<void(function_group
*)> dcb
);
45 void drop_callback(int handle
);
51 * Function implemented in C++ exported to Lua.
59 function(function_group
& group
, const std::string
& name
) throw(std::bad_alloc
);
61 * Unregister function.
63 virtual ~function() throw();
68 virtual int invoke(state
& L
) = 0;
71 function_group
& group
;
75 * Register multiple functions at once.
85 const std::string
& name
;
86 std::function
<int(state
& L
, parameters
& P
)> func
;
89 * Create new functions.
91 * Parameter grp: The group to put the functions to.
92 * Parameter basetable: The base table to interpret function names relative to.
93 * Parameter fnlist: The list of functions to register.
95 functions(function_group
& grp
, const std::string
& basetable
, std::initializer_list
<entry
> fnlist
);
101 class fn
: public function
104 fn(function_group
& grp
, const std::string
& name
, std::function
<int(state
& L
, parameters
& P
)> _func
);
106 int invoke(state
& L
);
108 std::function
<int(state
& L
, parameters
& P
)> func
;
110 functions(const functions
&);
111 functions
& operator=(const functions
&);