-
Notifications
You must be signed in to change notification settings - Fork 2
/
plu_lua_function.h
34 lines (25 loc) · 1.01 KB
/
plu_lua_function.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef PLU_LUA_FUNCTION_H_
#define PLU_LUA_FUNCTION_H_
#include <EXTERN.h>
#include <perl.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
typedef struct plu_function {
lua_State *L;
int registry_index;
} plu_function_t;
/* Create new function object from Lua function on top of Lua stack, pops function off of stack */
plu_function_t *plu_new_function_object(pTHX_ lua_State *ls);
/* Same as plu_new_function_object, but then converts it to a
* Perl sub{} (RV to CV) (not mortalized) */
SV *plu_new_function_object_perl(pTHX_ lua_State *ls);
/* Same as plu_new_function_object, but then converts it to a
* Perl sub{} (RV to CV) (not mortalized)
* Installs the sub as a named sub of fully qualified name 'fullname'. */
SV *plu_install_new_function_object_perl(pTHX_ lua_State *ls, char *fullname);
/* Extract function struct ptr from CV */
plu_function_t *plu_func_from_cv(pTHX_ CV *cv);
#define PLU_LUA_FUNCTION_PUSH_TO_STACK(func) \
lua_rawgeti((func).L, LUA_REGISTRYINDEX, (func).registry_index)
#endif