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

Proposed by Markos Zaharioudakis
Status: Merged
Merged at revision: 11635
Proposed branch: lp:~zorba-coders/zorba/threads
Merge into: lp:zorba
Diff against target: 1651 lines (+558/-394)
20 files modified
src/compiler/expression/expr_type.cpp (+1/-1)
src/compiler/translator/translator.cpp (+93/-2)
src/functions/func_fn_hof_functions_impl.cpp (+42/-94)
src/functions/func_parse_fragment_impl.cpp (+11/-19)
src/functions/func_strings_impl.cpp (+16/-9)
src/functions/function.cpp (+6/-0)
src/functions/function.h (+0/-8)
src/functions/pregenerated/func_strings.h (+2/-0)
src/functions/signature.cpp (+131/-96)
src/functions/signature.h (+20/-7)
src/runtime/spec/strings/strings.xml (+19/-12)
src/system/globalenv.cpp (+22/-6)
src/types/schema/schema.cpp (+28/-57)
src/types/schema/schema.h (+0/-8)
src/types/typeimpl.cpp (+55/-3)
src/types/typeimpl.h (+59/-34)
src/types/typemanagerimpl.cpp (+27/-10)
src/types/typeops.cpp (+0/-1)
src/zorbaserialization/class_serializer.cpp (+25/-26)
src/zorbaserialization/class_serializer.h (+1/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/threads
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+186514@code.launchpad.net

Commit message

More multi-threading work:
1. Function objects for builtin functions should not use any non-builtin types in their signature.
2. XQType does not inherit from RCObject anymore; instead it replicates RCObject functionalityinternally

Description of the change

More multi-threading work:
1. Function objects for builtin functions should not use any non-builtin types in their signature.
2. XQType does not inherit from RCObject anymore; instead it replicates RCObject functionalityinternally

To post a comment you must log in.
lp:~zorba-coders/zorba/threads updated
11579. By Markos Zaharioudakis

removed unnecessary recreation of mem archiver during shutdown

11580. By Markos Zaharioudakis

fixed type-related multi-threading problems

11581. By Markos Zaharioudakis

merge from trunk

11582. By Markos Zaharioudakis

fixed type-related multi-threading problems

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Stage "TestZorbaUbuntu" failed.
11 tests failed (8535 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/315/testReport/ to view the results.

lp:~zorba-coders/zorba/threads updated
11583. By Markos Zaharioudakis

fixed type-related multi-threading problems

11584. By Markos Zaharioudakis

reverted previous change: the mem archiver MUST be recreated after shutdown

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Stage "TestZorbaUbuntu" failed.
6 tests failed (8535 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/319/testReport/ to view the results.

lp:~zorba-coders/zorba/threads updated
11585. By Markos Zaharioudakis

fixed .csv files

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue succeeded - proposal merged!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/threads/+merge/186514

Stage "TestZorbaUbuntu" failed.
1 tests failed (8550 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/329/testReport/ to view the results.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/compiler/expression/expr_type.cpp'
2--- src/compiler/expression/expr_type.cpp 2013-08-16 13:00:06 +0000
3+++ src/compiler/expression/expr_type.cpp 2013-09-20 12:27:16 +0000
4@@ -675,7 +675,7 @@
5 for (csize i = 0; i < fiExpr->get_function()->getSignature().paramCount(); ++i)
6 paramTypes.push_back(fiExpr->get_function()->getSignature()[i]);
7
8- theType = new FunctionXQType(&rtm, paramTypes, retType, TypeConstants::QUANT_ONE);
9+ theType = rtm.create_function_type(paramTypes, retType, TypeConstants::QUANT_ONE);
10 }
11 return;
12 }
13
14=== modified file 'src/compiler/translator/translator.cpp'
15--- src/compiler/translator/translator.cpp 2013-09-17 21:12:49 +0000
16+++ src/compiler/translator/translator.cpp 2013-09-20 12:27:16 +0000
17@@ -1506,8 +1506,99 @@
18
19 TypeManager* tm = argExpr->get_type_manager();
20
21+ paramType = sign[i];
22+
23 switch (func->getKind())
24 {
25+ case FunctionConsts::FN_ZORBA_XML_PARSE_2:
26+ {
27+ if (i == 1)
28+ {
29+ paramType = tm->
30+ create_node_type(store::StoreConsts::elementNode,
31+ createQName(static_context::ZORBA_XML_FN_OPTIONS_NS,
32+ "",
33+ "options"),
34+ NULL,
35+ TypeConstants::QUANT_QUESTION,
36+ false,
37+ false);
38+ }
39+ break;
40+ }
41+ case FunctionConsts::FN_FOR_EACH_2:
42+ {
43+ if (i == 1)
44+ {
45+ std::vector<xqtref_t> args;
46+ args.push_back(theRTM.ITEM_TYPE_ONE);
47+
48+ paramType = tm->
49+ create_function_type(args,
50+ theRTM.ITEM_TYPE_STAR,
51+ TypeConstants::QUANT_ONE);
52+ }
53+ break;
54+ }
55+ case FunctionConsts::FN_FOR_EACH_PAIR_3:
56+ {
57+ if (i == 2)
58+ {
59+ std::vector<xqtref_t> args;
60+ args.push_back(theRTM.ITEM_TYPE_ONE);
61+ args.push_back(theRTM.ITEM_TYPE_ONE);
62+
63+ paramType = tm->
64+ create_function_type(args,
65+ theRTM.ITEM_TYPE_STAR,
66+ TypeConstants::QUANT_ONE);
67+ }
68+ break;
69+ }
70+ case FunctionConsts::FN_FOLD_LEFT_3:
71+ {
72+ if (i == 2)
73+ {
74+ std::vector<xqtref_t> args;
75+ args.push_back(theRTM.ITEM_TYPE_STAR);
76+ args.push_back(theRTM.ITEM_TYPE_ONE);
77+
78+ paramType = tm->
79+ create_function_type(args,
80+ theRTM.ITEM_TYPE_STAR,
81+ TypeConstants::QUANT_ONE);
82+ }
83+ break;
84+ }
85+ case FunctionConsts::FN_FOLD_RIGHT_3:
86+ {
87+ if (i == 2)
88+ {
89+ std::vector<xqtref_t> args;
90+ args.push_back(theRTM.ITEM_TYPE_ONE);
91+ args.push_back(theRTM.ITEM_TYPE_STAR);
92+
93+ paramType = tm->
94+ create_function_type(args,
95+ theRTM.ITEM_TYPE_STAR,
96+ TypeConstants::QUANT_ONE);
97+ }
98+ break;
99+ }
100+ case FunctionConsts::FN_FILTER_2:
101+ {
102+ if (i == 1)
103+ {
104+ std::vector<xqtref_t> args;
105+ args.push_back(theRTM.ITEM_TYPE_ONE);
106+
107+ paramType = tm->
108+ create_function_type(args,
109+ theRTM.BOOLEAN_TYPE_ONE,
110+ TypeConstants::QUANT_ONE);
111+ }
112+ break;
113+ }
114 case FunctionConsts::FN_ZORBA_XQDDF_PROBE_INDEX_POINT_VALUE_N:
115 {
116 if (i == 0)
117@@ -1562,7 +1653,7 @@
118 }
119 default:
120 {
121- paramType = sign[i];
122+ break;
123 }
124 }
125
126@@ -4041,7 +4132,7 @@
127 // We make sure that the types of the parameters and the return type
128 // are subtypes of the ones declared in the module
129 const signature& s = f->getSignature();
130- if (!s.subtype(tm, sig, loc))
131+ if (!s.subtype(tm, f, sig, loc))
132 {
133 RAISE_ERROR(zerr::ZXQP0007_FUNCTION_SIGNATURE_NOT_EQUAL, loc,
134 ERROR_PARAMS(BUILD_STRING('{',
135
136=== modified file 'src/functions/func_fn_hof_functions_impl.cpp'
137--- src/functions/func_fn_hof_functions_impl.cpp 2013-06-04 21:47:40 +0000
138+++ src/functions/func_fn_hof_functions_impl.cpp 2013-09-20 12:27:16 +0000
139@@ -143,100 +143,48 @@
140 ********************************************************************************/
141 void populate_context_hof_impl(static_context* sctx)
142 {
143- {
144- std::vector<xqtref_t> args;
145- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
146-
147- xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
148- args,
149- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
150- TypeConstants::QUANT_ONE);
151-
152- DECL_WITH_KIND(sctx,
153- fn_for_each_3_0,
154- (createQName(static_context::W3C_FN_NS, "", "for-each"),
155- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
156- hofParamType,
157- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
158- FunctionConsts::FN_FOR_EACH_2);
159- }
160-
161- {
162- std::vector<xqtref_t> args;
163- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
164-
165- xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
166- args,
167- GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,
168- TypeConstants::QUANT_ONE);
169-
170- DECL_WITH_KIND(sctx,
171- fn_filter,
172- (createQName(static_context::W3C_FN_NS, "", "filter"),
173- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
174- hofParamType,
175- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
176- FunctionConsts::FN_FILTER_2);
177- }
178-
179- {
180- std::vector<xqtref_t> args;
181- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
182- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
183-
184- xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(
185- args,
186- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
187- TypeConstants::QUANT_ONE);
188-
189- DECL_WITH_KIND(sctx,
190- fn_for_each_pair_3_0,
191- (createQName(static_context::W3C_FN_NS, "", "for-each-pair"),
192- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
193- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
194- hofParamType,
195- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
196- FunctionConsts::FN_FOR_EACH_PAIR_3);
197- }
198-
199- {
200- std::vector<xqtref_t> args;
201- xqtref_t hofParamType;
202-
203- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
204- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
205- hofParamType = GENV_TYPESYSTEM.create_function_type(
206- args,
207- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
208- TypeConstants::QUANT_ONE);
209-
210- DECL_WITH_KIND(sctx,
211- fn_fold_left_3_0,
212- (createQName(static_context::W3C_FN_NS, "", "fold-left"),
213- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
214- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
215- hofParamType,
216- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
217- FunctionConsts::FN_FOLD_LEFT_3);
218-
219- args.clear();
220- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
221- args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
222- hofParamType = GENV_TYPESYSTEM.create_function_type(
223- args,
224- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
225- TypeConstants::QUANT_ONE);
226-
227- DECL_WITH_KIND(sctx,
228- fn_fold_right_3_0,
229- (createQName(static_context::W3C_FN_NS, "", "fold-right"),
230- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
231- GENV_TYPESYSTEM.ITEM_TYPE_STAR,
232- hofParamType,
233- GENV_TYPESYSTEM.ITEM_TYPE_STAR),
234- FunctionConsts::FN_FOLD_RIGHT_3);
235- }
236-
237+ DECL_WITH_KIND(sctx,
238+ fn_for_each_3_0,
239+ (createQName(static_context::W3C_FN_NS, "", "for-each"),
240+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
241+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
242+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
243+ FunctionConsts::FN_FOR_EACH_2);
244+
245+ DECL_WITH_KIND(sctx,
246+ fn_filter,
247+ (createQName(static_context::W3C_FN_NS, "", "filter"),
248+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
249+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
250+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
251+ FunctionConsts::FN_FILTER_2);
252+
253+ DECL_WITH_KIND(sctx,
254+ fn_for_each_pair_3_0,
255+ (createQName(static_context::W3C_FN_NS, "", "for-each-pair"),
256+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
257+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
258+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
259+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
260+ FunctionConsts::FN_FOR_EACH_PAIR_3);
261+
262+ DECL_WITH_KIND(sctx,
263+ fn_fold_left_3_0,
264+ (createQName(static_context::W3C_FN_NS, "", "fold-left"),
265+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
266+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
267+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
268+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
269+ FunctionConsts::FN_FOLD_LEFT_3);
270+
271+ DECL_WITH_KIND(sctx,
272+ fn_fold_right_3_0,
273+ (createQName(static_context::W3C_FN_NS, "", "fold-right"),
274+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
275+ GENV_TYPESYSTEM.ITEM_TYPE_STAR,
276+ GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
277+ GENV_TYPESYSTEM.ITEM_TYPE_STAR),
278+ FunctionConsts::FN_FOLD_RIGHT_3);
279 }
280
281 }
282
283=== modified file 'src/functions/func_parse_fragment_impl.cpp'
284--- src/functions/func_parse_fragment_impl.cpp 2013-07-24 09:06:02 +0000
285+++ src/functions/func_parse_fragment_impl.cpp 2013-09-20 12:27:16 +0000
286@@ -37,25 +37,17 @@
287 ********************************************************************************/
288 void populate_context_parse_fragment_impl(static_context* sctx)
289 {
290- xqtref_t lParseOptType =
291- GENV_TYPESYSTEM.create_node_type(
292- store::StoreConsts::elementNode,
293- createQName(static_context::ZORBA_XML_FN_OPTIONS_NS,"","options"),
294- NULL,
295- TypeConstants::QUANT_QUESTION,
296- false,
297- false
298- );
299-
300- {
301- DECL_WITH_KIND(sctx, fn_zorba_xml_parse,
302- (createQName(static_context::ZORBA_XML_FN_NS,"","parse"),
303- GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
304- lParseOptType,
305- GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
306- FunctionConsts::FN_ZORBA_XML_PARSE_2);
307-
308- }
309+ // Note: the actual type of the 2nd param should be element(options)?
310+ // However, we cannot use a non-builtin type in the signature of a builtin
311+ // function. That's why we use type element() here and do special handling
312+ // of this function in the translator.
313+ DECL_WITH_KIND(sctx, fn_zorba_xml_parse,
314+ (createQName(static_context::ZORBA_XML_FN_NS, "", "parse"),
315+ GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
316+ GENV_TYPESYSTEM.ELEMENT_TYPE_QUESTION,
317+ GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
318+ FunctionConsts::FN_ZORBA_XML_PARSE_2);
319+
320 }
321
322 }
323
324=== modified file 'src/functions/func_strings_impl.cpp'
325--- src/functions/func_strings_impl.cpp 2013-02-07 17:24:36 +0000
326+++ src/functions/func_strings_impl.cpp 2013-09-20 12:27:16 +0000
327@@ -62,27 +62,34 @@
328 }
329
330
331+
332 /*******************************************************************************
333
334 ********************************************************************************/
335-void populate_context_strings_impl(static_context* sctx)
336+xqtref_t fn_analyze_string_3_0::getReturnType(const fo_expr* caller) const
337 {
338- xqtref_t lAnalyzeStringResultType =
339- GENV_TYPESYSTEM.create_node_type(
340+ return
341+ GENV_TYPESYSTEM.create_node_type(
342 store::StoreConsts::elementNode,
343- createQName("http://www.w3.org/2005/xpath-functions","","analyze-string-result"),
344+ createQName(static_context::W3C_FN_NS,"","analyze-string-result"),
345 NULL,
346 TypeConstants::QUANT_ONE,
347 false,
348- false
349- );
350-
351+ false);
352+}
353+
354+
355+/*******************************************************************************
356+
357+********************************************************************************/
358+void populate_context_strings_impl(static_context* sctx)
359+{
360 {
361 DECL_WITH_KIND(sctx, fn_analyze_string_3_0,
362 (createQName("http://www.w3.org/2005/xpath-functions","","analyze-string"),
363 GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
364 GENV_TYPESYSTEM.STRING_TYPE_ONE,
365- lAnalyzeStringResultType),
366+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE),
367 FunctionConsts::FN_ANALYZE_STRING_2);
368
369 }
370@@ -94,7 +101,7 @@
371 GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
372 GENV_TYPESYSTEM.STRING_TYPE_ONE,
373 GENV_TYPESYSTEM.STRING_TYPE_ONE,
374- lAnalyzeStringResultType),
375+ GENV_TYPESYSTEM.ELEMENT_TYPE_ONE),
376 FunctionConsts::FN_ANALYZE_STRING_3);
377 }
378 }
379
380=== modified file 'src/functions/function.cpp'
381--- src/functions/function.cpp 2013-07-31 16:35:39 +0000
382+++ src/functions/function.cpp 2013-09-20 12:27:16 +0000
383@@ -57,6 +57,12 @@
384 setFlag(FunctionConsts::isBuiltin);
385 #ifndef NDEBUG
386 theRefCount = 1000000;
387+
388+ csize numTypes = sig.theTypes.size();
389+ for (csize i = 0; i < numTypes; ++i)
390+ {
391+ assert(sig.theTypes[i]->is_builtin());
392+ }
393 #endif
394 }
395
396
397=== modified file 'src/functions/function.h'
398--- src/functions/function.h 2013-08-02 21:35:01 +0000
399+++ src/functions/function.h 2013-09-20 12:27:16 +0000
400@@ -48,11 +48,7 @@
401 The root sctx of the module containing the declaration. It is NULL for
402 functions that must be executed in the static context of the caller.
403 ********************************************************************************/
404-#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY
405 class function : public SimpleRCObject
406-#else
407-class function : public SyncedRCObject
408-#endif
409 {
410 protected:
411 signature theSignature;
412@@ -66,11 +62,7 @@
413
414 public:
415 SERIALIZABLE_CLASS(function);
416-#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY
417 SERIALIZABLE_CLASS_CONSTRUCTOR3(function, SimpleRCObject, theSignature);
418-#else
419- SERIALIZABLE_CLASS_CONSTRUCTOR3(function, SyncedRCObject, theSignature);
420-#endif
421 void serialize(::zorba::serialization::Archiver& ar);
422
423 public:
424
425=== modified file 'src/functions/pregenerated/func_strings.h'
426--- src/functions/pregenerated/func_strings.h 2013-07-11 22:08:29 +0000
427+++ src/functions/pregenerated/func_strings.h 2013-09-20 12:27:16 +0000
428@@ -447,6 +447,8 @@
429 theXQueryVersion = StaticContextConsts::xquery_version_3_0;
430 }
431
432+ xqtref_t getReturnType(const fo_expr* caller) const;
433+
434 CODEGEN_DECL();
435 };
436
437
438=== modified file 'src/functions/signature.cpp'
439--- src/functions/signature.cpp 2013-03-04 21:00:58 +0000
440+++ src/functions/signature.cpp 2013-09-20 12:27:16 +0000
441@@ -21,6 +21,13 @@
442
443 #include "types/typeops.h"
444
445+#include "functions/function.h"
446+#include "functions/library.h"
447+
448+#include "context/static_context.h"
449+
450+#include "store/api/item_factory.h"
451+
452 #include "zorbaserialization/serialize_template_types.h"
453 #include "zorbaserialization/serialize_zorba_types.h"
454
455@@ -31,100 +38,100 @@
456 {
457
458 SERIALIZABLE_CLASS_VERSIONS(signature)
459-
460-
461-signature::signature(
462- const store::Item_t& name,
463- const xqtref_t& paramType1,
464- bool variadic,
465- const xqtref_t& returnType)
466- :
467- theQName(name),
468- theNonOptimizedReturnType(NULL),
469- theIsVariadic(variadic)
470-{
471- theTypes.push_back(returnType);
472- theTypes.push_back(paramType1);
473-}
474-
475-
476-signature::signature(
477- const store::Item_t& name,
478- const xqtref_t& paramType1,
479- const xqtref_t& paramType2,
480- bool variadic,
481- const xqtref_t& returnType)
482- :
483- theQName(name),
484- theNonOptimizedReturnType(NULL),
485- theIsVariadic(variadic)
486-{
487- theTypes.push_back(returnType);
488- theTypes.push_back(paramType1);
489- theTypes.push_back(paramType2);
490-}
491-
492-
493-signature::signature(
494- const store::Item_t& name,
495- const xqtref_t& returnType)
496- :
497- theQName(name),
498- theNonOptimizedReturnType(NULL),
499- theIsVariadic(false)
500-{
501- theTypes.push_back(returnType);
502-}
503-
504-
505-signature::signature(
506- const store::Item_t& name,
507- const xqtref_t& paramType1,
508- const xqtref_t& returnType)
509- :
510- theQName(name),
511- theNonOptimizedReturnType(NULL),
512- theIsVariadic(false)
513-{
514- theTypes.push_back(returnType);
515- theTypes.push_back(paramType1);
516-}
517-
518-
519-signature::signature(
520- const store::Item_t& name,
521- const xqtref_t& paramType1,
522- const xqtref_t& paramType2,
523- const xqtref_t& returnType)
524- :
525- theQName(name),
526- theNonOptimizedReturnType(NULL),
527- theIsVariadic(false)
528-{
529- theTypes.push_back(returnType);
530- theTypes.push_back(paramType1);
531- theTypes.push_back(paramType2);
532-}
533-
534-
535-signature::signature(
536- const store::Item_t& name,
537- const xqtref_t& paramType1,
538- const xqtref_t& paramType2,
539+
540+
541+signature::signature(
542+ const store::Item_t& name,
543+ const xqtref_t& paramType1,
544+ bool variadic,
545+ const xqtref_t& returnType)
546+ :
547+ theQName(name),
548+ theNonOptimizedReturnType(NULL),
549+ theIsVariadic(variadic)
550+{
551+ theTypes.push_back(returnType);
552+ theTypes.push_back(paramType1);
553+}
554+
555+
556+signature::signature(
557+ const store::Item_t& name,
558+ const xqtref_t& paramType1,
559+ const xqtref_t& paramType2,
560+ bool variadic,
561+ const xqtref_t& returnType)
562+ :
563+ theQName(name),
564+ theNonOptimizedReturnType(NULL),
565+ theIsVariadic(variadic)
566+{
567+ theTypes.push_back(returnType);
568+ theTypes.push_back(paramType1);
569+ theTypes.push_back(paramType2);
570+}
571+
572+
573+signature::signature(
574+ const store::Item_t& name,
575+ const xqtref_t& returnType)
576+ :
577+ theQName(name),
578+ theNonOptimizedReturnType(NULL),
579+ theIsVariadic(false)
580+{
581+ theTypes.push_back(returnType);
582+}
583+
584+
585+signature::signature(
586+ const store::Item_t& name,
587+ const xqtref_t& paramType1,
588+ const xqtref_t& returnType)
589+ :
590+ theQName(name),
591+ theNonOptimizedReturnType(NULL),
592+ theIsVariadic(false)
593+{
594+ theTypes.push_back(returnType);
595+ theTypes.push_back(paramType1);
596+}
597+
598+
599+signature::signature(
600+ const store::Item_t& name,
601+ const xqtref_t& paramType1,
602+ const xqtref_t& paramType2,
603+ const xqtref_t& returnType)
604+ :
605+ theQName(name),
606+ theNonOptimizedReturnType(NULL),
607+ theIsVariadic(false)
608+{
609+ theTypes.push_back(returnType);
610+ theTypes.push_back(paramType1);
611+ theTypes.push_back(paramType2);
612+}
613+
614+
615+signature::signature(
616+ const store::Item_t& name,
617+ const xqtref_t& paramType1,
618+ const xqtref_t& paramType2,
619 const xqtref_t& paramType3,
620- const xqtref_t& returnType)
621- :
622- theQName(name),
623- theNonOptimizedReturnType(NULL),
624- theIsVariadic(false)
625-{
626- theTypes.push_back(returnType);
627- theTypes.push_back(paramType1);
628- theTypes.push_back(paramType2);
629+ const xqtref_t& returnType)
630+ :
631+ theQName(name),
632+ theNonOptimizedReturnType(NULL),
633+ theIsVariadic(false)
634+{
635+ theTypes.push_back(returnType);
636+ theTypes.push_back(paramType1);
637+ theTypes.push_back(paramType2);
638 theTypes.push_back(paramType3);
639 }
640-
641-
642+
643+
644 signature::signature(
645 const store::Item_t& name,
646 const xqtref_t& paramType1,
647@@ -309,8 +316,13 @@
648 }
649
650
651+/*******************************************************************************
652+ "this" is the signature of the function object. "s" is the signature of the
653+ declaration appearing in the lib module.
654+********************************************************************************/
655 bool signature::subtype(
656 const TypeManager* tm,
657+ const function* func,
658 const signature& s,
659 const QueryLoc& loc) const
660 {
661@@ -320,8 +332,8 @@
662 if (!theQName->equals(s.theQName.getp()))
663 return false;
664
665- if (theNonOptimizedReturnType.getp() != NULL && s.theNonOptimizedReturnType.getp() != NULL
666- &&
667+ if (theNonOptimizedReturnType.getp() != NULL &&
668+ s.theNonOptimizedReturnType.getp() != NULL &&
669 !TypeOps::is_subtype(tm,
670 *theNonOptimizedReturnType.getp(),
671 *s.theNonOptimizedReturnType.getp(),
672@@ -330,12 +342,35 @@
673 return false;
674 }
675
676- assert (s.theTypes.size() == theTypes.size() || theIsVariadic );
677+ assert (s.theTypes.size() == theTypes.size() || theIsVariadic);
678+
679 for (csize i = 0; i < theTypes.size(); ++i)
680 {
681+ xqtref_t builtinParamType = theTypes[i];
682+
683+ if (func == BUILTIN_FUNC(FN_ZORBA_XML_PARSE_2))
684+ {
685+ if (i == 2)
686+ {
687+ store::Item_t typeName;
688+ GENV_ITEMFACTORY->createQName(typeName,
689+ static_context::ZORBA_XML_FN_OPTIONS_NS,
690+ "",
691+ "options"),
692+
693+ builtinParamType = tm->
694+ create_node_type(store::StoreConsts::elementNode,
695+ typeName,
696+ NULL,
697+ TypeConstants::QUANT_QUESTION,
698+ false,
699+ false);
700+ }
701+ }
702+
703 if (!TypeOps::is_subtype(tm,
704- *theTypes[i].getp(),
705- *s.theTypes[i].getp(),
706+ *builtinParamType, // subtype
707+ *s.theTypes[i].getp(), // supertype
708 loc))
709 {
710 return false;
711
712=== modified file 'src/functions/signature.h'
713--- src/functions/signature.h 2013-03-04 21:00:58 +0000
714+++ src/functions/signature.h 2013-09-20 12:27:16 +0000
715@@ -25,24 +25,36 @@
716
717 namespace zorba {
718
719+class function;
720+
721 #define VARIADIC_SIG_SIZE 1000000
722
723 /*******************************************************************************
724
725- By convention, theTypes[0] = return type
726- theTypes[1] = first param type
727- theTypes[2] = second param type
728- ... = ...
729+ theQName :
730+ the qname of the function
731+
732+ theTypes:
733+ The return type and the paremater types. By convention, theTypes[0] holds the
734+ return type, theTypes[1] holds the first param type, theTypes[2] holds the 2nd
735+ param type, etc.
736+
737+ theNonOptimizedReturnType:
738+ This is the original, non-optimized return type of a function. Used in function
739+ literals type checks.
740+
741+ theIsVariadic:
742+ Whether thefunction is variadic.
743
744 ********************************************************************************/
745 class signature: public SimpleRCObject
746 {
747+ friend class function;
748+
749 protected:
750 store::Item_t theQName;
751 checked_vector<xqtref_t> theTypes;
752- xqtref_t theNonOptimizedReturnType; // This is the original, non-optimized
753- // return type of a function. Used in
754- // function literals type checks.
755+ xqtref_t theNonOptimizedReturnType;
756 bool theIsVariadic;
757
758 public:
759@@ -192,6 +204,7 @@
760
761 bool subtype(
762 const TypeManager* tm,
763+ const function* func,
764 const signature& s,
765 const QueryLoc& loc) const;
766 };
767
768=== modified file 'src/runtime/spec/strings/strings.xml'
769--- src/runtime/spec/strings/strings.xml 2013-07-11 22:08:29 +0000
770+++ src/runtime/spec/strings/strings.xml 2013-09-20 12:27:16 +0000
771@@ -670,19 +670,26 @@
772 </zorba:description>
773
774 <zorba:function generateDECL="false">
775- <zorba:signature localname="analyze-string" prefix="fn" version="3.0">
776- <zorba:param>xs:string?</zorba:param>
777- <zorba:param>xs:string</zorba:param>
778- <zorba:output>element()</zorba:output>
779- </zorba:signature>
780-
781- <zorba:signature localname="analyze-string" prefix="fn" version="3.0">
782- <zorba:param>xs:string?</zorba:param>
783- <zorba:param>xs:string</zorba:param>
784- <zorba:param>xs:string</zorba:param>
785- <zorba:output>element()</zorba:output>
786- </zorba:signature>
787+
788+ <zorba:signature localname="analyze-string" prefix="fn" version="3.0">
789+ <zorba:param>xs:string?</zorba:param>
790+ <zorba:param>xs:string</zorba:param>
791+ <zorba:output>element()</zorba:output>
792+ </zorba:signature>
793+
794+ <zorba:signature localname="analyze-string" prefix="fn" version="3.0">
795+ <zorba:param>xs:string?</zorba:param>
796+ <zorba:param>xs:string</zorba:param>
797+ <zorba:param>xs:string</zorba:param>
798+ <zorba:output>element()</zorba:output>
799+ </zorba:signature>
800+
801+ <zorba:methods>
802+ <zorba:getReturnType/>
803+ </zorba:methods>
804+
805 </zorba:function>
806+
807 </zorba:iterator>
808
809 <!--
810
811=== modified file 'src/system/globalenv.cpp'
812--- src/system/globalenv.cpp 2013-08-14 08:46:44 +0000
813+++ src/system/globalenv.cpp 2013-09-20 12:27:16 +0000
814@@ -61,6 +61,11 @@
815
816 #include "diagnostics/assert.h"
817
818+
819+#include "types/schema/xercesIncludes.h"
820+#include "types/schema/StrX.h"
821+
822+
823 using namespace zorba;
824
825
826@@ -72,7 +77,18 @@
827 void GlobalEnvironment::init(store::Store* store)
828 {
829 // initialize Xerces-C lib
830- Schema::initialize();
831+#ifndef ZORBA_NO_XMLSCHEMA
832+ try
833+ {
834+ XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
835+ }
836+ catch (const XERCES_CPP_NAMESPACE::XMLException& toCatch)
837+ {
838+ std::cerr << "Error during Xerces-C initialization! Message:\n"
839+ << StrX(toCatch.getMessage()) << std::endl;
840+ abort();
841+ }
842+#endif
843
844 m_globalEnv = new GlobalEnvironment();
845
846@@ -122,10 +138,9 @@
847
848
849 /*******************************************************************************
850-
851+ destroy all components that were initialized in init
852+ note: destruction must be done in reverse initialization order
853 ********************************************************************************/
854-// destroy all components that were initialized in init
855-// note: destruction must be done in reverse initialization order
856 void GlobalEnvironment::destroy()
857 {
858 delete m_globalEnv->theDynamicLoader;
859@@ -168,8 +183,9 @@
860 m_globalEnv = NULL;
861
862 // terminate Xerces-C lib
863- Schema::terminate();
864-
865+#ifndef ZORBA_NO_XMLSCHEMA
866+ XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate();
867+#endif
868 }
869
870
871
872=== modified file 'src/types/schema/schema.cpp'
873--- src/types/schema/schema.cpp 2013-09-17 21:12:49 +0000
874+++ src/types/schema/schema.cpp 2013-09-20 12:27:16 +0000
875@@ -18,6 +18,7 @@
876 #include <string>
877
878 #include "compiler/parser/query_loc.h"
879+
880 #include "context/namespace_context.h"
881 #include "context/static_context.h"
882 #include "context/uri_resolver.h"
883@@ -36,10 +37,14 @@
884 #include "types/schema/LoadSchemaErrorHandler.h"
885 #include "types/schema/PrintSchema.h"
886 #include "types/schema/XercesParseUtils.h"
887+#include "types/schema/xercesIncludes.h"
888+
889 #include "system/globalenv.h"
890+
891 #include "store/api/item_factory.h"
892+
893 #include "util/utf8_util.h"
894-#include "types/schema/xercesIncludes.h"
895+
896 #include "zorbatypes/URI.h"
897 #include <zorba/internal/unique_ptr.h>
898
899@@ -82,8 +87,6 @@
900
901 const char* Schema::XSD_NAMESPACE = static_context::W3C_XML_SCHEMA_NS;
902
903-bool Schema::theIsInitialized = false;
904-
905 #ifndef ZORBA_NO_XMLSCHEMA
906
907
908@@ -332,45 +335,6 @@
909
910
911 /*******************************************************************************
912- Initialize the Xerces platform. Called from GlobalEnvironment::init().
913-*******************************************************************************/
914-void Schema::initialize()
915-{
916-#ifndef ZORBA_NO_XMLSCHEMA
917- if (theIsInitialized)
918- return;
919-
920- try
921- {
922- XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
923- theIsInitialized = true;
924- }
925- catch (const XERCES_CPP_NAMESPACE::XMLException& toCatch)
926- {
927- std::cerr << "Error during Xerces-C initialization! Message:\n"
928- << StrX(toCatch.getMessage()) << std::endl;
929- return;
930- }
931-#endif
932-}
933-
934-
935-/*******************************************************************************
936- Terminate the Xerces platform. Called from GlobalEnvironment::destroy().
937-*******************************************************************************/
938-void Schema::terminate()
939-{
940-#ifndef ZORBA_NO_XMLSCHEMA
941- if (theIsInitialized)
942- {
943- XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate();
944- theIsInitialized = false;
945- }
946-#endif
947-}
948-
949-
950-/*******************************************************************************
951
952 *******************************************************************************/
953 Schema::Schema(TypeManager* tm)
954@@ -378,6 +342,8 @@
955 theTypeManager(tm),
956 theHasXSD(false)
957 {
958+ ZORBA_ASSERT(tm != &GENV_TYPESYSTEM);
959+
960 #ifndef ZORBA_NO_XMLSCHEMA
961 theGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
962 // QQQ should be zstring
963@@ -393,7 +359,6 @@
964 Schema::Schema(::zorba::serialization::Archiver& ar)
965 {
966 #ifndef ZORBA_NO_XMLSCHEMA
967- initialize();
968 theGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
969 theHasXSD = false;
970 #endif
971@@ -443,8 +408,8 @@
972 try
973 {
974 SAX2XMLReader* reader =
975- XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager,
976- theGrammarPool);
977+ XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager,
978+ theGrammarPool);
979
980 parser.reset(reader);
981 // Perform namespace processing
982@@ -879,7 +844,8 @@
983 baseXQType,
984 TypeConstants::QUANT_ONE,
985 XQType::ATOMIC_UDT,
986- XQType::SIMPLE_CONTENT_KIND);
987+ XQType::SIMPLE_CONTENT_KIND,
988+ false);
989
990 TRACE("created atomic " << qname->getStringValue()
991 << " base:" << baseXQType->toString());
992@@ -913,7 +879,8 @@
993 xsTypeDef->getAnonymous(),
994 qname,
995 NULL,
996- itemXQType.getp());
997+ itemXQType.getp(),
998+ false);
999
1000 //cout << " created UDT Simple List Type: " << xqType->toString() <<
1001 // endl; cout.flush();
1002@@ -970,7 +937,8 @@
1003 qname,
1004 baseXQType,
1005 TypeConstants::QUANT_ONE,
1006- unionItemTypes);
1007+ unionItemTypes,
1008+ false);
1009
1010 //std::cout << " created UDT Union Type: " << xqType->toString() << std::endl;
1011 // std::cout.flush();
1012@@ -1073,7 +1041,8 @@
1013 baseXQType,
1014 TypeConstants::QUANT_ONE,
1015 XQType::COMPLEX_UDT,
1016- contentType);
1017+ contentType,
1018+ false);
1019
1020 result = xqType;
1021
1022@@ -1330,7 +1299,8 @@
1023 }
1024
1025 XSNamedMap<XSObject> * elemDefs =
1026- model->getComponents(XSConstants::ELEMENT_DECLARATION);
1027+ model->getComponents(XSConstants::ELEMENT_DECLARATION);
1028+
1029 for( uint i = 0; i<elemDefs->getLength(); i++)
1030 {
1031 XSElementDeclaration* elemDecl = (XSElementDeclaration*)(elemDefs->item(i));
1032@@ -1539,13 +1509,14 @@
1033 }
1034
1035 xqtref_t xqType =
1036- xqtref_t(new UserDefinedXQType(typeManager,
1037- xsTypeDef->getAnonymous(),
1038- qname,
1039- baseXQType,
1040- TypeConstants::QUANT_ONE,
1041- XQType::COMPLEX_UDT,
1042- contentType));
1043+ xqtref_t(new UserDefinedXQType(typeManager,
1044+ xsTypeDef->getAnonymous(),
1045+ qname,
1046+ baseXQType,
1047+ TypeConstants::QUANT_ONE,
1048+ XQType::COMPLEX_UDT,
1049+ contentType,
1050+ false));
1051
1052 addTypeToCache(xqType);
1053
1054
1055=== modified file 'src/types/schema/schema.h'
1056--- src/types/schema/schema.h 2013-05-16 17:38:41 +0000
1057+++ src/types/schema/schema.h 2013-09-20 12:27:16 +0000
1058@@ -68,23 +68,15 @@
1059 static const char* XSD_NAMESPACE;
1060
1061 private:
1062- static bool theIsInitialized;
1063-
1064 TypeManager * theTypeManager;
1065
1066 bool theHasXSD;
1067 #ifndef ZORBA_NO_XMLSCHEMA
1068 XERCES_CPP_NAMESPACE::XMLGrammarPool * theGrammarPool;
1069- // QQQ use zstring?
1070 UdTypesCache * theUdTypesCache;
1071 #endif // ZORBA_NO_XMLSCHEMA
1072
1073 public:
1074- static void initialize();
1075-
1076- static void terminate();
1077-
1078-public:
1079 SERIALIZABLE_CLASS(Schema)
1080 Schema(::zorba::serialization::Archiver& ar);
1081 void serialize(::zorba::serialization::Archiver& ar);
1082
1083=== modified file 'src/types/typeimpl.cpp'
1084--- src/types/typeimpl.cpp 2013-07-23 17:34:35 +0000
1085+++ src/types/typeimpl.cpp 2013-09-20 12:27:16 +0000
1086@@ -174,6 +174,7 @@
1087 TypeConstants::quantifier_t quantifier,
1088 bool builtin)
1089 :
1090+ theRefCount(0),
1091 theManager((TypeManager*)manager),
1092 theKind(type_kind),
1093 theQuantifier(quantifier),
1094@@ -182,13 +183,33 @@
1095 if (theIsBuiltin)
1096 {
1097 #ifndef NDEBUG
1098- theRefCount = 1000000;
1099+ //theRefCount = 1000000;
1100 #endif
1101 // register this hardcoded object to help plan serialization
1102 XQType* this_ptr = this;
1103 *::zorba::serialization::ClassSerializer::getInstance()->
1104 getArchiverForHardcodedObjects() & this_ptr;
1105 }
1106+#if 0
1107+ else
1108+ {
1109+ std::cout << "allocated type " << this << " of kind "
1110+ << KIND_STRINGS[type_kind] << std::endl;
1111+ }
1112+#endif
1113+}
1114+
1115+
1116+/*******************************************************************************
1117+
1118+********************************************************************************/
1119+XQType::~XQType()
1120+{
1121+ if (theIsBuiltin)
1122+ {
1123+ assert(theRefCount == 0);
1124+ theRefCount = 0;
1125+ }
1126 }
1127
1128
1129@@ -796,6 +817,21 @@
1130 (contentType == NULL ||
1131 contentType->type_kind() == XQType::UNTYPED_KIND ||
1132 contentType->type_kind() == XQType::ANY_TYPE_KIND));
1133+
1134+#if 0
1135+ if (theIsBuiltin == false &&
1136+ nodeKind == store::StoreConsts::elementNode &&
1137+ contentType == NULL &&
1138+ nodeName == NULL)
1139+ {
1140+ ZORBA_ASSERT(false);
1141+ }
1142+
1143+ if (!theIsBuiltin)
1144+ {
1145+ std::cout << "allocated type " << this << " : " << toSchemaString() << std::endl;
1146+ }
1147+#endif
1148 }
1149
1150
1151@@ -804,15 +840,31 @@
1152 ********************************************************************************/
1153 NodeXQType::NodeXQType(
1154 const NodeXQType& source,
1155- TypeConstants::quantifier_t quantifier)
1156+ TypeConstants::quantifier_t quantifier,
1157+ bool builtin)
1158 :
1159- XQType(source.theManager, NODE_TYPE_KIND, quantifier, false),
1160+ XQType(source.theManager, NODE_TYPE_KIND, quantifier, builtin),
1161 theNodeKind(source.theNodeKind),
1162 theNodeName(source.theNodeName),
1163 theContentType(source.theContentType),
1164 theNillable(source.theNillable),
1165 theIsSchemaTest(source.theIsSchemaTest)
1166 {
1167+#if 0
1168+ if (theIsBuiltin == false &&
1169+ theNodeKind == store::StoreConsts::elementNode &&
1170+ theContentType == NULL &&
1171+ theNodeName == NULL)
1172+ {
1173+ std::cerr << "STRANGE TYPE" << std::endl;
1174+ theNodeKind = store::StoreConsts::elementNode;
1175+ }
1176+
1177+ if (!theIsBuiltin)
1178+ {
1179+ std::cout << "allocated copy type " << this << " : " << toSchemaString() << std::endl;
1180+ }
1181+#endif
1182 }
1183
1184
1185
1186=== modified file 'src/types/typeimpl.h'
1187--- src/types/typeimpl.h 2013-08-02 21:35:01 +0000
1188+++ src/types/typeimpl.h 2013-09-20 12:27:16 +0000
1189@@ -264,11 +264,7 @@
1190 TypeManager is deleted during engine shutdown.
1191
1192 ********************************************************************************/
1193-#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY
1194-class XQType : public SimpleRCObject
1195-#else
1196-class XQType : public SyncedRCObject
1197-#endif
1198+class XQType : public serialization::SerializeBaseClass
1199 {
1200 public:
1201 //
1202@@ -341,6 +337,8 @@
1203 protected:
1204 static const char * KIND_STRINGS[XQType::MAX_TYPE_KIND];
1205
1206+ mutable long theRefCount;
1207+
1208 TypeManager * theManager;
1209 TypeKind theKind;
1210 TypeConstants::quantifier_t theQuantifier;
1211@@ -349,21 +347,42 @@
1212
1213 public:
1214 SERIALIZABLE_ABSTRACT_CLASS(XQType)
1215-#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY
1216- SERIALIZABLE_CLASS_CONSTRUCTOR2(XQType, SimpleRCObject)
1217-#else
1218- SERIALIZABLE_CLASS_CONSTRUCTOR2(XQType, SyncedRCObject)
1219-#endif
1220+
1221+ XQType(::zorba::serialization::Archiver& ar)
1222+ :
1223+ serialization::SerializeBaseClass(),
1224+ theRefCount(0),
1225+ theIsBuiltin(false)
1226+ {
1227+ }
1228+
1229 void serialize(::zorba::serialization::Archiver& ar);
1230
1231 public:
1232- virtual ~XQType() { }
1233-
1234- void free()
1235- {
1236- if (!theIsBuiltin)
1237- delete this;
1238- }
1239+ long getRefCount() const
1240+ {
1241+ return theRefCount;
1242+ }
1243+
1244+ void addReference() const
1245+ {
1246+ if (!theIsBuiltin)
1247+ ++theRefCount;
1248+ }
1249+
1250+ void removeReference()
1251+ {
1252+ if (!theIsBuiltin)
1253+ {
1254+ assert(getRefCount() > 0);
1255+
1256+ if (--theRefCount == 0)
1257+ delete this;
1258+ }
1259+ }
1260+
1261+public:
1262+ virtual ~XQType();
1263
1264 TypeManager* get_manager() const { return theManager; }
1265
1266@@ -421,6 +440,9 @@
1267 TypeKind kind,
1268 TypeConstants::quantifier_t quant,
1269 bool builtin);
1270+
1271+private:
1272+ XQType& operator=(const XQType& t);
1273 };
1274
1275
1276@@ -435,7 +457,7 @@
1277 class NoneXQType : public XQType
1278 {
1279 public:
1280- NoneXQType(const TypeManager* manager, bool builtin = false);
1281+ NoneXQType(const TypeManager* manager, bool builtin);
1282
1283 public:
1284 SERIALIZABLE_CLASS(NoneXQType)
1285@@ -450,7 +472,7 @@
1286 class EmptyXQType : public XQType
1287 {
1288 public:
1289- EmptyXQType(const TypeManager* manager, bool builtin = false);
1290+ EmptyXQType(const TypeManager* manager, bool builtin);
1291
1292 public:
1293 SERIALIZABLE_CLASS(EmptyXQType)
1294@@ -468,7 +490,7 @@
1295 ItemXQType(
1296 const TypeManager* tm,
1297 TypeConstants::quantifier_t q,
1298- bool builtin = false);
1299+ bool builtin);
1300
1301 public:
1302 SERIALIZABLE_CLASS(ItemXQType)
1303@@ -501,7 +523,7 @@
1304 const TypeManager* manager,
1305 store::SchemaTypeCode code,
1306 TypeConstants::quantifier_t quant,
1307- bool builtin = false)
1308+ bool builtin)
1309 :
1310 XQType(manager, ATOMIC_TYPE_KIND, quant, builtin),
1311 theAtomicCode(code)
1312@@ -524,7 +546,7 @@
1313 StructuredItemXQType(
1314 const TypeManager* tm,
1315 TypeConstants::quantifier_t quant,
1316- bool builtin = false);
1317+ bool builtin);
1318
1319 public:
1320 SERIALIZABLE_CLASS(StructuredItemXQType)
1321@@ -552,7 +574,7 @@
1322 const TypeManager* manager,
1323 store::StoreConsts::JSONItemKind kind,
1324 TypeConstants::quantifier_t quantifier,
1325- bool builtin = false);
1326+ bool builtin);
1327
1328 store::StoreConsts::JSONItemKind get_json_kind() const { return theJSONKind; }
1329
1330@@ -589,9 +611,12 @@
1331 TypeConstants::quantifier_t quantifier,
1332 bool nillable,
1333 bool schematest,
1334- bool builtin = false);
1335+ bool builtin);
1336
1337- NodeXQType(const NodeXQType& source, TypeConstants::quantifier_t quant);
1338+ NodeXQType(
1339+ const NodeXQType& source,
1340+ TypeConstants::quantifier_t quant,
1341+ bool builtin);
1342
1343 store::StoreConsts::NodeKind get_node_kind() const { return theNodeKind; }
1344
1345@@ -630,7 +655,7 @@
1346 class AnyFunctionXQType : public XQType
1347 {
1348 public:
1349- AnyFunctionXQType(const TypeManager* manager, bool builtin = false)
1350+ AnyFunctionXQType(const TypeManager* manager, bool builtin)
1351 :
1352 XQType(manager, ANY_FUNCTION_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)
1353 {
1354@@ -639,7 +664,7 @@
1355 AnyFunctionXQType(
1356 const TypeManager* manager,
1357 TypeConstants::quantifier_t quantifier,
1358- bool builtin = false)
1359+ bool builtin)
1360 :
1361 XQType(manager, ANY_FUNCTION_TYPE_KIND, quantifier, builtin)
1362 {
1363@@ -673,7 +698,7 @@
1364 const std::vector<xqtref_t>& aParamTypes,
1365 const xqtref_t& aReturnType,
1366 TypeConstants::quantifier_t quantifier,
1367- bool builtin = false);
1368+ bool builtin);
1369
1370 const std::vector<xqtref_t>&
1371 get_param_types() const { return m_param_types; }
1372@@ -773,7 +798,7 @@
1373 TypeConstants::quantifier_t quantifier,
1374 UDTKind typeCategory,
1375 content_kind_t contentKind,
1376- bool builtin = false);
1377+ bool builtin);
1378
1379 // Constructor for List types
1380 UserDefinedXQType(
1381@@ -782,7 +807,7 @@
1382 store::Item_t qname,
1383 const xqtref_t& baseType,
1384 const XQType* listItemType,
1385- bool builtin = false);
1386+ bool builtin);
1387
1388 // Constructor for Union types
1389 UserDefinedXQType(
1390@@ -792,7 +817,7 @@
1391 const xqtref_t& baseType,
1392 TypeConstants::quantifier_t quantifier,
1393 const std::vector<xqtref_t>& unionItemTypes,
1394- bool builtin = false);
1395+ bool builtin);
1396
1397 virtual ~UserDefinedXQType() {}
1398
1399@@ -823,7 +848,7 @@
1400 class AnyXQType : public XQType
1401 {
1402 public:
1403- AnyXQType(const TypeManager* manager, bool builtin = false)
1404+ AnyXQType(const TypeManager* manager, bool builtin)
1405 :
1406 XQType(manager, ANY_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)
1407 {
1408@@ -842,7 +867,7 @@
1409 class UntypedXQType : public XQType
1410 {
1411 public:
1412- UntypedXQType(const TypeManager* manager, bool builtin = false)
1413+ UntypedXQType(const TypeManager* manager, bool builtin)
1414 :
1415 XQType(manager, UNTYPED_KIND, TypeConstants::QUANT_STAR, builtin)
1416 {
1417@@ -861,7 +886,7 @@
1418 class AnySimpleXQType : public XQType
1419 {
1420 public:
1421- AnySimpleXQType(const TypeManager* manager, bool builtin = false)
1422+ AnySimpleXQType(const TypeManager* manager, bool builtin)
1423 :
1424 XQType(manager, ANY_SIMPLE_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)
1425 {
1426
1427=== modified file 'src/types/typemanagerimpl.cpp'
1428--- src/types/typemanagerimpl.cpp 2013-07-01 18:59:06 +0000
1429+++ src/types/typemanagerimpl.cpp 2013-09-20 12:27:16 +0000
1430@@ -112,6 +112,8 @@
1431 ********************************************************************************/
1432 void TypeManagerImpl::initializeSchema()
1433 {
1434+ ZORBA_ASSERT(this != &GENV_TYPESYSTEM);
1435+
1436 if ( m_schema == NULL )
1437 m_schema = new Schema(this);
1438 }
1439@@ -223,7 +225,7 @@
1440 const xqtref_t& returnType,
1441 TypeConstants::quantifier_t quant) const
1442 {
1443- return new FunctionXQType(this, paramTypes, returnType, quant);
1444+ return new FunctionXQType(this, paramTypes, returnType, quant, false);
1445 }
1446
1447
1448@@ -532,7 +534,14 @@
1449 }
1450 else
1451 {
1452- return new NodeXQType(this, nodeKind, NULL, contentType, quant, false, false);
1453+ return new NodeXQType(this,
1454+ nodeKind,
1455+ NULL,
1456+ contentType,
1457+ quant,
1458+ false,
1459+ false,
1460+ false);
1461 }
1462 }
1463
1464@@ -548,7 +557,8 @@
1465 contentType,
1466 quant,
1467 nillable,
1468- schematest);
1469+ schematest,
1470+ false);
1471 }
1472 else
1473 {
1474@@ -567,7 +577,8 @@
1475 contentType,
1476 quant,
1477 false,
1478- schematest);
1479+ schematest,
1480+ false);
1481 }
1482 else
1483 {
1484@@ -594,6 +605,7 @@
1485 RTM.STRING_TYPE_ONE,
1486 quant,
1487 nillable,
1488+ false,
1489 false);
1490 }
1491 }
1492@@ -861,7 +873,8 @@
1493 return new FunctionXQType(this,
1494 paramTypes,
1495 nonOptimizedRetType.getp() ? nonOptimizedRetType : retType,
1496- quant);
1497+ quant,
1498+ false);
1499 }
1500
1501 else
1502@@ -1006,7 +1019,7 @@
1503 }
1504 else
1505 {
1506- return new NodeXQType(nt, quantifier);
1507+ return new NodeXQType(nt, quantifier, false);
1508 }
1509 }
1510
1511@@ -1027,7 +1040,8 @@
1512 return new FunctionXQType(this,
1513 ft.get_param_types(),
1514 ft.get_return_type(),
1515- quantifier);
1516+ quantifier,
1517+ false);
1518 }
1519
1520 case XQType::ITEM_KIND:
1521@@ -1064,7 +1078,8 @@
1522 udt.isAnonymous(),
1523 udt.getQName(),
1524 udt.getBaseType(),
1525- udt.getListItemType());
1526+ udt.getListItemType(),
1527+ false);
1528 }
1529 else if (udt.isUnion())
1530 {
1531@@ -1073,7 +1088,8 @@
1532 udt.getQName(),
1533 udt.getBaseType(),
1534 quantifier,
1535- udt.getUnionItemTypes());
1536+ udt.getUnionItemTypes(),
1537+ false);
1538 }
1539 else
1540 {
1541@@ -1083,7 +1099,8 @@
1542 udt.getBaseType(),
1543 quantifier,
1544 udt.getUDTKind(),
1545- udt.contentKind());
1546+ udt.contentKind(),
1547+ false);
1548 }
1549 }
1550 default:
1551
1552=== modified file 'src/types/typeops.cpp'
1553--- src/types/typeops.cpp 2013-06-24 07:56:21 +0000
1554+++ src/types/typeops.cpp 2013-09-20 12:27:16 +0000
1555@@ -322,7 +322,6 @@
1556
1557 case XQType::JSON_TYPE_KIND:
1558 case XQType::NODE_TYPE_KIND:
1559-
1560 {
1561 if (type.get_quantifier() == TypeConstants::QUANT_ONE)
1562 return &type;
1563
1564=== modified file 'src/zorbaserialization/class_serializer.cpp'
1565--- src/zorbaserialization/class_serializer.cpp 2013-02-07 17:24:36 +0000
1566+++ src/zorbaserialization/class_serializer.cpp 2013-09-20 12:27:16 +0000
1567@@ -40,6 +40,16 @@
1568 /*******************************************************************************
1569
1570 ********************************************************************************/
1571+ClassSerializer* ClassSerializer::getInstance()
1572+{
1573+ static ClassSerializer theInstance;
1574+ return &theInstance;
1575+}
1576+
1577+
1578+/*******************************************************************************
1579+
1580+********************************************************************************/
1581 ClassSerializer::ClassSerializer()
1582 {
1583 theClassFactories.resize(TYPE_LAST);
1584@@ -60,12 +70,21 @@
1585
1586
1587 /*******************************************************************************
1588-
1589-********************************************************************************/
1590-ClassSerializer* ClassSerializer::getInstance()
1591-{
1592- static ClassSerializer theInstance;
1593- return &theInstance;
1594+ called from GlobalEnvironment::destroy()
1595+********************************************************************************/
1596+void ClassSerializer::destroyArchiverForHardcodedObjects()
1597+{
1598+ delete harcoded_objects_archive;
1599+ harcoded_objects_archive = new MemArchiver(true, true);;
1600+}
1601+
1602+
1603+/*******************************************************************************
1604+
1605+********************************************************************************/
1606+Archiver* ClassSerializer::getArchiverForHardcodedObjects()
1607+{
1608+ return harcoded_objects_archive;
1609 }
1610
1611
1612@@ -93,26 +112,6 @@
1613 }
1614
1615
1616-/*******************************************************************************
1617-
1618-********************************************************************************/
1619-Archiver* ClassSerializer::getArchiverForHardcodedObjects()
1620-{
1621- return harcoded_objects_archive;
1622-}
1623-
1624-
1625-/*******************************************************************************
1626- called at shutdown
1627-********************************************************************************/
1628-void ClassSerializer::destroyArchiverForHardcodedObjects()
1629-{
1630- delete harcoded_objects_archive;
1631- harcoded_objects_archive = NULL;
1632- harcoded_objects_archive = new MemArchiver(true, true);
1633-}
1634-
1635-
1636 } // namespace serialization
1637 } // namespace zorba
1638 /* vim:set et sw=2 ts=2: */
1639
1640=== modified file 'src/zorbaserialization/class_serializer.h'
1641--- src/zorbaserialization/class_serializer.h 2013-03-05 00:45:43 +0000
1642+++ src/zorbaserialization/class_serializer.h 2013-09-20 12:27:16 +0000
1643@@ -125,7 +125,7 @@
1644 void operator&(Archiver& ar, T*& obj).
1645
1646 ********************************************************************************/
1647-class ZORBA_DLL_PUBLIC SerializeBaseClass
1648+class SerializeBaseClass
1649 {
1650 public:
1651 virtual ~SerializeBaseClass() {}

Subscribers

People subscribed via source and target branches