コード例 #1
0
        void AddMethods(InterfaceGen iface, bool shouldObsolete, CodeGenerationOptions opt)
        {
            foreach (var method in iface.Methods.Where(m => m.IsStatic))
            {
                var original = method.Deprecated;

                if (shouldObsolete && string.IsNullOrWhiteSpace(method.Deprecated))
                {
                    method.Deprecated = $"Use '{iface.FullName}.{method.AdjustedName}'. This class will be removed in a future release.";
                }

                Methods.Add(new BoundMethod(iface, method, opt, true));

                var name_and_jnisig     = method.JavaName + method.JniSignature.Replace("java/lang/CharSequence", "java/lang/String");
                var gen_string_overload = !method.IsOverride && method.Parameters.HasCharSequence && !iface.ContainsMethod(name_and_jnisig);

                if (gen_string_overload || method.IsReturnCharSequence)
                {
                    Methods.Add(new BoundMethodStringOverload(method, opt));
                }

                if (method.Asyncify)
                {
                    Methods.Add(new MethodAsyncWrapper(method, opt));
                }

                method.Deprecated = original;
            }
        }
コード例 #2
0
        void AddMethods(InterfaceGen iface, CodeGenerationOptions opt)
        {
            foreach (var m in iface.Methods.Where(m => !m.IsStatic && !m.IsInterfaceDefaultMethod))
            {
                if (m.Name == iface.Name || iface.ContainsProperty(m.Name, true))
                {
                    m.Name = "Invoke" + m.Name;
                }

                Methods.Add(new BoundInterfaceMethodDeclaration(m, iface.AssemblyQualifiedName + "Invoker", opt));
            }

            if (!opt.SupportDefaultInterfaceMethods)
            {
                return;
            }

            foreach (var method in iface.Methods.Where(m => m.IsInterfaceDefaultMethod || m.IsStatic))
            {
                if (!method.IsValid)
                {
                    continue;
                }

                Methods.Add(new BoundMethod(iface, method, opt, true));

                var name_and_jnisig     = method.JavaName + method.JniSignature.Replace("java/lang/CharSequence", "java/lang/String");
                var gen_string_overload = !method.IsOverride && method.Parameters.HasCharSequence && !iface.ContainsMethod(name_and_jnisig);

                if (gen_string_overload || method.IsReturnCharSequence)
                {
                    Methods.Add(new BoundMethodStringOverload(method, opt));
                }

                if (method.Asyncify)
                {
                    Methods.Add(new MethodAsyncWrapper(method, opt));
                }
            }
        }