Skip to content

Commit

Permalink
Add Unicode class to 6.c
Browse files Browse the repository at this point in the history
Providing:
- .version: the Unicode version supported
- .NFG: Bool whether NFG supported

Removes the $?UNICODE-VERSION, which is now accessible as Unicode.version
  • Loading branch information
lizmat committed Feb 8, 2023
1 parent 156fc2c commit db7ca2d
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 39 deletions.
58 changes: 58 additions & 0 deletions src/core.c/Unicode.pm6
@@ -0,0 +1,58 @@
my class Unicode {

#?if moar
my constant NFG = True;
#?endif
#?if !moar
my constant NFG = False;
#?endif

# This constant specifies the current Unicode version being supported
#?if jvm
my constant VERSION = nqp::jvmgetunicodeversion.Version;
#?endif
#?if !jvm
my constant VERSION = (
'1.1' => 'a',
'2.0' => '',
'2.1' => '',
'3.0' => 'ϟ',
'3.1' => 'ϴ',
'3.2' => '',
'4.0' => 'ȡ',
'4.1' => '',
'5.0' => '',
'5.1' => 'Ϗ',
'5.2' => '',
'6.0' => '',
'6.1' => '',
'6.2' => '',
'6.3' => 0x061C.chr,
'7.0' => 0x037F.chr,
'8.0' => 0x218A.chr,
'9.0' => 0xA7AE.chr,
'10.0' => 0x20BF.chr,
'11.0' => 0xA7AF.chr,
'12.0' => 0xA7BA.chr,
'12.1' => 0x32FF.chr,
'13.0' => 0x1F972.chr,
'14.0' => 0x061D.chr,
'15.0' => 0x0CF3.chr,
# PLEASE ADD NEWER UNICODE VERSIONS HERE, AS SOON AS THE UNICODE
# CONSORTIUM HAS RELEASED A NEW VERSION
).first(*.value.uniprop('Age') ne 'Unassigned', :end).key.Version;
#?endif

has Version $.version = VERSION;
has Bool $.NFG = NFG;

proto method version(|) {*}
multi method version(Unicode:U:) { VERSION }
multi method version(Unicode:D:) { $!version }

proto method NFG(|) {*}
multi method NFG(Unicode:U:) { NFG }
multi method NFG(Unicode:D:) { $!NFG }
}

# vim: expandtab shiftwidth=4
36 changes: 0 additions & 36 deletions src/core.e/core_prologue.pm6
Expand Up @@ -4,40 +4,4 @@ use MONKEY;
# declarations to allow correct recording of their respective language version.
my constant CORE-SETTING-REV = nqp::box_i(3, Metamodel::Configuration.language_revision_type);

# This constant specifies the current Unicode version being supported
#?if jvm
my constant $?UNICODE-VERSION = nqp::jvmgetunicodeversion.Version;
#?endif
#?if !jvm
my constant $?UNICODE-VERSION = (
'1.1' => 'a',
'2.0' => '',
'2.1' => '',
'3.0' => 'ϟ',
'3.1' => 'ϴ',
'3.2' => '',
'4.0' => 'ȡ',
'4.1' => '',
'5.0' => '',
'5.1' => 'Ϗ',
'5.2' => '',
'6.0' => '',
'6.1' => '',
'6.2' => '',
'6.3' => 0x061C.chr,
'7.0' => 0x037F.chr,
'8.0' => 0x218A.chr,
'9.0' => 0xA7AE.chr,
'10.0' => 0x20BF.chr,
'11.0' => 0xA7AF.chr,
'12.0' => 0xA7BA.chr,
'12.1' => 0x32FF.chr,
'13.0' => 0x1F972.chr,
'14.0' => 0x061D.chr,
'15.0' => 0x0CF3.chr,
# PLEASE ADD NEWER UNICODE VERSIONS HERE, AS SOON AS THE UNICODE
# CONSORTIUM HAS RELEASED A NEW VERSION
).first(*.value.uniprop('Age') ne 'Unassigned', :end).key.Version;
#?endif

# vim: expandtab shiftwidth=4
1 change: 1 addition & 0 deletions t/02-rakudo/03-corekeys-6c.t
Expand Up @@ -729,6 +729,7 @@ my @expected = (
Q{UIntLexRef},
Q{UIntPosRef},
Q{Uni},
Q{Unicode},
Q{UnsignedBlob},
Q{VM},
Q{ValueObjAt},
Expand Down
1 change: 1 addition & 0 deletions t/02-rakudo/03-corekeys-6d.t
Expand Up @@ -729,6 +729,7 @@ my @expected = (
Q{UIntLexRef},
Q{UIntPosRef},
Q{Uni},
Q{Unicode},
Q{UnsignedBlob},
Q{VM},
Q{ValueObjAt},
Expand Down
2 changes: 1 addition & 1 deletion t/02-rakudo/03-corekeys-6e.t
Expand Up @@ -13,7 +13,6 @@ my @expected = (
Q{$?BITS},
Q{$?NL},
Q{$?TABSTOP},
Q{$?UNICODE-VERSION},
Q{$_},
Q{},
Q{&CLONE-HASH-DECONTAINERIZED},
Expand Down Expand Up @@ -739,6 +738,7 @@ my @expected = (
Q{UIntLexRef},
Q{UIntPosRef},
Q{Uni},
Q{Unicode},
Q{UnsignedBlob},
Q{VM},
Q{ValueObjAt},
Expand Down
2 changes: 1 addition & 1 deletion t/02-rakudo/03-corekeys.t
Expand Up @@ -732,6 +732,7 @@ my @allowed =
Q{UIntLexRef},
Q{UIntPosRef},
Q{Uni},
Q{Unicode},
Q{UnsignedBlob},
Q{VM},
Q{ValueObjAt},
Expand Down Expand Up @@ -798,7 +799,6 @@ my @allowed =
Q{$!},
Q{$/},
Q{$=pod},
Q{$?UNICODE-VERSION},
Q{$_},
Q{},
Q{&last},
Expand Down
1 change: 1 addition & 0 deletions t/02-rakudo/04-settingkeys-6c.t
Expand Up @@ -729,6 +729,7 @@ my %allowed = (
Q{UIntLexRef},
Q{UIntPosRef},
Q{Uni},
Q{Unicode},
Q{UnsignedBlob},
Q{VM},
Q{ValueObjAt},
Expand Down
2 changes: 1 addition & 1 deletion t/02-rakudo/04-settingkeys-6e.t
Expand Up @@ -12,7 +12,6 @@ my %allowed = (
Q{$?BITS},
Q{$?NL},
Q{$?TABSTOP},
Q{$?UNICODE-VERSION},
Q{$_},
Q{&CLONE-HASH-DECONTAINERIZED},
Q{&CLONE-LIST-DECONTAINERIZED},
Expand Down Expand Up @@ -737,6 +736,7 @@ my %allowed = (
Q{UIntLexRef},
Q{UIntPosRef},
Q{Uni},
Q{Unicode},
Q{UnsignedBlob},
Q{VM},
Q{ValueObjAt},
Expand Down
1 change: 1 addition & 0 deletions tools/templates/6.c/core_sources
Expand Up @@ -251,5 +251,6 @@ src/core.c/WrappedJSObject.pm6)@
src/core.c/Rakudo/Metaops.pm6
src/core.c/Rakudo/Internals/PostcircumfixAdverbs.pm6
src/core.c/unicodey.pm6
src/core.c/Unicode.pm6
src/core.c/RakuAST/Deparse.pm6
src/core.c/core_epilogue.pm6

0 comments on commit db7ca2d

Please sign in to comment.