Merge lp:~zorba-coders/zorba/deprecate-true_false_null into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Chris Hillery
Approved revision: 11410
Merged at revision: 11427
Proposed branch: lp:~zorba-coders/zorba/deprecate-true_false_null
Merge into: lp:zorba
Diff against target: 161 lines (+96/-1)
6 files modified
include/zorba/pregenerated/diagnostic_list.h (+2/-0)
modules/com/zorba-xquery/www/modules/pregenerated/warnings.xq (+5/-1)
src/compiler/translator/translator.cpp (+81/-0)
src/diagnostics/diagnostic_en.xml (+4/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+3/-0)
src/diagnostics/pregenerated/dict_en.cpp (+1/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/deprecate-true_false_null
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Matthias Brantner Approve
Review via email: mp+160980@code.launchpad.net

Commit message

raise deprecated warning for true, false, null in xquery mode

Description of the change

note that most of the changes reverts back to the old behavior that was removed recently

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job deprecate-true_false_null-2013-04-25T18-32-44.528Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1, Needs Information < 1, Resubmit < 1. Got: 1 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job deprecate-true_false_null-2013-05-02T09-50-53.505Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/zorba/pregenerated/diagnostic_list.h'
2--- include/zorba/pregenerated/diagnostic_list.h 2013-04-23 13:12:58 +0000
3+++ include/zorba/pregenerated/diagnostic_list.h 2013-04-25 18:31:30 +0000
4@@ -944,6 +944,8 @@
5
6 extern ZORBA_DLL_PUBLIC ZorbaWarningCode ZWST0007_LOADER_PARSING_WARNING;
7
8+extern ZORBA_DLL_PUBLIC ZorbaWarningCode ZWST0008_DEPRECATED;
9+
10 } // namespace zwarn
11 } // namespace zorba
12 #endif /* ZORBA_DIAGNOSTIC_LIST_API_H */
13
14=== modified file 'modules/com/zorba-xquery/www/modules/pregenerated/warnings.xq'
15--- modules/com/zorba-xquery/www/modules/pregenerated/warnings.xq 2013-03-06 00:18:36 +0000
16+++ modules/com/zorba-xquery/www/modules/pregenerated/warnings.xq 2013-04-25 18:31:30 +0000
17@@ -76,4 +76,8 @@
18
19 (:~
20 :)
21-declare variable $zwarn:ZWST0007 as xs:QName := fn:QName($zwarn:NS, "zwarn:ZWST0007");
22\ No newline at end of file
23+declare variable $zwarn:ZWST0007 as xs:QName := fn:QName($zwarn:NS, "zwarn:ZWST0007");
24+
25+(:~
26+:)
27+declare variable $zwarn:ZWST0008 as xs:QName := fn:QName($zwarn:NS, "zwarn:ZWST0008");
28\ No newline at end of file
29
30=== modified file 'src/compiler/translator/translator.cpp'
31--- src/compiler/translator/translator.cpp 2013-04-24 03:54:58 +0000
32+++ src/compiler/translator/translator.cpp 2013-04-25 18:31:30 +0000
33@@ -9530,6 +9530,87 @@
34
35 ParseConstants::pathtype_t pe_type = pe.get_type();
36
37+ // terrible hack to allow for a standalone true, false or null to be
38+ // interpreted as a boolean. User must use ./true, ./false or ./null for
39+ // navigating XML elements named that way.
40+#ifdef ZORBA_WITH_JSON
41+ if (pe_type == ParseConstants::path_relative)
42+ {
43+ RelativePathExpr* lRootRelPathExpr =
44+ dynamic_cast<RelativePathExpr*>(pe.get_relpath_expr().getp());
45+
46+ ContextItemExpr* lStepExpr =
47+ dynamic_cast<ContextItemExpr*>(lRootRelPathExpr->get_step_expr());
48+
49+ AxisStep* lRelPathExpr =
50+ dynamic_cast<AxisStep*>(lRootRelPathExpr->get_relpath_expr());
51+
52+ // Only rewrites if expression consists of a context item step on the left
53+ // and of an axis step on the right,
54+ // AND if this context item was set implicitly by the parser, meaning,
55+ // the original expression was only an axis step.
56+ if (lRelPathExpr && lStepExpr && lRootRelPathExpr->is_implicit())
57+ {
58+ ForwardStep* lFwdStep =
59+ dynamic_cast<ForwardStep*>(lRelPathExpr->get_forward_step());
60+
61+ if (lFwdStep && lFwdStep->get_axis_kind() == ParseConstants::axis_child)
62+ {
63+ AbbrevForwardStep* lAbbrFwdStep =
64+ dynamic_cast<AbbrevForwardStep*>(lFwdStep->get_abbrev_step());
65+
66+ if (lAbbrFwdStep)
67+ {
68+ const NameTest* lNodetest =
69+ dynamic_cast<const NameTest*>(lAbbrFwdStep->get_node_test());
70+
71+ if (lNodetest)
72+ {
73+ const rchandle<QName> lQName = lNodetest->getQName();
74+
75+ if (lQName && lQName->get_prefix() == "")
76+ {
77+ const zstring& lLocal = lQName->get_localname();
78+
79+ bool lRet = false;
80+
81+ if (lLocal == "true")
82+ {
83+ push_nodestack(theExprManager->create_const_expr(theRootSctx, theUDF, loc, true));
84+ lRet = true;
85+ }
86+ else if (lLocal == "false")
87+ {
88+ push_nodestack(theExprManager->create_const_expr(theRootSctx, theUDF, loc, false));
89+ lRet = true;
90+ }
91+ else if (lLocal == "null")
92+ {
93+ store::Item_t lNull;
94+ GENV_ITEMFACTORY->createJSONNull(lNull);
95+ push_nodestack(theExprManager->create_const_expr(theRootSctx, theUDF, loc, lNull));
96+ lRet = true;
97+ }
98+
99+ if (lRet)
100+ {
101+ std::ostringstream lInstead;
102+ lInstead << ((lLocal == "null")?"jn:":"fn:");
103+ lInstead << lLocal << "()";
104+ theCCB->theXQueryDiagnostics->add_warning(
105+ NEW_XQUERY_WARNING(zwarn::ZWST0008_DEPRECATED,
106+ WARN_PARAMS(lLocal, lInstead.str()),
107+ WARN_LOC(loc)));
108+ return (void*)1;
109+ }
110+ }
111+ }
112+ }
113+ }
114+ }
115+ }
116+#endif
117+
118 relpath_expr* pathExpr = NULL;
119
120 // Put a NULL in the stack to mark the beginning of a PathExp tree.
121
122=== modified file 'src/diagnostics/diagnostic_en.xml'
123--- src/diagnostics/diagnostic_en.xml 2013-04-23 13:12:58 +0000
124+++ src/diagnostics/diagnostic_en.xml 2013-04-25 18:31:30 +0000
125@@ -3350,6 +3350,10 @@
126 <value>"$1":$2,$3: loader parsing warning${: 4}</value>
127 </diagnostic>
128
129+ <diagnostic code="ZWST0008" name="DEPRECATED">
130+ <value>"$1": has been deprecated; use "$2" instead</value>
131+ </diagnostic>
132+
133 </namespace>
134
135 <!--////////// Subvalues /////////////////////////////////////////////////-->
136
137=== modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp'
138--- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-04-23 13:12:58 +0000
139+++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-04-25 18:31:30 +0000
140@@ -1389,6 +1389,9 @@
141 ZorbaWarningCode ZWST0007_LOADER_PARSING_WARNING( "ZWST0007" );
142
143
144+ZorbaWarningCode ZWST0008_DEPRECATED( "ZWST0008" );
145+
146+
147 } // namespace zwarn
148
149 } // namespace zorba
150
151=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
152--- src/diagnostics/pregenerated/dict_en.cpp 2013-04-23 13:12:58 +0000
153+++ src/diagnostics/pregenerated/dict_en.cpp 2013-04-25 18:31:30 +0000
154@@ -491,6 +491,7 @@
155 { "ZWST0005", "\"$1\": function caching not possible; $2" },
156 { "ZWST0006", "\"$1\": function caching might not give the intended result because the function is declared as $2" },
157 { "ZWST0007", "\"$1\":$2,$3: loader parsing warning${: 4}" },
158+ { "ZWST0008", "\"$1\": has been deprecated; use \"$2\" instead" },
159 { "ZXQD0001", "\"$1\": prefix not declared when calling function \"$2\" from $3" },
160 { "ZXQD0002", "\"$1\": $2" },
161 { "ZXQD0003", "inconsistent options to the parse-xml() function: $1" },

Subscribers

People subscribed via source and target branches