Example #1
0
        public Signature GetNextSignature(ref int pos)
        {
            if (data == null)
            {
                return(Signature.Empty);
            }

            DType dtype = (DType)data[pos++];

            switch (dtype)
            {
            //case DType.Invalid:
            //	return typeof (void);
            case DType.Array:
                //peek to see if this is in fact a dictionary
                if ((DType)data[pos] == DType.DictEntryBegin)
                {
                    //skip over the {
                    pos++;
                    Signature keyType   = GetNextSignature(ref pos);
                    Signature valueType = GetNextSignature(ref pos);
                    //skip over the }
                    pos++;
                    return(Signature.MakeDict(keyType, valueType));
                }
                else
                {
                    Signature elementType = GetNextSignature(ref pos);
                    return(elementType.MakeArraySignature());
                }

            //case DType.DictEntryBegin: // FIXME: DictEntries should be handled separately.
            case DType.StructBegin:
                //List<Signature> fieldTypes = new List<Signature> ();
                Signature fieldsSig = Signature.Empty;
                while ((DType)data[pos] != DType.StructEnd)
                {
                    fieldsSig += GetNextSignature(ref pos);
                }
                //skip over the )
                pos++;
                return(Signature.MakeStruct(fieldsSig));

            //return fieldsSig;
            case DType.DictEntryBegin:
                Signature sigKey   = GetNextSignature(ref pos);
                Signature sigValue = GetNextSignature(ref pos);
                //skip over the }
                pos++;
                return(Signature.MakeDictEntry(sigKey, sigValue));

            default:
                return(new Signature(dtype));
            }
        }