title: creating a callback struct to pass into the LuaJIT FFI
body: <p>So first I load in a DLL I need</p>
  
  <pre><code>local ffi = require("ffi")
  local theDLL = ffi.load("thisDLL")
  </code></pre>
  
  <p>in the ffi cdef I have two different kinds of structs</p>
  
  <pre><code>ffi.cdef [[
      typedef struct StructSession StructSession;
      typedef struct {
          /*
          * begin_proj callback
          */
          bool (__cdecl *begin_proj)(char *proj);
  
          /*
          * save_proj_state
          */
          bool (__cdecl *save_proj_state)(unsigned char **buffer, int *len);
      } StructCallbacks;
  </code></pre>
  
  <p>I also have this function in the cdef</p>
  
  <pre><code>__declspec(dllexport) int __cdecl start_session(StructSession **session,
                                                             StructCallbacks *cb);
  </code></pre>
  
  <p>Now I would like to call this function</p>
  
  <pre><code>print(theDLL.start_session(a,b))
  </code></pre>
  
  <p>vars a and b are obviously placeholders, the question is how can I pass the structs the function needs? And say we get StructSession working, is making a callback to a function WITHIN LuaJIT even going to be possible for StructCallbacks?</p>