sovr610 / luainterface

Automatically exported from code.google.com/p/luainterface
1 stars 0 forks source link

Unable to using registered functions when working with other lua_state, #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi I stating to think about LuaInterface can't use any other lua_state that not 
previusly created with his own lua51 modofied module.

I have a c++/mfc unmanaged app, with a existing luastate running, I use loadlib 
to load a c# library with exported symbols.

there is my main funcition:

public static Lua L = null;

       [DllExport("bind", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
      static void Bind(IntPtr ls)
      {
          Lua L = new Lua(ls.ToInt64());
          lll wee = new lll();
          //L.DoString("a='eoeoeoeoeo Pabloko Rulez!!'");
          try
          {
              L.DoString("Dialog.Message('ALERTA','ERES GAY'); a=1+2+3+4+5+6; Dialog.Message('',a)");
              L.RegisterFunction("PablokoSays", wee, wee.GetType().GetMethod("PablokoSays"));
          }
          catch (Exception e) { }
      }

This finally works, but i edited luainterface lua.cs to remove some luanet 
calls in Lua(long) because the untouched lib produces a crash (i'n my lua state 
there arent luanet, because is created by original lua 5.1.4 libs)

Ok, this example works perfectly, but when i call the function registered:
public class lll
   {
       public static Lua L = null;

       public void PablokoSays(string uno, string dos)
       {
           return uno + ' ' + dos;  
       }
   }
}

Appcrash and not debuggeable.

I sepent at least 40 hours of work with this, but i think that i can't 
interface normal lua state in luanet with this method... it's true? :( 

Original issue reported on code.google.com by pablomor...@gmail.com on 16 Apr 2011 at 5:12