Merge lp:~zorba-coders/zorba/threads into lp:zorba
- threads
- Merge into trunk
Proposed by
Markos Zaharioudakis
Status: | Merged |
---|---|
Merged at revision: | 11549 |
Proposed branch: | lp:~zorba-coders/zorba/threads |
Merge into: | lp:zorba |
Diff against target: |
4779 lines (+1074/-880) 76 files modified
include/zorba/xquery.h (+17/-19) src/annotations/annotations.cpp (+10/-4) src/annotations/annotations.h (+6/-11) src/api/annotationimpl.cpp (+10/-5) src/api/annotationimpl.h (+1/-2) src/api/serialization/serializer.cpp (+15/-3) src/api/staticcontextimpl.cpp (+11/-17) src/api/xmldatamanagerimpl.cpp (+5/-4) src/api/xqueryimpl.cpp (+1/-0) src/api/xqueryimpl.h (+2/-8) src/api/zorbaimpl.cpp (+6/-0) src/api/zorbaimpl.h (+5/-3) src/capi/csequence.cpp (+3/-1) src/common/shared_types.h (+1/-3) src/compiler/codegen/plan_visitor.cpp (+1/-1) src/compiler/expression/expr_put.cpp (+1/-1) src/compiler/expression/fo_expr.cpp (+1/-1) src/compiler/expression/function_item_expr.cpp (+18/-16) src/compiler/expression/function_item_expr.h (+1/-1) src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp (+5/-3) src/compiler/rewriter/rules/type_rules.cpp (+1/-1) src/compiler/translator/translator.cpp (+89/-88) src/compiler/xqddf/collection_decl.cpp (+5/-4) src/compiler/xqddf/collection_decl.h (+6/-6) src/context/root_static_context.cpp (+7/-2) src/context/root_static_context.h (+2/-0) src/context/static_context.cpp (+46/-47) src/context/static_context.h (+14/-8) src/functions/external_function.cpp (+1/-2) src/functions/function.cpp (+35/-31) src/functions/function.h (+7/-9) src/functions/function_impl.h (+4/-4) src/functions/library.cpp (+13/-10) src/functions/library.h (+13/-7) src/functions/udf.cpp (+1/-3) src/runtime/full_text/ft_util.cpp (+5/-2) src/runtime/hof/fn_hof_functions_impl.cpp (+1/-1) src/runtime/hof/function_item.cpp (+11/-10) src/runtime/hof/function_item.h (+1/-1) src/runtime/nodes/nodes_impl.cpp (+1/-1) src/runtime/strings/strings_impl.cpp (+3/-3) src/store/api/annotation.h (+1/-8) src/store/api/collection.h (+1/-9) src/store/api/ic.h (+1/-9) src/store/api/index.h (+1/-9) src/store/api/item.h (+1/-1) src/store/naive/atomic_items.cpp (+7/-2) src/store/naive/atomic_items.h (+6/-0) src/store/naive/item.cpp (+11/-0) src/store/naive/loader_dtd.cpp (+10/-6) src/store/naive/loader_fast.cpp (+8/-5) src/store/naive/node_items.cpp (+5/-3) src/store/naive/nsbindings.cpp (+1/-0) src/store/naive/qname_pool.cpp (+110/-47) src/store/naive/qname_pool.h (+16/-8) src/store/naive/simple_item_factory.cpp (+2/-2) src/store/naive/simple_pul.cpp (+7/-8) src/store/naive/store.cpp (+63/-63) src/store/naive/store_defs.h (+1/-0) src/system/globalenv.cpp (+7/-7) src/system/globalenv.h (+16/-4) src/types/root_typemanager.cpp (+2/-2) src/types/schema/revalidateUtils.cpp (+12/-6) src/types/schema/schema.cpp (+1/-1) src/types/typeimpl.cpp (+3/-0) src/types/typemanagerimpl.cpp (+4/-2) src/util/http_util.cpp (+19/-6) src/zorbamisc/ns_consts.h (+0/-3) src/zorbaserialization/archiver_consts.h (+2/-1) src/zorbaserialization/serialize_zorba_types.cpp (+1/-1) src/zorbatypes/rchandle.cpp (+11/-67) src/zorbatypes/rchandle.h (+75/-47) test/driver/testdriver_common.cpp (+29/-16) test/driver/testdriver_common.h (+3/-2) test/driver/testdriver_mt.cpp (+250/-191) test/rbkt/Queries/zorba/updates/forms.xsd (+1/-1) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/threads |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+174198@code.launchpad.net |
Commit message
Some work towards multi-threading
1. Fixed a couple of threading bugs in qname pool
2. Redefined free() method for root_static_context and for builtin functions
3. Annotations are not RCObjects anymore
4. Use atomic ints are counters in RCObjects
5. No query cloning in testdriver_mt
Description of the change
Some work towards multi-threading
1. Fixed a couple of threading bugs in qname pool
2. Redefined free() method for root_static_context and for builtin functions
3. Annotations are not RCObjects anymore
4. Use atomic ints are counters in RCObjects
5. No query cloning in testdriver_mt
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 : | # |
Validation queue succeeded - proposal merged!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'include/zorba/xquery.h' |
2 | --- include/zorba/xquery.h 2013-05-28 00:58:27 +0000 |
3 | +++ include/zorba/xquery.h 2013-07-11 13:41:52 +0000 |
4 | @@ -29,16 +29,14 @@ |
5 | typedef Zorba_SerializerOptions_t* (*itemHandler)(void* aUserData); |
6 | |
7 | /** |
8 | - * \brief This class is the representation of an %XQuery in the %Zorba engine. |
9 | + * \brief This class is the representation of an %XQuery program in the %Zorba engine. |
10 | * |
11 | - * To compile and execute an XQuery, an instance of this class must be created. |
12 | - * This is done by using either the createQuery or compileQuery methods of the |
13 | - * Zorba class. These methods return an instance of XQuery_t, which is a |
14 | + * To compile and execute an XQuery program, an instance of this class must be |
15 | + * created. This is done by using either the createQuery or compileQuery methods |
16 | + * of the Zorba class. These methods return an instance of XQuery_t, which is a |
17 | * reference counted smart pointer to a dynamically allocated XQuery object. |
18 | - * After receiving an XQuery_t, an application can make multiple copies of it. |
19 | - * Hence, an XQuery object can have multiple users, potentially in different |
20 | - * threads. The XQuery object is deleted when all XQuery_t objects that point |
21 | - * to it are destroyed. |
22 | + * The XQuery object is deleted when all XQuery_t objects that point to it are |
23 | + * destroyed. |
24 | * |
25 | * The file \link simple.cpp \endlink contains some basic examples the demonstrate |
26 | * the use of this class. |
27 | @@ -51,7 +49,7 @@ |
28 | { |
29 | public: |
30 | /** |
31 | - * \brief Destructor that destroys this XQuery object. |
32 | + * \brief Destructor. |
33 | * |
34 | * The destructor is called automatically when there are no more XQuery_t |
35 | * smart pointers pointing to this XQuery instance. |
36 | @@ -61,11 +59,13 @@ |
37 | /** |
38 | * \brief Set the filename of a query. |
39 | * |
40 | - * This (after URI-encoding) becomes the encapsulating entity's |
41 | - * retrieval URI (in RFC 3986 terms). |
42 | + * This (after URI-encoding) becomes the encapsulating entity's retrieval URI |
43 | + * (in RFC 3986 terms), and may be used in the computation of the program's |
44 | + * static base URI property, as described at |
45 | + * http://www.w3.org/TR/xquery-30/#dt-base-uri-decl |
46 | */ |
47 | virtual void |
48 | - setFileName(const String&) = 0; |
49 | + setFileName(const String& flename) = 0; |
50 | |
51 | /** |
52 | * \brief Register an DiagnosticHandler to which errors during compilation or |
53 | @@ -74,14 +74,14 @@ |
54 | * If no DiagnosticHandler has been set via this function, the default error |
55 | * handling mechanism is to throw instances of the ZorbaException class. |
56 | * |
57 | - * @param aDiagnosticHandler DiagnosticHandler to which errors are reported. The |
58 | + * @param handler DiagnosticHandler to which errors are reported. The |
59 | * caller retains ownership over the DiagnosticHandler passed as |
60 | * parameter. |
61 | * @throw SystemException if the query has been closed. |
62 | * @see close() |
63 | */ |
64 | virtual void |
65 | - registerDiagnosticHandler(DiagnosticHandler* aDiagnosticHandler) = 0; |
66 | + registerDiagnosticHandler(DiagnosticHandler* handler) = 0; |
67 | |
68 | /** |
69 | * \brief Reset the error handling mechanism back to the default, |
70 | @@ -443,7 +443,7 @@ |
71 | * This file will contain the output of Zorba profiler. |
72 | */ |
73 | virtual void |
74 | - setProfileName( std::string aProfileName ) = 0; |
75 | + setProfileName(std::string aProfileName) = 0; |
76 | |
77 | /** |
78 | * \brief Get the filename of the profile |
79 | @@ -468,9 +468,7 @@ |
80 | * not been compiled, the server cannot connect to the client, etc.) |
81 | */ |
82 | virtual void |
83 | - debug( |
84 | - const std::string& host, |
85 | - unsigned short port) = 0; |
86 | + debug(const std::string& host, unsigned short port) = 0; |
87 | |
88 | /** |
89 | * \brief Start a debugger server. |
90 | @@ -556,7 +554,7 @@ |
91 | }; |
92 | |
93 | |
94 | -// xml serialization of the query (equiv to calling serialize(os) |
95 | +// XML serialization of the query result (equiv to calling serialize(os) |
96 | ZORBA_DLL_PUBLIC |
97 | std::ostream& operator<< (std::ostream& os, const XQuery_t& aQuery); |
98 | |
99 | |
100 | === modified file 'src/annotations/annotations.cpp' |
101 | --- src/annotations/annotations.cpp 2013-04-29 01:51:11 +0000 |
102 | +++ src/annotations/annotations.cpp 2013-07-11 13:41:52 +0000 |
103 | @@ -325,6 +325,12 @@ |
104 | ********************************************************************************/ |
105 | AnnotationList::~AnnotationList() |
106 | { |
107 | + for (Annotations::iterator ite = theAnnotationList.begin(); |
108 | + ite != theAnnotationList.end(); |
109 | + ++ite) |
110 | + { |
111 | + delete *ite; |
112 | + } |
113 | } |
114 | |
115 | |
116 | @@ -343,7 +349,7 @@ |
117 | AnnotationInternal* AnnotationList::get(csize index) const |
118 | { |
119 | if (index < theAnnotationList.size()) |
120 | - return theAnnotationList[index].getp(); |
121 | + return theAnnotationList[index]; |
122 | else |
123 | return NULL; |
124 | } |
125 | @@ -354,12 +360,12 @@ |
126 | ********************************************************************************/ |
127 | AnnotationInternal* AnnotationList::get(AnnotationInternal::AnnotationId id) const |
128 | { |
129 | - for (ListConstIter_t ite = theAnnotationList.begin(); |
130 | + for (Annotations::const_iterator ite = theAnnotationList.begin(); |
131 | ite != theAnnotationList.end(); |
132 | ++ite) |
133 | { |
134 | if ((*ite)->getId() == id) |
135 | - return (*ite).getp(); |
136 | + return (*ite); |
137 | } |
138 | |
139 | return NULL; |
140 | @@ -408,7 +414,7 @@ |
141 | RuleBitSet lCurrAnn; |
142 | |
143 | // mark and detect duplicates |
144 | - for (ListConstIter_t ite = theAnnotationList.begin(); |
145 | + for (Annotations::const_iterator ite = theAnnotationList.begin(); |
146 | ite != theAnnotationList.end(); |
147 | ++ite) |
148 | { |
149 | |
150 | === modified file 'src/annotations/annotations.h' |
151 | --- src/annotations/annotations.h 2013-04-29 00:41:13 +0000 |
152 | +++ src/annotations/annotations.h 2013-07-11 13:41:52 +0000 |
153 | @@ -32,9 +32,6 @@ |
154 | class AnnotationInternal; |
155 | class AnnotationList; |
156 | |
157 | -typedef rchandle<AnnotationInternal> AnnotationInternal_t; |
158 | -typedef rchandle<AnnotationList> AnnotationList_t; |
159 | - |
160 | class const_expr; |
161 | |
162 | /******************************************************************************* |
163 | @@ -53,7 +50,7 @@ |
164 | together in a declaration, then a conflict exists. Each set of annotations |
165 | is implemented as a bitset indexed by annotation id. |
166 | ********************************************************************************/ |
167 | -class AnnotationInternal : public SimpleRCObject |
168 | +class AnnotationInternal : public ::zorba::serialization::SerializeBaseClass |
169 | { |
170 | friend class AnnotationList; |
171 | |
172 | @@ -128,7 +125,7 @@ |
173 | |
174 | public: |
175 | SERIALIZABLE_CLASS(AnnotationInternal); |
176 | - SERIALIZABLE_CLASS_CONSTRUCTOR2(AnnotationInternal, SimpleRCObject) |
177 | + SERIALIZABLE_CLASS_CONSTRUCTOR(AnnotationInternal) |
178 | void serialize(::zorba::serialization::Archiver& ar); |
179 | |
180 | public: |
181 | @@ -149,7 +146,7 @@ |
182 | |
183 | Annotation ::= "%" EQName ("(" Literal ("," Literal)* ")")? |
184 | ********************************************************************************/ |
185 | -class AnnotationList : public SimpleRCObject |
186 | +class AnnotationList : public ::zorba::serialization::SerializeBaseClass |
187 | { |
188 | public: |
189 | enum DeclarationKind |
190 | @@ -165,16 +162,14 @@ |
191 | |
192 | typedef AnnotationInternal::AnnotationId AnnotationId; |
193 | |
194 | - typedef std::vector<AnnotationInternal_t> List_t; |
195 | - |
196 | - typedef List_t::const_iterator ListConstIter_t; |
197 | + typedef std::vector<AnnotationInternal*> Annotations; |
198 | |
199 | protected: |
200 | - List_t theAnnotationList; |
201 | + Annotations theAnnotationList; |
202 | |
203 | public: |
204 | SERIALIZABLE_CLASS(AnnotationList); |
205 | - SERIALIZABLE_CLASS_CONSTRUCTOR2(AnnotationList, SimpleRCObject) |
206 | + SERIALIZABLE_CLASS_CONSTRUCTOR(AnnotationList) |
207 | void serialize(::zorba::serialization::Archiver& ar); |
208 | |
209 | public: |
210 | |
211 | === modified file 'src/api/annotationimpl.cpp' |
212 | --- src/api/annotationimpl.cpp 2013-02-07 17:24:36 +0000 |
213 | +++ src/api/annotationimpl.cpp 2013-07-11 13:41:52 +0000 |
214 | @@ -27,11 +27,16 @@ |
215 | |
216 | ********************************************************************************/ |
217 | AnnotationImpl::AnnotationImpl(AnnotationInternal* ann) |
218 | - : theAnnotation(ann) |
219 | -{ |
220 | -} |
221 | - |
222 | -AnnotationImpl::~AnnotationImpl() {}; |
223 | +{ |
224 | + theAnnotation = new AnnotationInternal(*ann); |
225 | +} |
226 | + |
227 | + |
228 | +AnnotationImpl::~AnnotationImpl() |
229 | +{ |
230 | + delete theAnnotation; |
231 | +} |
232 | + |
233 | |
234 | Item AnnotationImpl::getQName() const |
235 | { |
236 | |
237 | === modified file 'src/api/annotationimpl.h' |
238 | --- src/api/annotationimpl.h 2013-02-07 17:24:36 +0000 |
239 | +++ src/api/annotationimpl.h 2013-07-11 13:41:52 +0000 |
240 | @@ -26,7 +26,6 @@ |
241 | { |
242 | |
243 | class AnnotationInternal; |
244 | -typedef rchandle<AnnotationInternal> AnnotationInternal_t; |
245 | |
246 | |
247 | /******************************************************************************* |
248 | @@ -38,7 +37,7 @@ |
249 | { |
250 | protected: |
251 | |
252 | - AnnotationInternal_t theAnnotation; |
253 | + AnnotationInternal * theAnnotation; |
254 | |
255 | public: |
256 | AnnotationImpl(AnnotationInternal* ann); |
257 | |
258 | === modified file 'src/api/serialization/serializer.cpp' |
259 | --- src/api/serialization/serializer.cpp 2013-06-29 08:38:53 +0000 |
260 | +++ src/api/serialization/serializer.cpp 2013-07-11 13:41:52 +0000 |
261 | @@ -38,10 +38,14 @@ |
262 | #include "util/xml_util.h" |
263 | |
264 | #include "system/globalenv.h" |
265 | + |
266 | #include "zorbamisc/ns_consts.h" |
267 | + |
268 | #include "zorbatypes/integer.h" |
269 | #include "zorbatypes/numconversions.h" |
270 | |
271 | +#include "context/static_context.h" |
272 | + |
273 | #include "store/api/iterator.h" |
274 | #include "store/api/iterator_factory.h" |
275 | #include "store/api/item.h" |
276 | @@ -192,10 +196,12 @@ |
277 | |
278 | // the input string is UTF-8 |
279 | int char_length; |
280 | - try { |
281 | + try |
282 | + { |
283 | char_length = utf8::char_length(*chars); |
284 | } |
285 | - catch ( utf8::invalid_byte const& ) { |
286 | + catch ( utf8::invalid_byte const& ) |
287 | + { |
288 | char_length = 1; |
289 | } |
290 | |
291 | @@ -445,9 +451,15 @@ |
292 | tr << " "; |
293 | |
294 | if (item->isStreamable()) |
295 | + { |
296 | emit_streamable_item(item); |
297 | + } |
298 | else |
299 | - emit_expanded_string(item->getStringValue().c_str(), item->getStringValue().size()); |
300 | + { |
301 | + zstring strval; |
302 | + item->getStringValue2(strval); |
303 | + emit_expanded_string(strval.c_str(), strval.size()); |
304 | + } |
305 | |
306 | thePreviousItemKind = PREVIOUS_ITEM_WAS_TEXT; |
307 | } |
308 | |
309 | === modified file 'src/api/staticcontextimpl.cpp' |
310 | --- src/api/staticcontextimpl.cpp 2013-05-31 03:38:45 +0000 |
311 | +++ src/api/staticcontextimpl.cpp 2013-07-11 13:41:52 +0000 |
312 | @@ -1497,26 +1497,24 @@ |
313 | Function_t |
314 | StaticContextImpl::checkInvokable(const Item& aQName, size_t aNumArgs) const |
315 | { |
316 | - Item lType = aQName.getType(); |
317 | - if (lType.getStringValue() != "xs:QName") |
318 | + store::Item* qname = Unmarshaller::getInternalItem(aQName); |
319 | + |
320 | + if (qname->getTypeCode() != store::XS_QNAME) |
321 | { |
322 | - throw XQUERY_EXCEPTION( |
323 | - err::XPTY0004, ERROR_PARAMS( ZED( BadType_23o ), "xs:QName" ) |
324 | - ); |
325 | + throw XQUERY_EXCEPTION(err::XPTY0004, |
326 | + ERROR_PARAMS(ZED(BadType_23o), "xs:QName" )); |
327 | } |
328 | |
329 | // test if function with given #args exists |
330 | Function_t lFunc; |
331 | + |
332 | std::vector<Function_t> lFunctions; |
333 | findFunctions(aQName, lFunctions); |
334 | + |
335 | if (lFunctions.empty()) |
336 | { |
337 | - throw XQUERY_EXCEPTION( |
338 | - err::XPST0017, |
339 | - ERROR_PARAMS( |
340 | - aQName.getStringValue(), ZED( FunctionUndeclared_3 ), aNumArgs |
341 | - ) |
342 | - ); |
343 | + throw XQUERY_EXCEPTION(err::XPST0017, |
344 | + ERROR_PARAMS(aQName.getStringValue(), ZED(FunctionUndeclared_3), aNumArgs)); |
345 | } |
346 | |
347 | for (std::vector<Function_t>::const_iterator lIter = lFunctions.begin(); |
348 | @@ -1531,12 +1529,8 @@ |
349 | |
350 | if (!lFunc) |
351 | { |
352 | - throw XQUERY_EXCEPTION( |
353 | - err::XPST0017, |
354 | - ERROR_PARAMS( |
355 | - aQName.getStringValue(), ZED( FunctionUndeclared_3 ), aNumArgs |
356 | - ) |
357 | - ); |
358 | + throw XQUERY_EXCEPTION(err::XPST0017, |
359 | + ERROR_PARAMS(aQName.getStringValue(), ZED(FunctionUndeclared_3), aNumArgs)); |
360 | } |
361 | |
362 | return lFunc; |
363 | |
364 | === modified file 'src/api/xmldatamanagerimpl.cpp' |
365 | --- src/api/xmldatamanagerimpl.cpp 2013-02-07 17:24:36 +0000 |
366 | +++ src/api/xmldatamanagerimpl.cpp 2013-07-11 13:41:52 +0000 |
367 | @@ -278,8 +278,7 @@ |
368 | { |
369 | ZORBA_DM_TRY |
370 | { |
371 | - Item lQName = theFactory->createQName(static_context::ZORBA_XML_FN_NS, |
372 | - "parse"); |
373 | + Item lQName = theFactory->createQName(static_context::ZORBA_XML_FN_NS, "parse"); |
374 | |
375 | // create a streamable string item |
376 | std::vector<ItemSequence_t> lArgs; |
377 | @@ -289,7 +288,9 @@ |
378 | Item empty_item; |
379 | Item validated_options; |
380 | NsBindings nsPairs; |
381 | - Item untyped_type = theFactory->createQName(XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped"); |
382 | + Item untyped_type = theFactory->createQName(static_context::W3C_XML_SCHEMA_NS, |
383 | + "", |
384 | + "untyped"); |
385 | Item options_node = theFactory->createElementNode(empty_item, |
386 | theFactory->createQName(static_context::ZORBA_XML_FN_OPTIONS_NS, "options"), |
387 | untyped_type, false, false, nsPairs); |
388 | @@ -337,7 +338,7 @@ |
389 | Item empty_item; |
390 | Item validated_options; |
391 | NsBindings nsPairs; |
392 | - Item untyped_type = theFactory->createQName(XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped"); |
393 | + Item untyped_type = theFactory->createQName(static_context::W3C_XML_SCHEMA_NS, "", "untyped"); |
394 | Item options_node = theFactory->createElementNode(empty_item, |
395 | theFactory->createQName(static_context::ZORBA_XML_FN_OPTIONS_NS, "options"), |
396 | untyped_type, false, false, nsPairs); |
397 | |
398 | === modified file 'src/api/xqueryimpl.cpp' |
399 | --- src/api/xqueryimpl.cpp 2013-05-28 00:01:01 +0000 |
400 | +++ src/api/xqueryimpl.cpp 2013-07-11 13:41:52 +0000 |
401 | @@ -178,6 +178,7 @@ |
402 | close(); |
403 | } |
404 | |
405 | + |
406 | /******************************************************************************* |
407 | Always called while holding theMutex |
408 | ********************************************************************************/ |
409 | |
410 | === modified file 'src/api/xqueryimpl.h' |
411 | --- src/api/xqueryimpl.h 2013-05-28 00:01:01 +0000 |
412 | +++ src/api/xqueryimpl.h 2013-07-11 13:41:52 +0000 |
413 | @@ -152,23 +152,17 @@ |
414 | |
415 | protected: |
416 | |
417 | - class PlanProxy : public RCObject |
418 | + class PlanProxy : public SyncedRCObject |
419 | { |
420 | public: |
421 | - SYNC_CODE(mutable RCLock theRCLock;) |
422 | - |
423 | rchandle<SimpleRCObject> theRootIter; |
424 | |
425 | public: |
426 | SERIALIZABLE_CLASS(PlanProxy) |
427 | - SERIALIZABLE_CLASS_CONSTRUCTOR2(PlanProxy, RCObject) |
428 | + SERIALIZABLE_CLASS_CONSTRUCTOR2(PlanProxy, SyncedRCObject) |
429 | void serialize(::zorba::serialization::Archiver& ar); |
430 | |
431 | public: |
432 | - long* getSharedRefCounter() const { return NULL; } |
433 | - |
434 | - SYNC_CODE(virtual RCLock* getRCLock() const { return &theRCLock; }) |
435 | - |
436 | PlanProxy(PlanIter_t& root); |
437 | }; |
438 | |
439 | |
440 | === modified file 'src/api/zorbaimpl.cpp' |
441 | --- src/api/zorbaimpl.cpp 2013-02-07 17:24:36 +0000 |
442 | +++ src/api/zorbaimpl.cpp 2013-07-11 13:41:52 +0000 |
443 | @@ -73,6 +73,7 @@ |
444 | } |
445 | #endif |
446 | |
447 | + |
448 | ZorbaImpl::ZorbaImpl() : theNumUsers(0) |
449 | { |
450 | #ifdef WIN32 |
451 | @@ -138,8 +139,10 @@ |
452 | XQuery_t ZorbaImpl::createQuery(DiagnosticHandler* aDiagnosticHandler) |
453 | { |
454 | XQuery_t lXQuery(new XQueryImpl()); |
455 | + |
456 | if (aDiagnosticHandler != 0) |
457 | lXQuery->registerDiagnosticHandler(aDiagnosticHandler); |
458 | + |
459 | return lXQuery; |
460 | } |
461 | |
462 | @@ -169,9 +172,12 @@ |
463 | DiagnosticHandler* aDiagnosticHandler) |
464 | { |
465 | XQuery_t lXQuery(new XQueryImpl()); |
466 | + |
467 | if (aDiagnosticHandler != 0) |
468 | lXQuery->registerDiagnosticHandler(aDiagnosticHandler); |
469 | + |
470 | lXQuery->compile(aQuery, aHints); |
471 | + |
472 | return lXQuery; |
473 | } |
474 | |
475 | |
476 | === modified file 'src/api/zorbaimpl.h' |
477 | --- src/api/zorbaimpl.h 2013-02-07 17:24:36 +0000 |
478 | +++ src/api/zorbaimpl.h 2013-07-11 13:41:52 +0000 |
479 | @@ -53,16 +53,18 @@ |
480 | */ |
481 | class ZorbaImpl : public Zorba |
482 | { |
483 | - protected: |
484 | +protected: |
485 | friend class Zorba; |
486 | |
487 | SYNC_CODE(Mutex theUsersMutex); |
488 | ulong theNumUsers; |
489 | + |
490 | public: |
491 | #ifdef WIN32 |
492 | static bool ctrl_c_signaled; |
493 | #endif |
494 | - public: |
495 | + |
496 | +public: |
497 | |
498 | static void notifyError(DiagnosticHandler*, ZorbaException const&); |
499 | |
500 | @@ -75,7 +77,7 @@ |
501 | |
502 | static void checkItem(const store::Item_t& aItem); |
503 | |
504 | - public: |
505 | +public: |
506 | |
507 | virtual ~ZorbaImpl(); |
508 | |
509 | |
510 | === modified file 'src/capi/csequence.cpp' |
511 | --- src/capi/csequence.cpp 2013-06-18 23:53:59 +0000 |
512 | +++ src/capi/csequence.cpp 2013-07-11 13:41:52 +0000 |
513 | @@ -30,6 +30,8 @@ |
514 | #include "zorbatypes/float.h" |
515 | #include "zorbatypes/numconversions.h" |
516 | |
517 | +#include "context/static_context.h" |
518 | + |
519 | #include "error.h" |
520 | |
521 | using namespace zorba; |
522 | @@ -240,7 +242,7 @@ |
523 | else /* not isNode() */ { |
524 | Item lType = lItem.getType(); |
525 | zorba::String lUri = lType.getNamespace(); |
526 | - if (lUri != XML_SCHEMA_NS) { |
527 | + if (lUri != static_context::W3C_XML_SCHEMA_NS) { |
528 | // We can only identify non-derived atomic types |
529 | return XQC_INTERNAL_ERROR; |
530 | } |
531 | |
532 | === modified file 'src/common/shared_types.h' |
533 | --- src/common/shared_types.h 2013-06-26 13:56:00 +0000 |
534 | +++ src/common/shared_types.h 2013-07-11 13:41:52 +0000 |
535 | @@ -44,9 +44,8 @@ |
536 | class QueryLoc; |
537 | |
538 | class function; |
539 | +class user_function; |
540 | typedef rchandle<function> function_t; |
541 | - |
542 | -class user_function; |
543 | typedef rchandle<user_function> user_function_t; |
544 | |
545 | class ItemIterator; |
546 | @@ -88,7 +87,6 @@ |
547 | |
548 | // Annotations |
549 | class AnnotationList; |
550 | -typedef rchandle<AnnotationList> AnnotationList_t; |
551 | |
552 | // Expression nodes |
553 | class expr; |
554 | |
555 | === modified file 'src/compiler/codegen/plan_visitor.cpp' |
556 | --- src/compiler/codegen/plan_visitor.cpp 2013-06-15 02:57:08 +0000 |
557 | +++ src/compiler/codegen/plan_visitor.cpp 2013-07-11 13:41:52 +0000 |
558 | @@ -468,7 +468,7 @@ |
559 | { |
560 | CODEGEN_TRACE_OUT(""); |
561 | |
562 | - FunctionItemInfo* fnInfo = v.get_dynamic_fn_info(); |
563 | + FunctionItemInfo* fnInfo = v.get_fi_info(); |
564 | fnInfo->theCCB = theCCB; |
565 | fnInfo->theLoc = qloc; |
566 | |
567 | |
568 | === modified file 'src/compiler/expression/expr_put.cpp' |
569 | --- src/compiler/expression/expr_put.cpp 2013-06-15 02:57:08 +0000 |
570 | +++ src/compiler/expression/expr_put.cpp 2013-07-11 13:41:52 +0000 |
571 | @@ -553,7 +553,7 @@ |
572 | } |
573 | |
574 | user_function* udf = |
575 | - static_cast<user_function*>(theFunctionItemInfo->theFunction.getp()); |
576 | + static_cast<user_function*>(theFunctionItemInfo->theFunction); |
577 | |
578 | if (udf != NULL && udf->getBody() != NULL) |
579 | udf->getBody()->put(os); |
580 | |
581 | === modified file 'src/compiler/expression/fo_expr.cpp' |
582 | --- src/compiler/expression/fo_expr.cpp 2013-02-07 17:24:36 +0000 |
583 | +++ src/compiler/expression/fo_expr.cpp 2013-07-11 13:41:52 +0000 |
584 | @@ -62,7 +62,7 @@ |
585 | user_function* udf, |
586 | const QueryLoc& loc) |
587 | { |
588 | - function* f = BuiltinFunctionLibrary::getFunction(FunctionConsts::OP_CONCATENATE_N); |
589 | + function* f = GENV_FUNC_LIB->getFunction(FunctionConsts::OP_CONCATENATE_N); |
590 | |
591 | std::auto_ptr<fo_expr> fo(ccb->theEM->create_fo_expr(sctx, udf, loc, f)); |
592 | |
593 | |
594 | === modified file 'src/compiler/expression/function_item_expr.cpp' |
595 | --- src/compiler/expression/function_item_expr.cpp 2013-04-24 01:35:58 +0000 |
596 | +++ src/compiler/expression/function_item_expr.cpp 2013-07-11 13:41:52 +0000 |
597 | @@ -92,15 +92,16 @@ |
598 | bool isInline, |
599 | bool isCoercion) |
600 | : |
601 | - expr(ccb, sctx, udf, loc, function_item_expr_kind), |
602 | - theFunctionItemInfo(new FunctionItemInfo(sctx, |
603 | - loc, |
604 | - f, |
605 | - f->getName(), |
606 | - arity, |
607 | - isInline, |
608 | - isCoercion)) |
609 | + expr(ccb, sctx, udf, loc, function_item_expr_kind) |
610 | { |
611 | + theFunctionItemInfo = new FunctionItemInfo(sctx, |
612 | + loc, |
613 | + f, |
614 | + f->getName(), |
615 | + arity, |
616 | + isInline, |
617 | + isCoercion); |
618 | + |
619 | assert(f != NULL); |
620 | compute_scripting_kind(); |
621 | } |
622 | @@ -114,15 +115,16 @@ |
623 | bool isInline, |
624 | bool isCoercion) |
625 | : |
626 | - expr(ccb, sctx, udf, loc, function_item_expr_kind), |
627 | - theFunctionItemInfo(new FunctionItemInfo(sctx, |
628 | - loc, |
629 | - NULL, |
630 | - NULL, |
631 | - 0, |
632 | - isInline, |
633 | - isCoercion)) |
634 | + expr(ccb, sctx, udf, loc, function_item_expr_kind) |
635 | { |
636 | + theFunctionItemInfo = new FunctionItemInfo(sctx, |
637 | + loc, |
638 | + NULL, |
639 | + NULL, |
640 | + 0, |
641 | + isInline, |
642 | + isCoercion); |
643 | + |
644 | compute_scripting_kind(); |
645 | } |
646 | |
647 | |
648 | === modified file 'src/compiler/expression/function_item_expr.h' |
649 | --- src/compiler/expression/function_item_expr.h 2013-04-27 16:36:36 +0000 |
650 | +++ src/compiler/expression/function_item_expr.h 2013-07-11 13:41:52 +0000 |
651 | @@ -151,7 +151,7 @@ |
652 | virtual ~function_item_expr(); |
653 | |
654 | public: |
655 | - FunctionItemInfo* get_dynamic_fn_info() { return theFunctionItemInfo; } |
656 | + FunctionItemInfo* get_fi_info() { return theFunctionItemInfo; } |
657 | |
658 | void add_variable(expr* var, var_expr* substVar); |
659 | |
660 | |
661 | === modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp' |
662 | --- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-06-18 23:53:59 +0000 |
663 | +++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-07-11 13:41:52 +0000 |
664 | @@ -38,6 +38,8 @@ |
665 | #include "store/api/copymode.h" |
666 | #include "store/api/iterator.h" |
667 | |
668 | +#include "context/static_context.h" |
669 | + |
670 | #include "system/globalenv.h" |
671 | #include "zorbamisc/ns_consts.h" |
672 | |
673 | @@ -517,9 +519,9 @@ |
674 | theIsIndexDecl(false), |
675 | theWaitForIndexSourceLiteral(false) |
676 | { |
677 | - theNamespaceMap["fn"] = XQUERY_XPATH_FN_NS; |
678 | - theNamespaceMap[""] = XQUERY_XPATH_FN_NS; |
679 | - theNamespaceMap[XML_SCHEMA_PREFIX] = XML_SCHEMA_NS; |
680 | + theNamespaceMap["fn"] = static_context::W3C_FN_NS; |
681 | + theNamespaceMap[""] = static_context::W3C_FN_NS; |
682 | + theNamespaceMap[XML_SCHEMA_PREFIX] = static_context::W3C_XML_SCHEMA_NS; |
683 | theNamespaceMap["local"] = XQUERY_LOCAL_FN_NS; |
684 | } |
685 | |
686 | |
687 | === modified file 'src/compiler/rewriter/rules/type_rules.cpp' |
688 | --- src/compiler/rewriter/rules/type_rules.cpp 2013-06-15 02:57:08 +0000 |
689 | +++ src/compiler/rewriter/rules/type_rules.cpp 2013-07-11 13:41:52 +0000 |
690 | @@ -605,7 +605,7 @@ |
691 | ZORBA_ASSERT(false); |
692 | } |
693 | |
694 | - return BuiltinFunctionLibrary::getFunction(newKind); |
695 | + return GENV_FUNC_LIB->getFunction(newKind); |
696 | } |
697 | |
698 | |
699 | |
700 | === modified file 'src/compiler/translator/translator.cpp' |
701 | --- src/compiler/translator/translator.cpp 2013-06-27 00:05:25 +0000 |
702 | +++ src/compiler/translator/translator.cpp 2013-07-11 13:41:52 +0000 |
703 | @@ -684,7 +684,7 @@ |
704 | |
705 | std::stack<bool> theInWhileStack; |
706 | |
707 | - rchandle<AnnotationList> theAnnotations; |
708 | + std::auto_ptr<AnnotationList> theAnnotations; |
709 | |
710 | IndexDecl_t theIndexDecl; |
711 | bool theIsInIndexDomain; |
712 | @@ -1123,7 +1123,7 @@ |
713 | } |
714 | else if (local == "atomic") |
715 | { |
716 | - ns = XML_SCHEMA_NS; |
717 | + ns = static_context::W3C_XML_SCHEMA_NS; |
718 | local = "anyAtomicType"; |
719 | } |
720 | else |
721 | @@ -1136,7 +1136,7 @@ |
722 | WARN_LOC(loc))); |
723 | } |
724 | |
725 | - ns = XML_SCHEMA_NS; |
726 | + ns = static_context::W3C_XML_SCHEMA_NS; |
727 | } |
728 | |
729 | GENV_ITEMFACTORY->createQName(qnameItem, ns, "", local); |
730 | @@ -1428,18 +1428,18 @@ |
731 | such a binding exists already in any of these sctxs. |
732 | ********************************************************************************/ |
733 | void bind_fn( |
734 | - function_t& f, |
735 | + const function_t& f, |
736 | csize nargs, |
737 | const QueryLoc& loc) |
738 | { |
739 | - theSctx->bind_fn(f, nargs, loc); |
740 | - |
741 | theModulesInfo->theGlobalSctx->bind_fn(f, nargs, loc); |
742 | |
743 | if (theExportSctx != NULL) |
744 | { |
745 | theExportSctx->bind_fn(f, nargs, loc); |
746 | } |
747 | + |
748 | + theSctx->bind_fn(f, nargs, loc); |
749 | } |
750 | |
751 | |
752 | @@ -1647,14 +1647,14 @@ |
753 | inlineFuncExpr->add_variable(fiVar, fiSubstVar); |
754 | |
755 | // Create the inline udf obj. |
756 | - user_function_t inlineUDF = |
757 | + std::auto_ptr<user_function> inlineUDF( |
758 | new user_function(loc, |
759 | signature(function_item_expr::create_inline_fname(loc), |
760 | funcType->get_param_types(), |
761 | returnType), |
762 | NULL, |
763 | SIMPLE_EXPR, |
764 | - theCCB); |
765 | + theCCB)); |
766 | |
767 | std::vector<var_expr*> argVars; |
768 | std::vector<expr*> arguments; // Arguments to the dynamic function call |
769 | @@ -1669,7 +1669,7 @@ |
770 | argVars.push_back(argVar); |
771 | |
772 | expr* arg = CREATE(wrapper)(theRootSctx, theUDF, loc, argVar); |
773 | - arg = normalize_fo_arg(i, arg, inlineUDF, loc); |
774 | + arg = normalize_fo_arg(i, arg, inlineUDF.get(), loc); |
775 | arguments.push_back(arg); |
776 | } |
777 | |
778 | @@ -1696,7 +1696,7 @@ |
779 | inlineUDF->setArgVars(argVars); |
780 | inlineUDF->setOptimized(true); |
781 | |
782 | - inlineFuncExpr->set_function(inlineUDF, inlineUDF->numArgs()); |
783 | + inlineFuncExpr->set_function(inlineUDF.release(), inlineUDF->numArgs()); |
784 | |
785 | // pop the scope. |
786 | pop_scope(); |
787 | @@ -1813,12 +1813,9 @@ |
788 | fkind = FunctionConsts::OP_SORT_DISTINCT_NODES_ASC_1; |
789 | } |
790 | |
791 | - fo_expr* dos = theExprManager-> |
792 | - create_fo_expr(theRootSctx, |
793 | - theUDF, |
794 | - expr->get_loc(), |
795 | - BuiltinFunctionLibrary::getFunction(fkind), |
796 | - expr); |
797 | + fo_expr* dos = CREATE(fo)(theRootSctx, theUDF, expr->get_loc(), |
798 | + GENV_FUNC_LIB->getFunction(fkind), |
799 | + expr); |
800 | |
801 | normalize_fo(dos); |
802 | |
803 | @@ -2209,7 +2206,7 @@ |
804 | theSctx->bind_ns(pfx, targetNS, loc); |
805 | } |
806 | |
807 | - if (targetNS == XML_SCHEMA_NS) |
808 | + if (targetNS == static_context::W3C_XML_SCHEMA_NS) |
809 | { |
810 | // Xerces doesn't like importing XMLSchema.xsd schema4schema, so we skip it |
811 | // see Xerces-C++ bug: https://issues.apache.org/jira/browse/XERCESC-1980 |
812 | @@ -3216,7 +3213,7 @@ |
813 | RAISE_ERROR(err::XQST0070, loc, |
814 | ERROR_PARAMS(ZED(XQST0070_ReservedPrefixInDecl_2), pre)); |
815 | } |
816 | - else if (uri == XML_NS || uri == XMLNS_NS) |
817 | + else if (uri == static_context::W3C_XML_NS || uri == XMLNS_NS) |
818 | { |
819 | RAISE_ERROR(err::XQST0070, loc, |
820 | ERROR_PARAMS(ZED(XQST0070_ReservedURI_23), pre, uri)); |
821 | @@ -3243,7 +3240,7 @@ |
822 | |
823 | zstring uri = v.get_default_namespace(); |
824 | |
825 | - if (uri == XML_NS || uri == XMLNS_NS) |
826 | + if (uri == static_context::W3C_XML_NS || uri == XMLNS_NS) |
827 | { |
828 | RAISE_ERROR(err::XQST0070, loc, |
829 | ERROR_PARAMS(ZED(XQST0070_ReservedURI_23), "", uri)); |
830 | @@ -3515,7 +3512,7 @@ |
831 | |
832 | // Get the parent of the query root sctx. This is the user-specified sctx |
833 | // (if any) or the zorba root sctx (if no user-specified sctx). |
834 | - static_context_t independentSctx = |
835 | + static_context* independentSctx = |
836 | static_cast<static_context *>(theCCB->theRootSctx->get_parent()); |
837 | |
838 | // Create the root sctx for the imported module as a child of the |
839 | @@ -3841,7 +3838,7 @@ |
840 | { |
841 | annotations->accept(*this); |
842 | |
843 | - if (theAnnotations) |
844 | + if (theAnnotations.get()) |
845 | { |
846 | theAnnotations-> |
847 | checkConflictingDeclarations(AnnotationList::var_decl, loc); |
848 | @@ -3874,7 +3871,7 @@ |
849 | ve->set_mutable(theSctx->is_feature_set(feature::scripting)); |
850 | } |
851 | |
852 | - theAnnotations = NULL; |
853 | + theAnnotations.reset(NULL); |
854 | |
855 | // Put a mapping between the var name and the var_expr in the local sctx. |
856 | // Raise error if var name exists already in local sctx obj. |
857 | @@ -3927,8 +3924,8 @@ |
858 | RAISE_ERROR(err::XQST0060, loc, ERROR_PARAMS(qnameItem->getStringValue())); |
859 | |
860 | if (ns == static_context::W3C_FN_NS || |
861 | - ns == XML_NS || |
862 | - ns == XML_SCHEMA_NS || |
863 | + ns == static_context::W3C_XML_NS || |
864 | + ns == static_context::W3C_XML_SCHEMA_NS || |
865 | ns == XSI_NS || |
866 | ns == static_context::XQUERY_MATH_FN_NS) |
867 | { |
868 | @@ -3984,12 +3981,12 @@ |
869 | } |
870 | |
871 | // Create the function signature. |
872 | - bool isVariadic = (theAnnotations ? ZANN_CONTAINS(zann_variadic): false); |
873 | + bool isVariadic = (theAnnotations.get() ? ZANN_CONTAINS(zann_variadic): false); |
874 | |
875 | signature sig(qnameItem, paramTypes, returnType, isVariadic); |
876 | |
877 | // Get the scripting kind of the function |
878 | - bool isSequential = (theAnnotations ? |
879 | + bool isSequential = (theAnnotations.get() ? |
880 | ZANN_CONTAINS(zann_sequential) : |
881 | false); |
882 | |
883 | @@ -4001,12 +3998,12 @@ |
884 | scriptKind = SEQUENTIAL_FUNC_EXPR; |
885 | |
886 | // create the function object |
887 | - function_t f; |
888 | + function_t func; |
889 | |
890 | if (func_decl->is_external()) |
891 | { |
892 | // 1. lookup if the function is a built-in function |
893 | - f = theSctx->lookup_fn(qnameItem, numParams, false); |
894 | + function* f = theSctx->lookup_fn(qnameItem, numParams, false); |
895 | |
896 | if (f != 0) |
897 | { |
898 | @@ -4036,8 +4033,8 @@ |
899 | qnameItem->getLocalName()))); |
900 | } |
901 | |
902 | - f->setAnnotations(theAnnotations); |
903 | - theAnnotations = NULL; // important to reset |
904 | + f->setAnnotations(theAnnotations.get()); |
905 | + theAnnotations.release(); // important to reset |
906 | |
907 | // continue with the next declaration, because we don't add already |
908 | // built-in functions to the static context |
909 | @@ -4080,25 +4077,27 @@ |
910 | |
911 | ZORBA_ASSERT(ef != NULL); |
912 | |
913 | - f = new external_function(loc, |
914 | - theRootSctx, |
915 | - qnameItem->getNamespace(), |
916 | - sig, |
917 | - scriptKind, |
918 | - ef); |
919 | + func = new external_function(loc, |
920 | + theRootSctx, |
921 | + qnameItem->getNamespace(), |
922 | + sig, |
923 | + scriptKind, |
924 | + ef); |
925 | } |
926 | - else // Process UDF (non-external) function declaration |
927 | + else |
928 | { |
929 | - f = new user_function(loc, sig, NULL, scriptKind, theCCB); // no body for now |
930 | + // It's a UDF (non-external) function declaration. Create a user_function |
931 | + // obj with no body for now. |
932 | + func = new user_function(loc, sig, NULL, scriptKind, theCCB); |
933 | } |
934 | |
935 | - f->setAnnotations(theAnnotations); |
936 | - theAnnotations = NULL; // important to reset |
937 | + func->setAnnotations(theAnnotations.get()); |
938 | + theAnnotations.release(); // important to reset |
939 | |
940 | // Create bindings between (function qname item, arity) and function obj |
941 | // in the current sctx of this module and, if this is a lib module, in its |
942 | // export sctx as well. |
943 | - bind_fn(f, numParams, loc); |
944 | + bind_fn(func, numParams, loc); |
945 | } |
946 | |
947 | if (haveXQueryOptions) |
948 | @@ -4753,7 +4752,7 @@ |
949 | |
950 | ve->set_mutable(false); |
951 | |
952 | - theAnnotations = NULL; |
953 | + theAnnotations.reset(NULL); |
954 | |
955 | // Put a mapping between the var name and the var_expr in the local sctx. |
956 | // Raise error if var name exists already in local sctx obj. |
957 | @@ -4819,9 +4818,9 @@ |
958 | { |
959 | TRACE_VISIT(); |
960 | |
961 | - assert(theAnnotations == NULL); |
962 | + assert(theAnnotations.get() == NULL); |
963 | |
964 | - theAnnotations = new AnnotationList(); |
965 | + theAnnotations.reset(new AnnotationList()); |
966 | |
967 | return no_state; |
968 | } |
969 | @@ -4861,7 +4860,7 @@ |
970 | |
971 | if (annotNS == static_context::XQUERY_NS || |
972 | annotNS == static_context::W3C_XML_NS || |
973 | - annotNS == XML_SCHEMA_NS || |
974 | + annotNS == static_context::W3C_XML_SCHEMA_NS || |
975 | annotNS == XSI_NS || |
976 | annotNS == static_context::W3C_FN_NS || |
977 | annotNS == static_context::XQUERY_MATH_FN_NS || |
978 | @@ -4977,9 +4976,9 @@ |
979 | lAnns->accept(*this); |
980 | } |
981 | |
982 | - if ( !theAnnotations ) |
983 | + if (theAnnotations.get() == NULL) |
984 | { |
985 | - theAnnotations = new AnnotationList(); |
986 | + theAnnotations.reset(new AnnotationList()); |
987 | } |
988 | |
989 | theAnnotations-> |
990 | @@ -5058,14 +5057,14 @@ |
991 | // Create the collection object and register it in the static context |
992 | StaticallyKnownCollection_t lColl = new StaticallyKnownCollection( |
993 | lExpandedQName, |
994 | - theAnnotations, |
995 | + theAnnotations.get(), |
996 | lNodeType, |
997 | lCollectionType, |
998 | lUpdateMode, |
999 | lOrderMode, |
1000 | lNodeModifier); |
1001 | |
1002 | - theAnnotations = NULL; // important to reset |
1003 | + theAnnotations.release(); // important to reset |
1004 | |
1005 | theSctx->bind_collection(lColl, loc); |
1006 | |
1007 | @@ -5136,7 +5135,7 @@ |
1008 | lAnns->accept(*this); |
1009 | } |
1010 | |
1011 | - if (theAnnotations) |
1012 | + if (theAnnotations.get()) |
1013 | { |
1014 | theAnnotations-> |
1015 | checkConflictingDeclarations(AnnotationList::index_decl, loc); |
1016 | @@ -5161,7 +5160,7 @@ |
1017 | } |
1018 | } |
1019 | |
1020 | - theAnnotations = NULL; |
1021 | + theAnnotations.reset(NULL); |
1022 | |
1023 | theIndexDecl = index; |
1024 | theIsInIndexDomain = true; |
1025 | @@ -6502,7 +6501,7 @@ |
1026 | |
1027 | var_expr* ve = dynamic_cast<var_expr*>(pop_nodestack()); |
1028 | |
1029 | - if (theAnnotations) |
1030 | + if (theAnnotations.get()) |
1031 | { |
1032 | theAnnotations-> |
1033 | checkConflictingDeclarations(AnnotationList::var_decl, loc); |
1034 | @@ -6546,7 +6545,7 @@ |
1035 | |
1036 | push_nodestack(initExpr); |
1037 | |
1038 | - theAnnotations = NULL; |
1039 | + theAnnotations.reset(NULL); |
1040 | } |
1041 | |
1042 | |
1043 | @@ -12595,17 +12594,17 @@ |
1044 | const QueryLoc& loc) |
1045 | { |
1046 | xqtref_t type; |
1047 | - rchandle<user_function> udf; |
1048 | + std::auto_ptr<user_function> udf; |
1049 | expr* body; |
1050 | |
1051 | function_item_expr* fiExpr = |
1052 | CREATE(function_item)(theRootSctx, theUDF, loc, false, false); |
1053 | |
1054 | - function* f = theSctx->lookup_fn(qnameItem, arity, loc); |
1055 | + function* func = theSctx->lookup_fn(qnameItem, arity, loc); |
1056 | |
1057 | // Raise XPST0017 if function could not be found, unless it is a type constructor |
1058 | // function |
1059 | - if (f == NULL) |
1060 | + if (func == NULL) |
1061 | { |
1062 | type = CTX_TM-> |
1063 | create_named_type(qnameItem, TypeConstants::QUANT_QUESTION, loc); |
1064 | @@ -12623,16 +12622,16 @@ |
1065 | var_expr* argVar = create_temp_var(loc, var_expr::arg_var); |
1066 | argVar->set_param_pos(0); |
1067 | udfArgs[0] = argVar; |
1068 | - expr* body = CREATE(cast)(theRootSctx, udf, loc, argVar, type, false); |
1069 | + expr* body = CREATE(cast)(theRootSctx, theUDF, loc, argVar, type, false); |
1070 | |
1071 | - udf = new user_function(loc, |
1072 | - signature(qnameItem, theRTM.ITEM_TYPE_QUESTION, type), |
1073 | - body, |
1074 | - SIMPLE_EXPR, |
1075 | - theCCB); |
1076 | + udf.reset(new user_function(loc, |
1077 | + signature(qnameItem, theRTM.ITEM_TYPE_QUESTION, type), |
1078 | + body, |
1079 | + SIMPLE_EXPR, |
1080 | + theCCB)); |
1081 | |
1082 | udf->setArgVars(udfArgs); |
1083 | - f = udf; |
1084 | + func = udf.get(); |
1085 | } |
1086 | else |
1087 | { |
1088 | @@ -12640,7 +12639,7 @@ |
1089 | // the module it belongs to has been imported. |
1090 | const zstring& fn_ns = qnameItem->getNamespace(); |
1091 | |
1092 | - if (f->isBuiltin() && |
1093 | + if (func->isBuiltin() && |
1094 | fn_ns != static_context::W3C_FN_NS && |
1095 | fn_ns != static_context::JSONIQ_FN_NS && |
1096 | fn_ns != static_context::XQUERY_MATH_FN_NS && |
1097 | @@ -12655,15 +12654,15 @@ |
1098 | |
1099 | // If it is a builtin function F with signature (R, T1, ..., TN) , wrap it |
1100 | // in a udf UF: function UF(x1 as T1, ..., xN as TN) as R { F(x1, ... xN) } |
1101 | - if (!f->isUdf()) |
1102 | + if (!func->isUdf()) |
1103 | { |
1104 | - FunctionConsts::FunctionKind fkind = f->getKind(); |
1105 | + FunctionConsts::FunctionKind fkind = func->getKind(); |
1106 | |
1107 | - udf = new user_function(loc, |
1108 | - f->getSignature(), |
1109 | - NULL, // no body for now |
1110 | - f->getScriptingKind(), |
1111 | - theCCB); |
1112 | + udf.reset(new user_function(loc, |
1113 | + func->getSignature(), |
1114 | + NULL, // no body for now |
1115 | + func->getScriptingKind(), |
1116 | + theCCB)); |
1117 | |
1118 | std::vector<expr*> foArgs(arity); |
1119 | std::vector<var_expr*> udfArgs(arity); |
1120 | @@ -12696,13 +12695,13 @@ |
1121 | |
1122 | fiExpr->add_variable(posVarRef, substVar); |
1123 | |
1124 | - body = generate_fn_body(f, foArgs, loc); |
1125 | + body = generate_fn_body(func, foArgs, loc); |
1126 | |
1127 | pop_scope(); |
1128 | } |
1129 | else |
1130 | { |
1131 | - body = generate_fn_body(f, foArgs, loc); |
1132 | + body = generate_fn_body(func, foArgs, loc); |
1133 | } |
1134 | |
1135 | break; |
1136 | @@ -12725,13 +12724,13 @@ |
1137 | |
1138 | fiExpr->add_variable(sizeVarRef, substVar); |
1139 | |
1140 | - body = generate_fn_body(f, foArgs, loc); |
1141 | + body = generate_fn_body(func, foArgs, loc); |
1142 | |
1143 | pop_scope(); |
1144 | } |
1145 | else |
1146 | { |
1147 | - body = generate_fn_body(f, foArgs, loc); |
1148 | + body = generate_fn_body(func, foArgs, loc); |
1149 | } |
1150 | |
1151 | break; |
1152 | @@ -12773,13 +12772,13 @@ |
1153 | |
1154 | fiExpr->add_variable(dotVarRef, substVar); |
1155 | |
1156 | - body = generate_fn_body(f, foArgs, loc); |
1157 | + body = generate_fn_body(func, foArgs, loc); |
1158 | |
1159 | pop_scope(); |
1160 | } |
1161 | else |
1162 | { |
1163 | - body = generate_fn_body(f, foArgs, loc); |
1164 | + body = generate_fn_body(func, foArgs, loc); |
1165 | } |
1166 | |
1167 | break; |
1168 | @@ -12793,7 +12792,7 @@ |
1169 | flworBody->add_clause(lc); |
1170 | foArgs[1] = CREATE(wrapper)(theRootSctx, theUDF, loc, lc->get_var()); |
1171 | |
1172 | - flworBody->set_return_expr(generate_fn_body(f, foArgs, loc)); |
1173 | + flworBody->set_return_expr(generate_fn_body(func, foArgs, loc)); |
1174 | body = flworBody; |
1175 | break; |
1176 | } |
1177 | @@ -12853,7 +12852,7 @@ |
1178 | fiExpr->add_variable(ctxVRef, substVar); |
1179 | } |
1180 | |
1181 | - body = generate_fn_body(f, foArgs, loc); |
1182 | + body = generate_fn_body(func, foArgs, loc); |
1183 | |
1184 | if (varAdded) |
1185 | pop_scope(); |
1186 | @@ -12862,7 +12861,7 @@ |
1187 | } |
1188 | default: |
1189 | { |
1190 | - body = generate_fn_body(f, foArgs, loc); |
1191 | + body = generate_fn_body(func, foArgs, loc); |
1192 | break; |
1193 | } |
1194 | } // switch |
1195 | @@ -12873,7 +12872,7 @@ |
1196 | } // if builtin function |
1197 | else |
1198 | { |
1199 | - udf = static_cast<user_function*>(f); |
1200 | + udf.reset(static_cast<user_function*>(func)); |
1201 | } |
1202 | } |
1203 | |
1204 | @@ -12882,7 +12881,7 @@ |
1205 | // because the function item expression may be a forward refereence to a real |
1206 | // UDF, in which case udf->numArgs() returns 0 since the UDF declaration has |
1207 | // not been fully processed yet. |
1208 | - fiExpr->set_function(udf, arity); |
1209 | + fiExpr->set_function(udf.release(), arity); |
1210 | |
1211 | return fiExpr; |
1212 | } |
1213 | @@ -13035,14 +13034,14 @@ |
1214 | } |
1215 | |
1216 | // Create the udf obj. |
1217 | - user_function_t udf = |
1218 | + std::auto_ptr<user_function> udf( |
1219 | new user_function(loc, |
1220 | signature(function_item_expr::create_inline_fname(loc), |
1221 | paramTypes, |
1222 | returnType), |
1223 | NULL, |
1224 | SIMPLE_EXPR, |
1225 | - theCCB); |
1226 | + theCCB)); |
1227 | |
1228 | // Parameters, if any, have been translated into LET vars in a flwor expr. |
1229 | // The UDF body, which in genral references these LET vars, must become the |
1230 | @@ -13064,7 +13063,7 @@ |
1231 | // for arg-value type checking must be placed in the body of the udf itself, |
1232 | // instead of the caller. |
1233 | argVar->set_type(theRTM.ITEM_TYPE_STAR); |
1234 | - lc->set_expr(normalize_fo_arg(i, lc->get_expr(), udf.getp(), loc)); |
1235 | + lc->set_expr(normalize_fo_arg(i, lc->get_expr(), udf.get(), loc)); |
1236 | |
1237 | argVars.push_back(argVar); |
1238 | } |
1239 | @@ -13078,11 +13077,13 @@ |
1240 | // Get the function_item_expr and set its function to the udf created above. |
1241 | function_item_expr* fiExpr = dynamic_cast<function_item_expr*>(theNodeStack.top()); |
1242 | assert(fiExpr != NULL); |
1243 | - fiExpr->set_function(udf, udf->numArgs()); |
1244 | + fiExpr->set_function(udf.get(), udf->numArgs()); |
1245 | |
1246 | if (theCCB->theConfig.translate_cb != NULL) |
1247 | theCCB->theConfig.translate_cb(udf->getBody(), |
1248 | udf->getName()->getStringValue().c_str()); |
1249 | + |
1250 | + udf.release(); |
1251 | } |
1252 | |
1253 | |
1254 | @@ -13510,13 +13511,13 @@ |
1255 | |
1256 | if (have_uri) |
1257 | { |
1258 | - if ((ZSTREQ(prefix, "xml") && !ZSTREQ(uri, XML_NS))) |
1259 | + if ((ZSTREQ(prefix, "xml") && uri != static_context::W3C_XML_NS)) |
1260 | { |
1261 | RAISE_ERROR(err::XQST0070, loc, |
1262 | ERROR_PARAMS(ZED(XQST0070_ReservedPrefix_23), prefix, uri)); |
1263 | } |
1264 | |
1265 | - if ((ZSTREQ(uri, XML_NS) && !ZSTREQ(prefix, "xml")) || |
1266 | + if ((uri == static_context::W3C_XML_NS && !ZSTREQ(prefix, "xml")) || |
1267 | ZSTREQ(uri, XMLNS_NS)) |
1268 | { |
1269 | RAISE_ERROR(err::XQST0070, loc, |
1270 | |
1271 | === modified file 'src/compiler/xqddf/collection_decl.cpp' |
1272 | --- src/compiler/xqddf/collection_decl.cpp 2013-02-07 17:24:36 +0000 |
1273 | +++ src/compiler/xqddf/collection_decl.cpp 2013-07-11 13:41:52 +0000 |
1274 | @@ -34,10 +34,10 @@ |
1275 | |
1276 | ********************************************************************************/ |
1277 | StaticallyKnownCollection::StaticallyKnownCollection( |
1278 | - store::Item_t& aName, |
1279 | - const AnnotationList_t& aAnnotations, |
1280 | - xqtref_t& aNodeType, |
1281 | - xqtref_t& aCollectionType, |
1282 | + store::Item_t& aName, |
1283 | + AnnotationList* aAnnotations, |
1284 | + xqtref_t& aNodeType, |
1285 | + xqtref_t& aCollectionType, |
1286 | StaticContextConsts::declaration_property_t aUpdateProperty, |
1287 | StaticContextConsts::declaration_property_t aOrderProperty, |
1288 | StaticContextConsts::node_modifier_t aNodeModifier |
1289 | @@ -59,6 +59,7 @@ |
1290 | ********************************************************************************/ |
1291 | StaticallyKnownCollection::~StaticallyKnownCollection() |
1292 | { |
1293 | + delete theAnnotations; |
1294 | } |
1295 | |
1296 | |
1297 | |
1298 | === modified file 'src/compiler/xqddf/collection_decl.h' |
1299 | --- src/compiler/xqddf/collection_decl.h 2013-02-07 17:24:36 +0000 |
1300 | +++ src/compiler/xqddf/collection_decl.h 2013-07-11 13:41:52 +0000 |
1301 | @@ -33,7 +33,7 @@ |
1302 | { |
1303 | private: |
1304 | store::Item_t theName; |
1305 | - AnnotationList_t theAnnotations; |
1306 | + AnnotationList * theAnnotations; |
1307 | xqtref_t theNodeType; |
1308 | xqtref_t theCollectionType; |
1309 | |
1310 | @@ -53,10 +53,10 @@ |
1311 | |
1312 | public: |
1313 | StaticallyKnownCollection( |
1314 | - store::Item_t& name, |
1315 | - const AnnotationList_t& nannotationList, |
1316 | - xqtref_t& nodeType, |
1317 | - xqtref_t& collectionType, |
1318 | + store::Item_t& name, |
1319 | + AnnotationList* annotationList, |
1320 | + xqtref_t& nodeType, |
1321 | + xqtref_t& collectionType, |
1322 | StaticContextConsts::declaration_property_t updateProperty, |
1323 | StaticContextConsts::declaration_property_t orderProperty, |
1324 | StaticContextConsts::node_modifier_t nodeModifier); |
1325 | @@ -65,7 +65,7 @@ |
1326 | |
1327 | const store::Item* getName() const { return theName.getp(); } |
1328 | |
1329 | - AnnotationList* getAnnotations() const { return theAnnotations.getp(); }; |
1330 | + AnnotationList* getAnnotations() const { return theAnnotations; } |
1331 | |
1332 | StaticContextConsts::declaration_property_t getUpdateProperty() const |
1333 | { |
1334 | |
1335 | === modified file 'src/context/root_static_context.cpp' |
1336 | --- src/context/root_static_context.cpp 2013-06-09 08:09:40 +0000 |
1337 | +++ src/context/root_static_context.cpp 2013-07-11 13:41:52 +0000 |
1338 | @@ -141,8 +141,8 @@ |
1339 | "jn", static_context::JSONIQ_FN_NS, |
1340 | "js", static_context::JSONIQ_DM_NS, |
1341 | "local", XQUERY_LOCAL_FN_NS, |
1342 | - "xml", XML_NS, |
1343 | - "xs", XML_SCHEMA_NS, |
1344 | + "xml", static_context::W3C_XML_NS, |
1345 | + "xs", static_context::W3C_XML_SCHEMA_NS, |
1346 | "xsi", XSI_NS, |
1347 | NULL, NULL |
1348 | }; |
1349 | @@ -275,5 +275,10 @@ |
1350 | { |
1351 | } |
1352 | |
1353 | + |
1354 | +void root_static_context::free() |
1355 | +{ |
1356 | +} |
1357 | + |
1358 | } |
1359 | /* vim:set et sw=2 ts=2: */ |
1360 | |
1361 | === modified file 'src/context/root_static_context.h' |
1362 | --- src/context/root_static_context.h 2013-02-07 17:24:36 +0000 |
1363 | +++ src/context/root_static_context.h 2013-07-11 13:41:52 +0000 |
1364 | @@ -40,6 +40,8 @@ |
1365 | |
1366 | void init(); |
1367 | |
1368 | + virtual void free(); |
1369 | + |
1370 | const char** get_builtin_uri_path() const { return theBuiltinURIPath; } |
1371 | const char** get_builtin_lib_path() const { return theBuiltinLibPath; } |
1372 | }; |
1373 | |
1374 | === modified file 'src/context/static_context.cpp' |
1375 | --- src/context/static_context.cpp 2013-07-04 22:17:19 +0000 |
1376 | +++ src/context/static_context.cpp 2013-07-11 13:41:52 +0000 |
1377 | @@ -131,12 +131,13 @@ |
1378 | *******************************************************************************/ |
1379 | FunctionInfo::FunctionInfo() |
1380 | : |
1381 | + theFunction(NULL), |
1382 | theIsDisabled(false) |
1383 | { |
1384 | } |
1385 | |
1386 | |
1387 | -FunctionInfo::FunctionInfo(const function_t& f, bool disabled) |
1388 | +FunctionInfo::FunctionInfo(function* f, bool disabled) |
1389 | : |
1390 | theFunction(f), |
1391 | theIsDisabled(disabled) |
1392 | @@ -324,14 +325,15 @@ |
1393 | const zstring |
1394 | static_context::DOT_SIZE_VAR_NAME = "$$context-size"; |
1395 | |
1396 | + |
1397 | const char* |
1398 | static_context::W3C_NS_PREFIX = "http://www.w3.org/"; |
1399 | |
1400 | const char* |
1401 | -static_context::ZORBA_NS_PREFIX = "http://www.zorba-xquery.com/"; |
1402 | +static_context::W3C_XML_NS = "http://www.w3.org/XML/1998/namespace"; |
1403 | |
1404 | const char* |
1405 | -static_context::ZORBA_IO_NS_PREFIX = "http://zorba.io/"; |
1406 | +static_context::W3C_XML_SCHEMA_NS = "http://www.w3.org/2001/XMLSchema"; |
1407 | |
1408 | const char* |
1409 | static_context::W3C_FN_NS = "http://www.w3.org/2005/xpath-functions"; |
1410 | @@ -340,11 +342,15 @@ |
1411 | static_context::W3C_ERR_NS = "http://www.w3.org/2005/xqt-errors"; |
1412 | |
1413 | const char* |
1414 | -static_context::W3C_XML_NS = "http://www.w3.org/XML/1998/namespace"; |
1415 | - |
1416 | -const char* |
1417 | static_context::XQUERY_MATH_FN_NS = "http://www.w3.org/2005/xpath-functions/math"; |
1418 | |
1419 | + |
1420 | +const char* |
1421 | +static_context::ZORBA_NS_PREFIX = "http://www.zorba-xquery.com/"; |
1422 | + |
1423 | +const char* |
1424 | +static_context::ZORBA_IO_NS_PREFIX = "http://zorba.io/"; |
1425 | + |
1426 | const char* |
1427 | static_context::ZORBA_MATH_FN_NS = |
1428 | "http://www.zorba-xquery.com/modules/math"; |
1429 | @@ -779,7 +785,7 @@ |
1430 | << parent << std::endl; |
1431 | #endif |
1432 | |
1433 | - if (theParent != NULL) |
1434 | + if (theParent != NULL && !theParent->is_global_root_sctx()) |
1435 | RCHelper::addReference(theParent); |
1436 | } |
1437 | |
1438 | @@ -789,7 +795,7 @@ |
1439 | ********************************************************************************/ |
1440 | static_context::static_context(::zorba::serialization::Archiver& ar) |
1441 | : |
1442 | - SimpleRCObject(ar), |
1443 | + SyncedRCObject(ar), |
1444 | theParent(NULL), |
1445 | theTraceStream(NULL), |
1446 | theQueryExpr(NULL), |
1447 | @@ -871,7 +877,9 @@ |
1448 | delete theICMap; |
1449 | |
1450 | if (theFunctionMap) |
1451 | + { |
1452 | delete theFunctionMap; |
1453 | + } |
1454 | |
1455 | if (theFunctionArityMap) |
1456 | { |
1457 | @@ -879,7 +887,8 @@ |
1458 | FunctionArityMap::iterator end = theFunctionArityMap->end(); |
1459 | for (; ite != end; ++ite) |
1460 | { |
1461 | - delete (*ite).second; |
1462 | + std::vector<FunctionInfo>* fv = ite.getValue(); |
1463 | + delete fv; |
1464 | } |
1465 | |
1466 | delete theFunctionArityMap; |
1467 | @@ -926,7 +935,7 @@ |
1468 | if (theBaseUriInfo) |
1469 | delete theBaseUriInfo; |
1470 | |
1471 | - if (theParent) |
1472 | + if (theParent && !theParent->is_global_root_sctx()) |
1473 | RCHelper::removeReference(theParent); |
1474 | } |
1475 | |
1476 | @@ -1062,7 +1071,7 @@ |
1477 | ar & parent_is_root; |
1478 | ar.set_is_temp_field(false); |
1479 | |
1480 | - if(!parent_is_root) |
1481 | + if (!parent_is_root) |
1482 | { |
1483 | ar.dont_allow_delay(); |
1484 | ar & theParent; |
1485 | @@ -1081,15 +1090,16 @@ |
1486 | ar & parent_is_root; |
1487 | ar.set_is_temp_field(false); |
1488 | |
1489 | - if(parent_is_root) |
1490 | + if (parent_is_root) |
1491 | { |
1492 | - set_parent_as_root(); |
1493 | + theParent = &GENV_ROOT_STATIC_CONTEXT; |
1494 | } |
1495 | else |
1496 | + { |
1497 | ar & theParent; |
1498 | - |
1499 | - if (theParent) |
1500 | - theParent->addReference(SYNC_CODE(theParent->getRCLock())); |
1501 | + ZORBA_ASSERT(theParent); |
1502 | + theParent->addReference(); |
1503 | + } |
1504 | } |
1505 | |
1506 | ar & theModuleNamespace; |
1507 | @@ -1198,15 +1208,6 @@ |
1508 | /***************************************************************************//** |
1509 | |
1510 | ********************************************************************************/ |
1511 | -void static_context::set_parent_as_root() |
1512 | -{ |
1513 | - theParent = &GENV_ROOT_STATIC_CONTEXT; |
1514 | -} |
1515 | - |
1516 | - |
1517 | -/***************************************************************************//** |
1518 | - |
1519 | -********************************************************************************/ |
1520 | expr* static_context::get_query_expr() const |
1521 | { |
1522 | return theQueryExpr; |
1523 | @@ -1891,7 +1892,7 @@ |
1524 | store::Item_t& validatedResult, |
1525 | StaticContextConsts::validation_mode_t validationMode) const |
1526 | { |
1527 | - zstring xsTns(XML_SCHEMA_NS); |
1528 | + zstring xsTns(static_context::W3C_XML_SCHEMA_NS); |
1529 | return validate(rootElement, validatedResult, xsTns, validationMode); |
1530 | } |
1531 | |
1532 | @@ -2456,7 +2457,7 @@ |
1533 | |
1534 | ********************************************************************************/ |
1535 | void static_context::bind_fn( |
1536 | - function_t& f, |
1537 | + const function_t& f, |
1538 | csize arity, |
1539 | const QueryLoc& loc) |
1540 | { |
1541 | @@ -2473,17 +2474,18 @@ |
1542 | theFunctionMap = new FunctionMap(HashMapItemPointerCmp(0, NULL), size, false); |
1543 | } |
1544 | |
1545 | - FunctionInfo fi(f); |
1546 | + FunctionInfo fi(f.getp()); |
1547 | |
1548 | if (!theFunctionMap->insert(qname, fi)) |
1549 | { |
1550 | // There is already a function F with the given qname in theFunctionMap. |
1551 | // First, check if F is the same as f, which implies that f is disabled. |
1552 | // In this case, re-enable f. Otherwise, we have to use theFunctionArityMap. |
1553 | - if (fi.theFunction == f) |
1554 | + if (fi.theFunction.getp() == f) |
1555 | { |
1556 | ZORBA_ASSERT(fi.theIsDisabled); |
1557 | fi.theIsDisabled = false; |
1558 | + theFunctionMap->update(qname, fi); |
1559 | return; |
1560 | } |
1561 | |
1562 | @@ -2505,7 +2507,7 @@ |
1563 | csize numFunctions = fv->size(); |
1564 | for (csize i = 0; i < numFunctions; ++i) |
1565 | { |
1566 | - if ((*fv)[i].theFunction == f) |
1567 | + if ((*fv)[i].theFunction.getp() == f) |
1568 | { |
1569 | ZORBA_ASSERT((*fv)[i].theIsDisabled); |
1570 | (*fv)[i].theIsDisabled = false; |
1571 | @@ -2671,7 +2673,7 @@ |
1572 | { |
1573 | if (sctx->theFunctionMap != NULL && sctx->theFunctionMap->get(qname2, fi)) |
1574 | { |
1575 | - function* f = fi.theFunction.getp(); |
1576 | + function* f = fi.theFunction; |
1577 | |
1578 | if (f->getArity() == arity || f->isVariadic()) |
1579 | { |
1580 | @@ -2694,7 +2696,7 @@ |
1581 | if ((*fv)[i].theIsDisabled && skipDisabled) |
1582 | return NULL; |
1583 | |
1584 | - return (*fv)[i].theFunction.getp(); |
1585 | + return (*fv)[i].theFunction; |
1586 | } |
1587 | } |
1588 | } |
1589 | @@ -2722,7 +2724,7 @@ |
1590 | |
1591 | if (theFunctionMap != NULL && theFunctionMap->get(qname2, fi)) |
1592 | { |
1593 | - function* f = fi.theFunction.getp(); |
1594 | + function* f = fi.theFunction; |
1595 | |
1596 | if (f->getArity() == arity || f->isVariadic()) |
1597 | { |
1598 | @@ -2744,7 +2746,7 @@ |
1599 | if ((*fv)[i].theIsDisabled && skipDisabled) |
1600 | return NULL; |
1601 | |
1602 | - return (*fv)[i].theFunction.getp(); |
1603 | + return (*fv)[i].theFunction; |
1604 | } |
1605 | } |
1606 | } |
1607 | @@ -2784,7 +2786,7 @@ |
1608 | |
1609 | for (; ite != end; ++ite) |
1610 | { |
1611 | - function* f = (*ite).second.theFunction.getp(); |
1612 | + function* f = (*ite).second.theFunction; |
1613 | |
1614 | if (!(*ite).second.theIsDisabled) |
1615 | { |
1616 | @@ -2842,10 +2844,10 @@ |
1617 | { |
1618 | std::vector<FunctionInfo>* fv = (*ite).second; |
1619 | |
1620 | - ulong numFunctions = (ulong)fv->size(); |
1621 | - for (ulong i = 0; i < numFunctions; ++i) |
1622 | + csize numFunctions = fv->size(); |
1623 | + for (csize i = 0; i < numFunctions; ++i) |
1624 | { |
1625 | - function* f = (*fv)[i].theFunction.getp(); |
1626 | + function* f = (*fv)[i].theFunction; |
1627 | |
1628 | if (!(*fv)[i].theIsDisabled) |
1629 | { |
1630 | @@ -2909,7 +2911,7 @@ |
1631 | if (theFunctionMap != NULL && theFunctionMap->get(qname2, fi)) |
1632 | { |
1633 | if (!fi.theIsDisabled) |
1634 | - functions.push_back(fi.theFunction.getp()); |
1635 | + functions.push_back(fi.theFunction); |
1636 | } |
1637 | |
1638 | std::vector<FunctionInfo>* fv = NULL; |
1639 | @@ -2920,7 +2922,7 @@ |
1640 | for (ulong i = 0; i < numFunctions; ++i) |
1641 | { |
1642 | if (!(*fv)[i].theIsDisabled) |
1643 | - functions.push_back((*fv)[i].theFunction.getp()); |
1644 | + functions.push_back((*fv)[i].theFunction); |
1645 | } |
1646 | } |
1647 | |
1648 | @@ -3217,11 +3219,8 @@ |
1649 | |
1650 | if (lookup_index(qname) != NULL) |
1651 | { |
1652 | - throw XQUERY_EXCEPTION( |
1653 | - zerr::ZDST0021_INDEX_ALREADY_DECLARED, |
1654 | - ERROR_PARAMS( qname->getStringValue() ), |
1655 | - ERROR_LOC( loc ) |
1656 | - ); |
1657 | + RAISE_ERROR(zerr::ZDST0021_INDEX_ALREADY_DECLARED, loc, |
1658 | + ERROR_PARAMS(qname->getStringValue())); |
1659 | } |
1660 | |
1661 | if (theIndexMap == NULL) |
1662 | @@ -4354,7 +4353,7 @@ |
1663 | FunctionMap::iterator end = module->theFunctionMap->end(); |
1664 | for (; ite != end; ++ite) |
1665 | { |
1666 | - function_t f = (*ite).second.theFunction; |
1667 | + function* f = (*ite).second.theFunction; |
1668 | if (!f->isPrivate()) |
1669 | bind_fn(f, f->getArity(), loc); |
1670 | } |
1671 | @@ -4378,7 +4377,7 @@ |
1672 | csize num = fv->size(); |
1673 | for (csize i = 0; i < num; ++i) |
1674 | { |
1675 | - function_t f = (*fv)[i].theFunction; |
1676 | + function* f = (*fv)[i].theFunction; |
1677 | bind_fn(f, f->getArity(), loc); |
1678 | } |
1679 | } |
1680 | |
1681 | === modified file 'src/context/static_context.h' |
1682 | --- src/context/static_context.h 2013-06-26 00:26:58 +0000 |
1683 | +++ src/context/static_context.h 2013-07-11 13:41:52 +0000 |
1684 | @@ -145,7 +145,7 @@ |
1685 | public: |
1686 | FunctionInfo(); |
1687 | |
1688 | - FunctionInfo(const function_t& f, bool disabled = false); |
1689 | + FunctionInfo(function* f, bool disabled = false); |
1690 | |
1691 | ~FunctionInfo(); |
1692 | }; |
1693 | @@ -287,7 +287,8 @@ |
1694 | |
1695 | theParent : |
1696 | ----------- |
1697 | - Pointer to the parent sctx object in the sctx hierarchy. |
1698 | + Pointer to the parent sctx object in the sctx hierarchy. Manual ref counting |
1699 | + is done via this pointer on the parent, unless the parent is the root sctx. |
1700 | |
1701 | theTraceStream : |
1702 | ---------------- |
1703 | @@ -442,7 +443,7 @@ |
1704 | context/featueres.h. |
1705 | ********************************************************************************/ |
1706 | |
1707 | -class static_context : public SimpleRCObject |
1708 | +class static_context : public SyncedRCObject |
1709 | { |
1710 | ITEM_PTR_HASH_MAP(StaticallyKnownCollection_t, CollectionMap); |
1711 | |
1712 | @@ -499,6 +500,8 @@ |
1713 | |
1714 | static const char* W3C_XML_NS; // http://www.w3.org/XML/1998/namespace |
1715 | |
1716 | + static const char* W3C_XML_SCHEMA_NS; // // http://www.w3.org/2001/XMLSchema |
1717 | + |
1718 | static const char* W3C_FN_NS; // http://www.w3.org/2005/xpath-functions |
1719 | |
1720 | static const char* W3C_ERR_NS; // http://www.w3.org/2005/xqt-errors |
1721 | @@ -569,11 +572,14 @@ |
1722 | static const char* ZORBA_OPTION_WARN_NS; |
1723 | static const char* ZORBA_OPTION_FEATURE_NS; |
1724 | static const char* ZORBA_OPTION_OPTIM_NS; |
1725 | + |
1726 | static const char* XQUERY_NS; // http://www.w3.org/2012/xquery |
1727 | static const char* XQUERY_OPTION_NS; // http://www.w3.org/2011/xquery-options |
1728 | static const char* ZORBA_VERSIONING_NS; |
1729 | |
1730 | protected: |
1731 | + SYNC_CODE(mutable RCLock theRCLock;) |
1732 | + |
1733 | static_context * theParent; |
1734 | |
1735 | std::ostream * theTraceStream; |
1736 | @@ -696,6 +702,8 @@ |
1737 | |
1738 | ~static_context(); |
1739 | |
1740 | + SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; }) |
1741 | + |
1742 | static_context* get_parent() const { return theParent; } |
1743 | |
1744 | static_context* create_child_context(); |
1745 | @@ -901,7 +909,7 @@ |
1746 | // |
1747 | // Functions |
1748 | // |
1749 | - void bind_fn(function_t& f, csize arity, const QueryLoc& loc); |
1750 | + void bind_fn(const function_t& f, csize arity, const QueryLoc& loc); |
1751 | |
1752 | void unbind_fn(const store::Item* qname, csize arity); |
1753 | |
1754 | @@ -929,8 +937,8 @@ |
1755 | std::vector<function*>& functions) const; |
1756 | |
1757 | void bind_external_module( |
1758 | - ExternalModule* aModule, |
1759 | - bool aDynamicallyLoaded = false); |
1760 | + ExternalModule* module, |
1761 | + bool dynamicallyLoaded = false); |
1762 | |
1763 | ExternalFunction* lookup_external_function( |
1764 | const zstring& prefix, |
1765 | @@ -1152,8 +1160,6 @@ |
1766 | //serialization helpers |
1767 | bool check_parent_is_root(); |
1768 | |
1769 | - void set_parent_as_root(); |
1770 | - |
1771 | private: |
1772 | |
1773 | void apply_uri_mappers( |
1774 | |
1775 | === modified file 'src/functions/external_function.cpp' |
1776 | --- src/functions/external_function.cpp 2013-02-07 17:24:36 +0000 |
1777 | +++ src/functions/external_function.cpp 2013-07-11 13:41:52 +0000 |
1778 | @@ -43,13 +43,12 @@ |
1779 | unsigned short scriptingType, |
1780 | ExternalFunction* impl) |
1781 | : |
1782 | - function(sig, FunctionConsts::FN_UNKNOWN), |
1783 | + function(sig, FunctionConsts::FN_UNKNOWN, false), |
1784 | theLoc(loc), |
1785 | theNamespace(ns), |
1786 | theScriptingKind(scriptingType), |
1787 | theImpl(impl) |
1788 | { |
1789 | - resetFlag(FunctionConsts::isBuiltin); |
1790 | theModuleSctx = modSctx; |
1791 | } |
1792 | |
1793 | |
1794 | === modified file 'src/functions/function.cpp' |
1795 | --- src/functions/function.cpp 2013-04-15 13:52:08 +0000 |
1796 | +++ src/functions/function.cpp 2013-07-11 13:41:52 +0000 |
1797 | @@ -34,39 +34,42 @@ |
1798 | namespace zorba { |
1799 | |
1800 | |
1801 | -#ifdef PRE_SERIALIZE_BUILTIN_FUNCTIONS |
1802 | -SERIALIZE_INTERNAL_METHOD(function) |
1803 | -#else |
1804 | SERIALIZABLE_CLASS_VERSIONS(function); |
1805 | -#endif |
1806 | |
1807 | |
1808 | /******************************************************************************* |
1809 | |
1810 | ********************************************************************************/ |
1811 | -function::function(const signature& sig, FunctionConsts::FunctionKind kind) |
1812 | +function::function( |
1813 | + const signature& sig, |
1814 | + FunctionConsts::FunctionKind kind, |
1815 | + bool isBuiltin) |
1816 | : |
1817 | theSignature(sig), |
1818 | theKind(kind), |
1819 | theFlags(0), |
1820 | + theAnnotationList(NULL), |
1821 | theModuleSctx(NULL), |
1822 | theXQueryVersion(StaticContextConsts::xquery_version_1_0) |
1823 | { |
1824 | - setFlag(FunctionConsts::isBuiltin); |
1825 | + if (isBuiltin) |
1826 | + { |
1827 | + setFlag(FunctionConsts::isBuiltin); |
1828 | +#ifndef NDEBUG |
1829 | + theRefCount = 1000000; |
1830 | +#endif |
1831 | + } |
1832 | + |
1833 | setFlag(FunctionConsts::isDeterministic); |
1834 | - |
1835 | -#ifdef PRE_SERIALIZE_BUILTIN_FUNCTIONS |
1836 | - zorba::serialization::Archiver& ar = |
1837 | - *::zorba::serialization::ClassSerializer::getInstance()-> |
1838 | - getArchiverForHardcodedObjects(); |
1839 | - |
1840 | - if (ar.is_loading_hardcoded_objects()) |
1841 | - { |
1842 | - // register this hardcoded object to help plan serialization |
1843 | - function* this_ptr = this; |
1844 | - ar & this_ptr; |
1845 | - } |
1846 | -#endif |
1847 | +} |
1848 | + |
1849 | + |
1850 | +/******************************************************************************* |
1851 | + |
1852 | +********************************************************************************/ |
1853 | +function::~function() |
1854 | +{ |
1855 | + delete theAnnotationList; |
1856 | } |
1857 | |
1858 | |
1859 | @@ -75,11 +78,6 @@ |
1860 | ********************************************************************************/ |
1861 | void function::serialize(::zorba::serialization::Archiver& ar) |
1862 | { |
1863 | -#ifdef PRE_SERIALIZE_BUILTIN_FUNCTIONS |
1864 | - if (ar.is_loading_hardcoded_objects()) |
1865 | - return; |
1866 | -#endif |
1867 | - |
1868 | ar & theSignature; |
1869 | SERIALIZE_ENUM(FunctionConsts::FunctionKind, theKind); |
1870 | ar & theFlags; |
1871 | @@ -87,13 +85,19 @@ |
1872 | ar & theModuleSctx; |
1873 | SERIALIZE_ENUM(StaticContextConsts::xquery_version_t, theXQueryVersion); |
1874 | |
1875 | - // If we don't pre-serialize builtin function, it is possible that a builtin |
1876 | - // functions needs to be serialized. This happens for builtin functions that |
1877 | - // are disabled, and as a result, have been registered in a non-root static |
1878 | - // context. |
1879 | -#ifdef PRE_SERIALIZE_BUILTIN_FUNCTIONS |
1880 | - ZORBA_ASSERT(!isBuiltin()); |
1881 | -#endif |
1882 | + // It is possible that a builtin function needs to be serialized. This happens |
1883 | + // for builtin functions that are disabled, and as a result, have been |
1884 | + // registered in a non-root static context. |
1885 | +} |
1886 | + |
1887 | + |
1888 | +/******************************************************************************* |
1889 | + |
1890 | +********************************************************************************/ |
1891 | +void function::free() |
1892 | +{ |
1893 | + if (!isBuiltin()) |
1894 | + delete this; |
1895 | } |
1896 | |
1897 | |
1898 | |
1899 | === modified file 'src/functions/function.h' |
1900 | --- src/functions/function.h 2013-04-15 13:52:08 +0000 |
1901 | +++ src/functions/function.h 2013-07-11 13:41:52 +0000 |
1902 | @@ -54,25 +54,23 @@ |
1903 | signature theSignature; |
1904 | FunctionConsts::FunctionKind theKind; |
1905 | uint32_t theFlags; |
1906 | - AnnotationList_t theAnnotationList; |
1907 | + AnnotationList * theAnnotationList; |
1908 | static_context * theModuleSctx; |
1909 | |
1910 | StaticContextConsts::xquery_version_t theXQueryVersion; |
1911 | |
1912 | |
1913 | public: |
1914 | -#ifdef PRE_SERIALIZE_BUILTIN_FUNCTIONS |
1915 | - SERIALIZABLE_ABSTRACT_CLASS(function); |
1916 | -#else |
1917 | SERIALIZABLE_CLASS(function); |
1918 | -#endif |
1919 | SERIALIZABLE_CLASS_CONSTRUCTOR3(function, SimpleRCObject, theSignature); |
1920 | void serialize(::zorba::serialization::Archiver& ar); |
1921 | |
1922 | public: |
1923 | - function(const signature& sig, FunctionConsts::FunctionKind kind); |
1924 | - |
1925 | - virtual ~function() {} |
1926 | + function(const signature& sig, FunctionConsts::FunctionKind k, bool isBuiltin = true); |
1927 | + |
1928 | + virtual ~function(); |
1929 | + |
1930 | + void free(); |
1931 | |
1932 | StaticContextConsts::xquery_version_t getXQueryVersion() const |
1933 | { |
1934 | @@ -164,7 +162,7 @@ |
1935 | |
1936 | void setAnnotations(AnnotationList* annotations); |
1937 | |
1938 | - const AnnotationList* getAnnotationList() const { return theAnnotationList.getp(); } |
1939 | + const AnnotationList* getAnnotationList() const { return theAnnotationList; } |
1940 | |
1941 | bool validate_args(std::vector<PlanIter_t>& argv) const; |
1942 | |
1943 | |
1944 | === modified file 'src/functions/function_impl.h' |
1945 | --- src/functions/function_impl.h 2013-02-07 17:24:36 +0000 |
1946 | +++ src/functions/function_impl.h 2013-07-11 13:41:52 +0000 |
1947 | @@ -44,23 +44,23 @@ |
1948 | #define DECL_WITH_KIND(sctx, type, sig, kind) \ |
1949 | do \ |
1950 | { \ |
1951 | - function_t type##_ptr(new type(signature sig, kind)); \ |
1952 | + function* type##_ptr = new type(signature sig, kind); \ |
1953 | const store::Item* fname = type##_ptr->getName(); \ |
1954 | ulong cnt = type##_ptr->getSignature().paramCount(); \ |
1955 | DEBUG_FN_DECL(fname, cnt); \ |
1956 | sctx->bind_fn(type##_ptr, cnt, QueryLoc::null); \ |
1957 | - BuiltinFunctionLibrary::theFunctions[type##_ptr->getKind()] = type##_ptr.getp(); \ |
1958 | + GENV_FUNC_LIB->addFunction(type##_ptr->getKind(), type##_ptr); \ |
1959 | } while(0) |
1960 | |
1961 | #define DECL(sctx, type, sig) \ |
1962 | do \ |
1963 | { \ |
1964 | - function_t type##_ptr(new type(signature sig)); \ |
1965 | + function* type##_ptr = new type(signature sig); \ |
1966 | const store::Item* fname = type##_ptr->getName(); \ |
1967 | ulong cnt = type##_ptr->getSignature().paramCount(); \ |
1968 | DEBUG_FN_DECL(fname, cnt); \ |
1969 | sctx->bind_fn(type##_ptr, cnt, QueryLoc::null); \ |
1970 | - BuiltinFunctionLibrary::theFunctions[type##_ptr->getKind()] = type##_ptr.getp(); \ |
1971 | + GENV_FUNC_LIB->addFunction(type##_ptr->getKind(), type##_ptr); \ |
1972 | } while(0) |
1973 | |
1974 | |
1975 | |
1976 | === modified file 'src/functions/library.cpp' |
1977 | --- src/functions/library.cpp 2013-06-27 00:05:25 +0000 |
1978 | +++ src/functions/library.cpp 2013-07-11 13:41:52 +0000 |
1979 | @@ -91,8 +91,6 @@ |
1980 | namespace zorba |
1981 | { |
1982 | |
1983 | -function** BuiltinFunctionLibrary::theFunctions = NULL; |
1984 | - |
1985 | // clear static initializer state |
1986 | |
1987 | // dummy function to tell the windows linker to keep the library.obj |
1988 | @@ -103,16 +101,16 @@ |
1989 | } |
1990 | |
1991 | |
1992 | -void BuiltinFunctionLibrary::create(static_context* sctx) |
1993 | +BuiltinFunctionLibrary::BuiltinFunctionLibrary() |
1994 | { |
1995 | -#ifdef PRE_SERIALIZE_BUILTIN_FUNCTIONS |
1996 | - zorba::serialization::Archiver& ar = *::zorba::serialization::ClassSerializer::getInstance()->getArchiverForHardcodedObjects(); |
1997 | - |
1998 | - ar.set_loading_hardcoded_objects(true); |
1999 | -#endif |
2000 | - |
2001 | theFunctions = new function*[FunctionConsts::FN_MAX_FUNC]; |
2002 | |
2003 | + memset(&theFunctions[0], 0, FunctionConsts::FN_MAX_FUNC * sizeof(function*)); |
2004 | +} |
2005 | + |
2006 | + |
2007 | +void BuiltinFunctionLibrary::populate(static_context* sctx) |
2008 | +{ |
2009 | populate_context_accessors(sctx); |
2010 | populate_context_any_uri(sctx); |
2011 | populate_context_accessors_impl(sctx); |
2012 | @@ -180,8 +178,13 @@ |
2013 | } |
2014 | |
2015 | |
2016 | -void BuiltinFunctionLibrary::destroy() |
2017 | +BuiltinFunctionLibrary::~BuiltinFunctionLibrary() |
2018 | { |
2019 | + for (csize i = 0; i < FunctionConsts::FN_MAX_FUNC; ++i) |
2020 | + { |
2021 | + delete theFunctions[i]; |
2022 | + } |
2023 | + |
2024 | delete [] theFunctions; |
2025 | } |
2026 | |
2027 | |
2028 | === modified file 'src/functions/library.h' |
2029 | --- src/functions/library.h 2013-02-07 17:24:36 +0000 |
2030 | +++ src/functions/library.h 2013-07-11 13:41:52 +0000 |
2031 | @@ -32,24 +32,30 @@ |
2032 | friend class GlobalEnvironment; |
2033 | |
2034 | public: |
2035 | - static function ** theFunctions; |
2036 | + function ** theFunctions; |
2037 | |
2038 | public: |
2039 | - static function* getFunction(FunctionConsts::FunctionKind kind) |
2040 | + BuiltinFunctionLibrary(); |
2041 | + |
2042 | + ~BuiltinFunctionLibrary(); |
2043 | + |
2044 | + void populate(static_context* sctx); |
2045 | + |
2046 | + function* getFunction(FunctionConsts::FunctionKind kind) |
2047 | { |
2048 | return theFunctions[kind]; |
2049 | } |
2050 | |
2051 | -private: |
2052 | - static void create(static_context* sctx); |
2053 | - |
2054 | - static void destroy(); |
2055 | + void addFunction(FunctionConsts::FunctionKind kind, function* f) |
2056 | + { |
2057 | + theFunctions[kind] = f; |
2058 | + } |
2059 | }; |
2060 | |
2061 | |
2062 | |
2063 | #define BUILTIN_FUNC(func_code) \ |
2064 | -BuiltinFunctionLibrary::getFunction(FunctionConsts::func_code) |
2065 | +GENV_FUNC_LIB->getFunction(FunctionConsts::func_code) |
2066 | |
2067 | |
2068 | } |
2069 | |
2070 | === modified file 'src/functions/udf.cpp' |
2071 | --- src/functions/udf.cpp 2013-06-15 21:18:01 +0000 |
2072 | +++ src/functions/udf.cpp 2013-07-11 13:41:52 +0000 |
2073 | @@ -62,7 +62,7 @@ |
2074 | unsigned short scriptingKind, |
2075 | CompilerCB* ccb) |
2076 | : |
2077 | - function(sig, FunctionConsts::FN_UNKNOWN), |
2078 | +function(sig, FunctionConsts::FN_UNKNOWN, false), |
2079 | theCCB(ccb), |
2080 | theLoc(loc), |
2081 | theScriptingKind(scriptingKind), |
2082 | @@ -76,8 +76,6 @@ |
2083 | theCacheComputed(false) |
2084 | { |
2085 | setFlag(FunctionConsts::isUDF); |
2086 | - resetFlag(FunctionConsts::isBuiltin); |
2087 | - setDeterministic(true); |
2088 | setPrivate(false); |
2089 | } |
2090 | |
2091 | |
2092 | === modified file 'src/runtime/full_text/ft_util.cpp' |
2093 | --- src/runtime/full_text/ft_util.cpp 2013-06-11 23:38:49 +0000 |
2094 | +++ src/runtime/full_text/ft_util.cpp 2013-07-11 13:41:52 +0000 |
2095 | @@ -19,13 +19,16 @@ |
2096 | #include <stdexcept> |
2097 | |
2098 | #include "diagnostics/xquery_diagnostics.h" |
2099 | + |
2100 | #include "util/locale.h" |
2101 | -#include "zorbamisc/ns_consts.h" |
2102 | + |
2103 | #include "zorbatypes/integer.h" |
2104 | #include "zorbatypes/numconversions.h" |
2105 | |
2106 | #include "ft_util.h" |
2107 | |
2108 | +#include "context/static_context.h" |
2109 | + |
2110 | using namespace zorba::locale; |
2111 | |
2112 | namespace zorba { |
2113 | @@ -41,7 +44,7 @@ |
2114 | store::Item const *const qname = attr->getNodeName(); |
2115 | if ( qname && |
2116 | qname->getLocalName() == "lang" && |
2117 | - qname->getNamespace() == XML_NS ) { |
2118 | + qname->getNamespace() == static_context::W3C_XML_NS ) { |
2119 | *lang = locale::find_lang( attr->getStringValue() ); |
2120 | found_lang = true; |
2121 | break; |
2122 | |
2123 | === modified file 'src/runtime/hof/fn_hof_functions_impl.cpp' |
2124 | --- src/runtime/hof/fn_hof_functions_impl.cpp 2013-06-04 21:47:40 +0000 |
2125 | +++ src/runtime/hof/fn_hof_functions_impl.cpp 2013-07-11 13:41:52 +0000 |
2126 | @@ -163,7 +163,7 @@ |
2127 | Translator::translate_literal_function(qname, arity, ccb, impSctx, loc); |
2128 | |
2129 | FunctionItemInfo_t fiInfo = |
2130 | - static_cast<function_item_expr*>(fiExpr)->get_dynamic_fn_info(); |
2131 | + static_cast<function_item_expr*>(fiExpr)->get_fi_info(); |
2132 | |
2133 | fiInfo->theCCB = ccb; |
2134 | |
2135 | |
2136 | === modified file 'src/runtime/hof/function_item.cpp' |
2137 | --- src/runtime/hof/function_item.cpp 2013-04-24 01:35:58 +0000 |
2138 | +++ src/runtime/hof/function_item.cpp 2013-07-11 13:41:52 +0000 |
2139 | @@ -141,7 +141,7 @@ |
2140 | if (ar.is_serializing_out()) |
2141 | { |
2142 | uint32_t planStateSize; |
2143 | - (void)static_cast<user_function*>(theFunction.getp())->getPlan(planStateSize, 1); |
2144 | + (void)static_cast<user_function*>(theFunction)->getPlan(planStateSize, 1); |
2145 | } |
2146 | } |
2147 | |
2148 | @@ -158,15 +158,6 @@ |
2149 | } |
2150 | |
2151 | |
2152 | -/******************************************************************************* |
2153 | - |
2154 | -********************************************************************************/ |
2155 | -FunctionItem::FunctionItem(::zorba::serialization::Archiver& ar) |
2156 | - : |
2157 | - store::Item(store::Item::FUNCTION) |
2158 | -{ |
2159 | -} |
2160 | - |
2161 | //////////////////////////////////////////////////////////////////////////////// |
2162 | // // |
2163 | // FunctionItem // |
2164 | @@ -202,6 +193,16 @@ |
2165 | /******************************************************************************* |
2166 | |
2167 | ********************************************************************************/ |
2168 | +FunctionItem::FunctionItem(::zorba::serialization::Archiver& ar) |
2169 | + : |
2170 | + store::Item(store::Item::FUNCTION) |
2171 | +{ |
2172 | +} |
2173 | + |
2174 | + |
2175 | +/******************************************************************************* |
2176 | + |
2177 | +********************************************************************************/ |
2178 | FunctionItem::~FunctionItem() |
2179 | { |
2180 | #if 0 |
2181 | |
2182 | === modified file 'src/runtime/hof/function_item.h' |
2183 | --- src/runtime/hof/function_item.h 2013-04-24 01:35:58 +0000 |
2184 | +++ src/runtime/hof/function_item.h 2013-07-11 13:41:52 +0000 |
2185 | @@ -112,7 +112,7 @@ |
2186 | |
2187 | static_context * theClosureSctx; |
2188 | |
2189 | - function_t theFunction; |
2190 | + function * theFunction; |
2191 | |
2192 | store::Item_t theQName; |
2193 | |
2194 | |
2195 | === modified file 'src/runtime/nodes/nodes_impl.cpp' |
2196 | --- src/runtime/nodes/nodes_impl.cpp 2013-05-06 22:57:08 +0000 |
2197 | +++ src/runtime/nodes/nodes_impl.cpp 2013-07-11 13:41:52 +0000 |
2198 | @@ -236,7 +236,7 @@ |
2199 | store::Item* lAttrName = aAttr->getNodeName(); |
2200 | |
2201 | return (ZSTREQ(lAttrName->getLocalName(), "lang") && |
2202 | - ZSTREQ(lAttrName->getNamespace(), XML_NS)); |
2203 | + lAttrName->getNamespace() == static_context::W3C_XML_NS); |
2204 | } |
2205 | |
2206 | |
2207 | |
2208 | === modified file 'src/runtime/strings/strings_impl.cpp' |
2209 | --- src/runtime/strings/strings_impl.cpp 2013-06-10 22:49:36 +0000 |
2210 | +++ src/runtime/strings/strings_impl.cpp 2013-07-11 13:41:52 +0000 |
2211 | @@ -1839,7 +1839,7 @@ |
2212 | store::NsBindings ns_binding; |
2213 | zstring baseURI; |
2214 | GENV_ITEMFACTORY->createQName(untyped_type_name, |
2215 | - XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped"); |
2216 | + static_context::W3C_XML_SCHEMA_NS, "", "untyped"); |
2217 | GENV_ITEMFACTORY->createQName(non_match_element_name, |
2218 | static_context::W3C_FN_NS, "fn", "non-match"); |
2219 | GENV_ITEMFACTORY->createElementNode(non_match_elem, parent, non_match_element_name, untyped_type_name, false, false, ns_binding, baseURI); |
2220 | @@ -1968,7 +1968,7 @@ |
2221 | store::NsBindings ns_binding; |
2222 | zstring baseURI; |
2223 | GENV_ITEMFACTORY->createQName(untyped_type_name, |
2224 | - XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped"); |
2225 | + static_context::W3C_XML_SCHEMA_NS, "", "untyped"); |
2226 | GENV_ITEMFACTORY->createQName(match_element_name, |
2227 | static_context::W3C_FN_NS, "fn", "match"); |
2228 | store::Item_t match_elem; |
2229 | @@ -2125,7 +2125,7 @@ |
2230 | store::NsBindings ns_binding; |
2231 | zstring baseURI; |
2232 | GENV_ITEMFACTORY->createQName(untyped_type_name, |
2233 | - XML_SCHEMA_NS, XML_SCHEMA_PREFIX, "untyped"); |
2234 | + static_context::W3C_XML_SCHEMA_NS, "", "untyped"); |
2235 | GENV_ITEMFACTORY->createQName(result_element_name, |
2236 | static_context::W3C_FN_NS, "fn", "analyze-string-result"); |
2237 | GENV_ITEMFACTORY->createElementNode(result, NULL, result_element_name, untyped_type_name, false, false, ns_binding, baseURI); |
2238 | |
2239 | === modified file 'src/store/api/annotation.h' |
2240 | --- src/store/api/annotation.h 2013-02-07 17:24:36 +0000 |
2241 | +++ src/store/api/annotation.h 2013-07-11 13:41:52 +0000 |
2242 | @@ -24,20 +24,13 @@ |
2243 | namespace zorba { namespace store { |
2244 | |
2245 | |
2246 | -class Annotation : public RCObject |
2247 | +class Annotation : public SyncedRCObject |
2248 | { |
2249 | -protected: |
2250 | - SYNC_CODE(mutable RCLock theRCLock;) |
2251 | - |
2252 | public: |
2253 | Item_t theName; |
2254 | std::vector<Item_t> theLiterals; |
2255 | |
2256 | public: |
2257 | - SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; }) |
2258 | - |
2259 | - long* getSharedRefCounter() const { return NULL; } |
2260 | - |
2261 | virtual ~Annotation() {} |
2262 | }; |
2263 | |
2264 | |
2265 | === modified file 'src/store/api/collection.h' |
2266 | --- src/store/api/collection.h 2013-04-29 14:39:04 +0000 |
2267 | +++ src/store/api/collection.h 2013-07-11 13:41:52 +0000 |
2268 | @@ -23,16 +23,8 @@ |
2269 | namespace zorba { namespace store { |
2270 | |
2271 | |
2272 | -class Collection : public RCObject |
2273 | +class Collection : public SyncedRCObject |
2274 | { |
2275 | -protected: |
2276 | - SYNC_CODE(mutable RCLock theRCLock;) |
2277 | - |
2278 | -public: |
2279 | - SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; }) |
2280 | - |
2281 | - long* getSharedRefCounter() const { return NULL; } |
2282 | - |
2283 | public: |
2284 | virtual ~Collection() {} |
2285 | |
2286 | |
2287 | === modified file 'src/store/api/ic.h' |
2288 | --- src/store/api/ic.h 2013-02-07 17:24:36 +0000 |
2289 | +++ src/store/api/ic.h 2013-07-11 13:41:52 +0000 |
2290 | @@ -31,7 +31,7 @@ |
2291 | * Integrity Constraints class. Contains the name of the IC and the |
2292 | * collection name. |
2293 | */ |
2294 | -class IC : public RCObject |
2295 | +class IC : public SyncedRCObject |
2296 | { |
2297 | public: |
2298 | enum ICKind |
2299 | @@ -40,14 +40,6 @@ |
2300 | ic_foreignkey |
2301 | }; |
2302 | |
2303 | -protected: |
2304 | - SYNC_CODE(mutable RCLock theRCLock;) |
2305 | - |
2306 | -public: |
2307 | - SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; }) |
2308 | - |
2309 | - long* getSharedRefCounter() const { return NULL; } |
2310 | - |
2311 | public: |
2312 | virtual ~IC() {} |
2313 | |
2314 | |
2315 | === modified file 'src/store/api/index.h' |
2316 | --- src/store/api/index.h 2013-02-07 17:24:36 +0000 |
2317 | +++ src/store/api/index.h 2013-07-11 13:41:52 +0000 |
2318 | @@ -369,11 +369,8 @@ |
2319 | IndexCondition below). |
2320 | |
2321 | *******************************************************************************/ |
2322 | -class Index : public RCObject |
2323 | +class Index : public SyncedRCObject |
2324 | { |
2325 | -protected: |
2326 | - SYNC_CODE(mutable RCLock theRCLock;) |
2327 | - |
2328 | public: |
2329 | class KeyIterator : virtual public SimpleRCObject |
2330 | { |
2331 | @@ -391,11 +388,6 @@ |
2332 | |
2333 | |
2334 | public: |
2335 | - SYNC_CODE(RCLock* getRCLock() const { return &theRCLock; }) |
2336 | - |
2337 | - long* getSharedRefCounter() const { return NULL; } |
2338 | - |
2339 | -public: |
2340 | |
2341 | virtual ~Index() {} |
2342 | |
2343 | |
2344 | === modified file 'src/store/api/item.h' |
2345 | --- src/store/api/item.h 2013-06-29 08:38:53 +0000 |
2346 | +++ src/store/api/item.h 2013-07-11 13:41:52 +0000 |
2347 | @@ -101,7 +101,7 @@ |
2348 | |
2349 | virtual ~Item() {} |
2350 | |
2351 | - virtual void free() { delete this; } |
2352 | + virtual void free(); |
2353 | |
2354 | long getRefCount() const { return theRefCount; } |
2355 | |
2356 | |
2357 | === modified file 'src/store/naive/atomic_items.cpp' |
2358 | --- src/store/naive/atomic_items.cpp 2013-06-21 01:06:29 +0000 |
2359 | +++ src/store/naive/atomic_items.cpp 2013-07-11 13:41:52 +0000 |
2360 | @@ -686,8 +686,8 @@ |
2361 | { |
2362 | assert(!isValid()); |
2363 | |
2364 | - store::Item_t lPoolQName = |
2365 | - GET_STORE().getQNamePool().insert(aNamespace, zstring(), aLocalName); |
2366 | + store::Item_t lPoolQName; |
2367 | + GET_STORE().getQNamePool().insert(lPoolQName, aNamespace, zstring(), aLocalName); |
2368 | |
2369 | QNameItem* lNormalized = static_cast<QNameItem*>(lPoolQName.getp()); |
2370 | assert(lNormalized->isNormalized()); |
2371 | @@ -705,12 +705,17 @@ |
2372 | if (theIsInPool) |
2373 | { |
2374 | thePool.remove(this); |
2375 | + |
2376 | + SYNC_CODE(getRCLock()->release()); |
2377 | + |
2378 | return; |
2379 | } |
2380 | |
2381 | assert(!isNormalized()); |
2382 | |
2383 | invalidate(false, NULL); |
2384 | + SYNC_CODE(getRCLock()->release()); |
2385 | + |
2386 | delete this; |
2387 | } |
2388 | |
2389 | |
2390 | === modified file 'src/store/naive/atomic_items.h' |
2391 | --- src/store/naive/atomic_items.h 2013-05-24 22:52:47 +0000 |
2392 | +++ src/store/naive/atomic_items.h 2013-07-11 13:41:52 +0000 |
2393 | @@ -424,6 +424,12 @@ |
2394 | |
2395 | const QNameItem* getNormalized() const { return theNormalizedQName; } |
2396 | |
2397 | + const zstring& getLocalName2() const { return theLocal; } |
2398 | + |
2399 | + const zstring& getNamespace2() const { return theNamespace; } |
2400 | + |
2401 | + const zstring& getPrefix2() const { return thePrefix; } |
2402 | + |
2403 | bool isBaseUri() const; |
2404 | |
2405 | bool isIdQName() const; |
2406 | |
2407 | === modified file 'src/store/naive/item.cpp' |
2408 | --- src/store/naive/item.cpp 2013-06-15 02:57:08 +0000 |
2409 | +++ src/store/naive/item.cpp 2013-07-11 13:41:52 +0000 |
2410 | @@ -40,6 +40,12 @@ |
2411 | { |
2412 | |
2413 | |
2414 | +void Item::free() |
2415 | +{ |
2416 | + delete this; |
2417 | +} |
2418 | + |
2419 | + |
2420 | void Item::addReference() const |
2421 | { |
2422 | #if defined WIN32 && !defined CYGWIN && !defined ZORBA_FOR_ONE_THREAD_ONLY |
2423 | @@ -135,6 +141,8 @@ |
2424 | { |
2425 | SYNC_CODE(static_cast<const simplestore::XmlNode*>(this)->getRCLock()->acquire()); |
2426 | |
2427 | + assert(theRefCount > 0); |
2428 | + |
2429 | --theRefCount; |
2430 | if (--(*theUnion.treeRCPtr) == 0) |
2431 | { |
2432 | @@ -150,6 +158,7 @@ |
2433 | case ARRAY: |
2434 | { |
2435 | SYNC_CODE(static_cast<const simplestore::json::JSONItem*>(this)->getRCLock()->acquire()); |
2436 | + assert(theRefCount > 0); |
2437 | |
2438 | if (--theRefCount == 0) |
2439 | { |
2440 | @@ -166,6 +175,8 @@ |
2441 | { |
2442 | SYNC_CODE(static_cast<const simplestore::AtomicItem*>(this)->getRCLock()->acquire()); |
2443 | |
2444 | + assert(theRefCount > 0); |
2445 | + |
2446 | if (--theRefCount == 0) |
2447 | { |
2448 | SYNC_CODE(static_cast<const simplestore::AtomicItem*>(this)->getRCLock()->release()); |
2449 | |
2450 | === modified file 'src/store/naive/loader_dtd.cpp' |
2451 | --- src/store/naive/loader_dtd.cpp 2013-04-16 21:12:12 +0000 |
2452 | +++ src/store/naive/loader_dtd.cpp 2013-07-11 13:41:52 +0000 |
2453 | @@ -1212,9 +1212,11 @@ |
2454 | csize numBindings = static_cast<csize>(numNamespaces); |
2455 | |
2456 | // Construct node name |
2457 | - store::Item_t nodeName = qnpool.insert(reinterpret_cast<const char*>(uri), |
2458 | - reinterpret_cast<const char*>(prefix), |
2459 | - reinterpret_cast<const char*>(lname)); |
2460 | + store::Item_t nodeName; |
2461 | + qnpool.insert(nodeName, |
2462 | + reinterpret_cast<const char*>(uri), |
2463 | + reinterpret_cast<const char*>(prefix), |
2464 | + reinterpret_cast<const char*>(lname)); |
2465 | |
2466 | // Create the element node and push it to the node stack |
2467 | ElementNode* elemNode = nfactory.createElementNode(nodeName, |
2468 | @@ -1335,9 +1337,11 @@ |
2469 | //std::cout << " att: " << attr->name << std::endl; std::cout.flush(); |
2470 | |
2471 | const char* lname = reinterpret_cast<const char*>(attr->name); |
2472 | - const char* prefix = reinterpret_cast<const char*>( attr->ns != NULL ? attr->ns->prefix : NULL); |
2473 | - const char* uri = reinterpret_cast<const char*>( attr->ns != NULL ? attr->ns->href : NULL); |
2474 | - store::Item_t qname = qnpool.insert(uri, prefix, lname); |
2475 | + const char* prefix = reinterpret_cast<const char*>(attr->ns != NULL ? attr->ns->prefix : NULL); |
2476 | + const char* uri = reinterpret_cast<const char*>(attr->ns != NULL ? attr->ns->href : NULL); |
2477 | + store::Item_t qname; |
2478 | + qnpool.insert(qname, uri, prefix, lname); |
2479 | + |
2480 | AttributeNode* attrNode = nfactory.createAttributeNode(qname); |
2481 | |
2482 | xmlChar* val = xmlGetProp(node, attr->name); |
2483 | |
2484 | === modified file 'src/store/naive/loader_fast.cpp' |
2485 | --- src/store/naive/loader_fast.cpp 2013-06-19 09:54:46 +0000 |
2486 | +++ src/store/naive/loader_fast.cpp 2013-07-11 13:41:52 +0000 |
2487 | @@ -676,10 +676,12 @@ |
2488 | csize numBindings = static_cast<csize>(numNamespaces); |
2489 | |
2490 | // Construct node name |
2491 | - store::Item_t nodeName = qnpool.insert(reinterpret_cast<const char*>(uri), |
2492 | - reinterpret_cast<const char*>(prefix), |
2493 | - reinterpret_cast<const char*>(lname)); |
2494 | - |
2495 | + store::Item_t nodeName; |
2496 | + qnpool.insert(nodeName, |
2497 | + reinterpret_cast<const char*>(uri), |
2498 | + reinterpret_cast<const char*>(prefix), |
2499 | + reinterpret_cast<const char*>(lname)); |
2500 | + |
2501 | // Create the element node and push it to the node stack |
2502 | ElementNode* elemNode = nfactory.createElementNode(nodeName, |
2503 | numBindings, |
2504 | @@ -803,7 +805,8 @@ |
2505 | const char* valueBegin = reinterpret_cast<const char*>(attributes[index+3]); |
2506 | const char* valueEnd = reinterpret_cast<const char*>(attributes[index+4]); |
2507 | |
2508 | - store::Item_t qname = qnpool.insert(uri, prefix, lname); |
2509 | + store::Item_t qname; |
2510 | + qnpool.insert(qname, uri, prefix, lname); |
2511 | |
2512 | zstring value(valueBegin, valueEnd); |
2513 | store::Item_t typedValue; |
2514 | |
2515 | === modified file 'src/store/naive/node_items.cpp' |
2516 | --- src/store/naive/node_items.cpp 2013-06-29 08:38:53 +0000 |
2517 | +++ src/store/naive/node_items.cpp 2013-07-11 13:41:52 +0000 |
2518 | @@ -3645,7 +3645,9 @@ |
2519 | |
2520 | const Store& store = GET_STORE(); |
2521 | |
2522 | - store::Item_t qname = store.getQNamePool().insert(store.XML_URI, "xml", "base"); |
2523 | + store::Item_t qname; |
2524 | + store.getQNamePool().insert(qname, store.XML_URI, "xml", "base"); |
2525 | + |
2526 | store::Item_t typeName = store.theSchemaTypeNames[store::XS_ANY_URI]; |
2527 | |
2528 | store::Item_t typedValue; |
2529 | @@ -5133,7 +5135,7 @@ |
2530 | theTarget.take(target); |
2531 | theContent.take(content); |
2532 | |
2533 | - theName = qnpool.insert(zstring(), zstring(), theTarget); |
2534 | + qnpool.insert(theName, zstring(), zstring(), theTarget); |
2535 | |
2536 | STORE_TRACE1("Loaded pi node " << this << " target = " << theTarget |
2537 | << std::endl); |
2538 | @@ -5158,7 +5160,7 @@ |
2539 | theTarget.take(target); |
2540 | theContent.take(content); |
2541 | |
2542 | - theName = qnpool.insert(zstring(), zstring(), theTarget); |
2543 | + qnpool.insert(theName, zstring(), zstring(), theTarget); |
2544 | |
2545 | if (parent) |
2546 | { |
2547 | |
2548 | === modified file 'src/store/naive/nsbindings.cpp' |
2549 | --- src/store/naive/nsbindings.cpp 2013-06-20 09:52:25 +0000 |
2550 | +++ src/store/naive/nsbindings.cpp 2013-07-11 13:41:52 +0000 |
2551 | @@ -16,6 +16,7 @@ |
2552 | #include "stdafx.h" |
2553 | |
2554 | #include "nsbindings.h" |
2555 | +#include "store_defs.h" |
2556 | |
2557 | #include "zorbautils/fatal.h" |
2558 | |
2559 | |
2560 | === modified file 'src/store/naive/qname_pool.cpp' |
2561 | --- src/store/naive/qname_pool.cpp 2013-02-07 17:24:36 +0000 |
2562 | +++ src/store/naive/qname_pool.cpp 2013-07-11 13:41:52 +0000 |
2563 | @@ -48,13 +48,16 @@ |
2564 | QNameItem* qn = &theCache[1]; |
2565 | QNameItem* last = qn + size - 1; |
2566 | |
2567 | - for (csize i = 1; qn < last; qn++, i++) |
2568 | + for (csize i = 1; qn < last; ++qn, ++i) |
2569 | { |
2570 | qn->theNextFree = i + 1; |
2571 | qn->thePrevFree = i - 1; |
2572 | qn->thePosition = i; |
2573 | } |
2574 | (--qn)->theNextFree = 0; |
2575 | + |
2576 | + qn = &theCache[0]; |
2577 | + qn->theNextFree = qn->thePrevFree = qn->thePosition = 0; |
2578 | } |
2579 | |
2580 | |
2581 | @@ -64,6 +67,27 @@ |
2582 | QNamePool::~QNamePool() |
2583 | { |
2584 | csize n = theHashSet.capacity(); |
2585 | + |
2586 | +#if 0 |
2587 | +#ifndef NDEBUG |
2588 | + csize numInPool = 0; |
2589 | + for (csize i = 0; i < theCacheSize; ++i) |
2590 | + { |
2591 | + QNameItem* qn = &theCache[i]; |
2592 | + |
2593 | + if (qn->getRefCount() != 0) |
2594 | + { |
2595 | + ++numInPool; |
2596 | + std::cerr << "QName in pool: RC = " << qn->getRefCount() << " : " |
2597 | + << qn->getStringValue() << " at pos : " << qn->thePosition |
2598 | + << std::endl; |
2599 | + } |
2600 | + } |
2601 | + |
2602 | + std::cerr << std::endl << numInPool << "qnames in pool" << std::endl; |
2603 | +#endif |
2604 | +#endif |
2605 | + |
2606 | for (csize i = 0; i < n; ++i) |
2607 | { |
2608 | if (!theHashSet.theHashTab[i].isFree() && |
2609 | @@ -84,19 +108,42 @@ |
2610 | ********************************************************************************/ |
2611 | void QNamePool::addInFreeList(QNameItem* qn) |
2612 | { |
2613 | - assert(qn->thePrevFree == 0); |
2614 | - assert(qn->theNextFree == 0); |
2615 | assert(qn->getRefCount() == 0); |
2616 | assert(theCache[theFirstFree].thePrevFree == 0); |
2617 | |
2618 | + // Nothing to do if qn is already in the free list |
2619 | + |
2620 | + if (qn->thePrevFree != 0 || qn->theNextFree != 0) |
2621 | + { |
2622 | +#ifndef NDEBUG |
2623 | + QNameItem* curr = &theCache[theFirstFree]; |
2624 | + while (curr != NULL && curr != qn) |
2625 | + curr = &theCache[curr->theNextFree]; |
2626 | + |
2627 | + assert(curr != NULL); |
2628 | +#endif |
2629 | + return; |
2630 | + } |
2631 | + |
2632 | + if (theFirstFree == qn->thePosition) |
2633 | + return; |
2634 | + |
2635 | + // add it in the list |
2636 | + |
2637 | qn->theNextFree = (uint16_t)theFirstFree; |
2638 | |
2639 | if (theFirstFree != 0) |
2640 | + { |
2641 | + assert(theCache[theFirstFree].thePosition == theFirstFree); |
2642 | + |
2643 | theCache[theFirstFree].thePrevFree = qn->thePosition; |
2644 | + } |
2645 | |
2646 | theFirstFree = qn->thePosition; |
2647 | |
2648 | - theNumFree++; |
2649 | + assert(theFirstFree > 0 && theFirstFree < theCacheSize); |
2650 | + |
2651 | + ++theNumFree; |
2652 | } |
2653 | |
2654 | |
2655 | @@ -107,19 +154,10 @@ |
2656 | { |
2657 | assert(qn->isInCache()); |
2658 | |
2659 | - if (qn->theNextFree == 0 && qn->thePrevFree == 0) |
2660 | - { |
2661 | - // Either qn does not belong to the free list, or is the only one in the |
2662 | - // free list |
2663 | - |
2664 | - if (theFirstFree != qn->thePosition) |
2665 | - return; |
2666 | - } |
2667 | - |
2668 | - assert(qn->getRefCount() == 0); |
2669 | - |
2670 | if (qn->theNextFree != 0) |
2671 | { |
2672 | + assert(qn->getRefCount() == 0); |
2673 | + assert(theFirstFree > 0 && theFirstFree < theCacheSize); |
2674 | assert(theCache[qn->theNextFree].thePrevFree = qn->thePosition); |
2675 | |
2676 | theCache[qn->theNextFree].thePrevFree = qn->thePrevFree; |
2677 | @@ -127,12 +165,29 @@ |
2678 | |
2679 | if (qn->thePrevFree != 0) |
2680 | { |
2681 | + assert(qn->getRefCount() == 0); |
2682 | + assert(theFirstFree > 0 && theFirstFree < theCacheSize); |
2683 | assert(theCache[qn->thePrevFree].theNextFree = qn->thePosition); |
2684 | |
2685 | theCache[qn->thePrevFree].theNextFree = qn->theNextFree; |
2686 | } |
2687 | + else if (qn->theNextFree == 0) |
2688 | + { |
2689 | + // Either qn does not belong to the free list, or is the only one in the |
2690 | + // free list |
2691 | + if (theFirstFree != qn->thePosition) |
2692 | + return; |
2693 | + |
2694 | + assert(qn->getRefCount() == 0); |
2695 | + assert(theFirstFree == qn->thePosition); |
2696 | + assert(theNumFree == 1); |
2697 | + |
2698 | + theFirstFree = qn->theNextFree; |
2699 | + } |
2700 | else |
2701 | { |
2702 | + // qn is the 1st slot in the free list |
2703 | + assert(qn->getRefCount() == 0); |
2704 | assert(theFirstFree == qn->thePosition); |
2705 | |
2706 | theFirstFree = qn->theNextFree; |
2707 | @@ -140,7 +195,7 @@ |
2708 | |
2709 | qn->theNextFree = qn->thePrevFree = 0; |
2710 | |
2711 | - theNumFree--; |
2712 | + --theNumFree; |
2713 | } |
2714 | |
2715 | |
2716 | @@ -159,15 +214,14 @@ |
2717 | |
2718 | theFirstFree = qn->theNextFree; |
2719 | |
2720 | - if (theFirstFree != 0) |
2721 | - { |
2722 | - assert(theCache[theFirstFree].thePrevFree == qn->thePosition); |
2723 | - theCache[theFirstFree].thePrevFree = 0; |
2724 | - } |
2725 | + assert(theFirstFree == 0 || |
2726 | + theCache[theFirstFree].thePrevFree == qn->thePosition); |
2727 | + |
2728 | + theCache[theFirstFree].thePrevFree = 0; |
2729 | |
2730 | qn->theNextFree = qn->thePrevFree = 0; |
2731 | |
2732 | - theNumFree--; |
2733 | + --theNumFree; |
2734 | |
2735 | return qn; |
2736 | } |
2737 | @@ -186,13 +240,15 @@ |
2738 | { |
2739 | QNameItem* normVictim = NULL; |
2740 | |
2741 | - SYNC_CODE(theHashSet.theMutex.lock(); \ |
2742 | - bool haveLock = true;) |
2743 | + SYNC_CODE(theHashSet.theMutex.lock();) |
2744 | |
2745 | try |
2746 | { |
2747 | if (qn->getRefCount() > 0) |
2748 | + { |
2749 | + SYNC_CODE(theHashSet.theMutex.unlock();) |
2750 | return; |
2751 | + } |
2752 | |
2753 | if (qn->isInCache()) |
2754 | { |
2755 | @@ -211,22 +267,20 @@ |
2756 | |
2757 | // Releasing the lock here to avoid deadlock, because decrementing the |
2758 | // normVictim counter might reenter QNamePool::remove. |
2759 | - SYNC_CODE(theHashSet.theMutex.unlock(); \ |
2760 | - haveLock = false;) |
2761 | - |
2762 | - if (normVictim) |
2763 | - { |
2764 | - normVictim->removeReference(); |
2765 | - } |
2766 | - |
2767 | + SYNC_CODE(theHashSet.theMutex.unlock();) |
2768 | } |
2769 | catch(...) |
2770 | { |
2771 | - SYNC_CODE(if (haveLock) \ |
2772 | - theHashSet.theMutex.unlock();) |
2773 | + SYNC_CODE(theHashSet.theMutex.unlock();) |
2774 | |
2775 | ZORBA_FATAL(0, "Unexpected exception"); |
2776 | } |
2777 | + |
2778 | + if (normVictim) |
2779 | + { |
2780 | + assert(normVictim->getRefCount() > 0 && normVictim->getRefCount() < 10000); |
2781 | + normVictim->removeReference(); |
2782 | + } |
2783 | } |
2784 | |
2785 | |
2786 | @@ -240,7 +294,8 @@ |
2787 | copied internally into zstring objects. So, it's always the caller who is |
2788 | resposnible for freeing the given strings. |
2789 | ********************************************************************************/ |
2790 | -store::Item_t QNamePool::insert( |
2791 | +void QNamePool::insert( |
2792 | + store::Item_t& res, |
2793 | const char* ns, |
2794 | const char* pre, |
2795 | const char* ln) |
2796 | @@ -251,6 +306,8 @@ |
2797 | store::Item_t normItem; |
2798 | QNameItem* normQName = NULL; |
2799 | |
2800 | + res = NULL; |
2801 | + |
2802 | bool normalized = (pre == NULL || *pre == '\0'); |
2803 | |
2804 | if (ns == NULL) ns = ""; |
2805 | @@ -286,7 +343,7 @@ |
2806 | SYNC_CODE(theHashSet.theMutex.unlock();\ |
2807 | haveLock = false;) |
2808 | |
2809 | - normItem = insert(ns, NULL, ln); |
2810 | + insert(normItem, ns, NULL, ln); |
2811 | normQName = static_cast<QNameItem*>(normItem.getp()); |
2812 | goto retry; |
2813 | } |
2814 | @@ -306,6 +363,9 @@ |
2815 | cachePin(qn); |
2816 | } |
2817 | |
2818 | + assert(qn->theNextFree == 0); |
2819 | + res = qn; |
2820 | + |
2821 | SYNC_CODE(theHashSet.theMutex.unlock();\ |
2822 | haveLock = false;) |
2823 | } |
2824 | @@ -319,10 +379,9 @@ |
2825 | |
2826 | if (normVictim != NULL) |
2827 | { |
2828 | + assert(normVictim->getRefCount() > 0 && normVictim->getRefCount() < 10000); |
2829 | normVictim->removeReference(); |
2830 | } |
2831 | - |
2832 | - return qn; |
2833 | } |
2834 | |
2835 | |
2836 | @@ -331,7 +390,8 @@ |
2837 | and local name, then create such a qname, insert it in the pool and return an |
2838 | rchandle to it. Otherwise, return an rchandle to the existing qname. |
2839 | ********************************************************************************/ |
2840 | -store::Item_t QNamePool::insert( |
2841 | +void QNamePool::insert( |
2842 | + store::Item_t& res, |
2843 | const zstring& ns, |
2844 | const zstring& pre, |
2845 | const zstring& ln) |
2846 | @@ -342,6 +402,8 @@ |
2847 | store::Item_t normItem; |
2848 | QNameItem* normQName = NULL; |
2849 | |
2850 | + res = NULL; |
2851 | + |
2852 | bool normalized = pre.empty(); |
2853 | |
2854 | zstring pooledNs; |
2855 | @@ -377,7 +439,7 @@ |
2856 | haveLock = false;) |
2857 | |
2858 | // This call will need the lock. |
2859 | - normItem = insert(pooledNs, zstring(), ln); |
2860 | + insert(normItem, pooledNs, zstring(), ln); |
2861 | normQName = static_cast<QNameItem*>(normItem.getp()); |
2862 | |
2863 | goto retry; |
2864 | @@ -398,23 +460,24 @@ |
2865 | cachePin(qn); |
2866 | } |
2867 | |
2868 | + assert(qn->theNextFree == 0); |
2869 | + res = qn; |
2870 | + |
2871 | SYNC_CODE(theHashSet.theMutex.unlock();\ |
2872 | haveLock = false;) |
2873 | } |
2874 | catch (...) |
2875 | { |
2876 | - SYNC_CODE(if (haveLock) \ |
2877 | - theHashSet.theMutex.unlock();) |
2878 | + SYNC_CODE(if (haveLock) theHashSet.theMutex.unlock();) |
2879 | |
2880 | ZORBA_FATAL(0, "Unexpected exception"); |
2881 | } |
2882 | |
2883 | if (normVictim != NULL) |
2884 | { |
2885 | + assert(normVictim->getRefCount() > 0 && normVictim->getRefCount() < 10000); |
2886 | normVictim->removeReference(); |
2887 | } |
2888 | - |
2889 | - return qn; |
2890 | } |
2891 | |
2892 | |
2893 | @@ -480,9 +543,9 @@ |
2894 | { |
2895 | QNameItem* qn = entry->key(); |
2896 | |
2897 | - if (ztd::equals(qn->getLocalName(), ln, lnlen) && |
2898 | - ztd::equals(qn->getNamespace(), ns, nslen) && |
2899 | - ztd::equals(qn->getPrefix(), pre, prelen)) |
2900 | + if (ztd::equals(qn->getLocalName2(), ln, lnlen) && |
2901 | + ztd::equals(qn->getNamespace2(), ns, nslen) && |
2902 | + ztd::equals(qn->getPrefix2(), pre, prelen)) |
2903 | return entry; |
2904 | |
2905 | entry = entry->getNext(); |
2906 | |
2907 | === modified file 'src/store/naive/qname_pool.h' |
2908 | --- src/store/naive/qname_pool.h 2013-02-07 17:24:36 +0000 |
2909 | +++ src/store/naive/qname_pool.h 2013-07-11 13:41:52 +0000 |
2910 | @@ -68,16 +68,16 @@ |
2911 | public: |
2912 | static bool equal(const QNameItem* t1, const QNameItem* t2) |
2913 | { |
2914 | - return (t1->getLocalName() == t2->getLocalName() && |
2915 | - t1->getNamespace() == t2->getNamespace() && |
2916 | - t1->getPrefix() == t2->getPrefix()); |
2917 | + return (t1->getLocalName2() == t2->getLocalName2() && |
2918 | + t1->getNamespace2() == t2->getNamespace2() && |
2919 | + t1->getPrefix2() == t2->getPrefix2()); |
2920 | } |
2921 | |
2922 | static uint32_t hash(const QNameItem* t) |
2923 | { |
2924 | - return hashfun::h32(t->getPrefix().c_str(), |
2925 | - hashfun::h32(t->getLocalName().c_str(), |
2926 | - hashfun::h32(t->getNamespace().c_str()))); |
2927 | + return hashfun::h32(t->getPrefix2().c_str(), |
2928 | + hashfun::h32(t->getLocalName2().c_str(), |
2929 | + hashfun::h32(t->getNamespace2().c_str()))); |
2930 | } |
2931 | }; |
2932 | |
2933 | @@ -115,9 +115,17 @@ |
2934 | |
2935 | ~QNamePool(); |
2936 | |
2937 | - store::Item_t insert(const char* ns, const char* pre, const char* ln); |
2938 | + void insert( |
2939 | + store::Item_t& res, |
2940 | + const char* ns, |
2941 | + const char* pre, |
2942 | + const char* ln); |
2943 | |
2944 | - store::Item_t insert(const zstring& ns, const zstring& pre, const zstring& ln); |
2945 | + void insert( |
2946 | + store::Item_t& res, |
2947 | + const zstring& ns, |
2948 | + const zstring& pre, |
2949 | + const zstring& ln); |
2950 | |
2951 | void remove(QNameItem* qn); |
2952 | |
2953 | |
2954 | === modified file 'src/store/naive/simple_item_factory.cpp' |
2955 | --- src/store/naive/simple_item_factory.cpp 2013-06-21 01:06:29 +0000 |
2956 | +++ src/store/naive/simple_item_factory.cpp 2013-07-11 13:41:52 +0000 |
2957 | @@ -81,7 +81,7 @@ |
2958 | const zstring& pre, |
2959 | const zstring& local) |
2960 | { |
2961 | - result = theQNamePool->insert(ns, pre, local); |
2962 | + theQNamePool->insert(result, ns, pre, local); |
2963 | return true; |
2964 | } |
2965 | |
2966 | @@ -92,7 +92,7 @@ |
2967 | const char* pre, |
2968 | const char* ln) |
2969 | { |
2970 | - result = theQNamePool->insert(ns, pre, ln); |
2971 | + theQNamePool->insert(result, ns, pre, ln); |
2972 | return true; |
2973 | } |
2974 | |
2975 | |
2976 | === modified file 'src/store/naive/simple_pul.cpp' |
2977 | --- src/store/naive/simple_pul.cpp 2013-06-15 02:57:08 +0000 |
2978 | +++ src/store/naive/simple_pul.cpp 2013-07-11 13:41:52 +0000 |
2979 | @@ -166,20 +166,19 @@ |
2980 | { |
2981 | const QNameItem* collName; |
2982 | |
2983 | - assert(target->isNode() |
2984 | - || target->isJSONItem()); |
2985 | + assert(target->isNode() || target->isJSONItem()); |
2986 | |
2987 | assert(dynamic_cast<const StructuredItem*>(target)); |
2988 | - const StructuredItem* lStructuredItem = |
2989 | - static_cast<const StructuredItem*>(target); |
2990 | - const store::Collection* lCollection = lStructuredItem->getCollection(); |
2991 | + |
2992 | + const StructuredItem* structuredItem = static_cast<const StructuredItem*>(target); |
2993 | + |
2994 | + const store::Collection* lCollection = structuredItem->getCollection(); |
2995 | |
2996 | if (lCollection != NULL) |
2997 | { |
2998 | - collName = static_cast<const QNameItem*>( |
2999 | - lCollection->getName())->getNormalized(); |
3000 | + collName = static_cast<const QNameItem*>(lCollection->getName()); |
3001 | |
3002 | - if (collName == theLastCollection) |
3003 | + if (theLastCollection != NULL && collName->equals(theLastCollection)) |
3004 | return theLastPul; |
3005 | |
3006 | return getCollectionPulByName(collName, lCollection->isDynamic()); |
3007 | |
3008 | === modified file 'src/store/naive/store.cpp' |
3009 | --- src/store/naive/store.cpp 2013-06-15 02:57:08 +0000 |
3010 | +++ src/store/naive/store.cpp 2013-07-11 13:41:52 +0000 |
3011 | @@ -185,69 +185,69 @@ |
3012 | |
3013 | theSchemaTypeNames.resize(store::XS_LAST); |
3014 | |
3015 | - JS_NULL_QNAME = theQNamePool->insert(JS_URI, "js", "null"); |
3016 | - JS_OBJECT_QNAME = theQNamePool->insert(JS_URI, "js", "object"); |
3017 | - JS_ARRAY_QNAME = theQNamePool->insert(JS_URI, "js", "array"); |
3018 | - |
3019 | - XS_UNTYPED_QNAME = theQNamePool->insert(ns, "xs", "untyped"); |
3020 | - |
3021 | - XS_ANY_QNAME = theQNamePool->insert(ns, "xs", "anyType"); |
3022 | - |
3023 | - theSchemaTypeNames[store::XS_ANY_ATOMIC] = |
3024 | - theQNamePool->insert(ns, "xs", "anyAtomicType"); |
3025 | - |
3026 | - theSchemaTypeNames[store::XS_UNTYPED_ATOMIC] = |
3027 | - theQNamePool->insert(ns, "xs", "untypedAtomic"); |
3028 | - |
3029 | - theSchemaTypeNames[store::XS_ANY_URI] = theQNamePool->insert(ns, "xs", "anyURI"); |
3030 | - theSchemaTypeNames[store::XS_QNAME] = theQNamePool->insert(ns, "xs", "QName"); |
3031 | - theSchemaTypeNames[store::XS_NOTATION] = theQNamePool->insert(ns, "xs", "NOTATION"); |
3032 | - theSchemaTypeNames[store::XS_STRING] = theQNamePool->insert(ns, "xs", "string"); |
3033 | - theSchemaTypeNames[store::XS_NORMALIZED_STRING] = theQNamePool->insert(ns, "xs", "normalizedString"); |
3034 | - theSchemaTypeNames[store::XS_TOKEN] = theQNamePool->insert(ns, "xs", "token"); |
3035 | - theSchemaTypeNames[store::XS_NMTOKEN] = theQNamePool->insert(ns, "xs", "NMTOKEN"); |
3036 | - theSchemaTypeNames[store::XS_LANGUAGE] = theQNamePool->insert(ns, "xs", "language"); |
3037 | - theSchemaTypeNames[store::XS_NAME] = theQNamePool->insert(ns, "xs", "Name"); |
3038 | - theSchemaTypeNames[store::XS_NCNAME] = theQNamePool->insert(ns, "xs", "NCName"); |
3039 | - theSchemaTypeNames[store::XS_ID] = theQNamePool->insert(ns, "xs", "ID"); |
3040 | - theSchemaTypeNames[store::XS_IDREF] = theQNamePool->insert(ns, "xs", "IDREF"); |
3041 | - theSchemaTypeNames[store::XS_ENTITY] = theQNamePool->insert(ns, "xs", "ENTITY"); |
3042 | - |
3043 | - theSchemaTypeNames[store::XS_DATETIME] = theQNamePool->insert(ns, "xs", "dateTime"); |
3044 | - theSchemaTypeNames[store::XS_DATETIME_STAMP] = theQNamePool->insert(ns, "xs", "dateTimeStamp"); |
3045 | - theSchemaTypeNames[store::XS_DATE] = theQNamePool->insert(ns, "xs", "date"); |
3046 | - theSchemaTypeNames[store::XS_TIME] = theQNamePool->insert(ns, "xs", "time"); |
3047 | - theSchemaTypeNames[store::XS_GYEAR_MONTH] = theQNamePool->insert(ns, "xs", "gYearMonth"); |
3048 | - theSchemaTypeNames[store::XS_GYEAR] = theQNamePool->insert(ns, "xs", "gYear"); |
3049 | - theSchemaTypeNames[store::XS_GMONTH_DAY] = theQNamePool->insert(ns, "xs", "gMonthDay"); |
3050 | - theSchemaTypeNames[store::XS_GDAY] = theQNamePool->insert(ns, "xs", "gDay"); |
3051 | - theSchemaTypeNames[store::XS_GMONTH] = theQNamePool->insert(ns, "xs", "gMonth"); |
3052 | - |
3053 | - theSchemaTypeNames[store::XS_DURATION] = theQNamePool->insert(ns, "xs", "duration"); |
3054 | - theSchemaTypeNames[store::XS_DT_DURATION] = theQNamePool->insert(ns, "xs", "dayTimeDuration"); |
3055 | - theSchemaTypeNames[store::XS_YM_DURATION] = theQNamePool->insert(ns, "xs", "yearMonthDuration"); |
3056 | - |
3057 | - theSchemaTypeNames[store::XS_FLOAT] = theQNamePool->insert(ns, "xs", "float"); |
3058 | - theSchemaTypeNames[store::XS_DOUBLE] = theQNamePool->insert(ns, "xs", "double"); |
3059 | - theSchemaTypeNames[store::XS_DECIMAL] = theQNamePool->insert(ns, "xs", "decimal"); |
3060 | - theSchemaTypeNames[store::XS_INTEGER] = theQNamePool->insert(ns, "xs", "integer"); |
3061 | - theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER] = theQNamePool->insert(ns, "xs", "nonPositiveInteger"); |
3062 | - theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER] = theQNamePool->insert(ns, "xs", "nonNegativeInteger"); |
3063 | - theSchemaTypeNames[store::XS_NEGATIVE_INTEGER] = theQNamePool->insert(ns, "xs", "negativeInteger"); |
3064 | - theSchemaTypeNames[store::XS_POSITIVE_INTEGER] = theQNamePool->insert(ns, "xs", "positiveInteger"); |
3065 | - |
3066 | - theSchemaTypeNames[store::XS_LONG] = theQNamePool->insert(ns, "xs", "long"); |
3067 | - theSchemaTypeNames[store::XS_INT] = theQNamePool->insert(ns, "xs", "int"); |
3068 | - theSchemaTypeNames[store::XS_SHORT] = theQNamePool->insert(ns, "xs", "short"); |
3069 | - theSchemaTypeNames[store::XS_BYTE] = theQNamePool->insert(ns, "xs", "byte"); |
3070 | - theSchemaTypeNames[store::XS_UNSIGNED_LONG] = theQNamePool->insert(ns, "xs", "unsignedLong"); |
3071 | - theSchemaTypeNames[store::XS_UNSIGNED_INT] = theQNamePool->insert(ns, "xs", "unsignedInt"); |
3072 | - theSchemaTypeNames[store::XS_UNSIGNED_SHORT] = theQNamePool->insert(ns, "xs", "unsignedShort"); |
3073 | - theSchemaTypeNames[store::XS_UNSIGNED_BYTE] = theQNamePool->insert(ns, "xs", "unsignedByte"); |
3074 | - |
3075 | - theSchemaTypeNames[store::XS_BASE64BINARY] = theQNamePool->insert(ns, "xs", "base64Binary"); |
3076 | - theSchemaTypeNames[store::XS_HEXBINARY] = theQNamePool->insert(ns, "xs", "hexBinary"); |
3077 | - theSchemaTypeNames[store::XS_BOOLEAN] = theQNamePool->insert(ns, "xs", "boolean"); |
3078 | + theQNamePool->insert(JS_NULL_QNAME, JS_URI, "js", "null"); |
3079 | + theQNamePool->insert(JS_OBJECT_QNAME, JS_URI, "js", "object"); |
3080 | + theQNamePool->insert(JS_ARRAY_QNAME, JS_URI, "js", "array"); |
3081 | + |
3082 | + theQNamePool->insert(XS_UNTYPED_QNAME, ns, "xs", "untyped"); |
3083 | + |
3084 | + theQNamePool->insert(XS_ANY_QNAME, ns, "xs", "anyType"); |
3085 | + |
3086 | + theQNamePool->insert(theSchemaTypeNames[store::XS_ANY_ATOMIC], |
3087 | + ns, "xs", "anyAtomicType"); |
3088 | + |
3089 | + theQNamePool->insert(theSchemaTypeNames[store::XS_UNTYPED_ATOMIC], |
3090 | + ns, "xs", "untypedAtomic"); |
3091 | + |
3092 | + theQNamePool->insert(theSchemaTypeNames[store::XS_ANY_URI], ns, "xs", "anyURI"); |
3093 | + theQNamePool->insert(theSchemaTypeNames[store::XS_QNAME], ns, "xs", "QName"); |
3094 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NOTATION], ns, "xs", "NOTATION"); |
3095 | + theQNamePool->insert(theSchemaTypeNames[store::XS_STRING], ns, "xs", "string"); |
3096 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NORMALIZED_STRING], ns, "xs", "normalizedString"); |
3097 | + theQNamePool->insert(theSchemaTypeNames[store::XS_TOKEN], ns, "xs", "token"); |
3098 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NMTOKEN], ns, "xs", "NMTOKEN"); |
3099 | + theQNamePool->insert(theSchemaTypeNames[store::XS_LANGUAGE], ns, "xs", "language"); |
3100 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NAME], ns, "xs", "Name"); |
3101 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NCNAME], ns, "xs", "NCName"); |
3102 | + theQNamePool->insert(theSchemaTypeNames[store::XS_ID], ns, "xs", "ID"); |
3103 | + theQNamePool->insert(theSchemaTypeNames[store::XS_IDREF], ns, "xs", "IDREF"); |
3104 | + theQNamePool->insert(theSchemaTypeNames[store::XS_ENTITY], ns, "xs", "ENTITY"); |
3105 | + |
3106 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DATETIME], ns, "xs", "dateTime"); |
3107 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DATETIME_STAMP], ns, "xs", "dateTimeStamp"); |
3108 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DATE], ns, "xs", "date"); |
3109 | + theQNamePool->insert(theSchemaTypeNames[store::XS_TIME], ns, "xs", "time"); |
3110 | + theQNamePool->insert(theSchemaTypeNames[store::XS_GYEAR_MONTH], ns, "xs", "gYearMonth"); |
3111 | + theQNamePool->insert(theSchemaTypeNames[store::XS_GYEAR], ns, "xs", "gYear"); |
3112 | + theQNamePool->insert(theSchemaTypeNames[store::XS_GMONTH_DAY], ns, "xs", "gMonthDay"); |
3113 | + theQNamePool->insert(theSchemaTypeNames[store::XS_GDAY], ns, "xs", "gDay"); |
3114 | + theQNamePool->insert(theSchemaTypeNames[store::XS_GMONTH], ns, "xs", "gMonth"); |
3115 | + |
3116 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DURATION], ns, "xs", "duration"); |
3117 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DT_DURATION], ns, "xs", "dayTimeDuration"); |
3118 | + theQNamePool->insert(theSchemaTypeNames[store::XS_YM_DURATION], ns, "xs", "yearMonthDuration"); |
3119 | + |
3120 | + theQNamePool->insert(theSchemaTypeNames[store::XS_FLOAT], ns, "xs", "float"); |
3121 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DOUBLE], ns, "xs", "double"); |
3122 | + theQNamePool->insert(theSchemaTypeNames[store::XS_DECIMAL], ns, "xs", "decimal"); |
3123 | + theQNamePool->insert(theSchemaTypeNames[store::XS_INTEGER], ns, "xs", "integer"); |
3124 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER], ns, "xs", "nonPositiveInteger"); |
3125 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER], ns, "xs", "nonNegativeInteger"); |
3126 | + theQNamePool->insert(theSchemaTypeNames[store::XS_NEGATIVE_INTEGER], ns, "xs", "negativeInteger"); |
3127 | + theQNamePool->insert(theSchemaTypeNames[store::XS_POSITIVE_INTEGER], ns, "xs", "positiveInteger"); |
3128 | + |
3129 | + theQNamePool->insert(theSchemaTypeNames[store::XS_LONG], ns, "xs", "long"); |
3130 | + theQNamePool->insert(theSchemaTypeNames[store::XS_INT], ns, "xs", "int"); |
3131 | + theQNamePool->insert(theSchemaTypeNames[store::XS_SHORT], ns, "xs", "short"); |
3132 | + theQNamePool->insert(theSchemaTypeNames[store::XS_BYTE], ns, "xs", "byte"); |
3133 | + theQNamePool->insert(theSchemaTypeNames[store::XS_UNSIGNED_LONG], ns, "xs", "unsignedLong"); |
3134 | + theQNamePool->insert(theSchemaTypeNames[store::XS_UNSIGNED_INT], ns, "xs", "unsignedInt"); |
3135 | + theQNamePool->insert(theSchemaTypeNames[store::XS_UNSIGNED_SHORT], ns, "xs", "unsignedShort"); |
3136 | + theQNamePool->insert(theSchemaTypeNames[store::XS_UNSIGNED_BYTE], ns, "xs", "unsignedByte"); |
3137 | + |
3138 | + theQNamePool->insert(theSchemaTypeNames[store::XS_BASE64BINARY], ns, "xs", "base64Binary"); |
3139 | + theQNamePool->insert(theSchemaTypeNames[store::XS_HEXBINARY], ns, "xs", "hexBinary"); |
3140 | + theQNamePool->insert(theSchemaTypeNames[store::XS_BOOLEAN], ns, "xs", "boolean"); |
3141 | |
3142 | for (csize i = 0; i < store::XS_LAST; ++i) |
3143 | { |
3144 | |
3145 | === modified file 'src/store/naive/store_defs.h' |
3146 | --- src/store/naive/store_defs.h 2013-02-26 04:12:43 +0000 |
3147 | +++ src/store/naive/store_defs.h 2013-07-11 13:41:52 +0000 |
3148 | @@ -26,6 +26,7 @@ |
3149 | //#define EMBEDED_TYPE |
3150 | //#define TEXT_ORDPATH |
3151 | |
3152 | +#define XML_NS "http://www.w3.org/XML/1998/namespace" |
3153 | |
3154 | #define GET_STORE() \ |
3155 | (*zorba::simplestore::StoreManagerImpl::getStoreInternal()) |
3156 | |
3157 | === modified file 'src/system/globalenv.cpp' |
3158 | --- src/system/globalenv.cpp 2013-05-13 08:45:43 +0000 |
3159 | +++ src/system/globalenv.cpp 2013-07-11 13:41:52 +0000 |
3160 | @@ -86,10 +86,11 @@ |
3161 | RCHelper::addReference(m_globalEnv->theRootTypeManager); |
3162 | |
3163 | m_globalEnv->theRootStaticContext = new root_static_context(); |
3164 | - RCHelper::addReference(m_globalEnv->theRootStaticContext); |
3165 | m_globalEnv->theRootStaticContext->init(); |
3166 | |
3167 | - BuiltinFunctionLibrary::create(m_globalEnv->theRootStaticContext); |
3168 | + m_globalEnv->theFunctionLib = new BuiltinFunctionLibrary(); |
3169 | + |
3170 | + m_globalEnv->theFunctionLib->populate(m_globalEnv->theRootStaticContext); |
3171 | |
3172 | AnnotationInternal::createBuiltIn(); |
3173 | |
3174 | @@ -105,7 +106,7 @@ |
3175 | #endif |
3176 | |
3177 | std::auto_ptr<XQueryCompilerSubsystem> lSubSystem = |
3178 | - XQueryCompilerSubsystem::create(); |
3179 | + XQueryCompilerSubsystem::create(); |
3180 | |
3181 | m_globalEnv->m_compilerSubSys = lSubSystem.release(); |
3182 | |
3183 | @@ -139,8 +140,9 @@ |
3184 | delete m_globalEnv->xqueryx_convertor; |
3185 | #endif |
3186 | |
3187 | - RCHelper::removeReference(m_globalEnv->theRootStaticContext); |
3188 | - m_globalEnv->theRootStaticContext = 0; |
3189 | + delete m_globalEnv->theRootStaticContext; |
3190 | + |
3191 | + delete m_globalEnv->theFunctionLib; |
3192 | |
3193 | RCHelper::removeReference(m_globalEnv->theRootTypeManager); |
3194 | m_globalEnv->theRootTypeManager = 0; |
3195 | @@ -157,8 +159,6 @@ |
3196 | // see http://www.icu-project.org/apiref/icu4c/uclean_8h.html#93f27d0ddc7c196a1da864763f2d8920 |
3197 | m_globalEnv->cleanup_icu(); |
3198 | |
3199 | - BuiltinFunctionLibrary::destroy(); |
3200 | - |
3201 | delete m_globalEnv; |
3202 | m_globalEnv = NULL; |
3203 | |
3204 | |
3205 | === modified file 'src/system/globalenv.h' |
3206 | --- src/system/globalenv.h 2013-02-07 17:24:36 +0000 |
3207 | +++ src/system/globalenv.h 2013-07-11 13:41:52 +0000 |
3208 | @@ -22,14 +22,17 @@ |
3209 | #include "common/common.h" |
3210 | #include "common/shared_types.h" |
3211 | |
3212 | -namespace zorba { |
3213 | +namespace zorba |
3214 | +{ |
3215 | |
3216 | class RootTypeManager; |
3217 | class root_static_context; |
3218 | class XQueryXConvertor; |
3219 | class DynamicLoader; |
3220 | +class BuiltinFunctionLibrary; |
3221 | |
3222 | -namespace internal { |
3223 | +namespace internal |
3224 | +{ |
3225 | class HTTPURLResolver; |
3226 | class FileURLResolver; |
3227 | class AutoFSURIMapper; |
3228 | @@ -38,12 +41,15 @@ |
3229 | #endif /* ZORBA_NO_FULL_TEXT */ |
3230 | } |
3231 | |
3232 | -namespace store { |
3233 | +namespace store |
3234 | +{ |
3235 | class Store; |
3236 | } |
3237 | |
3238 | |
3239 | -// exported for unit testing only |
3240 | +/******************************************************************************* |
3241 | + |
3242 | +********************************************************************************/ |
3243 | class ZORBA_DLL_PUBLIC GlobalEnvironment |
3244 | { |
3245 | private: |
3246 | @@ -57,6 +63,8 @@ |
3247 | |
3248 | root_static_context * theRootStaticContext; |
3249 | |
3250 | + BuiltinFunctionLibrary * theFunctionLib; |
3251 | + |
3252 | XQueryCompilerSubsystem * m_compilerSubSys; |
3253 | |
3254 | #ifdef ZORBA_XQUERYX |
3255 | @@ -95,6 +103,8 @@ |
3256 | |
3257 | bool isRootStaticContextInitialized() const; |
3258 | |
3259 | + BuiltinFunctionLibrary* getFuncLib() const { return theFunctionLib; } |
3260 | + |
3261 | XQueryCompilerSubsystem& getCompilerSubsystem(); |
3262 | |
3263 | store::Store& getStore(); |
3264 | @@ -142,6 +152,8 @@ |
3265 | |
3266 | #define GENV_ROOT_STATIC_CONTEXT GlobalEnvironment::getInstance().getRootStaticContext() |
3267 | |
3268 | +#define GENV_FUNC_LIB GlobalEnvironment::getInstance().getFuncLib() |
3269 | + |
3270 | #define GENV_DYNAMIC_LOADER GlobalEnvironment::getInstance().getDynamicLoader() |
3271 | |
3272 | } |
3273 | |
3274 | === modified file 'src/types/root_typemanager.cpp' |
3275 | --- src/types/root_typemanager.cpp 2013-06-15 02:57:08 +0000 |
3276 | +++ src/types/root_typemanager.cpp 2013-07-11 13:41:52 +0000 |
3277 | @@ -231,7 +231,7 @@ |
3278 | |
3279 | #define XSQNDECL(var, local) \ |
3280 | GENV.getStore().getItemFactory()-> \ |
3281 | - createQName(var, XML_SCHEMA_NS, XML_SCHEMA_PREFIX, local) |
3282 | + createQName(var, static_context::W3C_XML_SCHEMA_NS, "xs", local) |
3283 | |
3284 | XSQNDECL(XS_ANY_ATOMIC_QNAME, "anyAtomicType"); |
3285 | XSQNDECL(XS_STRING_QNAME, "string"); |
3286 | @@ -288,7 +288,7 @@ |
3287 | |
3288 | GENV_STORE.getItemFactory()->createQName(JS_NULL_QNAME, |
3289 | static_context::JSONIQ_DM_NS, |
3290 | - "js", |
3291 | + "", |
3292 | "null"); |
3293 | |
3294 | store::Item* tempQN = NULL; |
3295 | |
3296 | === modified file 'src/types/schema/revalidateUtils.cpp' |
3297 | --- src/types/schema/revalidateUtils.cpp 2013-06-29 08:38:53 +0000 |
3298 | +++ src/types/schema/revalidateUtils.cpp 2013-07-11 13:41:52 +0000 |
3299 | @@ -495,10 +495,8 @@ |
3300 | std::vector<store::Item_t>& resultList, |
3301 | const QueryLoc& loc) |
3302 | { |
3303 | - xqtref_t type = typeManager->create_named_atomic_type(typeQName, |
3304 | - TypeConstants::QUANT_ONE, |
3305 | - loc, |
3306 | - false); |
3307 | + xqtref_t type = typeManager->create_named_simple_type(typeQName); |
3308 | + |
3309 | //cout << " vup - processTextValue: '" << textValue->c_str() << "'\n"; |
3310 | //cout << " vup - processTextValue: " << typeQName->getPrefix()->str() |
3311 | // << ":" << typeQName->getLocalName()->str() << "@" |
3312 | @@ -509,7 +507,15 @@ |
3313 | store::Item_t result; |
3314 | if (type != NULL) |
3315 | { |
3316 | - if ( type->type_kind() == XQType::USER_DEFINED_KIND ) |
3317 | + if (type->type_kind() == XQType::ANY_SIMPLE_TYPE_KIND) |
3318 | + { |
3319 | + if (GENV_ITEMFACTORY->createUntypedAtomic(result, textValue)) |
3320 | + resultList.push_back(result); |
3321 | + |
3322 | + return; |
3323 | + } |
3324 | + |
3325 | + if (type->type_kind() == XQType::USER_DEFINED_KIND) |
3326 | { |
3327 | const UserDefinedXQType udXQType = static_cast<const UserDefinedXQType&>(*type); |
3328 | |
3329 | @@ -552,7 +558,7 @@ |
3330 | } |
3331 | else |
3332 | { |
3333 | - if ( GENV_ITEMFACTORY->createUntypedAtomic( result, textValue) ) |
3334 | + if (GENV_ITEMFACTORY->createUntypedAtomic(result, textValue)) |
3335 | resultList.push_back(result); |
3336 | } |
3337 | } |
3338 | |
3339 | === modified file 'src/types/schema/schema.cpp' |
3340 | --- src/types/schema/schema.cpp 2013-06-21 12:07:22 +0000 |
3341 | +++ src/types/schema/schema.cpp 2013-07-11 13:41:52 +0000 |
3342 | @@ -79,7 +79,7 @@ |
3343 | #endif |
3344 | |
3345 | |
3346 | -const char* Schema::XSD_NAMESPACE = XML_SCHEMA_NS; |
3347 | +const char* Schema::XSD_NAMESPACE = static_context::W3C_XML_SCHEMA_NS; |
3348 | |
3349 | bool Schema::theIsInitialized = false; |
3350 | |
3351 | |
3352 | === modified file 'src/types/typeimpl.cpp' |
3353 | --- src/types/typeimpl.cpp 2013-06-15 02:57:08 +0000 |
3354 | +++ src/types/typeimpl.cpp 2013-07-11 13:41:52 +0000 |
3355 | @@ -181,6 +181,9 @@ |
3356 | { |
3357 | if (theIsBuiltin) |
3358 | { |
3359 | +#ifndef NDEBUG |
3360 | + theRefCount = 1000000; |
3361 | +#endif |
3362 | // register this hardcoded object to help plan serialization |
3363 | XQType* this_ptr = this; |
3364 | *::zorba::serialization::ClassSerializer::getInstance()-> |
3365 | |
3366 | === modified file 'src/types/typemanagerimpl.cpp' |
3367 | --- src/types/typemanagerimpl.cpp 2013-06-15 02:57:08 +0000 |
3368 | +++ src/types/typemanagerimpl.cpp 2013-07-11 13:41:52 +0000 |
3369 | @@ -46,6 +46,8 @@ |
3370 | #include "zorbaserialization/serialize_template_types.h" |
3371 | #include "zorbaserialization/serialize_zorba_types.h" |
3372 | |
3373 | +#include "context/static_context.h" |
3374 | + |
3375 | #ifdef ZORBA_XBROWSER |
3376 | #include "DOMQName.h" |
3377 | #endif |
3378 | @@ -259,7 +261,7 @@ |
3379 | |
3380 | // If the type name is an XML Schema builtin type, then it cannot be an atomic |
3381 | // type (because, otherwise it would have been found above). So we return NULL. |
3382 | - if (ZSTREQ(qname->getNamespace(), XML_SCHEMA_NS)) |
3383 | + if (qname->getNamespace() == static_context::W3C_XML_SCHEMA_NS) |
3384 | { |
3385 | if (raiseError) |
3386 | { |
3387 | @@ -333,7 +335,7 @@ |
3388 | |
3389 | // If the type name is an XML Schema builtin type, then it can only be one of |
3390 | // xs:NMTOKES, xs:IDREFS, or xs:ENTITIES. |
3391 | - if (ZSTREQ(qname->getNamespace(), XML_SCHEMA_NS)) |
3392 | + if (qname->getNamespace() == static_context::W3C_XML_SCHEMA_NS) |
3393 | { |
3394 | RootTypeManager& rtm = GENV_TYPESYSTEM; |
3395 | |
3396 | |
3397 | === modified file 'src/util/http_util.cpp' |
3398 | --- src/util/http_util.cpp 2013-05-31 03:38:45 +0000 |
3399 | +++ src/util/http_util.cpp 2013-07-11 13:41:52 +0000 |
3400 | @@ -24,6 +24,7 @@ |
3401 | |
3402 | #include "api/unmarshaller.h" |
3403 | #include "zorbamisc/ns_consts.h" |
3404 | +#include "context/static_context.h" |
3405 | |
3406 | #include "http_util.h" |
3407 | |
3408 | @@ -53,16 +54,28 @@ |
3409 | ItemFactory* lFactory = lInstance->getItemFactory(); |
3410 | Item lNodeName = lFactory->createQName("http://expath.org/ns/http-client", "http", "request"); |
3411 | Item lEmptyItem; |
3412 | + |
3413 | NsBindings nsPairs; |
3414 | - nsPairs.push_back(std::make_pair(String(XML_SCHEMA_PREFIX), String(XML_SCHEMA_NS))); |
3415 | - Item lRequestElement = lFactory->createElementNode(lEmptyItem, lNodeName, |
3416 | - lFactory->createQName(XML_SCHEMA_NS, |
3417 | - XML_SCHEMA_PREFIX, "untyped"), |
3418 | - true, false, nsPairs); |
3419 | - lFactory->createAttributeNode(lRequestElement, lFactory->createQName("", "method"), Item(), lFactory->createString("GET")); |
3420 | + nsPairs.push_back(std::make_pair(String(XML_SCHEMA_PREFIX), |
3421 | + String(static_context::W3C_XML_SCHEMA_NS))); |
3422 | + |
3423 | + Item lRequestElement = |
3424 | + lFactory->createElementNode(lEmptyItem, lNodeName, |
3425 | + lFactory->createQName(static_context::W3C_XML_SCHEMA_NS, |
3426 | + "", "untyped"), |
3427 | + true, false, nsPairs); |
3428 | + |
3429 | + lFactory->createAttributeNode(lRequestElement, |
3430 | + lFactory->createQName("", "method"), |
3431 | + Item(), |
3432 | + lFactory->createString("GET")); |
3433 | + |
3434 | lFactory->createAttributeNode(lRequestElement, lFactory->createQName("", "href"), Item(), lFactory->createString(theUri.c_str())); |
3435 | + |
3436 | lFactory->createAttributeNode(lRequestElement, lFactory->createQName("", "override-media-type"), Item(), lFactory->createString("text/plain")); |
3437 | + |
3438 | lFactory->createAttributeNode(lRequestElement, lFactory->createQName("", "follow-redirect"), Item(), lFactory->createString("true")); |
3439 | + |
3440 | Zorba_CompilerHints_t lHints; |
3441 | lHints.opt_level = ZORBA_OPT_LEVEL_O1; |
3442 | theStaticContext->loadProlog("import module namespace httpc = \"http://www.zorba-xquery.com/modules/http-client\";", |
3443 | |
3444 | === modified file 'src/zorbamisc/ns_consts.h' |
3445 | --- src/zorbamisc/ns_consts.h 2013-06-25 04:47:15 +0000 |
3446 | +++ src/zorbamisc/ns_consts.h 2013-07-11 13:41:52 +0000 |
3447 | @@ -29,13 +29,10 @@ |
3448 | |
3449 | #define XMLNS_NS W3C_NS "2000/xmlns/" |
3450 | |
3451 | -#define XML_NS W3C_NS "XML/1998/namespace" |
3452 | -#define XML_SCHEMA_NS W3C_NS "2001/XMLSchema" |
3453 | #define XML_SCHEMA_PREFIX "xs" |
3454 | |
3455 | #define XQUERY_ERR_NS W3C_NS "2005/xqt-errors" //not predeclared in XQuery 3.0 |
3456 | #define XQUERY_LOCAL_FN_NS W3C_NS "2005/xquery-local-functions" |
3457 | -#define XQUERY_XPATH_FN_NS W3C_NS "2005/xpath-functions" |
3458 | |
3459 | #define XSI_NS W3C_NS "2001/XMLSchema-instance" |
3460 | |
3461 | |
3462 | === modified file 'src/zorbaserialization/archiver_consts.h' |
3463 | --- src/zorbaserialization/archiver_consts.h 2013-06-15 02:57:08 +0000 |
3464 | +++ src/zorbaserialization/archiver_consts.h 2013-07-11 13:41:52 +0000 |
3465 | @@ -378,7 +378,8 @@ |
3466 | TYPE_DebuggerSingletonIterator, |
3467 | TYPE_DebuggerCommons, |
3468 | |
3469 | - TYPE_RCObject, |
3470 | + TYPE_SyncedRCObject, |
3471 | + TYPE_SimpleRCObject, |
3472 | |
3473 | TYPE_INT64, |
3474 | TYPE_UINT64, |
3475 | |
3476 | === modified file 'src/zorbaserialization/serialize_zorba_types.cpp' |
3477 | --- src/zorbaserialization/serialize_zorba_types.cpp 2013-06-30 10:20:25 +0000 |
3478 | +++ src/zorbaserialization/serialize_zorba_types.cpp 2013-07-11 13:41:52 +0000 |
3479 | @@ -1203,7 +1203,7 @@ |
3480 | // store::simplestore::ElementNode *elem_node = dynamic_cast<store::simplestore::ElementNode*>(obj); |
3481 | // haveTypedValue = elem_node->haveTypedValue(); |
3482 | // haveEmptyValue = elem_node->haveEmptyValue(); |
3483 | - if (!ZSTREQ(name_of_type->getNamespace(), XML_SCHEMA_NS) || |
3484 | + if (name_of_type->getNamespace() != static_context::W3C_XML_SCHEMA_NS || |
3485 | !ZSTREQ(name_of_type->getLocalName(), "untyped")) |
3486 | haveTypedValue = true; |
3487 | } |
3488 | |
3489 | === modified file 'src/zorbatypes/rchandle.cpp' |
3490 | --- src/zorbatypes/rchandle.cpp 2013-02-26 04:12:43 +0000 |
3491 | +++ src/zorbatypes/rchandle.cpp 2013-07-11 13:41:52 +0000 |
3492 | @@ -39,12 +39,15 @@ |
3493 | |
3494 | ********************************************************************************/ |
3495 | |
3496 | -SERIALIZABLE_CLASS_VERSIONS(RCObject) |
3497 | - |
3498 | -SERIALIZABLE_CLASS_VERSIONS_2(SimpleRCObject, TYPE_RCObject) |
3499 | - |
3500 | - |
3501 | -void RCObject::serialize(::zorba::serialization::Archiver& ar) |
3502 | +SERIALIZABLE_CLASS_VERSIONS(SyncedRCObject) |
3503 | + |
3504 | +SERIALIZABLE_CLASS_VERSIONS_2(SimpleRCObject, TYPE_SimpleRCObject) |
3505 | + |
3506 | + |
3507 | +/******************************************************************************* |
3508 | + |
3509 | +********************************************************************************/ |
3510 | +void SyncedRCObject::serialize(::zorba::serialization::Archiver& ar) |
3511 | { |
3512 | ZORBA_ASSERT(false); |
3513 | |
3514 | @@ -53,67 +56,6 @@ |
3515 | } |
3516 | |
3517 | |
3518 | -void RCObject::addReference(SYNC_CODE(RCLock* lock)) const |
3519 | -{ |
3520 | -#if defined WIN32 && !defined CYGWIN &&!defined ZORBA_FOR_ONE_THREAD_ONLY |
3521 | - if(lock) |
3522 | - { |
3523 | - InterlockedIncrement(&theRefCount); |
3524 | - } |
3525 | - else |
3526 | - { |
3527 | - ++theRefCount; |
3528 | - } |
3529 | - |
3530 | -#else |
3531 | - |
3532 | - SYNC_CODE(if (lock) lock->acquire()); |
3533 | - |
3534 | - ++theRefCount; |
3535 | - |
3536 | - SYNC_CODE(if (lock) lock->release()); |
3537 | - |
3538 | -#endif |
3539 | -} |
3540 | - |
3541 | - |
3542 | -void RCObject::removeReference(SYNC_CODE(RCLock* lock)) |
3543 | -{ |
3544 | -#if defined WIN32 && !defined CYGWIN &&!defined ZORBA_FOR_ONE_THREAD_ONLY |
3545 | - if (lock) |
3546 | - { |
3547 | - if (!InterlockedDecrement(&theRefCount)) |
3548 | - { |
3549 | - free(); |
3550 | - return; |
3551 | - } |
3552 | - } |
3553 | - else |
3554 | - { |
3555 | - if (--theRefCount == 0) |
3556 | - { |
3557 | - free(); |
3558 | - return; |
3559 | - } |
3560 | - } |
3561 | - |
3562 | -#else |
3563 | - |
3564 | - SYNC_CODE(if (lock) lock->acquire()); |
3565 | - |
3566 | - if (--theRefCount == 0) |
3567 | - { |
3568 | - SYNC_CODE(if (lock) lock->release()); |
3569 | - free(); |
3570 | - return; |
3571 | - } |
3572 | - |
3573 | - SYNC_CODE(if (lock) lock->release()); |
3574 | - |
3575 | -#endif |
3576 | -} |
3577 | - |
3578 | - |
3579 | /******************************************************************************* |
3580 | |
3581 | ********************************************************************************/ |
3582 | @@ -125,11 +67,13 @@ |
3583 | theRefCount = 0; |
3584 | } |
3585 | |
3586 | + |
3587 | size_t SimpleRCObject::alloc_size() const |
3588 | { |
3589 | return 0; |
3590 | } |
3591 | |
3592 | + |
3593 | size_t SimpleRCObject::dynamic_size() const |
3594 | { |
3595 | return sizeof( *this ); |
3596 | |
3597 | === modified file 'src/zorbatypes/rchandle.h' |
3598 | --- src/zorbatypes/rchandle.h 2013-02-26 04:12:43 +0000 |
3599 | +++ src/zorbatypes/rchandle.h 2013-07-11 13:41:52 +0000 |
3600 | @@ -26,7 +26,7 @@ |
3601 | |
3602 | #include "zorbautils/fatal.h" |
3603 | |
3604 | -#include "zorbatypes/rclock.h" |
3605 | +#include "util/atomic_int.h" |
3606 | |
3607 | #include "zorbaserialization/class_serializer.h" |
3608 | |
3609 | @@ -53,15 +53,19 @@ |
3610 | reference count becomes 0. |
3611 | |
3612 | ********************************************************************************/ |
3613 | -class ZORBA_DLL_PUBLIC RCObject : public serialization::SerializeBaseClass |
3614 | +class SyncedRCObject : public serialization::SerializeBaseClass |
3615 | { |
3616 | protected: |
3617 | - mutable long theRefCount; |
3618 | +#ifdef ZORBA_FOR_ONE_THREAD_ONLY |
3619 | + mutable long theRefCount; |
3620 | +#else |
3621 | + mutable atomic_int theRefCount; |
3622 | +#endif |
3623 | |
3624 | public: |
3625 | - SERIALIZABLE_CLASS(RCObject); |
3626 | + SERIALIZABLE_CLASS(SyncedRCObject); |
3627 | |
3628 | - RCObject(::zorba::serialization::Archiver& ar) |
3629 | + SyncedRCObject(::zorba::serialization::Archiver& ar) |
3630 | : |
3631 | ::zorba::serialization::SerializeBaseClass(), |
3632 | theRefCount(0) |
3633 | @@ -71,38 +75,48 @@ |
3634 | void serialize(::zorba::serialization::Archiver& ar); |
3635 | |
3636 | public: |
3637 | - RCObject() |
3638 | + SyncedRCObject() |
3639 | : |
3640 | ::zorba::serialization::SerializeBaseClass(), |
3641 | theRefCount(0) |
3642 | { |
3643 | } |
3644 | |
3645 | - RCObject(const RCObject&) |
3646 | + SyncedRCObject(const SyncedRCObject&) |
3647 | : |
3648 | ::zorba::serialization::SerializeBaseClass(), |
3649 | theRefCount(0) |
3650 | { |
3651 | } |
3652 | |
3653 | - virtual ~RCObject() { } |
3654 | + virtual ~SyncedRCObject() { } |
3655 | |
3656 | - RCObject& operator=(const RCObject&) { return *this; } |
3657 | + SyncedRCObject& operator=(const SyncedRCObject&) { return *this; } |
3658 | |
3659 | virtual void free() { delete this; } |
3660 | |
3661 | +#ifdef ZORBA_FOR_ONE_THREAD_ONLY |
3662 | long getRefCount() const { return theRefCount; } |
3663 | - |
3664 | - void addReference(SYNC_CODE(RCLock* lock)) const; |
3665 | - |
3666 | - void removeReference(SYNC_CODE(RCLock* lock)); |
3667 | +#else |
3668 | + long getRefCount() const { return theRefCount.load(); } |
3669 | +#endif |
3670 | + |
3671 | + void addReference() const { ++theRefCount; } |
3672 | + |
3673 | + void removeReference() |
3674 | + { |
3675 | + assert(getRefCount() > 0); |
3676 | + |
3677 | + if (--theRefCount == 0) |
3678 | + free(); |
3679 | + } |
3680 | }; |
3681 | |
3682 | |
3683 | /******************************************************************************* |
3684 | |
3685 | ********************************************************************************/ |
3686 | -class ZORBA_DLL_PUBLIC SimpleRCObject : public serialization::SerializeBaseClass |
3687 | +class SimpleRCObject : public serialization::SerializeBaseClass |
3688 | { |
3689 | protected: |
3690 | mutable long theRefCount; |
3691 | @@ -145,17 +159,15 @@ |
3692 | |
3693 | long getRefCount() const { return theRefCount; } |
3694 | |
3695 | - void addReference(SYNC_CODE(RCLock* lock)) const { ++theRefCount; } |
3696 | + void addReference() const { ++theRefCount; } |
3697 | |
3698 | - void removeReference(SYNC_CODE(RCLock* lock)) |
3699 | + void removeReference() |
3700 | { |
3701 | + assert(getRefCount() > 0); |
3702 | + |
3703 | if (--theRefCount == 0) |
3704 | - { |
3705 | free(); |
3706 | - } |
3707 | } |
3708 | - |
3709 | - SYNC_CODE(RCLock* getRCLock() const { return NULL; }) |
3710 | }; |
3711 | |
3712 | |
3713 | @@ -200,7 +212,7 @@ |
3714 | ~rchandle() |
3715 | { |
3716 | if (p) |
3717 | - p->removeReference(SYNC_CODE(p->getRCLock())); |
3718 | + p->removeReference(); |
3719 | p = 0; |
3720 | } |
3721 | |
3722 | @@ -255,8 +267,11 @@ |
3723 | { |
3724 | if (p != rhs) |
3725 | { |
3726 | - if (p) p->removeReference(SYNC_CODE(p->getRCLock())); |
3727 | + if (p) |
3728 | + p->removeReference(); |
3729 | + |
3730 | p = const_cast<T*>(rhs); |
3731 | + |
3732 | init(); |
3733 | } |
3734 | return *this; |
3735 | @@ -266,8 +281,11 @@ |
3736 | { |
3737 | if (p != rhs) |
3738 | { |
3739 | - if (p) p->removeReference(SYNC_CODE(p->getRCLock())); |
3740 | + if (p) |
3741 | + p->removeReference(); |
3742 | + |
3743 | p = static_cast<T*>(const_cast<otherT*>(rhs)); |
3744 | + |
3745 | init(); |
3746 | } |
3747 | return *this; |
3748 | @@ -287,8 +305,11 @@ |
3749 | { |
3750 | if (p != rhs.getp()) |
3751 | { |
3752 | - if (p) p->removeReference(SYNC_CODE(p->getRCLock())); |
3753 | + if (p) |
3754 | + p->removeReference(); |
3755 | + |
3756 | p = static_cast<T*>(rhs.getp()); |
3757 | + |
3758 | rhs.setNull(); |
3759 | } |
3760 | return *this; |
3761 | @@ -298,7 +319,9 @@ |
3762 | { |
3763 | if (p != rhs.p) |
3764 | { |
3765 | - if (p) p->removeReference(SYNC_CODE(p->getRCLock())); |
3766 | + if (p) |
3767 | + p->removeReference(); |
3768 | + |
3769 | p = rhs.p; |
3770 | rhs.p = NULL; |
3771 | } |
3772 | @@ -323,8 +346,8 @@ |
3773 | protected: |
3774 | void init() |
3775 | { |
3776 | - if (p == 0) return; |
3777 | - p->addReference(SYNC_CODE(p->getRCLock())); |
3778 | + if (p) |
3779 | + p->addReference(); |
3780 | } |
3781 | |
3782 | |
3783 | @@ -332,8 +355,11 @@ |
3784 | { |
3785 | if (p != rhs.getp()) |
3786 | { |
3787 | - if (p) p->removeReference(SYNC_CODE(p->getRCLock())); |
3788 | + if (p) |
3789 | + p->removeReference(); |
3790 | + |
3791 | p = static_cast<T*>(rhs.getp()); |
3792 | + |
3793 | init(); |
3794 | } |
3795 | return *this; |
3796 | @@ -363,22 +389,24 @@ |
3797 | |
3798 | } // namespace ztd |
3799 | |
3800 | + |
3801 | /******************************************************************************* |
3802 | |
3803 | ********************************************************************************/ |
3804 | template<class T> class const_rchandle : protected rchandle<T> |
3805 | { |
3806 | public: |
3807 | - const_rchandle (const T *_p = 0) : rchandle<T> (const_cast<T *> (_p)) {} |
3808 | - |
3809 | - const_rchandle (const const_rchandle &rhs) : rchandle<T> (rhs) {} |
3810 | - |
3811 | - const_rchandle (rchandle<T> &rhs) : rchandle<T> (rhs) {} |
3812 | - |
3813 | - const_rchandle(::zorba::serialization::Archiver &ar) {} |
3814 | - |
3815 | - const_rchandle& operator= (const const_rchandle &rhs) { |
3816 | - this->assign (rhs); |
3817 | + const_rchandle(const T* _p = 0) : rchandle<T>(const_cast<T *>(_p)) {} |
3818 | + |
3819 | + const_rchandle(const const_rchandle& rhs) : rchandle<T>(rhs) {} |
3820 | + |
3821 | + const_rchandle(rchandle<T>& rhs) : rchandle<T>(rhs) {} |
3822 | + |
3823 | + const_rchandle(::zorba::serialization::Archiver& ar) {} |
3824 | + |
3825 | + const_rchandle& operator= (const const_rchandle& rhs) |
3826 | + { |
3827 | + this->assign(rhs); |
3828 | return *this; |
3829 | } |
3830 | |
3831 | @@ -387,20 +415,20 @@ |
3832 | |
3833 | void setNull() { rchandle<T>::setNull();} |
3834 | |
3835 | - const T* getp () const { return rchandle<T>::getp (); } |
3836 | + const T* getp() const { return rchandle<T>::getp (); } |
3837 | |
3838 | typename rchandle<T>::union_T getp_ref() { return rchandle<T>::getp_ref(); } |
3839 | |
3840 | - operator const T * () const { return rchandle<T>::getp (); } |
3841 | + operator const T* () const { return rchandle<T>::getp(); } |
3842 | |
3843 | const T* operator->() const { return getp(); } |
3844 | const T& operator*() const { return *getp(); } |
3845 | |
3846 | - bool operator== (const_rchandle h) const { return rchandle<T>::operator== (h); } |
3847 | - bool operator!= (const_rchandle h) const { return rchandle<T>::operator!= (h); } |
3848 | - bool operator== (const T * pp) const { return rchandle<T>::operator== (pp); } |
3849 | - bool operator!= (const T * pp) const { return rchandle<T>::operator!= (pp); } |
3850 | - bool operator< (const_rchandle h) const { return rchandle<T>::operator< (h); } |
3851 | + bool operator== (const_rchandle h) const { return rchandle<T>::operator==(h); } |
3852 | + bool operator!= (const_rchandle h) const { return rchandle<T>::operator!=(h); } |
3853 | + bool operator== (const T* pp) const { return rchandle<T>::operator==(pp); } |
3854 | + bool operator!= (const T* pp) const { return rchandle<T>::operator!=(pp); } |
3855 | + bool operator< (const_rchandle h) const { return rchandle<T>::operator<(h); } |
3856 | }; |
3857 | |
3858 | |
3859 | @@ -413,13 +441,13 @@ |
3860 | template<class T> |
3861 | static void addReference(T *t) |
3862 | { |
3863 | - t->addReference(SYNC_CODE(t->getRCLock())); |
3864 | + t->addReference(); |
3865 | } |
3866 | |
3867 | template<class T> |
3868 | static void removeReference(T *t) |
3869 | { |
3870 | - t->removeReference(SYNC_CODE(t->getRCLock())); |
3871 | + t->removeReference(); |
3872 | } |
3873 | |
3874 | template<class T> |
3875 | |
3876 | === modified file 'test/driver/testdriver_common.cpp' |
3877 | --- test/driver/testdriver_common.cpp 2013-05-16 08:22:46 +0000 |
3878 | +++ test/driver/testdriver_common.cpp 2013-07-11 13:41:52 +0000 |
3879 | @@ -280,7 +280,8 @@ |
3880 | bool enableDtd, |
3881 | zorba::DiagnosticHandler& errHandler) |
3882 | { |
3883 | - try { |
3884 | + try |
3885 | + { |
3886 | zorba::Zorba* engine = driverCtx.theEngine; |
3887 | Specification& spec = *driverCtx.theSpec; |
3888 | zorba::ItemFactory& factory = *engine->getItemFactory(); |
3889 | @@ -336,7 +337,8 @@ |
3890 | dctx->setVariable(zorba::String("x"), riter); |
3891 | } |
3892 | } |
3893 | - catch (zorba::ZorbaException const& e) { |
3894 | + catch (zorba::ZorbaException const& e) |
3895 | + { |
3896 | errHandler.error(e); |
3897 | } |
3898 | } |
3899 | @@ -457,6 +459,7 @@ |
3900 | } |
3901 | } |
3902 | |
3903 | + |
3904 | /** |
3905 | * Set all options on the provided static context. |
3906 | */ |
3907 | @@ -467,7 +470,8 @@ |
3908 | for (lIter = spec.optionsBegin(); lIter != spec.optionsEnd(); ++lIter) |
3909 | { |
3910 | zorba::Item lQName = driverCtx.theEngine->getItemFactory()-> |
3911 | - createQName(lIter->theOptName); |
3912 | + createQName(lIter->theOptName); |
3913 | + |
3914 | std::string lValue = lIter->theOptValue; |
3915 | sctx->declareOption(lQName, lValue); |
3916 | } |
3917 | @@ -475,41 +479,47 @@ |
3918 | if ( spec.getEnableDtd() ) |
3919 | { |
3920 | zorba::Item lQName = driverCtx.theEngine->getItemFactory()-> |
3921 | - createQName( |
3922 | - "http://www.zorba-xquery.com/options/features", "", "enable"); |
3923 | + createQName("http://www.zorba-xquery.com/options/features", "", "enable"); |
3924 | + |
3925 | sctx->declareOption(lQName, "dtd"); |
3926 | } |
3927 | } |
3928 | |
3929 | + |
3930 | /** |
3931 | * Register a URIMapper on the provided static context, and save it |
3932 | * in the DriverContext for later reference. |
3933 | */ |
3934 | -void addURIMapper |
3935 | -(DriverContext& driverCtx, const zorba::StaticContext_t& sctx, |
3936 | - zorba::URIMapper* mapper) |
3937 | +void addURIMapper( |
3938 | + DriverContext& driverCtx, |
3939 | + const zorba::StaticContext_t& sctx, |
3940 | + zorba::URIMapper* mapper) |
3941 | { |
3942 | sctx->registerURIMapper(mapper); |
3943 | driverCtx.theURIMappers.push_back(mapper); |
3944 | } |
3945 | |
3946 | + |
3947 | /** |
3948 | * Register a URLResolver on the provided static context, and save it |
3949 | * in the DriverContext for later reference. |
3950 | */ |
3951 | -void addURLResolver |
3952 | -(DriverContext& driverCtx, const zorba::StaticContext_t& sctx, |
3953 | - zorba::URLResolver* resolver) |
3954 | +void addURLResolver( |
3955 | + DriverContext& driverCtx, |
3956 | + const zorba::StaticContext_t& sctx, |
3957 | + zorba::URLResolver* resolver) |
3958 | { |
3959 | sctx->registerURLResolver(resolver); |
3960 | driverCtx.theURLResolvers.push_back(resolver); |
3961 | } |
3962 | |
3963 | + |
3964 | /** |
3965 | * Set all full-text URI mappers on the provided static context. |
3966 | */ |
3967 | -void setFullTextURIMappers |
3968 | -(DriverContext& driverCtx, const zorba::StaticContext_t& sctx) |
3969 | +void setFullTextURIMappers( |
3970 | + DriverContext& driverCtx, |
3971 | + const zorba::StaticContext_t& sctx) |
3972 | { |
3973 | #ifndef ZORBA_NO_FULL_TEXT |
3974 | Specification& spec = * (driverCtx.theSpec); |
3975 | @@ -522,8 +532,7 @@ |
3976 | /** |
3977 | * Set the module paths based on a :- or ;-separated list of paths. |
3978 | */ |
3979 | -void setModulePaths |
3980 | -(std::string paths, zorba::StaticContext_t& sctx) |
3981 | +void setModulePaths(std::string paths, zorba::StaticContext_t& sctx) |
3982 | { |
3983 | std::vector<zorba::String> lModulePaths; |
3984 | std::string lPath; |
3985 | @@ -533,15 +542,19 @@ |
3986 | char lDelim = ':'; |
3987 | #endif |
3988 | |
3989 | - while (zorba::ztd::split(paths, lDelim, &lPath, &paths)) { |
3990 | + while (zorba::ztd::split(paths, lDelim, &lPath, &paths)) |
3991 | + { |
3992 | lModulePaths.push_back(lPath); |
3993 | } |
3994 | + |
3995 | lModulePaths.push_back(paths); |
3996 | |
3997 | // Add the default paths for test modules. |
3998 | zorba::String lDefPath = zorba::CMAKE_BINARY_DIR + "/TEST_URI_PATH"; |
3999 | lModulePaths.push_back(lDefPath); |
4000 | + |
4001 | lDefPath = zorba::CMAKE_BINARY_DIR + "/TEST_LIB_PATH"; |
4002 | lModulePaths.push_back(lDefPath); |
4003 | + |
4004 | sctx->setModulePaths(lModulePaths); |
4005 | } |
4006 | |
4007 | === modified file 'test/driver/testdriver_common.h' |
4008 | --- test/driver/testdriver_common.h 2013-05-16 08:22:46 +0000 |
4009 | +++ test/driver/testdriver_common.h 2013-07-11 13:41:52 +0000 |
4010 | @@ -93,10 +93,11 @@ |
4011 | << "[line " << xe->source_line() << "]" |
4012 | << "[column " << xe->source_column() << "]" |
4013 | << "[file " << xe->source_uri() << "]"; |
4014 | - if(zorba::UserException const *ue = dynamic_cast<zorba::UserException const*>(&e)) |
4015 | + |
4016 | + if (zorba::UserException const *ue = dynamic_cast<zorba::UserException const*>(&e)) |
4017 | { |
4018 | zorba::UserException::error_object_type const & err_objs = ue->error_object(); |
4019 | - if(!err_objs.empty()) |
4020 | + if (!err_objs.empty()) |
4021 | { |
4022 | strdescr << " and ..." << std::endl << "User parameters:"; |
4023 | for(size_t i=0;i<err_objs.size();i++) |
4024 | |
4025 | === modified file 'test/driver/testdriver_mt.cpp' |
4026 | --- test/driver/testdriver_mt.cpp 2013-06-25 07:47:47 +0000 |
4027 | +++ test/driver/testdriver_mt.cpp 2013-07-11 13:41:52 +0000 |
4028 | @@ -58,70 +58,112 @@ |
4029 | std::string module_path; |
4030 | |
4031 | /******************************************************************************* |
4032 | - theQueriesDir : The full pathname of the dir that contains the queries |
4033 | - to run. It is created by appending the user-provided |
4034 | - bucket name to RBKT_SRC_DIR/Queries (for example, |
4035 | - RBKT_SRC_DIR/Queries/w3c_testsuite/Expressions). |
4036 | - theRefsDir : The full pathname of the dir that contains the expected |
4037 | - results of the queries. It is created by appending the |
4038 | - user-provided bucket name to RBKT_SRC_DIR/ExpQueryResults. |
4039 | - theResultsDir : The full pathname of the directory under which the result |
4040 | - and error files of the queries will be placed. It is |
4041 | - created by appending the user-provided bucket name to |
4042 | - RBKT_BINARY_DIR/QueryResults. |
4043 | - |
4044 | - theQueryFilenames : The relative pathnames of the queries found under |
4045 | - theQueriesDir. The pathname are relative to theQueriesDir. |
4046 | - |
4047 | - theNumQueries : The number of queries found under theQueriesDir. |
4048 | - |
4049 | - theNumRunsPerQuery : The number of times to run each query. |
4050 | - |
4051 | - theNumQueryRuns : How many times has each query being run so far. |
4052 | - |
4053 | - theQueryObjects : Pointers to the compiled query object for each query. |
4054 | - |
4055 | - theQueryStates : For each query, whether the query was run successfuly or not. |
4056 | - |
4057 | - theQueryLocks : |
4058 | - theGlobalLock : |
4059 | + |
4060 | + theQueriesDir |
4061 | + ------------- |
4062 | + The full pathname of the dir that contains the queries to run. It is a path |
4063 | + of the form <bucket-path>/Queries/<bucket-name>, where <bucket-path> is either |
4064 | + a user-provided absolute dir path, or RBKT_BINARY_DIR and <bucket-name> is a |
4065 | + user-provided bucket name (actually a relative dir path, which may also be |
4066 | + empty). |
4067 | + |
4068 | + theRefsDir |
4069 | + ---------- |
4070 | + The full pathname of the dir that contains the expected results of the queries. |
4071 | + It is a path of the form <bucket-path>/ExpQueryResults/<bucket-name>, where |
4072 | + <bucket-path> is either a user-provided absolute dir path, or RBKT_BINARY_DIR |
4073 | + and <bucket-name> is a user-provided bucket name (actually a relative dir path, |
4074 | + which may also be empty). |
4075 | + |
4076 | + theResultsDir |
4077 | + ------------- |
4078 | + The full pathname of the directory under which the result and error files of |
4079 | + the queries will be placed. It is a path of the form |
4080 | + RBKT_BINARY_DIR/QueryResults/<bucket-name>. |
4081 | + |
4082 | + theIsW3Cbucket |
4083 | + -------------- |
4084 | + Whether the user-provided bucket is inside W3C XQTS. |
4085 | + |
4086 | + theQueryFilenames |
4087 | + ----------------- |
4088 | + The relative pathnames of the queries found under theQueriesDir. The pathnames |
4089 | + are relative to theQueriesDir. |
4090 | + |
4091 | + theNumQueries |
4092 | + ------------- |
4093 | + The number of queries found under theQueriesDir. |
4094 | + |
4095 | + theNumRunsPerQuery |
4096 | + ------------------ |
4097 | + The number of times to run each query. |
4098 | + |
4099 | + theNumThreads |
4100 | + ------------- |
4101 | + The number of threads to use. |
4102 | + |
4103 | + theOutput |
4104 | + --------- |
4105 | + The stream where the output should go to. |
4106 | + |
4107 | + |
4108 | + theNumQueryRuns |
4109 | + --------------- |
4110 | + How many times has each query being run so far. |
4111 | + |
4112 | + theQueryStates |
4113 | + -------------- |
4114 | + For each query, whether the query was run successfuly or not. |
4115 | + |
4116 | + theQueryLocks : |
4117 | + --------------- |
4118 | + One lock per query. It is needed to protect theQueryObjects[queryNo] position. |
4119 | + |
4120 | + theGlobalLock : |
4121 | + --------------- |
4122 | + Acquired while the next query to be run is selected and locked by each thread. |
4123 | |
4124 | ********************************************************************************/ |
4125 | class Queries |
4126 | { |
4127 | public: |
4128 | std::string theQueriesDir; |
4129 | + |
4130 | std::string theRefsDir; |
4131 | + |
4132 | std::string theResultsDir; |
4133 | |
4134 | + bool theIsW3Cbucket; |
4135 | + |
4136 | std::vector<std::string> theQueryFilenames; |
4137 | |
4138 | - bool theIsW3Cbucket; |
4139 | - |
4140 | long theNumQueries; |
4141 | |
4142 | long theNumRunsPerQuery; |
4143 | |
4144 | + long theNumThreads; |
4145 | + |
4146 | + std::ostream& theOutput; |
4147 | + |
4148 | + |
4149 | std::vector<long> theNumQueryRuns; |
4150 | |
4151 | - std::vector<zorba::XQuery_t> theQueryObjects; |
4152 | - |
4153 | std::vector<bool> theQueryStates; |
4154 | |
4155 | - long theNumThreads; |
4156 | - |
4157 | - std::ostream& theOutput; |
4158 | - |
4159 | std::vector<zorba::Mutex*> theQueryLocks; |
4160 | + |
4161 | zorba::Mutex theGlobalLock; |
4162 | |
4163 | public: |
4164 | - Queries(std::ostream& lOutput) |
4165 | + Queries(std::ostream& output) |
4166 | : |
4167 | + theIsW3Cbucket(false), |
4168 | + theNumQueries(0), |
4169 | theNumRunsPerQuery(1), |
4170 | theNumThreads(1), |
4171 | - theOutput(lOutput) |
4172 | - {} |
4173 | + theOutput(output) |
4174 | + { |
4175 | + } |
4176 | |
4177 | ~Queries(); |
4178 | |
4179 | @@ -131,47 +173,55 @@ |
4180 | }; |
4181 | |
4182 | |
4183 | +/******************************************************************************* |
4184 | + |
4185 | +********************************************************************************/ |
4186 | Queries::~Queries() |
4187 | { |
4188 | clear(); |
4189 | } |
4190 | |
4191 | |
4192 | +/******************************************************************************* |
4193 | + |
4194 | +********************************************************************************/ |
4195 | void Queries::clear() |
4196 | { |
4197 | for (long i = 0; i < theNumQueries; i++) |
4198 | { |
4199 | - theQueryObjects[i] = NULL; |
4200 | delete theQueryLocks[i]; |
4201 | } |
4202 | |
4203 | theQueryFilenames.clear(); |
4204 | theNumQueryRuns.clear(); |
4205 | - theQueryObjects.clear(); |
4206 | + theQueryStates.clear(); |
4207 | |
4208 | theNumQueries = 0; |
4209 | } |
4210 | |
4211 | |
4212 | +/******************************************************************************* |
4213 | + Invoked under the protection of theGlobalLock. |
4214 | +********************************************************************************/ |
4215 | long Queries::getQuery() |
4216 | { |
4217 | - static long nextQuery = 0; |
4218 | + static long currQuery = 0; |
4219 | |
4220 | if (theNumThreads == 1) |
4221 | { |
4222 | - if (nextQuery == theNumQueries) |
4223 | + if (currQuery == theNumQueries) |
4224 | return -1; |
4225 | |
4226 | - if (theNumQueryRuns[nextQuery] == theNumRunsPerQuery) |
4227 | + if (theNumQueryRuns[currQuery] == theNumRunsPerQuery) |
4228 | { |
4229 | - ++nextQuery; |
4230 | + ++currQuery; |
4231 | |
4232 | - if (nextQuery == theNumQueries) |
4233 | + if (currQuery == theNumQueries) |
4234 | return -1; |
4235 | } |
4236 | |
4237 | - theNumQueryRuns[nextQuery]++; |
4238 | - return nextQuery; |
4239 | + theNumQueryRuns[currQuery]++; |
4240 | + return currQuery; |
4241 | } |
4242 | |
4243 | long randomNum = rand(); |
4244 | @@ -236,48 +286,60 @@ |
4245 | void createPath(const fs::path& filePath, std::ofstream& fileStream) |
4246 | { |
4247 | #if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4248 | + |
4249 | fileStream.open(filePath.file_string().c_str()); |
4250 | + |
4251 | + if (!fileStream.good()) |
4252 | + { |
4253 | + fs::path dirPath = filePath; |
4254 | + dirPath = dirPath.remove_leaf(); |
4255 | + |
4256 | + if (!fs::exists(dirPath.file_string())) |
4257 | + { |
4258 | + fs::create_directories(dirPath.file_string()); |
4259 | + |
4260 | + // clear the bad flag on windows, which for some unknown reason doesn't |
4261 | + // reset when opening a file again |
4262 | + fileStream.clear(); |
4263 | + |
4264 | + fileStream.open(filePath.file_string().c_str()); |
4265 | + } |
4266 | + |
4267 | + if (!fileStream.good()) |
4268 | + { |
4269 | + std::cerr << "Could not open file: " |
4270 | + << filePath.file_string() << std::endl; |
4271 | + abort(); |
4272 | + } |
4273 | + } |
4274 | + |
4275 | #else |
4276 | + |
4277 | fileStream.open(filePath.generic_string().c_str()); |
4278 | -#endif |
4279 | + |
4280 | if (!fileStream.good()) |
4281 | { |
4282 | fs::path dirPath = filePath; |
4283 | dirPath = dirPath.remove_leaf(); |
4284 | |
4285 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4286 | - if (!fs::exists(dirPath.file_string())) |
4287 | -#else |
4288 | if (!fs::exists(dirPath.generic_string())) |
4289 | -#endif |
4290 | { |
4291 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4292 | - fs::create_directories(dirPath.file_string()); |
4293 | -#else |
4294 | fs::create_directories(dirPath.generic_string()); |
4295 | -#endif |
4296 | |
4297 | // clear the bad flag on windows, which for some unknown reason doesn't |
4298 | // reset when opening a file again |
4299 | fileStream.clear(); |
4300 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4301 | - fileStream.open(filePath.file_string().c_str()); |
4302 | -#else |
4303 | fileStream.open(filePath.generic_string().c_str()); |
4304 | -#endif |
4305 | } |
4306 | |
4307 | if (!fileStream.good()) |
4308 | { |
4309 | std::cerr << "Could not open file: " |
4310 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4311 | - << filePath.file_string() << std::endl; |
4312 | -#else |
4313 | << filePath.generic_string() << std::endl; |
4314 | -#endif |
4315 | abort(); |
4316 | } |
4317 | } |
4318 | +#endif |
4319 | } |
4320 | |
4321 | |
4322 | @@ -338,18 +400,16 @@ |
4323 | |
4324 | ulong numCanon = 0; |
4325 | |
4326 | - long queryNo; |
4327 | - |
4328 | std::string w3cDataDir = "/Queries/w3c_testsuite/TestSources/"; |
4329 | std::string uri_map_file = rbkt_src_dir + w3cDataDir + "uri.txt"; |
4330 | std::string mod_map_file = rbkt_src_dir + w3cDataDir + "module.txt"; |
4331 | std::string col_map_file = rbkt_src_dir + w3cDataDir + "collection.txt"; |
4332 | |
4333 | - std::auto_ptr<zorba::TestSchemaURIMapper> smapper |
4334 | - (new zorba::TestSchemaURIMapper(uri_map_file.c_str(), false)); |
4335 | + std::auto_ptr<zorba::TestSchemaURIMapper> smapper; |
4336 | std::auto_ptr<zorba::TestModuleURIMapper> mmapper; |
4337 | - std::auto_ptr<zorba::TestCollectionURIMapper> cmapper; |
4338 | - std::auto_ptr<zorba::TestSchemeURIMapper> dmapper; |
4339 | + std::auto_ptr<zorba::TestCollectionURIMapper> cmapper; |
4340 | + |
4341 | + std::auto_ptr<zorba::TestSchemeURIMapper> dmapper; |
4342 | std::auto_ptr<zorba::TestURLResolver> tresolver; |
4343 | |
4344 | while (1) |
4345 | @@ -374,34 +434,23 @@ |
4346 | driverContext.theRbktBinaryDir = rbkt_bin_dir; |
4347 | driverContext.theSpec = &querySpec; |
4348 | |
4349 | - zorba::XQuery_t query; |
4350 | - |
4351 | // Choose a query to run. If no query is available, the thread finishes. |
4352 | // To choose the next query, the whole query container must be locked. |
4353 | // After the query is chosen, we release the global container lock and |
4354 | - // acquire the query-specific lock for the chosen query. The query lock |
4355 | - // is needed to protect the queries->theQueryObjects[queryNo] position and |
4356 | - // to make sure that the query will be compiled only once. |
4357 | + // acquire the query-specific lock for the chosen query. |
4358 | queries->theGlobalLock.lock(); |
4359 | |
4360 | - queryNo = queries->getQuery(); |
4361 | + long queryNo = queries->getQuery(); |
4362 | |
4363 | if (queryNo < 0) |
4364 | { |
4365 | - queries->theOutput << "Thread " << tno << " finished " << std::endl; |
4366 | - queries->theOutput << std::endl << "Number of canonicaliations = " << numCanon << std::endl; |
4367 | + queries->theOutput << "Thread " << tno << " finished " << std::endl |
4368 | + << std::endl << "Number of canonicaliations = " |
4369 | + << numCanon << std::endl; |
4370 | queries->theGlobalLock.unlock(); |
4371 | return 0; |
4372 | } |
4373 | |
4374 | - queries->theQueryLocks[queryNo]->lock(); |
4375 | - queries->theGlobalLock.unlock(); |
4376 | -#ifndef WIN32 |
4377 | - sched_yield(); |
4378 | -#else |
4379 | - // SwitchToThread(); |
4380 | -#endif |
4381 | - |
4382 | // Form the full pathname for the file containing the query. |
4383 | relativeQueryFile = queries->theQueryFilenames[queryNo]; |
4384 | queryPath = fs::path(queries->theQueriesDir) / (relativeQueryFile); |
4385 | @@ -411,11 +460,23 @@ |
4386 | #else |
4387 | std::string testName = fs::change_extension(queryPath, "").generic_string(); |
4388 | #endif |
4389 | + |
4390 | ulong pos = testName.find("Queries"); |
4391 | testName = testName.substr(pos + 8); |
4392 | |
4393 | queries->theOutput << "*** " << queryNo << " : " << testName |
4394 | - << " by thread " << tno << std::endl << std::endl; |
4395 | + << " by thread " << tno << " runNo : " |
4396 | + << queries->theNumQueryRuns[queryNo] |
4397 | + << std::endl << std::endl; |
4398 | + |
4399 | + queries->theQueryLocks[queryNo]->lock(); |
4400 | + queries->theGlobalLock.unlock(); |
4401 | + |
4402 | +#ifndef WIN32 |
4403 | + sched_yield(); |
4404 | +#else |
4405 | + // SwitchToThread(); |
4406 | +#endif |
4407 | |
4408 | // Form the full pathname for the .spec file that may be associated |
4409 | // with this query. If the .spec file exists, read its contents to |
4410 | @@ -423,11 +484,13 @@ |
4411 | // exprected errors, or the pathnames of reference-result files. |
4412 | specPath = fs::change_extension(queryPath, ".spec"); |
4413 | if (fs::exists(specPath)) |
4414 | + { |
4415 | #if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4416 | querySpec.parseFile(specPath.file_string(), rbkt_src_dir, rbkt_bin_dir); |
4417 | #else |
4418 | querySpec.parseFile(specPath.generic_string(), rbkt_src_dir, rbkt_bin_dir); |
4419 | #endif |
4420 | + } |
4421 | |
4422 | // Get the pathnames of the ref-result files found in the .spec file (if any). |
4423 | // If no ref-results file was specified in the .spec file, create a default |
4424 | @@ -446,6 +509,7 @@ |
4425 | if (refFilePaths.size() == 0) |
4426 | { |
4427 | std::string relativeRefFile = relativeQueryFile; |
4428 | + |
4429 | if (queries->theIsW3Cbucket) |
4430 | { |
4431 | ulong pos; |
4432 | @@ -481,28 +545,32 @@ |
4433 | createPath(resultFilePath, resFileStream); |
4434 | createPath(errorFilePath, errFileStream); |
4435 | |
4436 | + queries->theQueryLocks[queryNo]->unlock(); |
4437 | + |
4438 | // Create the static context. If this is a w3c query, install special uri |
4439 | // resolvers in the static context. |
4440 | zorba::StaticContext_t sctx = zorba->createStaticContext(); |
4441 | |
4442 | if (queries->theIsW3Cbucket) |
4443 | { |
4444 | - mmapper.reset |
4445 | - (new zorba::TestModuleURIMapper(mod_map_file.c_str(), |
4446 | - testName, false)); |
4447 | - cmapper.reset(new zorba::TestCollectionURIMapper( |
4448 | - col_map_file.c_str(), rbkt_src_dir)); |
4449 | + smapper.reset( |
4450 | + new zorba::TestSchemaURIMapper(uri_map_file.c_str(), false)); |
4451 | + |
4452 | + mmapper.reset( |
4453 | + new zorba::TestModuleURIMapper(mod_map_file.c_str(), testName, false)); |
4454 | + |
4455 | + cmapper.reset( |
4456 | + new zorba::TestCollectionURIMapper(col_map_file.c_str(), rbkt_src_dir)); |
4457 | + |
4458 | addURIMapper(driverContext, sctx, smapper.get()); |
4459 | addURIMapper(driverContext, sctx, mmapper.get()); |
4460 | addURIMapper(driverContext, sctx, cmapper.get()); |
4461 | |
4462 | sctx->setXQueryVersion(zorba::xquery_version_1_0); |
4463 | - zorba::Item lEnable |
4464 | - = zorba->getItemFactory()->createQName( |
4465 | - "http://www.zorba-xquery.com/options/features", "", "enable"); |
4466 | - zorba::Item lDisable |
4467 | - = zorba->getItemFactory()->createQName( |
4468 | - "http://www.zorba-xquery.com/options/features", "", "disable"); |
4469 | + |
4470 | + zorba::Item lDisable = zorba->getItemFactory()-> |
4471 | + createQName("http://www.zorba-xquery.com/options/features", "", "disable"); |
4472 | + |
4473 | sctx->declareOption(lDisable, "scripting"); |
4474 | sctx->setTraceStream(queries->theOutput); |
4475 | } |
4476 | @@ -513,6 +581,7 @@ |
4477 | { |
4478 | dmapper.reset(new zorba::TestSchemeURIMapper(rbkt_src_dir)); |
4479 | addURIMapper(driverContext, sctx, dmapper.get()); |
4480 | + |
4481 | tresolver.reset(new zorba::TestURLResolver()); |
4482 | addURLResolver(driverContext, sctx, tresolver.get()); |
4483 | } |
4484 | @@ -535,82 +604,63 @@ |
4485 | #endif |
4486 | |
4487 | // |
4488 | - // Compile the query, if it has not been compiled already. |
4489 | - // |
4490 | - if (queries->theQueryObjects[queryNo] == 0) |
4491 | - { |
4492 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4493 | - slurp_file(queryPath.file_string().c_str(), |
4494 | - queryString, |
4495 | - rbkt_src_dir, |
4496 | - rbkt_bin_dir); |
4497 | -#else |
4498 | - slurp_file(queryPath.generic_string().c_str(), |
4499 | - queryString, |
4500 | - rbkt_src_dir, |
4501 | - rbkt_bin_dir); |
4502 | -#endif |
4503 | - |
4504 | - |
4505 | - try |
4506 | - { |
4507 | - query = zorba->createQuery(&errHandler); |
4508 | - |
4509 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4510 | - query->setFileName(queryPath.file_string()); |
4511 | -#else |
4512 | - query->setFileName(queryPath.generic_string()); |
4513 | -#endif |
4514 | - query->compile(queryString.c_str(), sctx, getCompilerHints()); |
4515 | - } |
4516 | - catch(...) |
4517 | - { |
4518 | - queries->theOutput << "FAILURE : thread " << tno << " query " << queryNo |
4519 | - << " : " << queries->theQueryFilenames[queryNo] |
4520 | - << std::endl |
4521 | - << "Reason: received an unexpected exception during compilation" |
4522 | - << std::endl << std::endl; |
4523 | - |
4524 | - queries->theQueryLocks[queryNo]->unlock(); |
4525 | - failure = true; |
4526 | - goto done; |
4527 | - } |
4528 | - |
4529 | - if (errHandler.errors()) |
4530 | - { |
4531 | - if (checkErrors(querySpec, errHandler, queries->theOutput)) |
4532 | - { |
4533 | - queries->theQueryLocks[queryNo]->unlock(); |
4534 | - goto done; |
4535 | - } |
4536 | - else |
4537 | - { |
4538 | - queries->theOutput << "FAILURE : thread " << tno << " query " << queryNo |
4539 | - << " : " << queries->theQueryFilenames[queryNo] |
4540 | - << std::endl |
4541 | - << "Reason: received the following unexpected compilation errors : "; |
4542 | - printErrors(errHandler, NULL, false, queries->theOutput); |
4543 | - queries->theOutput << std::endl << std::endl; |
4544 | - |
4545 | - queries->theQueryLocks[queryNo]->unlock(); |
4546 | - failure = true; |
4547 | - goto done; |
4548 | - } |
4549 | - } |
4550 | - |
4551 | - queries->theQueryObjects[queryNo] = query; |
4552 | - } |
4553 | - |
4554 | - queries->theQueryLocks[queryNo]->unlock(); |
4555 | - |
4556 | - // |
4557 | - // Clone the compiled query and register with it the error handler of the |
4558 | - // current thread. |
4559 | - // |
4560 | - query = queries->theQueryObjects[queryNo]->clone(); |
4561 | + // Create the query and register the error handler with it. |
4562 | + // |
4563 | + zorba::XQuery_t query = zorba->createQuery(&errHandler); |
4564 | |
4565 | query->registerDiagnosticHandler(&errHandler); |
4566 | |
4567 | + // |
4568 | + // Compile the query |
4569 | + // |
4570 | +#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4571 | + slurp_file(queryPath.file_string().c_str(), |
4572 | + queryString, rbkt_src_dir, rbkt_bin_dir); |
4573 | +#else |
4574 | + slurp_file(queryPath.generic_string().c_str(), |
4575 | + queryString, rbkt_src_dir, rbkt_bin_dir); |
4576 | +#endif |
4577 | + |
4578 | + try |
4579 | + { |
4580 | +#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4581 | + query->setFileName(queryPath.file_string()); |
4582 | +#else |
4583 | + query->setFileName(queryPath.generic_string()); |
4584 | +#endif |
4585 | + |
4586 | + query->compile(queryString.c_str(), sctx, getCompilerHints()); |
4587 | + } |
4588 | + catch(...) |
4589 | + { |
4590 | + queries->theOutput << "FAILURE : thread " << tno << " query " << queryNo |
4591 | + << " : " << queries->theQueryFilenames[queryNo] |
4592 | + << std::endl |
4593 | + << "Reason: received an unexpected exception during compilation" |
4594 | + << std::endl << std::endl; |
4595 | + failure = true; |
4596 | + goto done; |
4597 | + } |
4598 | + |
4599 | + if (errHandler.errors()) |
4600 | + { |
4601 | + if (checkErrors(querySpec, errHandler, queries->theOutput)) |
4602 | + { |
4603 | + goto done; |
4604 | + } |
4605 | + else |
4606 | + { |
4607 | + queries->theOutput << "FAILURE : thread " << tno << " query " << queryNo |
4608 | + << " : " << queries->theQueryFilenames[queryNo] |
4609 | + << std::endl |
4610 | + << "Reason: received the following unexpected compilation errors : "; |
4611 | + printErrors(errHandler, NULL, false, queries->theOutput); |
4612 | + queries->theOutput << std::endl << std::endl; |
4613 | + |
4614 | + failure = true; |
4615 | + goto done; |
4616 | + } |
4617 | + } |
4618 | |
4619 | // |
4620 | // Execute the query |
4621 | @@ -628,6 +678,7 @@ |
4622 | lSerOptions.indent = ZORBA_INDENT_NO; |
4623 | |
4624 | query->execute(resFileStream, &lSerOptions); |
4625 | + |
4626 | resFileStream.close(); |
4627 | } |
4628 | } |
4629 | @@ -661,7 +712,8 @@ |
4630 | } |
4631 | } |
4632 | else if (querySpec.getComparisonMethod() != "Ignore" |
4633 | - && querySpec.errorsSize() > 0 && !refFileSpecified) |
4634 | + && querySpec.errorsSize() > 0 && |
4635 | + !refFileSpecified) |
4636 | { |
4637 | queries->theOutput << "FAILURE : thread " << tno << " query " << queryNo |
4638 | << " : " << queries->theQueryFilenames[queryNo] |
4639 | @@ -756,6 +808,9 @@ |
4640 | } |
4641 | |
4642 | |
4643 | +/******************************************************************************* |
4644 | + |
4645 | +********************************************************************************/ |
4646 | void usage() |
4647 | { |
4648 | std::cerr << "\nusage: testdriver_mt -b <bucket> [options] OR" << std::endl |
4649 | @@ -769,6 +824,9 @@ |
4650 | } |
4651 | |
4652 | |
4653 | +/******************************************************************************* |
4654 | + |
4655 | +********************************************************************************/ |
4656 | int |
4657 | #ifdef _WIN32_WCE |
4658 | _tmain(int argc, _TCHAR* argv[]) |
4659 | @@ -878,16 +936,20 @@ |
4660 | // This is a cheap and easy way to make a "null" ostream: |
4661 | std::ostringstream nullstream; |
4662 | nullstream.clear(std::ios::badbit); |
4663 | + |
4664 | + // |
4665 | + // Create the query manager |
4666 | + // |
4667 | Queries queries(quiet ? nullstream : std::cout); |
4668 | + |
4669 | queries.theNumRunsPerQuery = numRunsPerQuery; |
4670 | queries.theNumThreads = numThreads; |
4671 | |
4672 | - // Unfortunately there are still places SOMEwhere (in zorba? in a |
4673 | - // dependent library?) that output to stderr. It's important for the |
4674 | - // remote queue in particular that -q actually work, so we attempt |
4675 | - // to shut them up here. QQQ if we can figure out where those |
4676 | - // messages are coming from it would be better to fix those than |
4677 | - // take this heavy-handed approach. |
4678 | + // Unfortunately there are still places SOMEwhere (in zorba? in a dependent |
4679 | + // library?) that output to stderr. It's important for the remote queue in |
4680 | + // particular that -q actually work, so we attempt to shut them up here. |
4681 | + // QQQ if we can figure out where those messages are coming from it would be |
4682 | + // better to fix those than take this heavy-handed approach. |
4683 | if (quiet) |
4684 | { |
4685 | #ifndef WIN32 |
4686 | @@ -904,8 +966,6 @@ |
4687 | if (bucketPath == "") |
4688 | { |
4689 | bucketPath = zorba::RBKT_SRC_DIR; |
4690 | - // QQQ Probably should have an option for specifying alternative |
4691 | - // resultsDir too |
4692 | } |
4693 | else |
4694 | { |
4695 | @@ -927,7 +987,9 @@ |
4696 | testExtension = ".xqx"; |
4697 | } |
4698 | else if ((pos = refsDir.find("XQuery")) != std::string::npos) |
4699 | + { |
4700 | refsDir = refsDir.erase(pos, 7); |
4701 | + } |
4702 | } |
4703 | |
4704 | reportFilepath = zorba::RBKT_BINARY_DIR + "/../../Testing/" + reportFilename; |
4705 | @@ -945,38 +1007,35 @@ |
4706 | #else |
4707 | path = fs::system_complete(fs::path(queriesDir)); |
4708 | #endif |
4709 | + |
4710 | if (!fs::is_directory(path)) |
4711 | { |
4712 | std::cerr << "The directory " << queriesDir << " could not be found" << std::endl; |
4713 | exit(2); |
4714 | } |
4715 | + |
4716 | #if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4717 | queries.theQueriesDir = path.file_string(); |
4718 | + path = fs::system_complete(fs::path(refsDir, fs::native)); |
4719 | #else |
4720 | queries.theQueriesDir = path.generic_string(); |
4721 | -#endif |
4722 | - |
4723 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4724 | - path = fs::system_complete(fs::path(refsDir, fs::native)); |
4725 | -#else |
4726 | path = fs::system_complete(fs::path(refsDir)); |
4727 | #endif |
4728 | + |
4729 | if (!fs::is_directory(path)) |
4730 | { |
4731 | std::cerr << "The directory " << refsDir << " could not be found" << std::endl; |
4732 | exit(2); |
4733 | } |
4734 | + |
4735 | #if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4736 | queries.theRefsDir = path.native_directory_string(); |
4737 | + path = fs::system_complete(fs::path(resultsDir, fs::native)); |
4738 | #else |
4739 | queries.theRefsDir = path.parent_path().generic_string(); |
4740 | -#endif |
4741 | - |
4742 | -#if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4743 | - path = fs::system_complete(fs::path(resultsDir, fs::native)); |
4744 | -#else |
4745 | path = fs::system_complete(fs::path(resultsDir)); |
4746 | #endif |
4747 | + |
4748 | if (!fs::exists(path)) |
4749 | { |
4750 | fs::create_directories(path); |
4751 | @@ -986,6 +1045,7 @@ |
4752 | std::cerr << "The pathname " << resultsDir << " is not a directory" << std::endl; |
4753 | exit(2); |
4754 | } |
4755 | + |
4756 | #if !defined(BOOST_FILESYSTEM_VERSION) || BOOST_FILESYSTEM_VERSION == 2 |
4757 | queries.theResultsDir = path.native_directory_string(); |
4758 | #else |
4759 | @@ -1045,7 +1105,6 @@ |
4760 | // Prepare the Queries container |
4761 | // |
4762 | queries.theNumQueryRuns.resize(queries.theNumQueries); |
4763 | - queries.theQueryObjects.resize(queries.theNumQueries); |
4764 | queries.theQueryLocks.resize(queries.theNumQueries); |
4765 | queries.theQueryStates.resize(queries.theNumQueries); |
4766 | |
4767 | |
4768 | === modified file 'test/rbkt/Queries/zorba/updates/forms.xsd' |
4769 | --- test/rbkt/Queries/zorba/updates/forms.xsd 2012-06-01 08:35:24 +0000 |
4770 | +++ test/rbkt/Queries/zorba/updates/forms.xsd 2013-07-11 13:41:52 +0000 |
4771 | @@ -11,7 +11,7 @@ |
4772 | </xs:sequence> |
4773 | </xs:complexType> |
4774 | |
4775 | - <xs:element name="form" type="Form"></xs:element> |
4776 | + <xs:element name="form" type="Form"></xs:element> |
4777 | |
4778 | <xs:complexType name="Hidden"> |
4779 | <xs:attribute name="name" type="xs:string" use="required"></xs:attribute> |
Validation queue starting for the following merge proposals: /code.launchpad .net/~zorba- coders/ zorba/threads/ +merge/ 174198
https:/
Progress dashboard at http:// jenkins. lambda. nu/view/ ValidationQueue