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