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.v51.types;
8 
9 version(LUA_51):
10 
11 import core.stdc.stdio : BUFSIZ;
12 
13 // luaconf.h
14 enum LUA_IDSIZE = 60;
15 alias LUAI_UINT32 = uint;
16 alias LUAI_INT32 = int;
17 enum LUAI_MAXINT32 = int.max;
18 alias LUAI_UMEM = size_t;
19 alias LUAI_MEM = ptrdiff_t;
20 alias LUA_NUMBER = double;
21 alias LUA_INTEGER = ptrdiff_t;
22 
23 enum LUAL_BUFFERSIZE = BUFSIZ;
24 
25 enum LUAI_MAXSTACK = 1000000;
26 
27 // lauxlib.h
28 enum LUA_ERRFILE = LUA_ERRERR+1;
29 
30 struct luaL_Reg {
31     const(char)* name;
32     lua_CFunction func;
33 }
34 
35 enum LUA_NOREF = -2;
36 enum LUA_REFNIL = -1;
37 
38 struct luaL_Buffer {
39     char* p;
40     int lvl;
41     lua_State* L;
42     char[LUAL_BUFFERSIZE] buffer;
43 }
44 
45 // lua.h
46 // The 5.1 header does not define LUA_VERSION_MAJOR/MINOR/NUM/RELEASE, but we will
47 // for consistency with the other versions.
48 enum LUA_VERSION_MAJOR = "5";
49 enum LUA_VERSION_MINOR = "1";
50 enum LUA_VERSION_NUM = 501;
51 enum LUA_VERSION_RELEASE = 5;
52 
53 enum LUA_VERSION = "Lua " ~ LUA_VERSION_MAJOR ~ "." ~ LUA_VERSION_MINOR;
54 enum LUA_RELEASE = LUA_VERSION ~ "." ~ LUA_VERSION_RELEASE;
55 
56 enum LUA_SIGNATURE = "\033Lua";
57 enum LUA_MULTRET = -1;
58 
59 enum LUA_REGISTRYINDEX = -10_000;
60 enum LUA_ENVIRONINDEX = -10_001;
61 enum LUA_GLOBALSINDEX = -10_002;
62 
63 enum LUA_YIELD = 1;
64 enum LUA_ERRRUN = 2;
65 enum LUA_ERRSYNTAX = 3;
66 enum LUA_ERRMEM = 4;
67 enum LUA_ERRERR = 5;
68 
69 struct lua_State;
70 
71 nothrow {
72     alias lua_CFunction = int function(lua_State*);
73     alias lua_Reader = const(char)* function(lua_State*,void*,size_t);
74     alias lua_Writer = int function(lua_State*,const(void)*,size_t,void*);
75     alias lua_Alloc = void* function(void*,void*,size_t,size_t);
76 }
77 
78 enum LUA_TNONE = -1;
79 enum LUA_TNIL = 0;
80 enum LUA_TBOOLEAN = 1;
81 enum LUA_TLIGHTUSERDATA = 2;
82 enum LUA_TNUMBER = 3;
83 enum LUA_TSTRING = 4;
84 enum LUA_TTABLE = 5;
85 enum LUA_TFUNCTION = 6;
86 enum LUA_TUSERDATA = 7;
87 enum LUA_TTHREAD = 8;
88 
89 enum LUA_MINSTACK = 20;
90 
91 alias lua_Number = LUA_NUMBER;
92 alias lua_Integer = LUA_INTEGER;
93 
94 enum LUA_GCSTOP = 0;
95 enum LUA_GCRESTART = 1;
96 enum LUA_GCCOLLECT = 2;
97 enum LUA_GCCOUNT = 3;
98 enum LUA_GCCOUNTB = 4;
99 enum LUA_GCSTEP = 5;
100 enum LUA_GCSETPAUSE = 6;
101 enum LUA_GCSETSTEPMUL = 7;
102 
103 enum LUA_HOOKCALL = 0;
104 enum LUA_HOOKRET = 1;
105 enum LUA_HOOKLINE = 2;
106 enum LUA_HOOKCOUNT = 3;
107 enum LUA_HOOKTAILRET = 4;
108 
109 enum LUA_MASKCALL = 1 << LUA_HOOKCALL;
110 enum LUA_MASKRET = 1 << LUA_HOOKRET;
111 enum LUA_MASKLINE = 1 << LUA_HOOKLINE;
112 enum LUA_MASKCOUNT = 1 << LUA_HOOKCOUNT;
113 
114 struct lua_Debug {
115     int event;
116     const(char)* name;
117     const(char)* namewhat;
118     const(char)* what;
119     const(char)* source;
120     int currentline;
121     int nups;
122     int linedefined;
123     int lastlinedefined;
124     char[LUA_IDSIZE] short_src;
125     private int i_ci;
126 }
127 
128 alias lua_Hook = void function(lua_State*,lua_Debug*) nothrow;
129 
130 // lualib.h
131 enum LUA_FILEHANDLE = "FILE*";
132 enum LUA_COLIBNAME = "coroutine";
133 enum LUA_TABLIBNAME = "table";
134 enum LUA_IOLIBNAME = "io";
135 enum LUA_OSLIBNAME = "os";
136 enum LUA_STRLIBNAME = "string";
137 enum LUA_MATHLIBNAME = "math";
138 enum LUA_DBLIBNAME = "debug";
139 enum LUA_LOADLIBNAME = "package";