This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mktables: Add type_of() method to get range's type
authorKarl Williamson <public@khwilliamson.com>
Sat, 9 Oct 2010 23:58:11 +0000 (17:58 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 12 Oct 2010 20:50:03 +0000 (13:50 -0700)
This will be useful in outputting better annotations.

lib/unicore/mktables

index de3bd0d..b03c935 100644 (file)
@@ -2875,6 +2875,20 @@ sub trace { return main::trace(@_); }
         return $range->value;
     }
 
+    sub type_of {
+        # Returns the type of the range containing the code point, undef if
+        # the code point is not in the table
+
+        my $self = shift;
+        my $codepoint = shift;
+        Carp::carp_extra_args(\@_) if main::DEBUG && @_;
+
+        my $range = $self->containing_range($codepoint);
+        return unless defined $range;
+
+        return $range->type;
+    }
+
     sub _search_ranges {
         # Find the range in the list which contains a code point, or where it
         # should go if were to add it.  That is, it returns $i, such that:
@@ -4832,6 +4846,7 @@ sub trace { return main::trace(@_); }
                     min
                     range_count
                     reset_each_range
+                    type_of
                     value_of
                 ))
     {
@@ -7192,6 +7207,7 @@ sub trace { return main::trace(@_) if main::DEBUG && $to_trace }
                     status
                     status_info
                     to_output_map
+                    type_of
                     value_of
                     write
                 ))