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());
        }
Пример #2
0
        protected InteropMethodBodyWriter(MethodReference interopMethod, MethodReference methodForParameterNames, InteropMarshaler marshaler)
        {
            this._typeResolver  = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(interopMethod.DeclaringType, interopMethod);
            this._interopMethod = interopMethod;
            this._marshaler     = marshaler;
            MethodDefinition definition = this._interopMethod.Resolve();

            this._parameters = new MarshaledParameter[definition.Parameters.Count];
            for (int i = 0; i < definition.Parameters.Count; i++)
            {
                ParameterDefinition definition2   = definition.Parameters[i];
                TypeReference       parameterType = this._typeResolver.Resolve(definition2.ParameterType);
                this._parameters[i] = new MarshaledParameter(methodForParameterNames.Parameters[i].Name, Naming.ForParameterName(methodForParameterNames.Parameters[i]), parameterType, definition2.MarshalInfo, definition2.IsIn, definition2.IsOut);
            }
            List <MarshaledType> list = new List <MarshaledType>();

            foreach (MarshaledParameter parameter in this._parameters)
            {
                foreach (MarshaledType type in this.MarshalInfoWriterFor(parameter).MarshaledTypes)
                {
                    list.Add(new MarshaledType(type.Name, type.DecoratedName, parameter.NameInGeneratedCode + type.VariableName));
                }
            }
            MarshaledType[] marshaledTypes = this.MarshalInfoWriterFor(this.GetMethodReturnType()).MarshaledTypes;
            for (int j = 0; j < (marshaledTypes.Length - 1); j++)
            {
                MarshaledType type2 = marshaledTypes[j];
                list.Add(new MarshaledType(type2.Name + "*", type2.DecoratedName + "*", Naming.ForComInterfaceReturnParameterName() + type2.VariableName));
            }
            this._marshaledParameterTypes = list.ToArray();
            this._marshaledReturnType     = marshaledTypes[marshaledTypes.Length - 1];
        }