Example #1
0
        public UnionMember GetMemberOfType(TpmStruct s)
        {
            UnionMember elt = null;

            do
            {
                elt = GetElementOfType(s);
                s   = s.DerivedFrom;
            } while (elt == null && s != null);
            return(elt);
        }
Example #2
0
        public void Add(UnionMember newMem)
        {
            Members.Add(newMem);

            TpmType tdt = newMem.Type.StripTypedefs();

            if (tdt is TpmStruct)
            {
                (tdt as TpmStruct).RegisterContainingUnion(this);
            }
        }
Example #3
0
        public static void AddDerivedStruct(TpmStruct baseStruct, UnionMember curMember,
                                            TpmUnion curUnion, string comment = null)
        {
            string baseTypeName = baseStruct.SpecName;
            string newTypeName  = baseTypeName + "_" + RemoveEnumPrefix(curMember.SelectorValue.SpecName,
                                                                        curMember.SelectorValue.EnclosingEnum.SpecName);

            if (!TpmTypes.Contains(newTypeName))
            {
                var newStruct = new TpmStruct(newTypeName,
                                              comment ?? "Auto-derived from " + baseTypeName,
                                              baseStruct);
                TpmTypes.Add(newStruct);
            }

            var s = (TpmStruct)TpmTypes.Lookup(newTypeName);

            s.RegisterContainingUnion(curUnion);
            // Fix up the union field
            curMember.Type = s;
        }