Commit b5b573a3 authored by Megax's avatar Megax
Browse files

* lua_Debug osztaly a KopiLua-bol lesz ezentul meghivva. Igy tokeletesen fog...

* lua_Debug osztaly a KopiLua-bol lesz ezentul meghivva. Igy tokeletesen fog mukodni a konvertalas es a meghivas. Ket fv atalakitasa visszamaradt.
parent b969a882
using System;
using LuaInterface;
using System.Threading;
using LuaInterface;
/*
* Application to run Lua scripts that can use LuaInterface
......
......@@ -639,7 +639,7 @@ namespace KopiLua
lua_pushvalue(L, -1);
lua_replace(L, LUA_ENVIRONINDEX);
/* create `loaders' table */
lua_createtable(L, 0, loaders.Length - 1);
lua_createtable(L, loaders.Length - 1, 0);
/* fill it with pre-defined loaders */
for (i=0; loaders[i] != null; i++) {
lua_pushcfunction(L, loaders[i]);
......
......@@ -27,20 +27,22 @@ using System;
namespace LuaInterface.Event
{
using LuaCore = KopiLua.Lua;
/// <summary>
/// Event args for hook callback event
/// </summary>
/// <author>Reinhard Ostermeier</author>
public class DebugHookEventArgs : EventArgs
{
private readonly LuaDebug luaDebug;
private readonly LuaCore.lua_Debug luaDebug;
public DebugHookEventArgs(LuaDebug luaDebug)
public DebugHookEventArgs(LuaCore.lua_Debug luaDebug)
{
this.luaDebug = luaDebug;
}
public LuaDebug LuaDebug
public LuaCore.lua_Debug LuaDebug
{
get { return luaDebug; }
}
......
/*
* This file is part of LuaInterface.
*
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
namespace LuaInterface.Event
{
/// <summary>
/// Structure for lua debug information
/// </summary>
/// <remarks>
/// Do not change this struct because it must match the lua structure lua_debug
/// </remarks>
/// <author>Reinhard Ostermeier</author>
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct LuaDebug
{
public EventCodes eventCode;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public string name;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public string namewhat;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public string what;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public string source;
public int currentline;
public int nups;
public int linedefined;
public int lastlinedefined;
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 60/*LUA_IDSIZE*/)]
public string shortsrc;
public int i_ci;
}
}
\ No newline at end of file
......@@ -761,7 +761,6 @@ namespace LuaInterface
* Lets go of a previously allocated reference to a table, function
* or userdata
*/
#region lua debug functions
/// <summary>
/// Activates the debug hook
......@@ -770,15 +769,16 @@ namespace LuaInterface
/// <param name = "count">Count</param>
/// <returns>see lua docs. -1 if hook is already set</returns>
/// <author>Reinhard Ostermeier</author>
/*public int SetDebugHook(EventMasks mask, int count)
public int SetDebugHook(EventMasks mask, int count)
{
if(hookCallback.IsNull())
{
hookCallback = new LuaCore.lua_Hook(DebugHookCallback);
return LuaCore.lua_sethook(luaState, hookCallback, (int)mask, count);
}
return -1;
}*/
}
/// <summary>
/// Removes the debug hook
......@@ -818,14 +818,14 @@ namespace LuaInterface
/// <param name = "luaDebug">lua debug structure</param>
/// <returns>Returns true if level was allowed, false if level was invalid.</returns>
/// <author>Reinhard Ostermeier</author>
/*public bool GetStack(int level, out LuaDebug luaDebug)
/*public bool GetStack(int level, out LuaCore.lua_Debug luaDebug)
{
luaDebug = new LuaDebug();
LuaCore.lua_State ld = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(luaDebug));
System.Runtime.InteropServices.Marshal.StructureToPtr(luaDebug, ld, false);
try
{
return LuaCore.lua_getstack(luaState, level, ld) != 0;
return LuaCore.lua_getstack(luaState, level, luaDebug) != 0;
}
finally
{
......@@ -841,7 +841,7 @@ namespace LuaInterface
/// <param name = "luaDebug">lua debug structure</param>
/// <returns>see lua docs</returns>
/// <author>Reinhard Ostermeier</author>
/*public int GetInfo(String what, ref LuaDebug luaDebug)
/*public int GetInfo(String what, ref LuaCore.lua_Debug luaDebug)
{
LuaCore.lua_State ld = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(luaDebug));
System.Runtime.InteropServices.Marshal.StructureToPtr(luaDebug, ld, false);
......@@ -863,19 +863,17 @@ namespace LuaInterface
/// <param name = "n">see lua docs</param>
/// <returns>see lua docs</returns>
/// <author>Reinhard Ostermeier</author>
/*public String GetLocal(LuaDebug luaDebug, int n)
public string GetLocal(LuaCore.lua_Debug luaDebug, int n)
{
LuaCore.lua_State ld = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(luaDebug));
System.Runtime.InteropServices.Marshal.StructureToPtr(luaDebug, ld, false);
try
{
return LuaCore.lua_getlocal(luaState, ld, n);
return LuaCore.lua_getlocal(luaState, luaDebug, n).ToString();
}
finally
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(ld);
//System.Runtime.InteropServices.Marshal.FreeHGlobal(ld);
}
}
}*/
/// <summary>
/// Sets local (see lua docs)
......@@ -884,19 +882,17 @@ namespace LuaInterface
/// <param name = "n">see lua docs</param>
/// <returns>see lua docs</returns>
/// <author>Reinhard Ostermeier</author>
/*public String SetLocal(LuaDebug luaDebug, int n)
public string SetLocal(LuaCore.lua_Debug luaDebug, int n)
{
LuaCore.lua_State ld = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(luaDebug));
System.Runtime.InteropServices.Marshal.StructureToPtr(luaDebug, ld, false);
try
{
return LuaCore.lua_setlocal(luaState, ld, n);
return LuaCore.lua_setlocal(luaState, luaDebug, n).ToString();
}
finally
{
System.Runtime.InteropServices.Marshal.FreeHGlobal(ld);
//System.Runtime.InteropServices.Marshal.FreeHGlobal(ld);
}
}
}*/
/// <summary>
/// Gets up value (see lua docs)
......@@ -928,22 +924,20 @@ namespace LuaInterface
/// <param name = "luaState">lua state</param>
/// <param name = "luaDebug">Pointer to LuaDebug (lua_debug) structure</param>
/// <author>Reinhard Ostermeier</author>
/*private void DebugHookCallback(LuaCore.lua_State luaState, LuaCore.lua_Debug luaDebug)
private void DebugHookCallback(LuaCore.lua_State luaState, LuaCore.lua_Debug luaDebug)
{
try
{
LuaDebug ld = (LuaDebug)System.Runtime.InteropServices.Marshal.PtrToStructure(luaDebug, typeof(LuaDebug));
EventHandler<DebugHookEventArgs> temp = DebugHook;
if(temp != null)
{
temp(this, new DebugHookEventArgs(ld));
}
var temp = DebugHook;
if(!temp.IsNull())
temp(this, new DebugHookEventArgs(luaDebug));
}
catch (Exception ex)
catch(Exception ex)
{
OnHookException(new HookExceptionEventArgs(ex));
}
}*/
}
private void OnHookException(HookExceptionEventArgs e)
{
......
......@@ -78,7 +78,6 @@
<Compile Include="GenerateEventAssembly\CodeGeneration.cs" />
<Compile Include="Event\EventCodes.cs" />
<Compile Include="Event\EventMasks.cs" />
<Compile Include="Event\LuaDebug.cs" />
<Compile Include="Event\DebugHookEventArgs.cs" />
<Compile Include="Event\HookExceptionEventArgs.cs" />
<Compile Include="Exceptions\LuaException.cs" />
......
......@@ -38,22 +38,6 @@ namespace LuaInterface
{
private static int tag = 0;
/// <summary>
/// Function to get byte array from a object
/// </summary>
/// <param name="_Object">object to get byte array</param>
/// <returns>Byte Array</returns>
public static byte[] ObjectToByteArray(object obj)
{
if(obj.IsNull())
return null;
var bf = new BinaryFormatter();
var ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
public static LuaTypes ToLuaTypes(this int type)
{
return (LuaTypes)type;
......@@ -171,7 +155,7 @@ namespace LuaInterface
public static int checkudata_raw(LuaCore.lua_State luaState, int ud, string tname)
{
int p = (int)LuaCore.lua_touserdata2(luaState, ud);
//Console.WriteLine(BitConverter.ToInt32(ObjectToByteArray(LuaCore.lua_touserdata(luaState, ud)), 0));
if(p != 0)
{
/* value is a userdata? */
......
......@@ -172,7 +172,7 @@ namespace LuaInterface
}
object index = translator.getObject(luaState, 2);
var indexType = index.GetType();
//var indexType = index.GetType();
string methodName = index as string; // will be null if not a string arg
var objType = obj.GetType();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment