update lua support

main
Dominik Madarász 2024-01-01 22:15:15 +01:00
parent 9e31348378
commit 4e9bf5d6e7
3 changed files with 1750 additions and 1969 deletions

1725
tools/cparser.lua 100644

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,25 @@
local lcpp = require("tools/luajit_lcpp") local lcpp = require("tools/cparser")
local glue = [[ local glue = [[
#define __TINYC__ #define __TINYC__
#define static #define static
#define __thread #define __thread
#define STATIC_ASSERT(x)
//#define ifdef(a,b,...) ifdef_##a(b,__VA_ARGS__)
//#define ifndef(a,b,...) ifdef_##a(__VA_ARGS__,b)
//#define ifdef_true(b,...) b
//#define ifdef_false(b,...) __VA_ARGS__
#define OBJ \
struct { \
ifdef(debug, const char *objname;) \
uintptr_t objheader; \
array(struct obj*) objchildren; \
};
#define ENTITY \
struct { OBJ \
uintptr_t cflags; \
void *c[OBJCOMPONENTS_MAX]; \
};
typedef struct FILE FILE; typedef struct FILE FILE;
typedef long int ptrdiff_t; typedef long int ptrdiff_t;
typedef long unsigned int size_t; typedef long unsigned int size_t;
@ -18,17 +34,17 @@ function trim_multilines(str)
return output return output
end end
io.input("./engine/v4k.h") io.input("./engine/fwk.h")
local v4k_h = io.read("*all") local fwk_h = io.read("*all")
v4k_h = v4k_h:gsub("#line", "//#line") fwk_h = fwk_h:gsub("#line", "//#line")
v4k_h = v4k_h:gsub("#include", "//#include") fwk_h = fwk_h:gsub("#include", "//#include")
print('--autogenerated luajit bindings. do not edit.') -- .. os.date("%Y/%m/%d")) print('--autogenerated luajit bindings. do not edit.') -- .. os.date("%Y/%m/%d"))
print('local ffi = require("ffi")') print('local ffi = require("ffi")')
print('ffi.cdef([[') print('ffi.cdef([[')
local result = lcpp.compile(glue .. v4k_h) local result = lcpp.cppString(glue .. fwk_h, '-', {"-Znopass"}, 'fwk')
print( trim_multilines(result) ) --print( trim_multilines(result) )
print(']])') print(']])')
@ -68,11 +84,11 @@ function _M.mat44()
return m return m
end end
local fwk = ffi.load("v4k") local fwk = ffi.load("fwk")
return setmetatable( _M, { return setmetatable( _M, {
__index = function( table, key ) __index = function( table, key )
return fwk[ key ] return fwk[ key ]
end end
} ) } )
]]) ]])