コード例 #1
0
        uint WriteJavaMapEntry(StreamWriter output, TypeMapGenerator.TypeMapReleaseEntry entry, int entryIndex, ref uint extra_padding)
        {
            uint size = 0;

            WriteCommentLine(output, $"#{entryIndex}");
            WriteCommentLine(output, "module_index");
            size += WriteData(output, entry.ModuleIndex);

            WriteCommentLine(output, "type_token_id");
            size += WriteData(output, entry.SkipInJavaToManaged ? 0 : entry.Token);

            WriteCommentLine(output, "java_name");
            size += WriteAsciiData(output, entry.JavaName, mappingData.JavaNameWidth);

            if (extra_padding == 0)
            {
                extra_padding = size % (1U << (int)TargetProvider.MapJavaAlignBits);
            }

            size += WriteDataPadding(output, extra_padding);

            output.WriteLine();

            return(size);
        }
コード例 #2
0
        public NativeTypeMappingData(Action <string> logger, TypeMapGenerator.ModuleReleaseData[] modules, int javaNameWidth)
        {
            Modules = modules ?? throw new ArgumentNullException(nameof(modules));

            MapModuleCount = (uint)modules.Length;
            JavaNameWidth  = (uint)javaNameWidth;

            AssemblyNames = new Dictionary <string, string> (StringComparer.Ordinal);

            var tempJavaTypes        = new Dictionary <string, TypeMapGenerator.TypeMapReleaseEntry> (StringComparer.Ordinal);
            int managedStringCounter = 0;
            var moduleComparer       = new TypeMapGenerator.ModuleUUIDArrayComparer();

            foreach (TypeMapGenerator.ModuleReleaseData data in modules)
            {
                data.AssemblyNameLabel = $"map_aname.{managedStringCounter++}";
                AssemblyNames.Add(data.AssemblyNameLabel, data.AssemblyName);

                int moduleIndex = Array.BinarySearch(modules, data, moduleComparer);
                if (moduleIndex < 0)
                {
                    throw new InvalidOperationException($"Unable to map module with MVID {data.Mvid} to array index");
                }

                foreach (TypeMapGenerator.TypeMapReleaseEntry entry in data.Types)
                {
                    entry.ModuleIndex = moduleIndex;
                    if (tempJavaTypes.ContainsKey(entry.JavaName))
                    {
                        continue;
                    }
                    tempJavaTypes.Add(entry.JavaName, entry);
                }
            }

            var javaNames = tempJavaTypes.Keys.ToArray();

            Array.Sort(javaNames, StringComparer.Ordinal);

            var javaTypes = new TypeMapGenerator.TypeMapReleaseEntry[javaNames.Length];

            for (int i = 0; i < javaNames.Length; i++)
            {
                javaTypes[i] = tempJavaTypes[javaNames[i]];
            }

            JavaTypes     = javaTypes;
            JavaTypeNames = javaNames;
            JavaTypeCount = (uint)JavaTypes.Length;
        }
        uint WriteJavaMapEntry(StreamWriter output, TypeMapGenerator.TypeMapReleaseEntry entry, int entryIndex)
        {
            uint size = 0;

            WriteCommentLine(output, $"#{entryIndex}");
            WriteCommentLine(output, "module_index");
            size += WriteData(output, entry.ModuleIndex);

            WriteCommentLine(output, "type_token_id");
            size += WriteData(output, entry.SkipInJavaToManaged ? 0 : entry.Token);

            WriteCommentLine(output, "java_name");
            size += WriteAsciiData(output, entry.JavaName, mappingData.JavaNameWidth);

            output.WriteLine();

            return(size);
        }