v4k-git-backup/engine/bind/v4k.py

27 lines
934 B
Python
Raw Normal View History

2023-08-10 14:30:56 +00:00
import os
import sys
import ctypes
import cffi
ffi = cffi.FFI()
with open('./v4k.lua') as f:
lines = [line for line in f if not line.startswith('#')]
lines = [line for line in lines if not 'va_list' in line]
lines = [line for line in lines if not 'inline ' in line]
lines = [line for line in lines if not line.startswith('typedef union ') ]
lines = [line for line in lines if not '//lcpp INF' in line ]
data = ''.join(lines)
data = data[data.find('[[')+2:data.find(']]')]
data = '''
typedef struct vec2i { float x,y; } vec2i;
typedef struct vec3i { float x,y,z; } vec3i;
typedef struct vec2 { float x,y; } vec2;
typedef struct vec3 { float x,y,z; } vec3;
typedef struct vec4 { float x,y,z,w; } vec4;
typedef struct quat { float x,y,z,w; } quat;
typedef union frustum frustum;
typedef union json_t json_t;
''' + data
ffi.cdef(data)
v4k = ffi.dlopen('./v4k.dll')