コード例 #1
0
        public static IEnumerable <string> GetPackageNames(Declaration decl)
        {
            var namespaces = Declaration.GatherNamespaces(decl.Namespace)
                             .Where(ns => !(ns is TranslationUnit));

            return(namespaces.Select(n => n.Name.ToLowerInvariant()));
        }
コード例 #2
0
        public static IEnumerable <string> GetPackageNames(Declaration decl)
        {
            var namespaces = Declaration.GatherNamespaces(decl.Namespace)
                             .ToList();

            namespaces.Remove(namespaces.First());

            return(namespaces.Select(n => n.Name.ToLowerInvariant()));
        }
コード例 #3
0
        public static IEnumerable<string> GetPackageNames(Declaration decl)
        {
            var namespaces = Declaration.GatherNamespaces(decl.Namespace)
                .Where(ns => !(ns is TranslationUnit));

            var names = namespaces.Select(n => n.Name.ToLowerInvariant()).ToList();
            names.Insert(0, JavaGenerator.GetNativeLibPackageName(decl.TranslationUnit));

            return names;
        }
コード例 #4
0
        public void GenerateClassLookup(Class @class)
        {
            PushBlock();

            var classLookupId = GeneratedIdentifier(string.Format("lookup_class_{0}",
                                                                  @class.QualifiedName.Replace('.', '_')));

            WriteLine("static void {0}()", classLookupId);
            WriteStartBraceIndent();

            var classId = string.Format("{0}_class", @class.QualifiedName);

            WriteLine("if ({0} == 0)", classId);
            WriteStartBraceIndent();

            WriteLine("{0}();", GeneratedIdentifier("initialize_mono"));

            var assemblyName     = Unit.FileName;
            var assemblyLookupId = GeneratedIdentifier(string.Format("lookup_assembly_{0}",
                                                                     assemblyName.Replace('.', '_')));

            WriteLine("{0}();", assemblyLookupId);

            var namespaces = Declaration.GatherNamespaces(@class.Namespace).ToList();

            namespaces.Reverse();
            namespaces.Remove(namespaces.First());

            var @namespace = string.Join(".", namespaces);
            var ids        = string.Join(", ",
                                         @class.QualifiedName.Split('.').Select(n => string.Format("\"{0}\"", n)));

            var monoImageName = string.Format("{0}_image", AssemblyId);

            WriteLine("{0} = mono_class_from_name({1}, \"{2}\", \"{3}\");",
                      classId, monoImageName, @namespace, @class.OriginalName);
            WriteCloseBraceIndent();
            WriteCloseBraceIndent();

            PopBlock(NewLineKind.BeforeNextBlock);
        }
コード例 #5
0
        public static string GenerateMonoClassFromNameCall(Declaration decl)
        {
            var namespaces = Declaration.GatherNamespaces(decl.Namespace)
                             .Where(ns => !(ns is TranslationUnit));

            var @namespace = string.Join(".", namespaces);
            var ids        = string.Join(", ",
                                         decl.QualifiedName.Split('.').Select(n => string.Format("\"{0}\"", n)));

            var monoImageName = string.Format("{0}_image", CGenerator.AssemblyId(decl.TranslationUnit));
            var managedName   = decl.ManagedQualifiedName();

            var dotIndex = managedName.LastIndexOf(".", StringComparison.Ordinal);

            if (dotIndex > 0)
            {
                managedName = managedName.Substring(managedName.LastIndexOf(".", StringComparison.Ordinal) + 1);
            }

            return($"mono_class_from_name({monoImageName}, \"{@namespace}\", \"{managedName}\");");
        }
コード例 #6
0
        public void GenerateClassLookup(Class @class)
        {
            PushBlock();

            var classLookupId = GeneratedIdentifier($"lookup_class_{@class.QualifiedName.Replace('.', '_')}");

            WriteLine("static void {0}()", classLookupId);
            WriteStartBraceIndent();

            var classId = $"{@class.Name}::class_{@class.QualifiedName}";

            WriteLine($"if ({classId} == 0)");
            WriteStartBraceIndent();

            WriteLine($"{GeneratedIdentifier("initialize_mono")}();");

            var assemblyName     = Unit.FileName;
            var assemblyLookupId = GeneratedIdentifier($"lookup_assembly_{assemblyName.Replace('.', '_')}");

            WriteLine($"{assemblyLookupId}();");

            var namespaces = Declaration.GatherNamespaces(@class.Namespace)
                             .Where(ns => !(ns is TranslationUnit));

            var @namespace = string.Join(".", namespaces);
            var ids        = string.Join(", ",
                                         @class.QualifiedName.Split('.').Select(n => string.Format("\"{0}\"", n)));

            var monoImageName = string.Format("{0}_image", AssemblyId);

            WriteLine("{0} = mono_class_from_name({1}, \"{2}\", \"{3}\");",
                      classId, monoImageName, @namespace, @class.OriginalName);
            WriteCloseBraceIndent();
            WriteCloseBraceIndent();

            PopBlock(NewLineKind.BeforeNextBlock);
        }