public virtual void Visit(IParameterDefinition parameterDefinition) { IMarshallingInformation marshalling = parameterDefinition.MarshallingInformation; Debug.Assert((marshalling != null || !parameterDefinition.MarshallingDescriptor.IsDefaultOrEmpty) == parameterDefinition.IsMarshalledExplicitly); this.Visit(parameterDefinition.GetAttributes(Context)); this.Visit(parameterDefinition.CustomModifiers); MetadataConstant defaultValue = parameterDefinition.GetDefaultValue(Context); if (defaultValue != null) { this.Visit((IMetadataExpression)defaultValue); } if (marshalling != null) { // Note, we are not visiting MarshallingDescriptor. It is used only for // NoPia embedded/local types and VB Dev11 simply copies the bits without // cracking them. this.Visit(marshalling); } this.Visit(parameterDefinition.GetType(Context)); }
public override void Visit(IMarshallingInformation marshallingInformation) { if (Process(marshallingInformation)) { visitor.Visit(marshallingInformation); } base.Visit(marshallingInformation); }
public virtual void Visit(IFieldDefinition fieldDefinition) { MetadataConstant constant = fieldDefinition.GetCompileTimeValue(Context); IMarshallingInformation marshalling = fieldDefinition.MarshallingInformation; Debug.Assert((constant != null) == fieldDefinition.IsCompileTimeConstant); Debug.Assert((marshalling != null || !fieldDefinition.MarshallingDescriptor.IsDefaultOrEmpty) == fieldDefinition.IsMarshalledExplicitly); if (constant != null) { this.Visit((IMetadataExpression)constant); } if (marshalling != null) { // Note, we are not visiting MarshallingDescriptor. It is used only for // NoPia embedded/local types and VB Dev11 simply copies the bits without // cracking them. this.Visit(marshalling); } this.Visit(fieldDefinition.GetType(Context)); }
public virtual void onMetadataElement(IMarshallingInformation marshallingInformation) { }
public override void TraverseChildren(IMarshallingInformation marshallingInformation) { base.TraverseChildren(marshallingInformation); }
private void CheckUnmanagedType(IMarshallingInformation marshallingInformation, uint type, string propertyName) { if (type < 0x02 || (0x0c < type && type < 0x13 && type != 0x0f) || type == 0x18 || type == 0x21 || type == 0x27 || type == 0x29 || (0x2d < type && type != 0x50)) { this.ReportError(MetadataError.MarshallingInformationIsInvalid, marshallingInformation, propertyName); } }
private static void EmitStringReturnMarshalling(ILGenerator ilGenerator, IMethodReference ptrToStringAnsi, IMethodReference ptrToStringUnicode, StringFormatKind charSet, IMarshallingInformation returnTypeInfo) { bool doUnicodeMarshalling = false; if (returnTypeInfo != null && returnTypeInfo.UnmanagedType == UnmanagedType.LPWStr) { doUnicodeMarshalling = true; } else if (charSet == StringFormatKind.Unicode) { if (returnTypeInfo == null || (returnTypeInfo.UnmanagedType != UnmanagedType.LPStr && returnTypeInfo.UnmanagedType != UnmanagedType.LPTStr)) { doUnicodeMarshalling = true; } } ilGenerator.Emit(OperationCode.Call, doUnicodeMarshalling ? ptrToStringUnicode : ptrToStringAnsi); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Performs some computation with the given marshalling information. /// </summary> /// <param name="marshallingInformation"></param> public virtual void Visit(IMarshallingInformation marshallingInformation) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(marshallingInformation); if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) this.Visit(marshallingInformation.CustomMarshaller); if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray && (marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_DISPATCH || marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_UNKNOWN || marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_RECORD)) this.Visit(marshallingInformation.SafeArrayElementUserDefinedSubtype); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count. this.path.Pop(); }
/// <summary> /// Traverses the children of the marshalling information. /// </summary> public virtual void TraverseChildren(IMarshallingInformation marshallingInformation) { Contract.Requires(marshallingInformation != null); if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) { this.Traverse(marshallingInformation.CustomMarshaller); if (this.stopTraversal) return; } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray && (marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_DISPATCH || marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_UNKNOWN || marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_RECORD)) this.Traverse(marshallingInformation.SafeArrayElementUserDefinedSubtype); }
/// <summary> /// Performs some computation with the given marshalling information. /// </summary> public virtual void Visit(IMarshallingInformation marshallingInformation) { }
/// <summary> /// Rewrites the given marshalling information. /// </summary> public virtual IMarshallingInformation Rewrite(IMarshallingInformation marshallingInformation) { return marshallingInformation; }
private CustomAttributeBuilder GetMarshalAsAttribute(IMarshallingInformation marshallingInformation) { var marshalAsAttributeType = typeof(System.Runtime.InteropServices.MarshalAsAttribute); var constructor = marshalAsAttributeType.GetConstructor(new Type[] { typeof(System.Runtime.InteropServices.UnmanagedType) }); var arguments = new object[] { marshallingInformation.UnmanagedType }; List<FieldInfo> fields = new List<FieldInfo>(); List<object> fieldValues = new List<object>(); if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValArray || marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) { fields.Add(marshalAsAttributeType.GetField("ArraySubType")); fieldValues.Add(marshallingInformation.ElementType); } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.Interface) { fields.Add(marshalAsAttributeType.GetField("IidParameterIndex")); fieldValues.Add((int)marshallingInformation.IidParameterIndex); } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) { fields.Add(marshalAsAttributeType.GetField("MarshalCookie")); fieldValues.Add(marshallingInformation.CustomMarshallerRuntimeArgument); fields.Add(marshalAsAttributeType.GetField("MarshalTypeRef")); fieldValues.Add(this.loader.mapper.GetType(marshallingInformation.CustomMarshaller)); } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray) { fields.Add(marshalAsAttributeType.GetField("SafeArraySubType")); fieldValues.Add(marshallingInformation.SafeArrayElementSubtype); if (marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_DISPATCH || marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_UNKNOWN || marshallingInformation.SafeArrayElementSubtype == System.Runtime.InteropServices.VarEnum.VT_RECORD) { fields.Add(marshalAsAttributeType.GetField("SafeArrayUserDefinedSubType")); fieldValues.Add(this.loader.mapper.GetType(marshallingInformation.SafeArrayElementUserDefinedSubtype)); } } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValArray || marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValTStr || marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) { fields.Add(marshalAsAttributeType.GetField("SizeConst")); fieldValues.Add((int)marshallingInformation.NumberOfElements); } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray && marshallingInformation.ParamIndex != null) { fields.Add(marshalAsAttributeType.GetField("SizeParamIndex")); fieldValues.Add((short)marshallingInformation.ParamIndex.Value); } return new CustomAttributeBuilder(constructor, arguments, fields.ToArray(), fieldValues.ToArray()); }
public override void Visit(IMarshallingInformation marshallingInformation) { allElements.Add(new InvokInfo(Traverser, "IMarshallingInformation", marshallingInformation)); }
public override void Visit(IMarshallingInformation marshallingInformation) { if(Process(marshallingInformation)){visitor.Visit(marshallingInformation);} base.Visit(marshallingInformation); }
public override void Visit(IMarshallingInformation marshallingInformation) { // The type references in the marshalling information do not end up in tables, but are serialized as strings. }
/// <summary> /// Traverses the marshalling information. /// </summary> public void Traverse(IMarshallingInformation marshallingInformation) { Contract.Requires(marshallingInformation != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(marshallingInformation); if (this.stopTraversal) return; this.TraverseChildren(marshallingInformation); if (this.stopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(marshallingInformation); }
public void MarshallingInformation(IMarshallingInformation marshallInfo) { this.ILDasmPaper.Keyword("marshal"); this.ILDasmPaper.Symbol("("); if (marshallInfo.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) { this.ILDasmPaper.Keyword("custom"); this.ILDasmPaper.Symbol("("); this.ILDasmPaper.Identifier(TypeHelper.GetTypeName(marshallInfo.CustomMarshaller)); this.ILDasmPaper.Symbol(","); this.ILDasmPaper.Identifier(marshallInfo.CustomMarshallerRuntimeArgument); this.ILDasmPaper.Symbol(")"); } else if (marshallInfo.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) { this.UnmanagedType(marshallInfo.ElementType); this.ILDasmPaper.Symbol(","); this.ILDasmPaper.Int((int)marshallInfo.NumberOfElements); this.ILDasmPaper.Symbol(","); this.ILDasmPaper.Int(marshallInfo.ParamIndex == null ? -1 : (int)marshallInfo.ParamIndex.Value); } else if (marshallInfo.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.SafeArray) { this.ILDasmPaper.Identifier(marshallInfo.SafeArrayElementSubtype.ToString()); this.ILDasmPaper.Symbol(","); this.ILDasmPaper.Identifier(TypeHelper.GetTypeName(marshallInfo.SafeArrayElementUserDefinedSubtype)); } else { this.UnmanagedType(marshallInfo.UnmanagedType); } this.ILDasmPaper.Symbol(")"); }
public void Visit(IMarshallingInformation marshallingInformation) { Contract.Assume(false); }
public override void TraverseChildren(IMarshallingInformation marshallingInformation) { MethodEnter(marshallingInformation); base.TraverseChildren(marshallingInformation); MethodExit(); }
/// <summary> /// Performs some computation with the given marshalling information. /// </summary> public void Visit(IMarshallingInformation marshallingInformation) { CheckUnmanagedType(marshallingInformation, (uint)marshallingInformation.UnmanagedType, "UnmanagedType"); if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.CustomMarshaler) { if (marshallingInformation.CustomMarshaller is Dummy) this.ReportError(MetadataError.IncompleteNode, marshallingInformation, "CustomMarshaller"); } if (marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.ByValArray || marshallingInformation.UnmanagedType == System.Runtime.InteropServices.UnmanagedType.LPArray) { CheckUnmanagedType(marshallingInformation, (uint)marshallingInformation.ElementType, "ElementType"); } }
public void Visit(IMarshallingInformation marshallingInformation) { throw new NotImplementedException(); }
public virtual void Visit(IMarshallingInformation marshallingInformation) { throw ExceptionUtilities.Unreachable; }
public override void Visit(IMarshallingInformation marshallingInformation) { // ignore all marshalling information because is is part of implementation, not the api. }