Commit 2271a771 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Fixed test on iOS (device)

parent bf8c5fe6
Subproject commit 31271cd6f1b77768e6f70b4848e22fbc96b17338 Subproject commit 980e734233b9273426ba853b7078fddbc1f07549
Subproject commit f6a5029fb6650fe1cb763de1adf0df2f76a2fab6 Subproject commit ed5b8b89e20a6e230e12da1059918f6609bde2eb
This diff is collapsed.
/* /*
* This file is part of LuaInterface. * This file is part of LuaInterface.
* *
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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;
namespace LuaInterface.Event namespace LuaInterface.Event
{ {
using LuaCore = KeraLua.Lua; #if USE_KOPILUA
using LuaCore = KopiLua.Lua;
/// <summary> #else
/// Event args for hook callback event using LuaCore = KeraLua.Lua;
/// </summary> #endif
/// <author>Reinhard Ostermeier</author>
public class DebugHookEventArgs : EventArgs /// <summary>
{ /// Event args for hook callback event
private readonly LuaCore.lua_Debug luaDebug; /// </summary>
/// <author>Reinhard Ostermeier</author>
public DebugHookEventArgs (LuaCore.lua_Debug luaDebug) public class DebugHookEventArgs : EventArgs
{ {
this.luaDebug = luaDebug; private readonly LuaCore.lua_Debug luaDebug;
}
public DebugHookEventArgs (LuaCore.lua_Debug luaDebug)
public LuaCore.lua_Debug LuaDebug { {
get { return luaDebug; } this.luaDebug = luaDebug;
} }
}
public LuaCore.lua_Debug LuaDebug {
get { return luaDebug; }
}
}
} }
\ No newline at end of file
/* /*
* This file is part of LuaInterface. * This file is part of LuaInterface.
* *
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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;
namespace LuaInterface.Extensions namespace LuaInterface.Extensions
{ {
/// <summary> /// <summary>
/// Some random extension stuff. /// Some random extension stuff.
/// </summary> /// </summary>
static class GeneralExtensions static class GeneralExtensions
{ {
/// <summary> /// <summary>
/// Determines whether the specified obj is null. /// Determines whether the specified obj is null.
/// </summary> /// </summary>
/// <param name="obj">The obj.</param> /// <param name="obj">The obj.</param>
/// <returns> /// <returns>
/// <c>true</c> if the specified obj is null; otherwise, <c>false</c>. /// <c>true</c> if the specified obj is null; otherwise, <c>false</c>.
/// </returns> /// </returns>
public static bool IsNull (this object obj) public static bool IsNull (this object obj)
{ {
return (obj == null); return (obj == null);
} }
public static bool IsNull (this IntPtr ptr) public static bool IsNull (this IntPtr ptr)
{ {
return (ptr == null || ptr.Equals (IntPtr.Zero)); return (ptr.Equals (IntPtr.Zero));
} }
} }
} }
\ No newline at end of file
/* /*
* This file is part of LuaInterface. * This file is part of LuaInterface.
* *
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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;
namespace LuaInterface namespace LuaInterface
{ {
using LuaCore = KeraLua.Lua; #if USE_KOPILUA
/* using LuaCore = KopiLua.Lua;
* Class used for generating delegates that get a table from the Lua #else
* stack as a an object of a specific type. using LuaCore = KeraLua.Lua;
* #endif
* Author: Fabio Mascarenhas /*
* Version: 1.0 * Class used for generating delegates that get a table from the Lua
*/ * stack as a an object of a specific type.
class ClassGenerator *
{ * Author: Fabio Mascarenhas
private ObjectTranslator translator; * Version: 1.0
private Type klass; */
class ClassGenerator
public ClassGenerator (ObjectTranslator translator, Type klass) {
{ private ObjectTranslator translator;
this.translator = translator; private Type klass;
this.klass = klass;
} public ClassGenerator (ObjectTranslator translator, Type klass)
{
public object extractGenerated (LuaCore.lua_State luaState, int stackPos) this.translator = translator;
{ this.klass = klass;
return CodeGeneration.Instance.GetClassInstance (klass, translator.getTable (luaState, stackPos)); }
}
} public object extractGenerated (LuaCore.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. * This file is part of LuaInterface.
* *
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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;
namespace LuaInterface namespace LuaInterface
{ {
using LuaCore = KeraLua.Lua; #if USE_KOPILUA
/* using LuaCore = KopiLua.Lua;
* Class used for generating delegates that get a function from the Lua #else
* stack as a delegate of a specific type. using LuaCore = KeraLua.Lua;
* #endif
* Author: Fabio Mascarenhas /*
* Version: 1.0 * Class used for generating delegates that get a function from the Lua
*/ * stack as a delegate of a specific type.
class DelegateGenerator *
{ * Author: Fabio Mascarenhas
private ObjectTranslator translator; * Version: 1.0
private Type delegateType; */
class DelegateGenerator
{
public DelegateGenerator (ObjectTranslator translator, Type delegateType) private ObjectTranslator translator;
{ private Type delegateType;
this.translator = translator;
this.delegateType = delegateType;
} public DelegateGenerator (ObjectTranslator translator, Type delegateType)
{
public object extractGenerated (LuaCore.lua_State luaState, int stackPos) this.translator = translator;
{ this.delegateType = delegateType;
return CodeGeneration.Instance.GetDelegate (delegateType, translator.getFunction (luaState, stackPos)); }
}
} public object extractGenerated (LuaCore.lua_State luaState, int stackPos)
{
return CodeGeneration.Instance.GetDelegate (delegateType, translator.getFunction (luaState, stackPos));
}
}
} }
\ No newline at end of file
This diff is collapsed.
/* /*
* This file is part of LuaInterface. * This file is part of LuaInterface.
* *
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
namespace LuaInterface namespace LuaInterface
{ {
using LuaCore = KeraLua.Lua; #if USE_KOPILUA
using LuaCore = KopiLua.Lua;
public class LuaFunction : LuaBase #else
{ using LuaCore = KeraLua.Lua;
internal LuaCore.lua_CFunction function; #endif
public LuaFunction (int reference, Lua interpreter) public class LuaFunction : LuaBase
{ {
_Reference = reference; internal LuaCore.lua_CFunction function;
this.function = null;
_Interpreter = interpreter; public LuaFunction (int reference, Lua interpreter)
} {
_Reference = reference;
public LuaFunction (LuaCore.lua_CFunction function, Lua interpreter) this.function = null;
{ _Interpreter = interpreter;
_Reference = 0; }
this.function = function;
_Interpreter = interpreter; public LuaFunction (LuaCore.lua_CFunction function, Lua interpreter)
} {
_Reference = 0;
/* this.function = function;
* Calls the function casting return values to the types _Interpreter = interpreter;
* in returnTypes }
*/
internal object[] call (object[] args, Type[] returnTypes) /*
{ * Calls the function casting return values to the types
return _Interpreter.callFunction (this, args, returnTypes); * in returnTypes
} */
internal object[] call (object[] args, Type[] returnTypes)
/* {
* Calls the function and returns its return values inside return _Interpreter.callFunction (this, args, returnTypes);
* an array }
*/
public object[] Call (params object[] args) /*
{ * Calls the function and returns its return values inside
return _Interpreter.callFunction (this, args); * an array
} */
public object[] Call (params object[] args)
/* {
* Pushes the function into the Lua stack return _Interpreter.callFunction (this, args);
*/ }
internal void push (LuaCore.lua_State luaState)
{ /*
if (_Reference != 0) * Pushes the function into the Lua stack
LuaLib.lua_getref (luaState, _Reference); */
else internal void push (LuaCore.lua_State luaState)
_Interpreter.pushCSFunction (function); {
} if (_Reference != 0)
LuaLib.lua_getref (luaState, _Reference);
public override string ToString () else
{ _Interpreter.pushCSFunction (function);
return "function"; }
}
public override string ToString ()
public override bool Equals (object o) {
{ return "function";
if (o is LuaFunction) { }
var l = (LuaFunction)o;
public override bool Equals (object o)
if (this._Reference != 0 && l._Reference != 0) {
return _Interpreter.compareRef (l._Reference, this._Reference); if (o is LuaFunction) {
else var l = (LuaFunction)o;
return this.function == l.function;
} else if (this._Reference != 0 && l._Reference != 0)
return false; return _Interpreter.compareRef (l._Reference, this._Reference);
} else
return this.function == l.function;
public override int GetHashCode () } else
{ return false;
return _Reference != 0 ? _Reference : function.GetHashCode (); }
}
} public override int GetHashCode ()
{
return _Reference != 0 ? _Reference : function.GetHashCode ();
}
}
} }
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>False</Optimize> <Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath> <OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;MONOTOUCH</DefineConstants> <DefineConstants>DEBUG;MONOTOUCH;</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause> <ConsolePause>False</ConsolePause>
<DefineConstants>MONOTOUCH</DefineConstants> <DefineConstants>MONOTOUCH;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
<Compile Include="Metatables.cs" /> <Compile Include="Metatables.cs" />
<Compile Include="ObjectTranslator.cs" /> <Compile Include="ObjectTranslator.cs" />
<Compile Include="ProxyType.cs" /> <Compile Include="ProxyType.cs" />
<Compile Include="ObjectTranslatorPool.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\KeraLua\KeraLua.iOS.csproj"> <ProjectReference Include="..\KeraLua\KeraLua.iOS.csproj">
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
<AssemblyName>LuaInterface</AssemblyName> <AssemblyName>LuaInterface</AssemblyName>
<ReleaseVersion>2.x</ReleaseVersion> <ReleaseVersion>2.x</ReleaseVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
...@@ -79,6 +78,7 @@ ...@@ -79,6 +78,7 @@
<Compile Include="LuaLib\GCOptions.cs" /> <Compile Include="LuaLib\GCOptions.cs" />
<Compile Include="LuaLib\LuaLib.cs" /> <Compile Include="LuaLib\LuaLib.cs" />
<Compile Include="Config\LuaInterfaceConfig.cs" /> <Compile Include="Config\LuaInterfaceConfig.cs" />
<Compile Include="ObjectTranslatorPool.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.
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
--> -->
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\KeraLua\KeraLua.csproj"> <ProjectReference Include="..\KeraLua\KeraLua.csproj">
<Project>{47153754-10f5-44d8-b578-f5a32b69061a}</Project> <Project>{47153754-10F5-44D8-B578-F5A32B69061A}</Project>
<Name>KeraLua</Name> <Name>KeraLua</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\KopiLua\KopiLua.csproj"> <ProjectReference Include="..\KopiLua\KopiLua.csproj">
......
This diff is collapsed.
/* /*
* This file is part of LuaInterface. * This file is part of LuaInterface.
* *
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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.Text; using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace LuaInterface namespace LuaInterface
{ {
using LuaCore = KeraLua.Lua; #if USE_KOPILUA
using LuaCore = KopiLua.Lua;
/* #else
* Wrapper class for Lua tables using LuaCore = KeraLua.Lua;
* #endif
* Author: Fabio Mascarenhas
* Version: 1.0 /*
*/ * Wrapper class for Lua tables
public class LuaTable : LuaBase *
{ * Author: Fabio Mascarenhas
public LuaTable (int reference, Lua interpreter) * Version: 1.0
{ */
_Reference = reference; public class LuaTable : LuaBase
_Interpreter = interpreter; {
} public LuaTable (int reference, Lua interpreter)
{
/* _Reference = reference;
* Indexer for string fields of the table _Interpreter = interpreter;
*/ }
public object this [string field] {
get { /*
return _Interpreter.getObject (_Reference, field); * Indexer for string fields of the table
} */
set { public object this [string field] {
_Interpreter.setObject (_Reference, field, value); get {
} return _Interpreter.getObject (_Reference, field);
} }
set {
/* _Interpreter.setObject (_Reference, field, value);
* Indexer for numeric fields of the table }
*/ }
public object this [object field] {
get { /*
return _Interpreter.getObject (_Reference, field); * Indexer for numeric fields of the table
} */
set { public object this [object field] {
_Interpreter.setObject (_Reference, field, value); get {
} return _Interpreter.getObject (_Reference, field);
} }
set {
public System.Collections.IDictionaryEnumerator GetEnumerator () _Interpreter.setObject (_Reference, field, value);
{ }
return _Interpreter.GetTableDict (this).GetEnumerator (); }
}
public System.Collections.IDictionaryEnumerator GetEnumerator ()
public ICollection Keys { {
get { return _Interpreter.GetTableDict (this).Keys; } return _Interpreter.GetTableDict (this).GetEnumerator ();
} }
public ICollection Values { public ICollection Keys {
get { return _Interpreter.GetTableDict (this).Values; } get { return _Interpreter.GetTableDict (this).Keys; }
} }
/* public ICollection Values {
* Gets an string fields of a table ignoring its metatable, get { return _Interpreter.GetTableDict (this).Values; }
* if it exists }
*/
internal object rawget (string field) /*
{ * Gets an string fields of a table ignoring its metatable,
return _Interpreter.rawGetObject (_Reference, field); * if it exists
} */
internal object rawget (string field)
internal object rawgetFunction (string field) {
{ return _Interpreter.rawGetObject (_Reference, field);
object obj = _Interpreter.rawGetObject (_Reference, field); }
if (obj is LuaCore.lua_CFunction) internal object rawgetFunction (string field)
return new LuaFunction ((LuaCore.lua_CFunction)obj, _Interpreter); {
else object obj = _Interpreter.rawGetObject (_Reference, field);
return obj;
} if (obj is LuaCore.lua_CFunction)
return new LuaFunction ((LuaCore.lua_CFunction)obj, _Interpreter);
/* else
* Pushes this table into the Lua stack return obj;
*/ }
internal void push (LuaCore.lua_State luaState)
{ /*
LuaLib.lua_getref (luaState, _Reference); * Pushes this table into the Lua stack
} */
internal void push (LuaCore.lua_State luaState)
public override string ToString () {
{ LuaLib.lua_getref (luaState, _Reference);
return "table"; }
}
} public override string ToString ()
{
return "table";
}
}
} }
\ No newline at end of file
/* /*
* This file is part of LuaInterface. * This file is part of LuaInterface.
* *
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2012 Megax <http://megax.yeahunter.hu/> * Copyright (C) 2012 Megax <http://megax.yeahunter.hu/>
* *
* 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.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
namespace LuaInterface namespace LuaInterface
{ {
using LuaCore = KeraLua.Lua; #if USE_KOPILUA
using LuaCore = KopiLua.Lua;
public class LuaUserData : LuaBase #else
{ using LuaCore = KeraLua.Lua;
public LuaUserData (int reference, Lua interpreter) #endif
{
_Reference = reference; public class LuaUserData : LuaBase
_Interpreter = interpreter; {
} public LuaUserData (int reference, Lua interpreter)
{
/* _Reference = reference;
* Indexer for string fields of the userdata _Interpreter = interpreter;
*/ }
public object this [string field] {
get { /*
return _Interpreter.getObject (_Reference, field); * Indexer for string fields of the userdata
} */
set { public object this [string field] {
_Interpreter.setObject (_Reference, field, value); get {
} return _Interpreter.getObject (_Reference, field);
} }
set {
/* _Interpreter.setObject (_Reference, field, value);
* Indexer for numeric fields of the userdata }
*/ }
public object this [object field] {
get { /*
return _Interpreter.getObject (_Reference, field); * Indexer for numeric fields of the userdata
} */
set { public object this [object field] {
_Interpreter.setObject (_Reference, field, value); get {
} return _Interpreter.getObject (_Reference, field);
} }
set {
/* _Interpreter.setObject (_Reference, field, value);
* Calls the userdata and returns its return values inside }
* an array }
*/
public object[] Call (params object[] args) /*
{ * Calls the userdata and returns its return values inside
return _Interpreter.callFunction (this, args); * an array
} */
public object[] Call (params object[] args)
/* {
* Pushes the userdata into the Lua stack return _Interpreter.callFunction (this, args);
*/ }
internal void push (LuaCore.lua_State luaState)
{ /*
LuaLib.lua_getref (luaState, _Reference); * Pushes the userdata into the Lua stack
} */
internal void push (LuaCore.lua_State luaState)
public override string ToString () {
{ LuaLib.lua_getref (luaState, _Reference);
return "userdata"; }
}
} public override string ToString ()
{
return "userdata";
}
}
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
using System;
using System.Collections.Generic;
namespace LuaInterface
{
#if USE_KOPILUA
using LuaCore = KopiLua.Lua;
#else
using LuaCore = KeraLua.Lua;
#endif
internal class ObjectTranslatorPool
{
private static volatile ObjectTranslatorPool instance = new ObjectTranslatorPool ();
private static object syncRoot = new object ();
private Dictionary<LuaCore.lua_State, ObjectTranslator> translators = new Dictionary<LuaCore.lua_State, ObjectTranslator>();
public static ObjectTranslatorPool Instance
{
get
{
return instance;
}
}
public ObjectTranslatorPool ()
{
syncRoot = new Dictionary<LuaCore.lua_State, ObjectTranslator> ();
}
public void Add (LuaCore.lua_State luaState, ObjectTranslator translator)
{
translators.Add(luaState , translator);
}
public ObjectTranslator Find (LuaCore.lua_State luaState)
{
if (!translators.ContainsKey(luaState))
return null;
return translators [luaState];
}
public void Remove (LuaCore.lua_State luaState)
{
if (!translators.ContainsKey (luaState))
return;
translators.Remove (luaState);
}
}
}
...@@ -64,7 +64,9 @@ ...@@ -64,7 +64,9 @@
<IpaPackageName /> <IpaPackageName />
<MtouchI18n /> <MtouchI18n />
<MtouchArch>ARMv7</MtouchArch> <MtouchArch>ARMv7</MtouchArch>
<MtouchLink>Full</MtouchLink> <MtouchLink>None</MtouchLink>
<MtouchUseLlvm>true</MtouchUseLlvm>
<MtouchUseThumb>true</MtouchUseThumb>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>
......
...@@ -348,6 +348,16 @@ namespace LuaInterfaceTest ...@@ -348,6 +348,16 @@ namespace LuaInterfaceTest
//lua.RegisterFunction("regularMethod", genericClass, typeof(TestClassGeneric<>).GetMethod("RegularMethod")); //lua.RegisterFunction("regularMethod", genericClass, typeof(TestClassGeneric<>).GetMethod("RegularMethod"));
using (Lua lua = new Lua ()) { using (Lua lua = new Lua ()) {
TestClassWithGenericMethod classWithGenericMethod = new TestClassWithGenericMethod (); TestClassWithGenericMethod classWithGenericMethod = new TestClassWithGenericMethod ();
////////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
/// IMPORTANT: Use generic method with the type you will call or generic methods will fail with iOS
/// ////////////////////////////////////////////////////////////////////////
classWithGenericMethod.GenericMethod<double>(99.0);
classWithGenericMethod.GenericMethod<TestClass>(new TestClass (99));
////////////////////////////////////////////////////////////////////////////
/// ////////////////////////////////////////////////////////////////////////
lua.RegisterFunction ("genericMethod2", classWithGenericMethod, typeof(TestClassWithGenericMethod).GetMethod ("GenericMethod")); lua.RegisterFunction ("genericMethod2", classWithGenericMethod, typeof(TestClassWithGenericMethod).GetMethod ("GenericMethod"));
try { try {
......
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