Commit 81244a4d authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

improved error handling when not finding an index or field (from stevedenovan/MonoLuaInterface)

https://github.com/stevedonovan/MonoLuaInterface/commit/ceabde36fc08013a04cfff5b87325eeab8b277f1
parent afb6c136
...@@ -56,22 +56,23 @@ namespace NLua ...@@ -56,22 +56,23 @@ namespace NLua
/* /*
* __index metafunction for CLR objects. Implemented in Lua. * __index metafunction for CLR objects. Implemented in Lua.
*/ */
internal static string luaIndexFunction = internal static string luaIndexFunction =
"local function index(obj,name) \n" + @"local function index(obj,name)
" local meta=getmetatable(obj) \n" + local meta=getmetatable(obj)
" local cached=meta.cache[name] \n" + local cached=meta.cache[name]
" if cached~=nil then \n" + if cached then
" return cached \n" + return cached
" else \n" + else
" local value,isFunc=get_object_member(obj,name) \n" + local value,isFunc = get_object_member(obj,name)
" if isFunc then \n" + if not value then error(isFunc,2) end
" meta.cache[name]=value \n" + if isFunc then
" end \n" + meta.cache[name]=value
" return value \n" + end
" end \n" + return value
"end \n" + end
"return index "; end
return index";
public MetaFunctions (ObjectTranslator translator) public MetaFunctions (ObjectTranslator translator)
{ {
......
...@@ -56,11 +56,11 @@ ...@@ -56,11 +56,11 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Core\KeraLua\KeraLua.csproj"> <ProjectReference Include="..\Core\KeraLua\src\KeraLua.csproj">
<Project>{47153754-10f5-44d8-b578-f5a32b69061a}</Project> <Project>{47153754-10f5-44d8-b578-f5a32b69061a}</Project>
<Name>KeraLua</Name> <Name>KeraLua</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Core\KopiLua\KopiLua.csproj"> <ProjectReference Include="..\Core\KopiLua\KopiLua\KopiLua.csproj">
<Project>{E8DDBC21-EF74-4ABA-9C49-BFC702BE25D8}</Project> <Project>{E8DDBC21-EF74-4ABA-9C49-BFC702BE25D8}</Project>
<Name>KopiLua</Name> <Name>KopiLua</Name>
</ProjectReference> </ProjectReference>
......
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