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 StringMarshalInfoWriter(TypeReference type, MarshalType marshalType, MarshalInfo marshalInfo, bool useUnicodeCharSet, bool forByReferenceType, bool forFieldMarshaling) : base(type)
 {
     this._isStringBuilder   = MarshalingUtils.IsStringBuilder(type);
     this._useUnicodeCharSet = useUnicodeCharSet;
     this._nativeType        = DetermineNativeTypeFor(marshalType, marshalInfo, this._useUnicodeCharSet, this._isStringBuilder);
     if (this._nativeType == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean))
     {
         this._marshaledTypeName = "Il2CppHString";
     }
     else if (this.IsWideString)
     {
         this._marshaledTypeName = "Il2CppChar*";
     }
     else
     {
         this._marshaledTypeName = "char*";
     }
     this._marshaledTypes = new MarshaledType[] { new MarshaledType(this._marshaledTypeName, this._marshaledTypeName) };
     this._marshalInfo    = marshalInfo;
     this._canReferenceOriginalManagedString = ((!this._isStringBuilder && !forByReferenceType) && !forFieldMarshaling) && ((this._nativeType == Mono.Cecil.NativeType.LPWStr) || (this._nativeType == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean)));
 }
 public StringMarshalInfoWriter(TypeReference type, MarshalType marshalType, MarshalInfo marshalInfo, bool useUnicodeCharSet, bool forByReferenceType, bool forFieldMarshaling) : base(type)
 {
     this._isStringBuilder = MarshalingUtils.IsStringBuilder(type);
     this._useUnicodeCharSet = useUnicodeCharSet;
     this._nativeType = DetermineNativeTypeFor(marshalType, marshalInfo, this._useUnicodeCharSet, this._isStringBuilder);
     if (this._nativeType == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean))
     {
         this._marshaledTypeName = "Il2CppHString";
     }
     else if (this.IsWideString)
     {
         this._marshaledTypeName = "Il2CppChar*";
     }
     else
     {
         this._marshaledTypeName = "char*";
     }
     this._marshaledTypes = new MarshaledType[] { new MarshaledType(this._marshaledTypeName, this._marshaledTypeName) };
     this._marshalInfo = marshalInfo;
     this._canReferenceOriginalManagedString = ((!this._isStringBuilder && !forByReferenceType) && !forFieldMarshaling) && ((this._nativeType == Mono.Cecil.NativeType.LPWStr) || (this._nativeType == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean)));
 }
 private void FreeMarshaledString(CppCodeWriter writer, string variableName)
 {
     if (!this.IsFixedSizeString)
     {
         Mono.Cecil.NativeType type = this._nativeType;
         if (type == Mono.Cecil.NativeType.BStr)
         {
             object[] objArray1 = new object[] { variableName };
             writer.WriteLine("il2cpp_codegen_marshal_free_bstring({0});", objArray1);
         }
         else if (type == (Mono.Cecil.NativeType.Error | Mono.Cecil.NativeType.Boolean))
         {
             object[] objArray2 = new object[] { variableName };
             writer.WriteLine("il2cpp_codegen_marshal_free_hstring({0});", objArray2);
         }
         else
         {
             object[] objArray3 = new object[] { variableName };
             writer.WriteLine("il2cpp_codegen_marshal_free({0});", objArray3);
         }
         object[] args = new object[] { variableName, DefaultMarshalInfoWriter.Naming.Null };
         writer.WriteLine("{0} = {1};", args);
     }
 }