OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> |
3 * Copyright (C) 2006, 2009 Apple Inc. | 3 * Copyright (C) 2006, 2009 Apple Inc. |
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 }; | 65 }; |
66 | 66 |
67 struct FunctionRec { | 67 struct FunctionRec { |
68 typedef Function *(*FactoryFn)(); | 68 typedef Function *(*FactoryFn)(); |
69 FactoryFn factoryFn; | 69 FactoryFn factoryFn; |
70 Interval args; | 70 Interval args; |
71 }; | 71 }; |
72 | 72 |
73 static HashMap<String, FunctionRec>* functionMap; | 73 static HashMap<String, FunctionRec>* functionMap; |
74 | 74 |
75 class FunLast : public Function { | 75 class FunLast FINAL : public Function { |
76 virtual Value evaluate() const; | 76 virtual Value evaluate() const OVERRIDE; |
77 virtual Value::Type resultType() const { return Value::NumberValue; } | 77 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
78 public: | 78 public: |
79 FunLast() { setIsContextSizeSensitive(true); } | 79 FunLast() { setIsContextSizeSensitive(true); } |
80 }; | 80 }; |
81 | 81 |
82 class FunPosition : public Function { | 82 class FunPosition FINAL : public Function { |
83 virtual Value evaluate() const; | 83 virtual Value evaluate() const OVERRIDE; |
84 virtual Value::Type resultType() const { return Value::NumberValue; } | 84 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
85 public: | 85 public: |
86 FunPosition() { setIsContextPositionSensitive(true); } | 86 FunPosition() { setIsContextPositionSensitive(true); } |
87 }; | 87 }; |
88 | 88 |
89 class FunCount : public Function { | 89 class FunCount FINAL : public Function { |
90 virtual Value evaluate() const; | 90 virtual Value evaluate() const OVERRIDE; |
91 virtual Value::Type resultType() const { return Value::NumberValue; } | 91 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
92 }; | 92 }; |
93 | 93 |
94 class FunId : public Function { | 94 class FunId FINAL : public Function { |
95 virtual Value evaluate() const; | 95 virtual Value evaluate() const OVERRIDE; |
96 virtual Value::Type resultType() const { return Value::NodeSetValue; } | 96 virtual Value::Type resultType() const OVERRIDE { return Value::NodeSetValue
; } |
97 }; | 97 }; |
98 | 98 |
99 class FunLocalName : public Function { | 99 class FunLocalName FINAL : public Function { |
100 virtual Value evaluate() const; | 100 virtual Value evaluate() const OVERRIDE; |
101 virtual Value::Type resultType() const { return Value::StringValue; } | 101 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
102 public: | 102 public: |
103 FunLocalName() { setIsContextNodeSensitive(true); } // local-name() with no
arguments uses context node. | 103 FunLocalName() { setIsContextNodeSensitive(true); } // local-name() with no
arguments uses context node. |
104 }; | 104 }; |
105 | 105 |
106 class FunNamespaceURI : public Function { | 106 class FunNamespaceURI FINAL : public Function { |
107 virtual Value evaluate() const; | 107 virtual Value evaluate() const OVERRIDE; |
108 virtual Value::Type resultType() const { return Value::StringValue; } | 108 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
109 public: | 109 public: |
110 FunNamespaceURI() { setIsContextNodeSensitive(true); } // namespace-uri() wi
th no arguments uses context node. | 110 FunNamespaceURI() { setIsContextNodeSensitive(true); } // namespace-uri() wi
th no arguments uses context node. |
111 }; | 111 }; |
112 | 112 |
113 class FunName : public Function { | 113 class FunName FINAL : public Function { |
114 virtual Value evaluate() const; | 114 virtual Value evaluate() const OVERRIDE; |
115 virtual Value::Type resultType() const { return Value::StringValue; } | 115 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
116 public: | 116 public: |
117 FunName() { setIsContextNodeSensitive(true); } // name() with no arguments u
ses context node. | 117 FunName() { setIsContextNodeSensitive(true); } // name() with no arguments u
ses context node. |
118 }; | 118 }; |
119 | 119 |
120 class FunString : public Function { | 120 class FunString FINAL : public Function { |
121 virtual Value evaluate() const; | 121 virtual Value evaluate() const OVERRIDE; |
122 virtual Value::Type resultType() const { return Value::StringValue; } | 122 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
123 public: | 123 public: |
124 FunString() { setIsContextNodeSensitive(true); } // string() with no argumen
ts uses context node. | 124 FunString() { setIsContextNodeSensitive(true); } // string() with no argumen
ts uses context node. |
125 }; | 125 }; |
126 | 126 |
127 class FunConcat : public Function { | 127 class FunConcat FINAL : public Function { |
128 virtual Value evaluate() const; | 128 virtual Value evaluate() const OVERRIDE; |
129 virtual Value::Type resultType() const { return Value::StringValue; } | 129 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
130 }; | 130 }; |
131 | 131 |
132 class FunStartsWith : public Function { | 132 class FunStartsWith FINAL : public Function { |
133 virtual Value evaluate() const; | 133 virtual Value evaluate() const OVERRIDE; |
134 virtual Value::Type resultType() const { return Value::BooleanValue; } | 134 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
135 }; | 135 }; |
136 | 136 |
137 class FunContains : public Function { | 137 class FunContains FINAL : public Function { |
138 virtual Value evaluate() const; | 138 virtual Value evaluate() const OVERRIDE; |
139 virtual Value::Type resultType() const { return Value::BooleanValue; } | 139 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
140 }; | 140 }; |
141 | 141 |
142 class FunSubstringBefore : public Function { | 142 class FunSubstringBefore FINAL : public Function { |
143 virtual Value evaluate() const; | 143 virtual Value evaluate() const OVERRIDE; |
144 virtual Value::Type resultType() const { return Value::StringValue; } | 144 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
145 }; | 145 }; |
146 | 146 |
147 class FunSubstringAfter : public Function { | 147 class FunSubstringAfter FINAL : public Function { |
148 virtual Value evaluate() const; | 148 virtual Value evaluate() const OVERRIDE; |
149 virtual Value::Type resultType() const { return Value::StringValue; } | 149 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
150 }; | 150 }; |
151 | 151 |
152 class FunSubstring : public Function { | 152 class FunSubstring FINAL : public Function { |
153 virtual Value evaluate() const; | 153 virtual Value evaluate() const OVERRIDE; |
154 virtual Value::Type resultType() const { return Value::StringValue; } | 154 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
155 }; | 155 }; |
156 | 156 |
157 class FunStringLength : public Function { | 157 class FunStringLength FINAL : public Function { |
158 virtual Value evaluate() const; | 158 virtual Value evaluate() const OVERRIDE; |
159 virtual Value::Type resultType() const { return Value::NumberValue; } | 159 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
160 public: | 160 public: |
161 FunStringLength() { setIsContextNodeSensitive(true); } // string-length() wi
th no arguments uses context node. | 161 FunStringLength() { setIsContextNodeSensitive(true); } // string-length() wi
th no arguments uses context node. |
162 }; | 162 }; |
163 | 163 |
164 class FunNormalizeSpace : public Function { | 164 class FunNormalizeSpace FINAL : public Function { |
165 virtual Value evaluate() const; | 165 virtual Value evaluate() const OVERRIDE; |
166 virtual Value::Type resultType() const { return Value::StringValue; } | 166 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
167 public: | 167 public: |
168 FunNormalizeSpace() { setIsContextNodeSensitive(true); } // normalize-space(
) with no arguments uses context node. | 168 FunNormalizeSpace() { setIsContextNodeSensitive(true); } // normalize-space(
) with no arguments uses context node. |
169 }; | 169 }; |
170 | 170 |
171 class FunTranslate : public Function { | 171 class FunTranslate FINAL : public Function { |
172 virtual Value evaluate() const; | 172 virtual Value evaluate() const OVERRIDE; |
173 virtual Value::Type resultType() const { return Value::StringValue; } | 173 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
174 }; | 174 }; |
175 | 175 |
176 class FunBoolean : public Function { | 176 class FunBoolean FINAL : public Function { |
177 virtual Value evaluate() const; | 177 virtual Value evaluate() const OVERRIDE; |
178 virtual Value::Type resultType() const { return Value::BooleanValue; } | 178 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
179 }; | 179 }; |
180 | 180 |
181 class FunNot : public Function { | 181 class FunNot FINAL : public Function { |
182 virtual Value evaluate() const; | 182 virtual Value evaluate() const OVERRIDE; |
183 virtual Value::Type resultType() const { return Value::BooleanValue; } | 183 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
184 }; | 184 }; |
185 | 185 |
186 class FunTrue : public Function { | 186 class FunTrue FINAL : public Function { |
187 virtual Value evaluate() const; | 187 virtual Value evaluate() const OVERRIDE; |
188 virtual Value::Type resultType() const { return Value::BooleanValue; } | 188 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
189 }; | 189 }; |
190 | 190 |
191 class FunFalse : public Function { | 191 class FunFalse FINAL : public Function { |
192 virtual Value evaluate() const; | 192 virtual Value evaluate() const OVERRIDE; |
193 virtual Value::Type resultType() const { return Value::BooleanValue; } | 193 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
194 }; | 194 }; |
195 | 195 |
196 class FunLang : public Function { | 196 class FunLang FINAL : public Function { |
197 virtual Value evaluate() const; | 197 virtual Value evaluate() const OVERRIDE; |
198 virtual Value::Type resultType() const { return Value::BooleanValue; } | 198 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
199 public: | 199 public: |
200 FunLang() { setIsContextNodeSensitive(true); } // lang() always works on con
text node. | 200 FunLang() { setIsContextNodeSensitive(true); } // lang() always works on con
text node. |
201 }; | 201 }; |
202 | 202 |
203 class FunNumber : public Function { | 203 class FunNumber FINAL : public Function { |
204 virtual Value evaluate() const; | 204 virtual Value evaluate() const OVERRIDE; |
205 virtual Value::Type resultType() const { return Value::NumberValue; } | 205 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
206 public: | 206 public: |
207 FunNumber() { setIsContextNodeSensitive(true); } // number() with no argumen
ts uses context node. | 207 FunNumber() { setIsContextNodeSensitive(true); } // number() with no argumen
ts uses context node. |
208 }; | 208 }; |
209 | 209 |
210 class FunSum : public Function { | 210 class FunSum FINAL : public Function { |
211 virtual Value evaluate() const; | 211 virtual Value evaluate() const OVERRIDE; |
212 virtual Value::Type resultType() const { return Value::NumberValue; } | 212 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
213 }; | 213 }; |
214 | 214 |
215 class FunFloor : public Function { | 215 class FunFloor FINAL : public Function { |
216 virtual Value evaluate() const; | 216 virtual Value evaluate() const OVERRIDE; |
217 virtual Value::Type resultType() const { return Value::NumberValue; } | 217 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
218 }; | 218 }; |
219 | 219 |
220 class FunCeiling : public Function { | 220 class FunCeiling FINAL : public Function { |
221 virtual Value evaluate() const; | 221 virtual Value evaluate() const OVERRIDE; |
222 virtual Value::Type resultType() const { return Value::NumberValue; } | 222 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
223 }; | 223 }; |
224 | 224 |
225 class FunRound : public Function { | 225 class FunRound FINAL : public Function { |
226 virtual Value evaluate() const; | 226 virtual Value evaluate() const OVERRIDE; |
227 virtual Value::Type resultType() const { return Value::NumberValue; } | 227 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
228 public: | 228 public: |
229 static double round(double); | 229 static double round(double); |
230 }; | 230 }; |
231 | 231 |
232 DEFINE_FUNCTION_CREATOR(FunLast) | 232 DEFINE_FUNCTION_CREATOR(FunLast) |
233 DEFINE_FUNCTION_CREATOR(FunPosition) | 233 DEFINE_FUNCTION_CREATOR(FunPosition) |
234 DEFINE_FUNCTION_CREATOR(FunCount) | 234 DEFINE_FUNCTION_CREATOR(FunCount) |
235 DEFINE_FUNCTION_CREATOR(FunId) | 235 DEFINE_FUNCTION_CREATOR(FunId) |
236 DEFINE_FUNCTION_CREATOR(FunLocalName) | 236 DEFINE_FUNCTION_CREATOR(FunLocalName) |
237 DEFINE_FUNCTION_CREATOR(FunNamespaceURI) | 237 DEFINE_FUNCTION_CREATOR(FunNamespaceURI) |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 return 0; | 744 return 0; |
745 | 745 |
746 Function* function = functionRec->factoryFn(); | 746 Function* function = functionRec->factoryFn(); |
747 function->setArguments(args); | 747 function->setArguments(args); |
748 function->setName(name); | 748 function->setName(name); |
749 return function; | 749 return function; |
750 } | 750 } |
751 | 751 |
752 } | 752 } |
753 } | 753 } |
OLD | NEW |