Commit 50da4861 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

[WinRT] Added Windows Store build (WIP).

parent 25726c61
...@@ -159,9 +159,9 @@ namespace NLua ...@@ -159,9 +159,9 @@ namespace NLua
return extractValues [extractKey]; return extractValues [extractKey];
} else if (typeof(Delegate).IsAssignableFrom (paramType) && luatype == LuaTypes.Function) } else if (typeof(Delegate).IsAssignableFrom (paramType) && luatype == LuaTypes.Function)
return new ExtractValue (new DelegateGenerator (translator, paramType).ExtractGenerated); return new ExtractValue (new DelegateGenerator (translator, paramType).ExtractGenerated);
else if (paramType.IsInterface && luatype == LuaTypes.Table) else if (paramType.IsInterface() && luatype == LuaTypes.Table)
return new ExtractValue (new ClassGenerator (translator, paramType).ExtractGenerated); return new ExtractValue (new ClassGenerator (translator, paramType).ExtractGenerated);
else if ((paramType.IsInterface || paramType.IsClass) && luatype == LuaTypes.Nil) { else if ((paramType.IsInterface() || paramType.IsClass()) && luatype == LuaTypes.Nil) {
// kevinh - allow nil to be silently converted to null - extractNetObject will return null when the item ain't found // kevinh - allow nil to be silently converted to null - extractNetObject will return null when the item ain't found
return extractNetObject; return extractNetObject;
} else if (LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) { } else if (LuaLib.LuaType (luaState, stackPos) == LuaTypes.Table) {
......
/* /*
* This file is part of NLua. * This file is part of NLua.
* *
* Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com) * Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com)
* 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;
#if !SILVERLIGHT #if !SILVERLIGHT && !NETFX_CORE
using System.Runtime.Serialization; using System.Runtime.Serialization;
#endif #endif
namespace NLua.Exceptions namespace NLua.Exceptions
{ {
/// <summary> /// <summary>
/// Exceptions thrown by the Lua runtime /// Exceptions thrown by the Lua runtime
/// </summary> /// </summary>
#if !SILVERLIGHT #if !SILVERLIGHT && !NETFX_CORE
[Serializable] [Serializable]
#endif #endif
public class LuaException : Exception public class LuaException : Exception
{ {
public LuaException () public LuaException ()
{ {
} }
public LuaException (string message) : base(message) public LuaException (string message) : base(message)
{ {
} }
public LuaException (string message, Exception innerException) : base(message, innerException) public LuaException (string message, Exception innerException) : base(message, innerException)
{ {
} }
#if !SILVERLIGHT #if !SILVERLIGHT && !NETFX_CORE
protected LuaException (SerializationInfo info, StreamingContext context) : base(info, context) protected LuaException (SerializationInfo info, StreamingContext context) : base(info, context)
{ {
} }
#endif #endif
} }
} }
\ No newline at end of file
/* /*
* This file is part of NLua. * This file is part of NLua.
* *
* Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com) * Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com)
* 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 NLua.Exceptions namespace NLua.Exceptions
{ {
/// <summary> /// <summary>
/// Exceptions thrown by the Lua runtime because of errors in the script /// Exceptions thrown by the Lua runtime because of errors in the script
/// </summary> /// </summary>
/// ///
#if !SILVERLIGHT #if !SILVERLIGHT && !NETFX_CORE
[Serializable] [Serializable]
#endif #endif
public class LuaScriptException : LuaException public class LuaScriptException : LuaException
{ {
/// <summary> /// <summary>
/// Returns true if the exception has occured as the result of a .NET exception in user code /// Returns true if the exception has occured as the result of a .NET exception in user code
/// </summary> /// </summary>
public bool IsNetException { get; private set; } public bool IsNetException { get; private set; }
private readonly string source; private readonly string source;
/// <summary> /// <summary>
/// The position in the script where the exception was triggered. /// The position in the script where the exception was triggered.
/// </summary> /// </summary>
#if SILVERLIGHT #if SILVERLIGHT
public string Source { get { return source; } } public string Source { get { return source; } }
#else #else
public override string Source { get { return source; } } public override string Source { get { return source; } }
#endif #endif
/// <summary> /// <summary>
/// Creates a new Lua-only exception. /// Creates a new Lua-only exception.
/// </summary> /// </summary>
/// <param name="message">The message that describes the error.</param> /// <param name="message">The message that describes the error.</param>
/// <param name="source">The position in the script where the exception was triggered.</param> /// <param name="source">The position in the script where the exception was triggered.</param>
public LuaScriptException (string message, string source) : base(message) public LuaScriptException (string message, string source) : base(message)
{ {
this.source = source; this.source = source;
} }
/// <summary> /// <summary>
/// Creates a new .NET wrapping exception. /// Creates a new .NET wrapping exception.
/// </summary> /// </summary>
/// <param name="innerException">The .NET exception triggered by user-code.</param> /// <param name="innerException">The .NET exception triggered by user-code.</param>
/// <param name="source">The position in the script where the exception was triggered.</param> /// <param name="source">The position in the script where the exception was triggered.</param>
public LuaScriptException (Exception innerException, string source) public LuaScriptException (Exception innerException, string source)
: base("A .NET exception occured in user-code", innerException) : base("A .NET exception occured in user-code", innerException)
{ {
this.source = source; this.source = source;
this.IsNetException = true; this.IsNetException = true;
} }
public override string ToString () public override string ToString ()
{ {
// Prepend the error source // Prepend the error source
return GetType ().FullName + ": " + source + Message; return GetType ().FullName + ": " + source + Message;
} }
} }
} }
\ No newline at end of file
...@@ -62,13 +62,18 @@ namespace NLua.Extensions ...@@ -62,13 +62,18 @@ namespace NLua.Extensions
{ {
public static bool HasMethod (this Type t, string name) public static bool HasMethod (this Type t, string name)
{ {
#if NETFX_CORE
var op = t.GetPublicMethods (name);
return op.Any ();
#else
var op = t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); var op = t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
return op.Any (m => m.Name == name); return op.Any (m => m.Name == name);
#endif
} }
public static bool HasAdditionOpertator (this Type t) public static bool HasAdditionOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_Addition"); return t.HasMethod ("op_Addition");
...@@ -76,7 +81,7 @@ namespace NLua.Extensions ...@@ -76,7 +81,7 @@ namespace NLua.Extensions
public static bool HasSubtractionOpertator (this Type t) public static bool HasSubtractionOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_Subtraction"); return t.HasMethod ("op_Subtraction");
...@@ -84,7 +89,7 @@ namespace NLua.Extensions ...@@ -84,7 +89,7 @@ namespace NLua.Extensions
public static bool HasMultiplyOpertator (this Type t) public static bool HasMultiplyOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_Multiply"); return t.HasMethod ("op_Multiply");
...@@ -92,7 +97,7 @@ namespace NLua.Extensions ...@@ -92,7 +97,7 @@ namespace NLua.Extensions
public static bool HasDivisionOpertator (this Type t) public static bool HasDivisionOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_Division"); return t.HasMethod ("op_Division");
...@@ -100,7 +105,7 @@ namespace NLua.Extensions ...@@ -100,7 +105,7 @@ namespace NLua.Extensions
public static bool HasModulusOpertator (this Type t) public static bool HasModulusOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_Modulus"); return t.HasMethod ("op_Modulus");
...@@ -108,23 +113,23 @@ namespace NLua.Extensions ...@@ -108,23 +113,23 @@ namespace NLua.Extensions
public static bool HasUnaryNegationOpertator (this Type t) public static bool HasUnaryNegationOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
// Unary - will always have only one version. // Unary - will always have only one version.
var op = t.GetMethod ("op_UnaryNegation",BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static); var op = t.GetPublicMethods ("op_UnaryNegation");
return op != null; return op != null;
} }
public static bool HasEqualityOpertator (this Type t) public static bool HasEqualityOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_Equality"); return t.HasMethod ("op_Equality");
} }
public static bool HasLessThanOpertator (this Type t) public static bool HasLessThanOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_LessThan"); return t.HasMethod ("op_LessThan");
...@@ -132,7 +137,7 @@ namespace NLua.Extensions ...@@ -132,7 +137,7 @@ namespace NLua.Extensions
public static bool HasLessThanOrEqualOpertator (this Type t) public static bool HasLessThanOrEqualOpertator (this Type t)
{ {
if (t.IsPrimitive) if (t.IsPrimitive ())
return true; return true;
return t.HasMethod ("op_LessThanOrEqual"); return t.HasMethod ("op_LessThanOrEqual");
} }
...@@ -146,18 +151,18 @@ namespace NLua.Extensions ...@@ -146,18 +151,18 @@ namespace NLua.Extensions
{ {
List<Type> types = new List<Type> (); List<Type> types = new List<Type> ();
types.AddRange (type.Assembly.GetTypes ().Where (t => t.IsPublic)); types.AddRange (type.GetAssembly().GetTypes ().Where (t => t.IsPublic ()));
if (assemblies != null) { if (assemblies != null) {
foreach (Assembly item in assemblies) { foreach (Assembly item in assemblies) {
if (item == type.Assembly) if (item == type.GetAssembly ())
continue; continue;
types.AddRange (item.GetTypes ().Where (t => t.IsPublic)); types.AddRange (item.GetTypes ().Where (t => t.IsPublic ()));
} }
} }
var query = from extensionType in types var query = from extensionType in types
where extensionType.IsSealed && !extensionType.IsGenericType && !extensionType.IsNested where extensionType.IsSealed() && !extensionType.IsGenericType() && !extensionType.IsNested
from method in extensionType.GetMethods (BindingFlags.Static | BindingFlags.Public) from method in extensionType.GetMethods (BindingFlags.Static | BindingFlags.Public)
where method.IsDefined (typeof (ExtensionAttribute), false) where method.IsDefined (typeof (ExtensionAttribute), false)
where method.GetParameters () [0].ParameterType == type where method.GetParameters () [0].ParameterType == type
...@@ -180,6 +185,249 @@ namespace NLua.Extensions ...@@ -180,6 +185,249 @@ namespace NLua.Extensions
else else
return mi.First<MethodInfo> (); return mi.First<MethodInfo> ();
} }
public static bool IsPrimitive (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsPrimitive;
#else
return t.IsPrimitive;
#endif
}
public static bool IsClass (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsClass;
#else
return t.IsClass;
#endif
}
public static bool IsEnum (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsEnum;
#else
return t.IsEnum;
#endif
}
public static bool IsPublic (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsPublic;
#else
return t.IsPublic;
#endif
}
public static bool IsSealed (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsSealed;
#else
return t.IsSealed;
#endif
}
public static bool IsGenericType (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsGenericType;
#else
return t.IsGenericType;
#endif
}
public static bool IsInterface (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().IsInterface;
#else
return t.IsInterface;
#endif
}
public static Assembly GetAssembly (this Type t)
{
#if NETFX_CORE
return t.GetTypeInfo ().Assembly;
#else
return t.Assembly;
#endif
}
public static IEnumerable<MethodInfo> GetStaticPublicMethods (this Type t, string name)
{
#if NETFX_CORE
return GetAllDeclaredMethodsRecursively (t, name).Where (m => m.IsStatic);
#else
return t.GetMethods (BindingFlags.Public | BindingFlags.Static);
#endif
}
public static IEnumerable<MethodInfo> GetStaticPublicMethods (this Type t)
{
#if NETFX_CORE
return GetAllDeclaredMethodsRecursively (t).Where (m => m.IsStatic);
#else
return t.GetMethods (BindingFlags.Public | BindingFlags.Static);
#endif
}
public static IEnumerable<MethodInfo> GetInstancePublicMethods (this Type t, string name)
{
#if NETFX_CORE
return GetAllDeclaredMethodsRecursively (t, name).Where (m => !m.IsStatic);
#else
return t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
#endif
}
public static IEnumerable<MethodInfo> GetInstancePublicMethods (this Type t)
{
#if NETFX_CORE
return GetAllDeclaredMethodsRecursively (t).Where (m => !m.IsStatic);
#else
return t.GetMethods (BindingFlags.Public | BindingFlags.Instance);
#endif
}
public static IEnumerable<MethodInfo> GetPublicMethods (this Type t)
{
#if NETFX_CORE
return GetAllDeclaredMethodsRecursively (t);
#else
return t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
#endif
}
public static IEnumerable<MethodInfo> GetPublicMethods (this Type t, string name)
{
#if NETFX_CORE
return GetAllDeclaredMethodsRecursively (t, name);
#else
return t.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static).Where ( m => m.Name == name);
#endif
}
public static MethodInfo GetPublicMethod (this Type t, string name)
{
return GetPublicMethods (t, name).First ();
}
static bool Match (IEnumerable<ParameterInfo> parameters, Type[] signature)
{
if (parameters.Count () != signature.Count ())
return false;
int i = 0;
foreach (var parameter in parameters) {
if (parameters.GetType () != signature [i])
return false;
i++;
}
return true;
}
public static MethodInfo GetPublicMethod (this Type t, string name, Type[] signature)
{
#if NETFX_CORE
var methods = t.GetPublicMethods (name);
return methods.Where (m => Match (m.GetParameters (), signature)).FirstOrDefault ();
#else
return t.GetMethod (name, BindingFlags.Public | BindingFlags.Static |
BindingFlags.Instance , null, signature, null);
#endif
}
static IEnumerable<MethodInfo> GetAllDeclaredMethodsRecursively (Type t, string name)
{
var methods = t.GetTypeInfo ().GetDeclaredMethods (name);
if (t == typeof (object))
return methods;
var baseType = t.GetTypeInfo ().BaseType;
return methods.Concat (GetAllDeclaredMethodsRecursively (baseType, name));
}
static IEnumerable<MemberInfo> GetAllDeclaredMembersRecursively (Type t)
{
var members = t.GetTypeInfo ().DeclaredMembers;
if (t == typeof (object))
return members;
var baseType = t.GetTypeInfo ().BaseType;
return members.Concat (GetAllDeclaredMembersRecursively (baseType));
}
static IEnumerable<MethodInfo> GetAllDeclaredMethodsRecursively (Type t)
{
var methods = t.GetTypeInfo ().DeclaredMethods;
if (t == typeof (object))
return methods;
var baseType = t.GetTypeInfo ().BaseType;
return methods.Concat (GetAllDeclaredMethodsRecursively (baseType));
}
static FieldInfo GetDeclaredFieldRecursively (Type t, string name)
{
var field = t.GetTypeInfo ().GetDeclaredField (name);
if (field != null || t == typeof (object))
return field;
var baseType = t.GetTypeInfo ().BaseType;
return GetDeclaredFieldRecursively (baseType, name);
}
static IEnumerable<FieldInfo> GetAllDeclaredFieldsRecursively (Type t)
{
var fields = t.GetTypeInfo ().DeclaredFields;
if (t == typeof (object))
return fields;
var baseType = t.GetTypeInfo ().BaseType;
return fields.Concat (GetAllDeclaredFieldsRecursively (baseType));
}
public static IEnumerable<FieldInfo> GetPublicFields (this Type t)
{
#if NETFX_CORE
return GetAllDeclaredFieldsRecursively (t);
#else
return t.GetFields ();
#endif
}
public static FieldInfo GetPublicField (this Type t, string name)
{
#if NETFX_CORE
return GetDeclaredFieldRecursively (t, name);
#else
return t.GetField (name);
#endif
}
#if NETFX_CORE
static IEnumerable<Type> GetTypes (this Assembly assembly)
{
return assembly.ExportedTypes;
}
public static bool IsAssignableFrom (this Type t, Type t2)
{
return t.GetTypeInfo ().IsAssignableFrom (t2.GetTypeInfo ());
}
static IEnumerable<MethodInfo> GetMethods (this Type t, BindingFlags flags)
{
return null;
}
#endif
} }
static class StringExtensions static class StringExtensions
......
/* /*
* This file is part of NLua. * This file is part of NLua.
* *
* Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com) * Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com)
* 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.Threading; using System.Linq;
using System.Reflection; using System.Threading;
using System.Reflection;
#if !MONOTOUCH
using System.Reflection.Emit; #if !MONOTOUCH
#endif using System.Reflection.Emit;
using System.Collections; #endif
using System.Collections.Generic; using System.Collections;
using NLua.Method; using System.Collections.Generic;
using NLua.Method;
namespace NLua
{ namespace NLua
/* {
* Dynamically generates new types from existing types and /*
* Lua function and table values. Generated types are event handlers, * Dynamically generates new types from existing types and
* delegates, interface implementations and subclasses. * Lua function and table values. Generated types are event handlers,
* * delegates, interface implementations and subclasses.
* Author: Fabio Mascarenhas *
* Version: 1.0 * Author: Fabio Mascarenhas
*/ * Version: 1.0
class CodeGeneration */
{ class CodeGeneration
private Dictionary<Type, LuaClassType> classCollection = new Dictionary<Type, LuaClassType> (); {
private Dictionary<Type, Type> delegateCollection = new Dictionary<Type, Type> (); private Dictionary<Type, LuaClassType> classCollection = new Dictionary<Type, LuaClassType> ();
private static readonly CodeGeneration instance = new CodeGeneration (); private Dictionary<Type, Type> delegateCollection = new Dictionary<Type, Type> ();
private AssemblyName assemblyName; private static readonly CodeGeneration instance = new CodeGeneration ();
private AssemblyName assemblyName;
#if !MONOTOUCH && !SILVERLIGHT
private Dictionary<Type, Type> eventHandlerCollection = new Dictionary<Type, Type> (); #if !MONOTOUCH && !SILVERLIGHT && !NETFX_CORE
private Type eventHandlerParent = typeof(LuaEventHandler); private Dictionary<Type, Type> eventHandlerCollection = new Dictionary<Type, Type> ();
private Type delegateParent = typeof(LuaDelegate); private Type eventHandlerParent = typeof(LuaEventHandler);
private Type classHelper = typeof(LuaClassHelper); private Type delegateParent = typeof(LuaDelegate);
private AssemblyBuilder newAssembly; private Type classHelper = typeof(LuaClassHelper);
private ModuleBuilder newModule; private AssemblyBuilder newAssembly;
private int luaClassNumber = 1; private ModuleBuilder newModule;
#endif private int luaClassNumber = 1;
#endif
static CodeGeneration ()
{ static CodeGeneration ()
} {
}
private CodeGeneration ()
{ private CodeGeneration ()
// Create an assembly name {
assemblyName = new AssemblyName (); // Create an assembly name
assemblyName.Name = "NLua_generatedcode"; assemblyName = new AssemblyName ();
// Create a new assembly with one module. assemblyName.Name = "NLua_generatedcode";
#if !MONOTOUCH && !SILVERLIGHT // Create a new assembly with one module.
newAssembly = Thread.GetDomain ().DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.Run); #if !MONOTOUCH && !SILVERLIGHT && !NETFX_CORE
newModule = newAssembly.DefineDynamicModule ("NLua_generatedcode"); newAssembly = Thread.GetDomain ().DefineDynamicAssembly (assemblyName, AssemblyBuilderAccess.Run);
#endif newModule = newAssembly.DefineDynamicModule ("NLua_generatedcode");
} #endif
}
/*
* Singleton instance of the class /*
*/ * Singleton instance of the class
public static CodeGeneration Instance { */
get { return instance; } public static CodeGeneration Instance {
} get { return instance; }
}
/*
* Generates an event handler that calls a Lua function /*
*/ * Generates an event handler that calls a Lua function
private Type GenerateEvent (Type eventHandlerType) */
{ private Type GenerateEvent (Type eventHandlerType)
#if MONOTOUCH {
throw new NotImplementedException (" Emit not available on MonoTouch "); #if MONOTOUCH
#elif SILVERLIGHT throw new NotImplementedException (" Emit not available on MonoTouch ");
throw new NotImplementedException(" Emit not available on Silverlight "); #elif SILVERLIGHT
#else throw new NotImplementedException(" Emit not available on Silverlight ");
string typeName; #elif NETFX_CORE
lock (this) { throw new NotImplementedException(" Emit not available on Windows Store ");
typeName = "LuaGeneratedClass" + luaClassNumber.ToString (); #else
luaClassNumber++; string typeName;
} lock (this) {
typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
// Define a public class in the assembly, called typeName luaClassNumber++;
var myType = newModule.DefineType (typeName, TypeAttributes.Public, eventHandlerParent); }
// Defines the handler method. Its signature is void(object, <subclassofEventArgs>) // Define a public class in the assembly, called typeName
var paramTypes = new Type[2]; var myType = newModule.DefineType (typeName, TypeAttributes.Public, eventHandlerParent);
paramTypes [0] = typeof(object);
paramTypes [1] = eventHandlerType; // Defines the handler method. Its signature is void(object, <subclassofEventArgs>)
var returnType = typeof(void); var paramTypes = new Type[2];
var handleMethod = myType.DefineMethod ("HandleEvent", MethodAttributes.Public | MethodAttributes.HideBySig, returnType, paramTypes); paramTypes [0] = typeof(object);
paramTypes [1] = eventHandlerType;
// Emits the IL for the method. It loads the arguments var returnType = typeof(void);
// and calls the handleEvent method of the base class var handleMethod = myType.DefineMethod ("HandleEvent", MethodAttributes.Public | MethodAttributes.HideBySig, returnType, paramTypes);
ILGenerator generator = handleMethod.GetILGenerator ();
generator.Emit (OpCodes.Ldarg_0); // Emits the IL for the method. It loads the arguments
generator.Emit (OpCodes.Ldarg_1); // and calls the handleEvent method of the base class
generator.Emit (OpCodes.Ldarg_2); ILGenerator generator = handleMethod.GetILGenerator ();
var miGenericEventHandler = eventHandlerParent.GetMethod ("HandleEvent"); generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Call, miGenericEventHandler); generator.Emit (OpCodes.Ldarg_1);
// returns generator.Emit (OpCodes.Ldarg_2);
generator.Emit (OpCodes.Ret); var miGenericEventHandler = eventHandlerParent.GetMethod ("HandleEvent");
// creates the new type generator.Emit (OpCodes.Call, miGenericEventHandler);
return myType.CreateType (); // returns
#endif generator.Emit (OpCodes.Ret);
} // creates the new type
return myType.CreateType ();
/* #endif
* Generates a type that can be used for instantiating a delegate }
* of the provided type, given a Lua function.
*/ /*
private Type GenerateDelegate (Type delegateType) * Generates a type that can be used for instantiating a delegate
{ * of the provided type, given a Lua function.
#if MONOTOUCH */
throw new NotImplementedException ("GenerateDelegate is not available on iOS, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) "); private Type GenerateDelegate (Type delegateType)
#elif SILVERLIGHT {
throw new NotImplementedException("GenerateDelegate is not available on Silverlight, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) "); #if MONOTOUCH
#else throw new NotImplementedException ("GenerateDelegate is not available on iOS, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) ");
string typeName; #elif SILVERLIGHT
lock (this) { throw new NotImplementedException("GenerateDelegate is not available on Silverlight, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) ");
typeName = "LuaGeneratedClass" + luaClassNumber.ToString (); #elif NETFX_CORE
luaClassNumber++; throw new NotImplementedException("GenerateDelegate is not available on Windows Store, please register your LuaDelegate type with Lua.RegisterLuaDelegateType( yourDelegate, theLuaDelegateHandler) ");
} #else
string typeName;
// Define a public class in the assembly, called typeName lock (this) {
var myType = newModule.DefineType (typeName, TypeAttributes.Public, delegateParent); typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
luaClassNumber++;
// Defines the delegate method with the same signature as the }
// Invoke method of delegateType
var invokeMethod = delegateType.GetMethod ("Invoke"); // Define a public class in the assembly, called typeName
var paramInfo = invokeMethod.GetParameters (); var myType = newModule.DefineType (typeName, TypeAttributes.Public, delegateParent);
var paramTypes = new Type[paramInfo.Length];
var returnType = invokeMethod.ReturnType; // Defines the delegate method with the same signature as the
// Invoke method of delegateType
// Counts out and ref params, for use later var invokeMethod = delegateType.GetMethod ("Invoke");
int nOutParams = 0; var paramInfo = invokeMethod.GetParameters ();
int nOutAndRefParams = 0; var paramTypes = new Type[paramInfo.Length];
var returnType = invokeMethod.ReturnType;
for (int i = 0; i < paramTypes.Length; i++) {
paramTypes [i] = paramInfo [i].ParameterType; // Counts out and ref params, for use later
int nOutParams = 0;
if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut) int nOutAndRefParams = 0;
nOutParams++;
for (int i = 0; i < paramTypes.Length; i++) {
if (paramTypes [i].IsByRef) paramTypes [i] = paramInfo [i].ParameterType;
nOutAndRefParams++;
} if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut)
nOutParams++;
int[] refArgs = new int[nOutAndRefParams];
var delegateMethod = myType.DefineMethod ("CallFunction", invokeMethod.Attributes, returnType, paramTypes); if (paramTypes [i].IsByRef)
nOutAndRefParams++;
// Generates the IL for the method }
ILGenerator generator = delegateMethod.GetILGenerator ();
generator.DeclareLocal (typeof(object[])); // original arguments int[] refArgs = new int[nOutAndRefParams];
generator.DeclareLocal (typeof(object[])); // with out-only arguments removed var delegateMethod = myType.DefineMethod ("CallFunction", invokeMethod.Attributes, returnType, paramTypes);
generator.DeclareLocal (typeof(int[])); // indexes of out and ref arguments
// Generates the IL for the method
if (!(returnType == typeof(void))) // return value ILGenerator generator = delegateMethod.GetILGenerator ();
generator.DeclareLocal (returnType); generator.DeclareLocal (typeof(object[])); // original arguments
else generator.DeclareLocal (typeof(object[])); // with out-only arguments removed
generator.DeclareLocal (typeof(object)); generator.DeclareLocal (typeof(int[])); // indexes of out and ref arguments
// Initializes local variables if (!(returnType == typeof(void))) // return value
generator.Emit (OpCodes.Ldc_I4, paramTypes.Length); generator.DeclareLocal (returnType);
generator.Emit (OpCodes.Newarr, typeof(object)); else
generator.Emit (OpCodes.Stloc_0); generator.DeclareLocal (typeof(object));
generator.Emit (OpCodes.Ldc_I4, paramTypes.Length - nOutParams);
generator.Emit (OpCodes.Newarr, typeof(object)); // Initializes local variables
generator.Emit (OpCodes.Stloc_1); generator.Emit (OpCodes.Ldc_I4, paramTypes.Length);
generator.Emit (OpCodes.Ldc_I4, nOutAndRefParams); generator.Emit (OpCodes.Newarr, typeof(object));
generator.Emit (OpCodes.Newarr, typeof(int)); generator.Emit (OpCodes.Stloc_0);
generator.Emit (OpCodes.Stloc_2); generator.Emit (OpCodes.Ldc_I4, paramTypes.Length - nOutParams);
generator.Emit (OpCodes.Newarr, typeof(object));
// Stores the arguments in the local variables generator.Emit (OpCodes.Stloc_1);
for (int iArgs = 0, iInArgs = 0, iOutArgs = 0; iArgs < paramTypes.Length; iArgs++) { generator.Emit (OpCodes.Ldc_I4, nOutAndRefParams);
generator.Emit (OpCodes.Ldloc_0); generator.Emit (OpCodes.Newarr, typeof(int));
generator.Emit (OpCodes.Ldc_I4, iArgs); generator.Emit (OpCodes.Stloc_2);
generator.Emit (OpCodes.Ldarg, iArgs + 1);
// Stores the arguments in the local variables
if (paramTypes [iArgs].IsByRef) { for (int iArgs = 0, iInArgs = 0, iOutArgs = 0; iArgs < paramTypes.Length; iArgs++) {
if (paramTypes [iArgs].GetElementType ().IsValueType) { generator.Emit (OpCodes.Ldloc_0);
generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ()); generator.Emit (OpCodes.Ldc_I4, iArgs);
generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ()); generator.Emit (OpCodes.Ldarg, iArgs + 1);
} else
generator.Emit (OpCodes.Ldind_Ref); if (paramTypes [iArgs].IsByRef) {
} else { if (paramTypes [iArgs].GetElementType ().IsValueType) {
if (paramTypes [iArgs].IsValueType) generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
generator.Emit (OpCodes.Box, paramTypes [iArgs]); generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
} } else
generator.Emit (OpCodes.Ldind_Ref);
generator.Emit (OpCodes.Stelem_Ref); } else {
if (paramTypes [iArgs].IsValueType)
if (paramTypes [iArgs].IsByRef) { generator.Emit (OpCodes.Box, paramTypes [iArgs]);
generator.Emit (OpCodes.Ldloc_2); }
generator.Emit (OpCodes.Ldc_I4, iOutArgs);
generator.Emit (OpCodes.Ldc_I4, iArgs); generator.Emit (OpCodes.Stelem_Ref);
generator.Emit (OpCodes.Stelem_I4);
refArgs [iOutArgs] = iArgs; if (paramTypes [iArgs].IsByRef) {
iOutArgs++; generator.Emit (OpCodes.Ldloc_2);
} generator.Emit (OpCodes.Ldc_I4, iOutArgs);
generator.Emit (OpCodes.Ldc_I4, iArgs);
if (paramInfo [iArgs].IsIn || (!paramInfo [iArgs].IsOut)) { generator.Emit (OpCodes.Stelem_I4);
generator.Emit (OpCodes.Ldloc_1); refArgs [iOutArgs] = iArgs;
generator.Emit (OpCodes.Ldc_I4, iInArgs); iOutArgs++;
generator.Emit (OpCodes.Ldarg, iArgs + 1); }
if (paramTypes [iArgs].IsByRef) { if (paramInfo [iArgs].IsIn || (!paramInfo [iArgs].IsOut)) {
if (paramTypes [iArgs].GetElementType ().IsValueType) { generator.Emit (OpCodes.Ldloc_1);
generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ()); generator.Emit (OpCodes.Ldc_I4, iInArgs);
generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ()); generator.Emit (OpCodes.Ldarg, iArgs + 1);
} else
generator.Emit (OpCodes.Ldind_Ref); if (paramTypes [iArgs].IsByRef) {
} else { if (paramTypes [iArgs].GetElementType ().IsValueType) {
if (paramTypes [iArgs].IsValueType) generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
generator.Emit (OpCodes.Box, paramTypes [iArgs]); generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
} } else
generator.Emit (OpCodes.Ldind_Ref);
generator.Emit (OpCodes.Stelem_Ref); } else {
iInArgs++; if (paramTypes [iArgs].IsValueType)
} generator.Emit (OpCodes.Box, paramTypes [iArgs]);
} }
// Calls the callFunction method of the base class generator.Emit (OpCodes.Stelem_Ref);
generator.Emit (OpCodes.Ldarg_0); iInArgs++;
generator.Emit (OpCodes.Ldloc_0); }
generator.Emit (OpCodes.Ldloc_1); }
generator.Emit (OpCodes.Ldloc_2);
var miGenericEventHandler = delegateParent.GetMethod ("CallFunction"); // Calls the callFunction method of the base class
generator.Emit (OpCodes.Call, miGenericEventHandler); generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Ldloc_0);
// Stores return value generator.Emit (OpCodes.Ldloc_1);
if (returnType == typeof(void)) { generator.Emit (OpCodes.Ldloc_2);
generator.Emit (OpCodes.Pop); var miGenericEventHandler = delegateParent.GetMethod ("CallFunction");
generator.Emit (OpCodes.Ldnull); generator.Emit (OpCodes.Call, miGenericEventHandler);
} else if (returnType.IsValueType) {
generator.Emit (OpCodes.Unbox, returnType); // Stores return value
generator.Emit (OpCodes.Ldobj, returnType); if (returnType == typeof(void)) {
} else generator.Emit (OpCodes.Pop);
generator.Emit (OpCodes.Castclass, returnType); generator.Emit (OpCodes.Ldnull);
} else if (returnType.IsValueType) {
generator.Emit (OpCodes.Stloc_3); generator.Emit (OpCodes.Unbox, returnType);
generator.Emit (OpCodes.Ldobj, returnType);
// Stores new value of out and ref params } else
for (int i = 0; i < refArgs.Length; i++) { generator.Emit (OpCodes.Castclass, returnType);
generator.Emit (OpCodes.Ldarg, refArgs [i] + 1);
generator.Emit (OpCodes.Ldloc_0); generator.Emit (OpCodes.Stloc_3);
generator.Emit (OpCodes.Ldc_I4, refArgs [i]);
generator.Emit (OpCodes.Ldelem_Ref); // Stores new value of out and ref params
for (int i = 0; i < refArgs.Length; i++) {
if (paramTypes [refArgs [i]].GetElementType ().IsValueType) { generator.Emit (OpCodes.Ldarg, refArgs [i] + 1);
generator.Emit (OpCodes.Unbox, paramTypes [refArgs [i]].GetElementType ()); generator.Emit (OpCodes.Ldloc_0);
generator.Emit (OpCodes.Ldobj, paramTypes [refArgs [i]].GetElementType ()); generator.Emit (OpCodes.Ldc_I4, refArgs [i]);
generator.Emit (OpCodes.Stobj, paramTypes [refArgs [i]].GetElementType ()); generator.Emit (OpCodes.Ldelem_Ref);
} else {
generator.Emit (OpCodes.Castclass, paramTypes [refArgs [i]].GetElementType ()); if (paramTypes [refArgs [i]].GetElementType ().IsValueType) {
generator.Emit (OpCodes.Stind_Ref); generator.Emit (OpCodes.Unbox, paramTypes [refArgs [i]].GetElementType ());
} generator.Emit (OpCodes.Ldobj, paramTypes [refArgs [i]].GetElementType ());
} generator.Emit (OpCodes.Stobj, paramTypes [refArgs [i]].GetElementType ());
} else {
// Returns generator.Emit (OpCodes.Castclass, paramTypes [refArgs [i]].GetElementType ());
if (!(returnType == typeof(void))) generator.Emit (OpCodes.Stind_Ref);
generator.Emit (OpCodes.Ldloc_3); }
}
generator.Emit (OpCodes.Ret);
return myType.CreateType (); // creates the new type // Returns
#endif if (!(returnType == typeof(void)))
} generator.Emit (OpCodes.Ldloc_3);
void GetReturnTypesFromClass (Type klass, out Type[][] returnTypes) generator.Emit (OpCodes.Ret);
{ return myType.CreateType (); // creates the new type
var classMethods = klass.GetMethods (); #endif
returnTypes = new Type[classMethods.Length][]; }
int i = 0; void GetReturnTypesFromClass (Type klass, out Type[][] returnTypes)
{
foreach (var method in classMethods) { var classMethods = klass.GetMethods ();
if (klass.IsInterface) { returnTypes = new Type[classMethods.Length][];
GetReturnTypesFromMethod (method, out returnTypes [i]);
i++; int i = 0;
} else {
if (!method.IsPrivate && !method.IsFinal && method.IsVirtual) { foreach (var method in classMethods) {
GetReturnTypesFromMethod (method, out returnTypes [i]); if (klass.IsInterface) {
i++; GetReturnTypesFromMethod (method, out returnTypes [i]);
} i++;
} } else {
} if (!method.IsPrivate && !method.IsFinal && method.IsVirtual) {
} GetReturnTypesFromMethod (method, out returnTypes [i]);
i++;
/* }
* Generates an implementation of klass, if it is an interface, or }
* a subclass of klass that delegates its virtual methods to a Lua table. }
*/ }
public void GenerateClass (Type klass, out Type newType, out Type[][] returnTypes)
{ /*
#if MONOTOUCH * Generates an implementation of klass, if it is an interface, or
throw new NotImplementedException (" Emit not available on MonoTouch "); * a subclass of klass that delegates its virtual methods to a Lua table.
#elif SILVERLIGHT */
throw new NotImplementedException (" Emit not available on Silverlight "); public void GenerateClass (Type klass, out Type newType, out Type[][] returnTypes)
#else {
string typeName; #if MONOTOUCH
lock (this) { throw new NotImplementedException (" Emit not available on MonoTouch ");
typeName = "LuaGeneratedClass" + luaClassNumber.ToString (); #elif SILVERLIGHT
luaClassNumber++; throw new NotImplementedException (" Emit not available on Silverlight ");
} #elif NETFX_CORE
throw new NotImplementedException (" Emit not available on Windows Store ");
TypeBuilder myType; #else
// Define a public class in the assembly, called typeName string typeName;
if (klass.IsInterface) lock (this) {
myType = newModule.DefineType (typeName, TypeAttributes.Public, typeof(object), new Type[] { typeName = "LuaGeneratedClass" + luaClassNumber.ToString ();
klass, luaClassNumber++;
typeof(ILuaGeneratedType) }
});
else TypeBuilder myType;
myType = newModule.DefineType (typeName, TypeAttributes.Public, klass, new Type[] { typeof(ILuaGeneratedType) }); // Define a public class in the assembly, called typeName
if (klass.IsInterface)
// Field that stores the Lua table myType = newModule.DefineType (typeName, TypeAttributes.Public, typeof(object), new Type[] {
var luaTableField = myType.DefineField ("__luaInterface_luaTable", typeof(LuaTable), FieldAttributes.Public); klass,
// Field that stores the return types array typeof(ILuaGeneratedType)
var returnTypesField = myType.DefineField ("__luaInterface_returnTypes", typeof(Type[][]), FieldAttributes.Public); });
// Generates the constructor for the new type, it takes a Lua table and an array else
// of return types and stores them in the respective fields myType = newModule.DefineType (typeName, TypeAttributes.Public, klass, new Type[] { typeof(ILuaGeneratedType) });
var constructor = myType.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type[] {
typeof(LuaTable), // Field that stores the Lua table
typeof(Type[][]) var luaTableField = myType.DefineField ("__luaInterface_luaTable", typeof(LuaTable), FieldAttributes.Public);
}); // Field that stores the return types array
ILGenerator generator = constructor.GetILGenerator (); var returnTypesField = myType.DefineField ("__luaInterface_returnTypes", typeof(Type[][]), FieldAttributes.Public);
generator.Emit (OpCodes.Ldarg_0); // Generates the constructor for the new type, it takes a Lua table and an array
// of return types and stores them in the respective fields
if (klass.IsInterface) var constructor = myType.DefineConstructor (MethodAttributes.Public, CallingConventions.Standard, new Type[] {
generator.Emit (OpCodes.Call, typeof(object).GetConstructor (Type.EmptyTypes)); typeof(LuaTable),
else typeof(Type[][])
generator.Emit (OpCodes.Call, klass.GetConstructor (Type.EmptyTypes)); });
ILGenerator generator = constructor.GetILGenerator ();
generator.Emit (OpCodes.Ldarg_0); generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Ldarg_1);
generator.Emit (OpCodes.Stfld, luaTableField); if (klass.IsInterface)
generator.Emit (OpCodes.Ldarg_0); generator.Emit (OpCodes.Call, typeof(object).GetConstructor (Type.EmptyTypes));
generator.Emit (OpCodes.Ldarg_2); else
generator.Emit (OpCodes.Stfld, returnTypesField); generator.Emit (OpCodes.Call, klass.GetConstructor (Type.EmptyTypes));
generator.Emit (OpCodes.Ret);
// Generates overriden versions of the klass' public virtual methods generator.Emit (OpCodes.Ldarg_0);
var classMethods = klass.GetMethods (); generator.Emit (OpCodes.Ldarg_1);
returnTypes = new Type[classMethods.Length][]; generator.Emit (OpCodes.Stfld, luaTableField);
int i = 0; generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Ldarg_2);
foreach (var method in classMethods) { generator.Emit (OpCodes.Stfld, returnTypesField);
if (klass.IsInterface) { generator.Emit (OpCodes.Ret);
GenerateMethod (myType, method, MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot, // Generates overriden versions of the klass' public virtual methods
i, luaTableField, returnTypesField, false, out returnTypes [i]); var classMethods = klass.GetMethods ();
i++; returnTypes = new Type[classMethods.Length][];
} else { int i = 0;
if (!method.IsPrivate && !method.IsFinal && method.IsVirtual) {
GenerateMethod (myType, method, (method.Attributes | MethodAttributes.NewSlot) ^ MethodAttributes.NewSlot, i, foreach (var method in classMethods) {
luaTableField, returnTypesField, true, out returnTypes [i]); if (klass.IsInterface) {
i++; GenerateMethod (myType, method, MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot,
} i, luaTableField, returnTypesField, false, out returnTypes [i]);
} i++;
} } else {
if (!method.IsPrivate && !method.IsFinal && method.IsVirtual) {
// Generates an implementation of the luaInterfaceGetLuaTable method GenerateMethod (myType, method, (method.Attributes | MethodAttributes.NewSlot) ^ MethodAttributes.NewSlot, i,
var returnTableMethod = myType.DefineMethod ("LuaInterfaceGetLuaTable", luaTableField, returnTypesField, true, out returnTypes [i]);
MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual, typeof(LuaTable), new Type[0]); i++;
myType.DefineMethodOverride (returnTableMethod, typeof(ILuaGeneratedType).GetMethod ("LuaInterfaceGetLuaTable")); }
generator = returnTableMethod.GetILGenerator (); }
generator.Emit (OpCodes.Ldfld, luaTableField); }
generator.Emit (OpCodes.Ret);
newType = myType.CreateType (); // Creates the type // Generates an implementation of the luaInterfaceGetLuaTable method
#endif var returnTableMethod = myType.DefineMethod ("LuaInterfaceGetLuaTable",
} MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual, typeof(LuaTable), new Type[0]);
myType.DefineMethodOverride (returnTableMethod, typeof(ILuaGeneratedType).GetMethod ("LuaInterfaceGetLuaTable"));
void GetReturnTypesFromMethod (MethodInfo method, out Type[] returnTypes) generator = returnTableMethod.GetILGenerator ();
{ generator.Emit (OpCodes.Ldfld, luaTableField);
var paramInfo = method.GetParameters (); generator.Emit (OpCodes.Ret);
var paramTypes = new Type[paramInfo.Length]; newType = myType.CreateType (); // Creates the type
var returnTypesList = new List<Type> (); #endif
}
// Counts out and ref parameters, for later use,
// and creates the list of return types void GetReturnTypesFromMethod (MethodInfo method, out Type[] returnTypes)
int nOutParams = 0; {
int nOutAndRefParams = 0; var paramInfo = method.GetParameters ();
var returnType = method.ReturnType; var paramTypes = new Type[paramInfo.Length];
returnTypesList.Add (returnType); var returnTypesList = new List<Type> ();
for (int i = 0; i < paramTypes.Length; i++) { // Counts out and ref parameters, for later use,
paramTypes [i] = paramInfo [i].ParameterType; // and creates the list of return types
#if SILVERLIGHT int nOutParams = 0;
if (paramInfo[i].IsOut) { int nOutAndRefParams = 0;
#else var returnType = method.ReturnType;
if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut) { returnTypesList.Add (returnType);
#endif
nOutParams++; for (int i = 0; i < paramTypes.Length; i++) {
} paramTypes [i] = paramInfo [i].ParameterType;
#if SILVERLIGHT
if (paramTypes [i].IsByRef) { if (paramInfo[i].IsOut) {
returnTypesList.Add (paramTypes [i].GetElementType ()); #else
nOutAndRefParams++; if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut) {
} #endif
} nOutParams++;
}
returnTypes = returnTypesList.ToArray ();
} if (paramTypes [i].IsByRef) {
returnTypesList.Add (paramTypes [i].GetElementType ());
#if !MONOTOUCH && !SILVERLIGHT nOutAndRefParams++;
}
/* }
* Generates an overriden implementation of method inside myType that delegates
* to a function in a Lua table with the same name, if the function exists. If it returnTypes = returnTypesList.ToArray ();
* doesn't the method calls the base method (or does nothing, in case of interface }
* implementations).
*/ #if !MONOTOUCH && !SILVERLIGHT && !NETFX_CORE
private void GenerateMethod (TypeBuilder myType, MethodInfo method, MethodAttributes attributes, int methodIndex,
FieldInfo luaTableField, FieldInfo returnTypesField, bool generateBase, out Type[] returnTypes) /*
{ * Generates an overriden implementation of method inside myType that delegates
var paramInfo = method.GetParameters (); * to a function in a Lua table with the same name, if the function exists. If it
var paramTypes = new Type[paramInfo.Length]; * doesn't the method calls the base method (or does nothing, in case of interface
var returnTypesList = new List<Type> (); * implementations).
*/
// Counts out and ref parameters, for later use, private void GenerateMethod (TypeBuilder myType, MethodInfo method, MethodAttributes attributes, int methodIndex,
// and creates the list of return types FieldInfo luaTableField, FieldInfo returnTypesField, bool generateBase, out Type[] returnTypes)
int nOutParams = 0; {
int nOutAndRefParams = 0; var paramInfo = method.GetParameters ();
var returnType = method.ReturnType; var paramTypes = new Type[paramInfo.Length];
returnTypesList.Add (returnType); var returnTypesList = new List<Type> ();
for (int i = 0; i < paramTypes.Length; i++) { // Counts out and ref parameters, for later use,
paramTypes [i] = paramInfo [i].ParameterType; // and creates the list of return types
if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut) int nOutParams = 0;
nOutParams++; int nOutAndRefParams = 0;
var returnType = method.ReturnType;
if (paramTypes [i].IsByRef) { returnTypesList.Add (returnType);
returnTypesList.Add (paramTypes [i].GetElementType ());
nOutAndRefParams++; for (int i = 0; i < paramTypes.Length; i++) {
} paramTypes [i] = paramInfo [i].ParameterType;
} if ((!paramInfo [i].IsIn) && paramInfo [i].IsOut)
nOutParams++;
int[] refArgs = new int[nOutAndRefParams];
returnTypes = returnTypesList.ToArray (); if (paramTypes [i].IsByRef) {
returnTypesList.Add (paramTypes [i].GetElementType ());
// Generates a version of the method that calls the base implementation nOutAndRefParams++;
// directly, for use by the base field of the table }
if (generateBase) { }
var baseMethod = myType.DefineMethod ("__luaInterface_base_" + method.Name,
MethodAttributes.Private | MethodAttributes.NewSlot | MethodAttributes.HideBySig, int[] refArgs = new int[nOutAndRefParams];
returnType, paramTypes); returnTypes = returnTypesList.ToArray ();
ILGenerator generatorBase = baseMethod.GetILGenerator ();
generatorBase.Emit (OpCodes.Ldarg_0); // Generates a version of the method that calls the base implementation
// directly, for use by the base field of the table
for (int i = 0; i < paramTypes.Length; i++) if (generateBase) {
generatorBase.Emit (OpCodes.Ldarg, i + 1); var baseMethod = myType.DefineMethod ("__luaInterface_base_" + method.Name,
MethodAttributes.Private | MethodAttributes.NewSlot | MethodAttributes.HideBySig,
generatorBase.Emit (OpCodes.Call, method); returnType, paramTypes);
ILGenerator generatorBase = baseMethod.GetILGenerator ();
if (returnType == typeof(void)) generatorBase.Emit (OpCodes.Ldarg_0);
generatorBase.Emit (OpCodes.Pop);
for (int i = 0; i < paramTypes.Length; i++)
generatorBase.Emit (OpCodes.Ret); generatorBase.Emit (OpCodes.Ldarg, i + 1);
}
generatorBase.Emit (OpCodes.Call, method);
// Defines the method
var methodImpl = myType.DefineMethod (method.Name, attributes, returnType, paramTypes); if (returnType == typeof(void))
generatorBase.Emit (OpCodes.Pop);
// If it's an implementation of an interface tells what method it
// is overriding generatorBase.Emit (OpCodes.Ret);
if (myType.BaseType.Equals (typeof(object))) }
myType.DefineMethodOverride (methodImpl, method);
// Defines the method
ILGenerator generator = methodImpl.GetILGenerator (); var methodImpl = myType.DefineMethod (method.Name, attributes, returnType, paramTypes);
generator.DeclareLocal (typeof(object[])); // original arguments
generator.DeclareLocal (typeof(object[])); // with out-only arguments removed // If it's an implementation of an interface tells what method it
generator.DeclareLocal (typeof(int[])); // indexes of out and ref arguments // is overriding
if (myType.BaseType.Equals (typeof(object)))
if (!(returnType == typeof(void))) // return value myType.DefineMethodOverride (methodImpl, method);
generator.DeclareLocal (returnType);
else ILGenerator generator = methodImpl.GetILGenerator ();
generator.DeclareLocal (typeof(object)); generator.DeclareLocal (typeof(object[])); // original arguments
generator.DeclareLocal (typeof(object[])); // with out-only arguments removed
// Initializes local variables generator.DeclareLocal (typeof(int[])); // indexes of out and ref arguments
generator.Emit (OpCodes.Ldc_I4, paramTypes.Length);
generator.Emit (OpCodes.Newarr, typeof(object)); if (!(returnType == typeof(void))) // return value
generator.Emit (OpCodes.Stloc_0); generator.DeclareLocal (returnType);
generator.Emit (OpCodes.Ldc_I4, paramTypes.Length - nOutParams + 1); else
generator.Emit (OpCodes.Newarr, typeof(object)); generator.DeclareLocal (typeof(object));
generator.Emit (OpCodes.Stloc_1);
generator.Emit (OpCodes.Ldc_I4, nOutAndRefParams); // Initializes local variables
generator.Emit (OpCodes.Newarr, typeof(int)); generator.Emit (OpCodes.Ldc_I4, paramTypes.Length);
generator.Emit (OpCodes.Stloc_2); generator.Emit (OpCodes.Newarr, typeof(object));
generator.Emit (OpCodes.Ldloc_1); generator.Emit (OpCodes.Stloc_0);
generator.Emit (OpCodes.Ldc_I4_0); generator.Emit (OpCodes.Ldc_I4, paramTypes.Length - nOutParams + 1);
generator.Emit (OpCodes.Ldarg_0); generator.Emit (OpCodes.Newarr, typeof(object));
generator.Emit (OpCodes.Ldfld, luaTableField); generator.Emit (OpCodes.Stloc_1);
generator.Emit (OpCodes.Stelem_Ref); generator.Emit (OpCodes.Ldc_I4, nOutAndRefParams);
generator.Emit (OpCodes.Newarr, typeof(int));
// Stores the arguments into the local variables, as needed generator.Emit (OpCodes.Stloc_2);
for (int iArgs = 0, iInArgs = 1, iOutArgs = 0; iArgs < paramTypes.Length; iArgs++) { generator.Emit (OpCodes.Ldloc_1);
generator.Emit (OpCodes.Ldloc_0); generator.Emit (OpCodes.Ldc_I4_0);
generator.Emit (OpCodes.Ldc_I4, iArgs); generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Ldarg, iArgs + 1); generator.Emit (OpCodes.Ldfld, luaTableField);
generator.Emit (OpCodes.Stelem_Ref);
if (paramTypes [iArgs].IsByRef) {
if (paramTypes [iArgs].GetElementType ().IsValueType) { // Stores the arguments into the local variables, as needed
generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ()); for (int iArgs = 0, iInArgs = 1, iOutArgs = 0; iArgs < paramTypes.Length; iArgs++) {
generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ()); generator.Emit (OpCodes.Ldloc_0);
} else generator.Emit (OpCodes.Ldc_I4, iArgs);
generator.Emit (OpCodes.Ldind_Ref); generator.Emit (OpCodes.Ldarg, iArgs + 1);
} else {
if (paramTypes [iArgs].IsValueType) if (paramTypes [iArgs].IsByRef) {
generator.Emit (OpCodes.Box, paramTypes [iArgs]); if (paramTypes [iArgs].GetElementType ().IsValueType) {
} generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
generator.Emit (OpCodes.Stelem_Ref); } else
generator.Emit (OpCodes.Ldind_Ref);
if (paramTypes [iArgs].IsByRef) { } else {
generator.Emit (OpCodes.Ldloc_2); if (paramTypes [iArgs].IsValueType)
generator.Emit (OpCodes.Ldc_I4, iOutArgs); generator.Emit (OpCodes.Box, paramTypes [iArgs]);
generator.Emit (OpCodes.Ldc_I4, iArgs); }
generator.Emit (OpCodes.Stelem_I4);
refArgs [iOutArgs] = iArgs; generator.Emit (OpCodes.Stelem_Ref);
iOutArgs++;
} if (paramTypes [iArgs].IsByRef) {
generator.Emit (OpCodes.Ldloc_2);
if (paramInfo [iArgs].IsIn || (!paramInfo [iArgs].IsOut)) { generator.Emit (OpCodes.Ldc_I4, iOutArgs);
generator.Emit (OpCodes.Ldloc_1); generator.Emit (OpCodes.Ldc_I4, iArgs);
generator.Emit (OpCodes.Ldc_I4, iInArgs); generator.Emit (OpCodes.Stelem_I4);
generator.Emit (OpCodes.Ldarg, iArgs + 1); refArgs [iOutArgs] = iArgs;
iOutArgs++;
if (paramTypes [iArgs].IsByRef) { }
if (paramTypes [iArgs].GetElementType ().IsValueType) {
generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ()); if (paramInfo [iArgs].IsIn || (!paramInfo [iArgs].IsOut)) {
generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ()); generator.Emit (OpCodes.Ldloc_1);
} else generator.Emit (OpCodes.Ldc_I4, iInArgs);
generator.Emit (OpCodes.Ldind_Ref); generator.Emit (OpCodes.Ldarg, iArgs + 1);
} else {
if (paramTypes [iArgs].IsValueType) if (paramTypes [iArgs].IsByRef) {
generator.Emit (OpCodes.Box, paramTypes [iArgs]); if (paramTypes [iArgs].GetElementType ().IsValueType) {
} generator.Emit (OpCodes.Ldobj, paramTypes [iArgs].GetElementType ());
generator.Emit (OpCodes.Box, paramTypes [iArgs].GetElementType ());
generator.Emit (OpCodes.Stelem_Ref); } else
iInArgs++; generator.Emit (OpCodes.Ldind_Ref);
} } else {
} if (paramTypes [iArgs].IsValueType)
generator.Emit (OpCodes.Box, paramTypes [iArgs]);
// Gets the function the method will delegate to by calling }
// the getTableFunction method of class LuaClassHelper
generator.Emit (OpCodes.Ldarg_0); generator.Emit (OpCodes.Stelem_Ref);
generator.Emit (OpCodes.Ldfld, luaTableField); iInArgs++;
generator.Emit (OpCodes.Ldstr, method.Name); }
generator.Emit (OpCodes.Call, classHelper.GetMethod ("GetTableFunction")); }
var lab1 = generator.DefineLabel ();
generator.Emit (OpCodes.Dup); // Gets the function the method will delegate to by calling
generator.Emit (OpCodes.Brtrue_S, lab1); // the getTableFunction method of class LuaClassHelper
// Function does not exist, call base method generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Pop); generator.Emit (OpCodes.Ldfld, luaTableField);
generator.Emit (OpCodes.Ldstr, method.Name);
if (!method.IsAbstract) { generator.Emit (OpCodes.Call, classHelper.GetMethod ("GetTableFunction"));
generator.Emit (OpCodes.Ldarg_0); var lab1 = generator.DefineLabel ();
generator.Emit (OpCodes.Dup);
for (int i = 0; i < paramTypes.Length; i++) generator.Emit (OpCodes.Brtrue_S, lab1);
generator.Emit (OpCodes.Ldarg, i + 1); // Function does not exist, call base method
generator.Emit (OpCodes.Pop);
generator.Emit (OpCodes.Call, method);
if (!method.IsAbstract) {
if (returnType == typeof(void)) generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Pop);
for (int i = 0; i < paramTypes.Length; i++)
generator.Emit (OpCodes.Ret); generator.Emit (OpCodes.Ldarg, i + 1);
generator.Emit (OpCodes.Ldnull);
} else generator.Emit (OpCodes.Call, method);
generator.Emit (OpCodes.Ldnull);
if (returnType == typeof(void))
var lab2 = generator.DefineLabel (); generator.Emit (OpCodes.Pop);
generator.Emit (OpCodes.Br_S, lab2);
generator.MarkLabel (lab1); generator.Emit (OpCodes.Ret);
// Function exists, call using method callFunction of LuaClassHelper generator.Emit (OpCodes.Ldnull);
generator.Emit (OpCodes.Ldloc_0); } else
generator.Emit (OpCodes.Ldarg_0); generator.Emit (OpCodes.Ldnull);
generator.Emit (OpCodes.Ldfld, returnTypesField);
generator.Emit (OpCodes.Ldc_I4, methodIndex); var lab2 = generator.DefineLabel ();
generator.Emit (OpCodes.Ldelem_Ref); generator.Emit (OpCodes.Br_S, lab2);
generator.Emit (OpCodes.Ldloc_1); generator.MarkLabel (lab1);
generator.Emit (OpCodes.Ldloc_2); // Function exists, call using method callFunction of LuaClassHelper
generator.Emit (OpCodes.Call, classHelper.GetMethod ("CallFunction")); generator.Emit (OpCodes.Ldloc_0);
generator.MarkLabel (lab2); generator.Emit (OpCodes.Ldarg_0);
generator.Emit (OpCodes.Ldfld, returnTypesField);
// Stores the function return value generator.Emit (OpCodes.Ldc_I4, methodIndex);
if (returnType == typeof(void)) { generator.Emit (OpCodes.Ldelem_Ref);
generator.Emit (OpCodes.Pop); generator.Emit (OpCodes.Ldloc_1);
generator.Emit (OpCodes.Ldnull); generator.Emit (OpCodes.Ldloc_2);
} else if (returnType.IsValueType) { generator.Emit (OpCodes.Call, classHelper.GetMethod ("CallFunction"));
generator.Emit (OpCodes.Unbox, returnType); generator.MarkLabel (lab2);
generator.Emit (OpCodes.Ldobj, returnType);
} else // Stores the function return value
generator.Emit (OpCodes.Castclass, returnType); if (returnType == typeof(void)) {
generator.Emit (OpCodes.Pop);
generator.Emit (OpCodes.Stloc_3); generator.Emit (OpCodes.Ldnull);
} else if (returnType.IsValueType) {
// Sets return values of out and ref parameters generator.Emit (OpCodes.Unbox, returnType);
for (int i = 0; i < refArgs.Length; i++) { generator.Emit (OpCodes.Ldobj, returnType);
generator.Emit (OpCodes.Ldarg, refArgs [i] + 1); } else
generator.Emit (OpCodes.Ldloc_0); generator.Emit (OpCodes.Castclass, returnType);
generator.Emit (OpCodes.Ldc_I4, refArgs [i]);
generator.Emit (OpCodes.Ldelem_Ref); generator.Emit (OpCodes.Stloc_3);
if (paramTypes [refArgs [i]].GetElementType ().IsValueType) { // Sets return values of out and ref parameters
generator.Emit (OpCodes.Unbox, paramTypes [refArgs [i]].GetElementType ()); for (int i = 0; i < refArgs.Length; i++) {
generator.Emit (OpCodes.Ldobj, paramTypes [refArgs [i]].GetElementType ()); generator.Emit (OpCodes.Ldarg, refArgs [i] + 1);
generator.Emit (OpCodes.Stobj, paramTypes [refArgs [i]].GetElementType ()); generator.Emit (OpCodes.Ldloc_0);
} else { generator.Emit (OpCodes.Ldc_I4, refArgs [i]);
generator.Emit (OpCodes.Castclass, paramTypes [refArgs [i]].GetElementType ()); generator.Emit (OpCodes.Ldelem_Ref);
generator.Emit (OpCodes.Stind_Ref);
} if (paramTypes [refArgs [i]].GetElementType ().IsValueType) {
} generator.Emit (OpCodes.Unbox, paramTypes [refArgs [i]].GetElementType ());
generator.Emit (OpCodes.Ldobj, paramTypes [refArgs [i]].GetElementType ());
// Returns generator.Emit (OpCodes.Stobj, paramTypes [refArgs [i]].GetElementType ());
if (!(returnType == typeof(void))) } else {
generator.Emit (OpCodes.Ldloc_3); generator.Emit (OpCodes.Castclass, paramTypes [refArgs [i]].GetElementType ());
generator.Emit (OpCodes.Stind_Ref);
generator.Emit (OpCodes.Ret); }
} }
#endif
/* // Returns
* Gets an event handler for the event type that delegates to the eventHandler Lua function. if (!(returnType == typeof(void)))
* Caches the generated type. generator.Emit (OpCodes.Ldloc_3);
*/
public LuaEventHandler GetEvent (Type eventHandlerType, LuaFunction eventHandler) generator.Emit (OpCodes.Ret);
{ }
#if MONOTOUCH #endif
throw new NotImplementedException (" Emit not available on MonoTouch "); /*
#elif SILVERLIGHT * Gets an event handler for the event type that delegates to the eventHandler Lua function.
throw new NotImplementedException (" Emit not available on Silverlight "); * Caches the generated type.
#else */
Type eventConsumerType; public LuaEventHandler GetEvent (Type eventHandlerType, LuaFunction eventHandler)
{
if (eventHandlerCollection.ContainsKey (eventHandlerType)) #if MONOTOUCH
eventConsumerType = eventHandlerCollection [eventHandlerType]; throw new NotImplementedException (" Emit not available on MonoTouch ");
else { #elif SILVERLIGHT
eventConsumerType = GenerateEvent (eventHandlerType); throw new NotImplementedException (" Emit not available on Silverlight ");
eventHandlerCollection [eventHandlerType] = eventConsumerType; #elif NETFX_CORE
} throw new NotImplementedException (" Emit not available on Windows Store ");
#else
var luaEventHandler = (LuaEventHandler)Activator.CreateInstance (eventConsumerType); Type eventConsumerType;
luaEventHandler.handler = eventHandler;
return luaEventHandler; if (eventHandlerCollection.ContainsKey (eventHandlerType))
#endif eventConsumerType = eventHandlerCollection [eventHandlerType];
} else {
eventConsumerType = GenerateEvent (eventHandlerType);
public void RegisterLuaDelegateType (Type delegateType, Type luaDelegateType) eventHandlerCollection [eventHandlerType] = eventConsumerType;
{ }
delegateCollection [delegateType] = luaDelegateType;
} var luaEventHandler = (LuaEventHandler)Activator.CreateInstance (eventConsumerType);
luaEventHandler.handler = eventHandler;
public void RegisterLuaClassType (Type klass, Type luaClass) return luaEventHandler;
{ #endif
LuaClassType luaClassType = new LuaClassType (); }
luaClassType.klass = luaClass;
GetReturnTypesFromClass (klass, out luaClassType.returnTypes); public void RegisterLuaDelegateType (Type delegateType, Type luaDelegateType)
classCollection [klass] = luaClassType; {
} delegateCollection [delegateType] = luaDelegateType;
/* }
* Gets a delegate with delegateType that calls the luaFunc Lua function
* Caches the generated type. public void RegisterLuaClassType (Type klass, Type luaClass)
*/ {
public Delegate GetDelegate (Type delegateType, LuaFunction luaFunc) LuaClassType luaClassType = new LuaClassType ();
{ luaClassType.klass = luaClass;
var returnTypes = new List<Type> (); GetReturnTypesFromClass (klass, out luaClassType.returnTypes);
Type luaDelegateType; classCollection [klass] = luaClassType;
}
if (delegateCollection.ContainsKey (delegateType)) /*
luaDelegateType = delegateCollection [delegateType]; * Gets a delegate with delegateType that calls the luaFunc Lua function
else { * Caches the generated type.
luaDelegateType = GenerateDelegate (delegateType); */
delegateCollection [delegateType] = luaDelegateType; public Delegate GetDelegate (Type delegateType, LuaFunction luaFunc)
} {
var returnTypes = new List<Type> ();
var methodInfo = delegateType.GetMethod ("Invoke"); Type luaDelegateType;
returnTypes.Add (methodInfo.ReturnType);
if (delegateCollection.ContainsKey (delegateType))
foreach (ParameterInfo paramInfo in methodInfo.GetParameters()) { luaDelegateType = delegateCollection [delegateType];
if (paramInfo.ParameterType.IsByRef) else {
returnTypes.Add (paramInfo.ParameterType); luaDelegateType = GenerateDelegate (delegateType);
} delegateCollection [delegateType] = luaDelegateType;
}
var luaDelegate = (LuaDelegate)Activator.CreateInstance (luaDelegateType);
luaDelegate.function = luaFunc; var methodInfo = delegateType.GetMethod ("Invoke");
luaDelegate.returnTypes = returnTypes.ToArray (); returnTypes.Add (methodInfo.ReturnType);
return Delegate.CreateDelegate (delegateType, luaDelegate, "CallFunction"); foreach (ParameterInfo paramInfo in methodInfo.GetParameters()) {
} if (paramInfo.ParameterType.IsByRef)
returnTypes.Add (paramInfo.ParameterType);
/* }
* Gets an instance of an implementation of the klass interface or
* subclass of klass that delegates public virtual methods to the var luaDelegate = (LuaDelegate)Activator.CreateInstance (luaDelegateType);
* luaTable table. luaDelegate.function = luaFunc;
* Caches the generated type. luaDelegate.returnTypes = returnTypes.ToArray ();
*/ #if NETFX_CORE
public object GetClassInstance (Type klass, LuaTable luaTable) var mi = luaDelegate.GetType ().GetTypeInfo ().GetDeclaredMethod ("CallFunction");
{ return mi.CreateDelegate (delegateType, luaDelegate);
LuaClassType luaClassType; #else
return Delegate.CreateDelegate (delegateType, luaDelegate, "CallFunction");
if (classCollection.ContainsKey (klass)) #endif
luaClassType = classCollection [klass]; }
else {
luaClassType = new LuaClassType (); /*
GenerateClass (klass, out luaClassType.klass, out luaClassType.returnTypes); * Gets an instance of an implementation of the klass interface or
classCollection [klass] = luaClassType; * subclass of klass that delegates public virtual methods to the
} * luaTable table.
* Caches the generated type.
return Activator.CreateInstance (luaClassType.klass, new object[] { */
luaTable, public object GetClassInstance (Type klass, LuaTable luaTable)
luaClassType.returnTypes {
}); LuaClassType luaClassType;
}
} if (classCollection.ContainsKey (klass))
luaClassType = classCollection [klass];
else {
luaClassType = new LuaClassType ();
GenerateClass (klass, out luaClassType.klass, out luaClassType.returnTypes);
classCollection [klass] = luaClassType;
}
return Activator.CreateInstance (luaClassType.klass, new object[] {
luaTable,
luaClassType.returnTypes
});
}
}
} }
\ No newline at end of file
...@@ -596,7 +596,7 @@ end ...@@ -596,7 +596,7 @@ end
globals.Add (path + "("); globals.Add (path + "(");
} }
// If the type is a class or an interface and recursion hasn't been running too long, list the members // If the type is a class or an interface and recursion hasn't been running too long, list the members
else if ((type.IsClass || type.IsInterface) && type != typeof(string) && recursionCounter < 2) { else if ((type.IsClass () || type.IsInterface ()) && type != typeof(string) && recursionCounter < 2) {
#region Methods #region Methods
foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Instance)) {
string name = method.Name; string name = method.Name;
...@@ -967,6 +967,11 @@ end ...@@ -967,6 +967,11 @@ end
#if USE_KOPILUA #if USE_KOPILUA
static void DebugHookCallback (LuaState luaState, LuaDebug debug) static void DebugHookCallback (LuaState luaState, LuaDebug debug)
{ {
#elif NETFX_CORE
static void DebugHookCallback (LuaState luaState, long luaDebug)
{
IntPtr ptr = new IntPtr (luaDebug);
LuaDebug debug = System.Runtime.InteropServices.Marshal.PtrToStructure <LuaDebug> (ptr);
#else #else
static void DebugHookCallback (LuaState luaState, IntPtr luaDebug) static void DebugHookCallback (LuaState luaState, IntPtr luaDebug)
{ {
......
/* /*
* This file is part of NLua. * This file is part of NLua.
* *
* Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com) * Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com)
* Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz. * Copyright (C) 2003-2005 Fabio Mascarenhas de Queiroz.
* Copyright (C) 2009 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) 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.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#if !SILVERLIGHT #if !SILVERLIGHT && !NETFX_CORE
using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Binary;
#endif #endif
using NLua.Extensions; using NLua.Extensions;
namespace NLua namespace NLua
{ {
public enum LuaTypes : int public enum LuaTypes : int
{ {
None = -1, None = -1,
Nil = 0, Nil = 0,
Boolean = 1, Boolean = 1,
LightUserdata = 2, LightUserdata = 2,
Number = 3, Number = 3,
String = 4, String = 4,
Table = 5, Table = 5,
Function = 6, Function = 6,
UserData = 7, UserData = 7,
Thread = 8 Thread = 8
} }
} }
\ No newline at end of file
/* /*
* This file is part of NLua. * This file is part of NLua.
* *
* Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com) * Copyright (c) 2014 Vinicius Jarina (viniciusjarina@gmail.com)
* 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.Reflection; using System.Reflection;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using NLua.Extensions; using NLua.Extensions;
#if SILVERLIGHT #if SILVERLIGHT
using System.Linq; using System.Linq;
#endif #endif
namespace NLua namespace NLua
{ {
public static class LuaRegistrationHelper public static class LuaRegistrationHelper
{ {
#region Tagged instance methods #region Tagged instance methods
/// <summary> /// <summary>
/// Registers all public instance methods in an object tagged with <see cref="LuaGlobalAttribute"/> as Lua global functions /// Registers all public instance methods in an object tagged with <see cref="LuaGlobalAttribute"/> as Lua global functions
/// </summary> /// </summary>
/// <param name="lua">The Lua VM to add the methods to</param> /// <param name="lua">The Lua VM to add the methods to</param>
/// <param name="o">The object to get the methods from</param> /// <param name="o">The object to get the methods from</param>
public static void TaggedInstanceMethods (Lua lua, object o) public static void TaggedInstanceMethods (Lua lua, object o)
{ {
#region Sanity checks #region Sanity checks
if (lua == null) if (lua == null)
throw new ArgumentNullException ("lua"); throw new ArgumentNullException ("lua");
if (o == null) if (o == null)
throw new ArgumentNullException ("o"); throw new ArgumentNullException ("o");
#endregion #endregion
foreach (var method in o.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)) { foreach (var method in o.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)) {
foreach (LuaGlobalAttribute attribute in method.GetCustomAttributes(typeof(LuaGlobalAttribute), true)) { foreach (LuaGlobalAttribute attribute in method.GetCustomAttributes(typeof(LuaGlobalAttribute), true)) {
if (string.IsNullOrEmpty (attribute.Name)) if (string.IsNullOrEmpty (attribute.Name))
lua.RegisterFunction (method.Name, o, method); // CLR name lua.RegisterFunction (method.Name, o, method); // CLR name
else else
lua.RegisterFunction (attribute.Name, o, method); // Custom name lua.RegisterFunction (attribute.Name, o, method); // Custom name
} }
} }
} }
#endregion #endregion
#region Tagged static methods #region Tagged static methods
/// <summary> /// <summary>
/// Registers all public static methods in a class tagged with <see cref="LuaGlobalAttribute"/> as Lua global functions /// Registers all public static methods in a class tagged with <see cref="LuaGlobalAttribute"/> as Lua global functions
/// </summary> /// </summary>
/// <param name="lua">The Lua VM to add the methods to</param> /// <param name="lua">The Lua VM to add the methods to</param>
/// <param name="type">The class type to get the methods from</param> /// <param name="type">The class type to get the methods from</param>
public static void TaggedStaticMethods (Lua lua, Type type) public static void TaggedStaticMethods (Lua lua, Type type)
{ {
#region Sanity checks #region Sanity checks
if (lua == null) if (lua == null)
throw new ArgumentNullException ("lua"); throw new ArgumentNullException ("lua");
if (type == null) if (type == null)
throw new ArgumentNullException ("type"); throw new ArgumentNullException ("type");
if (!type.IsClass) if (!type.IsClass ())
throw new ArgumentException ("The type must be a class!", "type"); throw new ArgumentException ("The type must be a class!", "type");
#endregion #endregion
foreach (var method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)) { foreach (var method in type.GetMethods (BindingFlags.Static | BindingFlags.Public)) {
foreach (LuaGlobalAttribute attribute in method.GetCustomAttributes(typeof(LuaGlobalAttribute), false)) { foreach (LuaGlobalAttribute attribute in method.GetCustomAttributes (typeof(LuaGlobalAttribute), false)) {
if (string.IsNullOrEmpty (attribute.Name)) if (string.IsNullOrEmpty (attribute.Name))
lua.RegisterFunction (method.Name, null, method); // CLR name lua.RegisterFunction (method.Name, null, method); // CLR name
else else
lua.RegisterFunction (attribute.Name, null, method); // Custom name lua.RegisterFunction (attribute.Name, null, method); // Custom name
} }
} }
} }
#endregion #endregion
#region Enumeration #region Enumeration
/// <summary> /// <summary>
/// Registers an enumeration's values for usage as a Lua variable table /// Registers an enumeration's values for usage as a Lua variable table
/// </summary> /// </summary>
/// <typeparam name="T">The enum type to register</typeparam> /// <typeparam name="T">The enum type to register</typeparam>
/// <param name="lua">The Lua VM to add the enum to</param> /// <param name="lua">The Lua VM to add the enum to</param>
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "The type parameter is used to select an enum type")] [SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "The type parameter is used to select an enum type")]
public static void Enumeration<T> (Lua lua) public static void Enumeration<T> (Lua lua)
{ {
#region Sanity checks #region Sanity checks
if (lua == null) if (lua == null)
throw new ArgumentNullException ("lua"); throw new ArgumentNullException ("lua");
#endregion #endregion
var type = typeof(T); var type = typeof(T);
if (!type.IsEnum) if (!type.IsEnum ())
throw new ArgumentException ("The type must be an enumeration!"); throw new ArgumentException ("The type must be an enumeration!");
#if SILVERLIGHT #if SILVERLIGHT
string[] names = type.GetFields().Where(x => x.IsLiteral).Select(field => field.Name).ToArray(); string[] names = type.GetFields().Where(x => x.IsLiteral).Select(field => field.Name).ToArray();
var values = type.GetFields().Where(x => x.IsLiteral).Select(field => (T)field.GetValue(null)).ToArray(); var values = type.GetFields().Where(x => x.IsLiteral).Select(field => (T)field.GetValue(null)).ToArray();
#else #else
string[] names = Enum.GetNames (type); string[] names = Enum.GetNames (type);
var values = (T[])Enum.GetValues (type); var values = (T[])Enum.GetValues (type);
#endif #endif
lua.NewTable (type.Name); lua.NewTable (type.Name);
for (int i = 0; i < names.Length; i++) { for (int i = 0; i < names.Length; i++) {
string path = type.Name + "." + names [i]; string path = type.Name + "." + names [i];
lua [path] = values [i]; lua [path] = values [i];
} }
} }
#endregion #endregion
} }
} }
\ No newline at end of file
...@@ -326,7 +326,7 @@ namespace NLua ...@@ -326,7 +326,7 @@ namespace NLua
{ {
int depth = LuaLib.LuaGetTop (luaState); int depth = LuaLib.LuaGetTop (luaState);
#if WINDOWS_PHONE #if WINDOWS_PHONE || NETFX_CORE
Debug.WriteLine("lua stack depth: {0}", depth); Debug.WriteLine("lua stack depth: {0}", depth);
#elif UNITY_3D #elif UNITY_3D
UnityEngine.Debug.Log(string.Format("lua stack depth: {0}", depth)); UnityEngine.Debug.Log(string.Format("lua stack depth: {0}", depth));
...@@ -345,7 +345,7 @@ namespace NLua ...@@ -345,7 +345,7 @@ namespace NLua
strrep = obj.ToString (); strrep = obj.ToString ();
} }
#if WINDOWS_PHONE #if WINDOWS_PHONE || NETFX_CORE
Debug.WriteLine("{0}: ({1}) {2}", i, typestr, strrep); Debug.WriteLine("{0}: ({1}) {2}", i, typestr, strrep);
#elif UNITY_3D #elif UNITY_3D
UnityEngine.Debug.Log(string.Format("{0}: ({1}) {2}", i, typestr, strrep)); UnityEngine.Debug.Log(string.Format("{0}: ({1}) {2}", i, typestr, strrep));
...@@ -400,14 +400,19 @@ namespace NLua ...@@ -400,14 +400,19 @@ namespace NLua
// Try to access by array if the type is right and index is an int (lua numbers always come across as double) // Try to access by array if the type is right and index is an int (lua numbers always come across as double)
if (objType.IsArray && index is double) { if (objType.IsArray && index is double) {
int intIndex = (int)((double)index); int intIndex = (int)((double)index);
#if NETFX_CORE
Type type = objType;
#else
Type type = objType.UnderlyingSystemType;
#endif
if (objType.UnderlyingSystemType == typeof(float[])) { if (type == typeof(float[])) {
float[] arr = ((float[])obj); float[] arr = ((float[])obj);
translator.Push (luaState, arr [intIndex]); translator.Push (luaState, arr [intIndex]);
} else if (objType.UnderlyingSystemType == typeof(double[])) { } else if (type == typeof(double[])) {
double[] arr = ((double[])obj); double[] arr = ((double[])obj);
translator.Push (luaState, arr [intIndex]); translator.Push (luaState, arr [intIndex]);
} else if (objType.UnderlyingSystemType == typeof(int[])) { } else if (type == typeof(int[])) {
int[] arr = ((int[])obj); int[] arr = ((int[])obj);
translator.Push (luaState, arr [intIndex]); translator.Push (luaState, arr [intIndex]);
} else { } else {
...@@ -612,7 +617,11 @@ namespace NLua ...@@ -612,7 +617,11 @@ namespace NLua
// If we can't find the getter in our class, recurse up to the base class and see // If we can't find the getter in our class, recurse up to the base class and see
// if they can help. // if they can help.
if (objType.UnderlyingSystemType != typeof(object)) if (objType.UnderlyingSystemType != typeof(object))
#if NETFX_CORE
return GetMember (luaState, new ProxyType(objType.UnderlyingSystemType.GetTypeInfo().BaseType), obj, methodName, bindingType);
#else
return GetMember (luaState, new ProxyType(objType.UnderlyingSystemType.BaseType), obj, methodName, bindingType); return GetMember (luaState, new ProxyType(objType.UnderlyingSystemType.BaseType), obj, methodName, bindingType);
#endif
else else
LuaLib.LuaPushNil (luaState); LuaLib.LuaPushNil (luaState);
} catch (TargetInvocationException e) { // Convert this exception into a Lua error } catch (TargetInvocationException e) { // Convert this exception into a Lua error
...@@ -932,7 +941,7 @@ namespace NLua ...@@ -932,7 +941,7 @@ namespace NLua
return 1; return 1;
} }
else else
return GetMember (luaState, klass, null, methodName, BindingFlags.FlattenHierarchy | BindingFlags.Static); return GetMember (luaState, klass, null, methodName, BindingFlags.Static);
} }
} }
...@@ -960,7 +969,7 @@ namespace NLua ...@@ -960,7 +969,7 @@ namespace NLua
} else } else
target = (ProxyType)obj; target = (ProxyType)obj;
return SetMember (luaState, target, null, BindingFlags.FlattenHierarchy | BindingFlags.Static); return SetMember (luaState, target, null, BindingFlags.Static);
} }
/* /*
......
...@@ -204,7 +204,11 @@ namespace NLua.Method ...@@ -204,7 +204,11 @@ namespace NLua.Method
string candidateName = null; string candidateName = null;
foreach (var member in _Members) { foreach (var member in _Members) {
#if NETFX_CORE
candidateName = member.DeclaringType.Name + "." + member.Name;
#else
candidateName = member.ReflectedType.Name + "." + member.Name; candidateName = member.ReflectedType.Name + "." + member.Name;
#endif
var m = (MethodInfo)member; var m = (MethodInfo)member;
bool isMethod = _Translator.MatchParameters (luaState, m, ref _LastCalledMethod); bool isMethod = _Translator.MatchParameters (luaState, m, ref _LastCalledMethod);
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}</ProjectGuid> <ProjectGuid>{1E72B073-2154-4329-BC8D-94F19F91C945}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NLua.WP8</RootNamespace> <RootNamespace>NLua.WP8</RootNamespace>
<AssemblyName>NLua.WP8</AssemblyName> <AssemblyName>NLua.WP8</AssemblyName>
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier> <DefaultLanguage>en-US</DefaultLanguage>
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion> <TargetPlatformVersion>8.1</TargetPlatformVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion> <MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
<SilverlightApplication>false</SilverlightApplication> <FileAlignment>512</FileAlignment>
<ValidateXaml>true</ValidateXaml> <ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> <DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <PlatformTarget>ARM</PlatformTarget>
<OutputPath>Bin\x86\Debug</OutputPath> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<DebugType>pdbonly</DebugType> <OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>Bin\x86\Release</OutputPath> <NoWarn>;2008</NoWarn>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> <DebugType>pdbonly</DebugType>
<NoStdLib>true</NoStdLib> <PlatformTarget>ARM</PlatformTarget>
<NoConfig>true</NoConfig> <UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' "> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <PlatformTarget>x86</PlatformTarget>
<OutputPath>Bin\ARM\Debug</OutputPath> <UseVSHostingProcess>false</UseVSHostingProcess>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' "> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DebugType>pdbonly</DebugType> <OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_PHONE_APP</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>Bin\ARM\Release</OutputPath> <NoWarn>;2008</NoWarn>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> <DebugType>pdbonly</DebugType>
<NoStdLib>true</NoStdLib> <PlatformTarget>x86</PlatformTarget>
<NoConfig>true</NoConfig> <UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<ProjectReference Include="..\KeraLua\src\WP8\KeraLua.WP8.csproj">
<Project>{1f139ccb-195b-402d-8776-7a15a3e05886}</Project>
<Name>KeraLua.WP8</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CheckType.cs" /> <Compile Include="CheckType.cs" />
<Compile Include="Config\NLuaConfig.cs" /> <Compile Include="Config\NLuaConfig.cs" />
...@@ -122,23 +125,17 @@ ...@@ -122,23 +125,17 @@
<Compile Include="Method\RegisterEventHandler.cs" /> <Compile Include="Method\RegisterEventHandler.cs" />
<Compile Include="ObjectTranslator.cs" /> <Compile Include="ObjectTranslator.cs" />
<Compile Include="ObjectTranslatorPool.cs" /> <Compile Include="ObjectTranslatorPool.cs" />
<Compile Include="Platform\BindFlags.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProxyType.cs" /> <Compile Include="ProxyType.cs" />
<Compile Include="Platform\CLSCompliantAttribute.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<ProjectReference Include="..\KeraLua\external\lua\wp8_build\lua\lua52\lua52.vcxproj"> <VisualStudioVersion>12.0</VisualStudioVersion>
<Project>{ABD36435-56AD-4940-B51A-10AEECA46C01}</Project> </PropertyGroup>
<Name>lua52</Name> <PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == '' ">
</ProjectReference> <TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
<ProjectReference Include="..\KeraLua\src\WP8\KeraLua.WP8.csproj"> </PropertyGroup>
<Project>{2C343545-0778-49BB-9665-1FA656013466}</Project> <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Name>KeraLua.WP8</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
<ProjectExtensions />
<!-- 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.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NLua.WPSL8</RootNamespace>
<AssemblyName>NLua.WPSL8</AssemblyName>
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<SilverlightVersion>
</SilverlightVersion>
<SilverlightApplication>false</SilverlightApplication>
<ValidateXaml>true</ValidateXaml>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<TargetFrameworkProfile />
<DefaultLanguage>en-US</DefaultLanguage>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\x86\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\x86\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\ARM\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\ARM\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget />
</PropertyGroup>
<ItemGroup>
<Compile Include="CheckType.cs" />
<Compile Include="Config\NLuaConfig.cs" />
<Compile Include="Event\DebugHookEventArgs.cs" />
<Compile Include="Event\EventCodes.cs" />
<Compile Include="Event\EventMasks.cs" />
<Compile Include="Event\HookExceptionEventArgs.cs" />
<Compile Include="Exceptions\LuaException.cs" />
<Compile Include="Exceptions\LuaScriptException.cs" />
<Compile Include="Extensions\GeneralExtensions.cs" />
<Compile Include="GenerateEventAssembly\ClassGenerator.cs" />
<Compile Include="GenerateEventAssembly\CodeGeneration.cs" />
<Compile Include="GenerateEventAssembly\DelegateGenerator.cs" />
<Compile Include="GenerateEventAssembly\ILuaGeneratedType.cs" />
<Compile Include="GenerateEventAssembly\LuaClassType.cs" />
<Compile Include="Lua.cs" />
<Compile Include="LuaBase.cs" />
<Compile Include="LuaFunction.cs" />
<Compile Include="LuaGlobalAttribute.cs" />
<Compile Include="LuaHideAttribute.cs" />
<Compile Include="LuaLib\GCOptions.cs" />
<Compile Include="LuaLib\LuaEnums.cs" />
<Compile Include="LuaLib\LuaIndexes.cs" />
<Compile Include="LuaLib\LuaLib.cs" />
<Compile Include="LuaLib\LuaTypes.cs" />
<Compile Include="LuaLib\References.cs" />
<Compile Include="LuaRegistrationHelper.cs" />
<Compile Include="LuaTable.cs" />
<Compile Include="LuaUserData.cs" />
<Compile Include="Metatables.cs" />
<Compile Include="Method\EventHandlerContainer.cs" />
<Compile Include="Method\LuaClassHelper.cs" />
<Compile Include="Method\LuaDelegate.cs" />
<Compile Include="Method\LuaEventHandler.cs" />
<Compile Include="Method\LuaMethodWrapper.cs" />
<Compile Include="Method\MethodArgs.cs" />
<Compile Include="Method\MethodCache.cs" />
<Compile Include="Method\RegisterEventHandler.cs" />
<Compile Include="ObjectTranslator.cs" />
<Compile Include="ObjectTranslatorPool.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProxyType.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\KeraLua\external\lua\wpsl8_build\lua\lua52\lua52.vcxproj">
<Project>{ABD36435-56AD-4940-B51A-10AEECA46C01}</Project>
<Name>lua52</Name>
</ProjectReference>
<ProjectReference Include="..\KeraLua\src\WP8\KeraLua.WPSL8.csproj">
<Project>{2C343545-0778-49BB-9665-1FA656013466}</Project>
<Name>KeraLua.WPSL8</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
<ProjectExtensions />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
...@@ -276,14 +276,18 @@ namespace NLua ...@@ -276,14 +276,18 @@ namespace NLua
Exception exception = null; Exception exception = null;
try { try {
#if NETFX_CORE
assembly = Assembly.Load (new AssemblyName (assemblyName));
#else
assembly = Assembly.Load (assemblyName); assembly = Assembly.Load (assemblyName);
#endif
} catch (BadImageFormatException) { } catch (BadImageFormatException) {
// The assemblyName was invalid. It is most likely a path. // The assemblyName was invalid. It is most likely a path.
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
exception = e; exception = e;
} }
#if !SILVERLIGHT #if !SILVERLIGHT && !NETFX_CORE
if (assembly == null) { if (assembly == null) {
try { try {
assembly = Assembly.Load (AssemblyName.GetAssemblyName (assemblyName)); assembly = Assembly.Load (AssemblyName.GetAssemblyName (assemblyName));
...@@ -502,7 +506,7 @@ namespace NLua ...@@ -502,7 +506,7 @@ namespace NLua
try { try {
var method = klass.GetMethod (methodName, BindingFlags.Public | BindingFlags.Static | var method = klass.GetMethod (methodName, BindingFlags.Public | BindingFlags.Static |
BindingFlags.Instance | BindingFlags.FlattenHierarchy, signature); BindingFlags.Instance, signature);
PushFunction (luaState, new LuaNativeFunction ((new LuaMethodWrapper (this, target, klass, method)).invokeFunction)); PushFunction (luaState, new LuaNativeFunction ((new LuaMethodWrapper (this, target, klass, method)).invokeFunction));
} catch (Exception e) { } catch (Exception e) {
ThrowError (luaState, e); ThrowError (luaState, e);
...@@ -583,7 +587,11 @@ namespace NLua ...@@ -583,7 +587,11 @@ namespace NLua
} }
// Object already in the list of Lua objects? Push the stored reference. // Object already in the list of Lua objects? Push the stored reference.
#if NETFX_CORE
bool found = (!o.GetType().GetTypeInfo().IsValueType) && objectsBackMap.TryGetValue (o, out index);
#else
bool found = (!o.GetType().IsValueType) && objectsBackMap.TryGetValue (o, out index); bool found = (!o.GetType().IsValueType) && objectsBackMap.TryGetValue (o, out index);
#endif
if (found) { if (found) {
LuaLib.LuaLGetMetatable (luaState, "luaNet_objects"); LuaLib.LuaLGetMetatable (luaState, "luaNet_objects");
...@@ -740,7 +748,11 @@ namespace NLua ...@@ -740,7 +748,11 @@ namespace NLua
private void CollectObject (object o, int udata) private void CollectObject (object o, int udata)
{ {
objects.Remove (udata); objects.Remove (udata);
#if NETFX_CORE
if (!o.GetType ().GetTypeInfo ().IsValueType)
#else
if (!o.GetType ().IsValueType) if (!o.GetType ().IsValueType)
#endif
objectsBackMap.Remove (o); objectsBackMap.Remove (o);
} }
...@@ -749,8 +761,13 @@ namespace NLua ...@@ -749,8 +761,13 @@ namespace NLua
// New object: inserts it in the list // New object: inserts it in the list
int index = nextObj++; int index = nextObj++;
objects [index] = obj; objects [index] = obj;
#if NETFX_CORE
if (!obj.GetType ().GetTypeInfo().IsValueType)
#else
if (!obj.GetType().IsValueType) if (!obj.GetType().IsValueType)
objectsBackMap [obj] = index; #endif
objectsBackMap [obj] = index;
return index; return index;
} }
...@@ -896,7 +913,7 @@ namespace NLua ...@@ -896,7 +913,7 @@ namespace NLua
{ {
if (o is ILuaGeneratedType) { if (o is ILuaGeneratedType) {
// Make sure we are _really_ ILuaGenerated // Make sure we are _really_ ILuaGenerated
var typ = o.GetType (); var typ = o.GetType ().GetTypeInfo ();
return typ.GetInterface ("ILuaGeneratedType", true) != null; return typ.GetInterface ("ILuaGeneratedType", true) != null;
} }
return false; return false;
...@@ -996,7 +1013,7 @@ namespace NLua ...@@ -996,7 +1013,7 @@ namespace NLua
int EnumFromIntInternal (LuaState luaState) int EnumFromIntInternal (LuaState luaState)
{ {
Type t = TypeOf (luaState, 1); Type t = TypeOf (luaState, 1);
if (t == null || !t.IsEnum) if (t == null || !t.IsEnum ())
return PushError (luaState, "Not an Enum."); return PushError (luaState, "Not an Enum.");
object res = null; object res = null;
......
using System;
namespace System.Reflection
{
public enum BindingFlags
{
Instance = 4,
Static = 8,
Public = 16,
}
}
File mode changed from 100644 to 100755
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 # Visual Studio 2013
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLua.WP8", "Core\NLua\NLua.WP8.csproj", "{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}" VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua52", "Core\KeraLua\external\lua\wp8_build\lua\lua52\lua52.vcxproj", "{51334677-A80F-40F7-8CFE-5DA0A92AC0C6}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeraLua.WP8", "Core\KeraLua\src\WP8\KeraLua.WP8.csproj", "{2C343545-0778-49BB-9665-1FA656013466}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeraLua.WP8", "Core\KeraLua\src\WP8\KeraLua.WP8.csproj", "{1F139CCB-195B-402D-8776-7A15A3E05886}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua52", "Core\KeraLua\external\lua\wp8_build\lua\lua52\lua52.vcxproj", "{ABD36435-56AD-4940-B51A-10AEECA46C01}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLua.WP8", "Core\NLua\NLua.WP8.csproj", "{1E72B073-2154-4329-BC8D-94F19F91C945}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLuaTest.WP8", "NLuaTest.WP8\NLuaTest.WP8.csproj", "{0AF57940-43F8-492B-9684-0369259C990B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -23,90 +23,64 @@ Global ...@@ -23,90 +23,64 @@ Global
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|Any CPU.ActiveCfg = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Any CPU.Build.0 = Debug|Any CPU {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|ARM.ActiveCfg = Debug|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|ARM.ActiveCfg = Debug|ARM {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|ARM.Build.0 = Debug|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|ARM.Build.0 = Debug|ARM {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Mixed Platforms.Build.0 = Debug|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|Win32.ActiveCfg = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Win32.ActiveCfg = Debug|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|Win32.Build.0 = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Win32.Build.0 = Debug|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|x86.ActiveCfg = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|x86.ActiveCfg = Debug|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Debug|x86.Build.0 = Debug|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|x86.Build.0 = Debug|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|Any CPU.ActiveCfg = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Any CPU.ActiveCfg = Release|Any CPU {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|ARM.ActiveCfg = Release|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Any CPU.Build.0 = Release|Any CPU {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|ARM.Build.0 = Release|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|ARM.ActiveCfg = Release|ARM {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|ARM.Build.0 = Release|ARM {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|Mixed Platforms.Build.0 = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Mixed Platforms.ActiveCfg = Release|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|Win32.ActiveCfg = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Mixed Platforms.Build.0 = Release|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|Win32.Build.0 = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Win32.ActiveCfg = Release|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|x86.ActiveCfg = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Win32.Build.0 = Release|x86 {51334677-A80F-40F7-8CFE-5DA0A92AC0C6}.Release|x86.Build.0 = Release|Win32
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|x86.ActiveCfg = Release|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|x86.Build.0 = Release|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|ARM.ActiveCfg = Debug|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|ARM.Build.0 = Debug|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Debug|ARM.ActiveCfg = Debug|ARM {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|ARM.Build.0 = Debug|ARM {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|Mixed Platforms.Build.0 = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|Win32.ActiveCfg = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Mixed Platforms.Build.0 = Debug|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|Win32.Build.0 = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Win32.ActiveCfg = Debug|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|x86.ActiveCfg = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Win32.Build.0 = Debug|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Debug|x86.Build.0 = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|x86.ActiveCfg = Debug|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Debug|x86.Build.0 = Debug|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|Any CPU.Build.0 = Release|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Release|Any CPU.ActiveCfg = Release|Any CPU {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|ARM.ActiveCfg = Release|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Release|Any CPU.Build.0 = Release|Any CPU {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|ARM.Build.0 = Release|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Release|ARM.ActiveCfg = Release|ARM {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|Mixed Platforms.ActiveCfg = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|ARM.Build.0 = Release|ARM {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|Mixed Platforms.Build.0 = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Mixed Platforms.ActiveCfg = Release|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|Win32.ActiveCfg = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Mixed Platforms.Build.0 = Release|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|Win32.Build.0 = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Win32.ActiveCfg = Release|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|x86.ActiveCfg = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Win32.Build.0 = Release|x86 {1F139CCB-195B-402D-8776-7A15A3E05886}.Release|x86.Build.0 = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|x86.ActiveCfg = Release|x86 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Release|x86.Build.0 = Release|x86 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Any CPU.ActiveCfg = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|ARM.ActiveCfg = Debug|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|ARM.ActiveCfg = Debug|ARM {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|ARM.Build.0 = Debug|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|ARM.Build.0 = Debug|ARM {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|Mixed Platforms.Build.0 = Debug|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|Win32.ActiveCfg = Debug|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Win32.ActiveCfg = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|Win32.Build.0 = Debug|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Win32.Build.0 = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|x86.ActiveCfg = Debug|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|x86.ActiveCfg = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Debug|x86.Build.0 = Debug|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|x86.Build.0 = Debug|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Any CPU.ActiveCfg = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|Any CPU.Build.0 = Release|Any CPU
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|ARM.ActiveCfg = Release|ARM {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|ARM.ActiveCfg = Release|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|ARM.Build.0 = Release|ARM {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|ARM.Build.0 = Release|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Mixed Platforms.ActiveCfg = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|Mixed Platforms.ActiveCfg = Release|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Mixed Platforms.Build.0 = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|Mixed Platforms.Build.0 = Release|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Win32.ActiveCfg = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|Win32.ActiveCfg = Release|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Win32.Build.0 = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|Win32.Build.0 = Release|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|x86.ActiveCfg = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|x86.ActiveCfg = Release|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|x86.Build.0 = Release|Win32 {1E72B073-2154-4329-BC8D-94F19F91C945}.Release|x86.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Any CPU.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|ARM.ActiveCfg = Debug|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|ARM.Build.0 = Debug|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|ARM.Deploy.0 = Debug|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Mixed Platforms.Build.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Win32.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Win32.Build.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Win32.Deploy.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x86.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x86.Build.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x86.Deploy.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Any CPU.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|ARM.ActiveCfg = Release|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Release|ARM.Build.0 = Release|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Release|ARM.Deploy.0 = Release|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Mixed Platforms.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Mixed Platforms.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Mixed Platforms.Deploy.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Win32.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Win32.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Win32.Deploy.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x86.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x86.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLua.WPSL8", "Core\NLua\NLua.WPSL8.csproj", "{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeraLua.WPSL8", "Core\KeraLua\src\WP8\KeraLua.WPSL8.csproj", "{2C343545-0778-49BB-9665-1FA656013466}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua52", "Core\KeraLua\external\lua\wpsl8_build\lua\lua52\lua52.vcxproj", "{ABD36435-56AD-4940-B51A-10AEECA46C01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLuaTest.WPSL8", "NLuaTest.WPSL8\NLuaTest.WPSL8.csproj", "{0AF57940-43F8-492B-9684-0369259C990B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|ARM.ActiveCfg = Debug|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|ARM.Build.0 = Debug|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Win32.ActiveCfg = Debug|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|Win32.Build.0 = Debug|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|x64.ActiveCfg = Debug|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|x86.ActiveCfg = Debug|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Debug|x86.Build.0 = Debug|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Any CPU.Build.0 = Release|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|ARM.ActiveCfg = Release|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|ARM.Build.0 = Release|ARM
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Mixed Platforms.Build.0 = Release|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Win32.ActiveCfg = Release|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|Win32.Build.0 = Release|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|x64.ActiveCfg = Release|Any CPU
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|x86.ActiveCfg = Release|x86
{9F7E0FFB-FC0E-485B-A1E8-FE04A94E40E7}.Release|x86.Build.0 = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Debug|ARM.ActiveCfg = Debug|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Debug|ARM.Build.0 = Debug|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Mixed Platforms.Build.0 = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Win32.ActiveCfg = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|Win32.Build.0 = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Debug|x86.ActiveCfg = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Debug|x86.Build.0 = Debug|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Release|Any CPU.Build.0 = Release|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Release|ARM.ActiveCfg = Release|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Release|ARM.Build.0 = Release|ARM
{2C343545-0778-49BB-9665-1FA656013466}.Release|Mixed Platforms.ActiveCfg = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Mixed Platforms.Build.0 = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Win32.ActiveCfg = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|Win32.Build.0 = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|x64.ActiveCfg = Release|Any CPU
{2C343545-0778-49BB-9665-1FA656013466}.Release|x86.ActiveCfg = Release|x86
{2C343545-0778-49BB-9665-1FA656013466}.Release|x86.Build.0 = Release|x86
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Any CPU.ActiveCfg = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|ARM.ActiveCfg = Debug|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|ARM.Build.0 = Debug|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Win32.ActiveCfg = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|Win32.Build.0 = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|x64.ActiveCfg = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|x86.ActiveCfg = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Debug|x86.Build.0 = Debug|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Any CPU.ActiveCfg = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|ARM.ActiveCfg = Release|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|ARM.Build.0 = Release|ARM
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Mixed Platforms.Build.0 = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Win32.ActiveCfg = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|Win32.Build.0 = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|x64.ActiveCfg = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|x86.ActiveCfg = Release|Win32
{ABD36435-56AD-4940-B51A-10AEECA46C01}.Release|x86.Build.0 = Release|Win32
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Any CPU.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|ARM.ActiveCfg = Debug|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|ARM.Build.0 = Debug|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|ARM.Deploy.0 = Debug|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Mixed Platforms.Build.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Win32.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Win32.Build.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|Win32.Deploy.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x64.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x86.ActiveCfg = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x86.Build.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Debug|x86.Deploy.0 = Debug|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Any CPU.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|ARM.ActiveCfg = Release|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Release|ARM.Build.0 = Release|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Release|ARM.Deploy.0 = Release|ARM
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Mixed Platforms.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Mixed Platforms.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Mixed Platforms.Deploy.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Win32.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Win32.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|Win32.Deploy.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x64.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x86.ActiveCfg = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x86.Build.0 = Release|x86
{0AF57940-43F8-492B-9684-0369259C990B}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
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