Author: rloach
Date: 2007-03-26 07:59:46 -0500 (Mon, 26 Mar 2007)
New Revision: 74977

Modified:
   trunk/tao/src/Tao.Lua/Lua.cs
Log:
Tao.Lua - lua_tostring fix (fdorothy).

Modified: trunk/tao/src/Tao.Lua/Lua.cs
===================================================================
--- trunk/tao/src/Tao.Lua/Lua.cs        2007-03-26 12:31:45 UTC (rev 74976)
+++ trunk/tao/src/Tao.Lua/Lua.cs        2007-03-26 12:59:46 UTC (rev 74977)
@@ -592,7 +592,7 @@
         /// </returns>
         [CLSCompliant(false)]
         [DllImport(LUA_NATIVE_LIBRARY, CallingConvention = 
CALLING_CONVENTION), SuppressUnmanagedCodeSecurity]
-        public extern static string lua_tolstring(lua_State L, int idx, ref 
size_t len);
+        public extern static string lua_tolstring(lua_State L, int idx, out 
size_t len);
 
         //LUA_API size_t          (lua_objlen) (lua_State *L, int idx);
         /// <summary>
@@ -1477,8 +1477,12 @@
         /// <returns></returns>
         public static string lua_tostring(lua_State L, int i)
         {
-            uint blah = 0;
-            return lua_tolstring(L, i, ref blah);
+            int strlen;
+            IntPtr str = lua_tolstring(L, i, out strlen);
+            if (str != IntPtr.Zero)
+                return Marshal.PtrToStringAnsi(str, strlen);
+            else
+                return null;
         }
 
         #endregion Some Useful Macros

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to