protected ArrayMarshalInfoWriter(ArrayType type, MarshalType marshalType, MarshalInfo marshalInfo) : base(type) { this._marshalInfo = marshalInfo; this._marshalType = marshalType; this._arrayType = type; this._elementType = type.ElementType; MarshalInfo info = null; ArrayMarshalInfo info2 = marshalInfo as ArrayMarshalInfo; FixedArrayMarshalInfo info3 = marshalInfo as FixedArrayMarshalInfo; this._arraySize = 1; this._nativeElementType = NativeType.None; if (info2 != null) { this._arraySize = info2.Size; this._sizeParameterIndex = info2.SizeParameterIndex; if ((this._arraySize == 0) || ((this._arraySize == -1) && (this._sizeParameterIndex >= 0))) { this._arraySizeSelection = ArraySizeOptions.UseSizeParameterIndex; } else { this._arraySizeSelection = ArraySizeOptions.UseArraySize; } this._nativeElementType = info2.ElementType; info = new MarshalInfo(this._nativeElementType); } else if (info3 != null) { this._arraySize = info3.Size; this._nativeElementType = info3.ElementType; info = new MarshalInfo(this._nativeElementType); } if (this._arraySize == -1) { this._arraySize = 1; } this._elementTypeMarshalInfoWriter = MarshalDataCollector.MarshalInfoWriterFor(this._elementType, marshalType, info, false, false, true, null); if (this._elementTypeMarshalInfoWriter.MarshaledTypes.Length > 1) { throw new InvalidOperationException($"ArrayMarshalInfoWriter cannot marshal arrays of {this._elementType.FullName}."); } this._arrayMarshaledTypeName = this._elementTypeMarshalInfoWriter.MarshaledTypes[0].DecoratedName + "*"; if (marshalType == MarshalType.WindowsRuntime) { string name = DefaultMarshalInfoWriter.Naming.ForVariable(DefaultMarshalInfoWriter.TypeProvider.UInt32TypeReference); this._arraySizeSelection = ArraySizeOptions.UseFirstMarshaledType; this._marshaledTypes = new MarshaledType[] { new MarshaledType(name, name, "ArraySize"), new MarshaledType(this._arrayMarshaledTypeName, this._arrayMarshaledTypeName) }; } else { this._marshaledTypes = new MarshaledType[] { new MarshaledType(this._arrayMarshaledTypeName, this._arrayMarshaledTypeName) }; } StringMarshalInfoWriter writer = this._elementTypeMarshalInfoWriter as StringMarshalInfoWriter; if (writer != null) { this._nativeElementType = writer.NativeType; } }
public override string WriteMarshalEmptyVariableFromNative(CppCodeWriter writer, string variableName, IList <MarshaledParameter> methodParameters, IRuntimeMetadataAccess metadataAccess) { string name = $"_{DefaultMarshalInfoWriter.CleanVariableName(variableName)}_empty"; writer.WriteVariable(this._elementType, name); return(DefaultMarshalInfoWriter.Naming.AddressOf(name)); }
public override string WriteMarshalVariableFromNative(CppCodeWriter writer, string variableName, IList <MarshaledParameter> methodParameters, bool returnValue, bool forNativeWrapperOfManagedMethod, IRuntimeMetadataAccess metadataAccess) { string marshaledVariableName = variableName.Replace("*", ""); string unmarshaledVariableName = $"_{DefaultMarshalInfoWriter.CleanVariableName(variableName)}_unmarshaled"; this.WriteDeclareAndAllocateObject(writer, unmarshaledVariableName, marshaledVariableName, metadataAccess); this.WriteMarshalVariableFromNative(writer, variableName, new ManagedMarshalValue(unmarshaledVariableName), methodParameters, returnValue, forNativeWrapperOfManagedMethod, metadataAccess); return(unmarshaledVariableName); }
public BlittableByReferenceMarshalInfoWriter(ByReferenceType type, MarshalType marshalType, MarshalInfo marshalInfo) : base(type) { this._elementType = type.ElementType; this._elementTypeMarshalInfoWriter = MarshalDataCollector.MarshalInfoWriterFor(this._elementType, marshalType, marshalInfo, false, true, false, null); if (this._elementTypeMarshalInfoWriter.MarshaledTypes.Length > 1) { throw new InvalidOperationException($"BlittableByReferenceMarshalInfoWriter cannot marshal {type.ElementType.FullName}&."); } this._marshaledTypes = new MarshaledType[] { new MarshaledType(this._elementTypeMarshalInfoWriter.MarshaledTypes[0].Name + "*", this._elementTypeMarshalInfoWriter.MarshaledTypes[0].DecoratedName + "*") }; }
public ComSafeArrayMarshalInfoWriter(ArrayType type, MarshalInfo marshalInfo) : base(type) { this._elementType = type.ElementType; this._marshalInfo = marshalInfo as SafeArrayMarshalInfo; if (this._marshalInfo == null) { throw new InvalidOperationException($"SafeArray type '{type.FullName}' has invalid MarshalAsAttribute."); } if ((this._marshalInfo.ElementType == VariantType.BStr) && (this._elementType.MetadataType != MetadataType.String)) { throw new InvalidOperationException($"SafeArray(BSTR) type '{type.FullName}' has invalid MarshalAsAttribute."); } NativeType nativeElementType = this.GetNativeElementType(); this._elementTypeMarshalInfoWriter = MarshalDataCollector.MarshalInfoWriterFor(this._elementType, MarshalType.COM, new MarshalInfo(nativeElementType), false, false, false, null); string name = $"Il2CppSafeArray/*{this._marshalInfo.ElementType.ToString().ToUpper()}*/*"; this._marshaledTypes = new MarshaledType[] { new MarshaledType(name, name) }; }
public ByReferenceMarshalInfoWriter(ByReferenceType type, MarshalType marshalType, MarshalInfo marshalInfo) : base(type) { this._elementType = type.ElementType; this._elementTypeMarshalInfoWriter = MarshalDataCollector.MarshalInfoWriterFor(type.ElementType, marshalType, marshalInfo, false, true, false, null); if (< > f__am$cache0 == null) {