title: Reading and writing C struct from embedded lua
body: <p>I'd like to embed lua to allow scripting in my C++ application. In particular, I have two structs which I'd like to pass as arguments to a given lua function. One will be read-only, the other will be read/write. Highly simplified examples of these structs follow:</p>
  
  <pre><code>struct inData
  {
      int x;
      int y;
      //many other fields follow
  };
  
  struct outData
  {
      int a;
      double b;
      //other fields follow
  };
  </code></pre>
  
  <p>Both of these structs are created in the C++ code and will be processed there both before and after calling the lua functions. How can I pass these structs to a lua function such that the function can do things like this:</p>
  
  <pre><code>if(inData.x &gt; 5) then outData.a = 1 end
  </code></pre>
  
  <p>and have the outData instance actually retain the changes after returning from the lua function?</p>