コード例 #1
0
 public static void Serialize(this SerializingContainer2 sc, ref ScriptStructFlags flags)
 {
     if (sc.IsLoading)
     {
         flags = (ScriptStructFlags)sc.ms.ReadUInt32();
     }
     else
     {
         sc.ms.Writer.WriteUInt32((uint)flags);
     }
 }
コード例 #2
0
 public Struct(string name, VariableType parent, ScriptStructFlags flags,
               List <VariableDeclaration> variableDeclarations = null,
               List <VariableType> typeDeclarations            = null,
               DefaultPropertiesBlock defaults = null,
               SourcePosition start            = null, SourcePosition end = null)
     : base(name, start, end, name switch
 {
     "Vector" => EPropertyType.Vector,
     "Rotator" => EPropertyType.Rotator,
     _ => EPropertyType.Struct
 })
コード例 #3
0
        public bool VisitNode(Struct node)
        {
            // struct [specifiers] structname [extends parentstruct] { \n contents \n };
            Write($"{STRUCT} ");

            var specs = new List <string>();
            ScriptStructFlags flags = node.Flags;

            if (flags.Has(ScriptStructFlags.Native))
            {
                specs.Add("native");
            }
            if (flags.Has(ScriptStructFlags.Export))
            {
                specs.Add("export");
            }
            if (flags.Has(ScriptStructFlags.Transient))
            {
                specs.Add("transient");
            }
            if (flags.Has(ScriptStructFlags.Immutable))
            {
                specs.Add("immutable");
            }
            else if (flags.Has(ScriptStructFlags.Atomic))
            {
                specs.Add("atomic");
            }
            if (flags.Has(ScriptStructFlags.ImmutableWhenCooked))
            {
                specs.Add("immutablewhencooked");
            }
            if (flags.Has(ScriptStructFlags.StrictConfig))
            {
                specs.Add("strictconfig");
            }

            if (specs.Any())
            {
                Append($"{string.Join(" ", specs)} ");
            }

            Append($"{node.Name} ");
            if (node.Parent != null)
            {
                Append($"{EXTENDS} {node.Parent.Name} ");
            }
            Write("{");
            NestingLevel++;

            foreach (VariableType typeDeclaration in node.TypeDeclarations)
            {
                typeDeclaration.AcceptVisitor(this);
            }

            foreach (VariableDeclaration member in node.VariableDeclarations)
            {
                member.AcceptVisitor(this);
            }

            if (node.DefaultProperties.Statements.Any())
            {
                Write("");
                node.DefaultProperties.AcceptVisitor(this);
            }

            NestingLevel--;
            Write("};");

            return(true);
        }