Esempio n. 1
0
        private static void GenerateNewIndex(ClassDescription csd, Lua4NetSerializer serializer)
        {
            serializer.NewLine();
            serializer.NewLine(string.Format("function {0}.__SetByIndex(t,k,v)", csd.GetNamespaceName(csd.ProxyName)));
            serializer.BeginBlock("");
            serializer.NewLine(string.Format("local pf = {0}.__SetProperty[k]", csd.GetNamespaceName(csd.ProxyName)));
            serializer.NewLine("if pf ~= nil then");
            serializer.BeginBlock("");
            serializer.Apppend("        pf(t,v)");
            serializer.NewLine("return");
            serializer.EndBlock("end");

            if (csd.HasBaseClassDescription)
            {
                serializer.NewLine(string.Format("{0}.__SetByIndex(t,k,v)", csd.GetBaseClassProxyName()));
                serializer.NewLine("return");
            }
            else
            {
                serializer.NewLine("print(k .. ' is not a property')");
            }
            serializer.EndBlock("end");
        }
Esempio n. 2
0
        private static void GenerateIndex(ClassDescription csd, Lua4NetSerializer serializer)
        {
            serializer.NewLine();
            serializer.NewLine(string.Format("function {0}.__GetByIndex(t,k)", csd.GetNamespaceName(csd.ProxyName)));
            serializer.BeginBlock("");
                serializer.NewLine(string.Format("local pf = {0}.__GetProperty[k]", csd.GetNamespaceName(csd.ProxyName)));
                serializer.NewLine("if pf ~= nil then");
                serializer.BeginBlock("");
                    serializer.Apppend("    return pf(t)");
                serializer.EndBlock("end");

                serializer.NewLine(string.Format("local f = {0}.__Method[k]", csd.GetNamespaceName(csd.ProxyName)));
                serializer.NewLine("if f ~= nil then");
                serializer.BeginBlock("");
                serializer.Apppend("    return f");
                serializer.EndBlock("end");
                if (csd.HasBaseClassDescription)
                {
                    serializer.NewLine(string.Format("return {0}.__GetByIndex(t,k)", csd.GetBaseClassProxyName()));
                }
                else
                {
                    serializer.NewLine("return nil");
                }
            serializer.EndBlock("end");
        }