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