Example #1
0
        internal void Serialize(System.IO.BinaryWriter writer)
        {
            writer.Write((byte)type);

            if (type == Type.String)
            {
                ObjLua.WriteString(str, writer);
            }
            else if (type == Type.Number)
            {
                if (parent.Parent.NumberSize == 8)
                {
                    writer.Write((double)dval);
                }
                else if (parent.Parent.NumberSize == 4)
                {
                    writer.Write((float)dval);
                }
                else
                {
                    throw new Exception("Number Size " + parent.Parent.NumberSize.ToString() + " is not supported!");
                }
            }
            else if (type == Type.Empty)
            {
            }
            else
            {
                throw new Exception("Unknown Constant Type: 0x" + Helper.HexString((byte)type) + ", 0x" + Helper.HexString(writer.BaseStream.Position - 0x40));
            }
        }
Example #2
0
        internal void Unserialize(System.IO.BinaryReader reader)
        {
            type = (Type)reader.ReadByte();

            str   = "";
            bdata = new uint[0];
            badd  = new byte[0];
            if (type == Type.String)
            {
                str = ObjLua.ReadString(reader);
            }
            else if (type == Type.Number)
            {
                if (parent.Parent.NumberSize == 8)
                {
                    dval = reader.ReadDouble();
                }
                else if (parent.Parent.NumberSize == 4)
                {
                    dval = reader.ReadSingle();
                }
                else
                {
                    throw new Exception("Number Size " + parent.Parent.NumberSize.ToString() + " is not supported!");
                }
            }
            else if (type == Type.Empty)
            {
            }
            else
            {
                throw new Exception("Unknown Constant Type: 0x" + Helper.HexString((byte)type) + ", 0x" + Helper.HexString(reader.BaseStream.Position - 0x40));
            }
        }
Example #3
0
 public void Dispose()
 {
     parent = null;
     if (contants != null)
     {
         contants.Clear();
     }
     contants = null;
 }
Example #4
0
        public ObjLuaFunction(ObjLua parent)
        {
            this.parent = parent;
            name        = "";

            contants  = new ArrayList();
            functions = new ArrayList();
            codes     = new ArrayList();
            srcln     = new ArrayList();
            local     = new ArrayList();
            upval     = new ArrayList();
        }
Example #5
0
        internal void Serialize(System.IO.BinaryWriter writer)
        {
            ObjLua.WriteString(name, writer);

            writer.Write(linedef);
            writer.Write(nups);
            writer.Write(argc);
            writer.Write(isinout);
            writer.Write(stacksz);

            writer.Write((uint)srcln.Count);
            foreach (ObjLuaSourceLine item in srcln)
            {
                item.Serialize(writer);
            }

            writer.Write((uint)local.Count);
            foreach (ObjLuaLocalVar item in local)
            {
                item.Serialize(writer);
            }

            writer.Write((uint)upval.Count);
            foreach (ObjLuaUpValue item in upval)
            {
                item.Serialize(writer);
            }

            writer.Write((uint)contants.Count);
            foreach (ObjLuaConstant item in contants)
            {
                item.Serialize(writer);
            }

            writer.Write((uint)functions.Count);
            foreach (ObjLuaFunction item in functions)
            {
                item.Serialize(writer);
            }

            writer.Write((uint)codes.Count);
            foreach (ObjLuaCode item in codes)
            {
                item.Serialize(writer);
            }
        }
Example #6
0
        internal void Unserialize(System.IO.BinaryReader reader)
        {
            contants.Clear();
            functions.Clear();
            codes.Clear();
            srcln.Clear();
            local.Clear();
            upval.Clear();

            name = ObjLua.ReadString(reader);

            linedef = reader.ReadUInt32();
            nups    = reader.ReadByte();
            argc    = reader.ReadByte();
            isinout = reader.ReadByte();
            stacksz = reader.ReadByte();

            uint linenfosz = reader.ReadUInt32();

            for (uint i = 0; i < linenfosz; i++)
            {
                ObjLuaSourceLine item = new ObjLuaSourceLine(this);
                item.Unserialize(reader);

                srcln.Add(item);
            }

            uint locvarsz = reader.ReadUInt32();

            for (uint i = 0; i < locvarsz; i++)
            {
                ObjLuaLocalVar item = new ObjLuaLocalVar(this);
                item.Unserialize(reader);

                local.Add(item);
            }

            uint upvalsz = reader.ReadUInt32();

            for (uint i = 0; i < upvalsz; i++)
            {
                ObjLuaUpValue item = new ObjLuaUpValue(this);
                item.Unserialize(reader);

                upval.Add(item);
            }

            uint constsz = reader.ReadUInt32();

            for (uint i = 0; i < constsz; i++)
            {
                ObjLuaConstant item = new ObjLuaConstant(this);
                item.Unserialize(reader);

                contants.Add(item);
            }

            uint fncsz = reader.ReadUInt32();

            for (uint i = 0; i < fncsz; i++)
            {
                ObjLuaFunction item = new ObjLuaFunction(this.parent);
                item.Unserialize(reader);

                functions.Add(item);
            }

            uint codesz = reader.ReadUInt32();

            for (uint i = 0; i < codesz; i++)
            {
                ObjLuaCode item = ObjLuaCode.Unserialize(reader, this);

                codes.Add(item);
            }
        }
Example #7
0
 internal void Serialize(System.IO.BinaryWriter writer)
 {
     ObjLua.WriteString(name, writer);
     writer.Write(start);
     writer.Write(end);
 }
Example #8
0
 internal void Unserialize(System.IO.BinaryReader reader)
 {
     name  = ObjLua.ReadString(reader);
     start = reader.ReadUInt32();
     end   = reader.ReadUInt32();
 }