Merge lp:~zorba-coders/zorba/redirect into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10558
Merged at revision: 10556
Proposed branch: lp:~zorba-coders/zorba/redirect
Merge into: lp:zorba
Diff against target: 258 lines (+104/-71)
5 files modified
ChangeLog (+1/-0)
doc/zorba/impl_dep_features.dox (+2/-2)
src/compiler/translator/translator.cpp (+1/-7)
src/functions/signature.cpp (+91/-61)
src/functions/signature.h (+9/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/redirect
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Juan Zacarias Approve
Matthias Brantner Pending
Review via email: mp+83227@code.launchpad.net

Commit message

Allow external functions to be updating.

Description of the change

Allow external functions to be updating.

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 redirect-2011-11-23T22-30-21.892Z 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. Got: 3 Pending.

Revision history for this message
Juan Zacarias (juan457) wrote :

It solves the issue for the evaluate-updating function for xqxq module to work as an updating function

review: Approve
Revision history for this message
Markos Zaharioudakis (markos-za) wrote :

I prefer a different fix, which brings us closer to the end goal of mixing PULs and XDM. I have committed this fix. Please review and make sure it works with xqxq.

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 redirect-2011-11-24T10-23-15.44Z 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. Got: 1 Approve, 3 Pending.

Revision history for this message
Juan Zacarias (juan457) wrote :

Is working for the xqxq module

Revision history for this message
Juan Zacarias (juan457) :
review: Approve
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 :

Validation queue job redirect-2011-11-25T12-45-17.416Z 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 'ChangeLog'
2--- ChangeLog 2011-11-23 16:27:08 +0000
3+++ ChangeLog 2011-11-24 10:24:28 +0000
4@@ -15,6 +15,7 @@
5 * Implemented the probe-index-range-value for general indexes
6 * Added ExternalFunctionParameter class to be registered in the DynamicContext
7 * New module for compiling and executing XQueries from XQuery (xqxq)
8+ * External functions are allowed to be updating (i.e. return a pending update list)
9
10 Optimization:
11 * Optimization for positioned sequence access (e.g. $x[$x[1]] where $x is a
12
13=== modified file 'doc/zorba/impl_dep_features.dox'
14--- doc/zorba/impl_dep_features.dox 2011-10-07 08:28:43 +0000
15+++ doc/zorba/impl_dep_features.dox 2011-11-24 10:24:28 +0000
16@@ -216,7 +216,7 @@
17 <tr bgcolor="lightcyan">
18 <td>W3C XQuery Update Facility 1.0</td>
19 <td>The mechanism (if any) by which an external function can return an XDM instance and/or a pending update list to the invoking query.</td>
20- <td>Zorba allows external functions to be implemented in C++. Such functions may return XDM instances. However, it is not possible to implement an updating external function.</td>
21+ <td>Zorba allows external functions to be implemented in C++. Such functions may return XDM instances. Moreover, external functions declared as updating may return pending update lists generated by any updating expression. However, it's not possible to create new update primtives and return those.</td>
22 </tr>
23 <tr bgcolor="lightcyan">
24 <td>W3C XQuery Update Facility 1.0</td>
25@@ -744,4 +744,4 @@
26 <td>static</td>
27 <td>no wildcards </td>
28 </tr>
29-</table>*/
30\ No newline at end of file
31+</table>*/
32
33=== modified file 'src/compiler/translator/translator.cpp'
34--- src/compiler/translator/translator.cpp 2011-11-22 08:57:25 +0000
35+++ src/compiler/translator/translator.cpp 2011-11-24 10:24:28 +0000
36@@ -3188,12 +3188,6 @@
37 // have an updating expr as input to a treat expr, which is not allowed
38 // yet.
39 //returnType = theRTM.EMPTY_TYPE;
40-
41- // TODO: remove this
42- if (func_decl->is_external())
43- {
44- returnType = theRTM.EMPTY_TYPE;
45- }
46 }
47
48 // Create the function signature.
49@@ -3228,7 +3222,7 @@
50 // We make sure that the types of the parameters and the return type
51 // are equal to the one that is declared in the module
52 const signature& s = f->getSignature();
53- if (!sig.equals(tm, s))
54+ if (!s.subtype(tm, sig, loc))
55 {
56 RAISE_ERROR(zerr::ZXQP0007_FUNCTION_SIGNATURE_NOT_EQUAL, loc,
57 ERROR_PARAMS(BUILD_STRING('{',
58
59=== modified file 'src/functions/signature.cpp'
60--- src/functions/signature.cpp 2011-07-01 05:22:12 +0000
61+++ src/functions/signature.cpp 2011-11-24 10:24:28 +0000
62@@ -37,68 +37,68 @@
63 :
64 theQName(name),
65 theIsVariadic(variadic)
66-{
67- theTypes.push_back(returnType);
68- theTypes.push_back(paramType1);
69-}
70-
71-
72-signature::signature(
73- const store::Item_t& name,
74- const xqtref_t& returnType)
75- :
76- theQName(name),
77- theIsVariadic(false)
78-{
79- theTypes.push_back(returnType);
80-}
81-
82-
83-signature::signature(
84- const store::Item_t& name,
85- const xqtref_t& paramType1,
86- const xqtref_t& returnType)
87- :
88- theQName(name),
89- theIsVariadic(false)
90-{
91- theTypes.push_back(returnType);
92- theTypes.push_back(paramType1);
93-}
94-
95-
96-signature::signature(
97- const store::Item_t& name,
98- const xqtref_t& paramType1,
99- const xqtref_t& paramType2,
100- const xqtref_t& returnType)
101- :
102- theQName(name),
103- theIsVariadic(false)
104-{
105- theTypes.push_back(returnType);
106- theTypes.push_back(paramType1);
107- theTypes.push_back(paramType2);
108-}
109-
110-
111-signature::signature(
112- const store::Item_t& name,
113- const xqtref_t& paramType1,
114- const xqtref_t& paramType2,
115+{
116+ theTypes.push_back(returnType);
117+ theTypes.push_back(paramType1);
118+}
119+
120+
121+signature::signature(
122+ const store::Item_t& name,
123+ const xqtref_t& returnType)
124+ :
125+ theQName(name),
126+ theIsVariadic(false)
127+{
128+ theTypes.push_back(returnType);
129+}
130+
131+
132+signature::signature(
133+ const store::Item_t& name,
134+ const xqtref_t& paramType1,
135+ const xqtref_t& returnType)
136+ :
137+ theQName(name),
138+ theIsVariadic(false)
139+{
140+ theTypes.push_back(returnType);
141+ theTypes.push_back(paramType1);
142+}
143+
144+
145+signature::signature(
146+ const store::Item_t& name,
147+ const xqtref_t& paramType1,
148+ const xqtref_t& paramType2,
149+ const xqtref_t& returnType)
150+ :
151+ theQName(name),
152+ theIsVariadic(false)
153+{
154+ theTypes.push_back(returnType);
155+ theTypes.push_back(paramType1);
156+ theTypes.push_back(paramType2);
157+}
158+
159+
160+signature::signature(
161+ const store::Item_t& name,
162+ const xqtref_t& paramType1,
163+ const xqtref_t& paramType2,
164 const xqtref_t& paramType3,
165- const xqtref_t& returnType)
166- :
167- theQName(name),
168- theIsVariadic(false)
169-{
170- theTypes.push_back(returnType);
171- theTypes.push_back(paramType1);
172- theTypes.push_back(paramType2);
173+ const xqtref_t& returnType)
174+ :
175+ theQName(name),
176+ theIsVariadic(false)
177+{
178+ theTypes.push_back(returnType);
179+ theTypes.push_back(paramType1);
180+ theTypes.push_back(paramType2);
181 theTypes.push_back(paramType3);
182 }
183-
184-
185+
186+
187 signature::signature(
188 const store::Item_t& name,
189 const xqtref_t& paramType1,
190@@ -237,7 +237,10 @@
191 }
192
193
194-bool signature::equals(const TypeManager* tm, const signature& s) const
195+bool signature::equals(
196+ const TypeManager* tm,
197+ const signature& s,
198+ const QueryLoc& loc) const
199 {
200 if (paramCount() != s.paramCount())
201 return false;
202@@ -251,7 +254,34 @@
203 if (!TypeOps::is_equal(tm,
204 *theTypes[i].getp(),
205 *s.theTypes[i].getp(),
206- QueryLoc::null))
207+ loc))
208+ {
209+ return false;
210+ }
211+ }
212+
213+ return true;
214+}
215+
216+
217+bool signature::subtype(
218+ const TypeManager* tm,
219+ const signature& s,
220+ const QueryLoc& loc) const
221+{
222+ if (paramCount() != s.paramCount())
223+ return false;
224+
225+ if (!theQName->equals(s.theQName.getp()))
226+ return false;
227+
228+ assert (s.theTypes.size() == theTypes.size() || theIsVariadic );
229+ for (csize i = 0; i < theTypes.size(); ++i)
230+ {
231+ if (!TypeOps::is_subtype(tm,
232+ *theTypes[i].getp(),
233+ *s.theTypes[i].getp(),
234+ loc))
235 {
236 return false;
237 }
238
239=== modified file 'src/functions/signature.h'
240--- src/functions/signature.h 2011-06-21 05:41:24 +0000
241+++ src/functions/signature.h 2011-11-24 10:24:28 +0000
242@@ -168,7 +168,15 @@
243
244 xqtref_t& returnType() { return theTypes[0]; }
245
246- bool equals(const TypeManager* tm, const signature& s) const;
247+ bool equals(
248+ const TypeManager* tm,
249+ const signature& s,
250+ const QueryLoc& loc) const;
251+
252+ bool subtype(
253+ const TypeManager* tm,
254+ const signature& s,
255+ const QueryLoc& loc) const;
256 };
257
258 } /* namespace zorba */

Subscribers

People subscribed via source and target branches