OLD | NEW |
| (Empty) |
1 /* This is JavaScriptCore's variant of the PCRE library. While this library | |
2 started out as a copy of PCRE, many of the features of PCRE have been | |
3 removed. This library now supports only the regular expression features | |
4 required by the JavaScript language specification, and has only the functions | |
5 needed by JavaScriptCore and the rest of WebKit. | |
6 | |
7 Originally written by Philip Hazel | |
8 Copyright (c) 1997-2006 University of Cambridge | |
9 Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. | |
10 | |
11 ----------------------------------------------------------------------------- | |
12 Redistribution and use in source and binary forms, with or without | |
13 modification, are permitted provided that the following conditions are met: | |
14 | |
15 * Redistributions of source code must retain the above copyright notice, | |
16 this list of conditions and the following disclaimer. | |
17 | |
18 * Redistributions in binary form must reproduce the above copyright | |
19 notice, this list of conditions and the following disclaimer in the | |
20 documentation and/or other materials provided with the distribution. | |
21 | |
22 * Neither the name of the University of Cambridge nor the names of its | |
23 contributors may be used to endorse or promote products derived from | |
24 this software without specific prior written permission. | |
25 | |
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 POSSIBILITY OF SUCH DAMAGE. | |
37 ----------------------------------------------------------------------------- | |
38 */ | |
39 | |
40 #ifndef THIRD_PARTY_JSCRE_UCPINTERNAL_H_ | |
41 #define THIRD_PARTY_JSCRE_UCPINTERNAL_H_ | |
42 | |
43 /************************************************* | |
44 * Unicode Property Table handler * | |
45 *************************************************/ | |
46 | |
47 /* Internal header file defining the layout of the bits in each pair of 32-bit | |
48 words that form a data item in the table. */ | |
49 | |
50 typedef struct cnode { | |
51 unsigned f0; | |
52 unsigned f1; | |
53 } cnode; | |
54 | |
55 /* Things for the f0 field */ | |
56 | |
57 #define f0_scriptmask 0xff000000 /* Mask for script field */ | |
58 #define f0_scriptshift 24 /* Shift for script value */ | |
59 #define f0_rangeflag 0x00f00000 /* Flag for a range item */ | |
60 #define f0_charmask 0x001fffff /* Mask for code point value */ | |
61 | |
62 /* Things for the f1 field */ | |
63 | |
64 #define f1_typemask 0xfc000000 /* Mask for char type field */ | |
65 #define f1_typeshift 26 /* Shift for the type field */ | |
66 #define f1_rangemask 0x0000ffff /* Mask for a range offset */ | |
67 #define f1_casemask 0x0000ffff /* Mask for a case offset */ | |
68 #define f1_caseneg 0xffff8000 /* Bits for negation */ | |
69 | |
70 /* The data consists of a vector of structures of type cnode. The two unsigned | |
71 32-bit integers are used as follows: | |
72 | |
73 (f0) (1) The most significant byte holds the script number. The numbers are | |
74 defined by the enum in ucp.h. | |
75 | |
76 (2) The 0x00800000 bit is set if this entry defines a range of characters. | |
77 It is not set if this entry defines a single character | |
78 | |
79 (3) The 0x00600000 bits are spare. | |
80 | |
81 (4) The 0x001fffff bits contain the code point. No Unicode code point will | |
82 ever be greater than 0x0010ffff, so this should be OK for ever. | |
83 | |
84 (f1) (1) The 0xfc000000 bits contain the character type number. The numbers are | |
85 defined by an enum in ucp.h. | |
86 | |
87 (2) The 0x03ff0000 bits are spare. | |
88 | |
89 (3) The 0x0000ffff bits contain EITHER the unsigned offset to the top of | |
90 range if this entry defines a range, OR the *signed* offset to the | |
91 character's "other case" partner if this entry defines a single | |
92 character. There is no partner if the value is zero. | |
93 | |
94 ------------------------------------------------------------------------------- | |
95 | script (8) |.|.|.| codepoint (21) || type (6) |.|.| spare (8) | offset (16) | | |
96 ------------------------------------------------------------------------------- | |
97 | | | | | | |
98 | | |-> spare | |-> spare | |
99 | | | | |
100 | |-> spare |-> spare | |
101 | | |
102 |-> range flag | |
103 | |
104 The upper/lower casing information is set only for characters that come in | |
105 pairs. The non-one-to-one mappings in the Unicode data are ignored. | |
106 | |
107 When searching the data, proceed as follows: | |
108 | |
109 (1) Set up for a binary chop search. | |
110 | |
111 (2) If the top is not greater than the bottom, the character is not in the | |
112 table. Its type must therefore be "Cn" ("Undefined"). | |
113 | |
114 (3) Find the middle vector element. | |
115 | |
116 (4) Extract the code point and compare. If equal, we are done. | |
117 | |
118 (5) If the test character is smaller, set the top to the current point, and | |
119 goto (2). | |
120 | |
121 (6) If the current entry defines a range, compute the last character by adding | |
122 the offset, and see if the test character is within the range. If it is, | |
123 we are done. | |
124 | |
125 (7) Otherwise, set the bottom to one element past the current point and goto | |
126 (2). | |
127 */ | |
128 | |
129 /* End of ucpinternal.h */ | |
130 #endif // THIRD_PARTY_JSCRE_UCPINTERNAL_H_ | |
OLD | NEW |