-
Notifications
You must be signed in to change notification settings - Fork 2
/
plu_table.h
38 lines (27 loc) · 1.11 KB
/
plu_table.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
35
36
37
38
#ifndef PLU_TABLE_H_
#define PLU_TABLE_H_
#include <EXTERN.h>
#include <perl.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
typedef struct plu_table {
lua_State *L;
int registry_index;
} plu_table_t;
/* Create new table object from table on top of Lua stack, pops table off of stack */
plu_table_t *plu_new_table_object(pTHX_ lua_State *ls);
/* Same as plu_new_table_object, but then converts it to a
* blessed Perl SV (not mortalized) */
SV *plu_new_table_object_perl(pTHX_ lua_State *ls);
/* Convert the guts of an XS wrapper of a Lua table to a (mortal) Perl HV */
HV *plu_table_obj_to_hash(pTHX_ plu_table_t *THIS, int recursive);
/* Convert the guts of an XS wrapper of a Lua table to a (mortal) Perl AV */
AV *plu_table_obj_to_array(pTHX_ plu_table_t *THIS, int recursive);
/* Returns a Perl AV of keys in the Lua table */
AV *plu_table_obj_to_keys_array(pTHX_ plu_table_t *THIS);
/* Returns a Perl AV of values in the Lua table */
AV *plu_table_obj_to_values_array(pTHX_ plu_table_t *THIS);
#define PLU_TABLE_PUSH_TO_STACK(tbl) \
lua_rawgeti((tbl).L, LUA_REGISTRYINDEX, (tbl).registry_index)
#endif