1 #define nsHtml5NamedCharacters_cpp_
9 #include "nsHtml5NamedCharacters.h"
11 jArray
<jArray
<PRInt8
,PRInt32
>,PRInt32
> nsHtml5NamedCharacters::NAMES
;
13 const PRUnichar
nsHtml5NamedCharacters::VALUES
[][2] = {
14 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
16 #include "nsHtml5NamedCharactersInclude.h"
17 #undef NAMED_CHARACTER_REFERENCE
20 PRUnichar
** nsHtml5NamedCharacters::WINDOWS_1252
;
21 static PRUnichar
const WINDOWS_1252_DATA
[] = {
57 * To avoid having lots of pointers in the |charData| array, below,
58 * which would cause us to have to do lots of relocations at library
59 * load time, store all the string data for the names in one big array.
60 * Then use tricks with enums to help us build an array that contains
61 * the positions of each within the big arrays.
64 static const PRInt8 ALL_NAMES
[] = {
65 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
67 #include "nsHtml5NamedCharactersInclude.h"
68 #undef NAMED_CHARACTER_REFERENCE
72 DUMMY_INITIAL_NAME_POSITION
= 0,
73 /* enums don't take up space, so generate _START and _END */
74 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
75 NAME_##N##_DUMMY, /* automatically one higher than previous */ \
76 NAME_##N##_START = NAME_##N##_DUMMY - 1, \
77 NAME_##N##_END = NAME_##N##_START + LEN + FLAG,
78 #include "nsHtml5NamedCharactersInclude.h"
79 #undef NAMED_CHARACTER_REFERENCE
80 DUMMY_FINAL_NAME_VALUE
83 #define NAMED_CHARACTERS_COUNT 2138
85 /* check that the start positions will fit in 16 bits */
86 PR_STATIC_ASSERT(NS_ARRAY_LENGTH(ALL_NAMES
) < 0x10000);
88 struct NamedCharacterData
{
96 static const NamedCharacterData charData
[NAMED_CHARACTERS_COUNT
] = {
98 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
99 { NAME_##N##_START, LEN, N },
101 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
102 { NAME_##N##_START, LEN, },
104 #include "nsHtml5NamedCharactersInclude.h"
105 #undef NAMED_CHARACTER_REFERENCE
109 nsHtml5NamedCharacters::initializeStatics()
111 NAMES
= jArray
<jArray
<PRInt8
,PRInt32
>,PRInt32
>(NAMED_CHARACTERS_COUNT
);
112 PRInt8
* allNames
= const_cast<PRInt8
*>(ALL_NAMES
);
113 for (PRInt32 i
= 0; i
< NAMED_CHARACTERS_COUNT
; ++i
) {
114 const NamedCharacterData
&data
= charData
[i
];
115 NS_ABORT_IF_FALSE(data
.n
== i
,
116 "index error in nsHtml5NamedCharactersInclude.h");
117 NAMES
[i
] = jArray
<PRInt8
,PRInt32
>(allNames
+ data
.nameStart
, data
.nameLen
);
120 WINDOWS_1252
= new PRUnichar
*[32];
121 for (PRInt32 i
= 0; i
< 32; ++i
) {
122 WINDOWS_1252
[i
] = (PRUnichar
*)&(WINDOWS_1252_DATA
[i
]);
127 nsHtml5NamedCharacters::releaseStatics()
130 delete[] WINDOWS_1252
;