Ejemplo n.º 1
0
            public RustParameterInfo(RustCodeGen gen, Marshaller.ComMethodParameterInfo cmpi)
            {
                RustCodeGen            = gen;
                ComMethodParameterInfo = cmpi;

                gen.EnqueueTypeGeneration(cmpi.Type);
                NativeName = ComMethodParameterInfo.IsReturnValue ? "retval" :
                             SnakeCaseConverter.Join(DotNetCamelCaseConverter.Split(ComMethodParameterInfo.ParameterInfo.Name)).ToLowerInvariant();
            }
Ejemplo n.º 2
0
            public RustInterfaceMethodInfo(RustCodeGen gen, Marshaller.ComMethodInfo cmi)
            {
                RustCodeGen    = gen;
                ComMethodInfo  = cmi;
                ParameterInfos = cmi.ParameterInfos.Select((pi) => new RustParameterInfo(gen, pi)).ToArray();

                string name = cmi.MethodInfo.Name;

                if (name.StartsWith("get_") || name.StartsWith("set_"))
                {
                    NativeName = name.Substring(0, 4) + SnakeCaseConverter.Join(DotNetPascalCaseConverter.Split(name.Substring(4))).ToLowerInvariant();
                }
                else
                {
                    NativeName = SnakeCaseConverter.Join(DotNetPascalCaseConverter.Split(name)).ToLowerInvariant();
                }

                // Retrieve the documentation entry
                if (gen.options.RustdocEntrySource != null)
                {
                    if (name.StartsWith("get_") || name.StartsWith("set_"))
                    {
                        var prop = cmi.MethodInfo.DeclaringType.GetProperty(name.Substring(4));
                        if (prop != null)
                        {
                            RustdocEntry = gen.options.RustdocEntrySource.GetEntryForProperty(prop,
                                                                                              name.StartsWith("set_"));
                        }
                    }
                    else
                    {
                        RustdocEntry = gen.options.RustdocEntrySource.GetEntryForMethod(cmi.MethodInfo);
                    }
                }

                if (cmi.ReturnsHresult)
                {
                    NativeReturnTypeName = $"{gen.options.NgscomCratePath}::HResult";
                }
                else
                {
                    NativeReturnTypeName = RustCodeGen.TranslateNativeType(cmi.NativeReturnType, false, false);
                }
            }