forked from casssoft/imgui_lua_bindings
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathimgui_lua_bindings.cpp
More file actions
645 lines (564 loc) · 17.1 KB
/
imgui_lua_bindings.cpp
File metadata and controls
645 lines (564 loc) · 17.1 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
#include <stdio.h>
#include <imgui.h>
#include <deque>
#include <vector>
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
// THIS IS FOR LUA 5.3 although you can make a few changes for other versions
// define ENABLE_IM_LUA_END_STACK
// to keep track of end and begins and clean up the imgui stack
// if lua errors
// define this global before you call RunString or LoadImGuiBindings
lua_State* lState;
#ifdef ENABLE_IM_LUA_END_STACK
// Stack for imgui begin and end
std::deque<int> endStack;
static void AddToStack(int type) {
endStack.push_back(type);
}
static void PopEndStack(int type) {
if (!endStack.empty()) {
endStack.pop_back(); // hopefully the type matches
}
}
static void ImEndStack(int type);
#endif
#define IMGUI_FUNCTION_DRAW_LIST(name) \
static int impl_draw_list_##name(lua_State *L) { \
int max_args = lua_gettop(L); \
int arg = 1; \
int stackval = 0;
#define IMGUI_FUNCTION(name) \
static int impl_##name(lua_State *L) { \
int max_args = lua_gettop(L); \
int arg = 1; \
int stackval = 0;
#define IMGUI
// I use OpenGL so this is a GLuint
// Using unsigned int cause im lazy don't copy me
#define IM_TEXTURE_ID_ARG(name) \
const ImTextureID name = (ImTextureID)luaL_checkinteger(L, arg++);
#define LABEL_ARG(name) \
size_t i_##name##_size; \
const char * name = luaL_checklstring(L, arg++, &(i_##name##_size));
#define OPTIONAL_LABEL_ARG(name, otherwise) \
const char* name; \
if (arg <= max_args) { \
name = lua_tostring(L, arg++); \
} else { \
name = otherwise; \
}
#define IOTEXT_ARG(name) \
size_t i_##name##_size; \
const char * i_##name##_const = luaL_checklstring(L, arg++, &(i_##name##_size)); \
char name[255]; \
strcpy(name, i_##name##_const);
#define END_IOTEXT(name) \
const char* o_##name = name;\
lua_pushstring(L, o_##name); \
stackval++;
#define IM_VEC_2_ARG(name)\
const lua_Number i_##name##_x = luaL_checknumber(L, arg++); \
const lua_Number i_##name##_y = luaL_checknumber(L, arg++); \
const ImVec2 name((double)i_##name##_x, (double)i_##name##_y);
#define OPTIONAL_IM_VEC_2_ARG(name, x, y) \
lua_Number i_##name##_x = x; \
lua_Number i_##name##_y = y; \
if (arg <= max_args - 1) { \
i_##name##_x = luaL_checknumber(L, arg++); \
i_##name##_y = luaL_checknumber(L, arg++); \
} \
const ImVec2 name((double)i_##name##_x, (double)i_##name##_y);
#define IM_VEC_4_ARG(name) \
const lua_Number i_##name##_x = luaL_checknumber(L, arg++); \
const lua_Number i_##name##_y = luaL_checknumber(L, arg++); \
const lua_Number i_##name##_z = luaL_checknumber(L, arg++); \
const lua_Number i_##name##_w = luaL_checknumber(L, arg++); \
const ImVec4 name((double)i_##name##_x, (double)i_##name##_y, (double)i_##name##_z, (double)i_##name##_w);
#define OPTIONAL_IM_VEC_4_ARG(name, x, y, z, w) \
lua_Number i_##name##_x = x; \
lua_Number i_##name##_y = y; \
lua_Number i_##name##_z = z; \
lua_Number i_##name##_w = w; \
if (arg <= max_args - 1) { \
i_##name##_x = luaL_checknumber(L, arg++); \
i_##name##_y = luaL_checknumber(L, arg++); \
i_##name##_z = luaL_checknumber(L, arg++); \
i_##name##_w = luaL_checknumber(L, arg++); \
} \
const ImVec4 name((double)i_##name##_x, (double)i_##name##_y, (double)i_##name##_z, (double)i_##name##_w);
#define NUMBER_ARG(name)\
lua_Number name = luaL_checknumber(L, arg++);
#define FLOAT_ARRAY_DEF(name, size)\
float name[size];
#define FLOAT_ARRAY_ARG(name, it)\
name[it] = (float)luaL_checknumber(L, arg++);
#define OPTIONAL_NUMBER_ARG(name, otherwise)\
lua_Number name = otherwise; \
if (arg <= max_args) { \
name = lua_tonumber(L, arg++); \
}
#define FLOAT_POINTER_ARG(name) \
float i_##name##_value = luaL_checknumber(L, arg++); \
float* name = &(i_##name##_value);
#define END_FLOAT_POINTER(name) \
if (name != NULL) { \
lua_pushnumber(L, i_##name##_value); \
stackval++; \
}
#define INT_ARG(name) \
const int name = (int)luaL_checknumber(L, arg++);
#define INT_ARRAY_DEF(name,size) \
int name[size];
#define INT_ARRAY_ARG(name,it) \
name[it] = (int)luaL_checknumber(L, arg++);
#define OPTIONAL_INT_ARG(name, otherwise)\
int name = otherwise; \
if (arg <= max_args) { \
name = (int)lua_tonumber(L, arg++); \
}
#define INT_POINTER_ARG(name) \
int i_##name##_value = (int)luaL_checkinteger(L, arg++); \
int* name = &(i_##name##_value);
#define END_INT_POINTER(name) \
if (name != NULL) { \
lua_pushnumber(L, i_##name##_value); \
stackval++; \
}
#define UINT_ARG(name) \
const unsigned int name = (unsigned int)luaL_checkinteger(L, arg++);
#define OPTIONAL_UINT_ARG(name, otherwise)\
unsigned int name = otherwise; \
if (arg <= max_args) { \
name = (unsigned int)luaL_checkinteger(L, arg++); \
}
#define UINT_POINTER_ARG(name) \
unsigned int i_##name##_value = (unsigned int)luaL_checkinteger(L, arg++); \
unsigned int* name = &(i_##name##_value);
#define END_UINT_POINTER(name) \
if (name != NULL) { \
lua_pushnumber(L, i_##name##_value); \
stackval++; \
}
#define BOOL_ARG(name) \
bool name = lua_toboolean(L, arg++);
#define OPTIONAL_BOOL_ARG(name, otherwise) \
bool name = otherwise; \
if (arg <= max_args) { \
name = lua_toboolean(L, arg++); \
}
#define BOOL_POINTER_ARG(name) \
bool i_##name##_value = lua_toboolean(L, arg++); \
bool* name = &(i_##name##_value);
#define OPTIONAL_BOOL_POINTER_ARG(name) \
bool i_##name##_value; \
bool* name = NULL; \
if (arg <= max_args) { \
i_##name##_value = lua_toboolean(L, arg++); \
name = &(i_##name##_value); \
}
#define END_BOOL_POINTER(name) \
if (name != NULL) { \
lua_pushboolean(L, (int)i_##name##_value); \
stackval++; \
}
#define VOID_ARG(name) \
void* name = NULL; \
size_t arg_##name = arg++; \
lua_Number o_##name##_int; \
bool o_##name##_bool; \
char* o_##name##_str; \
int type_##name = lua_type(L, arg_##name); \
switch (type_##name) { \
case LUA_TNUMBER: \
{ \
o_##name##_int = luaL_checknumber(L, arg_##name); \
name = (void*)&o_##name##_int; \
break; \
} \
case LUA_TBOOLEAN: \
{ \
o_##name##_bool = lua_toboolean(L, arg_##name); \
name = (void*)&o_##name##_bool; \
break; \
} \
case LUA_TSTRING: \
{ \
size_t i_##name##_size; \
o_##name##_str = const_cast<char*>(luaL_checklstring(L, arg_##name, &(i_##name##_size))); \
name = (void*)&o_##name##_str; \
break; \
} \
}
#define OPTIONAL_VOID_ARG(name, otherwise) \
void* name = NULL; \
size_t arg_##name = arg++; \
if (arg_##name <= max_args) { \
lua_Number o_##name##_int; \
bool o_##name##_bool; \
char* o_##name##_str; \
int type_##name = lua_type(L, arg_##name); \
switch (type_##name) { \
case LUA_TNUMBER: \
{ \
o_##name##_int = luaL_checknumber(L, arg_##name); \
name = (void*)&o_##name##_int; \
break; \
} \
case LUA_TBOOLEAN: \
{ \
o_##name##_bool = lua_toboolean(L, arg_##name); \
name = (void*)&o_##name##_bool; \
break; \
} \
case LUA_TSTRING: \
{ \
size_t i_##name##_size; \
o_##name##_str = const_cast<char*>(luaL_checklstring(L, arg_##name, &(i_##name##_size))); \
name = (void*)&o_##name##_str; \
break; \
} \
} \
}
#define CALLBACK_STUB(name, callback) \
callback name = NULL;
#define CALL_FUNCTION(name, retType,...) \
retType ret = ImGui::name(__VA_ARGS__);
#define DRAW_LIST_CALL_FUNCTION(name, retType,...) \
retType ret = ImGui::GetWindowDrawList()->name(__VA_ARGS__);
#define CALL_FUNCTION_NO_RET(name, ...) \
ImGui::name(__VA_ARGS__);
#define DRAW_LIST_CALL_FUNCTION_NO_RET(name, ...) \
ImGui::GetWindowDrawList()->name(__VA_ARGS__);
#define PUSH_STRING(name) \
lua_pushstring(L, name); \
stackval++;
#define PUSH_NUMBER(name) \
lua_pushnumber(L, name); \
stackval++;
#define PUSH_BOOL(name) \
lua_pushboolean(L, (int) name); \
stackval++;
#define PUSH_TABLE \
lua_newtable(L); \
stackval++;
#define PUSH_TABLE_TABLE \
lua_newtable(L);
#define PUSH_TABLE_STRING(name) \
lua_pushstring(L, name);
#define PUSH_TABLE_NUMBER(name) \
lua_pushnumber(L, name);
#define PUSH_TABLE_BOOL(name) \
lua_pushboolean(L, (int) name);
#define SET_TABLE_FIELD(name) \
lua_setfield(L, -2, name);
#define END_IMGUI_FUNC \
return stackval; \
}
#ifdef ENABLE_IM_LUA_END_STACK
#define IF_RET_ADD_END_STACK(type) \
if (ret) { \
AddToStack(type); \
}
#define ADD_END_STACK(type) \
AddToStack(type);
#define POP_END_STACK(type) \
PopEndStack(type);
#define END_STACK_START \
static void ImEndStack(int type) { \
switch(type) {
#define END_STACK_OPTION(type, function) \
case type: \
ImGui::function(); \
break;
#define END_STACK_END \
} \
}
#else
#define END_STACK_START
#define END_STACK_OPTION(type, function)
#define END_STACK_END
#define IF_RET_ADD_END_STACK(type)
#define ADD_END_STACK(type)
#define POP_END_STACK(type)
#endif
#define START_ENUM(name)
#define MAKE_ENUM(c_name,lua_name)
#define END_ENUM(name)
#include "imgui_iterator.h"
static const struct luaL_Reg imguilib [] = {
#undef IMGUI_FUNCTION
#define IMGUI_FUNCTION(name) {#name, impl_##name},
#undef IMGUI_FUNCTION_DRAW_LIST
#define IMGUI_FUNCTION_DRAW_LIST(name) {"DrawList_" #name, impl_draw_list_##name},
// These defines are just redefining everything to nothing so
// we can get the function names
#undef IM_TEXTURE_ID_ARG
#define IM_TEXTURE_ID_ARG(name)
#undef OPTIONAL_LABEL_ARG
#define OPTIONAL_LABEL_ARG(name, otherwise)
#undef LABEL_ARG
#define LABEL_ARG(name)
#undef IOTEXT_ARG
#define IOTEXT_ARG(name)
#undef IM_VEC_2_ARG
#define IM_VEC_2_ARG(name)
#undef OPTIONAL_IM_VEC_2_ARG
#define OPTIONAL_IM_VEC_2_ARG(name, x, y)
#undef IM_VEC_4_ARG
#define IM_VEC_4_ARG(name)
#undef OPTIONAL_IM_VEC_4_ARG
#define OPTIONAL_IM_VEC_4_ARG(name, x, y, z, w)
#undef NUMBER_ARG
#define NUMBER_ARG(name)
#undef FLOAT_ARRAY_DEF
#define FLOAT_ARRAY_DEF(name, size)
#undef FLOAT_ARRAY_ARG
#define FLOAT_ARRAY_ARG(name, it)
#undef OPTIONAL_NUMBER_ARG
#define OPTIONAL_NUMBER_ARG(name, otherwise)
#undef FLOAT_POINTER_ARG
#define FLOAT_POINTER_ARG(name)
#undef END_FLOAT_POINTER
#define END_FLOAT_POINTER(name)
#undef OPTIONAL_INT_ARG
#define OPTIONAL_INT_ARG(name, otherwise)
#undef INT_ARG
#define INT_ARG(name)
#undef INT_ARRAY_DEF
#define INT_ARRAY_DEF(name,size)
#undef INT_ARRAY_ARG
#define INT_ARRAY_ARG(name,it)
#undef OPTIONAL_UINT_ARG
#define OPTIONAL_UINT_ARG(name, otherwise)
#undef UINT_ARG
#define UINT_ARG(name)
#undef INT_POINTER_ARG
#define INT_POINTER_ARG(name)
#undef END_INT_POINTER
#define END_INT_POINTER(name)
#undef UINT_POINTER_ARG
#define UINT_POINTER_ARG(name)
#undef END_UINT_POINTER
#define END_UINT_POINTER(name)
#undef BOOL_POINTER_ARG
#define BOOL_POINTER_ARG(name)
#undef OPTIONAL_BOOL_POINTER_ARG
#define OPTIONAL_BOOL_POINTER_ARG(name)
#undef OPTIONAL_BOOL_ARG
#define OPTIONAL_BOOL_ARG(name, otherwise)
#undef BOOL_ARG
#define BOOL_ARG(name)
#undef VOID_ARG
#define VOID_ARG(name)
#undef OPTIONAL_VOID_ARG
#define OPTIONAL_VOID_ARG(name, otherwise)
#undef CALLBACK_STUB
#define CALLBACK_STUB(name, callback)
#undef CALL_FUNCTION
#define CALL_FUNCTION(name, retType, ...)
#undef DRAW_LIST_CALL_FUNCTION
#define DRAW_LIST_CALL_FUNCTION(name, retType, ...)
#undef CALL_FUNCTION_NO_RET
#define CALL_FUNCTION_NO_RET(name, ...)
#undef DRAW_LIST_CALL_FUNCTION_NO_RET
#define DRAW_LIST_CALL_FUNCTION_NO_RET(name, ...)
#undef PUSH_STRING
#define PUSH_STRING(name)
#undef END_IOTEXT
#define END_IOTEXT(name)
#undef PUSH_NUMBER
#define PUSH_NUMBER(name)
#undef PUSH_BOOL
#define PUSH_BOOL(name)
#undef PUSH_TABLE
#define PUSH_TABLE
#undef PUSH_TABLE_TABLE
#define PUSH_TABLE_TABLE
#undef PUSH_TABLE_STRING
#define PUSH_TABLE_STRING(name)
#undef PUSH_TABLE_NUMBER
#define PUSH_TABLE_NUMBER(name)
#undef PUSH_TABLE_BOOL
#define PUSH_TABLE_BOOL(name)
#undef SET_TABLE_FIELD
#define SET_TABLE_FIELD(name)
#undef END_BOOL_POINTER
#define END_BOOL_POINTER(name)
#undef END_IMGUI_FUNC
#define END_IMGUI_FUNC
#undef END_STACK_START
#define END_STACK_START
#undef END_STACK_OPTION
#define END_STACK_OPTION(type, function)
#undef END_STACK_END
#define END_STACK_END
#undef IF_RET_ADD_END_STACK
#define IF_RET_ADD_END_STACK(type)
#undef ADD_END_STACK
#define ADD_END_STACK(type)
#undef POP_END_STACK
#define POP_END_STACK(type)
#undef START_ENUM
#define START_ENUM(name)
#undef MAKE_ENUM
#define MAKE_ENUM(c_name,lua_name)
#undef END_ENUM
#define END_ENUM(name)
#include "imgui_iterator.h"
// impl_Button is undeclared
// {"Button", impl_Button},
{NULL, NULL}
};
static void PushImguiEnums(lua_State* lState, const char* tableName) {
lua_pushstring(lState, tableName);
lua_newtable(lState);
#undef START_ENUM
#undef MAKE_ENUM
#undef END_ENUM
#define START_ENUM(name) \
lua_pushstring(lState, #name); \
lua_newtable(lState); \
{ \
int i = 1;
#define MAKE_ENUM(c_name,lua_name) \
lua_pushstring(lState, #lua_name); \
lua_pushnumber(lState, c_name); \
lua_rawset(lState, -3);
#define END_ENUM(name) \
} \
lua_rawset(lState, -3);
// These defines are just redefining everything to nothing so
// we get only the enums.
#undef IMGUI_FUNCTION
#define IMGUI_FUNCTION(name)
#undef IMGUI_FUNCTION_DRAW_LIST
#define IMGUI_FUNCTION_DRAW_LIST(name)
#undef IM_TEXTURE_ID_ARG
#define IM_TEXTURE_ID_ARG(name)
#undef OPTIONAL_LABEL_ARG
#define OPTIONAL_LABEL_ARG(name, otherwise)
#undef LABEL_ARG
#define LABEL_ARG(name)
#undef IOTEXT_ARG
#define IOTEXT_ARG(name)
#undef IM_VEC_2_ARG
#define IM_VEC_2_ARG(name)
#undef OPTIONAL_IM_VEC_2_ARG
#define OPTIONAL_IM_VEC_2_ARG(name, x, y)
#undef IM_VEC_4_ARG
#define IM_VEC_4_ARG(name)
#undef OPTIONAL_IM_VEC_4_ARG
#define OPTIONAL_IM_VEC_4_ARG(name, x, y, z, w)
#undef NUMBER_ARG
#define NUMBER_ARG(name)
#undef FLOAT_ARRAY_DEF
#define FLOAT_ARRAY_DEF(name, size)
#undef FLOAT_ARRAY_ARG
#define FLOAT_ARRAY_ARG(name, it)
#undef OPTIONAL_NUMBER_ARG
#define OPTIONAL_NUMBER_ARG(name, otherwise)
#undef FLOAT_POINTER_ARG
#define FLOAT_POINTER_ARG(name)
#undef END_FLOAT_POINTER
#define END_FLOAT_POINTER(name)
#undef OPTIONAL_INT_ARG
#define OPTIONAL_INT_ARG(name, otherwise)
#undef INT_ARG
#define INT_ARG(name)
#undef INT_ARRAY_DEF
#define INT_ARRAY_DEF(name,size)
#undef INT_ARRAY_ARG
#define INT_ARRAY_ARG(name,it)
#undef OPTIONAL_UINT_ARG
#define OPTIONAL_UINT_ARG(name, otherwise)
#undef UINT_ARG
#define UINT_ARG(name)
#undef INT_POINTER_ARG
#define INT_POINTER_ARG(name)
#undef END_INT_POINTER
#define END_INT_POINTER(name)
#undef UINT_POINTER_ARG
#define UINT_POINTER_ARG(name)
#undef END_UINT_POINTER
#define END_UINT_POINTER(name)
#undef BOOL_POINTER_ARG
#define BOOL_POINTER_ARG(name)
#undef OPTIONAL_BOOL_POINTER_ARG
#define OPTIONAL_BOOL_POINTER_ARG(name)
#undef OPTIONAL_BOOL_ARG
#define OPTIONAL_BOOL_ARG(name, otherwise)
#undef BOOL_ARG
#define BOOL_ARG(name)
#undef VOID_ARG
#define VOID_ARG(name)
#undef OPTIONAL_VOID_ARG
#define OPTIONAL_VOID_ARG(name, otherwise)
#undef CALLBACK_STUB
#define CALLBACK_STUB(name, callback)
#undef CALL_FUNCTION
#define CALL_FUNCTION(name, retType, ...)
#undef DRAW_LIST_CALL_FUNCTION
#define DRAW_LIST_CALL_FUNCTION(name, retType, ...)
#undef CALL_FUNCTION_NO_RET
#define CALL_FUNCTION_NO_RET(name, ...)
#undef DRAW_LIST_CALL_FUNCTION_NO_RET
#define DRAW_LIST_CALL_FUNCTION_NO_RET(name, ...)
#undef PUSH_STRING
#define PUSH_STRING(name)
#undef END_IOTEXT
#define END_IOTEXT(name)
#undef PUSH_NUMBER
#define PUSH_NUMBER(name)
#undef PUSH_BOOL
#define PUSH_BOOL(name)
#undef PUSH_TABLE
#define PUSH_TABLE
#undef PUSH_TABLE_TABLE
#define PUSH_TABLE_TABLE
#undef PUSH_TABLE_STRING
#define PUSH_TABLE_STRING(name)
#undef PUSH_TABLE_NUMBER
#define PUSH_TABLE_NUMBER(name)
#undef PUSH_TABLE_BOOL
#define PUSH_TABLE_BOOL(name)
#undef SET_TABLE_FIELD
#define SET_TABLE_FIELD(name)
#undef END_BOOL_POINTER
#define END_BOOL_POINTER(name)
#undef END_IMGUI_FUNC
#define END_IMGUI_FUNC
#undef END_STACK_START
#define END_STACK_START
#undef END_STACK_OPTION
#define END_STACK_OPTION(type, function)
#undef END_STACK_END
#define END_STACK_END
#undef IF_RET_ADD_END_STACK
#define IF_RET_ADD_END_STACK(type)
#undef ADD_END_STACK
#define ADD_END_STACK(type)
#undef POP_END_STACK
#define POP_END_STACK(type)
#include "imgui_iterator.h"
lua_rawset(lState, -3);
};
void LoadImguiBindings() {
if (!lState) {
fprintf(stderr, "You didn't assign the global lState, either assign that or refactor LoadImguiBindings and RunString\n");
}
lua_newtable(lState);
luaL_setfuncs(lState, imguilib, 0);
PushImguiEnums(lState, "constant");
lua_setglobal(lState, "imgui");
}
std::vector<int> drawList;
int imgui_draw(lua_State *L){
lua_pushvalue(L, 1);
auto ref = luaL_ref(L, LUA_REGISTRYINDEX);
drawList.push_back(ref);
return 1;
}