-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbindvar.h
More file actions
85 lines (68 loc) · 1.48 KB
/
Copy pathbindvar.h
File metadata and controls
85 lines (68 loc) · 1.48 KB
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
//
// Created by zhenkai on 2020/6/2.
//
#ifndef LUABIND_BINDVAR_H
#define LUABIND_BINDVAR_H
#include <lua.hpp>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define LT_NONE (-1)
#define LT_NIL 0
#define LT_INTEGER 1
#define LT_REAL 2
#define LT_STRING 3
#define LT_BOOLEAN 4
#define LT_POINTER 5
#define LT_DUPSTRING 10
#define LT_ARRAY 6
#define LT_MAP 7
#define DEFAULT_ARGS_NUM 3
typedef struct lval {
int type;
union {
void *p; /* light userdata */
lua_Integer i; /* integer numbers */
lua_Number n; /* float numbers */
const char *str; /* string */
int b; /* bool */
} v;
} lval;
// 参数容器
typedef struct lvars {
int n;
int cap;
lval *v;
} lvars;
class LUABridge {
private:
lval* newval();
protected:
lua_State *L;
lvars *args;
public:
LUABridge(lua_State *l);
virtual ~LUABridge();
float tonumber(int index);
const char *tostring(int index);
bool tobool(int index);
void *topointer(int index);
void pushnumber(float value);
void pushstring(const char *value);
void pushdupstring(char *value);
void pushbool(bool value);
void pushpointer(void *value);
void pushnil();
};
class Request : public LUABridge {
public:
Request(lua_State *l);
lvars *gencargs();
};
class Response : public LUABridge {
public:
Response(lua_State *l);
int genluaargs();
};
#endif //LUABIND_BINDVAR_H