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
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
|
/**
* lite_xl_plugin_api.h
* API for writing C extension modules loaded by Lite XL.
* This file is licensed under MIT.
*
* The Lite XL plugin API is quite simple.
* You would write a lua C extension and replace any references to lua.h, lauxlib.h
* and lualib.h with lite_xl_plugin_api.h.
* In your main file (where your entrypoint resides), define LITE_XL_PLUGIN_ENTRYPOINT.
* If you have multiple entrypoints, define LITE_XL_PLUGIN_ENTRYPOINT in one of them.
*
* After that, you need to create a Lite XL entrypoint, which is formatted as
* luaopen_lite_xl_xxxxx instead of luaopen_xxxxx.
* This entrypoint accepts a lua_State and an extra parameter of type void *.
* In this entrypoint, call lite_xl_plugin_init() with the extra parameter.
* If you have multiple entrypoints, you must call lite_xl_plugin_init() in
* each of them.
* This function is not thread safe, so don't try to do anything stupid.
*
* An example:
*
* #define LITE_XL_PLUGIN_ENTRYPOINT
* #include "lite_xl_plugin_api.h"
* int luaopen_lite_xl_xxxxx(lua_State* L, void* XL) {
* lite_xl_plugin_init(XL);
* ...
* return 1;
* }
*
* You can compile the library just like any Lua library without linking to Lua.
* An example command would be: gcc -shared -o xxxxx.so xxxxx.c
* You must not link to ANY lua library to avoid symbol collision.
*
* This file contains stock configuration for a typical installation of Lua 5.4.6.
* DO NOT MODIFY ANYTHING. MODIFYING STUFFS IN HERE WILL BREAK
* COMPATIBILITY WITH LITE XL AND CAUSE UNDEBUGGABLE BUGS.
*
* For reference, here are a list of permalinks to previous version of this file that targets an older version of Lua.
* If you don't need functionalities offered by the new version, use the OLDEST FILE for backwards compatibility.
*
* - Lua 5.4.4: https://github.com/lite-xl/lite-xl/blob/397973067f14420b26e3b20a238a50016c0b75e2/resources/include/lite_xl_plugin_api.h
**/
#ifndef LITE_XL_PLUGIN_API
#define LITE_XL_PLUGIN_API
#include <stdio.h>
#include <stdlib.h>
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/* FOR_EACH macro */
#define CONCAT(arg1, arg2) CONCAT1(arg1, arg2)
#define CONCAT1(arg1, arg2) CONCAT2(arg1, arg2)
#define CONCAT2(arg1, arg2) arg1##arg2
#define FE_1(what, x) what x
#define FE_2(what, x, ...) what x,FE_1(what, __VA_ARGS__)
#define FE_3(what, x, ...) what x,FE_2(what, __VA_ARGS__)
#define FE_4(what, x, ...) what x,FE_3(what, __VA_ARGS__)
#define FE_5(what, x, ...) what x,FE_4(what, __VA_ARGS__)
#define FE_6(what, x, ...) what x,FE_5(what, __VA_ARGS__)
#define FE_7(what, x, ...) what x,FE_6(what, __VA_ARGS__)
#define FE_8(what, x, ...) what x,FE_7(what, __VA_ARGS__)
#define FOR_EACH_NARG(...) FOR_EACH_NARG_(__VA_ARGS__, FOR_EACH_RSEQ_N())
#define FOR_EACH_NARG_(...) FOR_EACH_ARG_N(__VA_ARGS__)
#define FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
#define FOR_EACH_RSEQ_N() 8, 7, 6, 5, 4, 3, 2, 1, 0
#define FOR_EACH_(N, what, ...) CONCAT(FE_, N)(what, __VA_ARGS__)
#define FOR_EACH(what, ...) FOR_EACH_(FOR_EACH_NARG(__VA_ARGS__), what, __VA_ARGS__)
#define SYMBOL_WRAP_DECL(ret, name, ...) \
ret name(__VA_ARGS__)
#define SYMBOL_WRAP_CALL(name, ...) \
__##name(__VA_ARGS__)
#define SYMBOL_WRAP_CALL_FB(name, ...) \
return __lite_xl_fallback_##name(__VA_ARGS__)
#ifdef LITE_XL_PLUGIN_ENTRYPOINT
#define SYMBOL_DECLARE(ret, name, ...) \
static ret (*__##name) (__VA_ARGS__); \
SYMBOL_WRAP_DECL(ret, name, __VA_ARGS__); \
static ret __lite_xl_fallback_##name(FOR_EACH(UNUSED, __VA_ARGS__)) { \
fputs("warning: " #name " is a stub", stderr); \
exit(1); \
}
#define SYMBOL_DECLARE_VARARG(ret, name, ...) \
static ret (*__##name) (__VA_ARGS__, ...); \
SYMBOL_WRAP_DECL(ret, name, __VA_ARGS__, ...); \
static ret __lite_xl_fallback_##name(FOR_EACH(UNUSED, __VA_ARGS__), ...) { \
fputs("warning: " #name " is a stub", stderr); \
exit(1); \
}
#else
#define SYMBOL_DECLARE(ret, name, ...) \
SYMBOL_WRAP_DECL(ret, name, __VA_ARGS__);
#define SYMBOL_DECLARE_VARARG(ret, name, ...) \
SYMBOL_WRAP_DECL(ret, name, __VA_ARGS__, ...);
#endif
/*
** $Id: luaconf.h $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
#ifndef luaconf_h
#define luaconf_h
#include <limits.h>
#include <stddef.h>
/*
** ===================================================================
** General Configuration File for Lua
**
** Some definitions here can be changed externally, through the compiler
** (e.g., with '-D' options): They are commented out or protected
** by '#if !defined' guards. However, several other definitions
** should be changed directly here, either because they affect the
** Lua ABI (by making the changes here, you ensure that all software
** connected to Lua, such as C libraries, will be compiled with the same
** configuration); or because they are seldom changed.
**
** Search for "@@" to find all configurable definitions.
** ===================================================================
*/
/*
** {====================================================================
** System Configuration: macros to adapt (if needed) Lua to some
** particular platform, for instance restricting it to C89.
** =====================================================================
*/
/*
@@ LUA_USE_C89 controls the use of non-ISO-C89 features.
** Define it if you want Lua to avoid the use of a few C99 features
** or Windows-specific features on Windows.
*/
/* #define LUA_USE_C89 */
/*
** By default, Lua on Windows use (some) specific Windows features
*/
#if !defined(LUA_USE_C89) && defined(_WIN32) && !defined(_WIN32_WCE)
#define LUA_USE_WINDOWS /* enable goodies for regular Windows */
#endif
#if defined(LUA_USE_WINDOWS)
#define LUA_DL_DLL /* enable support for DLL */
#define LUA_USE_C89 /* broadly, Windows is C89 */
#endif
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
#endif
#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* MacOS does not need -ldl */
#endif
/*
@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
*/
#define LUAI_IS32INT ((UINT_MAX >> 30) >= 3)
/* }================================================================== */
/*
** {==================================================================
** Configuration for Number types. These options should not be
** set externally, because any other code connected to Lua must
** use the same configuration.
** ===================================================================
*/
/*
@@ LUA_INT_TYPE defines the type for Lua integers.
@@ LUA_FLOAT_TYPE defines the type for Lua floats.
** Lua should work fine with any mix of these options supported
** by your C compiler. The usual configurations are 64-bit integers
** and 'double' (the default), 32-bit integers and 'float' (for
** restricted platforms), and 'long'/'double' (for C compilers not
** compliant with C99, which may not have support for 'long long').
*/
/* predefined options for LUA_INT_TYPE */
#define LUA_INT_INT 1
#define LUA_INT_LONG 2
#define LUA_INT_LONGLONG 3
/* predefined options for LUA_FLOAT_TYPE */
#define LUA_FLOAT_FLOAT 1
#define LUA_FLOAT_DOUBLE 2
#define LUA_FLOAT_LONGDOUBLE 3
/* Default configuration ('long long' and 'double', for 64-bit Lua) */
#define LUA_INT_DEFAULT LUA_INT_LONGLONG
#define LUA_FLOAT_DEFAULT LUA_FLOAT_DOUBLE
/*
@@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats.
*/
#define LUA_32BITS 0
/*
@@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
** C89 ('long' and 'double'); Windows always has '__int64', so it does
** not need to use this case.
*/
#if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS)
#define LUA_C89_NUMBERS 1
#else
#define LUA_C89_NUMBERS 0
#endif
#if LUA_32BITS /* { */
/*
** 32-bit integers and 'float'
*/
#if LUAI_IS32INT /* use 'int' if big enough */
#define LUA_INT_TYPE LUA_INT_INT
#else /* otherwise use 'long' */
#define LUA_INT_TYPE LUA_INT_LONG
#endif
#define LUA_FLOAT_TYPE LUA_FLOAT_FLOAT
#elif LUA_C89_NUMBERS /* }{ */
/*
** largest types available for C89 ('long' and 'double')
*/
#define LUA_INT_TYPE LUA_INT_LONG
#define LUA_FLOAT_TYPE LUA_FLOAT_DOUBLE
#else /* }{ */
/* use defaults */
#define LUA_INT_TYPE LUA_INT_DEFAULT
#define LUA_FLOAT_TYPE LUA_FLOAT_DEFAULT
#endif /* } */
/* }================================================================== */
/*
** {==================================================================
** Configuration for Paths.
** ===================================================================
*/
/*
** LUA_PATH_SEP is the character that separates templates in a path.
** LUA_PATH_MARK is the string that marks the substitution points in a
** template.
** LUA_EXEC_DIR in a Windows path is replaced by the executable's
** directory.
*/
#define LUA_PATH_SEP ";"
#define LUA_PATH_MARK "?"
#define LUA_EXEC_DIR "!"
/*
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
** Lua libraries.
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
** C libraries.
** CHANGE them if your machine has a non-conventional directory
** hierarchy or if you want to install your libraries in
** non-conventional directories.
*/
#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
#if defined(_WIN32) /* { */
/*
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/
#define LUA_LDIR "!\\lua\\"
#define LUA_CDIR "!\\"
#define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\"
#if !defined(LUA_PATH_DEFAULT)
#define LUA_PATH_DEFAULT \
LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \
LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \
".\\?.lua;" ".\\?\\init.lua"
#endif
#if !defined(LUA_CPATH_DEFAULT)
#define LUA_CPATH_DEFAULT \
LUA_CDIR"?.dll;" \
LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \
LUA_CDIR"loadall.dll;" ".\\?.dll"
#endif
#else /* }{ */
#define LUA_ROOT "/usr/local/"
#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
#if !defined(LUA_PATH_DEFAULT)
#define LUA_PATH_DEFAULT \
LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
"./?.lua;" "./?/init.lua"
#endif
#if !defined(LUA_CPATH_DEFAULT)
#define LUA_CPATH_DEFAULT \
LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so"
#endif
#endif /* } */
/*
@@ LUA_DIRSEP is the directory separator (for submodules).
** CHANGE it if your machine does not use "/" as the directory separator
** and is not Windows. (On Windows Lua automatically uses "\".)
*/
#if !defined(LUA_DIRSEP)
#if defined(_WIN32)
#define LUA_DIRSEP "\\"
#else
#define LUA_DIRSEP "/"
#endif
#endif
/* }================================================================== */
/*
** {==================================================================
** Marks for exported symbols in the C code
** ===================================================================
*/
/*
@@ LUA_API is a mark for all core API functions.
@@ LUALIB_API is a mark for all auxiliary library functions.
@@ LUAMOD_API is a mark for all standard library opening functions.
** CHANGE them if you need to define those functions in some special way.
** For instance, if you want to create one Windows DLL with the core and
** the libraries, you may want to use the following definition (define
** LUA_BUILD_AS_DLL to get it).
*/
#if defined(LUA_BUILD_AS_DLL) /* { */
#if defined(LUA_CORE) || defined(LUA_LIB) /* { */
#define LUA_API __declspec(dllexport)
#else /* }{ */
#define LUA_API __declspec(dllimport)
#endif /* } */
#else /* }{ */
#define LUA_API extern
#endif /* } */
/*
** More often than not the libs go together with the core.
*/
#define LUALIB_API LUA_API
#define LUAMOD_API LUA_API
/*
@@ LUAI_FUNC is a mark for all extern functions that are not to be
** exported to outside modules.
@@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
** none of which to be exported to outside modules (LUAI_DDEF for
** definitions and LUAI_DDEC for declarations).
** CHANGE them if you need to mark them in some special way. Elf/gcc
** (versions 3.2 and later) mark them as "hidden" to optimize access
** when Lua is compiled as a shared library. Not all elf targets support
** this attribute. Unfortunately, gcc does not offer a way to check
** whether the target offers that support, and those without support
** give a warning about it. To avoid these warnings, change to the
** default definition.
*/
#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
defined(__ELF__) /* { */
#define LUAI_FUNC __attribute__((visibility("internal"))) extern
#else /* }{ */
#define LUAI_FUNC extern
#endif /* } */
#define LUAI_DDEC(dec) LUAI_FUNC dec
#define LUAI_DDEF /* empty */
/* }================================================================== */
/*
** {==================================================================
** Compatibility with previous versions
** ===================================================================
*/
/*
@@ LUA_COMPAT_5_3 controls other macros for compatibility with Lua 5.3.
** You can define it to get all options, or change specific options
** to fit your specific needs.
*/
#if defined(LUA_COMPAT_5_3) /* { */
/*
@@ LUA_COMPAT_MATHLIB controls the presence of several deprecated
** functions in the mathematical library.
** (These functions were already officially removed in 5.3;
** nevertheless they are still available here.)
*/
#define LUA_COMPAT_MATHLIB
/*
@@ LUA_COMPAT_APIINTCASTS controls the presence of macros for
** manipulating other integer types (lua_pushunsigned, lua_tounsigned,
** luaL_checkint, luaL_checklong, etc.)
** (These macros were also officially removed in 5.3, but they are still
** available here.)
*/
#define LUA_COMPAT_APIINTCASTS
/*
@@ LUA_COMPAT_LT_LE controls the emulation of the '__le' metamethod
** using '__lt'.
*/
#define LUA_COMPAT_LT_LE
/*
@@ The following macros supply trivial compatibility for some
** changes in the API. The macros themselves document how to
** change your code to avoid using them.
** (Once more, these macros were officially removed in 5.3, but they are
** still available here.)
*/
#define lua_strlen(L,i) lua_rawlen(L, (i))
#define lua_objlen(L,i) lua_rawlen(L, (i))
#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
#define lua_lessthan(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPLT)
#endif /* } */
/* }================================================================== */
/*
** {==================================================================
** Configuration for Numbers (low-level part).
** Change these definitions if no predefined LUA_FLOAT_* / LUA_INT_*
** satisfy your needs.
** ===================================================================
*/
/*
@@ LUAI_UACNUMBER is the result of a 'default argument promotion'
@@ over a floating number.
@@ l_floatatt(x) corrects float attribute 'x' to the proper float type
** by prefixing it with one of FLT/DBL/LDBL.
@@ LUA_NUMBER_FRMLEN is the length modifier for writing floats.
@@ LUA_NUMBER_FMT is the format for writing floats.
@@ lua_number2str converts a float to a string.
@@ l_mathop allows the addition of an 'l' or 'f' to all math operations.
@@ l_floor takes the floor of a float.
@@ lua_str2number converts a decimal numeral to a number.
*/
/* The following definitions are good for most cases here */
#define l_floor(x) (l_mathop(floor)(x))
#define lua_number2str(s,sz,n) \
l_sprintf((s), sz, LUA_NUMBER_FMT, (LUAI_UACNUMBER)(n))
/*
@@ lua_numbertointeger converts a float number with an integral value
** to an integer, or returns 0 if float is not within the range of
** a lua_Integer. (The range comparisons are tricky because of
** rounding. The tests here assume a two-complement representation,
** where MININTEGER always has an exact representation as a float;
** MAXINTEGER may not have one, and therefore its conversion to float
** may have an ill-defined value.)
*/
#define lua_numbertointeger(n,p) \
((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \
(n) < -(LUA_NUMBER)(LUA_MININTEGER) && \
(*(p) = (LUA_INTEGER)(n), 1))
/* now the variable definitions */
#if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */
#define LUA_NUMBER float
#define l_floatatt(n) (FLT_##n)
#define LUAI_UACNUMBER double
#define LUA_NUMBER_FRMLEN ""
#define LUA_NUMBER_FMT "%.7g"
#define l_mathop(op) op##f
#define lua_str2number(s,p) strtof((s), (p))
#elif LUA_FLOAT_TYPE == LUA_FLOAT_LONGDOUBLE /* }{ long double */
#define LUA_NUMBER long double
#define l_floatatt(n) (LDBL_##n)
#define LUAI_UACNUMBER long double
#define LUA_NUMBER_FRMLEN "L"
#define LUA_NUMBER_FMT "%.19Lg"
#define l_mathop(op) op##l
#define lua_str2number(s,p) strtold((s), (p))
#elif LUA_FLOAT_TYPE == LUA_FLOAT_DOUBLE /* }{ double */
#define LUA_NUMBER double
#define l_floatatt(n) (DBL_##n)
#define LUAI_UACNUMBER double
#define LUA_NUMBER_FRMLEN ""
#define LUA_NUMBER_FMT "%.14g"
#define l_mathop(op) op
#define lua_str2number(s,p) strtod((s), (p))
#else /* }{ */
#error "numeric float type not defined"
#endif /* } */
/*
@@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER.
@@ LUAI_UACINT is the result of a 'default argument promotion'
@@ over a LUA_INTEGER.
@@ LUA_INTEGER_FRMLEN is the length modifier for reading/writing integers.
@@ LUA_INTEGER_FMT is the format for writing integers.
@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
@@ lua_integer2str converts an integer to a string.
*/
/* The following definitions are good for most cases here */
#define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d"
#define LUAI_UACINT LUA_INTEGER
#define lua_integer2str(s,sz,n) \
l_sprintf((s), sz, LUA_INTEGER_FMT, (LUAI_UACINT)(n))
/*
** use LUAI_UACINT here to avoid problems with promotions (which
** can turn a comparison between unsigneds into a signed comparison)
*/
#define LUA_UNSIGNED unsigned LUAI_UACINT
/* now the variable definitions */
#if LUA_INT_TYPE == LUA_INT_INT /* { int */
#define LUA_INTEGER int
#define LUA_INTEGER_FRMLEN ""
#define LUA_MAXINTEGER INT_MAX
#define LUA_MININTEGER INT_MIN
#define LUA_MAXUNSIGNED UINT_MAX
#elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */
#define LUA_INTEGER long
#define LUA_INTEGER_FRMLEN "l"
#define LUA_MAXINTEGER LONG_MAX
#define LUA_MININTEGER LONG_MIN
#define LUA_MAXUNSIGNED ULONG_MAX
#elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */
/* use presence of macro LLONG_MAX as proxy for C99 compliance */
#if defined(LLONG_MAX) /* { */
/* use ISO C99 stuff */
#define LUA_INTEGER long long
#define LUA_INTEGER_FRMLEN "ll"
#define LUA_MAXINTEGER LLONG_MAX
#define LUA_MININTEGER LLONG_MIN
#define LUA_MAXUNSIGNED ULLONG_MAX
#elif defined(LUA_USE_WINDOWS) /* }{ */
/* in Windows, can use specific Windows types */
#define LUA_INTEGER __int64
#define LUA_INTEGER_FRMLEN "I64"
#define LUA_MAXINTEGER _I64_MAX
#define LUA_MININTEGER _I64_MIN
#define LUA_MAXUNSIGNED _UI64_MAX
#else /* }{ */
#error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \
or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)"
#endif /* } */
#else /* }{ */
#error "numeric integer type not defined"
#endif /* } */
/* }================================================================== */
/*
** {==================================================================
** Dependencies with C99 and other C details
** ===================================================================
*/
/*
@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
** (All uses in Lua have only one format item.)
*/
#if !defined(LUA_USE_C89)
#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
#else
#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i))
#endif
/*
@@ lua_strx2number converts a hexadecimal numeral to a number.
** In C99, 'strtod' does that conversion. Otherwise, you can
** leave 'lua_strx2number' undefined and Lua will provide its own
** implementation.
*/
#if !defined(LUA_USE_C89)
#define lua_strx2number(s,p) lua_str2number(s,p)
#endif
/*
@@ lua_pointer2str converts a pointer to a readable string in a
** non-specified way.
*/
#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p)
/*
@@ lua_number2strx converts a float to a hexadecimal numeral.
** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that.
** Otherwise, you can leave 'lua_number2strx' undefined and Lua will
** provide its own implementation.
*/
#if !defined(LUA_USE_C89)
#define lua_number2strx(L,b,sz,f,n) \
((void)L, l_sprintf(b,sz,f,(LUAI_UACNUMBER)(n)))
#endif
/*
** 'strtof' and 'opf' variants for math functions are not valid in
** C89. Otherwise, the macro 'HUGE_VALF' is a good proxy for testing the
** availability of these variants. ('math.h' is already included in
** all files that use these macros.)
*/
#if defined(LUA_USE_C89) || (defined(HUGE_VAL) && !defined(HUGE_VALF))
#undef l_mathop /* variants not available */
#undef lua_str2number
#define l_mathop(op) (lua_Number)op /* no variant */
#define lua_str2number(s,p) ((lua_Number)strtod((s), (p)))
#endif
/*
@@ LUA_KCONTEXT is the type of the context ('ctx') for continuation
** functions. It must be a numerical type; Lua will use 'intptr_t' if
** available, otherwise it will use 'ptrdiff_t' (the nearest thing to
** 'intptr_t' in C89)
*/
#define LUA_KCONTEXT ptrdiff_t
#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
__STDC_VERSION__ >= 199901L
#include <stdint.h>
#if defined(INTPTR_MAX) /* even in C99 this type is optional */
#undef LUA_KCONTEXT
#define LUA_KCONTEXT intptr_t
#endif
#endif
/*
@@ lua_getlocaledecpoint gets the locale "radix character" (decimal point).
** Change that if you do not want to use C locales. (Code using this
** macro must include the header 'locale.h'.)
*/
#if !defined(lua_getlocaledecpoint)
#define lua_getlocaledecpoint() (localeconv()->decimal_point[0])
#endif
/*
** macros to improve jump prediction, used mostly for error handling
** and debug facilities. (Some macros in the Lua API use these macros.
** Define LUA_NOBUILTIN if you do not want '__builtin_expect' in your
** code.)
*/
#if !defined(luai_likely)
#if defined(__GNUC__) && !defined(LUA_NOBUILTIN)
#define luai_likely(x) (__builtin_expect(((x) != 0), 1))
#define luai_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else
#define luai_likely(x) (x)
#define luai_unlikely(x) (x)
#endif
#endif
#if defined(LUA_CORE) || defined(LUA_LIB)
/* shorter names for Lua's own use */
#define l_likely(x) luai_likely(x)
#define l_unlikely(x) luai_unlikely(x)
#endif
/* }================================================================== */
/*
** {==================================================================
** Language Variations
** =====================================================================
*/
/*
@@ LUA_NOCVTN2S/LUA_NOCVTS2N control how Lua performs some
** coercions. Define LUA_NOCVTN2S to turn off automatic coercion from
** numbers to strings. Define LUA_NOCVTS2N to turn off automatic
** coercion from strings to numbers.
*/
/* #define LUA_NOCVTN2S */
/* #define LUA_NOCVTS2N */
/*
@@ LUA_USE_APICHECK turns on several consistency checks on the C API.
** Define it as a help when debugging C code.
*/
#if defined(LUA_USE_APICHECK)
#include <assert.h>
#define luai_apicheck(l,e) assert(e)
#endif
/* }================================================================== */
/*
** {==================================================================
** Macros that affect the API and must be stable (that is, must be the
** same when you compile Lua and when you compile code that links to
** Lua).
** =====================================================================
*/
/*
@@ LUAI_MAXSTACK limits the size of the Lua stack.
** CHANGE it if you need a different limit. This limit is arbitrary;
** its only purpose is to stop Lua from consuming unlimited stack
** space (and to reserve some numbers for pseudo-indices).
** (It must fit into max(size_t)/32.)
*/
#if LUAI_IS32INT
#define LUAI_MAXSTACK 1000000
#else
#define LUAI_MAXSTACK 15000
#endif
/*
@@ LUA_EXTRASPACE defines the size of a raw memory area associated with
** a Lua state with very fast access.
** CHANGE it if you need a different size.
*/
#define LUA_EXTRASPACE (sizeof(void *))
/*
@@ LUA_IDSIZE gives the maximum size for the description of the source
@@ of a function in debug information.
** CHANGE it if you want a different size.
*/
#define LUA_IDSIZE 60
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
*/
#define LUAL_BUFFERSIZE ((int)(16 * sizeof(void*) * sizeof(lua_Number)))
/*
@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure
** maximum alignment for the other items in that union.
*/
#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
/* }================================================================== */
#endif
/*
** $Id: lua.h $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
*/
#ifndef lua_h
#define lua_h
#include <stdarg.h>
#include <stddef.h>
#define LUA_VERSION_MAJOR "5"
#define LUA_VERSION_MINOR "4"
#define LUA_VERSION_RELEASE "4"
#define LUA_VERSION_NUM 504
#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 4)
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2022 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
/* mark for precompiled code ('<esc>Lua') */
#define LUA_SIGNATURE "\x1bLua"
/* option for multiple returns in 'lua_pcall' and 'lua_call' */
#define LUA_MULTRET (-1)
/*
** Pseudo-indices
** (-LUAI_MAXSTACK is the minimum valid index; we keep some free empty
** space after that to help overflow detection)
*/
#define LUA_REGISTRYINDEX (-LUAI_MAXSTACK - 1000)
#define lua_upvalueindex(i) (LUA_REGISTRYINDEX - (i))
/* thread status */
#define LUA_OK 0
#define LUA_YIELD 1
#define LUA_ERRRUN 2
#define LUA_ERRSYNTAX 3
#define LUA_ERRMEM 4
#define LUA_ERRERR 5
typedef struct lua_State lua_State;
/*
** basic types
*/
#define LUA_TNONE (-1)
#define LUA_TNIL 0
#define LUA_TBOOLEAN 1
#define LUA_TLIGHTUSERDATA 2
#define LUA_TNUMBER 3
#define LUA_TSTRING 4
#define LUA_TTABLE 5
#define LUA_TFUNCTION 6
#define LUA_TUSERDATA 7
#define LUA_TTHREAD 8
#define LUA_NUMTYPES 9
/* minimum Lua stack available to a C function */
#define LUA_MINSTACK 20
/* predefined values in the registry */
#define LUA_RIDX_MAINTHREAD 1
#define LUA_RIDX_GLOBALS 2
#define LUA_RIDX_LAST LUA_RIDX_GLOBALS
/* type of numbers in Lua */
typedef LUA_NUMBER lua_Number;
/* type for integer functions */
typedef LUA_INTEGER lua_Integer;
/* unsigned integer type */
typedef LUA_UNSIGNED lua_Unsigned;
/* type for continuation-function contexts */
typedef LUA_KCONTEXT lua_KContext;
/*
** Type for C functions registered with Lua
*/
typedef int (*lua_CFunction) (lua_State *L);
/*
** Type for continuation functions
*/
typedef int (*lua_KFunction) (lua_State *L, int status, lua_KContext ctx);
/*
** Type for functions that read/write blocks when loading/dumping Lua chunks
*/
typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
typedef int (*lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud);
/*
** Type for memory-allocation functions
*/
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
/*
** Type for warning functions
*/
typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);
/*
** generic extra include file
*/
#if defined(LUA_USER_H)
#include LUA_USER_H
#endif
/*
** RCS ident string
*/
extern const char lua_ident[];
/*
** state manipulation
*/
SYMBOL_DECLARE(lua_State *, lua_newstate, lua_Alloc f, void *ud)
SYMBOL_DECLARE(void, lua_close, lua_State *L)
SYMBOL_DECLARE(lua_State *, lua_newthread, lua_State *L)
SYMBOL_DECLARE(int, lua_closethread, lua_State *L, lua_State *from)
SYMBOL_DECLARE(int, lua_resetthread, lua_State *L)
SYMBOL_DECLARE(lua_CFunction, lua_atpanic, lua_State *L, lua_CFunction panicf)
SYMBOL_DECLARE(lua_Number, lua_version, lua_State *L)
/*
** basic stack manipulation
*/
SYMBOL_DECLARE(int , lua_absindex, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_gettop, lua_State *L)
SYMBOL_DECLARE(void, lua_settop, lua_State *L, int idx)
SYMBOL_DECLARE(void, lua_pushvalue, lua_State *L, int idx)
SYMBOL_DECLARE(void, lua_rotate, lua_State *L, int idx, int n)
SYMBOL_DECLARE(void, lua_copy, lua_State *L, int fromidx, int toidx)
SYMBOL_DECLARE(int , lua_checkstack, lua_State *L, int n)
SYMBOL_DECLARE(void, lua_xmove, lua_State *from, lua_State *to, int n)
/*
** access functions (stack -> C)
*/
SYMBOL_DECLARE(int , lua_isnumber, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_isstring, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_iscfunction, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_isinteger, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_isuserdata, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_type, lua_State *L, int idx)
SYMBOL_DECLARE(const char *, lua_typename, lua_State *L, int tp)
SYMBOL_DECLARE(lua_Number , lua_tonumberx, lua_State *L, int idx, int *isnum)
SYMBOL_DECLARE(lua_Integer , lua_tointegerx, lua_State *L, int idx, int *isnum)
SYMBOL_DECLARE(int , lua_toboolean, lua_State *L, int idx)
SYMBOL_DECLARE(const char *, lua_tolstring, lua_State *L, int idx, size_t *len)
SYMBOL_DECLARE(lua_Unsigned , lua_rawlen, lua_State *L, int idx)
SYMBOL_DECLARE(lua_CFunction , lua_tocfunction, lua_State *L, int idx)
SYMBOL_DECLARE(void *, lua_touserdata, lua_State *L, int idx)
SYMBOL_DECLARE(lua_State *, lua_tothread, lua_State *L, int idx)
SYMBOL_DECLARE(const void *, lua_topointer, lua_State *L, int idx)
/*
** Comparison and arithmetic functions
*/
#define LUA_OPADD 0 /* ORDER TM, ORDER OP */
#define LUA_OPSUB 1
#define LUA_OPMUL 2
#define LUA_OPMOD 3
#define LUA_OPPOW 4
#define LUA_OPDIV 5
#define LUA_OPIDIV 6
#define LUA_OPBAND 7
#define LUA_OPBOR 8
#define LUA_OPBXOR 9
#define LUA_OPSHL 10
#define LUA_OPSHR 11
#define LUA_OPUNM 12
#define LUA_OPBNOT 13
SYMBOL_DECLARE(void , lua_arith, lua_State *L, int op)
#define LUA_OPEQ 0
#define LUA_OPLT 1
#define LUA_OPLE 2
SYMBOL_DECLARE(int , lua_rawequal, lua_State *L, int idx1, int idx2)
SYMBOL_DECLARE(int , lua_compare, lua_State *L, int idx1, int idx2, int op)
/*
** push functions (C -> stack)
*/
SYMBOL_DECLARE(void , lua_pushnil, lua_State *L)
SYMBOL_DECLARE(void , lua_pushnumber, lua_State *L, lua_Number n)
SYMBOL_DECLARE(void , lua_pushinteger, lua_State *L, lua_Integer n)
SYMBOL_DECLARE(const char *, lua_pushlstring, lua_State *L, const char *s, size_t len)
SYMBOL_DECLARE(const char *, lua_pushstring, lua_State *L, const char *s)
SYMBOL_DECLARE(const char *, lua_pushvfstring, lua_State *L, const char *fmt,
va_list argp)
SYMBOL_DECLARE_VARARG(const char *, lua_pushfstring, lua_State *L, const char *fmt)
SYMBOL_DECLARE(void , lua_pushcclosure, lua_State *L, lua_CFunction fn, int n)
SYMBOL_DECLARE(void , lua_pushboolean, lua_State *L, int b)
SYMBOL_DECLARE(void , lua_pushlightuserdata, lua_State *L, void *p)
SYMBOL_DECLARE(int , lua_pushthread, lua_State *L)
/*
** get functions (Lua -> stack)
*/
SYMBOL_DECLARE(int , lua_getglobal, lua_State *L, const char *name)
SYMBOL_DECLARE(int , lua_gettable, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_getfield, lua_State *L, int idx, const char *k)
SYMBOL_DECLARE(int , lua_geti, lua_State *L, int idx, lua_Integer n)
SYMBOL_DECLARE(int , lua_rawget, lua_State *L, int idx)
SYMBOL_DECLARE(int , lua_rawgeti, lua_State *L, int idx, lua_Integer n)
SYMBOL_DECLARE(int , lua_rawgetp, lua_State *L, int idx, const void *p)
SYMBOL_DECLARE(void , lua_createtable, lua_State *L, int narr, int nrec)
SYMBOL_DECLARE(void *, lua_newuserdatauv, lua_State *L, size_t sz, int nuvalue)
SYMBOL_DECLARE(int , lua_getmetatable, lua_State *L, int objindex)
SYMBOL_DECLARE(int , lua_getiuservalue, lua_State *L, int idx, int n)
/*
** set functions (stack -> Lua)
*/
SYMBOL_DECLARE(void , lua_setglobal, lua_State *L, const char *name)
SYMBOL_DECLARE(void , lua_settable, lua_State *L, int idx)
SYMBOL_DECLARE(void , lua_setfield, lua_State *L, int idx, const char *k)
SYMBOL_DECLARE(void , lua_seti, lua_State *L, int idx, lua_Integer n)
SYMBOL_DECLARE(void , lua_rawset, lua_State *L, int idx)
SYMBOL_DECLARE(void , lua_rawseti, lua_State *L, int idx, lua_Integer n)
SYMBOL_DECLARE(void , lua_rawsetp, lua_State *L, int idx, const void *p)
SYMBOL_DECLARE(int , lua_setmetatable, lua_State *L, int objindex)
SYMBOL_DECLARE(int , lua_setiuservalue, lua_State *L, int idx, int n)
/*
** 'load' and 'call' functions (load and run Lua code)
*/
SYMBOL_DECLARE(void, lua_callk, lua_State *L, int nargs, int nresults,
lua_KContext ctx, lua_KFunction k)
#define lua_call(L,n,r) lua_callk(L, (n), (r), 0, NULL)
SYMBOL_DECLARE(int, lua_pcallk, lua_State *L, int nargs, int nresults, int errfunc,
lua_KContext ctx, lua_KFunction k)
#define lua_pcall(L,n,r,f) lua_pcallk(L, (n), (r), (f), 0, NULL)
SYMBOL_DECLARE(int, lua_load, lua_State *L, lua_Reader reader, void *dt,
const char *chunkname, const char *mode)
SYMBOL_DECLARE(int, lua_dump, lua_State *L, lua_Writer writer, void *data, int strip)
/*
** coroutine functions
*/
SYMBOL_DECLARE(int, lua_yieldk, lua_State *L, int nresults, lua_KContext ctx,
lua_KFunction k)
SYMBOL_DECLARE(int, lua_resume, lua_State *L, lua_State *from, int narg,
int *nres)
SYMBOL_DECLARE(int, lua_status, lua_State *L)
SYMBOL_DECLARE(int, lua_isyieldable, lua_State *L)
#define lua_yield(L,n) lua_yieldk(L, (n), 0, NULL)
/*
** Warning-related functions
*/
SYMBOL_DECLARE(void, lua_setwarnf, lua_State *L, lua_WarnFunction f, void *ud)
SYMBOL_DECLARE(void, lua_warning, lua_State *L, const char *msg, int tocont)
/*
** garbage-collection function and options
*/
#define LUA_GCSTOP 0
#define LUA_GCRESTART 1
#define LUA_GCCOLLECT 2
#define LUA_GCCOUNT 3
#define LUA_GCCOUNTB 4
#define LUA_GCSTEP 5
#define LUA_GCSETPAUSE 6
#define LUA_GCSETSTEPMUL 7
#define LUA_GCISRUNNING 9
#define LUA_GCGEN 10
#define LUA_GCINC 11
SYMBOL_DECLARE_VARARG(int, lua_gc, lua_State *L, int what)
/*
** miscellaneous functions
*/
SYMBOL_DECLARE(int , lua_error, lua_State *L)
SYMBOL_DECLARE(int , lua_next, lua_State *L, int idx)
SYMBOL_DECLARE(void, lua_concat, lua_State *L, int n)
SYMBOL_DECLARE(void, lua_len, lua_State *L, int idx)
SYMBOL_DECLARE(size_t, lua_stringtonumber, lua_State *L, const char *s)
SYMBOL_DECLARE(lua_Alloc, lua_getallocf, lua_State *L, void **ud)
SYMBOL_DECLARE(void , lua_setallocf, lua_State *L, lua_Alloc f, void *ud)
SYMBOL_DECLARE(void, lua_toclose, lua_State *L, int idx)
SYMBOL_DECLARE(void, lua_closeslot, lua_State *L, int idx)
/*
** {==============================================================
** some useful macros
** ===============================================================
*/
#define lua_getextraspace(L) ((void *)((char *)(L) - LUA_EXTRASPACE))
#define lua_tonumber(L,i) lua_tonumberx(L,(i),NULL)
#define lua_tointeger(L,i) lua_tointegerx(L,(i),NULL)
#define lua_pop(L,n) lua_settop(L, -(n)-1)
#define lua_newtable(L) lua_createtable(L, 0, 0)
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
#define lua_pushliteral(L, s) lua_pushstring(L, "" s)
#define lua_pushglobaltable(L) \
((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
#define lua_insert(L,idx) lua_rotate(L, (idx), 1)
#define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))
#define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))
/* }============================================================== */
/*
** {==============================================================
** compatibility macros
** ===============================================================
*/
#if defined(LUA_COMPAT_APIINTCASTS)
#define lua_pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n))
#define lua_tounsignedx(L,i,is) ((lua_Unsigned)lua_tointegerx(L,i,is))
#define lua_tounsigned(L,i) lua_tounsignedx(L,(i),NULL)
#endif
#define lua_newuserdata(L,s) lua_newuserdatauv(L,s,1)
#define lua_getuservalue(L,idx) lua_getiuservalue(L,idx,1)
#define lua_setuservalue(L,idx) lua_setiuservalue(L,idx,1)
#define LUA_NUMTAGS LUA_NUMTYPES
/* }============================================================== */
/*
** {======================================================================
** Debug API
** =======================================================================
*/
/*
** Event codes
*/
#define LUA_HOOKCALL 0
#define LUA_HOOKRET 1
#define LUA_HOOKLINE 2
#define LUA_HOOKCOUNT 3
#define LUA_HOOKTAILCALL 4
/*
** Event masks
*/
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
#define LUA_MASKRET (1 << LUA_HOOKRET)
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
typedef struct lua_Debug lua_Debug; /* activation record */
/* Functions to be called by the debugger in specific events */
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
SYMBOL_DECLARE(int, lua_getstack, lua_State *L, int level, lua_Debug *ar)
SYMBOL_DECLARE(int, lua_getinfo, lua_State *L, const char *what, lua_Debug *ar)
SYMBOL_DECLARE(const char *, lua_getlocal, lua_State *L, const lua_Debug *ar, int n)
SYMBOL_DECLARE(const char *, lua_setlocal, lua_State *L, const lua_Debug *ar, int n)
SYMBOL_DECLARE(const char *, lua_getupvalue, lua_State *L, int funcindex, int n)
SYMBOL_DECLARE(const char *, lua_setupvalue, lua_State *L, int funcindex, int n)
SYMBOL_DECLARE(void *, lua_upvalueid, lua_State *L, int fidx, int n)
SYMBOL_DECLARE(void, lua_upvaluejoin, lua_State *L, int fidx1, int n1,
int fidx2, int n2)
SYMBOL_DECLARE(void, lua_sethook, lua_State *L, lua_Hook func, int mask, int count)
SYMBOL_DECLARE(lua_Hook, lua_gethook, lua_State *L)
SYMBOL_DECLARE(int, lua_gethookmask, lua_State *L)
SYMBOL_DECLARE(int, lua_gethookcount, lua_State *L)
SYMBOL_DECLARE(int, lua_setcstacklimit, lua_State *L, unsigned int limit)
struct lua_Debug {
int event;
const char *name; /* (n) */
const char *namewhat; /* (n) 'global', 'local', 'field', 'method' */
const char *what; /* (S) 'Lua', 'C', 'main', 'tail' */
const char *source; /* (S) */
size_t srclen; /* (S) */
int currentline; /* (l) */
int linedefined; /* (S) */
int lastlinedefined; /* (S) */
unsigned char nups; /* (u) number of upvalues */
unsigned char nparams;/* (u) number of parameters */
char isvararg; /* (u) */
char istailcall; /* (t) */
unsigned short ftransfer; /* (r) index of first value transferred */
unsigned short ntransfer; /* (r) number of transferred values */
char short_src[LUA_IDSIZE]; /* (S) */
/* private part */
struct CallInfo *i_ci; /* active function */
};
/* }====================================================================== */
#endif
/*
** $Id: lauxlib.h $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
#ifndef lauxlib_h
#define lauxlib_h
#include <stddef.h>
#include <stdio.h>
/* global table */
#define LUA_GNAME "_G"
typedef struct luaL_Buffer luaL_Buffer;
/* extra error code for 'luaL_loadfilex' */
#define LUA_ERRFILE (LUA_ERRERR+1)
/* key, in the registry, for table of loaded modules */
#define LUA_LOADED_TABLE "_LOADED"
/* key, in the registry, for table of preloaded loaders */
#define LUA_PRELOAD_TABLE "_PRELOAD"
typedef struct luaL_Reg {
const char *name;
lua_CFunction func;
} luaL_Reg;
#define LUAL_NUMSIZES (sizeof(lua_Integer)*16 + sizeof(lua_Number))
SYMBOL_DECLARE(void, luaL_checkversion_, lua_State *L, lua_Number ver, size_t sz)
#define luaL_checkversion(L) \
luaL_checkversion_(L, LUA_VERSION_NUM, LUAL_NUMSIZES)
SYMBOL_DECLARE(int, luaL_getmetafield, lua_State *L, int obj, const char *e)
SYMBOL_DECLARE(int, luaL_callmeta, lua_State *L, int obj, const char *e)
SYMBOL_DECLARE(const char *, luaL_tolstring, lua_State *L, int idx, size_t *len)
SYMBOL_DECLARE(int, luaL_argerror, lua_State *L, int arg, const char *extramsg)
SYMBOL_DECLARE(int, luaL_typeerror, lua_State *L, int arg, const char *tname)
SYMBOL_DECLARE(const char *, luaL_checklstring, lua_State *L, int arg,
size_t *l)
SYMBOL_DECLARE(const char *, luaL_optlstring, lua_State *L, int arg,
const char *def, size_t *l)
SYMBOL_DECLARE(lua_Number, luaL_checknumber, lua_State *L, int arg)
SYMBOL_DECLARE(lua_Number, luaL_optnumber, lua_State *L, int arg, lua_Number def)
SYMBOL_DECLARE(lua_Integer, luaL_checkinteger, lua_State *L, int arg)
SYMBOL_DECLARE(lua_Integer, luaL_optinteger, lua_State *L, int arg,
lua_Integer def)
SYMBOL_DECLARE(void, luaL_checkstack, lua_State *L, int sz, const char *msg)
SYMBOL_DECLARE(void, luaL_checktype, lua_State *L, int arg, int t)
SYMBOL_DECLARE(void, luaL_checkany, lua_State *L, int arg)
SYMBOL_DECLARE(int , luaL_newmetatable, lua_State *L, const char *tname)
SYMBOL_DECLARE(void , luaL_setmetatable, lua_State *L, const char *tname)
SYMBOL_DECLARE(void *, luaL_testudata, lua_State *L, int ud, const char *tname)
SYMBOL_DECLARE(void *, luaL_checkudata, lua_State *L, int ud, const char *tname)
SYMBOL_DECLARE(void, luaL_where, lua_State *L, int lvl)
SYMBOL_DECLARE_VARARG(int, luaL_error, lua_State *L, const char *fmt)
SYMBOL_DECLARE(int, luaL_checkoption, lua_State *L, int arg, const char *def,
const char *const lst[])
SYMBOL_DECLARE(int, luaL_fileresult, lua_State *L, int stat, const char *fname)
SYMBOL_DECLARE(int, luaL_execresult, lua_State *L, int stat)
/* predefined references */
#define LUA_NOREF (-2)
#define LUA_REFNIL (-1)
SYMBOL_DECLARE(int, luaL_ref, lua_State *L, int t)
SYMBOL_DECLARE(void, luaL_unref, lua_State *L, int t, int ref)
SYMBOL_DECLARE(int, luaL_loadfilex, lua_State *L, const char *filename,
const char *mode)
#define luaL_loadfile(L,f) luaL_loadfilex(L,f,NULL)
SYMBOL_DECLARE(int, luaL_loadbufferx, lua_State *L, const char *buff, size_t sz,
const char *name, const char *mode)
SYMBOL_DECLARE(int, luaL_loadstring, lua_State *L, const char *s)
SYMBOL_DECLARE(lua_State *, luaL_newstate, void)
SYMBOL_DECLARE(lua_Integer, luaL_len, lua_State *L, int idx)
SYMBOL_DECLARE(void, luaL_addgsub, luaL_Buffer *b, const char *s,
const char *p, const char *r)
SYMBOL_DECLARE(const char *, luaL_gsub, lua_State *L, const char *s,
const char *p, const char *r)
SYMBOL_DECLARE(void, luaL_setfuncs, lua_State *L, const luaL_Reg *l, int nup)
SYMBOL_DECLARE(int, luaL_getsubtable, lua_State *L, int idx, const char *fname)
SYMBOL_DECLARE(void, luaL_traceback, lua_State *L, lua_State *L1,
const char *msg, int level)
SYMBOL_DECLARE(void, luaL_requiref, lua_State *L, const char *modname,
lua_CFunction openf, int glb)
/*
** ===============================================================
** some useful macros
** ===============================================================
*/
#define luaL_newlibtable(L,l) \
lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
#define luaL_newlib(L,l) \
(luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
#define luaL_argcheck(L, cond,arg,extramsg) \
((void)(luai_likely(cond) || luaL_argerror(L, (arg), (extramsg))))
#define luaL_argexpected(L,cond,arg,tname) \
((void)(luai_likely(cond) || luaL_typeerror(L, (arg), (tname))))
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
#define luaL_dofile(L, fn) \
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_dostring(L, s) \
(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
#define luaL_loadbuffer(L,s,sz,n) luaL_loadbufferx(L,s,sz,n,NULL)
/*
** Perform arithmetic operations on lua_Integer values with wrap-around
** semantics, as the Lua core does.
*/
#define luaL_intop(op,v1,v2) \
((lua_Integer)((lua_Unsigned)(v1) op (lua_Unsigned)(v2)))
/* push the value used to represent failure/error */
#define luaL_pushfail(L) lua_pushnil(L)
/*
** Internal assertions for in-house debugging
*/
#if !defined(lua_assert)
#if defined LUAI_ASSERT
#include <assert.h>
#define lua_assert(c) assert(c)
#else
#define lua_assert(c) ((void)0)
#endif
#endif
/*
** {======================================================
** Generic Buffer manipulation
** =======================================================
*/
struct luaL_Buffer {
char *b; /* buffer address */
size_t size; /* buffer size */
size_t n; /* number of characters in buffer */
lua_State *L;
union {
LUAI_MAXALIGN; /* ensure maximum alignment for buffer */
char b[LUAL_BUFFERSIZE]; /* initial buffer */
} init;
};
#define luaL_bufflen(bf) ((bf)->n)
#define luaL_buffaddr(bf) ((bf)->b)
#define luaL_addchar(B,c) \
((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
((B)->b[(B)->n++] = (c)))
#define luaL_addsize(B,s) ((B)->n += (s))
#define luaL_buffsub(B,s) ((B)->n -= (s))
SYMBOL_DECLARE(void, luaL_buffinit, lua_State *L, luaL_Buffer *B)
SYMBOL_DECLARE(char *, luaL_prepbuffsize, luaL_Buffer *B, size_t sz)
SYMBOL_DECLARE(void, luaL_addlstring, luaL_Buffer *B, const char *s, size_t l)
SYMBOL_DECLARE(void, luaL_addstring, luaL_Buffer *B, const char *s)
SYMBOL_DECLARE(void, luaL_addvalue, luaL_Buffer *B)
SYMBOL_DECLARE(void, luaL_pushresult, luaL_Buffer *B)
SYMBOL_DECLARE(void, luaL_pushresultsize, luaL_Buffer *B, size_t sz)
SYMBOL_DECLARE(char *, luaL_buffinitsize, lua_State *L, luaL_Buffer *B, size_t sz)
#define luaL_prepbuffer(B) luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
/* }====================================================== */
/*
** {======================================================
** File handles for IO library
** =======================================================
*/
/*
** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
** initial structure 'luaL_Stream' (it may contain other fields
** after that initial structure).
*/
#define LUA_FILEHANDLE "FILE*"
typedef struct luaL_Stream {
FILE *f; /* stream (NULL for incompletely created streams) */
lua_CFunction closef; /* to close stream (NULL for closed streams) */
} luaL_Stream;
/* }====================================================== */
/*
** {==================================================================
** "Abstraction Layer" for basic report of messages and errors
** ===================================================================
*/
/* print a string */
#if !defined(lua_writestring)
#define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
#endif
/* print a newline and flush the output */
#if !defined(lua_writeline)
#define lua_writeline() (lua_writestring("\n", 1), fflush(stdout))
#endif
/* print an error message */
#if !defined(lua_writestringerror)
#define lua_writestringerror(s,p) \
(fprintf(stderr, (s), (p)), fflush(stderr))
#endif
/* }================================================================== */
/*
** {============================================================
** Compatibility with deprecated conversions
** =============================================================
*/
#if defined(LUA_COMPAT_APIINTCASTS)
#define luaL_checkunsigned(L,a) ((lua_Unsigned)luaL_checkinteger(L,a))
#define luaL_optunsigned(L,a,d) \
((lua_Unsigned)luaL_optinteger(L,a,(lua_Integer)(d)))
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
#endif
/* }============================================================ */
#endif
/*
** $Id: lualib.h $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
#ifndef lualib_h
#define lualib_h
/* version suffix for environment variable names */
#define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
SYMBOL_DECLARE(int, luaopen_base, lua_State *L)
#define LUA_COLIBNAME "coroutine"
SYMBOL_DECLARE(int, luaopen_coroutine, lua_State *L)
#define LUA_TABLIBNAME "table"
SYMBOL_DECLARE(int, luaopen_table, lua_State *L)
#define LUA_IOLIBNAME "io"
SYMBOL_DECLARE(int, luaopen_io, lua_State *L)
#define LUA_OSLIBNAME "os"
SYMBOL_DECLARE(int, luaopen_os, lua_State *L)
#define LUA_STRLIBNAME "string"
SYMBOL_DECLARE(int, luaopen_string, lua_State *L)
#define LUA_UTF8LIBNAME "utf8"
SYMBOL_DECLARE(int, luaopen_utf8, lua_State *L)
#define LUA_MATHLIBNAME "math"
SYMBOL_DECLARE(int, luaopen_math, lua_State *L)
#define LUA_DBLIBNAME "debug"
SYMBOL_DECLARE(int, luaopen_debug, lua_State *L)
#define LUA_LOADLIBNAME "package"
SYMBOL_DECLARE(int, luaopen_package, lua_State *L)
/* open all previous libraries */
SYMBOL_DECLARE(void, luaL_openlibs, lua_State *L)
#endif
#ifdef LITE_XL_PLUGIN_ENTRYPOINT
SYMBOL_WRAP_DECL(lua_State *, lua_newstate, lua_Alloc f, void *ud) {
return SYMBOL_WRAP_CALL(lua_newstate, f, ud);
}
SYMBOL_WRAP_DECL(void, lua_close, lua_State *L) {
SYMBOL_WRAP_CALL(lua_close, L);
}
SYMBOL_WRAP_DECL(lua_State *, lua_newthread, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_newthread, L);
}
SYMBOL_WRAP_DECL(int, lua_closethread, lua_State *L, lua_State *from) {
return SYMBOL_WRAP_CALL(lua_closethread, L, from);
}
SYMBOL_WRAP_DECL(int, lua_resetthread, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_resetthread, L);
}
SYMBOL_WRAP_DECL(lua_CFunction, lua_atpanic, lua_State *L, lua_CFunction panicf) {
return SYMBOL_WRAP_CALL(lua_atpanic, L, panicf);
}
SYMBOL_WRAP_DECL(lua_Number, lua_version, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_version, L);
}
SYMBOL_WRAP_DECL(int, lua_absindex, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_absindex, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_gettop, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_gettop, L);
}
SYMBOL_WRAP_DECL(void, lua_settop, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_settop, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_pushvalue, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_pushvalue, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_rotate, lua_State *L, int idx, int n) {
SYMBOL_WRAP_CALL(lua_rotate, L, idx, n);
}
SYMBOL_WRAP_DECL(void, lua_copy, lua_State *L, int fromidx, int toidx) {
SYMBOL_WRAP_CALL(lua_copy, L, fromidx, toidx);
}
SYMBOL_WRAP_DECL(int, lua_checkstack, lua_State *L, int sz) {
return SYMBOL_WRAP_CALL(lua_checkstack, L, sz);
}
SYMBOL_WRAP_DECL(void, lua_xmove, lua_State *from, lua_State *to, int n) {
SYMBOL_WRAP_CALL(lua_xmove, from, to, n);
}
SYMBOL_WRAP_DECL(int, lua_isnumber, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_isnumber, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_isstring, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_isstring, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_iscfunction, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_iscfunction, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_isinteger, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_isinteger, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_isuserdata, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_isuserdata, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_type, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_type, L, idx);
}
SYMBOL_WRAP_DECL(const char *, lua_typename, lua_State *L, int tp) {
return SYMBOL_WRAP_CALL(lua_typename, L, tp);
}
SYMBOL_WRAP_DECL(lua_Number, lua_tonumberx, lua_State *L, int idx, int *isnum) {
return SYMBOL_WRAP_CALL(lua_tonumberx, L, idx, isnum);
}
SYMBOL_WRAP_DECL(lua_Integer, lua_tointegerx, lua_State *L, int idx, int *isnum) {
return SYMBOL_WRAP_CALL(lua_tointegerx, L, idx, isnum);
}
SYMBOL_WRAP_DECL(int, lua_toboolean, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_toboolean, L, idx);
}
SYMBOL_WRAP_DECL(const char *, lua_tolstring, lua_State *L, int idx, size_t *len) {
return SYMBOL_WRAP_CALL(lua_tolstring, L, idx, len);
}
SYMBOL_WRAP_DECL(lua_Unsigned, lua_rawlen, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_rawlen, L, idx);
}
SYMBOL_WRAP_DECL(lua_CFunction, lua_tocfunction, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_tocfunction, L, idx);
}
SYMBOL_WRAP_DECL(void *, lua_touserdata, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_touserdata, L, idx);
}
SYMBOL_WRAP_DECL(lua_State *, lua_tothread, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_tothread, L, idx);
}
SYMBOL_WRAP_DECL(const void *, lua_topointer, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_topointer, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_arith, lua_State *L, int op) {
SYMBOL_WRAP_CALL(lua_arith, L, op);
}
SYMBOL_WRAP_DECL(int, lua_rawequal, lua_State *L, int idx1, int idx2) {
return SYMBOL_WRAP_CALL(lua_rawequal, L, idx1, idx2);
}
SYMBOL_WRAP_DECL(int, lua_compare, lua_State *L, int idx1, int idx2, int op) {
return SYMBOL_WRAP_CALL(lua_compare, L, idx1, idx2, op);
}
SYMBOL_WRAP_DECL(void, lua_pushnil, lua_State *L) {
SYMBOL_WRAP_CALL(lua_pushnil, L);
}
SYMBOL_WRAP_DECL(void, lua_pushnumber, lua_State *L, lua_Number n) {
SYMBOL_WRAP_CALL(lua_pushnumber, L, n);
}
SYMBOL_WRAP_DECL(void, lua_pushinteger, lua_State *L, lua_Integer n) {
SYMBOL_WRAP_CALL(lua_pushinteger, L, n);
}
SYMBOL_WRAP_DECL(const char *, lua_pushlstring, lua_State *L, const char *s, size_t l) {
return SYMBOL_WRAP_CALL(lua_pushlstring, L, s, l);
}
SYMBOL_WRAP_DECL(const char *, lua_pushstring, lua_State *L, const char *s) {
return SYMBOL_WRAP_CALL(lua_pushstring, L, s);
}
SYMBOL_WRAP_DECL(const char *, lua_pushvfstring, lua_State *L, const char *fmt, va_list argp) {
return SYMBOL_WRAP_CALL(lua_pushvfstring, L, fmt, argp);
}
SYMBOL_WRAP_DECL(const char *, lua_pushfstring, lua_State *L, const char *fmt, ...) {
const char *res;
va_list argp;
va_start(argp, fmt);
res = lua_pushvfstring(L, fmt, argp);
va_end(argp);
return res;
}
SYMBOL_WRAP_DECL(void, lua_pushcclosure, lua_State *L, lua_CFunction fn, int n) {
SYMBOL_WRAP_CALL(lua_pushcclosure, L, fn, n);
}
SYMBOL_WRAP_DECL(void, lua_pushboolean, lua_State *L, int b) {
SYMBOL_WRAP_CALL(lua_pushboolean, L, b);
}
SYMBOL_WRAP_DECL(void, lua_pushlightuserdata, lua_State *L, void *p) {
SYMBOL_WRAP_CALL(lua_pushlightuserdata, L, p);
}
SYMBOL_WRAP_DECL(int, lua_pushthread, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_pushthread, L);
}
SYMBOL_WRAP_DECL(int, lua_getglobal, lua_State *L, const char *var) {
return SYMBOL_WRAP_CALL(lua_getglobal, L, var);
}
SYMBOL_WRAP_DECL(int, lua_gettable, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_gettable, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_getfield, lua_State *L, int idx, const char *k) {
return SYMBOL_WRAP_CALL(lua_getfield, L, idx, k);
}
SYMBOL_WRAP_DECL(int , lua_geti, lua_State *L, int idx, lua_Integer n) {
return SYMBOL_WRAP_CALL(lua_geti, L, idx, n);
}
SYMBOL_WRAP_DECL(int, lua_rawget, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_rawget, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_rawgeti, lua_State *L, int idx, lua_Integer n) {
return SYMBOL_WRAP_CALL(lua_rawgeti, L, idx, n);
}
SYMBOL_WRAP_DECL(int, lua_rawgetp, lua_State *L, int idx, const void *p) {
return SYMBOL_WRAP_CALL(lua_rawgetp, L, idx, p);
}
SYMBOL_WRAP_DECL(void, lua_createtable, lua_State *L, int narr, int nrec) {
SYMBOL_WRAP_CALL(lua_createtable, L, narr, nrec);
}
SYMBOL_WRAP_DECL(void *, lua_newuserdatauv, lua_State *L, size_t sz, int nuvalue) {
return SYMBOL_WRAP_CALL(lua_newuserdatauv, L, sz, nuvalue);
}
SYMBOL_WRAP_DECL(int, lua_getmetatable, lua_State *L, int objindex) {
return SYMBOL_WRAP_CALL(lua_getmetatable, L, objindex);
}
SYMBOL_WRAP_DECL(int, lua_getiuservalue, lua_State *L, int idx, int n) {
return SYMBOL_WRAP_CALL(lua_getiuservalue, L, idx, n);
}
SYMBOL_WRAP_DECL(void, lua_setglobal, lua_State *L, const char *var) {
SYMBOL_WRAP_CALL(lua_setglobal, L, var);
}
SYMBOL_WRAP_DECL(void, lua_settable, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_settable, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_setfield, lua_State *L, int idx, const char *k) {
SYMBOL_WRAP_CALL(lua_setfield, L, idx, k);
}
SYMBOL_WRAP_DECL(void, lua_seti, lua_State *L, int idx, lua_Integer n) {
SYMBOL_WRAP_CALL(lua_seti, L, idx, n);
}
SYMBOL_WRAP_DECL(void, lua_rawset, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_rawset, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_rawseti, lua_State *L, int idx, lua_Integer n) {
SYMBOL_WRAP_CALL(lua_rawseti, L, idx, n);
}
SYMBOL_WRAP_DECL(void, lua_rawsetp, lua_State *L, int idx, const void *p) {
SYMBOL_WRAP_CALL(lua_rawsetp, L, idx, p);
}
SYMBOL_WRAP_DECL(int, lua_setmetatable, lua_State *L, int objindex) {
return SYMBOL_WRAP_CALL(lua_setmetatable, L, objindex);
}
SYMBOL_WRAP_DECL(int, lua_setiuservalue, lua_State *L, int idx, int n) {
return SYMBOL_WRAP_CALL(lua_setiuservalue, L, idx, n);
}
SYMBOL_WRAP_DECL(void, lua_callk, lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k) {
SYMBOL_WRAP_CALL(lua_callk, L, nargs, nresults, ctx, k);
}
SYMBOL_WRAP_DECL(int, lua_pcallk, lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k) {
return SYMBOL_WRAP_CALL(lua_pcallk, L, nargs, nresults, errfunc, ctx, k);
}
SYMBOL_WRAP_DECL(int, lua_load, lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode) {
return SYMBOL_WRAP_CALL(lua_load, L, reader, dt, chunkname, mode);
}
SYMBOL_WRAP_DECL(int, lua_dump, lua_State *L, lua_Writer writer, void *data, int strip) {
return SYMBOL_WRAP_CALL(lua_dump, L, writer, data, strip);
}
SYMBOL_WRAP_DECL(int, lua_yieldk, lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k) {
return SYMBOL_WRAP_CALL(lua_yieldk, L, nresults, ctx, k);
}
SYMBOL_WRAP_DECL(int, lua_resume, lua_State *L, lua_State *from, int narg, int *nres) {
return SYMBOL_WRAP_CALL(lua_resume, L, from, narg, nres);
}
SYMBOL_WRAP_DECL(int, lua_status, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_status, L);
}
SYMBOL_WRAP_DECL(int, lua_isyieldable, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_isyieldable, L);
}
SYMBOL_WRAP_DECL(void, lua_setwarnf, lua_State *L, lua_WarnFunction f, void *ud) {
SYMBOL_WRAP_CALL(lua_setwarnf, L, f, ud);
}
SYMBOL_WRAP_DECL(void, lua_warning, lua_State *L, const char *msg, int tocont) {
SYMBOL_WRAP_CALL(lua_warning, L, msg, tocont);
}
SYMBOL_WRAP_DECL(int, lua_gc, lua_State *L, int what, ...) {
/* there are no straightforward ways of passing data. */
int r;
va_list ap;
va_start(ap, what);
if (what == LUA_GCSTEP) {
int stepsize = va_arg(ap, int);
r = __lua_gc(L, what, stepsize);
} else if (what == LUA_GCINC) {
int pause = va_arg(ap, int);
int stepmul = va_arg(ap, int);
int stepsize = va_arg(ap, int);
r = __lua_gc(L, what, pause, stepmul, stepsize);
} else if (what == LUA_GCGEN) {
int minormul = va_arg(ap, int);
int majormul = va_arg(ap, int);
r = __lua_gc(L, what, minormul, majormul);
} else {
r = __lua_gc(L, what);
}
return r;
}
SYMBOL_WRAP_DECL(int, lua_error, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_error, L);
}
SYMBOL_WRAP_DECL(int, lua_next, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(lua_next, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_concat, lua_State *L, int n) {
SYMBOL_WRAP_CALL(lua_concat, L, n);
}
SYMBOL_WRAP_DECL(void, lua_len, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_len, L, idx);
}
SYMBOL_WRAP_DECL(size_t, lua_stringtonumber, lua_State *L, const char *s) {
return SYMBOL_WRAP_CALL(lua_stringtonumber, L, s);
}
SYMBOL_WRAP_DECL(lua_Alloc, lua_getallocf, lua_State *L, void **ud) {
return SYMBOL_WRAP_CALL(lua_getallocf, L, ud);
}
SYMBOL_WRAP_DECL(void, lua_setallocf, lua_State *L, lua_Alloc f, void *ud) {
SYMBOL_WRAP_CALL(lua_setallocf, L, f, ud);
}
SYMBOL_WRAP_DECL(void, lua_toclose, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_toclose, L, idx);
}
SYMBOL_WRAP_DECL(void, lua_closeslot, lua_State *L, int idx) {
SYMBOL_WRAP_CALL(lua_closeslot, L, idx);
}
SYMBOL_WRAP_DECL(int, lua_getstack, lua_State *L, int level, lua_Debug *ar) {
return SYMBOL_WRAP_CALL(lua_getstack, L, level, ar);
}
SYMBOL_WRAP_DECL(int, lua_getinfo, lua_State *L, const char *what, lua_Debug *ar) {
return SYMBOL_WRAP_CALL(lua_getinfo, L, what, ar);
}
SYMBOL_WRAP_DECL(const char *, lua_getlocal, lua_State *L, const lua_Debug *ar, int n) {
return SYMBOL_WRAP_CALL(lua_getlocal, L, ar, n);
}
SYMBOL_WRAP_DECL(const char *, lua_setlocal, lua_State *L, const lua_Debug *ar, int n) {
return SYMBOL_WRAP_CALL(lua_setlocal, L, ar, n);
}
SYMBOL_WRAP_DECL(const char *, lua_getupvalue, lua_State *L, int funcindex, int n) {
return SYMBOL_WRAP_CALL(lua_getupvalue, L, funcindex, n);
}
SYMBOL_WRAP_DECL(const char *, lua_setupvalue, lua_State *L, int funcindex, int n) {
return SYMBOL_WRAP_CALL(lua_setupvalue, L, funcindex, n);
}
SYMBOL_WRAP_DECL(void *, lua_upvalueid, lua_State *L, int fidx, int n) {
return SYMBOL_WRAP_CALL(lua_upvalueid, L, fidx, n);
}
SYMBOL_WRAP_DECL(void, lua_upvaluejoin, lua_State *L, int fidx1, int n1, int fidx2, int n2) {
SYMBOL_WRAP_CALL(lua_upvaluejoin, L, fidx1, n1, fidx2, n2);
}
SYMBOL_WRAP_DECL(void, lua_sethook, lua_State *L, lua_Hook func, int mask, int count) {
SYMBOL_WRAP_CALL(lua_sethook, L, func, mask, count);
}
SYMBOL_WRAP_DECL(lua_Hook, lua_gethook, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_gethook, L);
}
SYMBOL_WRAP_DECL(int, lua_gethookmask, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_gethookmask, L);
}
SYMBOL_WRAP_DECL(int, lua_gethookcount, lua_State *L) {
return SYMBOL_WRAP_CALL(lua_gethookcount, L);
}
SYMBOL_WRAP_DECL(int, lua_setcstacklimit, lua_State *L, unsigned int limit) {
return SYMBOL_WRAP_CALL(lua_setcstacklimit, L, limit);
}
SYMBOL_WRAP_DECL(void, luaL_checkversion_, lua_State *L, lua_Number ver, size_t sz) {
SYMBOL_WRAP_CALL(luaL_checkversion_, L, ver, sz);
}
SYMBOL_WRAP_DECL(int, luaL_getmetafield, lua_State *L, int obj, const char *e) {
return SYMBOL_WRAP_CALL(luaL_getmetafield, L, obj, e);
}
SYMBOL_WRAP_DECL(int, luaL_callmeta, lua_State *L, int obj, const char *e) {
return SYMBOL_WRAP_CALL(luaL_callmeta, L, obj, e);
}
SYMBOL_WRAP_DECL(const char *, luaL_tolstring, lua_State *L, int idx, size_t *len) {
return SYMBOL_WRAP_CALL(luaL_tolstring, L, idx, len);
}
SYMBOL_WRAP_DECL(int, luaL_argerror, lua_State *L, int numarg, const char *extramsg) {
return SYMBOL_WRAP_CALL(luaL_argerror, L, numarg, extramsg);
}
SYMBOL_WRAP_DECL(int, luaL_typeerror, lua_State *L, int arg, const char *tname) {
return SYMBOL_WRAP_CALL(luaL_typeerror, L, arg, tname);
}
SYMBOL_WRAP_DECL(const char *, luaL_checklstring, lua_State *L, int numArg, size_t *l) {
return SYMBOL_WRAP_CALL(luaL_checklstring, L, numArg, l);
}
SYMBOL_WRAP_DECL(const char *, luaL_optlstring, lua_State *L, int numArg, const char *def, size_t *l) {
return SYMBOL_WRAP_CALL(luaL_optlstring, L, numArg, def, l);
}
SYMBOL_WRAP_DECL(lua_Number, luaL_checknumber, lua_State *L, int numArg) {
return SYMBOL_WRAP_CALL(luaL_checknumber, L, numArg);
}
SYMBOL_WRAP_DECL(lua_Number, luaL_optnumber, lua_State *L, int nArg, lua_Number def) {
return SYMBOL_WRAP_CALL(luaL_optnumber, L, nArg, def);
}
SYMBOL_WRAP_DECL(lua_Integer, luaL_checkinteger, lua_State *L, int numArg) {
return SYMBOL_WRAP_CALL(luaL_checkinteger, L, numArg);
}
SYMBOL_WRAP_DECL(lua_Integer, luaL_optinteger, lua_State *L, int nArg, lua_Integer def) {
return SYMBOL_WRAP_CALL(luaL_optinteger, L, nArg, def);
}
SYMBOL_WRAP_DECL(void, luaL_checkstack, lua_State *L, int sz, const char *msg) {
SYMBOL_WRAP_CALL(luaL_checkstack, L, sz, msg);
}
SYMBOL_WRAP_DECL(void, luaL_checktype, lua_State *L, int narg, int t) {
SYMBOL_WRAP_CALL(luaL_checktype, L, narg, t);
}
SYMBOL_WRAP_DECL(void, luaL_checkany, lua_State *L, int narg) {
SYMBOL_WRAP_CALL(luaL_checkany, L, narg);
}
SYMBOL_WRAP_DECL(int, luaL_newmetatable, lua_State *L, const char *tname) {
return SYMBOL_WRAP_CALL(luaL_newmetatable, L, tname);
}
SYMBOL_WRAP_DECL(void, luaL_setmetatable, lua_State *L, const char *tname) {
SYMBOL_WRAP_CALL(luaL_setmetatable, L, tname);
}
SYMBOL_WRAP_DECL(void *, luaL_testudata, lua_State *L, int ud, const char *tname) {
return SYMBOL_WRAP_CALL(luaL_testudata, L, ud, tname);
}
SYMBOL_WRAP_DECL(void *, luaL_checkudata, lua_State *L, int ud, const char *tname) {
return SYMBOL_WRAP_CALL(luaL_checkudata, L, ud, tname);
}
SYMBOL_WRAP_DECL(void, luaL_where, lua_State *L, int lvl) {
SYMBOL_WRAP_CALL(luaL_where, L, lvl);
}
SYMBOL_WRAP_DECL(int, luaL_error, lua_State *L, const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
luaL_where(L, 1);
lua_pushvfstring(L, fmt, argp);
va_end(argp);
lua_concat(L, 2);
return lua_error(L);
}
SYMBOL_WRAP_DECL(int, luaL_checkoption, lua_State *L, int narg, const char *def, const char *const lst[]) {
return SYMBOL_WRAP_CALL(luaL_checkoption, L, narg, def, lst);
}
SYMBOL_WRAP_DECL(int, luaL_fileresult, lua_State *L, int stat, const char *fname) {
return SYMBOL_WRAP_CALL(luaL_fileresult, L, stat, fname);
}
SYMBOL_WRAP_DECL(int, luaL_execresult, lua_State *L, int stat) {
return SYMBOL_WRAP_CALL(luaL_execresult, L, stat);
}
SYMBOL_WRAP_DECL(int, luaL_ref, lua_State *L, int t) {
return SYMBOL_WRAP_CALL(luaL_ref, L, t);
}
SYMBOL_WRAP_DECL(void, luaL_unref, lua_State *L, int t, int ref) {
SYMBOL_WRAP_CALL(luaL_unref, L, t, ref);
}
SYMBOL_WRAP_DECL(int, luaL_loadfilex, lua_State *L, const char *filename, const char *mode) {
return SYMBOL_WRAP_CALL(luaL_loadfilex, L, filename, mode);
}
SYMBOL_WRAP_DECL(int, luaL_loadbufferx, lua_State *L, const char *buff, size_t sz, const char *name, const char *mode) {
return SYMBOL_WRAP_CALL(luaL_loadbufferx, L, buff, sz, name, mode);
}
SYMBOL_WRAP_DECL(int, luaL_loadstring, lua_State *L, const char *s) {
return SYMBOL_WRAP_CALL(luaL_loadstring, L, s);
}
SYMBOL_WRAP_DECL(lua_State *, luaL_newstate, void) {
return __luaL_newstate();
}
SYMBOL_WRAP_DECL(lua_Integer, luaL_len, lua_State *L, int idx) {
return SYMBOL_WRAP_CALL(luaL_len, L, idx);
}
SYMBOL_WRAP_DECL(void, luaL_addgsub, luaL_Buffer *b, const char *s,
const char *p, const char *r) {
SYMBOL_WRAP_CALL(luaL_addgsub, b, s, p, r);
}
SYMBOL_WRAP_DECL(const char *, luaL_gsub, lua_State *L, const char *s, const char *p, const char *r) {
return SYMBOL_WRAP_CALL(luaL_gsub, L, s, p, r);
}
SYMBOL_WRAP_DECL(void, luaL_setfuncs, lua_State *L, const luaL_Reg *l, int nup) {
SYMBOL_WRAP_CALL(luaL_setfuncs, L, l, nup);
}
SYMBOL_WRAP_DECL(int, luaL_getsubtable, lua_State *L, int idx, const char *fname) {
return SYMBOL_WRAP_CALL(luaL_getsubtable, L, idx, fname);
}
SYMBOL_WRAP_DECL(void, luaL_traceback, lua_State *L, lua_State *L1, const char *msg, int level) {
SYMBOL_WRAP_CALL(luaL_traceback, L, L1, msg, level);
}
SYMBOL_WRAP_DECL(void, luaL_requiref, lua_State *L, const char *modname, lua_CFunction openf, int glb) {
SYMBOL_WRAP_CALL(luaL_requiref, L, modname, openf, glb);
}
SYMBOL_WRAP_DECL(void, luaL_buffinit, lua_State *L, luaL_Buffer *B) {
SYMBOL_WRAP_CALL(luaL_buffinit, L, B);
}
SYMBOL_WRAP_DECL(char *, luaL_prepbuffsize, luaL_Buffer *B, size_t sz) {
return SYMBOL_WRAP_CALL(luaL_prepbuffsize, B, sz);
}
SYMBOL_WRAP_DECL(void, luaL_addlstring, luaL_Buffer *B, const char *s, size_t l) {
SYMBOL_WRAP_CALL(luaL_addlstring, B, s, l);
}
SYMBOL_WRAP_DECL(void, luaL_addstring, luaL_Buffer *B, const char *s) {
SYMBOL_WRAP_CALL(luaL_addstring, B, s);
}
SYMBOL_WRAP_DECL(void, luaL_addvalue, luaL_Buffer *B) {
SYMBOL_WRAP_CALL(luaL_addvalue, B);
}
SYMBOL_WRAP_DECL(void, luaL_pushresult, luaL_Buffer *B) {
SYMBOL_WRAP_CALL(luaL_pushresult, B);
}
SYMBOL_WRAP_DECL(void, luaL_pushresultsize, luaL_Buffer *B, size_t sz) {
SYMBOL_WRAP_CALL(luaL_pushresultsize, B, sz);
}
SYMBOL_WRAP_DECL(char *, luaL_buffinitsize, lua_State *L, luaL_Buffer *B, size_t sz) {
return SYMBOL_WRAP_CALL(luaL_buffinitsize, L, B, sz);
}
SYMBOL_WRAP_DECL(int, luaopen_base, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_base, L);
}
SYMBOL_WRAP_DECL(int, luaopen_coroutine, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_coroutine, L);
}
SYMBOL_WRAP_DECL(int, luaopen_table, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_table, L);
}
SYMBOL_WRAP_DECL(int, luaopen_io, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_io, L);
}
SYMBOL_WRAP_DECL(int, luaopen_os, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_os, L);
}
SYMBOL_WRAP_DECL(int, luaopen_string, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_string, L);
}
SYMBOL_WRAP_DECL(int, luaopen_utf8, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_utf8, L);
}
SYMBOL_WRAP_DECL(int, luaopen_math, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_math, L);
}
SYMBOL_WRAP_DECL(int, luaopen_debug, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_debug, L);
}
SYMBOL_WRAP_DECL(int, luaopen_package, lua_State *L) {
return SYMBOL_WRAP_CALL(luaopen_package, L);
}
SYMBOL_WRAP_DECL(void, luaL_openlibs, lua_State *L) {
SYMBOL_WRAP_CALL(luaL_openlibs, L);
}
#define IMPORT_SYMBOL(name, ret, ...) \
__##name = (\
(*(void **) (&__##name) = symbol(#name)), \
__##name == NULL ? ((ret (*) (__VA_ARGS__)) &__lite_xl_fallback_##name) : __##name\
)
void lite_xl_plugin_init(void *XL) {
void* (*symbol)(const char *);
*(void **) (&symbol) = XL;
IMPORT_SYMBOL(lua_newstate, lua_State *, lua_Alloc f, void *ud);
IMPORT_SYMBOL(lua_close, void, lua_State *L);
IMPORT_SYMBOL(lua_newthread, lua_State *, lua_State *L);
IMPORT_SYMBOL(lua_closethread, int, lua_State *L, lua_State *from);
IMPORT_SYMBOL(lua_resetthread, int, lua_State *L);
IMPORT_SYMBOL(lua_atpanic, lua_CFunction, lua_State *L, lua_CFunction panicf);
IMPORT_SYMBOL(lua_version, lua_Number, lua_State *L);
IMPORT_SYMBOL(lua_absindex, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_gettop, int, lua_State *L);
IMPORT_SYMBOL(lua_settop, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_pushvalue, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_rotate, void, lua_State *L, int idx, int n);
IMPORT_SYMBOL(lua_copy, void, lua_State *L, int fromidx, int toidx);
IMPORT_SYMBOL(lua_checkstack, int, lua_State *L, int sz);
IMPORT_SYMBOL(lua_xmove, void, lua_State *from, lua_State *to, int n);
IMPORT_SYMBOL(lua_isnumber, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_isstring, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_iscfunction, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_isinteger, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_isuserdata, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_type, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_typename, const char *, lua_State *L, int tp);
IMPORT_SYMBOL(lua_tonumberx, lua_Number, lua_State *L, int idx, int *isnum);
IMPORT_SYMBOL(lua_tointegerx, lua_Integer, lua_State *L, int idx, int *isnum);
IMPORT_SYMBOL(lua_toboolean, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_tolstring, const char *, lua_State *L, int idx, size_t *len);
IMPORT_SYMBOL(lua_rawlen, lua_Unsigned, lua_State *L, int idx);
IMPORT_SYMBOL(lua_tocfunction, lua_CFunction, lua_State *L, int idx);
IMPORT_SYMBOL(lua_touserdata, void *, lua_State *L, int idx);
IMPORT_SYMBOL(lua_tothread, lua_State *, lua_State *L, int idx);
IMPORT_SYMBOL(lua_topointer, const void *, lua_State *L, int idx);
IMPORT_SYMBOL(lua_arith, void, lua_State *L, int op);
IMPORT_SYMBOL(lua_rawequal, int, lua_State *L, int idx1, int idx2);
IMPORT_SYMBOL(lua_compare, int, lua_State *L, int idx1, int idx2, int op);
IMPORT_SYMBOL(lua_pushnil, void, lua_State *L);
IMPORT_SYMBOL(lua_pushnumber, void, lua_State *L, lua_Number n);
IMPORT_SYMBOL(lua_pushinteger, void, lua_State *L, lua_Integer n);
IMPORT_SYMBOL(lua_pushlstring, const char *, lua_State *L, const char *s, size_t l);
IMPORT_SYMBOL(lua_pushstring, const char *, lua_State *L, const char *s);
IMPORT_SYMBOL(lua_pushvfstring, const char *, lua_State *L, const char *fmt, va_list argp);
IMPORT_SYMBOL(lua_pushfstring, const char *, lua_State *L, const char *fmt, ...);
IMPORT_SYMBOL(lua_pushcclosure, void, lua_State *L, lua_CFunction fn, int n);
IMPORT_SYMBOL(lua_pushboolean, void, lua_State *L, int b);
IMPORT_SYMBOL(lua_pushlightuserdata, void, lua_State *L, void *p);
IMPORT_SYMBOL(lua_pushthread, int, lua_State *L);
IMPORT_SYMBOL(lua_getglobal, int, lua_State *L, const char *var);
IMPORT_SYMBOL(lua_gettable, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_getfield, int, lua_State *L, int idx, const char *k);
IMPORT_SYMBOL(lua_geti, int, lua_State *L, int idx, lua_Integer n);
IMPORT_SYMBOL(lua_rawget, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_rawgeti, int, lua_State *L, int idx, lua_Integer n);
IMPORT_SYMBOL(lua_rawgetp, int, lua_State *L, int idx, const void *p);
IMPORT_SYMBOL(lua_createtable, void, lua_State *L, int narr, int nrec);
IMPORT_SYMBOL(lua_newuserdatauv, void *, lua_State *L, size_t sz, int nuvalue);
IMPORT_SYMBOL(lua_getmetatable, int, lua_State *L, int objindex);
IMPORT_SYMBOL(lua_getiuservalue, int, lua_State *L, int idx, int n);
IMPORT_SYMBOL(lua_setglobal, void, lua_State *L, const char *var);
IMPORT_SYMBOL(lua_settable, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_setfield, void, lua_State *L, int idx, const char *k);
IMPORT_SYMBOL(lua_seti, void, lua_State *L, int idx, lua_Integer n);
IMPORT_SYMBOL(lua_rawset, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_rawseti, void, lua_State *L, int idx, lua_Integer n);
IMPORT_SYMBOL(lua_rawsetp, void, lua_State *L, int idx, const void *p);
IMPORT_SYMBOL(lua_setmetatable, int, lua_State *L, int objindex);
IMPORT_SYMBOL(lua_setiuservalue, int, lua_State *L, int idx, int n);
IMPORT_SYMBOL(lua_callk, void, lua_State *L, int nargs, int nresults, lua_KContext ctx, lua_KFunction k);
IMPORT_SYMBOL(lua_pcallk, int, lua_State *L, int nargs, int nresults, int errfunc, lua_KContext ctx, lua_KFunction k);
IMPORT_SYMBOL(lua_load, int, lua_State *L, lua_Reader reader, void *dt, const char *chunkname, const char *mode);
IMPORT_SYMBOL(lua_dump, int, lua_State *L, lua_Writer writer, void *data, int strip);
IMPORT_SYMBOL(lua_yieldk, int, lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k);
IMPORT_SYMBOL(lua_resume, int, lua_State *L, lua_State *from, int narg, int *nres);
IMPORT_SYMBOL(lua_status, int, lua_State *L);
IMPORT_SYMBOL(lua_isyieldable, int, lua_State *L);
IMPORT_SYMBOL(lua_setwarnf, void, lua_State *L, lua_WarnFunction f, void *ud);
IMPORT_SYMBOL(lua_warning, void, lua_State *L, const char *msg, int tocont);
IMPORT_SYMBOL(lua_gc, int, lua_State *L, int what, ...);
IMPORT_SYMBOL(lua_error, int, lua_State *L);
IMPORT_SYMBOL(lua_next, int, lua_State *L, int idx);
IMPORT_SYMBOL(lua_concat, void, lua_State *L, int n);
IMPORT_SYMBOL(lua_len, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_stringtonumber, size_t, lua_State *L, const char *s);
IMPORT_SYMBOL(lua_getallocf, lua_Alloc, lua_State *L, void **ud);
IMPORT_SYMBOL(lua_setallocf, void, lua_State *L, lua_Alloc f, void *ud);
IMPORT_SYMBOL(lua_toclose, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_closeslot, void, lua_State *L, int idx);
IMPORT_SYMBOL(lua_getstack, int, lua_State *L, int level, lua_Debug *ar);
IMPORT_SYMBOL(lua_getinfo, int, lua_State *L, const char *what, lua_Debug *ar);
IMPORT_SYMBOL(lua_getlocal, const char *, lua_State *L, const lua_Debug *ar, int n);
IMPORT_SYMBOL(lua_setlocal, const char *, lua_State *L, const lua_Debug *ar, int n);
IMPORT_SYMBOL(lua_getupvalue, const char *, lua_State *L, int funcindex, int n);
IMPORT_SYMBOL(lua_setupvalue, const char *, lua_State *L, int funcindex, int n);
IMPORT_SYMBOL(lua_upvalueid, void *, lua_State *L, int fidx, int n);
IMPORT_SYMBOL(lua_upvaluejoin, void, lua_State *L, int fidx1, int n1, int fidx2, int n2);
IMPORT_SYMBOL(lua_sethook, void, lua_State *L, lua_Hook func, int mask, int count);
IMPORT_SYMBOL(lua_gethook, lua_Hook, lua_State *L);
IMPORT_SYMBOL(lua_gethookmask, int, lua_State *L);
IMPORT_SYMBOL(lua_gethookcount, int, lua_State *L);
IMPORT_SYMBOL(lua_setcstacklimit, int, lua_State *L, unsigned int limit);
IMPORT_SYMBOL(luaL_checkversion_, void, lua_State *L, lua_Number ver, size_t sz);
IMPORT_SYMBOL(luaL_getmetafield, int, lua_State *L, int obj, const char *e);
IMPORT_SYMBOL(luaL_callmeta, int, lua_State *L, int obj, const char *e);
IMPORT_SYMBOL(luaL_tolstring, const char *, lua_State *L, int idx, size_t *len);
IMPORT_SYMBOL(luaL_argerror, int, lua_State *L, int numarg, const char *extramsg);
IMPORT_SYMBOL(luaL_typeerror, int, lua_State *L, int arg, const char *tname);
IMPORT_SYMBOL(luaL_checklstring, const char *, lua_State *L, int numArg, size_t *l);
IMPORT_SYMBOL(luaL_optlstring, const char *, lua_State *L, int numArg, const char *def, size_t *l);
IMPORT_SYMBOL(luaL_checknumber, lua_Number, lua_State *L, int numArg);
IMPORT_SYMBOL(luaL_optnumber, lua_Number, lua_State *L, int nArg, lua_Number def);
IMPORT_SYMBOL(luaL_checkinteger, lua_Integer, lua_State *L, int numArg);
IMPORT_SYMBOL(luaL_optinteger, lua_Integer, lua_State *L, int nArg, lua_Integer def);
IMPORT_SYMBOL(luaL_checkstack, void, lua_State *L, int sz, const char *msg);
IMPORT_SYMBOL(luaL_checktype, void, lua_State *L, int narg, int t);
IMPORT_SYMBOL(luaL_checkany, void, lua_State *L, int narg);
IMPORT_SYMBOL(luaL_newmetatable, int, lua_State *L, const char *tname);
IMPORT_SYMBOL(luaL_setmetatable, void, lua_State *L, const char *tname);
IMPORT_SYMBOL(luaL_testudata, void *, lua_State *L, int ud, const char *tname);
IMPORT_SYMBOL(luaL_checkudata, void *, lua_State *L, int ud, const char *tname);
IMPORT_SYMBOL(luaL_where, void, lua_State *L, int lvl);
IMPORT_SYMBOL(luaL_error, int, lua_State *L, const char *fmt, ...);
IMPORT_SYMBOL(luaL_checkoption, int, lua_State *L, int narg, const char *def, const char *const lst[]);
IMPORT_SYMBOL(luaL_fileresult, int, lua_State *L, int stat, const char *fname);
IMPORT_SYMBOL(luaL_execresult, int, lua_State *L, int stat);
IMPORT_SYMBOL(luaL_ref, int, lua_State *L, int t);
IMPORT_SYMBOL(luaL_unref, void, lua_State *L, int t, int ref);
IMPORT_SYMBOL(luaL_loadfilex, int, lua_State *L, const char *filename, const char *mode);
IMPORT_SYMBOL(luaL_loadbufferx, int, lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
IMPORT_SYMBOL(luaL_loadstring, int, lua_State *L, const char *s);
IMPORT_SYMBOL(luaL_newstate, lua_State *, void);
IMPORT_SYMBOL(luaL_len, lua_Integer, lua_State *L, int idx);
IMPORT_SYMBOL(luaL_addgsub, void, luaL_Buffer *b, const char *s, const char *p, const char *r);
IMPORT_SYMBOL(luaL_gsub, const char *, lua_State *L, const char *s, const char *p, const char *r);
IMPORT_SYMBOL(luaL_setfuncs, void, lua_State *L, const luaL_Reg *l, int nup);
IMPORT_SYMBOL(luaL_getsubtable, int, lua_State *L, int idx, const char *fname);
IMPORT_SYMBOL(luaL_traceback, void, lua_State *L, lua_State *L1, const char *msg, int level);
IMPORT_SYMBOL(luaL_requiref, void, lua_State *L, const char *modname, lua_CFunction openf, int glb);
IMPORT_SYMBOL(luaL_buffinit, void, lua_State *L, luaL_Buffer *B);
IMPORT_SYMBOL(luaL_prepbuffsize, char *, luaL_Buffer *B, size_t sz);
IMPORT_SYMBOL(luaL_addlstring, void, luaL_Buffer *B, const char *s, size_t l);
IMPORT_SYMBOL(luaL_addstring, void, luaL_Buffer *B, const char *s);
IMPORT_SYMBOL(luaL_addvalue, void, luaL_Buffer *B);
IMPORT_SYMBOL(luaL_pushresult, void, luaL_Buffer *B);
IMPORT_SYMBOL(luaL_pushresultsize, void, luaL_Buffer *B, size_t sz);
IMPORT_SYMBOL(luaL_buffinitsize, char *, lua_State *L, luaL_Buffer *B, size_t sz);
IMPORT_SYMBOL(luaopen_base, int, lua_State *L);
IMPORT_SYMBOL(luaopen_coroutine, int, lua_State *L);
IMPORT_SYMBOL(luaopen_table, int, lua_State *L);
IMPORT_SYMBOL(luaopen_io, int, lua_State *L);
IMPORT_SYMBOL(luaopen_os, int, lua_State *L);
IMPORT_SYMBOL(luaopen_string, int, lua_State *L);
IMPORT_SYMBOL(luaopen_utf8, int, lua_State *L);
IMPORT_SYMBOL(luaopen_math, int, lua_State *L);
IMPORT_SYMBOL(luaopen_debug, int, lua_State *L);
IMPORT_SYMBOL(luaopen_package, int, lua_State *L);
IMPORT_SYMBOL(luaL_openlibs, void, lua_State* L);
}
#undef IMPORT_SYMBOL
#undef IMPORT_SYMBOL_OPT
#else /* LITE_XL_PLUGIN_ENTRYPOINT */
void lite_xl_plugin_init(void *XL);
#endif /* LITE_XL_PLUGIN_ENTRYPOINT */
#undef LITE_XL_API
#undef SYMBOL_WRAP_DECL
#undef SYMBOL_WRAP_CALL
#undef SYMBOL_WRAP_CALL_FB
#undef SYMBOL_DECLARE
#undef SYMBOL_DECLARE_VARARG
#undef UNUSED
#undef CONCAT
#undef CONCAT1
#undef CONCAT2
#undef FE_1
#undef FE_2
#undef FE_3
#undef FE_4
#undef FE_5
#undef FE_6
#undef FE_7
#undef FE_8
#undef FOR_EACH_NARG
#undef FOR_EACH_NARG_
#undef FOR_EACH_ARG_N
#undef FOR_EACH_RSEQ_N
#undef FOR_EACH_
#undef FOR_EACH
#endif /* LITE_XL_PLUGIN_API */
/******************************************************************************
* Copyright (C) 1994-2023 Lua.org, PUC-Rio; Lite XL contributors.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
|