public MarshalSig GetMarshalSig(uint index)
        {
            MarshalSig ms = m_signatures [index] as MarshalSig;

            if (ms == null)
            {
                byte [] data = m_root.Streams.BlobHeap.Read(index);
                ms = ReadMarshalSig(data);
                m_signatures [index] = ms;
            }
            return(ms);
        }
        void Write(MarshalSig ms)
        {
            Write((int)ms.NativeInstrinsic);
            switch (ms.NativeInstrinsic)
            {
            case NativeType.ARRAY:
                MarshalSig.Array ar = (MarshalSig.Array)ms.Spec;
                Write((int)ar.ArrayElemType);
                if (ar.ParamNum != -1)
                {
                    Write(ar.ParamNum);
                }
                if (ar.NumElem != -1)
                {
                    Write(ar.NumElem);
                }
                if (ar.ElemMult != -1)
                {
                    Write(ar.ElemMult);
                }
                break;

            case NativeType.CUSTOMMARSHALER:
                MarshalSig.CustomMarshaler cm = (MarshalSig.CustomMarshaler)ms.Spec;
                Write(cm.Guid);
                Write(cm.UnmanagedType);
                Write(cm.ManagedType);
                Write(cm.Cookie);
                break;

            case NativeType.FIXEDARRAY:
                MarshalSig.FixedArray fa = (MarshalSig.FixedArray)ms.Spec;
                Write(fa.NumElem);
                if (fa.ArrayElemType != NativeType.NONE)
                {
                    Write((int)fa.ArrayElemType);
                }
                break;

            case NativeType.SAFEARRAY:
                Write((int)((MarshalSig.SafeArray)ms.Spec).ArrayElemType);
                break;

            case NativeType.FIXEDSYSSTRING:
                Write(((MarshalSig.FixedSysString)ms.Spec).Size);
                break;
            }
        }
Example #3
0
		public uint AddMarshalSig (MarshalSig ms)
		{
			m_sigWriter.Empty ();
			Write (ms);
			return GetPointer ();
		}
Example #4
0
		void Write (MarshalSig ms)
		{
			Write ((int) ms.NativeInstrinsic);
			switch (ms.NativeInstrinsic) {
			case NativeType.ARRAY :
				MarshalSig.Array ar = (MarshalSig.Array) ms.Spec;
				Write ((int) ar.ArrayElemType);
				if (ar.ParamNum != -1)
					Write (ar.ParamNum);
				if (ar.NumElem != -1)
					Write (ar.NumElem);
				if (ar.ElemMult != -1)
					Write (ar.ElemMult);
				break;
			case NativeType.CUSTOMMARSHALER :
				MarshalSig.CustomMarshaler cm = (MarshalSig.CustomMarshaler) ms.Spec;
				Write (cm.Guid);
				Write (cm.UnmanagedType);
				Write (cm.ManagedType);
				Write (cm.Cookie);
				break;
			case NativeType.FIXEDARRAY :
				MarshalSig.FixedArray fa = (MarshalSig.FixedArray) ms.Spec;
				Write (fa.NumElem);
				if (fa.ArrayElemType != NativeType.NONE)
					Write ((int) fa.ArrayElemType);
				break;
			case NativeType.SAFEARRAY :
				Write ((int) ((MarshalSig.SafeArray) ms.Spec).ArrayElemType);
				break;
			case NativeType.FIXEDSYSSTRING :
				Write (((MarshalSig.FixedSysString) ms.Spec).Size);
				break;
			}
		}
        public MarshalSig GetMarshalSig(MarshalDesc mSpec)
        {
            MarshalSig ms = new MarshalSig (mSpec.NativeIntrinsic);

            if (mSpec is ArrayMarshalDesc) {
                ArrayMarshalDesc amd = mSpec as ArrayMarshalDesc;
                MarshalSig.Array ar = new MarshalSig.Array ();
                ar.ArrayElemType = amd.ElemType;
                ar.NumElem = amd.NumElem;
                ar.ParamNum = amd.ParamNum;
                ar.ElemMult = amd.ElemMult;
                ms.Spec = ar;
            } else if (mSpec is CustomMarshalerDesc) {
                CustomMarshalerDesc cmd = mSpec as CustomMarshalerDesc;
                MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler ();
                cm.Guid = cmd.Guid.ToString ();
                cm.UnmanagedType = cmd.UnmanagedType;
                cm.ManagedType = cmd.ManagedType;
                cm.Cookie = cmd.Cookie;
                ms.Spec = cm;
            } else if (mSpec is FixedArrayDesc) {
                FixedArrayDesc fad = mSpec as FixedArrayDesc;
                MarshalSig.FixedArray fa = new MarshalSig.FixedArray ();
                fa.ArrayElemType  = fad.ElemType;
                fa.NumElem = fad.NumElem;
                ms.Spec = fa;
            } else if (mSpec is FixedSysStringDesc) {
                MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString ();
                fss.Size = (mSpec as FixedSysStringDesc).Size;
                ms.Spec = fss;
            } else if (mSpec is SafeArrayDesc) {
                MarshalSig.SafeArray sa = new MarshalSig.SafeArray ();
                sa.ArrayElemType = (mSpec as SafeArrayDesc).ElemType;
                ms.Spec = sa;
            }

            return ms;
        }
Example #6
0
 protected MarshalSpec BuildMarshalDesc(MarshalSig ms, IHasMarshalSpec container)
 {
     if (ms.Spec is MarshalSig.Array) {
         ArrayMarshalSpec amd = new ArrayMarshalSpec (container);
         MarshalSig.Array ar = (MarshalSig.Array) ms.Spec;
         amd.ElemType = ar.ArrayElemType;
         amd.NumElem = ar.NumElem;
         amd.ParamNum = ar.ParamNum;
         amd.ElemMult = ar.ElemMult;
         return amd;
     } else if (ms.Spec is MarshalSig.CustomMarshaler) {
         CustomMarshalerSpec cmd = new CustomMarshalerSpec (container);
         MarshalSig.CustomMarshaler cmsig = (MarshalSig.CustomMarshaler) ms.Spec;
         cmd.Guid = cmsig.Guid.Length > 0 ? new Guid (cmsig.Guid) : new Guid ();
         cmd.UnmanagedType = cmsig.UnmanagedType;
         cmd.ManagedType = cmsig.ManagedType;
         cmd.Cookie = cmsig.Cookie;
         return cmd;
     } else if (ms.Spec is MarshalSig.FixedArray) {
         FixedArraySpec fad = new FixedArraySpec (container);
         MarshalSig.FixedArray fasig = (MarshalSig.FixedArray) ms.Spec;
         fad.ElemType = fasig.ArrayElemType;
         fad.NumElem = fasig.NumElem;
         return fad;
     } else if (ms.Spec is MarshalSig.FixedSysString) {
         FixedSysStringSpec fssc = new FixedSysStringSpec (container);
         fssc.Size = ((MarshalSig.FixedSysString) ms.Spec).Size;
         return fssc;
     } else if (ms.Spec is MarshalSig.SafeArray) {
         SafeArraySpec sad = new SafeArraySpec (container);
         sad.ElemType = ((MarshalSig.SafeArray) ms.Spec).ArrayElemType;
         return sad;
     } else {
         return new MarshalSpec (ms.NativeInstrinsic, container);
     }
 }
        MarshalSig ReadMarshalSig(byte [] data)
        {
            int        start;
            MarshalSig ms = new MarshalSig((NativeType)Utilities.ReadCompressedInteger(data, 0, out start));

            switch (ms.NativeInstrinsic)
            {
            case NativeType.ARRAY:
                MarshalSig.Array ar = new MarshalSig.Array();
                ar.ArrayElemType = (NativeType)Utilities.ReadCompressedInteger(data, start, out start);
                if (start < data.Length)
                {
                    ar.ParamNum = Utilities.ReadCompressedInteger(data, start, out start);
                }
                if (start < data.Length)
                {
                    ar.NumElem = Utilities.ReadCompressedInteger(data, start, out start);
                }
                if (start < data.Length)
                {
                    ar.ElemMult = Utilities.ReadCompressedInteger(data, start, out start);
                }
                ms.Spec = ar;
                break;

            case NativeType.CUSTOMMARSHALER:
                MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler();
                cm.Guid          = ReadUTF8String(data, start, out start);
                cm.UnmanagedType = ReadUTF8String(data, start, out start);
                cm.ManagedType   = ReadUTF8String(data, start, out start);
                cm.Cookie        = ReadUTF8String(data, start, out start);
                ms.Spec          = cm;
                break;

            case NativeType.FIXEDARRAY:
                MarshalSig.FixedArray fa = new MarshalSig.FixedArray();
                fa.NumElem = Utilities.ReadCompressedInteger(data, start, out start);
                if (start < data.Length)
                {
                    fa.ArrayElemType = (NativeType)Utilities.ReadCompressedInteger(data, start, out start);
                }
                ms.Spec = fa;
                break;

            case NativeType.SAFEARRAY:
                MarshalSig.SafeArray sa = new MarshalSig.SafeArray();
                if (start < data.Length)
                {
                    sa.ArrayElemType = (VariantType)Utilities.ReadCompressedInteger(data, start, out start);
                }
                ms.Spec = sa;
                break;

            case NativeType.FIXEDSYSSTRING:
                MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString();
                if (start < data.Length)
                {
                    fss.Size = Utilities.ReadCompressedInteger(data, start, out start);
                }
                ms.Spec = fss;
                break;
            }
            return(ms);
        }
 public uint AddMarshalSig(MarshalSig ms)
 {
     m_sigWriter.Empty();
     Write(ms);
     return(GetPointer());
 }
Example #9
0
 MarshalSig ReadMarshalSig(byte [] data)
 {
     int start;
     MarshalSig ms = new MarshalSig ((NativeType) Utilities.ReadCompressedInteger (data, 0, out start));
     switch (ms.NativeInstrinsic) {
     case NativeType.ARRAY:
         MarshalSig.Array ar = new MarshalSig.Array ();
         ar.ArrayElemType = (NativeType) Utilities.ReadCompressedInteger (data, start, out start);
         if (start < data.Length)
             ar.ParamNum = Utilities.ReadCompressedInteger (data, start, out start);
         if (start < data.Length)
             ar.NumElem = Utilities.ReadCompressedInteger (data, start, out start);
         if (start < data.Length)
             ar.ElemMult = Utilities.ReadCompressedInteger (data, start, out start);
         ms.Spec = ar;
         break;
     case NativeType.CUSTOMMARSHALER:
         MarshalSig.CustomMarshaler cm = new MarshalSig.CustomMarshaler ();
         cm.Guid = ReadUTF8String (data, start, out start);
         cm.UnmanagedType = ReadUTF8String (data, start, out start);
         cm.ManagedType = ReadUTF8String (data, start, out start);
         cm.Cookie = ReadUTF8String (data, start, out start);
         ms.Spec = cm;
         break;
     case NativeType.FIXEDARRAY:
         MarshalSig.FixedArray fa = new MarshalSig.FixedArray ();
         fa.NumElem = Utilities.ReadCompressedInteger (data, start, out start);
         if (start < data.Length)
             fa.ArrayElemType = (NativeType) Utilities.ReadCompressedInteger (data, start, out start);
         ms.Spec = fa;
         break;
     case NativeType.SAFEARRAY:
         MarshalSig.SafeArray sa = new MarshalSig.SafeArray ();
         if (start < data.Length)
             sa.ArrayElemType = (VariantType) Utilities.ReadCompressedInteger (data, start, out start);
         ms.Spec = sa;
         break;
     case NativeType.FIXEDSYSSTRING:
         MarshalSig.FixedSysString fss = new MarshalSig.FixedSysString ();
         if (start < data.Length)
             fss.Size = Utilities.ReadCompressedInteger (data, start, out start);
         ms.Spec = fss;
         break;
     }
     return ms;
 }