aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser/luatablegen/W_Code_Section_tablegen.c
blob: 717af94a95fc71b24ecffbbea0191ff502a0b82e (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// automatically generated by luatablegen
#include "../lua-5.3.4/src/lua.h"
#include "../lua-5.3.4/src/lauxlib.h"
#include "../lua-5.3.4/src/lualib.h"
#include <inttypes.h>
#include <stdbool.h>
#ifndef _W_Code_Section_H
#define _W_Code_Section_H
#ifdef __cplusplus
extern "C" {
#endif
#include "./W_Code_Section_tablegen.h"

#include "../wasm.h"

static W_Code_Section* convert_W_Code_Section (lua_State* __ls, int index) {
	W_Code_Section* dummy = (W_Code_Section*)lua_touserdata(__ls, index);
	if (dummy == NULL) printf("W_Code_Section:bad user data type.\n");
	return dummy;
}

static W_Code_Section* check_W_Code_Section(lua_State* __ls, int index) {
	W_Code_Section* dummy;
	luaL_checktype(__ls, index, LUA_TUSERDATA);
	dummy = (W_Code_Section*)luaL_checkudata(__ls, index, "W_Code_Section");
	if (dummy == NULL) printf("W_Code_Section:bad user data type.\n");
	return dummy;
}

W_Code_Section* push_W_Code_Section(lua_State* __ls) {
	lua_checkstack(__ls, 1);
	W_Code_Section* dummy = lua_newuserdata(__ls, sizeof(W_Code_Section));
	luaL_getmetatable(__ls, "W_Code_Section");
	lua_setmetatable(__ls, -2);
	return dummy;
}

int W_Code_Section_push_args(lua_State* __ls, W_Code_Section* _st) {
	lua_checkstack(__ls, 2);
	lua_pushinteger(__ls, _st->count);
	lua_pushlightuserdata(__ls, _st->bodies);
	return 0;
}

int new_W_Code_Section(lua_State* __ls) {
	lua_checkstack(__ls, 2);
	varuint32 count = luaL_optinteger(__ls,-2,0);
	W_Function_Body** bodies = lua_touserdata(__ls,-1);
	W_Code_Section* dummy = push_W_Code_Section(__ls);
	dummy->count = count;
	dummy->bodies = bodies;
	return 1;
}

static int getter_W_Code_Section_count(lua_State* __ls) {
	W_Code_Section* dummy = check_W_Code_Section(__ls, 1);
	lua_pop(__ls, -1);
	lua_pushinteger(__ls, dummy->count);
	return 1;
}
static int getter_W_Code_Section_bodies(lua_State* __ls) {
	W_Code_Section* dummy = check_W_Code_Section(__ls, 1);
	lua_pop(__ls, -1);
	lua_pushlightuserdata(__ls, dummy->bodies);
	return 1;
}

static int setter_W_Code_Section_count(lua_State* __ls) {
	W_Code_Section* dummy = check_W_Code_Section(__ls, 1);
	dummy->count = luaL_checkinteger(__ls, 2);
	lua_settop(__ls, 1);
	return 1;
}
static int setter_W_Code_Section_bodies(lua_State* __ls) {
	W_Code_Section* dummy = check_W_Code_Section(__ls, 1);
	dummy->bodies = luaL_checkudata(__ls, 2, "W_Code_Section");
	lua_settop(__ls, 1);
	return 1;
}

static const luaL_Reg W_Code_Section_methods[] = {
	{"new", new_W_Code_Section},
	{"set_count", setter_W_Code_Section_count},
	{"set_bodies", setter_W_Code_Section_bodies},
	{"count", getter_W_Code_Section_count},
	{"bodies", getter_W_Code_Section_bodies},
	{0,0}
};

static const luaL_Reg W_Code_Section_meta[] = {
	{0, 0}
};

int W_Code_Section_register(lua_State* __ls) {
	luaL_openlib(__ls, "W_Code_Section", W_Code_Section_methods, 0);
	luaL_newmetatable(__ls, "W_Code_Section");
	luaL_openlib(__ls, 0, W_Code_Section_meta, 0);
	lua_pushliteral(__ls, "__index");
	lua_pushvalue(__ls, -3);
	lua_rawset(__ls, -3);
	lua_pushliteral(__ls, "__metatable");
	lua_pushvalue(__ls, -3);
	lua_rawset(__ls, -3);
	lua_pop(__ls, 1);
return 1;
}

#ifdef __cplusplus
}
#endif //end of extern c
#endif //end of inclusion guard