Commit e029feb0 authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Removed IReflect dependency. (Windows Store doesn't support IReflect) :)

parent 2bcd5944
<?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="4.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')" /> <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>
<ProjectGuid>{A42D438C-34B3-4D3D-8165-8D3779FE16A7}</ProjectGuid> <ProjectGuid>{A42D438C-34B3-4D3D-8165-8D3779FE16A7}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ConsoleTest</RootNamespace> <RootNamespace>ConsoleTest</RootNamespace>
<AssemblyName>ConsoleTest</AssemblyName> <AssemblyName>ConsoleTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ReleaseVersion>2.x</ReleaseVersion> <ReleaseVersion>2.x</ReleaseVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\tests\</OutputPath> <OutputPath>..\tests\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugKopiLua|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugKopiLua|AnyCPU'">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<OutputPath>bin\DebugKopiLua\</OutputPath> <OutputPath>bin\DebugKopiLua\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseKopiLua|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseKopiLua|AnyCPU'">
<OutputPath>bin\ReleaseKopiLua\</OutputPath> <OutputPath>bin\ReleaseKopiLua\</OutputPath>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\tests\Entity.cs"> <Compile Include="..\tests\Entity.cs">
<Link>Entity.cs</Link> <Link>Entity.cs</Link>
</Compile> </Compile>
<Compile Include="..\tests\TestLua.cs"> <Compile Include="Program.cs" />
<Link>TestLua.cs</Link> <Compile Include="Properties\AssemblyInfo.cs" />
</Compile> </ItemGroup>
<Compile Include="Program.cs" /> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<None Include="App.config" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
</ItemGroup> Other similar extension points exist, see Microsoft.Common.targets.
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Target Name="BeforeBuild">
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. </Target>
Other similar extension points exist, see Microsoft.Common.targets. <Target Name="AfterBuild">
<Target Name="BeforeBuild"> </Target>
</Target> -->
<Target Name="AfterBuild"> <ItemGroup>
</Target> <ProjectReference Include="..\Core\KopiLua\KopiLua\KopiLua.Net45.csproj">
--> <Project>{E8DDBC21-EF74-4ABA-9C49-BFC702BE25D8}</Project>
<ItemGroup> <Name>KopiLua.Net45</Name>
<ProjectReference Include="..\Core\KopiLua\KopiLua\KopiLua.Net45.csproj"> </ProjectReference>
<Project>{e8ddbc21-ef74-4aba-9c49-bfc702be25d8}</Project> <ProjectReference Include="..\Core\NLua\NLua.Net45.csproj">
<Name>KopiLua.Net45</Name> <Project>{F55CABBB-4108-4A39-94E1-581FD46DC021}</Project>
</ProjectReference> <Name>NLua.Net45</Name>
<ProjectReference Include="..\Core\NLua\NLua.Net45.csproj"> </ProjectReference>
<Project>{F55CABBB-4108-4A39-94E1-581FD46DC021}</Project> <ProjectReference Include="..\Core\KeraLua\src\KeraLua.Net45.csproj">
<Name>NLua.Net45</Name> <Project>{47153754-10F5-44D8-B578-F5A32B69061A}</Project>
</ProjectReference> <Name>KeraLua.Net45</Name>
<ProjectReference Include="..\Core\KeraLua\src\KeraLua.Net45.csproj"> </ProjectReference>
<Project>{47153754-10F5-44D8-B578-F5A32B69061A}</Project> <ProjectReference Include="..\NLuaTest\NLuaTest.csproj">
<Name>KeraLua.Net45</Name> <Project>{D5FCADFA-5047-40C2-B392-256875862920}</Project>
</ProjectReference> <Name>NLuaTest</Name>
<ProjectReference Include="..\NLuaTest\NLuaTest.csproj"> </ProjectReference>
<Project>{D5FCADFA-5047-40C2-B392-256875862920}</Project> </ItemGroup>
<Name>NLuaTest</Name>
</ProjectReference>
</ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -84,7 +84,7 @@ namespace NLua ...@@ -84,7 +84,7 @@ namespace NLua
* Checks if the value at Lua stack index stackPos matches paramType, * Checks if the value at Lua stack index stackPos matches paramType,
* returning a conversion function if it does and null otherwise. * returning a conversion function if it does and null otherwise.
*/ */
internal ExtractValue GetExtractor (IReflect paramType) internal ExtractValue GetExtractor (ProxyType paramType)
{ {
return GetExtractor (paramType.UnderlyingSystemType); return GetExtractor (paramType.UnderlyingSystemType);
} }
......
...@@ -1103,7 +1103,7 @@ end ...@@ -1103,7 +1103,7 @@ end
{ {
// We leave nothing on the stack when we are done // We leave nothing on the stack when we are done
int oldTop = LuaLib.LuaGetTop (luaState); int oldTop = LuaLib.LuaGetTop (luaState);
var wrapper = new LuaMethodWrapper (translator, target, function.DeclaringType, function); var wrapper = new LuaMethodWrapper (translator, target, new ProxyType(function.DeclaringType), function);
translator.Push (luaState, new LuaNativeFunction (wrapper.invokeFunction)); translator.Push (luaState, new LuaNativeFunction (wrapper.invokeFunction));
this [path] = translator.GetObject (luaState, -1); this [path] = translator.GetObject (luaState, -1);
var f = GetFunction (path); var f = GetFunction (path);
......
...@@ -398,14 +398,14 @@ namespace NLua ...@@ -398,14 +398,14 @@ namespace NLua
//var indexType = index.GetType(); //var indexType = index.GetType();
string methodName = index as string; // will be null if not a string arg string methodName = index as string; // will be null if not a string arg
var objType = obj.GetType (); var objType = obj.GetType ();
var proxyType = new ProxyType (objType);
// Handle the most common case, looking up the method by name. // Handle the most common case, looking up the method by name.
// CP: This will fail when using indexers and attempting to get a value with the same name as a property of the object, // CP: This will fail when using indexers and attempting to get a value with the same name as a property of the object,
// ie: xmlelement['item'] <- item is a property of xmlelement // ie: xmlelement['item'] <- item is a property of xmlelement
try { try {
if (!string.IsNullOrEmpty(methodName) && IsMemberPresent (objType, methodName)) if (!string.IsNullOrEmpty(methodName) && IsMemberPresent (proxyType, methodName))
return GetMember (luaState, objType, obj, methodName, BindingFlags.Instance); return GetMember (luaState, proxyType, obj, methodName, BindingFlags.Instance);
} catch { } catch {
} }
...@@ -508,12 +508,12 @@ namespace NLua ...@@ -508,12 +508,12 @@ namespace NLua
return 2; return 2;
} }
GetMember (luaState, obj.GetType (), obj, "__luaInterface_base_" + methodName, BindingFlags.Instance); GetMember (luaState, new ProxyType(obj.GetType ()), obj, "__luaInterface_base_" + methodName, BindingFlags.Instance);
LuaLib.LuaSetTop (luaState, -2); LuaLib.LuaSetTop (luaState, -2);
if (LuaLib.LuaType (luaState, -1) == LuaTypes.Nil) { if (LuaLib.LuaType (luaState, -1) == LuaTypes.Nil) {
LuaLib.LuaSetTop (luaState, -2); LuaLib.LuaSetTop (luaState, -2);
return GetMember (luaState, obj.GetType (), obj, methodName, BindingFlags.Instance); return GetMember (luaState, new ProxyType(obj.GetType ()), obj, methodName, BindingFlags.Instance);
} }
LuaLib.LuaPushBoolean (luaState, false); LuaLib.LuaPushBoolean (luaState, false);
...@@ -526,7 +526,7 @@ namespace NLua ...@@ -526,7 +526,7 @@ namespace NLua
/// <param name="objType"></param> /// <param name="objType"></param>
/// <param name="methodName"></param> /// <param name="methodName"></param>
/// <returns></returns> /// <returns></returns>
bool IsMemberPresent (IReflect objType, string methodName) bool IsMemberPresent (ProxyType objType, string methodName)
{ {
object cachedMember = CheckMemberCache (memberCache, objType, methodName); object cachedMember = CheckMemberCache (memberCache, objType, methodName);
...@@ -558,7 +558,7 @@ namespace NLua ...@@ -558,7 +558,7 @@ namespace NLua
} }
MethodInfo methodInfo = translator.GetExtensionMethod (type, name); MethodInfo methodInfo = translator.GetExtensionMethod (type, name);
var wrapper = new LuaNativeFunction ((new LuaMethodWrapper (translator, obj, type, methodInfo)).invokeFunction); var wrapper = new LuaNativeFunction ((new LuaMethodWrapper (translator, obj,new ProxyType(type), methodInfo)).invokeFunction);
SetMemberCache (memberCache, type, name, wrapper); SetMemberCache (memberCache, type, name, wrapper);
...@@ -573,7 +573,7 @@ namespace NLua ...@@ -573,7 +573,7 @@ namespace NLua
* Uses reflection to find members, and stores the reflected MemberInfo object in * Uses reflection to find members, and stores the reflected MemberInfo object in
* a cache (indexed by the type of the object and the name of the member). * a cache (indexed by the type of the object and the name of the member).
*/ */
int GetMember (LuaState luaState, IReflect objType, object obj, string methodName, BindingFlags bindingType) int GetMember (LuaState luaState, ProxyType objType, object obj, string methodName, BindingFlags bindingType)
{ {
bool implicitStatic = false; bool implicitStatic = false;
MemberInfo member = null; MemberInfo member = null;
...@@ -624,8 +624,8 @@ namespace NLua ...@@ -624,8 +624,8 @@ namespace NLua
} catch (ArgumentException) { } catch (ArgumentException) {
// 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 is Type && !(((Type)objType) == typeof(object))) if (objType.UnderlyingSystemType != typeof(object))
return GetMember (luaState, ((Type)objType).BaseType, obj, methodName, bindingType); return GetMember (luaState, new ProxyType(objType.UnderlyingSystemType.BaseType), obj, methodName, bindingType);
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
...@@ -685,7 +685,12 @@ namespace NLua ...@@ -685,7 +685,12 @@ namespace NLua
/* /*
* Checks if a MemberInfo object is cached, returning it or null. * Checks if a MemberInfo object is cached, returning it or null.
*/ */
private object CheckMemberCache (Dictionary<object, object> memberCache, IReflect objType, string memberName) object CheckMemberCache (Dictionary<object, object> memberCache, Type objType, string memberName)
{
return CheckMemberCache (memberCache, new ProxyType (objType), memberName);
}
object CheckMemberCache (Dictionary<object, object> memberCache, ProxyType objType, string memberName)
{ {
object members = null; object members = null;
...@@ -707,7 +712,12 @@ namespace NLua ...@@ -707,7 +712,12 @@ namespace NLua
/* /*
* Stores a MemberInfo object in the member cache. * Stores a MemberInfo object in the member cache.
*/ */
private void SetMemberCache (Dictionary<object, object> memberCache, IReflect objType, string memberName, object member) void SetMemberCache (Dictionary<object, object> memberCache, Type objType, string memberName, object member)
{
SetMemberCache (memberCache, new ProxyType (objType), memberName, member);
}
void SetMemberCache (Dictionary<object, object> memberCache, ProxyType objType, string memberName, object member)
{ {
Dictionary<object, object> members = null; Dictionary<object, object> members = null;
object memberCacheValue = null; object memberCacheValue = null;
...@@ -751,7 +761,7 @@ namespace NLua ...@@ -751,7 +761,7 @@ namespace NLua
// First try to look up the parameter as a property name // First try to look up the parameter as a property name
string detailMessage; string detailMessage;
bool didMember = TrySetMember (luaState, type, target, BindingFlags.Instance, out detailMessage); bool didMember = TrySetMember (luaState, new ProxyType(type), target, BindingFlags.Instance, out detailMessage);
if (didMember) if (didMember)
return 0; // Must have found the property name return 0; // Must have found the property name
...@@ -804,7 +814,7 @@ namespace NLua ...@@ -804,7 +814,7 @@ namespace NLua
/// <param name="target"></param> /// <param name="target"></param>
/// <param name="bindingType"></param> /// <param name="bindingType"></param>
/// <returns>false if unable to find the named member, true for success</returns> /// <returns>false if unable to find the named member, true for success</returns>
private bool TrySetMember (LuaState luaState, IReflect targetType, object target, BindingFlags bindingType, out string detailMessage) bool TrySetMember (LuaState luaState, ProxyType targetType, object target, BindingFlags bindingType, out string detailMessage)
{ {
detailMessage = null; // No error yet detailMessage = null; // No error yet
...@@ -872,7 +882,7 @@ namespace NLua ...@@ -872,7 +882,7 @@ namespace NLua
* Writes to fields or properties, either static or instance. Throws an error * Writes to fields or properties, either static or instance. Throws an error
* if the operation is invalid. * if the operation is invalid.
*/ */
private int SetMember (LuaState luaState, IReflect targetType, object target, BindingFlags bindingType) private int SetMember (LuaState luaState, ProxyType targetType, object target, BindingFlags bindingType)
{ {
string detail; string detail;
bool success = TrySetMember (luaState, targetType, target, bindingType, out detail); bool success = TrySetMember (luaState, targetType, target, bindingType, out detail);
...@@ -915,15 +925,15 @@ namespace NLua ...@@ -915,15 +925,15 @@ namespace NLua
private int GetClassMethodInternal (LuaState luaState) private int GetClassMethodInternal (LuaState luaState)
{ {
IReflect klass; ProxyType klass;
object obj = translator.GetRawNetObject (luaState, 1); object obj = translator.GetRawNetObject (luaState, 1);
if (obj == null || !(obj is IReflect)) { if (obj == null || !(obj is ProxyType)) {
translator.ThrowError (luaState, "trying to index an invalid type reference"); translator.ThrowError (luaState, "trying to index an invalid type reference");
LuaLib.LuaPushNil (luaState); LuaLib.LuaPushNil (luaState);
return 1; return 1;
} else } else
klass = (IReflect)obj; klass = (ProxyType)obj;
if (LuaLib.LuaIsNumber (luaState, 2)) { if (LuaLib.LuaIsNumber (luaState, 2)) {
int size = (int)LuaLib.LuaToNumber (luaState, 2); int size = (int)LuaLib.LuaToNumber (luaState, 2);
...@@ -957,14 +967,14 @@ namespace NLua ...@@ -957,14 +967,14 @@ namespace NLua
private int SetClassFieldOrPropertyInternal (LuaState luaState) private int SetClassFieldOrPropertyInternal (LuaState luaState)
{ {
IReflect target; ProxyType target;
object obj = translator.GetRawNetObject (luaState, 1); object obj = translator.GetRawNetObject (luaState, 1);
if (obj == null || !(obj is IReflect)) { if (obj == null || !(obj is ProxyType)) {
translator.ThrowError (luaState, "trying to index an invalid type reference"); translator.ThrowError (luaState, "trying to index an invalid type reference");
return 0; return 0;
} else } else
target = (IReflect)obj; target = (ProxyType)obj;
return SetMember (luaState, target, null, BindingFlags.FlattenHierarchy | BindingFlags.Static); return SetMember (luaState, target, null, BindingFlags.FlattenHierarchy | BindingFlags.Static);
} }
...@@ -989,15 +999,15 @@ namespace NLua ...@@ -989,15 +999,15 @@ namespace NLua
private int CallConstructorInternal (LuaState luaState) private int CallConstructorInternal (LuaState luaState)
{ {
var validConstructor = new MethodCache (); var validConstructor = new MethodCache ();
IReflect klass; ProxyType klass;
object obj = translator.GetRawNetObject (luaState, 1); object obj = translator.GetRawNetObject (luaState, 1);
if (obj == null || !(obj is IReflect)) { if (obj == null || !(obj is ProxyType)) {
translator.ThrowError (luaState, "trying to call constructor on an invalid type reference"); translator.ThrowError (luaState, "trying to call constructor on an invalid type reference");
LuaLib.LuaPushNil (luaState); LuaLib.LuaPushNil (luaState);
return 1; return 1;
} else } else
klass = (IReflect)obj; klass = (ProxyType)obj;
LuaLib.LuaRemove (luaState, 1); LuaLib.LuaRemove (luaState, 1);
var constructors = klass.UnderlyingSystemType.GetConstructors (); var constructors = klass.UnderlyingSystemType.GetConstructors ();
......
...@@ -66,7 +66,7 @@ namespace NLua.Method ...@@ -66,7 +66,7 @@ namespace NLua.Method
/* /*
* Constructs the wrapper for a known MethodBase instance * Constructs the wrapper for a known MethodBase instance
*/ */
public LuaMethodWrapper (ObjectTranslator translator, object target, IReflect targetType, MethodBase method) public LuaMethodWrapper (ObjectTranslator translator, object target, ProxyType targetType, MethodBase method)
{ {
invokeFunction = new LuaNativeFunction (this.Call); invokeFunction = new LuaNativeFunction (this.Call);
_Translator = translator; _Translator = translator;
...@@ -87,7 +87,7 @@ namespace NLua.Method ...@@ -87,7 +87,7 @@ namespace NLua.Method
/* /*
* Constructs the wrapper for a known method name * Constructs the wrapper for a known method name
*/ */
public LuaMethodWrapper (ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) public LuaMethodWrapper (ObjectTranslator translator, ProxyType targetType, string methodName, BindingFlags bindingType)
{ {
invokeFunction = new LuaNativeFunction (this.Call); invokeFunction = new LuaNativeFunction (this.Call);
......
...@@ -480,12 +480,12 @@ namespace NLua ...@@ -480,12 +480,12 @@ namespace NLua
private int GetMethodSignatureInternal (LuaState luaState) private int GetMethodSignatureInternal (LuaState luaState)
{ {
IReflect klass; ProxyType klass;
object target; object target;
int udata = LuaLib.LuaNetCheckUData (luaState, 1, "luaNet_class"); int udata = LuaLib.LuaNetCheckUData (luaState, 1, "luaNet_class");
if (udata != -1) { if (udata != -1) {
klass = (IReflect)objects [udata]; klass = (ProxyType)objects [udata];
target = null; target = null;
} else { } else {
target = GetRawNetObject (luaState, 1); target = GetRawNetObject (luaState, 1);
...@@ -496,7 +496,7 @@ namespace NLua ...@@ -496,7 +496,7 @@ namespace NLua
return 1; return 1;
} }
klass = target.GetType (); klass = new ProxyType(target.GetType ());
} }
string methodName = LuaLib.LuaToString (luaState, 2).ToString (); string methodName = LuaLib.LuaToString (luaState, 2).ToString ();
...@@ -533,11 +533,11 @@ namespace NLua ...@@ -533,11 +533,11 @@ namespace NLua
private int GetConstructorSignatureInternal (LuaState luaState) private int GetConstructorSignatureInternal (LuaState luaState)
{ {
IReflect klass = null; ProxyType klass = null;
int udata = LuaLib.LuaNetCheckUData (luaState, 1, "luaNet_class"); int udata = LuaLib.LuaNetCheckUData (luaState, 1, "luaNet_class");
if (udata != -1) if (udata != -1)
klass = (IReflect)objects [udata]; klass = (ProxyType)objects [udata];
if (klass == null) if (klass == null)
ThrowError (luaState, "get_constructor_bysig: first arg is invalid type reference"); ThrowError (luaState, "get_constructor_bysig: first arg is invalid type reference");
......
/* /*
* 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.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
namespace NLua namespace NLua
{ {
/// <summary> /// <summary>
/// Summary description for ProxyType. /// Summary description for ProxyType.
/// </summary> /// </summary>
public class ProxyType : IReflect public class ProxyType
{ {
private Type proxy; private Type proxy;
public ProxyType (Type proxy) public ProxyType (Type proxy)
{ {
this.proxy = proxy; this.proxy = proxy;
} }
/// <summary> /// <summary>
/// Provide human readable short hand for this proxy object /// Provide human readable short hand for this proxy object
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override string ToString () public override string ToString ()
{ {
return "ProxyType(" + UnderlyingSystemType + ")"; return "ProxyType(" + UnderlyingSystemType + ")";
} }
public Type UnderlyingSystemType { public Type UnderlyingSystemType {
get { return proxy; } get { return proxy; }
} }
public FieldInfo GetField (string name, BindingFlags bindingAttr) public override bool Equals (object obj)
{ {
return proxy.GetField (name, bindingAttr); if (obj is Type)
} return proxy.Equals ((Type)obj);
if (obj is ProxyType)
public FieldInfo[] GetFields (BindingFlags bindingAttr) return proxy.Equals (((ProxyType)obj).UnderlyingSystemType);
{ return proxy.Equals (obj);
return proxy.GetFields (bindingAttr); }
}
public override int GetHashCode ()
public MemberInfo[] GetMember (string name, BindingFlags bindingAttr) {
{ return proxy.GetHashCode ();
return proxy.GetMember (name, bindingAttr); }
}
public MemberInfo[] GetMember (string name, BindingFlags bindingAttr)
public MemberInfo[] GetMembers (BindingFlags bindingAttr) {
{ return proxy.GetMember (name, bindingAttr);
return proxy.GetMembers (bindingAttr); }
}
public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
public MethodInfo GetMethod (string name, BindingFlags bindingAttr) {
{ return proxy.GetMethod (name, bindingAttr, binder, types, modifiers);
return proxy.GetMethod (name, bindingAttr); }
} }
public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
{
return proxy.GetMethod (name, bindingAttr, binder, types, modifiers);
}
public MethodInfo[] GetMethods (BindingFlags bindingAttr)
{
return proxy.GetMethods (bindingAttr);
}
public PropertyInfo GetProperty (string name, BindingFlags bindingAttr)
{
return proxy.GetProperty (name, bindingAttr);
}
public PropertyInfo GetProperty (string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
{
return proxy.GetProperty (name, bindingAttr, binder, returnType, types, modifiers);
}
public PropertyInfo[] GetProperties (BindingFlags bindingAttr)
{
return proxy.GetProperties (bindingAttr);
}
public object InvokeMember (string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
{
return proxy.InvokeMember (name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
}
}
} }
\ No newline at end of file
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