public sealed override string WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess) { string variableName = string.Format("_{0}_marshaled", sourceVariable.GetNiceName()); this.WriteNativeVariableDeclarationOfType(writer, variableName); this.WriteMarshalVariableToNative(writer, sourceVariable, variableName, managedVariableName, metadataAccess); return variableName; }
private void WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string destinationVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess, bool isMarshalingReturnValue) { string str; if (this._nativeType == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean)) { object[] args = new object[] { sourceVariable.Load(), DefaultMarshalInfoWriter.Naming.Null }; writer.WriteLine("if ({0} == {1})", args); using (new BlockWriter(writer, false)) { object[] arguments = new object[] { !string.IsNullOrEmpty(managedVariableName) ? managedVariableName : sourceVariable.GetNiceName() }; writer.WriteStatement(Emit.RaiseManagedException("il2cpp_codegen_get_argument_null_exception(\"{0}\")", arguments)); } } if (this.IsFixedSizeString) { str = !this.IsWideString ? "il2cpp_codegen_marshal_string_fixed" : "il2cpp_codegen_marshal_wstring_fixed"; object[] objArray3 = new object[] { str, sourceVariable.Load(), this._marshaledTypeName, destinationVariable, ((FixedSysStringMarshalInfo) this._marshalInfo).Size }; writer.WriteLine("{0}({1}, ({2})&{3}, {4});", objArray3); } else if (this._canReferenceOriginalManagedString && !isMarshalingReturnValue) { if (this._nativeType != Mono.Cecil.NativeType.LPWStr) { if (this._nativeType != (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean)) { throw new InvalidOperationException(string.Format("StringMarshalInfoWriter doesn't know how to marshal {0} while maintaining reference to original managed string.", this._nativeType)); } string niceName = sourceVariable.GetNiceName(); string str4 = niceName + "NativeView"; string str5 = niceName + "HStringReference"; writer.WriteLine(); object[] objArray6 = new object[] { str4, sourceVariable.Load() }; writer.WriteLine("DECLARE_IL2CPP_STRING_AS_STRING_VIEW_OF_NATIVE_CHARS({0}, {1});", objArray6); object[] objArray7 = new object[] { str5, str4 }; writer.WriteLine("il2cpp::utils::Il2CppHStringReference {0}({1});", objArray7); object[] objArray8 = new object[] { destinationVariable, str5 }; writer.WriteLine("{0} = {1};", objArray8); } else { string str2 = sourceVariable.Load(); object[] objArray4 = new object[] { str2, DefaultMarshalInfoWriter.Naming.Null }; writer.WriteLine("if ({0} != {1})", objArray4); using (new BlockWriter(writer, false)) { if (<>f__am$cache0 == null) {
public override string WriteMarshalEmptyVariableToNative(CppCodeWriter writer, ManagedMarshalValue variableName, IList<MarshaledParameter> methodParameters) { string str = string.Format("_{0}_empty", variableName.GetNiceName()); this._elementTypeMarshalInfoWriter.WriteNativeVariableDeclarationOfType(writer, str); return DefaultMarshalInfoWriter.Naming.AddressOf(str); }
public override string WriteMarshalEmptyVariableToNative(CppCodeWriter writer, ManagedMarshalValue variableName, IList<MarshaledParameter> methodParameters) { string str = string.Format("_{0}_marshaled", variableName.GetNiceName()); this.WriteNativeVariableDeclarationOfType(writer, str); return str; }