1 
2 //          Copyright 2019 - 2021 Michael D. Parker
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 module bindbc.lua.v52.types;
8 
9 version(LUA_52):
10 
11 import core.stdc.stdio : BUFSIZ, FILE;
12 
13 // luaconf.h
14 enum LUA_IDSIZE = 60;
15 alias LUA_INT32 = int;
16 alias LUAI_UMEM = size_t;
17 alias LUAI_MEM = ptrdiff_t;
18 alias LUA_NUMBER = double;
19 alias LUA_INTEGER = ptrdiff_t;
20 alias LUA_UNSIGNED = uint;
21 
22 enum LUAL_BUFFERSIZE = BUFSIZ;
23 
24 enum LUAI_MAXSTACK = 1000000;
25 
26 enum LUAI_FIRSTPSEUDOIDX = (-LUAI_MAXSTACK - 1000);
27 
28 // lauxlib.h
29 enum LUA_ERRFILE = LUA_ERRERR+1;
30 
31 struct luaL_Reg {
32     const(char)* name;
33     lua_CFunction func;
34 }
35 
36 enum LUA_NOREF = -2;
37 enum LUA_REFNIL = -1;
38 
39 struct luaL_Buffer {
40     char* b;
41     size_t size;
42     size_t n;
43     lua_State* L;
44     char[LUAL_BUFFERSIZE] buffer;
45 }
46 
47 alias LUA_FILEHANDLE = FILE*;
48 
49 struct luaL_Stream {
50     FILE* f;
51     lua_CFunction closef;
52 }
53 
54 // lua.h
55 enum LUA_VERSION_MAJOR = "5";
56 enum LUA_VERSION_MINOR = "2";
57 enum LUA_VERSION_NUM = 502;
58 enum LUA_VERSION_RELEASE = 4;
59 
60 enum LUA_VERSION = "Lua " ~ LUA_VERSION_MAJOR ~ "." ~ LUA_VERSION_MINOR;
61 enum LUA_RELEASE = LUA_VERSION ~ "." ~ LUA_VERSION_RELEASE;
62 
63 enum LUA_SIGNATURE = "\033Lua";
64 enum LUA_MULTRET = -1;
65 
66 enum LUA_REGISTRYINDEX = LUAI_FIRSTPSEUDOIDX;
67 
68 enum LUA_OK = 0;
69 enum LUA_YIELD = 1;
70 enum LUA_ERRRUN = 2;
71 enum LUA_ERRSYNTAX = 3;
72 enum LUA_ERRMEM = 4;
73 enum LUA_ERRGCMM = 5;
74 enum LUA_ERRERR = 6;
75 
76 struct lua_State;
77 
78 nothrow {
79     alias lua_CFunction = int function(lua_State*);
80     alias lua_Reader = const(char)* function(lua_State*,void*,size_t);
81     alias lua_Writer = int function(lua_State*,const(void)*,size_t,void*);
82     alias lua_Alloc = void* function(void*,void*,size_t,size_t);
83 }
84 
85 enum LUA_TNONE = -1;
86 enum LUA_TNIL = 0;
87 enum LUA_TBOOLEAN = 1;
88 enum LUA_TLIGHTUSERDATA = 2;
89 enum LUA_TNUMBER = 3;
90 enum LUA_TSTRING = 4;
91 enum LUA_TTABLE = 5;
92 enum LUA_TFUNCTION = 6;
93 enum LUA_TUSERDATA = 7;
94 enum LUA_TTHREAD = 8;
95 enum LUA_NUMTAGS = 9;
96 
97 enum LUA_MINSTACK = 20;
98 
99 enum LUA_RIDX_MAINTHREAD = 1;
100 enum LUA_RIDX_GLOBALS = 2;
101 enum LUA_RIDX_LAST = LUA_RIDX_GLOBALS;
102 
103 alias lua_Number = LUA_NUMBER;
104 alias lua_Integer = LUA_INTEGER;
105 alias lua_Unsigned = LUA_UNSIGNED;
106 
107 enum LUA_OPADD = 0;
108 enum LUA_OPSUB = 1;
109 enum LUA_OPMUL = 2;
110 enum LUA_OPDIV = 3;
111 enum LUA_OPMOD = 4;
112 enum LUA_OPPOW = 5;
113 enum LUA_OPUNM = 6;
114 
115 enum LUA_OPEQ = 0;
116 enum LUA_OPLT = 1;
117 enum LUA_OPLE = 2;
118 
119 enum LUA_GCSTOP = 0;
120 enum LUA_GCRESTART = 1;
121 enum LUA_GCCOLLECT = 2;
122 enum LUA_GCCOUNT = 3;
123 enum LUA_GCCOUNTB = 4;
124 enum LUA_GCSTEP = 5;
125 enum LUA_GCSETPAUSE = 6;
126 enum LUA_GCSETSTEPMUL = 7;
127 enum LUA_GCSETMAJORINC = 8;
128 enum LUA_GCISRUNNING = 9;
129 enum LUA_GCGEN = 10;
130 enum LUA_GCINC = 11;
131 
132 enum LUA_HOOKCALL = 0;
133 enum LUA_HOOKRET = 1;
134 enum LUA_HOOKLINE = 2;
135 enum LUA_HOOKCOUNT = 3;
136 enum LUA_HOOKTAILRET = 4;
137 
138 enum LUA_MASKCALL = 1 << LUA_HOOKCALL;
139 enum LUA_MASKRET = 1 << LUA_HOOKRET;
140 enum LUA_MASKLINE = 1 << LUA_HOOKLINE;
141 enum LUA_MASKCOUNT = 1 << LUA_HOOKCOUNT;
142 
143 struct lua_Debug {
144     int event;
145     const(char)* name;
146     const(char)* namewhat;
147     const(char)* what;
148     const(char)* source;
149     int currentline;
150     int linedefined;
151     int lastlinedefined;
152     ubyte nups;
153     ubyte nparams;
154     char isvararg;
155     char istailcall;
156     char[LUA_IDSIZE] short_src;
157     private void* i_ci;
158 }
159 
160 alias lua_Hook = void function(lua_State*,lua_Debug*) nothrow;
161 
162 // lualib.h
163 enum LUA_COLIBNAME = "coroutine";
164 enum LUA_TABLIBNAME = "table";
165 enum LUA_IOLIBNAME = "io";
166 enum LUA_OSLIBNAME = "os";
167 enum LUA_STRLIBNAME = "string";
168 enum LUA_BITLIBNAME = "bit32";
169 enum LUA_MATHLIBNAME = "math";
170 enum LUA_DBLIBNAME = "debug";
171 enum LUA_LOADLIBNAME = "package";