Guards = #if 0 ... #endif around things you don't need.
Leadwerks_G.h is my own doing: after sticking in a bunch of said guards to get rid of unwanted things like the standard libraries, run it through gcc -E to include all files and expand all macros, creating a "flat" Leadwerks header. This is not necessary to use SWIG in the general case (SWIG is built on GCC anyway, it can do preprocessor stuff perfectly well), but it gave a clearer idea of what was going on, I thought.
SWIG produces C-style code like this:
EXPORT void _wrap_Entity_Translate__SWIG_1 (Leadwerks::Entity *larg1, float larg2, float larg3, float larg4) {
Leadwerks::Entity *arg1 = (Leadwerks::Entity *) 0 ;
float arg2 ;
float arg3 ;
float arg4 ;
arg1 = larg1;
arg2 = larg2;
arg3 = larg3;
arg4 = larg4;
try {
{
(arg1)->Translate(arg2,arg3,arg4);
}
} catch (...) {
}
}
(Longwinded to read but will be identical to a one-liner after optimisation.) That's what is found in Leadwerks_wrap.cxx: C-style wrappers for C++ calls, creating a completely flat API. I assume this also answers the question about heap usage (which I otherwise don't follow, sorry).
It also produces FFI declarations for the requested language to make these C-style wrapper functions available. How much more wrapping takes place at that level depends on how that language's FFI works (the CFFI output is nice primarily because it consists entirely of easily-parsed type declarations - I assume a Common Lisp interpreter will build glue out of these itself - rather than actual C glue code to do the dynamic type checking like it outputs for some other targets; this means you can extract the types for other uses).