internal static string BuildMethodParameterList(MethodReference interopMethod, MethodReference interfaceMethod, Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolver, MarshalType marshalType, bool includeTypeNames) { List <string> elements = new List <string>(); int num = 0; foreach (ParameterDefinition definition in interopMethod.Parameters) { MarshalInfo marshalInfo = interfaceMethod.Parameters[num].MarshalInfo; DefaultMarshalInfoWriter writer = MarshalDataCollector.MarshalInfoWriterFor(typeResolver.Resolve(definition.ParameterType), marshalType, marshalInfo, true, false, false, null); foreach (MarshaledType type in writer.MarshaledTypes) { elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0} {1}", type.DecoratedName, Naming.ForParameterName(definition) + type.VariableName)); } num++; } TypeReference reference2 = typeResolver.Resolve(interopMethod.ReturnType); if (reference2.MetadataType != MetadataType.Void) { MarshalInfo info2 = interfaceMethod.MethodReturnType.MarshalInfo; MarshaledType[] marshaledTypes = MarshalDataCollector.MarshalInfoWriterFor(reference2, marshalType, info2, true, false, false, null).MarshaledTypes; for (int i = 0; i < (marshaledTypes.Length - 1); i++) { elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0}* {1}", marshaledTypes[i].DecoratedName, Naming.ForComInterfaceReturnParameterName() + marshaledTypes[i].VariableName)); } elements.Add(string.Format(!includeTypeNames ? "{1}" : "{0}* {1}", marshaledTypes[marshaledTypes.Length - 1].DecoratedName, Naming.ForComInterfaceReturnParameterName())); } return(elements.AggregateWithComma()); }
private static string Sizes(TypeDefinition type) { DefaultMarshalInfoWriter writer = MarshalDataCollector.MarshalInfoWriterFor(type, MarshalType.PInvoke, null, false, false, false, null); object[] args = new object[4]; args[0] = !type.HasGenericParameters ? InstanceSizeFor(type) : "0"; args[1] = !type.HasGenericParameters ? writer.NativeSize : "0"; if (!type.HasGenericParameters && (< > f__am$cacheB == null)) {
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(string.Format("BlittableByReferenceMarshalInfoWriter cannot marshal {0}&.", 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(string.Format("SafeArray type '{0}' has invalid MarshalAsAttribute.", type.FullName)); } if ((this._marshalInfo.ElementType == VariantType.BStr) && (this._elementType.MetadataType != MetadataType.String)) { throw new InvalidOperationException(string.Format("SafeArray(BSTR) type '{0}' has invalid MarshalAsAttribute.", type.FullName)); } NativeType nativeElementType = this.GetNativeElementType(); this._elementTypeMarshalInfoWriter = MarshalDataCollector.MarshalInfoWriterFor(this._elementType, MarshalType.COM, new MarshalInfo(nativeElementType), false, false, false, null); string name = string.Format("Il2CppSafeArray/*{0}*/*", this._marshalInfo.ElementType.ToString().ToUpper()); this._marshaledTypes = new MarshaledType[] { new MarshaledType(name, name) }; }
public void WriteMethodBody(CppCodeWriter writer, IRuntimeMetadataAccess metadataAccess) { DefaultMarshalInfoWriter writer2 = this.FirstOrDefaultUnmarshalableMarshalInfoWriter(); if (writer2 != null) { writer.WriteStatement(Emit.RaiseManagedException(writer2.GetMarshalingException())); } else { foreach (MarshaledParameter parameter in this._parameters) { this.MarshalInfoWriterFor(parameter).WriteIncludesForMarshaling(writer); } this.MarshalInfoWriterFor(this.GetMethodReturnType()).WriteIncludesForMarshaling(writer); this.WriteMethodBodyImpl(writer, metadataAccess); } }
protected string GetFunctionCallParametersExpression(string[] localVariableNames) { List <string> elements = new List <string>(); for (int i = 0; i < localVariableNames.Length; i++) { DefaultMarshalInfoWriter writer = base.MarshalInfoWriterFor(base._parameters[i]); foreach (MarshaledType type in writer.MarshaledTypes) { string marshaledVariableName = localVariableNames[i] + type.VariableName; string item = writer.DecorateVariable(base._parameters[i].NameInGeneratedCode, marshaledVariableName); elements.Add(item); } } DefaultMarshalInfoWriter writer2 = base.MarshalInfoWriterFor(this.GetMethodReturnType()); MarshaledType[] marshaledTypes = base.MarshalInfoWriterFor(this.GetMethodReturnType()).MarshaledTypes; for (int j = 0; j < (marshaledTypes.Length - 1); j++) { string str3 = InteropMethodBodyWriter.Naming.ForInteropReturnValue() + marshaledTypes[j].VariableName; elements.Add("&" + writer2.DecorateVariable(null, str3)); } return(elements.AggregateWithComma()); }
private static string FormatIl2CppMarshalingFunction(TypeDefinition marshalableType) { DefaultMarshalInfoWriter writer = MarshalDataCollector.MarshalInfoWriterFor(marshalableType, MarshalType.PInvoke, null, false, false, false, null); return($"{{ {writer.MarshalToNativeFunctionName}, {writer.MarshalFromNativeFunctionName}, {writer.MarshalCleanupFunctionName} }}"); }
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) {