| ... | ... | @@ -9,7 +9,21 @@ const ucd = @import("./lib.zig"); |
| 9 | 9 | const std = @import("std"); |
| 10 | 10 | const extras = @import("extras"); |
| 11 | 11 | |
| 12 | | pub const data_soa = extras.StaticMultiList(Codepoint).initComptime(&data).items; |
| 12 | const data_soa = extras.StaticMultiList(Codepoint).initComptime(&data).items; |
| 13 | pub const data_code = data_soa[0][0..].*; |
| 14 | pub const data_name = data_soa[1][0..].*; |
| 15 | pub const data_gc = data_soa[2][0..].*; |
| 16 | pub const data_ccc = data_soa[3][0..].*; |
| 17 | pub const data_bc = data_soa[4][0..].*; |
| 18 | pub const data_decomp = data_soa[5][0..].*; |
| 19 | pub const data_decomp_map = data_soa[6][0..].*; |
| 20 | pub const data_nt_dec = data_soa[7][0..].*; |
| 21 | pub const data_nt_dig = data_soa[8][0..].*; |
| 22 | pub const data_nt_num = data_soa[9][0..].*; |
| 23 | pub const data_bm = data_soa[10][0..].*; |
| 24 | pub const data_sum = data_soa[11][0..].*; |
| 25 | pub const data_slm = data_soa[12][0..].*; |
| 26 | pub const data_stm = data_soa[13][0..].*; |
| 13 | 27 | |
| 14 | 28 | pub const Codepoint = struct { |
| 15 | 29 | u21, // U+ code |
| ... | ... | @@ -49,8 +63,8 @@ pub const Decomposition = enum { |
| 49 | 63 | narrow, |
| 50 | 64 | }; |
| 51 | 65 | |
| 52 | | pub fn find(cp: u21) Codepoint { |
| 53 | | return data[binarySearchClosest(u21, data_soa[0], cp, compare)]; |
| 66 | pub fn find(cp: u21) usize { |
| 67 | return binarySearchClosest(u21, &data_code, cp, compare); |
| 54 | 68 | } |
| 55 | 69 | |
| 56 | 70 | fn binarySearchClosest(comptime T: type, items: []const T, context: anytype, comptime compareFn: fn (@TypeOf(context), T) std.math.Order) usize { |
| ... | ... | @@ -74,7 +88,7 @@ pub fn compare(needle: u21, row: u21) std.math.Order { |
| 74 | 88 | return .eq; |
| 75 | 89 | } |
| 76 | 90 | |
| 77 | | pub const data = [_]Codepoint{ |
| 91 | const data = [_]Codepoint{ |
| 78 | 92 | .{ 0x0000, "<control>", .Cc, 0, .BN, .__none, &.{}, "", "", "", false, null, null, null, }, |
| 79 | 93 | .{ 0x0001, "<control>", .Cc, 0, .BN, .__none, &.{}, "", "", "", false, null, null, null, }, |
| 80 | 94 | .{ 0x0002, "<control>", .Cc, 0, .BN, .__none, &.{}, "", "", "", false, null, null, null, }, |