Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba
- markos-scratch
- Merge into trunk
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Approved by: | Chris Hillery |
Approved revision: | 11094 |
Merged at revision: | 11426 |
Proposed branch: | lp:~zorba-coders/zorba/markos-scratch |
Merge into: | lp:zorba |
Diff against target: |
437 lines (+96/-46) 9 files modified
src/compiler/translator/translator.cpp (+20/-12) src/runtime/booleans/BooleanImpl.cpp (+8/-8) src/runtime/core/sequencetypes.cpp (+6/-3) src/runtime/core/sequencetypes.h (+1/-0) src/runtime/sequences/SequencesImpl.cpp (+7/-7) src/types/casting.cpp (+48/-7) src/types/casting.h (+2/-0) src/types/schema/schema.cpp (+2/-3) test/fots/CMakeLists.txt (+2/-6) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/markos-scratch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+162005@code.launchpad.net |
Commit message
fixed bugs related to casting to xs:QName and xs:token
Description of the change
fixed bugs related to casting to xs:QName and xs:token
To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) : | # |
review:
Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba failed. Below is the output from the failed tests.
Revision history for this message
Chris Hillery (ceejatec) wrote : | # |
Sorry, I was working on the RQ machine and I think I accidentally broke this RQ run. I've restarted it.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job markos-
All tests succeeded!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/compiler/translator/translator.cpp' |
2 | --- src/compiler/translator/translator.cpp 2013-04-30 22:57:18 +0000 |
3 | +++ src/compiler/translator/translator.cpp 2013-05-02 00:32:32 +0000 |
4 | @@ -9159,7 +9159,7 @@ |
5 | ********************************************************************************/ |
6 | expr* create_cast_expr( |
7 | const QueryLoc& loc, |
8 | - expr* node, |
9 | + expr* inExpr, |
10 | const xqtref_t& type, |
11 | bool allowsEmpty, |
12 | bool isCast) |
13 | @@ -9185,16 +9185,24 @@ |
14 | |
15 | if (TypeOps::is_subtype(tm, *type, *theRTM.QNAME_TYPE_QUESTION, loc)) |
16 | { |
17 | - if (node->get_expr_kind() == const_expr_kind) |
18 | + if (inExpr->get_expr_kind() == const_expr_kind) |
19 | { |
20 | - const const_expr* ce = static_cast<const_expr*>(node); |
21 | + const const_expr* ce = static_cast<const_expr*>(inExpr); |
22 | |
23 | if (ce->get_val()->getTypeCode() == store::XS_STRING) |
24 | { |
25 | store::Item_t result; |
26 | + store::Item_t value = ce->get_val(); |
27 | + xqtref_t ptype = TypeOps::prime_type(tm, *type); |
28 | + |
29 | try |
30 | { |
31 | - GenericCast::castToQName(result, ce->get_val(), theNSCtx, false, tm, loc); |
32 | + GenericCast::castToAtomic(result, |
33 | + value, |
34 | + ptype.getp(), |
35 | + tm, |
36 | + theNSCtx, |
37 | + loc); |
38 | } |
39 | catch (ZorbaException& e) |
40 | { |
41 | @@ -9229,7 +9237,7 @@ |
42 | } |
43 | } |
44 | |
45 | - xqtref_t inputType = node->get_return_type(); |
46 | + xqtref_t inputType = inExpr->get_return_type(); |
47 | |
48 | if (theSctx->xquery_version() < StaticContextConsts::xquery_version_3_0) |
49 | { |
50 | @@ -9239,21 +9247,21 @@ |
51 | { |
52 | if (TypeOps::is_subtype(tm, *inputType, *theRTM.QNAME_TYPE_STAR, loc)) |
53 | { |
54 | - return CREATE(cast)(theRootSctx, theUDF, loc, node, type, allowsEmpty); |
55 | + return CREATE(cast)(theRootSctx, theUDF, loc, inExpr, type, allowsEmpty); |
56 | } |
57 | else |
58 | { |
59 | - return CREATE(treat)(theRootSctx, theUDF, loc, node, type, TREAT_TYPE_MATCH); |
60 | + return CREATE(treat)(theRootSctx, theUDF, loc, inExpr, type, TREAT_TYPE_MATCH); |
61 | } |
62 | } |
63 | else |
64 | { |
65 | - return CREATE(instanceof)(theRootSctx, theUDF, loc, node, type); |
66 | + return CREATE(instanceof)(theRootSctx, theUDF, loc, inExpr, type); |
67 | } |
68 | } |
69 | |
70 | - expr* input = wrap_in_atomization(node); |
71 | - |
72 | + expr* input = wrap_in_atomization(inExpr); |
73 | + /* |
74 | if (TypeOps::is_subtype(tm, *inputType, *theRTM.ANY_NODE_TYPE_PLUS, loc)) |
75 | { |
76 | if (isCast) |
77 | @@ -9265,7 +9273,7 @@ |
78 | return CREATE(const)(theRootSctx, theUDF, loc, false); |
79 | } |
80 | } |
81 | - |
82 | + */ |
83 | if (isCast) |
84 | return CREATE(cast)(theRootSctx, theUDF, loc, input, type, allowsEmpty); |
85 | else |
86 | @@ -9273,7 +9281,7 @@ |
87 | } |
88 | else |
89 | { |
90 | - expr* input = wrap_in_atomization(node); |
91 | + expr* input = wrap_in_atomization(inExpr); |
92 | |
93 | if (isCast) |
94 | return CREATE(cast)(theRootSctx, theUDF, loc, input, type, allowsEmpty); |
95 | |
96 | === modified file 'src/runtime/booleans/BooleanImpl.cpp' |
97 | --- src/runtime/booleans/BooleanImpl.cpp 2013-04-04 01:37:05 +0000 |
98 | +++ src/runtime/booleans/BooleanImpl.cpp 2013-05-02 00:32:32 +0000 |
99 | @@ -636,23 +636,23 @@ |
100 | { |
101 | GenericCast::castToBuiltinAtomic(castItem0, item0, store::XS_STRING, NULL, loc); |
102 | |
103 | - if (!GenericCast::promote(castItem1, item1, store::XS_STRING, tm, loc)) |
104 | + if (!GenericCast::promote(castItem1, item1, store::XS_STRING, NULL, tm, loc)) |
105 | castItem1.transfer(item1); |
106 | } |
107 | } |
108 | else if (type1 == store::XS_UNTYPED_ATOMIC) |
109 | { |
110 | - if (!GenericCast::promote(castItem0, item0, store::XS_STRING, tm, loc)) |
111 | + if (!GenericCast::promote(castItem0, item0, store::XS_STRING, NULL, tm, loc)) |
112 | castItem0.transfer(item0); |
113 | |
114 | GenericCast::castToBuiltinAtomic(castItem1, item1, store::XS_STRING, NULL, loc); |
115 | } |
116 | else |
117 | { |
118 | - if (!GenericCast::promote(castItem0, item0, type1, tm, loc)) |
119 | + if (!GenericCast::promote(castItem0, item0, type1, NULL, tm, loc)) |
120 | castItem0.transfer(item0); |
121 | |
122 | - if (!GenericCast::promote(castItem1, item1, type0, tm, loc)) |
123 | + if (!GenericCast::promote(castItem1, item1, type0, NULL, tm, loc)) |
124 | castItem1.transfer(item1); |
125 | } |
126 | } |
127 | @@ -808,7 +808,7 @@ |
128 | { |
129 | GenericCast::castToBuiltinAtomic(castItem0, item0, store::XS_DOUBLE, NULL, loc); |
130 | |
131 | - GenericCast::promote(castItem1, item1, store::XS_DOUBLE, tm, loc); |
132 | + GenericCast::promote(castItem1, item1, store::XS_DOUBLE, NULL, tm, loc); |
133 | } |
134 | else if (type1 == store::XS_UNTYPED_ATOMIC) |
135 | { |
136 | @@ -831,7 +831,7 @@ |
137 | if (TypeOps::is_numeric(type0)) |
138 | { |
139 | GenericCast::castToBuiltinAtomic(castItem1, item1, store::XS_DOUBLE, NULL, loc); |
140 | - GenericCast::promote(castItem0, item0, store::XS_DOUBLE, tm, loc); |
141 | + GenericCast::promote(castItem0, item0, store::XS_DOUBLE, NULL, tm, loc); |
142 | } |
143 | else if (TypeOps::is_subtype(type0, store::XS_STRING)) |
144 | { |
145 | @@ -846,10 +846,10 @@ |
146 | } |
147 | else |
148 | { |
149 | - if (!GenericCast::promote(castItem0, item0, type1, tm, loc)) |
150 | + if (!GenericCast::promote(castItem0, item0, type1, NULL, tm, loc)) |
151 | castItem0.transfer(item0); |
152 | |
153 | - if (!GenericCast::promote(castItem1, item1, type0, tm, loc)) |
154 | + if (!GenericCast::promote(castItem1, item1, type0, NULL, tm, loc)) |
155 | castItem1.transfer(item1); |
156 | } |
157 | } |
158 | |
159 | === modified file 'src/runtime/core/sequencetypes.cpp' |
160 | --- src/runtime/core/sequencetypes.cpp 2013-04-23 10:58:29 +0000 |
161 | +++ src/runtime/core/sequencetypes.cpp 2013-05-02 00:32:32 +0000 |
162 | @@ -377,7 +377,8 @@ |
163 | : |
164 | UnaryBaseIterator<PromoteIterator, PlanIteratorState>(sctx, loc, child), |
165 | theErrorKind(err), |
166 | - theQName(qname) |
167 | + theQName(qname), |
168 | + theNsCtx(theSctx) |
169 | { |
170 | thePromoteType = TypeOps::prime_type(sctx->get_typemanager(), *promoteType); |
171 | theQuantifier = promoteType->get_quantifier(); |
172 | @@ -398,6 +399,8 @@ |
173 | SERIALIZE_ENUM(TypeConstants::quantifier_t, theQuantifier); |
174 | SERIALIZE_ENUM(PromoteErrorKind, theErrorKind); |
175 | ar & theQName; |
176 | + |
177 | + theNsCtx.setStaticContext(theSctx); |
178 | } |
179 | |
180 | |
181 | @@ -428,7 +431,7 @@ |
182 | } |
183 | |
184 | // catch exceptions to add/change the error location |
185 | - if (! GenericCast::promote(result, item, thePromoteType, tm, loc)) |
186 | + if (! GenericCast::promote(result, item, thePromoteType, &theNsCtx, tm, loc)) |
187 | { |
188 | zstring valueType = tm->create_value_type(item)->toSchemaString(); |
189 | raiseError(valueType); |
190 | @@ -440,7 +443,7 @@ |
191 | { |
192 | do |
193 | { |
194 | - if (! GenericCast::promote(result, item, thePromoteType, tm, loc)) |
195 | + if (! GenericCast::promote(result, item, thePromoteType, &theNsCtx, tm, loc)) |
196 | { |
197 | zstring valueType = tm->create_value_type(item)->toSchemaString(); |
198 | raiseError(valueType); |
199 | |
200 | === modified file 'src/runtime/core/sequencetypes.h' |
201 | --- src/runtime/core/sequencetypes.h 2013-02-07 17:24:36 +0000 |
202 | +++ src/runtime/core/sequencetypes.h 2013-05-02 00:32:32 +0000 |
203 | @@ -168,6 +168,7 @@ |
204 | TypeConstants::quantifier_t theQuantifier; |
205 | PromoteErrorKind theErrorKind; |
206 | store::Item_t theQName; |
207 | + namespace_context theNsCtx; |
208 | |
209 | public: |
210 | SERIALIZABLE_CLASS(PromoteIterator); |
211 | |
212 | === modified file 'src/runtime/sequences/SequencesImpl.cpp' |
213 | --- src/runtime/sequences/SequencesImpl.cpp 2013-02-07 17:24:36 +0000 |
214 | +++ src/runtime/sequences/SequencesImpl.cpp 2013-05-02 00:32:32 +0000 |
215 | @@ -21,7 +21,10 @@ |
216 | #include <sstream> |
217 | |
218 | #include "zorbautils/fatal.h" |
219 | + |
220 | #include "diagnostics/xquery_diagnostics.h" |
221 | +#include "diagnostics/util_macros.h" |
222 | + |
223 | #include "zorbatypes/URI.h" |
224 | |
225 | // For timing |
226 | @@ -175,20 +178,17 @@ |
227 | { |
228 | // Type Promotion |
229 | store::Item_t lItemCur; |
230 | - if (!GenericCast::promote(lItemCur, lRunningItem, &*lMaxType, tm, loc)) |
231 | + if (!GenericCast::promote(lItemCur, lRunningItem, &*lMaxType, NULL, tm, loc)) |
232 | { |
233 | - if (GenericCast::promote(lItemCur, result, &*lRunningType, tm, loc)) |
234 | + if (GenericCast::promote(lItemCur, result, &*lRunningType, NULL, tm, loc)) |
235 | { |
236 | result.transfer(lItemCur); |
237 | lMaxType = tm->create_value_type(result); |
238 | } |
239 | else |
240 | { |
241 | - throw XQUERY_EXCEPTION( |
242 | - err::FORG0006, |
243 | - ERROR_PARAMS( ZED( PromotionImpossible ) ), |
244 | - ERROR_LOC( loc ) |
245 | - ); |
246 | + RAISE_ERROR(err::FORG0006, loc, |
247 | + ERROR_PARAMS(ZED(PromotionImpossible))); |
248 | } |
249 | } |
250 | else |
251 | |
252 | === modified file 'src/types/casting.cpp' |
253 | --- src/types/casting.cpp 2013-04-30 23:29:51 +0000 |
254 | +++ src/types/casting.cpp 2013-05-02 00:32:32 +0000 |
255 | @@ -907,6 +907,14 @@ |
256 | } |
257 | |
258 | |
259 | +T1_TO_T2(uA, QN) |
260 | +{ |
261 | + zstring strval2; |
262 | + aItem->getStringValue2(strval2); |
263 | + str_QN(result, aItem, strval2, aFactory, nsCtx, errInfo); |
264 | +} |
265 | + |
266 | + |
267 | T1_TO_T2(flt, uA) |
268 | { |
269 | zstring strval2; |
270 | @@ -1715,11 +1723,43 @@ |
271 | } |
272 | case store::XS_TOKEN: |
273 | { |
274 | - if (GenericCast::instance()->castableToToken(strval)) |
275 | + char ch; |
276 | + zstring::size_type sz = strval.size(); |
277 | + |
278 | + ascii::trim_whitespace(strval); |
279 | + |
280 | + bool spaceSeen = false; |
281 | + |
282 | + for (zstring::size_type i = 0; i < sz; ++i) |
283 | { |
284 | - factory->createToken(result, strval); |
285 | - return; |
286 | + ch = strval[i]; |
287 | + |
288 | + if (ch == '\r' || ch == '\n' || ch == '\t') |
289 | + { |
290 | + strval[i] = ' '; |
291 | + ch = ' '; |
292 | + } |
293 | + |
294 | + if (ch == ' ') |
295 | + { |
296 | + if (spaceSeen) |
297 | + { |
298 | + strval.erase(i, 1); |
299 | + --i; |
300 | + --sz; |
301 | + } |
302 | + |
303 | + spaceSeen = true; |
304 | + } |
305 | + else |
306 | + { |
307 | + spaceSeen = false; |
308 | + } |
309 | } |
310 | + |
311 | + factory->createToken(result, strval); |
312 | + return; |
313 | + |
314 | break; |
315 | } |
316 | case store::XS_LANGUAGE: |
317 | @@ -2102,7 +2142,7 @@ |
318 | |
319 | {&uA_uA, &uA_str, &uA_flt, &uA_dbl , &uA_dec , &uA_int, &uA_dur, &uA_yMD, |
320 | &uA_dTD, &uA_dT, &uA_tim, &uA_dat, &uA_gYM , &uA_gYr , &uA_gMD, &uA_gDay, |
321 | - &uA_gMon, &uA_bool, &uA_b64, &uA_hxB, &uA_aURI, 0, 0, &uA_uint, |
322 | + &uA_gMon, &uA_bool, &uA_b64, &uA_hxB, &uA_aURI, &uA_QN, 0, &uA_uint, |
323 | 0, &uA_dTSt}, // uA |
324 | |
325 | {&str_uA, &str_str, &str_flt, &str_dbl, &str_dec, &str_int, &str_dur, &str_yMD, |
326 | @@ -2716,8 +2756,6 @@ |
327 | { |
328 | ch = str[i]; |
329 | |
330 | - // do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) |
331 | - // characters */ |
332 | if (ch == '\r' || ch == '\n' || ch == '\t') |
333 | { |
334 | return false; |
335 | @@ -3006,6 +3044,7 @@ |
336 | store::Item_t& result, |
337 | store::Item_t& item, |
338 | const XQType* targetType, |
339 | + const namespace_context* nsCtx, |
340 | const TypeManager* tm, |
341 | const QueryLoc& loc) |
342 | { |
343 | @@ -3019,6 +3058,7 @@ |
344 | return promote(result, |
345 | item, |
346 | static_cast<const AtomicXQType*>(targetType)->get_type_code(), |
347 | + nsCtx, |
348 | tm, |
349 | loc); |
350 | } |
351 | @@ -3038,7 +3078,7 @@ |
352 | if (TypeOps::is_equal(tm, *itemType, *rtm.UNTYPED_ATOMIC_TYPE_ONE) && |
353 | ! TypeOps::is_equal(tm, *TypeOps::prime_type(tm, *targetType), *rtm.QNAME_TYPE_ONE)) |
354 | { |
355 | - return castToAtomic(result, item, targetType, tm, NULL, loc); |
356 | + return castToAtomic(result, item, targetType, tm, nsCtx, loc); |
357 | } |
358 | |
359 | // Decimal/Float --> xs:double |
360 | @@ -3087,6 +3127,7 @@ |
361 | store::Item_t& result, |
362 | store::Item_t& item, |
363 | store::SchemaTypeCode targetType, |
364 | + const namespace_context* nsCtx, |
365 | const TypeManager* tm, |
366 | const QueryLoc& loc) |
367 | { |
368 | |
369 | === modified file 'src/types/casting.h' |
370 | --- src/types/casting.h 2013-03-12 17:03:31 +0000 |
371 | +++ src/types/casting.h 2013-05-02 00:32:32 +0000 |
372 | @@ -74,6 +74,7 @@ |
373 | store::Item_t& result, |
374 | store::Item_t& item, |
375 | const XQType* targetType, |
376 | + const namespace_context* nsCtx, |
377 | const TypeManager* tm, |
378 | const QueryLoc& loc); |
379 | |
380 | @@ -81,6 +82,7 @@ |
381 | store::Item_t& result, |
382 | store::Item_t& item, |
383 | store::SchemaTypeCode targetType, |
384 | + const namespace_context* nsCtx, |
385 | const TypeManager* tm, |
386 | const QueryLoc& loc); |
387 | |
388 | |
389 | === modified file 'src/types/schema/schema.cpp' |
390 | --- src/types/schema/schema.cpp 2013-04-25 12:49:22 +0000 |
391 | +++ src/types/schema/schema.cpp 2013-05-02 00:32:32 +0000 |
392 | @@ -1746,9 +1746,8 @@ |
393 | } |
394 | |
395 | // workaround for validating xs:NOTATION with Xerces |
396 | - if (theTypeManager != NULL |
397 | - && |
398 | - udXQType->isSubTypeOf(theTypeManager, *GENV_TYPESYSTEM.NOTATION_TYPE_ONE)) |
399 | + if (theTypeManager != NULL && |
400 | + udXQType->isSubTypeOf(theTypeManager, *GENV_TYPESYSTEM.NOTATION_TYPE_STAR)) |
401 | { |
402 | // textValue must be in the form of URI:LOCAL |
403 | size_t colonIndex = textValue.find_first_of(":"); |
404 | |
405 | === modified file 'test/fots/CMakeLists.txt' |
406 | --- test/fots/CMakeLists.txt 2013-05-01 22:25:33 +0000 |
407 | +++ test/fots/CMakeLists.txt 2013-05-02 00:32:32 +0000 |
408 | @@ -265,10 +265,9 @@ |
409 | EXPECTED_FOTS_FAILURE (prod-Annotation annotation-assertion-9 0) |
410 | EXPECTED_FOTS_FAILURE (prod-Annotation annotation-assertion-10 0) |
411 | EXPECTED_FOTS_FAILURE (prod-BaseURIDecl K2-BaseURIProlog-5 0) |
412 | -EXPECTED_FOTS_FAILURE (prod-CastExpr CastAs674a 0) |
413 | -EXPECTED_FOTS_FAILURE (prod-CastExpr K-SeqExprCast-71b 0) |
414 | +EXPECTED_FOTS_FAILURE (prod-CastExpr CastAsNamespaceSensitiveType-11 0) |
415 | +EXPECTED_FOTS_FAILURE (prod-CastExpr CastAsNamespaceSensitiveType-12 0) |
416 | EXPECTED_FOTS_FAILURE (prod-CastExpr.derived cbcl-cast-ncname-001 0) |
417 | -EXPECTED_FOTS_FAILURE (prod-CastExpr.derived cbcl-cast-token-001 0) |
418 | EXPECTED_FOTS_FAILURE (prod-CastExpr.schema CastAs-UnionType-17 0) |
419 | EXPECTED_FOTS_FAILURE (prod-CastExpr.schema CastAs-UnionType-22 0) |
420 | EXPECTED_FOTS_FAILURE (prod-CastExpr.schema CastAs-UnionType-23 0) |
421 | @@ -295,7 +294,6 @@ |
422 | EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-005 0) |
423 | EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-007 0) |
424 | EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-008 0) |
425 | -EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-015 0) |
426 | EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-031 0) |
427 | EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-033 0) |
428 | EXPECTED_FOTS_FAILURE (prod-FunctionCall FunctionCall-037 0) |
429 | @@ -373,8 +371,6 @@ |
430 | EXPECTED_FOTS_FAILURE (xs-anyURI cbcl-anyURI-002 0) |
431 | EXPECTED_FOTS_FAILURE (xs-anyURI cbcl-anyURI-006 0) |
432 | EXPECTED_FOTS_FAILURE (xs-base64Binary base64-115 0) |
433 | -EXPECTED_FOTS_FAILURE (xs-token cbcl-token-002 0) |
434 | -EXPECTED_FOTS_FAILURE (xs-token cbcl-token-004 0) |
435 | EXPECTED_FOTS_FAILURE (fn-fold-left fold-left-009 0) |
436 | EXPECTED_FOTS_FAILURE (fn-function-lookup fn-function-lookup-062 0) |
437 | EXPECTED_FOTS_FAILURE (fn-map-pairs fn-map-pairs-026 0) |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ markos- scratch- 2013-05- 02T00-49- 06.887Z/ log.html
Log at: http://