Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added resources/tables/CR_L1.bin
Binary file not shown.
Binary file added resources/tables/CR_LD.bin
Binary file not shown.
Binary file added resources/tables/CR_javaAlphabetic.bin
Binary file not shown.
Binary file added resources/tables/CR_javaDefined.bin
Binary file not shown.
Binary file added resources/tables/CR_javaDigit.bin
Binary file not shown.
Binary file added resources/tables/CR_javaISOControl.bin
Binary file not shown.
Binary file added resources/tables/CR_javaIdentifierIgnorable.bin
Binary file not shown.
Binary file added resources/tables/CR_javaIdeographic.bin
Binary file not shown.
Binary file added resources/tables/CR_javaJavaIdentifierPart.bin
Binary file not shown.
Binary file added resources/tables/CR_javaJavaIdentifierStart.bin
Binary file not shown.
Binary file added resources/tables/CR_javaLetter.bin
Binary file not shown.
Binary file added resources/tables/CR_javaLetterOrDigit.bin
Binary file not shown.
Binary file added resources/tables/CR_javaLowerCase.bin
Binary file not shown.
Binary file added resources/tables/CR_javaMirrored.bin
Binary file not shown.
Binary file added resources/tables/CR_javaSpaceChar.bin
Binary file not shown.
Binary file added resources/tables/CR_javaTitleCase.bin
Binary file not shown.
Binary file added resources/tables/CR_javaUnicodeIdentifierPart.bin
Binary file not shown.
Binary file not shown.
Binary file added resources/tables/CR_javaUpperCase.bin
Binary file not shown.
Binary file added resources/tables/CR_javaWhitespace.bin
Binary file not shown.
Binary file added resources/tables/CR_perlHorizontalWhiteSpace.bin
Binary file not shown.
Binary file added resources/tables/CR_perlVerticalWhiteSpace.bin
Binary file not shown.
38 changes: 19 additions & 19 deletions scripts/ExtractTables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
enc_path = "#{repo_path}/enc"
folds_src = open("#{enc_path}/unicode.c").read
unicode_src = open("#{enc_path}/unicode/name2ctype.src").read
additional_unicode_src = open("additional_name2ctype.src").read

dst_dir = "../src/org/jcodings"
dst_bin_dir = "../resources/tables"
Expand Down Expand Up @@ -72,7 +73,8 @@ def extract_to to, file
end
end

unicode_src.scan(/static\s+const\s+(\w+)\s+(\w+)\[\]\s+=\s+\{(.*?)\}\;/m).each do |(type, name, tab)|
(unicode_src.scan(/static\s+const\s+(\w+)\s+(\w+)\[\]\s+=\s+\{(.*?)\}\;/m) +
additional_unicode_src.scan(/static\s+const\s+(\w+)\s+(\w+)\[\]\s+=\s+\{(.*?)\}\;/m)).each do |(type, name, tab)|
tab = tab.split(",").map { |e| e.strip }
assert_eq(tab.last, "")
tab.pop
Expand All @@ -96,34 +98,32 @@ def extract_to to, file
end


cr_map = unicode_src.scan(/#define (CR_.*?) (.*)/).inject(Hash.new { |h, k| k }) { |h, (k, v)| h[k] = v; h }
cr_map = (unicode_src.scan(/#define (CR_.*?) (.*)/) + additional_unicode_src.scan(/#define (CR_.*?) (.*)/)).inject(Hash.new { |h, k| k }) { |h, (k, v)| h[k] = v; h }

aliases = unicode_src[/%%(.*?)%%/m, 1].scan(/(.*?),\s+(\d+)/).inject(Hash.new { |h, k| h[k] = [] }) { |h, (name, num)| h[num.to_i] << name; h }.inject({}) do |h, (k, v)|
full, *abbr = v.map { |e| e.strip }
h[full] = abbr
h
end

unicode_src.scan(/CodeRanges\[\]\s+=\s+\{(.*?)\}\;/m) do |e|
names = e.first.scan(/CR_\w+/)
e = unicode_src.scan(/CodeRanges\[\]\s+=\s+\{(.*?)\}\;/m)[0][0] + additional_unicode_src.scan(/CodeRanges\[\]\s+=\s+\{(.*?)\}\;/m)[0][0]

cnames = names.map do |c|
n = c[/CR_(.*)/, 1]
px = case n
when /Age_(\d)_(\d)/
"age=#{$1}.#{$2}"
else
n.tr('_', '').downcase
end
cnames = e.scan(/CR_\w+/).map do |c|
n = c[/CR_(.*)/, 1]
px = case n
when /Age_(\d)_(\d)/
"age=#{$1}.#{$2}"
else
n.tr('_', '').downcase
end

([px] + aliases[px].to_a).map { |n| "#{INDENT * 4}new CodeRangeEntry(\"#{n}\", \"#{cr_map[c]}\")" }.join(",\n")
end
([px] + aliases[px].to_a).map { |n| "#{INDENT * 4}new CodeRangeEntry(\"#{n}\", \"#{cr_map[c]}\")" }.join(",\n")
end

open("#{enc_dir}/UnicodeProperties.java", "wb") do |f|
f << open("UnicodePropertiesTemplate.java", "rb").read.
sub(/%\{stdcrs\}/, cnames[0..14].join(",\n")).
sub(/%\{extcrs\}/, cnames.join(",\n"))
end
open("#{enc_dir}/UnicodeProperties.java", "wb") do |f|
f << open("UnicodePropertiesTemplate.java", "rb").read.
sub(/%\{stdcrs\}/, cnames[0..14].join(",\n")).
sub(/%\{extcrs\}/, cnames.join(",\n"))
end

enc_db = open("#{repo_path}/encdb.h").read.tr('()', '').scan(/ENC_([A-Z_]+)(.*?);/m).reject { |a, b| a =~ /DEFINE/ }
Expand Down
Loading