cffi-lua
cffi-lua copied to clipboard
Parse constants like luajit-ffi
Hello ! Nice work ! While doing some tests with existing luajit-ffi files I noticed that cffi do not understand this declarations as constants like enums:
/* kind of structural variable: */
static const int GLP_CV= 1; /* continuous variable */
static const int GLP_IV = 2; /* integer variable */
static const int GLP_BV= 3; /* binary variable */
Cheers !
Also on linux to eliminate the dependency on libstdc++ I've added this to src/util.cc
#include <cstdlib>
#include <cstdio>
#include "util.hh"
// MSVC uses __cdecl calling convention for new/delete :-O
#ifdef _MSC_VER
# define NEWDEL_CALL __cdecl
#else
# define NEWDEL_CALL
#endif
void *NEWDEL_CALL operator new(size_t n) {
void *p = malloc(n);
if (!p) {
abort(); /* FIXME: do not abort */
}
return p;
}
void *NEWDEL_CALL operator new[](size_t n) {
void *p = malloc(n);
if (!p) {
abort();
}
return p;
}
void NEWDEL_CALL operator delete(void *p) {
free(p);
}
void NEWDEL_CALL operator delete[](void *p) {
free(p);
}
void NEWDEL_CALL operator delete(void *p, size_t) {
free(p);
}
void NEWDEL_CALL operator delete[](void *p, size_t) {
free(p);
}
extern "C" void __cxa_pure_virtual ()
{
puts("__cxa_pure_virtual called\n");
abort ();
}
extern "C" int __cxa_thread_atexit(void (*func)(), void *obj,
void *dso_symbol) {
int __cxa_thread_atexit_impl(void (*)(), void *, void *);
return __cxa_thread_atexit_impl(func, obj, dso_symbol);
}
constants parsing is a rough work in progress right now, as is eliminating libstdc++ (the ultimate goal is to not have any C runtime dependency on windows, on unix-likes it'll use libc as libc is the standard runtime)