private void WriteMarshalToNativeForNonSealedType(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string destinationVariable) { object[] args = new object[] { sourceVariable.Load() }; writer.WriteLine("if (({0})->klass->is_import_or_windows_runtime)", args); using (new BlockWriter(writer, false)) { if (this._isClass) { object[] objArray2 = new object[] { destinationVariable, sourceVariable.Load(), DefaultMarshalInfoWriter.Naming.ForComTypeInterfaceFieldGetter(this._defaultInterface) }; writer.WriteLine("{0} = ({1})->{2}();", objArray2); object[] objArray3 = new object[] { destinationVariable }; writer.WriteLine("{0}->AddRef();", objArray3); } else { object[] objArray4 = new object[] { DefaultMarshalInfoWriter.Naming.ForInteropHResultVariable(), DefaultMarshalInfoWriter.Naming.ForVariable(DefaultMarshalInfoWriter.TypeProvider.Il2CppComObjectTypeReference), sourceVariable.Load(), DefaultMarshalInfoWriter.Naming.ForIl2CppComObjectIdentityField(), this._interfaceTypeName, destinationVariable }; writer.WriteLine("il2cpp_hresult_t {0} = (({1}){2})->{3}->QueryInterface({4}::IID, reinterpret_cast<void**>(&{5}));", objArray4); writer.WriteStatement(Emit.Call("il2cpp_codegen_com_raise_exception_if_failed", DefaultMarshalInfoWriter.Naming.ForInteropHResultVariable())); } } writer.WriteLine("else"); using (new BlockWriter(writer, false)) { object[] objArray5 = new object[] { destinationVariable, this._interfaceTypeName, sourceVariable.Load() }; writer.WriteLine("{0} = il2cpp_codegen_com_get_or_create_ccw<{1}>({2});", objArray5); } }
public override string WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess) { if (DefaultMarshalInfoWriter.Naming.ForVariable(base._typeRef) != this._marshaledTypes[0].DecoratedName) { return string.Format("reinterpret_cast<{0}>({1})", this._marshaledTypes[0].DecoratedName, sourceVariable.Load()); } return sourceVariable.Load(); }
public override void WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string destinationVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess) { object[] args = new object[] { sourceVariable.Load(), destinationVariable }; writer.WriteLine("il2cpp_codegen_com_marshal_variant((Il2CppCodeGenObject*)({0}), &({1}));", args); }
public override void WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string destinationVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess) { if (this._marshalInfo.ElementType == VariantType.BStr) { object[] args = new object[] { destinationVariable, sourceVariable.Load() }; writer.WriteLine("{0} = il2cpp_codegen_com_marshal_safe_array_bstring({1});", args); } else { object[] objArray2 = new object[] { destinationVariable, this._marshalInfo.ElementType.ToString().ToUpper(), sourceVariable.Load() }; writer.WriteLine("{0} = il2cpp_codegen_com_marshal_safe_array(IL2CPP_VT_{1}, {2});", objArray2); } }
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 void WriteMarshalVariableFromNative(CppCodeWriter writer, string variableName, ManagedMarshalValue destinationVariable, IList<MarshaledParameter> methodParameters, bool returnValue, bool forNativeWrapperOfManagedMethod, IRuntimeMetadataAccess metadataAccess) { string str; if (this._isStringBuilder) { str = !this.IsWideString ? "il2cpp_codegen_marshal_string_builder_result" : "il2cpp_codegen_marshal_wstring_builder_result"; object[] args = new object[] { str, destinationVariable.Load(), variableName }; writer.WriteLine("{0}({1}, {2});", args); } else { Mono.Cecil.NativeType type = this._nativeType; if (type == Mono.Cecil.NativeType.BStr) { str = "il2cpp_codegen_marshal_bstring_result"; } else if (type == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean)) { str = "il2cpp_codegen_marshal_hstring_result"; } else { str = !this.IsWideString ? "il2cpp_codegen_marshal_string_result" : "il2cpp_codegen_marshal_wstring_result"; } object[] objArray2 = new object[] { str, variableName }; writer.WriteLine(destinationVariable.Store("{0}({1})", objArray2)); } }
public sealed override void WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string destinationVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess) { object[] args = new object[] { sourceVariable.Load(), DefaultMarshalInfoWriter.Naming.Null }; writer.WriteLine("if ({0} != {1})", args); using (new BlockWriter(writer, false)) { if (this._isSealed) { object[] objArray2 = new object[] { destinationVariable, sourceVariable.Load(), DefaultMarshalInfoWriter.Naming.ForComTypeInterfaceFieldGetter(this._defaultInterface) }; writer.WriteLine("{0} = ({1})->{2}();", objArray2); } else { this.WriteMarshalToNativeForNonSealedType(writer, sourceVariable, destinationVariable); } } writer.WriteLine("else"); using (new BlockWriter(writer, false)) { object[] objArray3 = new object[] { destinationVariable, DefaultMarshalInfoWriter.Naming.Null }; writer.WriteLine("{0} = {1};", objArray3); } }
public override void WriteMarshalVariableToNative(CppCodeWriter writer, ManagedMarshalValue sourceVariable, string destinationVariable, string managedVariableName, IRuntimeMetadataAccess metadataAccess) { object[] args = new object[] { destinationVariable, sourceVariable.Load() }; writer.WriteLine("{0} = il2cpp_codegen_marshal_delegate(reinterpret_cast<Il2CppCodeGenMulticastDelegate*>({1}));", args); }