Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba
- pjl-misc
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Matthias Brantner |
Approved revision: | 11262 |
Merged at revision: | 11529 |
Proposed branch: | lp:~paul-lucas/zorba/pjl-misc |
Merge into: | lp:zorba |
Diff against target: |
1293 lines (+213/-437) 29 files modified
ChangeLog (+1/-0) doc/cxx/examples/jsoniq.cpp (+2/-62) include/zorba/item_factory.h (+0/-9) src/api/dynamiccontextimpl.cpp (+4/-4) src/api/itemfactoryimpl.cpp (+6/-15) src/api/itemfactoryimpl.h (+0/-3) src/capi/csequence.cpp (+7/-7) src/capi/cstatic_context.cpp (+5/-5) src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp (+1/-1) src/context/static_context.cpp (+1/-1) src/runtime/json/json_loader.cpp (+22/-2) src/store/api/item_factory.h (+0/-4) src/store/naive/atomic_items.cpp (+3/-3) src/store/naive/simple_item_factory.cpp (+0/-52) src/store/naive/simple_item_factory.h (+0/-8) src/types/casting.cpp (+5/-5) src/types/schema/XercesParseUtils.cpp (+2/-2) src/util/json_parser.cpp (+23/-7) src/util/json_parser.h (+32/-1) src/zorbaserialization/serialize_basic_types.cpp (+2/-2) src/zorbatypes/decimal.h (+29/-0) src/zorbatypes/float.h (+34/-0) src/zorbatypes/integer.h (+33/-0) swig/ItemFactory.h (+1/-11) swig/ItemFactory.i (+0/-4) swig/csharp/tests/test10.cs (+0/-86) swig/php/tests/test11.php (+0/-59) swig/python/tests/test13.py (+0/-43) swig/ruby/tests/test13.rb (+0/-41) |
To merge this branch: | bzr merge lp:~paul-lucas/zorba/pjl-misc |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Paul J. Lucas | Approve | ||
Review via email: mp+170225@code.launchpad.net |
Commit message
* Added numeric_type to json::token.
* Removed createJSONNumber().
* Added constructors and assignment operators to Integer, Decimal, and Float that take a string type.
* Clean-up of now unnecessary use of c_str().
Description of the change
* Added numeric_type to json::token.
* Removed createJSONNumber().
* Added constructors and assignment operators to Integer, Decimal, and Float that take a string type.
* Clean-up of now unnecessary use of c_str().
Paul J. Lucas (paul-lucas) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job pjl-misc-
final status was:
4 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job pjl-misc-
All tests succeeded!
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 Approve.
- 11257. By Paul J. Lucas
-
Updated ChangeLog.
- 11258. By Paul J. Lucas
-
Added operator<<() for token::
numeric_ type. - 11259. By Paul J. Lucas
-
Tweaks.
- 11260. By Paul J. Lucas
-
Merge from trunk.
Matthias Brantner (matthias-brantner) wrote : | # |
- I think we should remove the examples 7 and 8. The tests don't make sense anymore
- Is it possible to avoid the string copy in line 338 of the diff (s = t.get_value())?
- The csharp, php, ruby, and python tests can also be removed
- What's the performance gain?
Paul J. Lucas (paul-lucas) wrote : | # |
- I removed examples 7 & 8.
- The string copy isn't a copy: it's just a ref-count increment. Regardless, it's gone.
- Which c#, php, ruby, and python tests? While file(s)? Please be specific.
- I don't know what the perf. gain is.
Matthias Brantner (matthias-brantner) wrote : | # |
> - Which c#, php, ruby, and python tests? While file(s)? Please be specific.
swig/csharp/
swig/php/
swig/python/
swig/ruby/
> - I don't know what the perf. gain is.
Maybe it would be worth finding out.
- 11261. By Paul J. Lucas
-
Removed tests.
- 11262. By Paul J. Lucas
-
Merge from trunk.
Paul J. Lucas (paul-lucas) wrote : | # |
Tests removed.
The point of this MP was to remove the confusing createJSONNumber(). The performance has probably improved slightly due to removing an extra virtual function call. If you want to find out more, you're free to run some tests.
Matthias Brantner (matthias-brantner) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job pjl-misc-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2013-06-19 19:27:26 +0000 |
3 | +++ ChangeLog 2013-06-19 22:22:31 +0000 |
4 | @@ -25,6 +25,7 @@ |
5 | * Fixed bug #1188084 (fn-replace-42 failing) |
6 | * Fixed bug in hoisting through try-catch expr |
7 | * Fixed bug #1162631 (format-integer 'w' format of negative numbers) |
8 | + * Fixed bug #1192285 (Have JSON token know number subtype) |
9 | * Fixed bug #1190261 (relative paths bug in file module) |
10 | * Fixed bug #1187537 (Eliminate (or at least reduce) use of MAX_PATH) |
11 | * Fixed bug #1180220 (Consolidate redundant path/file public APIs) |
12 | |
13 | === modified file 'doc/cxx/examples/jsoniq.cpp' |
14 | --- doc/cxx/examples/jsoniq.cpp 2013-02-07 17:24:36 +0000 |
15 | +++ doc/cxx/examples/jsoniq.cpp 2013-06-19 22:22:31 +0000 |
16 | @@ -196,59 +196,9 @@ |
17 | } |
18 | |
19 | /** |
20 | - * Test creating some JSON numbers. |
21 | - */ |
22 | -bool |
23 | -example_7(Zorba* aZorba) |
24 | -{ |
25 | - Item lNum = aZorba->getItemFactory()->createJSONNumber(String("12345")); |
26 | - if (lNum.getType().getLocalName().compare("integer") != 0) { |
27 | - std::cout << "Didn't create an xs:integer!"; |
28 | - return false; |
29 | - } |
30 | - if (!serialize(aZorba, lNum, "12345")) { |
31 | - return false; |
32 | - } |
33 | - |
34 | - lNum = aZorba->getItemFactory()->createJSONNumber(String("123.345")); |
35 | - if (lNum.getType().getLocalName().compare("decimal") != 0) { |
36 | - std::cout << "Didn't create an xs:decimal!"; |
37 | - return false; |
38 | - } |
39 | - if (!serialize(aZorba, lNum, "123.345")) { |
40 | - return false; |
41 | - } |
42 | - |
43 | - lNum = aZorba->getItemFactory()->createJSONNumber(String("12.34e5")); |
44 | - if (lNum.getType().getLocalName().compare("double") != 0) { |
45 | - std::cout << "Didn't create an xs:double!"; |
46 | - return false; |
47 | - } |
48 | - if (!serialize(aZorba, lNum, "1.234E6")) { |
49 | - return false; |
50 | - } |
51 | - |
52 | - return true; |
53 | -} |
54 | - |
55 | -/** |
56 | - * Test creating a JSON object. |
57 | - */ |
58 | -bool example_8(Zorba* aZorba) |
59 | -{ |
60 | - Item lValue = aZorba->getItemFactory()->createJSONNumber("1234"); |
61 | - Item lName = aZorba->getItemFactory()->createString("name"); |
62 | - std::vector<std::pair<Item, Item> > pairs; |
63 | - pairs.push_back(std::pair<Item, Item>(lName, lValue)); |
64 | - Item lObj = aZorba->getItemFactory()->createJSONObject(pairs); |
65 | - |
66 | - return serialize(aZorba, lObj, "{ \"name\" : 1234 }"); |
67 | -} |
68 | - |
69 | -/** |
70 | * Test creating a JSON array. |
71 | */ |
72 | -bool example_9(Zorba* aZorba) |
73 | +bool example_7(Zorba* aZorba) |
74 | { |
75 | std::vector<Item> lMembers; |
76 | for (int i = 1; i <= 4; i++) { |
77 | @@ -301,20 +251,10 @@ |
78 | if (!res) return 1; |
79 | std::cout << std::endl; |
80 | |
81 | - std::cout << "executing jsoniq example 7" << std::endl; |
82 | + std::cout << "executing jsoniq example 9" << std::endl; |
83 | res = jsoniq_test::example_7(lZorba); |
84 | if (!res) return 1; |
85 | std::cout << std::endl; |
86 | - |
87 | - std::cout << "executing jsoniq example 8" << std::endl; |
88 | - res = jsoniq_test::example_8(lZorba); |
89 | - if (!res) return 1; |
90 | - std::cout << std::endl; |
91 | - |
92 | - std::cout << "executing jsoniq example 9" << std::endl; |
93 | - res = jsoniq_test::example_9(lZorba); |
94 | - if (!res) return 1; |
95 | - std::cout << std::endl; |
96 | } |
97 | catch (ZorbaException& e) { |
98 | std::cout << "ZorbaException raised: " << e.what() << std::endl; |
99 | |
100 | === modified file 'include/zorba/item_factory.h' |
101 | --- include/zorba/item_factory.h 2013-06-15 02:57:08 +0000 |
102 | +++ include/zorba/item_factory.h 2013-06-19 22:22:31 +0000 |
103 | @@ -769,15 +769,6 @@ |
104 | virtual Item createJSONNull() = 0; |
105 | |
106 | /** |
107 | - * Create a JSON Number item from a string. This will actually be |
108 | - * an xs:integer, xs:double, or xs:decimal, depending on the content |
109 | - * of the string. |
110 | - * |
111 | - * @param aString The input string. |
112 | - */ |
113 | - virtual Item createJSONNumber(String aString) = 0; |
114 | - |
115 | - /** |
116 | * Create a JSON Object containing the specified JSON Pairs. |
117 | * |
118 | * @param aNames A vector containing the name and value of each pair. |
119 | |
120 | === modified file 'src/api/dynamiccontextimpl.cpp' |
121 | --- src/api/dynamiccontextimpl.cpp 2013-05-08 20:14:47 +0000 |
122 | +++ src/api/dynamiccontextimpl.cpp 2013-06-19 22:22:31 +0000 |
123 | @@ -730,7 +730,7 @@ |
124 | { |
125 | ZORBA_DCTX_TRY |
126 | { |
127 | - std::string lName = aName.c_str(); |
128 | + std::string lName( aName.c_str() ); |
129 | return theCtx->addExternalFunctionParam(lName, aValue); |
130 | } |
131 | ZORBA_DCTX_CATCH |
132 | @@ -747,7 +747,7 @@ |
133 | { |
134 | ZORBA_DCTX_TRY |
135 | { |
136 | - std::string lName = aName.c_str(); |
137 | + std::string lName( aName.c_str() ); |
138 | return theCtx->getExternalFunctionParam(lName, aValue); |
139 | } |
140 | ZORBA_DCTX_CATCH |
141 | @@ -765,7 +765,7 @@ |
142 | { |
143 | ZORBA_DCTX_TRY |
144 | { |
145 | - std::string lName = aName.c_str(); |
146 | + std::string lName( aName.c_str() ); |
147 | return theCtx->addExternalFunctionParameter(lName, aValue); |
148 | } |
149 | ZORBA_DCTX_CATCH |
150 | @@ -781,7 +781,7 @@ |
151 | { |
152 | ZORBA_DCTX_TRY |
153 | { |
154 | - std::string lName = aName.c_str(); |
155 | + std::string lName( aName.c_str() ); |
156 | return theCtx->getExternalFunctionParameter(lName); |
157 | } |
158 | ZORBA_DCTX_CATCH |
159 | |
160 | === modified file 'src/api/itemfactoryimpl.cpp' |
161 | --- src/api/itemfactoryimpl.cpp 2013-06-15 02:57:08 +0000 |
162 | +++ src/api/itemfactoryimpl.cpp 2013-06-19 22:22:31 +0000 |
163 | @@ -298,7 +298,7 @@ |
164 | Item ItemFactoryImpl::createDecimalFromLong (unsigned long aValue) |
165 | { |
166 | store::Item_t lItem; |
167 | - Decimal const lDecimal(aValue); |
168 | + xs_decimal const lDecimal(aValue); |
169 | theItemFactory->createDecimal(lItem, lDecimal); |
170 | return &*lItem; |
171 | } |
172 | @@ -308,7 +308,7 @@ |
173 | { |
174 | store::Item_t lItem; |
175 | try { |
176 | - Decimal const lDecimal(aValue); |
177 | + xs_decimal const lDecimal(aValue); |
178 | theItemFactory->createDecimal(lItem, lDecimal); |
179 | } |
180 | catch ( std::invalid_argument const& ) { |
181 | @@ -323,7 +323,7 @@ |
182 | store::Item_t lItem; |
183 | zstring lString = Unmarshaller::getInternalString(aValue); |
184 | try { |
185 | - Decimal const lDecimal(lString.c_str()); |
186 | + xs_decimal const lDecimal(lString); |
187 | theItemFactory->createDecimal(lItem, lDecimal); |
188 | } |
189 | catch ( std::exception const& ) { |
190 | @@ -349,7 +349,7 @@ |
191 | zstring const &lString = Unmarshaller::getInternalString( aInteger ); |
192 | store::Item_t lItem; |
193 | try { |
194 | - xs_integer const lInteger( lString.c_str() ); |
195 | + xs_integer const lInteger( lString ); |
196 | theItemFactory->createInteger(lItem, lInteger); |
197 | } |
198 | catch ( std::exception const& ) { |
199 | @@ -475,7 +475,7 @@ |
200 | |
201 | store::Item_t lItem; |
202 | try { |
203 | - xs_double const lDouble(lString.c_str()); |
204 | + xs_double const lDouble(lString); |
205 | theItemFactory->createDouble(lItem, lDouble); |
206 | } |
207 | catch ( std::exception const& ) { |
208 | @@ -549,7 +549,7 @@ |
209 | zstring const &lString = Unmarshaller::getInternalString( aValue ); |
210 | store::Item_t lItem; |
211 | try { |
212 | - xs_float const lFloat(lString.c_str()); |
213 | + xs_float const lFloat(lString); |
214 | theItemFactory->createFloat(lItem, lFloat); |
215 | } |
216 | catch ( std::exception const& ) { |
217 | @@ -960,15 +960,6 @@ |
218 | return &*lItem; |
219 | } |
220 | |
221 | -zorba::Item ItemFactoryImpl::createJSONNumber(String aString) |
222 | -{ |
223 | - store::Item_t lItem; |
224 | - zstring &lString = Unmarshaller::getInternalString(aString); |
225 | - theItemFactory->createJSONNumber(lItem, lString); |
226 | - return &*lItem; |
227 | -} |
228 | - |
229 | - |
230 | zorba::Item ItemFactoryImpl::createJSONObject( |
231 | std::vector<std::pair<Item, Item> >& aPairs) |
232 | { |
233 | |
234 | === modified file 'src/api/itemfactoryimpl.h' |
235 | --- src/api/itemfactoryimpl.h 2013-06-15 02:57:08 +0000 |
236 | +++ src/api/itemfactoryimpl.h 2013-06-19 22:22:31 +0000 |
237 | @@ -292,9 +292,6 @@ |
238 | createJSONNull(); |
239 | |
240 | virtual Item |
241 | - createJSONNumber(String aString); |
242 | - |
243 | - virtual Item |
244 | createJSONObject(std::vector<std::pair<Item, Item> >& aPairs); |
245 | |
246 | virtual Item |
247 | |
248 | === modified file 'src/capi/csequence.cpp' |
249 | --- src/capi/csequence.cpp 2013-05-15 23:22:01 +0000 |
250 | +++ src/capi/csequence.cpp 2013-06-19 22:22:31 +0000 |
251 | @@ -351,8 +351,8 @@ |
252 | me->theStrings.push_back(lUri); |
253 | zorba::String lLocal = lItem.getLocalName(); |
254 | me->theStrings.push_back(lLocal); |
255 | - (*uri) = lUri.c_str(); |
256 | - (*name) = lLocal.c_str(); |
257 | + *uri = lUri.c_str(); |
258 | + *name = lLocal.c_str(); |
259 | } |
260 | SEQ_CATCH; |
261 | } |
262 | @@ -367,7 +367,7 @@ |
263 | } |
264 | zorba::String lString = me->theItem.getStringValue(); |
265 | me->theStrings.push_back(lString); |
266 | - (*value) = lString.c_str(); |
267 | + *value = lString.c_str(); |
268 | } |
269 | SEQ_CATCH; |
270 | } |
271 | @@ -439,8 +439,8 @@ |
272 | // de-allocated memory. |
273 | try { |
274 | String const lStringValue = me->theItem.getStringValue(); |
275 | - xs_double const doublevalue( lStringValue.c_str() ); |
276 | - (*value) = static_cast<double> (doublevalue.getNumber()); |
277 | + xs_double const doublevalue( lStringValue ); |
278 | + *value = static_cast<double> (doublevalue.getNumber()); |
279 | } |
280 | catch ( std::exception const& ) { |
281 | return XQC_TYPE_ERROR; |
282 | @@ -474,8 +474,8 @@ |
283 | me->theStrings.push_back(lUri); |
284 | zorba::String lName = lNodeName->getLocalName(); |
285 | me->theStrings.push_back(lName); |
286 | - (*uri) = lUri.c_str(); |
287 | - (*name) = lName.c_str(); |
288 | + *uri = lUri.c_str(); |
289 | + *name = lName.c_str(); |
290 | } |
291 | SEQ_CATCH; |
292 | } |
293 | |
294 | === modified file 'src/capi/cstatic_context.cpp' |
295 | --- src/capi/cstatic_context.cpp 2013-02-07 17:24:36 +0000 |
296 | +++ src/capi/cstatic_context.cpp 2013-06-19 22:22:31 +0000 |
297 | @@ -164,7 +164,7 @@ |
298 | getNamespaceURIByPrefix(prefix); |
299 | me->theStrings.push_back(lNS); |
300 | |
301 | - (*result_ns) = lNS.c_str(); |
302 | + *result_ns = lNS.c_str(); |
303 | } |
304 | SC_CATCH; |
305 | } |
306 | @@ -187,7 +187,7 @@ |
307 | zorba::String lURI = me->theContext.get()-> |
308 | getDefaultElementAndTypeNamespace(); |
309 | me->theStrings.push_back(lURI); |
310 | - (*uri) = lURI.c_str(); |
311 | + *uri = lURI.c_str(); |
312 | } |
313 | SC_CATCH; |
314 | } |
315 | @@ -209,7 +209,7 @@ |
316 | SC_TRY { |
317 | zorba::String lURI = me->theContext.get()->getDefaultFunctionNamespace(); |
318 | me->theStrings.push_back(lURI); |
319 | - (*uri) = lURI.c_str(); |
320 | + *uri = lURI.c_str(); |
321 | } |
322 | SC_CATCH; |
323 | } |
324 | @@ -241,7 +241,7 @@ |
325 | SC_TRY { |
326 | zorba::String lURI = me->theContext.get()->getDefaultCollation(); |
327 | me->theStrings.push_back(lURI); |
328 | - (*uri) = lURI.c_str(); |
329 | + *uri = lURI.c_str(); |
330 | } |
331 | SC_CATCH; |
332 | } |
333 | @@ -597,7 +597,7 @@ |
334 | SC_TRY { |
335 | zorba::String lBaseURI = me->theContext.get()->getBaseURI(); |
336 | me->theStrings.push_back(lBaseURI); |
337 | - (*base_uri) = lBaseURI.c_str(); |
338 | + *base_uri = lBaseURI.c_str(); |
339 | } |
340 | SC_CATCH; |
341 | } |
342 | |
343 | === modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp' |
344 | --- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-06-07 13:46:26 +0000 |
345 | +++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-06-19 22:22:31 +0000 |
346 | @@ -181,7 +181,7 @@ |
347 | } |
348 | } |
349 | } |
350 | - zstring lTmp = lAttrValue.str().c_str(); |
351 | + zstring lTmp( lAttrValue.str() ); |
352 | store::Item_t lAttrValueItem; |
353 | theFactory->createString(lAttrValueItem, lTmp); |
354 | |
355 | |
356 | === modified file 'src/context/static_context.cpp' |
357 | --- src/context/static_context.cpp 2013-06-15 02:57:08 +0000 |
358 | +++ src/context/static_context.cpp 2013-06-19 22:22:31 +0000 |
359 | @@ -3430,7 +3430,7 @@ |
360 | if (theDefaultCollation != NULL || !is_known_collation(uri)) |
361 | throw XQUERY_EXCEPTION(err::XQST0038, ERROR_LOC(loc)); |
362 | |
363 | - zstring resolvedUri = resolve_relative_uri(uri); |
364 | + zstring const resolvedUri( resolve_relative_uri(uri) ); |
365 | |
366 | theDefaultCollation = new std::string(resolvedUri.c_str()); |
367 | } |
368 | |
369 | === modified file 'src/runtime/json/json_loader.cpp' |
370 | --- src/runtime/json/json_loader.cpp 2013-06-15 02:57:08 +0000 |
371 | +++ src/runtime/json/json_loader.cpp 2013-06-19 22:22:31 +0000 |
372 | @@ -26,6 +26,9 @@ |
373 | #include "diagnostics/xquery_diagnostics.h" |
374 | #include "store/api/item_factory.h" |
375 | #include "system/globalenv.h" |
376 | +#include "zorbatypes/decimal.h" |
377 | +#include "zorbatypes/float.h" |
378 | +#include "zorbatypes/integer.h" |
379 | #include "zorbatypes/zstring.h" |
380 | |
381 | // local |
382 | @@ -178,8 +181,25 @@ |
383 | case ',': |
384 | continue; |
385 | case token::number: |
386 | - s = t.get_value(); |
387 | - GENV_ITEMFACTORY->createJSONNumber( item, s ); |
388 | + switch ( t.get_numeric_type() ) { |
389 | + case token::integer: |
390 | + GENV_ITEMFACTORY->createInteger( |
391 | + item, xs_integer( t.get_value() ) |
392 | + ); |
393 | + break; |
394 | + case token::decimal: |
395 | + GENV_ITEMFACTORY->createDecimal( |
396 | + item, xs_decimal( t.get_value() ) |
397 | + ); |
398 | + break; |
399 | + case token::floating_point: |
400 | + GENV_ITEMFACTORY->createDouble( |
401 | + item, xs_double( t.get_value() ) |
402 | + ); |
403 | + break; |
404 | + default: |
405 | + assert( false ); |
406 | + } |
407 | break; |
408 | case token::string: |
409 | s = t.get_value(); |
410 | |
411 | === modified file 'src/store/api/item_factory.h' |
412 | --- src/store/api/item_factory.h 2013-06-15 02:57:08 +0000 |
413 | +++ src/store/api/item_factory.h 2013-06-19 22:22:31 +0000 |
414 | @@ -797,10 +797,6 @@ |
415 | |
416 | virtual bool createJSONNull(Item_t& result) = 0; |
417 | |
418 | - virtual bool createJSONNumber(Item_t& result, Item_t& string) = 0; |
419 | - |
420 | - virtual bool createJSONNumber(Item_t& result, zstring& string) = 0; |
421 | - |
422 | /** |
423 | * |
424 | */ |
425 | |
426 | === modified file 'src/store/naive/atomic_items.cpp' |
427 | --- src/store/naive/atomic_items.cpp 2013-05-28 17:08:27 +0000 |
428 | +++ src/store/naive/atomic_items.cpp 2013-06-19 22:22:31 +0000 |
429 | @@ -495,7 +495,7 @@ |
430 | { |
431 | try |
432 | { |
433 | - xs_double const doubleValue(theValue.c_str()); |
434 | + xs_double const doubleValue(theValue); |
435 | return GET_FACTORY().createDouble(result, doubleValue); |
436 | } |
437 | catch ( std::exception const& ) |
438 | @@ -510,7 +510,7 @@ |
439 | { |
440 | try |
441 | { |
442 | - xs_decimal const decValue(theValue.c_str()); |
443 | + xs_decimal const decValue(theValue); |
444 | return GET_FACTORY().createDecimal(result, decValue); |
445 | } |
446 | catch ( std::exception const& ) |
447 | @@ -525,7 +525,7 @@ |
448 | { |
449 | try |
450 | { |
451 | - xs_integer const intValue(theValue.c_str()); |
452 | + xs_integer const intValue(theValue); |
453 | return GET_FACTORY().createInteger(result, intValue); |
454 | } |
455 | catch ( std::exception const& ) |
456 | |
457 | === modified file 'src/store/naive/simple_item_factory.cpp' |
458 | --- src/store/naive/simple_item_factory.cpp 2013-06-15 02:57:08 +0000 |
459 | +++ src/store/naive/simple_item_factory.cpp 2013-06-19 22:22:31 +0000 |
460 | @@ -2231,58 +2231,6 @@ |
461 | /******************************************************************************* |
462 | |
463 | ********************************************************************************/ |
464 | -bool BasicItemFactory::createJSONNumber( |
465 | - store::Item_t& result, |
466 | - store::Item_t& string) |
467 | -{ |
468 | - zstring s = string->getStringValue(); |
469 | - return createJSONNumber(result, s); |
470 | -} |
471 | - |
472 | - |
473 | -/******************************************************************************* |
474 | - |
475 | -********************************************************************************/ |
476 | -bool BasicItemFactory::createJSONNumber( |
477 | - store::Item_t& result, |
478 | - zstring& string) |
479 | -{ |
480 | - try |
481 | - { |
482 | - bool dot = (strchr(string.c_str(), 46) != NULL); |
483 | - bool e = (strpbrk(string.c_str(), "eE") != NULL); |
484 | - if (!e) |
485 | - { |
486 | - if (!dot) |
487 | - { |
488 | - // xs:integer |
489 | - xs_integer i = Integer(string.c_str()); |
490 | - return createInteger(result, i); |
491 | - } |
492 | - else |
493 | - { |
494 | - // xs:decimal |
495 | - xs_decimal d = Decimal(string.c_str()); |
496 | - return createDecimal(result, d); |
497 | - } |
498 | - } |
499 | - else |
500 | - { |
501 | - // xs:double |
502 | - xs_double d = FloatImpl<double>(string.c_str()); |
503 | - return createDouble(result, d); |
504 | - } |
505 | - } |
506 | - catch (std::exception const&) |
507 | - { |
508 | - return false; |
509 | - } |
510 | -} |
511 | - |
512 | - |
513 | -/******************************************************************************* |
514 | - |
515 | -********************************************************************************/ |
516 | bool BasicItemFactory::createJSONArray( |
517 | store::Item_t& result, |
518 | const std::vector<store::Iterator_t>& sources, |
519 | |
520 | === modified file 'src/store/naive/simple_item_factory.h' |
521 | --- src/store/naive/simple_item_factory.h 2013-06-15 02:57:08 +0000 |
522 | +++ src/store/naive/simple_item_factory.h 2013-06-19 22:22:31 +0000 |
523 | @@ -414,14 +414,6 @@ |
524 | |
525 | bool createJSONNull(store::Item_t& result); |
526 | |
527 | - bool createJSONNumber( |
528 | - store::Item_t& result, |
529 | - store::Item_t& string); |
530 | - |
531 | - bool createJSONNumber( |
532 | - store::Item_t& result, |
533 | - zstring& string); |
534 | - |
535 | bool createJSONArray( |
536 | store::Item_t& result, |
537 | const std::vector<store::Iterator_t>& sources, |
538 | |
539 | === modified file 'src/types/casting.cpp' |
540 | --- src/types/casting.cpp 2013-06-19 19:27:26 +0000 |
541 | +++ src/types/casting.cpp 2013-06-19 22:22:31 +0000 |
542 | @@ -346,7 +346,7 @@ |
543 | { |
544 | try |
545 | { |
546 | - xs_float const n(strval.c_str()); |
547 | + xs_float const n(strval); |
548 | aFactory->createFloat(result, n); |
549 | } |
550 | catch (std::invalid_argument const&) |
551 | @@ -364,7 +364,7 @@ |
552 | { |
553 | try |
554 | { |
555 | - xs_double const n(strval.c_str()); |
556 | + xs_double const n(strval); |
557 | aFactory->createDouble(result, n); |
558 | } |
559 | catch (std::invalid_argument const& ) |
560 | @@ -382,7 +382,7 @@ |
561 | { |
562 | try |
563 | { |
564 | - xs_decimal const n(strval.c_str()); |
565 | + xs_decimal const n(strval); |
566 | aFactory->createDecimal(result, n); |
567 | } |
568 | catch (const std::invalid_argument& ) |
569 | @@ -400,7 +400,7 @@ |
570 | { |
571 | try |
572 | { |
573 | - xs_integer const n(strval.c_str()); |
574 | + xs_integer const n(strval); |
575 | aFactory->createInteger(result, n); |
576 | } |
577 | catch (const std::invalid_argument& ) |
578 | @@ -418,7 +418,7 @@ |
579 | { |
580 | try |
581 | { |
582 | - xs_nonNegativeInteger const n(strval.c_str()); |
583 | + xs_nonNegativeInteger const n(strval); |
584 | aFactory->createNonNegativeInteger(result, n); |
585 | } |
586 | catch ( std::invalid_argument const& ) |
587 | |
588 | === modified file 'src/types/schema/XercesParseUtils.cpp' |
589 | --- src/types/schema/XercesParseUtils.cpp 2013-05-15 23:22:01 +0000 |
590 | +++ src/types/schema/XercesParseUtils.cpp 2013-06-19 22:22:31 +0000 |
591 | @@ -466,7 +466,7 @@ |
592 | utf8::normalize_space(textValue, &textValue2); |
593 | try |
594 | { |
595 | - xs_float const n(textValue2.c_str()); |
596 | + xs_float const n(textValue2); |
597 | return GENV_ITEMFACTORY->createFloat(result, n); |
598 | } |
599 | catch ( std::exception const& ) { |
600 | @@ -504,7 +504,7 @@ |
601 | utf8::normalize_space(textValue, &textValue2); |
602 | store::ItemFactory* factory = GENV_ITEMFACTORY; |
603 | try { |
604 | - xs_double const n(textValue2.c_str()); |
605 | + xs_double const n(textValue2); |
606 | return factory->createDouble(result, n); |
607 | } |
608 | catch ( std::exception const& ) { |
609 | |
610 | === modified file 'src/util/json_parser.cpp' |
611 | --- src/util/json_parser.cpp 2013-02-07 17:24:36 +0000 |
612 | +++ src/util/json_parser.cpp 2013-06-19 22:22:31 +0000 |
613 | @@ -156,7 +156,7 @@ |
614 | |
615 | /////////////////////////////////////////////////////////////////////////////// |
616 | |
617 | -token::token() : type_( none ) { |
618 | +token::token() : type_( none ), numeric_type_( non_numeric ) { |
619 | } |
620 | |
621 | ostream& operator<<( ostream &o, token::type tt ) { |
622 | @@ -172,6 +172,16 @@ |
623 | return o; |
624 | } |
625 | |
626 | +std::ostream& operator<<( ostream &o, token::numeric_type nt ) { |
627 | + switch ( nt ) { |
628 | + case token::non_numeric : o << "<non_numeric>" ; break; |
629 | + case token::integer : o << "integer" ; break; |
630 | + case token::decimal : o << "decimal" ; break; |
631 | + case token::floating_point: o << "floating_point"; break; |
632 | + } |
633 | + return o; |
634 | +} |
635 | + |
636 | ostream& operator<<( ostream &o, token const &t ) { |
637 | switch ( t.get_type() ) { |
638 | case token::string: o << '"' << t.get_value() << '"'; break; |
639 | @@ -239,7 +249,7 @@ |
640 | case '9': |
641 | t->type_ = token::number; |
642 | t->loc_ = cur_loc_; |
643 | - parse_number( c, &t->value_ ); |
644 | + t->numeric_type_ = parse_number( c, &t->value_ ); |
645 | return true; |
646 | case 'f': // false |
647 | case 'n': // null |
648 | @@ -340,7 +350,8 @@ |
649 | return tt; |
650 | } |
651 | |
652 | -void lexer::parse_number( char first_c, token::value_type *value ) { |
653 | +token::numeric_type lexer::parse_number( char first_c, |
654 | + token::value_type *value ) { |
655 | value->clear(); |
656 | |
657 | // <number> ::= [-] <int> [<frac>] [<exp>] |
658 | @@ -355,13 +366,14 @@ |
659 | if ( !ascii::is_digit( c ) ) |
660 | throw illegal_number( cur_loc_ ); |
661 | *value += c; |
662 | + token::numeric_type numeric_type = token::integer; |
663 | if ( c == '0' ) { |
664 | if ( !get_char( &c ) ) |
665 | - return; |
666 | + goto done; |
667 | } else { |
668 | while ( true ) { |
669 | if ( !get_char( &c ) ) |
670 | - return; |
671 | + goto done; |
672 | if ( !ascii::is_digit( c ) ) |
673 | break; |
674 | *value += c; |
675 | @@ -374,9 +386,10 @@ |
676 | if ( !get_char( &c ) || !ascii::is_digit( c ) ) |
677 | throw illegal_number( cur_loc_ ); |
678 | *value += c; |
679 | + numeric_type = token::decimal; |
680 | while ( true ) { |
681 | if ( !get_char( &c ) ) |
682 | - return; |
683 | + goto done; |
684 | if ( !ascii::is_digit( c ) ) |
685 | break; |
686 | *value += c; |
687 | @@ -398,9 +411,10 @@ |
688 | if ( !ascii::is_digit( c ) ) |
689 | throw illegal_number( cur_loc_ ); |
690 | *value += c; |
691 | + numeric_type = token::floating_point; |
692 | while ( true ) { |
693 | if ( !get_char( &c ) ) |
694 | - return; |
695 | + goto done; |
696 | if ( !ascii::is_digit( c ) ) |
697 | break; |
698 | *value += c; |
699 | @@ -408,6 +422,8 @@ |
700 | } |
701 | |
702 | in_->putback( c ); |
703 | +done: |
704 | + return numeric_type; |
705 | } |
706 | |
707 | void lexer::parse_string( token::value_type *value ) { |
708 | |
709 | === modified file 'src/util/json_parser.h' |
710 | --- src/util/json_parser.h 2013-06-01 00:30:39 +0000 |
711 | +++ src/util/json_parser.h 2013-06-19 22:22:31 +0000 |
712 | @@ -94,6 +94,17 @@ |
713 | }; |
714 | |
715 | /** |
716 | + * The numeric types of \c number tokens in JSON. Note that this is an |
717 | + * extension since JSON does not distinguish between numeric types. |
718 | + */ |
719 | + enum numeric_type { |
720 | + non_numeric, |
721 | + integer = 'i', |
722 | + decimal = 'd', |
723 | + floating_point = 'f', |
724 | + }; |
725 | + |
726 | + /** |
727 | * Default constructor. |
728 | */ |
729 | token(); |
730 | @@ -103,6 +114,7 @@ |
731 | */ |
732 | void clear() { |
733 | type_ = none; |
734 | + numeric_type_ = non_numeric; |
735 | value_.clear(); |
736 | } |
737 | |
738 | @@ -125,6 +137,15 @@ |
739 | } |
740 | |
741 | /** |
742 | + * Gets the numeric type of this %token if it's type is \c number. |
743 | + * |
744 | + * @return Returns said type or \c non_numeric if the type is not \c number. |
745 | + */ |
746 | + numeric_type get_numeric_type() const { |
747 | + return numeric_type_; |
748 | + } |
749 | + |
750 | + /** |
751 | * Gets the value of this %token, if any. Only %token types string, number, |
752 | * false, null, and true have a value. |
753 | * |
754 | @@ -146,6 +167,7 @@ |
755 | private: |
756 | location loc_; |
757 | type type_; |
758 | + numeric_type numeric_type_; |
759 | value_type value_; |
760 | |
761 | friend class lexer; |
762 | @@ -169,6 +191,15 @@ |
763 | std::ostream& operator<<( std::ostream &o, token::type tt ); |
764 | |
765 | /** |
766 | + * Emits the given token numeric type to an ostream. |
767 | + * |
768 | + * @param o The ostream to emit to. |
769 | + * @param nt The token numeric type to emit. |
770 | + * @return Returns \a o. |
771 | + */ |
772 | +std::ostream& operator<<( std::ostream &o, token::numeric_type nt ); |
773 | + |
774 | +/** |
775 | * Emits the given token to an ostream. |
776 | * |
777 | * @param o The ostream to emit to. |
778 | @@ -476,7 +507,7 @@ |
779 | bool peek_char( char* ); |
780 | unicode::code_point parse_codepoint(); |
781 | token::type parse_literal( char, token::value_type* ); |
782 | - void parse_number( char, token::value_type* ); |
783 | + token::numeric_type parse_number( char, token::value_type* ); |
784 | void parse_string( token::value_type* ); |
785 | |
786 | std::istream *in_; |
787 | |
788 | === modified file 'src/zorbaserialization/serialize_basic_types.cpp' |
789 | --- src/zorbaserialization/serialize_basic_types.cpp 2013-05-15 23:22:01 +0000 |
790 | +++ src/zorbaserialization/serialize_basic_types.cpp 2013-06-19 22:22:31 +0000 |
791 | @@ -397,7 +397,7 @@ |
792 | |
793 | ar.read_next_simple_temp_field(TYPE_ZSTRING, &float_str); |
794 | |
795 | - FloatImpl<float> zorba_float(float_str.c_str()); |
796 | + FloatImpl<float> zorba_float(float_str); |
797 | obj = zorba_float.getNumber(); |
798 | } |
799 | } |
800 | @@ -428,7 +428,7 @@ |
801 | |
802 | ar.read_next_simple_temp_field(TYPE_ZSTRING, &double_str); |
803 | |
804 | - FloatImpl<double> zorba_double(double_str.c_str()); |
805 | + FloatImpl<double> zorba_double(double_str); |
806 | obj = zorba_double.getNumber(); |
807 | } |
808 | } |
809 | |
810 | === modified file 'src/zorbatypes/decimal.h' |
811 | --- src/zorbatypes/decimal.h 2013-06-07 21:22:39 +0000 |
812 | +++ src/zorbatypes/decimal.h 2013-06-19 22:22:31 +0000 |
813 | @@ -75,6 +75,17 @@ |
814 | explicit Decimal( char const *s ); |
815 | |
816 | /** |
817 | + * Constructs a %Decimal from a string. |
818 | + * |
819 | + * @tparam StringType The string type. |
820 | + * @param s The string to parse. Leading and trailing whitespace is ignored. |
821 | + * @throw std::invalid_argument if \a s does not contain a valid decimal. |
822 | + */ |
823 | + template<class StringType> |
824 | + explicit Decimal( StringType const &s, |
825 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType)>::type* = nullptr ); |
826 | + |
827 | + /** |
828 | * Constructs a %Decimal from a Double. |
829 | * |
830 | * @param n The Double. |
831 | @@ -120,6 +131,11 @@ |
832 | Decimal& operator=( unsigned long long n ); |
833 | |
834 | Decimal& operator=( char const *s ); |
835 | + |
836 | + template<class StringType> |
837 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType),Decimal&>::type |
838 | + operator=( StringType const &s ); |
839 | + |
840 | Decimal& operator=( Double const &d ); |
841 | Decimal& operator=( Float const &f ); |
842 | |
843 | @@ -276,6 +292,13 @@ |
844 | parse( s, &value_ ); |
845 | } |
846 | |
847 | +template<class StringType> |
848 | +inline Decimal::Decimal( StringType const &s, |
849 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType)>::type* ) |
850 | +{ |
851 | + parse( s.c_str(), &value_ ); |
852 | +} |
853 | + |
854 | inline Decimal::Decimal( Decimal const &d ) : value_( d.value_ ) |
855 | { |
856 | } |
857 | @@ -309,6 +332,12 @@ |
858 | return *this; |
859 | } |
860 | |
861 | +template<class StringType> inline |
862 | +typename std::enable_if<ZORBA_HAS_C_STR(StringType),Decimal&>::type |
863 | +Decimal::operator=( StringType const &s ) { |
864 | + return operator=( s.c_str() ); |
865 | +} |
866 | + |
867 | ////////// arithmetic operators /////////////////////////////////////////////// |
868 | |
869 | #define ZORBA_DECIMAL_OP(OP) \ |
870 | |
871 | === modified file 'src/zorbatypes/float.h' |
872 | --- src/zorbatypes/float.h 2013-05-18 14:36:06 +0000 |
873 | +++ src/zorbatypes/float.h 2013-06-19 22:22:31 +0000 |
874 | @@ -79,6 +79,20 @@ |
875 | explicit FloatImpl( char const *s ); |
876 | |
877 | /** |
878 | + * Constructs a %FloatImpl from a string. |
879 | + * |
880 | + * @tparam StringType The string type. |
881 | + * @param s The string to parse. Leading and trailing whitespace is ignored. |
882 | + * @throw std::invalid_argument if \a s does not contain a valid floating |
883 | + * point number. |
884 | + * @throw std::range_error if \a s contains a number that either underflows |
885 | + * or overflows the smallest or largest representable floating point number. |
886 | + */ |
887 | + template<class StringType> |
888 | + explicit FloatImpl( StringType const &s, |
889 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType)>::type* = nullptr ); |
890 | + |
891 | + /** |
892 | * Constructs from another %FloatImpl even if its \c FloatType is different. |
893 | * (This subsumes the conventional copy constructor.) |
894 | * |
895 | @@ -116,6 +130,11 @@ |
896 | FloatImpl& operator=( double n ); |
897 | |
898 | FloatImpl& operator=( char const *s ); |
899 | + |
900 | + template<class StringType> |
901 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType),FloatImpl&>::type |
902 | + operator=( StringType const &s ); |
903 | + |
904 | FloatImpl& operator=( Decimal const &d ); |
905 | |
906 | template<class T> |
907 | @@ -399,6 +418,14 @@ |
908 | } |
909 | |
910 | template<typename F> |
911 | +template<class StringType> |
912 | +inline FloatImpl<F>::FloatImpl( StringType const &s, |
913 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType)>::type* ) |
914 | +{ |
915 | + parse( s.c_str() ); |
916 | +} |
917 | + |
918 | +template<typename F> |
919 | template<typename G> |
920 | inline FloatImpl<F>::FloatImpl( FloatImpl<G> const &f ) : |
921 | value_( static_cast<F>( f.value_ ) ), precision_( max_precision() ) |
922 | @@ -442,6 +469,13 @@ |
923 | return *this; |
924 | } |
925 | |
926 | +template<typename F> |
927 | +template<class StringType> inline |
928 | +typename std::enable_if<ZORBA_HAS_C_STR(StringType),FloatImpl<F>&>::type |
929 | +FloatImpl<F>::operator=( StringType const &s ) { |
930 | + return operator=( s.c_str() ); |
931 | +} |
932 | + |
933 | ////////// arithmetic operators /////////////////////////////////////////////// |
934 | |
935 | #define ZORBA_FLOAT_OP(OP,T) \ |
936 | |
937 | === modified file 'src/zorbatypes/integer.h' |
938 | --- src/zorbatypes/integer.h 2013-06-07 21:22:39 +0000 |
939 | +++ src/zorbatypes/integer.h 2013-06-19 22:22:31 +0000 |
940 | @@ -175,6 +175,19 @@ |
941 | explicit IntegerImpl( char const *s ); |
942 | |
943 | /** |
944 | + * Constructs an %IntegerImpl from a string. |
945 | + * |
946 | + * @tparam StringType The string type. |
947 | + * @param s The string to parse. Leading and trailing whitespace is ignored. |
948 | + * @throw std::invalid_argument if \a s does not contain a valid integer. |
949 | + * @throw std::range_error if \a s contains an integer that either underflows |
950 | + * or overflows the smallest or largest representable/legal integer. |
951 | + */ |
952 | + template<class StringType> |
953 | + explicit IntegerImpl( StringType const &s, |
954 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType)>::type* = nullptr ); |
955 | + |
956 | + /** |
957 | * Constructs an %IntegerImpl from a Double. |
958 | * |
959 | * @param d The Double. |
960 | @@ -232,6 +245,11 @@ |
961 | IntegerImpl& operator=( double n ); |
962 | |
963 | IntegerImpl& operator=( char const *s ); |
964 | + |
965 | + template<class StringType> |
966 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType),IntegerImpl&>::type |
967 | + operator=( StringType const &s ); |
968 | + |
969 | IntegerImpl& operator=( Decimal const &d ); |
970 | IntegerImpl& operator=( Double const &d ); |
971 | IntegerImpl& operator=( Float const &f ); |
972 | @@ -721,6 +739,14 @@ |
973 | } |
974 | |
975 | template<class T> |
976 | +template<class StringType> |
977 | +inline IntegerImpl<T>::IntegerImpl( StringType const &s, |
978 | + typename std::enable_if<ZORBA_HAS_C_STR(StringType)>::type* ) |
979 | +{ |
980 | + parse( s.c_str() ); |
981 | +} |
982 | + |
983 | +template<class T> |
984 | template<class U> |
985 | inline IntegerImpl<T>::IntegerImpl( IntegerImpl<U> const &i ) : |
986 | value_( T::check_value( i.value_ ) ) |
987 | @@ -760,6 +786,13 @@ |
988 | } |
989 | |
990 | template<class T> |
991 | +template<class StringType> inline |
992 | +typename std::enable_if<ZORBA_HAS_C_STR(StringType),IntegerImpl<T>&>::type |
993 | +IntegerImpl<T>::operator=( StringType const &s ) { |
994 | + return operator=( s.c_str() ); |
995 | +} |
996 | + |
997 | +template<class T> |
998 | template<class U> |
999 | inline IntegerImpl<T>& IntegerImpl<T>::operator=( IntegerImpl<U> const &i ) { |
1000 | T::check_value( value_ = i.value_ ); |
1001 | |
1002 | === modified file 'swig/ItemFactory.h' |
1003 | --- swig/ItemFactory.h 2013-04-17 17:49:23 +0000 |
1004 | +++ swig/ItemFactory.h 2013-06-19 22:22:31 +0000 |
1005 | @@ -606,16 +606,6 @@ |
1006 | Item createJSONNull(); |
1007 | |
1008 | /** |
1009 | - * \brief Create a JSON Number item from a string. |
1010 | - * This will actually be |
1011 | - * an xs:integer, xs:double, or xs:decimal, depending on the content |
1012 | - * of the string. |
1013 | - * |
1014 | - * @param aString The input string. |
1015 | - */ |
1016 | - Item createJSONNumber(std::string aString); |
1017 | - |
1018 | - /** |
1019 | * \brief Create a JSON Object containing the specified JSON Pairs. |
1020 | * |
1021 | * @param aNames A vector containing the name and value of each pair. |
1022 | @@ -675,4 +665,4 @@ |
1023 | |
1024 | }; // class ItemFactory |
1025 | |
1026 | -#endif |
1027 | \ No newline at end of file |
1028 | +#endif |
1029 | |
1030 | === modified file 'swig/ItemFactory.i' |
1031 | --- swig/ItemFactory.i 2013-04-17 17:49:23 +0000 |
1032 | +++ swig/ItemFactory.i 2013-06-19 22:22:31 +0000 |
1033 | @@ -224,10 +224,6 @@ |
1034 | return Item( theItemFactory->createJSONNull() ); |
1035 | } |
1036 | |
1037 | - Item ItemFactory::createJSONNumber(std::string aString) { |
1038 | - return Item( theItemFactory->createJSONNumber(aString)); |
1039 | - } |
1040 | - |
1041 | Item ItemFactory::createJSONObject(std::vector<std::pair<Item, Item> >& aNames) { |
1042 | std::vector< std::pair< zorba::Item, zorba::Item > > names; |
1043 | names.reserve(aNames.size()); |
1044 | |
1045 | === removed file 'swig/csharp/tests/test10.cs' |
1046 | --- swig/csharp/tests/test10.cs 2013-03-26 01:56:30 +0000 |
1047 | +++ swig/csharp/tests/test10.cs 1970-01-01 00:00:00 +0000 |
1048 | @@ -1,86 +0,0 @@ |
1049 | -/* |
1050 | - * Copyright 2006-2012 The FLWOR Foundation. |
1051 | - * |
1052 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1053 | - * you may not use this file except in compliance with the License. |
1054 | - * You may obtain a copy of the License at |
1055 | - * |
1056 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1057 | - * |
1058 | - * Unless required by applicable law or agreed to in writing, software |
1059 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1060 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1061 | - * See the License for the specific language governing permissions and |
1062 | - * limitations under the License. |
1063 | - */ |
1064 | -using System; |
1065 | -using System.Text; |
1066 | -using org.zorbaxquery.api; |
1067 | - |
1068 | -namespace ZorbaApplication |
1069 | -{ |
1070 | - |
1071 | - class MyDiagnosticHandler : DiagnosticHandler { |
1072 | - public override void error(ZorbaException exception) { |
1073 | - System.Console.WriteLine("Exception catched in MyDiagnosticHandler"); |
1074 | - System.Console.WriteLine("Description: " + exception.getDescription()); |
1075 | - } |
1076 | - } |
1077 | - |
1078 | - class Program |
1079 | - { |
1080 | - static String test() { |
1081 | - MyDiagnosticHandler diagnosticHandler = new MyDiagnosticHandler(); |
1082 | - |
1083 | - InMemoryStore store = InMemoryStore.getInstance(); |
1084 | - Zorba zorba = Zorba.getInstance(store); |
1085 | - |
1086 | - ItemFactory itemFactory = zorba.getItemFactory(); |
1087 | - Item iNull = itemFactory.createJSONNull(); |
1088 | - System.Console.WriteLine( "Creating JSON Item null: " + iNull.serialize()); |
1089 | - iNull.Dispose(); |
1090 | - |
1091 | - Item iNumber = itemFactory.createJSONNumber("5"); |
1092 | - System.Console.WriteLine( "Creating JSON Item number: " + iNumber.serialize() ); |
1093 | - iNumber.Dispose(); |
1094 | - |
1095 | - StringVector sv = new StringVector(); |
1096 | - sv.Add("Hello"); |
1097 | - sv.Add("Zorba"); |
1098 | - sv.Add("Hello"); |
1099 | - sv.Add("Zorba"); |
1100 | - Item iArray = itemFactory.createJSONArray(sv); |
1101 | - sv.Dispose(); |
1102 | - System.Console.WriteLine( "Creating JSON Item array: " + iArray.serialize() ); |
1103 | - iArray.Dispose(); |
1104 | - |
1105 | - zorba.shutdown(); |
1106 | - InMemoryStore.shutdown(store); |
1107 | - |
1108 | - return "ok"; |
1109 | - } |
1110 | - |
1111 | - static void Main(string[] args) |
1112 | - { |
1113 | - System.Console.WriteLine("Running: Compile query string using Diagnostic Handler"); |
1114 | - |
1115 | - String testResult = "ok"; |
1116 | - String result; |
1117 | - try { |
1118 | - result = test(); |
1119 | - } catch(Exception e) { |
1120 | - System.Console.WriteLine("Failed"); |
1121 | - Console.WriteLine("{0} Exception caught.", e); |
1122 | - return; |
1123 | - } |
1124 | - |
1125 | - if (result.Equals(testResult)) { |
1126 | - System.Console.WriteLine("Success"); |
1127 | - } else { |
1128 | - System.Console.WriteLine("Failed"); |
1129 | - } |
1130 | - |
1131 | - |
1132 | - } |
1133 | - } |
1134 | -} |
1135 | |
1136 | === removed file 'swig/php/tests/test11.php' |
1137 | --- swig/php/tests/test11.php 2013-03-26 01:56:30 +0000 |
1138 | +++ swig/php/tests/test11.php 1970-01-01 00:00:00 +0000 |
1139 | @@ -1,59 +0,0 @@ |
1140 | -<? |
1141 | -/* |
1142 | - * Copyright 2006-2013 The FLWOR Foundation. |
1143 | - * |
1144 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
1145 | - * you may not use this file except in compliance with the License. |
1146 | - * You may obtain a copy of the License at |
1147 | - * |
1148 | - * http://www.apache.org/licenses/LICENSE-2.0 |
1149 | - * |
1150 | - * Unless required by applicable law or agreed to in writing, software |
1151 | - * distributed under the License is distributed on an "AS IS" BASIS, |
1152 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1153 | - * See the License for the specific language governing permissions and |
1154 | - * limitations under the License. |
1155 | - */ |
1156 | - |
1157 | -require 'zorba_api_wrapper.php'; |
1158 | - |
1159 | -class MyDiagnosticHandler extends DiagnosticHandler { |
1160 | - public function error($args) { |
1161 | - print "Error caught in DiagnosticHandler: " . $args->getDescription() . "\n"; |
1162 | - } |
1163 | -} |
1164 | - |
1165 | -function test(Zorba $aZorba) |
1166 | -{ |
1167 | - $diagnosticHandler = new MyDiagnosticHandler(); |
1168 | - try { |
1169 | - $itemFactory = $aZorba->getItemFactory(); |
1170 | - print "Creating JSON Item null: ". $itemFactory->createJSONNull()->serialize() . "\n"; |
1171 | - print "Creating JSON Item number: ". $itemFactory->createJSONNumber("5")->serialize() . "\n"; |
1172 | - $sv = new StringVector(4); |
1173 | - $sv->set(0, "Hello"); |
1174 | - $sv->set(1, "Zorba"); |
1175 | - $sv->set(2, "Hello"); |
1176 | - $sv->set(3, "Zorba"); |
1177 | - print "Creating JSON Item array: ". $itemFactory->createJSONArray($sv)->serialize() . "\n"; |
1178 | - print "Success"; |
1179 | - } catch (ZorbaException $e) { |
1180 | - print "Caught unexpected Zorba error: " . $e->getDescription() . "\n" ; |
1181 | - exit(); |
1182 | - } catch (Exception $e) { |
1183 | - print "Caught error: " . $e . "\n"; |
1184 | - exit(); |
1185 | - } |
1186 | - return; |
1187 | -} |
1188 | - |
1189 | -$store = InMemoryStore::getInstance(); |
1190 | -$zorba = Zorba::getInstance($store); |
1191 | - |
1192 | -print "Running: Compile query string using Diagnostic Handler\n"; |
1193 | -test($zorba); |
1194 | - |
1195 | -$zorba->shutdown(); |
1196 | -InMemoryStore::shutdown($store); |
1197 | - |
1198 | -?> |
1199 | |
1200 | === removed file 'swig/python/tests/test13.py' |
1201 | --- swig/python/tests/test13.py 2013-03-22 23:40:03 +0000 |
1202 | +++ swig/python/tests/test13.py 1970-01-01 00:00:00 +0000 |
1203 | @@ -1,43 +0,0 @@ |
1204 | -# Copyright 2006-2013 The FLWOR Foundation. |
1205 | -# |
1206 | -# Licensed under the Apache License, Version 2.0 (the "License"); |
1207 | -# you may not use this file except in compliance with the License. |
1208 | -# You may obtain a copy of the License at |
1209 | -# |
1210 | -# http://www.apache.org/licenses/LICENSE-2.0 |
1211 | -# |
1212 | -# Unless required by applicable law or agreed to in writing, software |
1213 | -# distributed under the License is distributed on an "AS IS" BASIS, |
1214 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1215 | -# See the License for the specific language governing permissions and |
1216 | -# limitations under the License. |
1217 | - |
1218 | -import sys |
1219 | -sys.path.insert(0, '@pythonPath@') |
1220 | -import zorba_api |
1221 | - |
1222 | -def test(zorba): |
1223 | - try: |
1224 | - itemFactory = zorba.getItemFactory() |
1225 | - print "Creating JSON Item null: ", itemFactory.createJSONNull().serialize() |
1226 | - print "Creating JSON Item null: ", itemFactory.createJSONNumber("5").serialize() |
1227 | - sv = zorba_api.StringVector(4) |
1228 | - sv[0]="Hello" |
1229 | - sv[1]="Zorba" |
1230 | - sv[2]="Hello" |
1231 | - sv[3]="Zorba" |
1232 | - print "Creating JSON Item null: ", itemFactory.createJSONArray(sv).serialize() |
1233 | - print "Success" |
1234 | - except Exception, e: |
1235 | - print "Caught error: ", e |
1236 | - return |
1237 | - |
1238 | -store = zorba_api.InMemoryStore_getInstance() |
1239 | -zorba = zorba_api.Zorba_getInstance(store) |
1240 | - |
1241 | -print "Running: Creating JSON objects using the API" |
1242 | -test(zorba) |
1243 | - |
1244 | - |
1245 | -zorba.shutdown() |
1246 | -zorba_api.InMemoryStore_shutdown(store) |
1247 | |
1248 | === removed file 'swig/ruby/tests/test13.rb' |
1249 | --- swig/ruby/tests/test13.rb 2013-03-26 01:56:30 +0000 |
1250 | +++ swig/ruby/tests/test13.rb 1970-01-01 00:00:00 +0000 |
1251 | @@ -1,41 +0,0 @@ |
1252 | -# Copyright 2006-2012 The FLWOR Foundation. |
1253 | -# |
1254 | -# Licensed under the Apache License, Version 2.0 (the "License"); |
1255 | -# you may not use this file except in compliance with the License. |
1256 | -# You may obtain a copy of the License at |
1257 | -# |
1258 | -# http://www.apache.org/licenses/LICENSE-2.0 |
1259 | -# |
1260 | -# Unless required by applicable law or agreed to in writing, software |
1261 | -# distributed under the License is distributed on an "AS IS" BASIS, |
1262 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
1263 | -# See the License for the specific language governing permissions and |
1264 | -# limitations under the License. |
1265 | - |
1266 | -require '@rubyPath@/zorba_api' |
1267 | - |
1268 | -def test(zorba) |
1269 | - begin |
1270 | - itemFactory = zorba.getItemFactory() |
1271 | - print "Creating JSON Item null: ", itemFactory.createJSONNull().serialize() |
1272 | - print "Creating JSON Item number: ", itemFactory.createJSONNumber("5").serialize() |
1273 | - sv = Zorba_api.StringVector(4) |
1274 | - sv[0]="Hello" |
1275 | - sv[1]="Zorba" |
1276 | - sv[2]="Hello" |
1277 | - sv[3]="Zorba" |
1278 | - print "Creating JSON Item array: ", itemFactory.createJSONArray(sv).serialize() |
1279 | - print "Success" |
1280 | - rescue => e |
1281 | - print "Caught error: " + e.message |
1282 | - end |
1283 | -end |
1284 | - |
1285 | -store = Zorba_api::InMemoryStore.getInstance() |
1286 | -zorba = Zorba_api::Zorba.getInstance(store) |
1287 | - |
1288 | -print "Running: Creating JSON objects using the API" |
1289 | -test(zorba) |
1290 | - |
1291 | -zorba.shutdown() |
1292 | -Zorba_api::InMemoryStore.shutdown(store) |
1293 | \ No newline at end of file |
Validation queue starting for merge proposal. zorbatest. lambda. nu:8080/ remotequeue/ pjl-misc- 2013-06- 19T00-16- 10.219Z/ log.html
Log at: http://