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

Proposed by Juan Zacarias
Status: Merged
Approved by: Matthias Brantner
Approved revision: 10558
Merged at revision: 10561
Proposed branch: lp:~zorba-coders/zorba/api_changes
Merge into: lp:zorba
Diff against target: 252 lines (+104/-15)
8 files modified
ChangeLog (+1/-1)
include/zorba/dynamic_context.h (+13/-0)
include/zorba/xquery.h (+0/-7)
src/api/dynamiccontextimpl.cpp (+34/-0)
src/api/dynamiccontextimpl.h (+6/-0)
src/api/xqueryimpl.cpp (+1/-2)
src/api/xqueryimpl.h (+2/-2)
test/unit/cxx_api_changes.cpp (+47/-3)
To merge this branch: bzr merge lp:~zorba-coders/zorba/api_changes
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Markos Zaharioudakis Approve
Review via email: mp+83426@code.launchpad.net

Commit message

API changes
Removed isBoundExternalVariable from xquery.h
Added 2 functions to dynamic_context.h
isBoundContextItem and isBoundExternalVariable

Description of the change

API changes
Removed isBoundExternalVariable from xquery.h
Added 2 functions to dynamic_context.h
isBoundContextItem and isBoundExternalVariable

To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

The ChangeLog should also mention the function isBoundContextItem in the entry that currently already mentions isBoundExternalVariable.

Also, the diff looks like the commit was using tabs for indentation. Could you please change them into spaces?

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

done

Revision history for this message
Matthias Brantner (matthias-brantner) :
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/api_changes into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:272 (message):
  Validation queue job api_changes-2011-11-29T00-19-04.132Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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/api_changes into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:272 (message):
  Validation queue job api_changes-2011-11-30T03-17-11.87Z is finished. The
  final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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 api_changes-2011-11-30T04-34-11.991Z 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 22:25:05 +0000
3+++ ChangeLog 2011-11-28 23:55:27 +0000
4@@ -8,7 +8,7 @@
5 * New node-reference module. References can be obtained for any node, and
6 different nodes cannot have the same identifier.
7 * Custom Full-text thesaurus using Zorba URI resolver mechanism.
8- * Modified C++ API to add isSequential, getExternalVariables, and
9+ * Modified C++ API to add isSequential, getExternalVariables, isBoundContextItem and
10 isBoundExternalVariable Functions
11 * Collection allows to retrieve information about the type
12 and the annotations of a static collection.
13
14=== modified file 'include/zorba/dynamic_context.h'
15--- include/zorba/dynamic_context.h 2011-10-20 17:17:48 +0000
16+++ include/zorba/dynamic_context.h 2011-11-28 23:55:27 +0000
17@@ -263,6 +263,19 @@
18 virtual ExternalFunctionParameter*
19 getExternalFunctionParameter ( const String& aName ) const = 0;
20
21+ /** \brief Returns true if the variable is bound to a value
22+ *
23+ * @param aNamespace the namespace of the qname of the variable to check
24+ * @param aLocalname the localname of the qname of the variable to check
25+ */
26+ virtual bool
27+ isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const = 0;
28+
29+ /** \brief Returns true if a context item has been bound to the Dynamic Context
30+ */
31+ virtual bool
32+ isBoundContextItem() const = 0;
33+
34 protected:
35 /** \brief Destructor
36 */
37
38=== modified file 'include/zorba/xquery.h'
39--- include/zorba/xquery.h 2011-11-11 18:32:12 +0000
40+++ include/zorba/xquery.h 2011-11-28 23:55:27 +0000
41@@ -304,13 +304,6 @@
42 */
43 virtual void
44 printPlan(std::ostream& aStream, bool aDotFormat = false) const = 0;
45-
46- /** \brief Returns true if the variable is bound to a value
47- *
48- * @param aQName the qname of the variable to check
49- */
50- virtual bool
51- isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const = 0;
52
53 /**
54 * \brief Check if this query is an updating query.
55
56=== modified file 'src/api/dynamiccontextimpl.cpp'
57--- src/api/dynamiccontextimpl.cpp 2011-10-20 17:17:48 +0000
58+++ src/api/dynamiccontextimpl.cpp 2011-11-28 23:55:27 +0000
59@@ -182,6 +182,7 @@
60 return var;
61 }
62
63+
64 /****************************************************************************//**
65
66 ********************************************************************************/
67@@ -592,6 +593,7 @@
68 return false;
69 }
70
71+
72 /****************************************************************************//**
73
74 ********************************************************************************/
75@@ -607,5 +609,37 @@
76 return 0;
77 }
78
79+
80+/****************************************************************************//**
81+
82+********************************************************************************/
83+bool
84+DynamicContextImpl::isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const
85+{
86+ ZORBA_DCTX_TRY
87+ {
88+ if(theQuery->isBoundVariable(aNamespace, aLocalname))
89+ return true;
90+ }
91+ ZORBA_DCTX_CATCH
92+ return false;
93+}
94+
95+/****************************************************************************//**
96+
97+********************************************************************************/
98+bool
99+DynamicContextImpl::isBoundContextItem() const
100+{
101+ ZORBA_DCTX_TRY
102+ {
103+ String varName = Unmarshaller::newString(static_context::DOT_VAR_NAME);
104+ if(theQuery->isBoundVariable("", varName))
105+ return true;
106+ }
107+ ZORBA_DCTX_CATCH
108+ return false;
109+}
110+
111 } // namespace zorba
112 /* vim:set et sw=2 ts=2: */
113
114=== modified file 'src/api/dynamiccontextimpl.h'
115--- src/api/dynamiccontextimpl.h 2011-10-20 17:17:48 +0000
116+++ src/api/dynamiccontextimpl.h 2011-11-28 23:55:27 +0000
117@@ -143,6 +143,12 @@
118 virtual ExternalFunctionParameter*
119 getExternalFunctionParameter ( const String& aName ) const;
120
121+ virtual bool
122+ isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const;
123+
124+ virtual bool
125+ isBoundContextItem() const;
126+
127 protected:
128 void checkNoIterators() const;
129
130
131=== modified file 'src/api/xqueryimpl.cpp'
132--- src/api/xqueryimpl.cpp 2011-11-11 18:32:12 +0000
133+++ src/api/xqueryimpl.cpp 2011-11-28 23:55:27 +0000
134@@ -772,11 +772,10 @@
135 QUERY_CATCH
136 }
137
138-
139 /*******************************************************************************
140
141 ********************************************************************************/
142-bool XQueryImpl::isBoundExternalVariable(
143+bool XQueryImpl::isBoundVariable(
144 const String& aNamespace,
145 const String& aLocalname) const
146 {
147
148=== modified file 'src/api/xqueryimpl.h'
149--- src/api/xqueryimpl.h 2011-11-11 18:32:12 +0000
150+++ src/api/xqueryimpl.h 2011-11-28 23:55:27 +0000
151@@ -286,8 +286,6 @@
152
153 void getExternalVariables(Iterator_t& aVarsIter) const;
154
155- bool isBoundExternalVariable(const String& aNamespace, const String& aLocalname) const;
156-
157 bool isUpdating() const;
158
159 bool isSequential() const;
160@@ -399,6 +397,8 @@
161 #endif
162
163 void notifyAllWarnings() const;
164+
165+ bool isBoundVariable(const String& aNamespace, const String& aLocalname) const;
166 };
167
168
169
170=== modified file 'test/unit/cxx_api_changes.cpp'
171--- test/unit/cxx_api_changes.cpp 2011-11-11 18:32:12 +0000
172+++ test/unit/cxx_api_changes.cpp 2011-11-28 23:55:27 +0000
173@@ -226,7 +226,7 @@
174 std::vector<Item>::const_iterator lEnd = lVars.end();
175
176 Item item = aZorba->getItemFactory()->createInt(4);
177-
178+
179
180 bool isBound1;
181 bool isBound2;
182@@ -234,10 +234,10 @@
183 for(; lIte != lEnd; ++lIte)
184 {
185 Item qname = *lIte;
186- isBound1 = lQuery->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
187+ isBound1 = lQuery->getDynamicContext()->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
188 Item value = aZorba->getItemFactory()->createString("foo");
189 lQuery->getDynamicContext()->setVariable(qname.getStringValue(), value);
190- isBound2 = lQuery->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
191+ isBound2 = lQuery->getDynamicContext()->isBoundExternalVariable(qname.getNamespace(), qname.getLocalName());
192 }
193
194 if (!isBound1 && isBound2)
195@@ -258,6 +258,44 @@
196 return true;
197 }
198
199+bool
200+cxx_api_changes_test6(Zorba* aZorba)
201+{
202+ try
203+ {
204+
205+ std::string lIn = "1+1";
206+
207+ XQuery_t lQuery = aZorba->compileQuery(lIn);
208+
209+ Zorba* lZorba = Zorba::getInstance(0);
210+
211+ bool isBound1;
212+ bool isBound2;
213+
214+ isBound1 = lQuery->getDynamicContext()->isBoundContextItem();
215+
216+ Item lContextItem = aZorba->getItemFactory()->createString("foo");
217+ lQuery->getDynamicContext()->setContextItem(lContextItem);
218+ isBound2 = lQuery->getDynamicContext()->isBoundContextItem();
219+
220+ if (!isBound1 && isBound2)
221+ return true;
222+
223+ }
224+ catch (XQueryException& qe)
225+ {
226+ std::cerr << qe << std::endl;
227+ return false;
228+ }
229+ catch (ZorbaException& e)
230+ {
231+ std::cerr << e << std::endl;
232+ return false;
233+ }
234+
235+ return true;
236+}
237
238 int
239 cxx_api_changes (int argc, char* argv[])
240@@ -295,6 +333,12 @@
241 return 5;
242 }
243
244+ std::cout << "executing cxx_api_changes_test6" << std::endl;
245+ if (!cxx_api_changes_test6(lZorba))
246+ {
247+ return 6;
248+ }
249+
250 lZorba->shutdown();
251 zorba::StoreManager::shutdownStore(lStore);
252 return 0;

Subscribers

People subscribed via source and target branches