Commit 8a76b646 authored by Megax's avatar Megax
Browse files

* LuaInterface szerkezeti felepitese lasacskan at lesz formalva. Amikor lesz...

* LuaInterface szerkezeti felepitese lasacskan at lesz formalva. Amikor lesz idom es kedvem folytatom az atalakitast.
parent 02869e90
/*
* 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
{
/*
* Class used for generating delegates that get a table from the Lua
* stack as a an object of a specific type.
*
* Author: Fabio Mascarenhas
* Version: 1.0
*/
class ClassGenerator
{
private ObjectTranslator translator;
private Type klass;
public ClassGenerator(ObjectTranslator translator, Type klass)
{
this.translator = translator;
this.klass = klass;
}
public object extractGenerated(KopiLua.Lua.lua_State luaState, int stackPos)
{
return CodeGeneration.Instance.GetClassInstance(klass, translator.getTable(luaState, stackPos));
}
}
}
\ No newline at end of file
/*
* 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
{
/*
* Class used for generating delegates that get a function from the Lua
* stack as a delegate of a specific type.
*
* Author: Fabio Mascarenhas
* Version: 1.0
*/
class DelegateGenerator
{
private ObjectTranslator translator;
private Type delegateType;
public DelegateGenerator(ObjectTranslator translator, Type delegateType)
{
this.translator = translator;
this.delegateType = delegateType;
}
public object extractGenerated(KopiLua.Lua.lua_State luaState, int stackPos)
{
return CodeGeneration.Instance.GetDelegate(delegateType, translator.getFunction(luaState, stackPos));
}
}
}
\ No newline at end of file
/*
* 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
{
/*
* Common interface for types generated from tables. The method
* returns the table that overrides some or all of the type's methods.
*/
public interface ILuaGeneratedType
{
LuaTable __luaInterface_getLuaTable();
}
}
\ No newline at end of file
/*
* 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
{
/*
* Structure to store a type and the return types of
* its methods (the type of the returned value and out/ref
* parameters).
*/
struct LuaClassType
{
public Type klass;
public Type[][] returnTypes;
}
}
\ No newline at end of file
/*
* 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;
using System.IO;
using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using LuaInterface.Event;
namespace LuaInterface namespace LuaInterface
{ {
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Threading;
using LuaWrap;
/* /*
* Main class of LuaInterface * Main class of LuaInterface
* Object-oriented wrapper to Lua API * Object-oriented wrapper to Lua API
...@@ -64,15 +88,15 @@ namespace LuaInterface ...@@ -64,15 +88,15 @@ namespace LuaInterface
"-- Preload the mscorlib assembly \n"+ "-- Preload the mscorlib assembly \n"+
"luanet.load_assembly(\"mscorlib\") \n"; "luanet.load_assembly(\"mscorlib\") \n";
/*readonly */ KopiLua.Lua.lua_State luaState; private /*readonly */ KopiLua.Lua.lua_State luaState;
ObjectTranslator translator; private ObjectTranslator translator;
KopiLua.Lua.lua_CFunction panicCallback/*, lockCallback, unlockCallback*/; private KopiLua.Lua.lua_CFunction panicCallback;
/// <summary> /// <summary>
/// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects /// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
/// </summary> /// </summary>
object luaLock = new object(); private object luaLock = new object();
public Lua() public Lua()
{ {
...@@ -561,8 +585,8 @@ namespace LuaInterface ...@@ -561,8 +585,8 @@ namespace LuaInterface
public LuaFunction GetFunction(string fullPath) public LuaFunction GetFunction(string fullPath)
{ {
object obj=this[fullPath]; object obj=this[fullPath];
//return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : (LuaFunction)obj); return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : (LuaFunction)obj);
return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : /*(LuaFunction)*/new LuaFunction(obj.GetHashCode(), this)); //return (obj is KopiLua.Lua.lua_CFunction ? new LuaFunction((KopiLua.Lua.lua_CFunction)obj,this) : /*(LuaFunction)*/new LuaFunction(obj.GetHashCode(), this));
} }
/* /*
* Gets a function global variable as a delegate of * Gets a function global variable as a delegate of
...@@ -1041,98 +1065,4 @@ namespace LuaInterface ...@@ -1041,98 +1065,4 @@ namespace LuaInterface
#endregion #endregion
} }
/// <summary>
/// Event codes for lua hook function
/// </summary>
/// <remarks>
/// Do not change any of the values because they must match the lua values
/// </remarks>
/// <author>Reinhard Ostermeier</author>
public enum EventCodes
{
LUA_HOOKCALL = 0,
LUA_HOOKRET = 1,
LUA_HOOKLINE = 2,
LUA_HOOKCOUNT = 3,
LUA_HOOKTAILRET = 4,
}
/// <summary>
/// Event masks for lua hook callback
/// </summary>
/// <remarks>
/// Do not change any of the values because they must match the lua values
/// </remarks>
/// <author>Reinhard Ostermeier</author>
[Flags]
public enum EventMasks
{
LUA_MASKCALL = (1 << EventCodes.LUA_HOOKCALL),
LUA_MASKRET = (1 << EventCodes.LUA_HOOKRET),
LUA_MASKLINE = (1 << EventCodes.LUA_HOOKLINE),
LUA_MASKCOUNT = (1 << EventCodes.LUA_HOOKCOUNT),
LUA_MASKALL = Int32.MaxValue,
}
/// <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;
}
/// <summary>
/// Event args for hook callback event
/// </summary>
/// <author>Reinhard Ostermeier</author>
public class DebugHookEventArgs : EventArgs
{
private readonly LuaDebug luaDebug;
public DebugHookEventArgs(LuaDebug luaDebug)
{
this.luaDebug = luaDebug;
}
public LuaDebug LuaDebug
{
get { return luaDebug; }
}
}
public class HookExceptionEventArgs : EventArgs
{
private readonly Exception m_Exception;
public Exception Exception
{
get { return m_Exception; }
}
public HookExceptionEventArgs(Exception ex)
{
m_Exception = ex;
}
}
} }
\ No newline at end of file
using System; /*
* 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
......
/*
* 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; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
......
using System; /*
using System.Collections.Generic; * 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;
using System.Text; using System.Text;
using LuaWrap; using System.Collections.Generic;
namespace LuaInterface namespace LuaInterface
{ {
public class LuaFunction : LuaBase public class LuaFunction : LuaBase
{ {
//private Lua interpreter;
internal KopiLua.Lua.lua_CFunction function; internal KopiLua.Lua.lua_CFunction function;
//internal int reference;
public LuaFunction(int reference, Lua interpreter) public LuaFunction(int reference, Lua interpreter)
{ {
...@@ -25,39 +47,6 @@ namespace LuaInterface ...@@ -25,39 +47,6 @@ namespace LuaInterface
_Interpreter = interpreter; _Interpreter = interpreter;
} }
//~LuaFunction()
//{
// if (reference != 0)
// interpreter.dispose(reference);
//}
//bool disposed = false;
//~LuaFunction()
//{
// Dispose(false);
//}
//public void Dispose()
//{
// Dispose(true);
// GC.SuppressFinalize(this);
//}
//public virtual void Dispose(bool disposeManagedResources)
//{
// if (!this.disposed)
// {
// if (disposeManagedResources)
// {
// if (_Reference != 0)
// _Interpreter.dispose(_Reference);
// }
// disposed = true;
// }
//}
/* /*
* Calls the function casting return values to the types * Calls the function casting return values to the types
* in returnTypes * in returnTypes
......
/*
* 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; using System;
namespace LuaInterface namespace LuaInterface
......
/*
* 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; using System;
namespace LuaInterface namespace LuaInterface
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CheckType.cs" /> <Compile Include="CheckType.cs" />
<Compile Include="GenerateEventAssembly.cs" />
<Compile Include="Lua.cs" /> <Compile Include="Lua.cs" />
<Compile Include="LuaException.cs" /> <Compile Include="LuaException.cs" />
<Compile Include="Metatables.cs" /> <Compile Include="Metatables.cs" />
...@@ -53,6 +52,17 @@ ...@@ -53,6 +52,17 @@
<Compile Include="LuaScriptException.cs" /> <Compile Include="LuaScriptException.cs" />
<Compile Include="LuaTable.cs" /> <Compile Include="LuaTable.cs" />
<Compile Include="LuaUserData.cs" /> <Compile Include="LuaUserData.cs" />
<Compile Include="Extensions\GeneralExtensions.cs" />
<Compile Include="GenerateEventAssembly\LuaClassType.cs" />
<Compile Include="GenerateEventAssembly\ILuaGeneratedType.cs" />
<Compile Include="GenerateEventAssembly\DelegateGenerator.cs" />
<Compile Include="GenerateEventAssembly\ClassGenerator.cs" />
<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" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
...@@ -68,4 +78,9 @@ ...@@ -68,4 +78,9 @@
<Name>KopiLua</Name> <Name>KopiLua</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Extensions\" />
<Folder Include="GenerateEventAssembly\" />
<Folder Include="Event\" />
</ItemGroup>
</Project> </Project>
// /*
// LuaDLL.cs * This file is part of LuaInterface.
// *
// Author: * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
// Joshua Simmons <simmons.44@gmail.com> * Copyright (C) 2009 Joshua Simmons <simmons.44@gmail.com>
// * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
// Copyright (c) 2009 Joshua Simmons *
// * Permission is hereby granted, free of charge, to any person obtaining a copy
// Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal
// of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights
// in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is
// copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:
// furnished to do so, subject to the following conditions: *
// * The above copyright notice and this permission notice shall be included in
// The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
// all copies or substantial portions of the Software. *
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// 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
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE.
// THE SOFTWARE. */
using System; using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using KopiLua; using System.Runtime.Serialization.Formatters.Binary;
using LuaInterface.Extensions;
namespace LuaWrap namespace LuaInterface
{ {
/// <summary> /// <summary>
/// Enumeration of basic lua globals. /// Enumeration of basic lua globals.
...@@ -114,7 +115,7 @@ namespace LuaWrap ...@@ -114,7 +115,7 @@ namespace LuaWrap
Collect = 2, Collect = 2,
/// <summary> /// <summary>
/// Returns the current amount of memory (in Kbytes) in use by Lua. /// Returns the current amount of memory (in Kbytes) in use by KopiLua.Lua.
/// </summary> /// </summary>
Count = 3, Count = 3,
...@@ -150,6 +151,22 @@ namespace LuaWrap ...@@ -150,6 +151,22 @@ namespace LuaWrap
{ {
private static int tag = 0; 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) public static LuaTypes ToLuaTypes(this int type)
{ {
return (LuaTypes)type; return (LuaTypes)type;
...@@ -175,9 +192,9 @@ namespace LuaWrap ...@@ -175,9 +192,9 @@ namespace LuaWrap
/// <param name="fn"> /// <param name="fn">
/// A <see cref="CallbackFunction"/> /// A <see cref="CallbackFunction"/>
/// </param> /// </param>
public static void lua_pushcfunction(Lua.lua_State state, Lua.lua_CFunction fn) public static void lua_pushcfunction(KopiLua.Lua.lua_State state, KopiLua.Lua.lua_CFunction fn)
{ {
Lua.lua_pushcclosure(state, fn, 0); KopiLua.Lua.lua_pushcclosure(state, fn, 0);
} }
#endregion #endregion
...@@ -194,9 +211,9 @@ namespace LuaWrap ...@@ -194,9 +211,9 @@ namespace LuaWrap
/// <returns> /// <returns>
/// A <see cref="System.Boolean"/> /// A <see cref="System.Boolean"/>
/// </returns> /// </returns>
public static bool luaL_dofile(Lua.lua_State state, string filename) public static bool luaL_dofile(KopiLua.Lua.lua_State state, string filename)
{ {
return (Lua.luaL_loadfile(state, filename).ToLuaEnum() == LuaEnum.Ok) && (Lua.lua_pcall(state, 0, (int)LuaEnum.MultiRet, 0).ToLuaEnum() == LuaEnum.Ok); return (KopiLua.Lua.luaL_loadfile(state, filename).ToLuaEnum() == LuaEnum.Ok) && (KopiLua.Lua.lua_pcall(state, 0, (int)LuaEnum.MultiRet, 0).ToLuaEnum() == LuaEnum.Ok);
} }
/// <summary> /// <summary>
...@@ -211,14 +228,14 @@ namespace LuaWrap ...@@ -211,14 +228,14 @@ namespace LuaWrap
/// <returns> /// <returns>
/// A <see cref="System.Boolean"/> /// A <see cref="System.Boolean"/>
/// </returns> /// </returns>
public static bool luaL_dostring(Lua.lua_State state, string chunk) public static bool luaL_dostring(KopiLua.Lua.lua_State state, string chunk)
{ {
return (Lua.luaL_loadstring(state, chunk).ToLuaEnum() == LuaEnum.Ok) && (Lua.lua_pcall(state, 0, (int)LuaEnum.MultiRet, 0).ToLuaEnum() == LuaEnum.Ok); return (KopiLua.Lua.luaL_loadstring(state, chunk).ToLuaEnum() == LuaEnum.Ok) && (KopiLua.Lua.lua_pcall(state, 0, (int)LuaEnum.MultiRet, 0).ToLuaEnum() == LuaEnum.Ok);
} }
public static LuaEnum luaL_loadbuffer(Lua.lua_State luaState, string buff, string name) public static LuaEnum luaL_loadbuffer(KopiLua.Lua.lua_State luaState, string buff, string name)
{ {
LuaEnum result = Lua.luaL_loadbuffer(luaState, buff, (uint)buff.Length, name).ToLuaEnum(); var result = KopiLua.Lua.luaL_loadbuffer(luaState, buff, (uint)buff.Length, name).ToLuaEnum();
return result; return result;
} }
...@@ -234,22 +251,24 @@ namespace LuaWrap ...@@ -234,22 +251,24 @@ namespace LuaWrap
/// <param name="r"> /// <param name="r">
/// A <see cref="System.Int32"/> /// A <see cref="System.Int32"/>
/// </param> /// </param>
public static void luaL_getref(Lua.lua_State state, int t, int r) public static void luaL_getref(KopiLua.Lua.lua_State state, int t, int r)
{ {
Lua.lua_rawgeti(state, t, r); KopiLua.Lua.lua_rawgeti(state, t, r);
} }
public static bool luaL_checkmetatable(Lua.lua_State luaState,int index) public static bool luaL_checkmetatable(KopiLua.Lua.lua_State luaState,int index)
{ {
bool retVal = false; bool retVal = false;
Console.WriteLine("v: " + luaState.tt.ToString());
if(Lua.lua_getmetatable(luaState,index)!=0) if(KopiLua.Lua.lua_getmetatable(luaState,index)!=0)
{ {
Lua.lua_pushlightuserdata(luaState, tag); KopiLua.Lua.lua_pushlightuserdata(luaState, tag);
Lua.lua_rawget(luaState, -2); KopiLua.Lua.lua_rawget(luaState, -2);
retVal = !Lua.lua_isnil(luaState, -1); retVal = !KopiLua.Lua.lua_isnil(luaState, -1);
Lua.lua_settop(luaState, -3); KopiLua.Lua.lua_settop(luaState, -3);
} }
return retVal; return retVal;
} }
...@@ -258,44 +277,43 @@ namespace LuaWrap ...@@ -258,44 +277,43 @@ namespace LuaWrap
return tag; return tag;
} }
public static void lua_getref(Lua.lua_State luaState, int reference) public static void lua_getref(KopiLua.Lua.lua_State luaState, int reference)
{ {
Lua.lua_rawgeti(luaState, (int)PseudoIndex.Registry, reference); KopiLua.Lua.lua_rawgeti(luaState, (int)PseudoIndex.Registry, reference);
} }
public static void lua_unref(Lua.lua_State luaState, int reference) public static void lua_unref(KopiLua.Lua.lua_State luaState, int reference)
{ {
Lua.luaL_unref(luaState, (int)PseudoIndex.Registry, reference); KopiLua.Lua.luaL_unref(luaState, (int)PseudoIndex.Registry, reference);
} }
public static int luanet_rawnetobj(Lua.lua_State luaState,int obj) public static int luanet_rawnetobj(KopiLua.Lua.lua_State luaState,int obj)
{ {
int udata= (int)Lua.lua_touserdata2(luaState, obj); int udata = (int)KopiLua.Lua.lua_touserdata2(luaState, obj);
if(udata!=0) return udata != 0 ? udata : -1;
return udata;
return -1;
} }
public static void lua_pushstdcallcfunction(Lua.lua_State luaState, KopiLua.Lua.lua_CFunction function) public static void lua_pushstdcallcfunction(KopiLua.Lua.lua_State luaState,KopiLua.Lua.lua_CFunction function)
{ {
lua_pushcfunction(luaState, function); lua_pushcfunction(luaState, function);
} }
public static int checkudata_raw(Lua.lua_State luaState, int ud, string tname) public static int checkudata_raw(KopiLua.Lua.lua_State luaState, int ud, string tname)
{ {
int p = (int)Lua.lua_touserdata2(luaState, ud); int p = (int)KopiLua.Lua.lua_touserdata2(luaState, ud);
//Console.WriteLine(BitConverter.ToInt32(ObjectToByteArray(KopiLua.Lua.lua_touserdata(luaState, ud)), 0));
if(p != 0) if(p != 0)
{ {
/* value is a userdata? */ /* value is a userdata? */
if(Lua.lua_getmetatable(luaState, ud)!=0) if(KopiLua.Lua.lua_getmetatable(luaState, ud)!=0)
{ {
/* does it have a metatable? */ /* does it have a metatable? */
Lua.lua_getfield(luaState, (int)PseudoIndex.Registry, tname); /* get correct metatable */ KopiLua.Lua.lua_getfield(luaState, (int)PseudoIndex.Registry, tname); /* get correct metatable */
bool isEqual = Lua.lua_rawequal(luaState, -1, -2).ToBoolean(); bool isEqual = KopiLua.Lua.lua_rawequal(luaState, -1, -2).ToBoolean();
// NASTY - we need our own version of the lua_pop macro // NASTY - we need our own version of the lua_pop macro
// lua_pop(L, 2); /* remove both metatables */ // lua_pop(L, 2); /* remove both metatables */
Lua.lua_settop(luaState, -(2) - 1); KopiLua.Lua.lua_settop(luaState, -(2) - 1);
if(isEqual) /* does it have the correct mt? */ if(isEqual) /* does it have the correct mt? */
return p; return p;
...@@ -305,33 +323,31 @@ namespace LuaWrap ...@@ -305,33 +323,31 @@ namespace LuaWrap
return 0; return 0;
} }
public static int luanet_checkudata(Lua.lua_State luaState, int ud, string tname) public static int luanet_checkudata(KopiLua.Lua.lua_State luaState, int ud, string tname)
{ {
int udata = checkudata_raw(luaState, ud, tname); int udata = checkudata_raw(luaState, ud, tname);
return udata != 0 ? udata : -1;
if(udata != 0)
return udata;
return -1;
} }
public static void luanet_newudata(Lua.lua_State luaState, int val) public static void luanet_newudata(KopiLua.Lua.lua_State luaState, int val)
{ {
Lua.lua_newuserdata(luaState, (uint)val); KopiLua.Lua.lua_newuserdata(luaState, (uint)val);
} }
public static int luanet_tonetobject(Lua.lua_State luaState, int index) public static int luanet_tonetobject(KopiLua.Lua.lua_State luaState, int index)
{ {
int udata; int udata;
Console.WriteLine("x" + KopiLua.Lua.lua_type(luaState, index).ToString());
if(Lua.lua_type(luaState, index).ToLuaTypes() == LuaTypes.UserData) if(KopiLua.Lua.lua_type(luaState, index).ToLuaTypes() == LuaTypes.UserData)
{ {
if(luaL_checkmetatable(luaState, index)) if(luaL_checkmetatable(luaState, index))
{ {
udata = (int)Lua.lua_touserdata2(luaState, index); udata = (int)KopiLua.Lua.lua_touserdata2(luaState, index);
if(udata != 0) if(udata != 0)
return udata; return udata;
} }
udata = checkudata_raw(luaState, index, "luaNet_class"); udata = checkudata_raw(luaState, index, "luaNet_class");
if(udata != 0) if(udata != 0)
return udata; return udata;
...@@ -344,17 +360,14 @@ namespace LuaWrap ...@@ -344,17 +360,14 @@ namespace LuaWrap
if(udata != 0) if(udata != 0)
return udata; return udata;
} }
return -1; return -1;
} }
public static int lua_ref(Lua.lua_State luaState, int lockRef) public static int lua_ref(KopiLua.Lua.lua_State luaState, int lockRef)
{ {
if(lockRef != 0) return lockRef != 0 ? KopiLua.Lua.luaL_ref(luaState, (int)PseudoIndex.Registry) : 0;
return Lua.luaL_ref(luaState, (int)PseudoIndex.Registry);
else
return 0;
} }
#endregion #endregion
} }
} }
\ No newline at end of file
using System; /*
* 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;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reflection; using System.Reflection;
......
using System; /*
* 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 namespace LuaInterface
{ {
......
using System; /*
using System.Collections.Generic; * 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;
using System.Text; using System.Text;
using System.Collections; using System.Collections;
using LuaWrap; using System.Collections.Generic;
namespace LuaInterface namespace LuaInterface
{ {
...@@ -14,43 +38,12 @@ namespace LuaInterface ...@@ -14,43 +38,12 @@ namespace LuaInterface
*/ */
public class LuaTable : LuaBase public class LuaTable : LuaBase
{ {
//internal int _Reference;
//private Lua _Interpreter;
public LuaTable(int reference, Lua interpreter) public LuaTable(int reference, Lua interpreter)
{ {
_Reference = reference; _Reference = reference;
_Interpreter = interpreter; _Interpreter = interpreter;
} }
//bool disposed = false;
//~LuaTable()
//{
// Dispose(false);
//}
//public void Dispose()
//{
// Dispose(true);
// GC.SuppressFinalize(this);
//}
//public virtual void Dispose(bool disposeManagedResources)
//{
// if (!this.disposed)
// {
// if (disposeManagedResources)
// {
// if (_Reference != 0)
// _Interpreter.dispose(_Reference);
// }
// disposed = true;
// }
//}
//~LuaTable()
//{
// _Interpreter.dispose(_Reference);
//}
/* /*
* Indexer for string fields of the table * Indexer for string fields of the table
*/ */
...@@ -126,18 +119,5 @@ namespace LuaInterface ...@@ -126,18 +119,5 @@ namespace LuaInterface
{ {
return "table"; return "table";
} }
//public override bool Equals(object o)
//{
// if (o is LuaTable)
// {
// LuaTable l = (LuaTable)o;
// return _Interpreter.compareRef(l._Reference, _Reference);
// }
// else return false;
//}
//public override int GetHashCode()
//{
// return _Reference;
//}
} }
} }
using System; /*
using System.Collections.Generic; * 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;
using System.Text; using System.Text;
using LuaWrap; using System.Collections.Generic;
namespace LuaInterface namespace LuaInterface
{ {
public class LuaUserData : LuaBase public class LuaUserData : LuaBase
{ {
//internal int _Reference;
//private Lua _Interpreter;
public LuaUserData(int reference, Lua interpreter) public LuaUserData(int reference, Lua interpreter)
{ {
_Reference = reference; _Reference = reference;
_Interpreter = interpreter; _Interpreter = interpreter;
} }
//~LuaUserData()
//{
// if (_Reference != 0)
// _Interpreter.dispose(_Reference);
//}
/* /*
* Indexer for string fields of the userdata * Indexer for string fields of the userdata
*/ */
...@@ -66,18 +84,5 @@ namespace LuaInterface ...@@ -66,18 +84,5 @@ namespace LuaInterface
{ {
return "userdata"; return "userdata";
} }
//public override bool Equals(object o)
//{
// if (o is LuaUserData)
// {
// LuaUserData l = (LuaUserData)o;
// return _Interpreter.compareRef(l._Reference, _Reference);
// }
// else return false;
//}
//public override int GetHashCode()
//{
// return _Reference;
//}
} }
} }
\ No newline at end of file
/*
* 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;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace LuaInterface namespace LuaInterface
{ {
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using LuaWrap;
/* /*
* Functions used in the metatables of userdata representing * Functions used in the metatables of userdata representing
* CLR objects * CLR objects
...@@ -110,7 +134,7 @@ namespace LuaInterface ...@@ -110,7 +134,7 @@ namespace LuaInterface
{ {
LuaTypes type = KopiLua.Lua.lua_type(luaState, i).ToLuaTypes(); LuaTypes type = KopiLua.Lua.lua_type(luaState, i).ToLuaTypes();
// we dump stacks when deep in calls, calling typename while the stack is in flux can fail sometimes, so manually check for key types // we dump stacks when deep in calls, calling typename while the stack is in flux can fail sometimes, so manually check for key types
string typestr = (type == LuaTypes.Table) ? "table" : KopiLua.Lua.lua_typename(luaState, Convert.ToInt32(type)).ToString(); string typestr = (type == LuaTypes.Table) ? "table" : KopiLua.Lua.lua_typename(luaState, (int)type).ToString();
string strrep = KopiLua.Lua.lua_tostring(luaState, i).ToString(); string strrep = KopiLua.Lua.lua_tostring(luaState, i).ToString();
if (type == LuaTypes.UserData) if (type == LuaTypes.UserData)
......
/*
* 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;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;
using System.Diagnostics;
namespace LuaInterface namespace LuaInterface
{ {
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;
using System.Diagnostics;
using LuaWrap;
/* /*
* Cached method * Cached method
*/ */
......
/*
* 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;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;
using System.Diagnostics;
namespace LuaInterface namespace LuaInterface
{ {
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;
using System.Diagnostics;
using LuaWrap;
/* /*
* Passes objects from the CLR to Lua and vice-versa * Passes objects from the CLR to Lua and vice-versa
* *
...@@ -206,7 +230,7 @@ namespace LuaInterface ...@@ -206,7 +230,7 @@ namespace LuaInterface
try try
{ {
assembly = Assembly.LoadWithPartialName(assemblyName); assembly = Assembly.Load(assemblyName);
} }
catch (BadImageFormatException) catch (BadImageFormatException)
{ {
...@@ -614,6 +638,7 @@ namespace LuaInterface ...@@ -614,6 +638,7 @@ namespace LuaInterface
case LuaTypes.UserData: case LuaTypes.UserData:
{ {
int udata=LuaLib.luanet_tonetobject(luaState,index); int udata=LuaLib.luanet_tonetobject(luaState,index);
Console.WriteLine(udata);
if(udata!=-1) if(udata!=-1)
return objects[udata]; return objects[udata];
else else
......
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