示例#1
0
            private void SetFields(object fields)
            {
                lock (this) {
                    IList <object> list       = GetFieldsList(fields);
                    IList <object> anonFields = StructType.GetAnonymousFields(this);

                    int          size = 0, alignment = 1;
                    List <Field> allFields = new List <Field>();//GetBaseSizeAlignmentAndFields(out size, out alignment);
                    int?         bitCount;
                    for (int fieldIndex = 0; fieldIndex < list.Count; fieldIndex++)
                    {
                        object      o = list[fieldIndex];
                        string      fieldName;
                        INativeType cdata;
                        GetFieldInfo(this, o, out fieldName, out cdata, out bitCount);
                        alignment = Math.Max(alignment, cdata.Alignment);
                        size      = Math.Max(size, cdata.Size);

                        Field newField = new Field(fieldName, cdata, 0, allFields.Count);
                        allFields.Add(newField);
                        AddSlot(fieldName, newField);

                        if (anonFields != null && anonFields.Contains(fieldName))
                        {
                            StructType.AddAnonymousFields(this, allFields, cdata, newField);
                        }
                    }

                    StructType.CheckAnonymousFields(allFields, anonFields);

                    _fields    = allFields.ToArray();
                    _size      = PythonStruct.Align(size, alignment);
                    _alignment = alignment;
                }
            }