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
=== modified file 'src/compiler/expression/expr_type.cpp'
--- src/compiler/expression/expr_type.cpp 2013-08-16 13:00:06 +0000
+++ src/compiler/expression/expr_type.cpp 2013-09-20 12:27:16 +0000
@@ -675,7 +675,7 @@
675 for (csize i = 0; i < fiExpr->get_function()->getSignature().paramCount(); ++i)675 for (csize i = 0; i < fiExpr->get_function()->getSignature().paramCount(); ++i)
676 paramTypes.push_back(fiExpr->get_function()->getSignature()[i]);676 paramTypes.push_back(fiExpr->get_function()->getSignature()[i]);
677677
678 theType = new FunctionXQType(&rtm, paramTypes, retType, TypeConstants::QUANT_ONE);678 theType = rtm.create_function_type(paramTypes, retType, TypeConstants::QUANT_ONE);
679 }679 }
680 return;680 return;
681 }681 }
682682
=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp 2013-09-17 21:12:49 +0000
+++ src/compiler/translator/translator.cpp 2013-09-20 12:27:16 +0000
@@ -1506,8 +1506,99 @@
15061506
1507 TypeManager* tm = argExpr->get_type_manager();1507 TypeManager* tm = argExpr->get_type_manager();
15081508
1509 paramType = sign[i];
1510
1509 switch (func->getKind())1511 switch (func->getKind())
1510 {1512 {
1513 case FunctionConsts::FN_ZORBA_XML_PARSE_2:
1514 {
1515 if (i == 1)
1516 {
1517 paramType = tm->
1518 create_node_type(store::StoreConsts::elementNode,
1519 createQName(static_context::ZORBA_XML_FN_OPTIONS_NS,
1520 "",
1521 "options"),
1522 NULL,
1523 TypeConstants::QUANT_QUESTION,
1524 false,
1525 false);
1526 }
1527 break;
1528 }
1529 case FunctionConsts::FN_FOR_EACH_2:
1530 {
1531 if (i == 1)
1532 {
1533 std::vector<xqtref_t> args;
1534 args.push_back(theRTM.ITEM_TYPE_ONE);
1535
1536 paramType = tm->
1537 create_function_type(args,
1538 theRTM.ITEM_TYPE_STAR,
1539 TypeConstants::QUANT_ONE);
1540 }
1541 break;
1542 }
1543 case FunctionConsts::FN_FOR_EACH_PAIR_3:
1544 {
1545 if (i == 2)
1546 {
1547 std::vector<xqtref_t> args;
1548 args.push_back(theRTM.ITEM_TYPE_ONE);
1549 args.push_back(theRTM.ITEM_TYPE_ONE);
1550
1551 paramType = tm->
1552 create_function_type(args,
1553 theRTM.ITEM_TYPE_STAR,
1554 TypeConstants::QUANT_ONE);
1555 }
1556 break;
1557 }
1558 case FunctionConsts::FN_FOLD_LEFT_3:
1559 {
1560 if (i == 2)
1561 {
1562 std::vector<xqtref_t> args;
1563 args.push_back(theRTM.ITEM_TYPE_STAR);
1564 args.push_back(theRTM.ITEM_TYPE_ONE);
1565
1566 paramType = tm->
1567 create_function_type(args,
1568 theRTM.ITEM_TYPE_STAR,
1569 TypeConstants::QUANT_ONE);
1570 }
1571 break;
1572 }
1573 case FunctionConsts::FN_FOLD_RIGHT_3:
1574 {
1575 if (i == 2)
1576 {
1577 std::vector<xqtref_t> args;
1578 args.push_back(theRTM.ITEM_TYPE_ONE);
1579 args.push_back(theRTM.ITEM_TYPE_STAR);
1580
1581 paramType = tm->
1582 create_function_type(args,
1583 theRTM.ITEM_TYPE_STAR,
1584 TypeConstants::QUANT_ONE);
1585 }
1586 break;
1587 }
1588 case FunctionConsts::FN_FILTER_2:
1589 {
1590 if (i == 1)
1591 {
1592 std::vector<xqtref_t> args;
1593 args.push_back(theRTM.ITEM_TYPE_ONE);
1594
1595 paramType = tm->
1596 create_function_type(args,
1597 theRTM.BOOLEAN_TYPE_ONE,
1598 TypeConstants::QUANT_ONE);
1599 }
1600 break;
1601 }
1511 case FunctionConsts::FN_ZORBA_XQDDF_PROBE_INDEX_POINT_VALUE_N:1602 case FunctionConsts::FN_ZORBA_XQDDF_PROBE_INDEX_POINT_VALUE_N:
1512 {1603 {
1513 if (i == 0)1604 if (i == 0)
@@ -1562,7 +1653,7 @@
1562 }1653 }
1563 default:1654 default:
1564 {1655 {
1565 paramType = sign[i];1656 break;
1566 }1657 }
1567 }1658 }
15681659
@@ -4041,7 +4132,7 @@
4041 // We make sure that the types of the parameters and the return type4132 // We make sure that the types of the parameters and the return type
4042 // are subtypes of the ones declared in the module4133 // are subtypes of the ones declared in the module
4043 const signature& s = f->getSignature();4134 const signature& s = f->getSignature();
4044 if (!s.subtype(tm, sig, loc))4135 if (!s.subtype(tm, f, sig, loc))
4045 {4136 {
4046 RAISE_ERROR(zerr::ZXQP0007_FUNCTION_SIGNATURE_NOT_EQUAL, loc,4137 RAISE_ERROR(zerr::ZXQP0007_FUNCTION_SIGNATURE_NOT_EQUAL, loc,
4047 ERROR_PARAMS(BUILD_STRING('{',4138 ERROR_PARAMS(BUILD_STRING('{',
40484139
=== modified file 'src/functions/func_fn_hof_functions_impl.cpp'
--- src/functions/func_fn_hof_functions_impl.cpp 2013-06-04 21:47:40 +0000
+++ src/functions/func_fn_hof_functions_impl.cpp 2013-09-20 12:27:16 +0000
@@ -143,100 +143,48 @@
143********************************************************************************/143********************************************************************************/
144void populate_context_hof_impl(static_context* sctx)144void populate_context_hof_impl(static_context* sctx)
145{145{
146 {146 DECL_WITH_KIND(sctx,
147 std::vector<xqtref_t> args;147 fn_for_each_3_0,
148 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);148 (createQName(static_context::W3C_FN_NS, "", "for-each"),
149149 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
150 xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(150 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
151 args,151 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
152 GENV_TYPESYSTEM.ITEM_TYPE_STAR,152 FunctionConsts::FN_FOR_EACH_2);
153 TypeConstants::QUANT_ONE);153
154154 DECL_WITH_KIND(sctx,
155 DECL_WITH_KIND(sctx,155 fn_filter,
156 fn_for_each_3_0,156 (createQName(static_context::W3C_FN_NS, "", "filter"),
157 (createQName(static_context::W3C_FN_NS, "", "for-each"),157 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
158 GENV_TYPESYSTEM.ITEM_TYPE_STAR,158 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
159 hofParamType,159 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
160 GENV_TYPESYSTEM.ITEM_TYPE_STAR),160 FunctionConsts::FN_FILTER_2);
161 FunctionConsts::FN_FOR_EACH_2);161
162 }162 DECL_WITH_KIND(sctx,
163163 fn_for_each_pair_3_0,
164 {164 (createQName(static_context::W3C_FN_NS, "", "for-each-pair"),
165 std::vector<xqtref_t> args;165 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
166 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);166 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
167167 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
168 xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(168 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
169 args,169 FunctionConsts::FN_FOR_EACH_PAIR_3);
170 GENV_TYPESYSTEM.BOOLEAN_TYPE_ONE,170
171 TypeConstants::QUANT_ONE);171 DECL_WITH_KIND(sctx,
172172 fn_fold_left_3_0,
173 DECL_WITH_KIND(sctx,173 (createQName(static_context::W3C_FN_NS, "", "fold-left"),
174 fn_filter,174 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
175 (createQName(static_context::W3C_FN_NS, "", "filter"),175 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
176 GENV_TYPESYSTEM.ITEM_TYPE_STAR,176 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
177 hofParamType,177 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
178 GENV_TYPESYSTEM.ITEM_TYPE_STAR),178 FunctionConsts::FN_FOLD_LEFT_3);
179 FunctionConsts::FN_FILTER_2);179
180 }180 DECL_WITH_KIND(sctx,
181181 fn_fold_right_3_0,
182 {182 (createQName(static_context::W3C_FN_NS, "", "fold-right"),
183 std::vector<xqtref_t> args;183 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
184 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);184 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
185 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);185 GENV_TYPESYSTEM.ANY_FUNCTION_TYPE_ONE,
186186 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
187 xqtref_t hofParamType = GENV_TYPESYSTEM.create_function_type(187 FunctionConsts::FN_FOLD_RIGHT_3);
188 args,
189 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
190 TypeConstants::QUANT_ONE);
191
192 DECL_WITH_KIND(sctx,
193 fn_for_each_pair_3_0,
194 (createQName(static_context::W3C_FN_NS, "", "for-each-pair"),
195 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
196 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
197 hofParamType,
198 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
199 FunctionConsts::FN_FOR_EACH_PAIR_3);
200 }
201
202 {
203 std::vector<xqtref_t> args;
204 xqtref_t hofParamType;
205
206 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
207 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
208 hofParamType = GENV_TYPESYSTEM.create_function_type(
209 args,
210 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
211 TypeConstants::QUANT_ONE);
212
213 DECL_WITH_KIND(sctx,
214 fn_fold_left_3_0,
215 (createQName(static_context::W3C_FN_NS, "", "fold-left"),
216 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
217 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
218 hofParamType,
219 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
220 FunctionConsts::FN_FOLD_LEFT_3);
221
222 args.clear();
223 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_ONE);
224 args.push_back(GENV_TYPESYSTEM.ITEM_TYPE_STAR);
225 hofParamType = GENV_TYPESYSTEM.create_function_type(
226 args,
227 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
228 TypeConstants::QUANT_ONE);
229
230 DECL_WITH_KIND(sctx,
231 fn_fold_right_3_0,
232 (createQName(static_context::W3C_FN_NS, "", "fold-right"),
233 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
234 GENV_TYPESYSTEM.ITEM_TYPE_STAR,
235 hofParamType,
236 GENV_TYPESYSTEM.ITEM_TYPE_STAR),
237 FunctionConsts::FN_FOLD_RIGHT_3);
238 }
239
240}188}
241189
242}190}
243191
=== modified file 'src/functions/func_parse_fragment_impl.cpp'
--- src/functions/func_parse_fragment_impl.cpp 2013-07-24 09:06:02 +0000
+++ src/functions/func_parse_fragment_impl.cpp 2013-09-20 12:27:16 +0000
@@ -37,25 +37,17 @@
37********************************************************************************/37********************************************************************************/
38void populate_context_parse_fragment_impl(static_context* sctx)38void populate_context_parse_fragment_impl(static_context* sctx)
39{39{
40 xqtref_t lParseOptType =40 // Note: the actual type of the 2nd param should be element(options)?
41 GENV_TYPESYSTEM.create_node_type(41 // However, we cannot use a non-builtin type in the signature of a builtin
42 store::StoreConsts::elementNode,42 // function. That's why we use type element() here and do special handling
43 createQName(static_context::ZORBA_XML_FN_OPTIONS_NS,"","options"),43 // of this function in the translator.
44 NULL,44 DECL_WITH_KIND(sctx, fn_zorba_xml_parse,
45 TypeConstants::QUANT_QUESTION,45 (createQName(static_context::ZORBA_XML_FN_NS, "", "parse"),
46 false,46 GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
47 false47 GENV_TYPESYSTEM.ELEMENT_TYPE_QUESTION,
48 );48 GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
4949 FunctionConsts::FN_ZORBA_XML_PARSE_2);
50 {50
51 DECL_WITH_KIND(sctx, fn_zorba_xml_parse,
52 (createQName(static_context::ZORBA_XML_FN_NS,"","parse"),
53 GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
54 lParseOptType,
55 GENV_TYPESYSTEM.ANY_NODE_TYPE_STAR),
56 FunctionConsts::FN_ZORBA_XML_PARSE_2);
57
58 }
59}51}
6052
61}53}
6254
=== modified file 'src/functions/func_strings_impl.cpp'
--- src/functions/func_strings_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/functions/func_strings_impl.cpp 2013-09-20 12:27:16 +0000
@@ -62,27 +62,34 @@
62}62}
6363
6464
65
65/*******************************************************************************66/*******************************************************************************
6667
67********************************************************************************/68********************************************************************************/
68void populate_context_strings_impl(static_context* sctx)69xqtref_t fn_analyze_string_3_0::getReturnType(const fo_expr* caller) const
69{70{
70 xqtref_t lAnalyzeStringResultType =71 return
71 GENV_TYPESYSTEM.create_node_type(72 GENV_TYPESYSTEM.create_node_type(
72 store::StoreConsts::elementNode,73 store::StoreConsts::elementNode,
73 createQName("http://www.w3.org/2005/xpath-functions","","analyze-string-result"),74 createQName(static_context::W3C_FN_NS,"","analyze-string-result"),
74 NULL,75 NULL,
75 TypeConstants::QUANT_ONE,76 TypeConstants::QUANT_ONE,
76 false,77 false,
77 false78 false);
78 );79}
7980
81
82/*******************************************************************************
83
84********************************************************************************/
85void populate_context_strings_impl(static_context* sctx)
86{
80 {87 {
81 DECL_WITH_KIND(sctx, fn_analyze_string_3_0,88 DECL_WITH_KIND(sctx, fn_analyze_string_3_0,
82 (createQName("http://www.w3.org/2005/xpath-functions","","analyze-string"), 89 (createQName("http://www.w3.org/2005/xpath-functions","","analyze-string"),
83 GENV_TYPESYSTEM.STRING_TYPE_QUESTION, 90 GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
84 GENV_TYPESYSTEM.STRING_TYPE_ONE, 91 GENV_TYPESYSTEM.STRING_TYPE_ONE,
85 lAnalyzeStringResultType),92 GENV_TYPESYSTEM.ELEMENT_TYPE_ONE),
86 FunctionConsts::FN_ANALYZE_STRING_2);93 FunctionConsts::FN_ANALYZE_STRING_2);
8794
88 }95 }
@@ -94,7 +101,7 @@
94 GENV_TYPESYSTEM.STRING_TYPE_QUESTION, 101 GENV_TYPESYSTEM.STRING_TYPE_QUESTION,
95 GENV_TYPESYSTEM.STRING_TYPE_ONE, 102 GENV_TYPESYSTEM.STRING_TYPE_ONE,
96 GENV_TYPESYSTEM.STRING_TYPE_ONE, 103 GENV_TYPESYSTEM.STRING_TYPE_ONE,
97 lAnalyzeStringResultType),104 GENV_TYPESYSTEM.ELEMENT_TYPE_ONE),
98 FunctionConsts::FN_ANALYZE_STRING_3);105 FunctionConsts::FN_ANALYZE_STRING_3);
99 }106 }
100}107}
101108
=== modified file 'src/functions/function.cpp'
--- src/functions/function.cpp 2013-07-31 16:35:39 +0000
+++ src/functions/function.cpp 2013-09-20 12:27:16 +0000
@@ -57,6 +57,12 @@
57 setFlag(FunctionConsts::isBuiltin);57 setFlag(FunctionConsts::isBuiltin);
58#ifndef NDEBUG58#ifndef NDEBUG
59 theRefCount = 1000000;59 theRefCount = 1000000;
60
61 csize numTypes = sig.theTypes.size();
62 for (csize i = 0; i < numTypes; ++i)
63 {
64 assert(sig.theTypes[i]->is_builtin());
65 }
60#endif66#endif
61 }67 }
6268
6369
=== modified file 'src/functions/function.h'
--- src/functions/function.h 2013-08-02 21:35:01 +0000
+++ src/functions/function.h 2013-09-20 12:27:16 +0000
@@ -48,11 +48,7 @@
48 The root sctx of the module containing the declaration. It is NULL for 48 The root sctx of the module containing the declaration. It is NULL for
49 functions that must be executed in the static context of the caller.49 functions that must be executed in the static context of the caller.
50********************************************************************************/50********************************************************************************/
51#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY
52class function : public SimpleRCObject51class function : public SimpleRCObject
53#else
54class function : public SyncedRCObject
55#endif
56{52{
57protected:53protected:
58 signature theSignature;54 signature theSignature;
@@ -66,11 +62,7 @@
6662
67public:63public:
68 SERIALIZABLE_CLASS(function);64 SERIALIZABLE_CLASS(function);
69#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY
70 SERIALIZABLE_CLASS_CONSTRUCTOR3(function, SimpleRCObject, theSignature);65 SERIALIZABLE_CLASS_CONSTRUCTOR3(function, SimpleRCObject, theSignature);
71#else
72 SERIALIZABLE_CLASS_CONSTRUCTOR3(function, SyncedRCObject, theSignature);
73#endif
74 void serialize(::zorba::serialization::Archiver& ar);66 void serialize(::zorba::serialization::Archiver& ar);
7567
76public:68public:
7769
=== modified file 'src/functions/pregenerated/func_strings.h'
--- src/functions/pregenerated/func_strings.h 2013-07-11 22:08:29 +0000
+++ src/functions/pregenerated/func_strings.h 2013-09-20 12:27:16 +0000
@@ -447,6 +447,8 @@
447theXQueryVersion = StaticContextConsts::xquery_version_3_0;447theXQueryVersion = StaticContextConsts::xquery_version_3_0;
448 }448 }
449449
450 xqtref_t getReturnType(const fo_expr* caller) const;
451
450 CODEGEN_DECL();452 CODEGEN_DECL();
451};453};
452454
453455
=== modified file 'src/functions/signature.cpp'
--- src/functions/signature.cpp 2013-03-04 21:00:58 +0000
+++ src/functions/signature.cpp 2013-09-20 12:27:16 +0000
@@ -21,6 +21,13 @@
2121
22#include "types/typeops.h"22#include "types/typeops.h"
2323
24#include "functions/function.h"
25#include "functions/library.h"
26
27#include "context/static_context.h"
28
29#include "store/api/item_factory.h"
30
24#include "zorbaserialization/serialize_template_types.h"31#include "zorbaserialization/serialize_template_types.h"
25#include "zorbaserialization/serialize_zorba_types.h"32#include "zorbaserialization/serialize_zorba_types.h"
2633
@@ -31,100 +38,100 @@
31{38{
3239
33SERIALIZABLE_CLASS_VERSIONS(signature)40SERIALIZABLE_CLASS_VERSIONS(signature)
3441
3542
36signature::signature(43signature::signature(
37 const store::Item_t& name,44 const store::Item_t& name,
38 const xqtref_t& paramType1,45 const xqtref_t& paramType1,
39 bool variadic,46 bool variadic,
40 const xqtref_t& returnType)47 const xqtref_t& returnType)
41 :48 :
42 theQName(name),49 theQName(name),
43 theNonOptimizedReturnType(NULL),50 theNonOptimizedReturnType(NULL),
44 theIsVariadic(variadic)51 theIsVariadic(variadic)
45{52{
46 theTypes.push_back(returnType);53 theTypes.push_back(returnType);
47 theTypes.push_back(paramType1);54 theTypes.push_back(paramType1);
48}55}
4956
5057
51signature::signature(58signature::signature(
52 const store::Item_t& name,59 const store::Item_t& name,
53 const xqtref_t& paramType1,60 const xqtref_t& paramType1,
54 const xqtref_t& paramType2,61 const xqtref_t& paramType2,
55 bool variadic,62 bool variadic,
56 const xqtref_t& returnType)63 const xqtref_t& returnType)
57 :64 :
58 theQName(name),65 theQName(name),
59 theNonOptimizedReturnType(NULL),66 theNonOptimizedReturnType(NULL),
60 theIsVariadic(variadic)67 theIsVariadic(variadic)
61{68{
62 theTypes.push_back(returnType);69 theTypes.push_back(returnType);
63 theTypes.push_back(paramType1);70 theTypes.push_back(paramType1);
64 theTypes.push_back(paramType2);71 theTypes.push_back(paramType2);
65}72}
6673
6774
68signature::signature(75signature::signature(
69 const store::Item_t& name,76 const store::Item_t& name,
70 const xqtref_t& returnType)77 const xqtref_t& returnType)
71 :78 :
72 theQName(name),79 theQName(name),
73 theNonOptimizedReturnType(NULL),80 theNonOptimizedReturnType(NULL),
74 theIsVariadic(false)81 theIsVariadic(false)
75{82{
76 theTypes.push_back(returnType);83 theTypes.push_back(returnType);
77}84}
7885
7986
80signature::signature(87signature::signature(
81 const store::Item_t& name,88 const store::Item_t& name,
82 const xqtref_t& paramType1,89 const xqtref_t& paramType1,
83 const xqtref_t& returnType)90 const xqtref_t& returnType)
84 :91 :
85 theQName(name),92 theQName(name),
86 theNonOptimizedReturnType(NULL),93 theNonOptimizedReturnType(NULL),
87 theIsVariadic(false)94 theIsVariadic(false)
88{95{
89 theTypes.push_back(returnType);96 theTypes.push_back(returnType);
90 theTypes.push_back(paramType1);97 theTypes.push_back(paramType1);
91}98}
9299
93100
94signature::signature(101signature::signature(
95 const store::Item_t& name,102 const store::Item_t& name,
96 const xqtref_t& paramType1,103 const xqtref_t& paramType1,
97 const xqtref_t& paramType2,104 const xqtref_t& paramType2,
98 const xqtref_t& returnType)105 const xqtref_t& returnType)
99 :106 :
100 theQName(name),107 theQName(name),
101 theNonOptimizedReturnType(NULL),108 theNonOptimizedReturnType(NULL),
102 theIsVariadic(false)109 theIsVariadic(false)
103{110{
104 theTypes.push_back(returnType);111 theTypes.push_back(returnType);
105 theTypes.push_back(paramType1);112 theTypes.push_back(paramType1);
106 theTypes.push_back(paramType2);113 theTypes.push_back(paramType2);
107}114}
108115
109116
110signature::signature(117signature::signature(
111 const store::Item_t& name,118 const store::Item_t& name,
112 const xqtref_t& paramType1,119 const xqtref_t& paramType1,
113 const xqtref_t& paramType2,120 const xqtref_t& paramType2,
114 const xqtref_t& paramType3,121 const xqtref_t& paramType3,
115 const xqtref_t& returnType)122 const xqtref_t& returnType)
116 :123 :
117 theQName(name),124 theQName(name),
118 theNonOptimizedReturnType(NULL),125 theNonOptimizedReturnType(NULL),
119 theIsVariadic(false)126 theIsVariadic(false)
120{127{
121 theTypes.push_back(returnType);128 theTypes.push_back(returnType);
122 theTypes.push_back(paramType1);129 theTypes.push_back(paramType1);
123 theTypes.push_back(paramType2);130 theTypes.push_back(paramType2);
124 theTypes.push_back(paramType3);131 theTypes.push_back(paramType3);
125}132}
126133
127134
128signature::signature(135signature::signature(
129 const store::Item_t& name,136 const store::Item_t& name,
130 const xqtref_t& paramType1,137 const xqtref_t& paramType1,
@@ -309,8 +316,13 @@
309}316}
310317
311318
319/*******************************************************************************
320 "this" is the signature of the function object. "s" is the signature of the
321 declaration appearing in the lib module.
322********************************************************************************/
312bool signature::subtype(323bool signature::subtype(
313 const TypeManager* tm,324 const TypeManager* tm,
325 const function* func,
314 const signature& s,326 const signature& s,
315 const QueryLoc& loc) const327 const QueryLoc& loc) const
316{328{
@@ -320,8 +332,8 @@
320 if (!theQName->equals(s.theQName.getp()))332 if (!theQName->equals(s.theQName.getp()))
321 return false;333 return false;
322334
323 if (theNonOptimizedReturnType.getp() != NULL && s.theNonOptimizedReturnType.getp() != NULL335 if (theNonOptimizedReturnType.getp() != NULL &&
324 &&336 s.theNonOptimizedReturnType.getp() != NULL &&
325 !TypeOps::is_subtype(tm,337 !TypeOps::is_subtype(tm,
326 *theNonOptimizedReturnType.getp(),338 *theNonOptimizedReturnType.getp(),
327 *s.theNonOptimizedReturnType.getp(),339 *s.theNonOptimizedReturnType.getp(),
@@ -330,12 +342,35 @@
330 return false;342 return false;
331 }343 }
332344
333 assert (s.theTypes.size() == theTypes.size() || theIsVariadic );345 assert (s.theTypes.size() == theTypes.size() || theIsVariadic);
346
334 for (csize i = 0; i < theTypes.size(); ++i)347 for (csize i = 0; i < theTypes.size(); ++i)
335 {348 {
349 xqtref_t builtinParamType = theTypes[i];
350
351 if (func == BUILTIN_FUNC(FN_ZORBA_XML_PARSE_2))
352 {
353 if (i == 2)
354 {
355 store::Item_t typeName;
356 GENV_ITEMFACTORY->createQName(typeName,
357 static_context::ZORBA_XML_FN_OPTIONS_NS,
358 "",
359 "options"),
360
361 builtinParamType = tm->
362 create_node_type(store::StoreConsts::elementNode,
363 typeName,
364 NULL,
365 TypeConstants::QUANT_QUESTION,
366 false,
367 false);
368 }
369 }
370
336 if (!TypeOps::is_subtype(tm,371 if (!TypeOps::is_subtype(tm,
337 *theTypes[i].getp(),372 *builtinParamType, // subtype
338 *s.theTypes[i].getp(),373 *s.theTypes[i].getp(), // supertype
339 loc))374 loc))
340 {375 {
341 return false;376 return false;
342377
=== modified file 'src/functions/signature.h'
--- src/functions/signature.h 2013-03-04 21:00:58 +0000
+++ src/functions/signature.h 2013-09-20 12:27:16 +0000
@@ -25,24 +25,36 @@
2525
26namespace zorba {26namespace zorba {
2727
28class function;
29
28#define VARIADIC_SIG_SIZE 100000030#define VARIADIC_SIG_SIZE 1000000
2931
30/*******************************************************************************32/*******************************************************************************
3133
32 By convention, theTypes[0] = return type34 theQName :
33 theTypes[1] = first param type35 the qname of the function
34 theTypes[2] = second param type36
35 ... = ...37 theTypes:
38 The return type and the paremater types. By convention, theTypes[0] holds the
39 return type, theTypes[1] holds the first param type, theTypes[2] holds the 2nd
40 param type, etc.
41
42 theNonOptimizedReturnType:
43 This is the original, non-optimized return type of a function. Used in function
44 literals type checks.
45
46 theIsVariadic:
47 Whether thefunction is variadic.
3648
37********************************************************************************/49********************************************************************************/
38class signature: public SimpleRCObject50class signature: public SimpleRCObject
39{51{
52 friend class function;
53
40 protected:54 protected:
41 store::Item_t theQName;55 store::Item_t theQName;
42 checked_vector<xqtref_t> theTypes;56 checked_vector<xqtref_t> theTypes;
43 xqtref_t theNonOptimizedReturnType; // This is the original, non-optimized57 xqtref_t theNonOptimizedReturnType;
44 // return type of a function. Used in
45 // function literals type checks.
46 bool theIsVariadic;58 bool theIsVariadic;
4759
48 public:60 public:
@@ -192,6 +204,7 @@
192204
193 bool subtype(205 bool subtype(
194 const TypeManager* tm,206 const TypeManager* tm,
207 const function* func,
195 const signature& s,208 const signature& s,
196 const QueryLoc& loc) const;209 const QueryLoc& loc) const;
197};210};
198211
=== modified file 'src/runtime/spec/strings/strings.xml'
--- src/runtime/spec/strings/strings.xml 2013-07-11 22:08:29 +0000
+++ src/runtime/spec/strings/strings.xml 2013-09-20 12:27:16 +0000
@@ -670,19 +670,26 @@
670 </zorba:description>670 </zorba:description>
671671
672 <zorba:function generateDECL="false">672 <zorba:function generateDECL="false">
673 <zorba:signature localname="analyze-string" prefix="fn" version="3.0">673
674 <zorba:param>xs:string?</zorba:param>674 <zorba:signature localname="analyze-string" prefix="fn" version="3.0">
675 <zorba:param>xs:string</zorba:param>675 <zorba:param>xs:string?</zorba:param>
676 <zorba:output>element()</zorba:output>676 <zorba:param>xs:string</zorba:param>
677 </zorba:signature>677 <zorba:output>element()</zorba:output>
678678 </zorba:signature>
679 <zorba:signature localname="analyze-string" prefix="fn" version="3.0">679
680 <zorba:param>xs:string?</zorba:param>680 <zorba:signature localname="analyze-string" prefix="fn" version="3.0">
681 <zorba:param>xs:string</zorba:param>681 <zorba:param>xs:string?</zorba:param>
682 <zorba:param>xs:string</zorba:param>682 <zorba:param>xs:string</zorba:param>
683 <zorba:output>element()</zorba:output>683 <zorba:param>xs:string</zorba:param>
684 </zorba:signature>684 <zorba:output>element()</zorba:output>
685 </zorba:signature>
686
687 <zorba:methods>
688 <zorba:getReturnType/>
689 </zorba:methods>
690
685 </zorba:function>691 </zorba:function>
692
686</zorba:iterator>693</zorba:iterator>
687694
688<!--695<!--
689696
=== modified file 'src/system/globalenv.cpp'
--- src/system/globalenv.cpp 2013-08-14 08:46:44 +0000
+++ src/system/globalenv.cpp 2013-09-20 12:27:16 +0000
@@ -61,6 +61,11 @@
6161
62#include "diagnostics/assert.h"62#include "diagnostics/assert.h"
6363
64
65#include "types/schema/xercesIncludes.h"
66#include "types/schema/StrX.h"
67
68
64using namespace zorba;69using namespace zorba;
6570
6671
@@ -72,7 +77,18 @@
72void GlobalEnvironment::init(store::Store* store)77void GlobalEnvironment::init(store::Store* store)
73{78{
74 // initialize Xerces-C lib79 // initialize Xerces-C lib
75 Schema::initialize();80#ifndef ZORBA_NO_XMLSCHEMA
81 try
82 {
83 XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
84 }
85 catch (const XERCES_CPP_NAMESPACE::XMLException& toCatch)
86 {
87 std::cerr << "Error during Xerces-C initialization! Message:\n"
88 << StrX(toCatch.getMessage()) << std::endl;
89 abort();
90 }
91#endif
7692
77 m_globalEnv = new GlobalEnvironment();93 m_globalEnv = new GlobalEnvironment();
7894
@@ -122,10 +138,9 @@
122138
123139
124/*******************************************************************************140/*******************************************************************************
125141 destroy all components that were initialized in init
142 note: destruction must be done in reverse initialization order
126********************************************************************************/143********************************************************************************/
127// destroy all components that were initialized in init
128// note: destruction must be done in reverse initialization order
129void GlobalEnvironment::destroy()144void GlobalEnvironment::destroy()
130{145{
131 delete m_globalEnv->theDynamicLoader;146 delete m_globalEnv->theDynamicLoader;
@@ -168,8 +183,9 @@
168 m_globalEnv = NULL;183 m_globalEnv = NULL;
169184
170 // terminate Xerces-C lib185 // terminate Xerces-C lib
171 Schema::terminate();186#ifndef ZORBA_NO_XMLSCHEMA
172187 XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate();
188#endif
173}189}
174190
175191
176192
=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp 2013-09-17 21:12:49 +0000
+++ src/types/schema/schema.cpp 2013-09-20 12:27:16 +0000
@@ -18,6 +18,7 @@
18#include <string>18#include <string>
1919
20#include "compiler/parser/query_loc.h"20#include "compiler/parser/query_loc.h"
21
21#include "context/namespace_context.h"22#include "context/namespace_context.h"
22#include "context/static_context.h"23#include "context/static_context.h"
23#include "context/uri_resolver.h"24#include "context/uri_resolver.h"
@@ -36,10 +37,14 @@
36#include "types/schema/LoadSchemaErrorHandler.h"37#include "types/schema/LoadSchemaErrorHandler.h"
37#include "types/schema/PrintSchema.h"38#include "types/schema/PrintSchema.h"
38#include "types/schema/XercesParseUtils.h"39#include "types/schema/XercesParseUtils.h"
40#include "types/schema/xercesIncludes.h"
41
39#include "system/globalenv.h"42#include "system/globalenv.h"
43
40#include "store/api/item_factory.h"44#include "store/api/item_factory.h"
45
41#include "util/utf8_util.h"46#include "util/utf8_util.h"
42#include "types/schema/xercesIncludes.h"47
43#include "zorbatypes/URI.h"48#include "zorbatypes/URI.h"
44#include <zorba/internal/unique_ptr.h>49#include <zorba/internal/unique_ptr.h>
4550
@@ -82,8 +87,6 @@
8287
83const char* Schema::XSD_NAMESPACE = static_context::W3C_XML_SCHEMA_NS;88const char* Schema::XSD_NAMESPACE = static_context::W3C_XML_SCHEMA_NS;
8489
85bool Schema::theIsInitialized = false;
86
87#ifndef ZORBA_NO_XMLSCHEMA90#ifndef ZORBA_NO_XMLSCHEMA
8891
8992
@@ -332,45 +335,6 @@
332335
333336
334/*******************************************************************************337/*******************************************************************************
335 Initialize the Xerces platform. Called from GlobalEnvironment::init().
336*******************************************************************************/
337void Schema::initialize()
338{
339#ifndef ZORBA_NO_XMLSCHEMA
340 if (theIsInitialized)
341 return;
342
343 try
344 {
345 XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();
346 theIsInitialized = true;
347 }
348 catch (const XERCES_CPP_NAMESPACE::XMLException& toCatch)
349 {
350 std::cerr << "Error during Xerces-C initialization! Message:\n"
351 << StrX(toCatch.getMessage()) << std::endl;
352 return;
353 }
354#endif
355}
356
357
358/*******************************************************************************
359 Terminate the Xerces platform. Called from GlobalEnvironment::destroy().
360*******************************************************************************/
361void Schema::terminate()
362{
363#ifndef ZORBA_NO_XMLSCHEMA
364 if (theIsInitialized)
365 {
366 XERCES_CPP_NAMESPACE::XMLPlatformUtils::Terminate();
367 theIsInitialized = false;
368 }
369#endif
370}
371
372
373/*******************************************************************************
374338
375*******************************************************************************/339*******************************************************************************/
376Schema::Schema(TypeManager* tm)340Schema::Schema(TypeManager* tm)
@@ -378,6 +342,8 @@
378 theTypeManager(tm),342 theTypeManager(tm),
379 theHasXSD(false)343 theHasXSD(false)
380{344{
345 ZORBA_ASSERT(tm != &GENV_TYPESYSTEM);
346
381#ifndef ZORBA_NO_XMLSCHEMA347#ifndef ZORBA_NO_XMLSCHEMA
382 theGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);348 theGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
383 // QQQ should be zstring349 // QQQ should be zstring
@@ -393,7 +359,6 @@
393Schema::Schema(::zorba::serialization::Archiver& ar)359Schema::Schema(::zorba::serialization::Archiver& ar)
394{360{
395#ifndef ZORBA_NO_XMLSCHEMA361#ifndef ZORBA_NO_XMLSCHEMA
396 initialize();
397 theGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);362 theGrammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager);
398 theHasXSD = false;363 theHasXSD = false;
399#endif364#endif
@@ -443,8 +408,8 @@
443 try408 try
444 {409 {
445 SAX2XMLReader* reader =410 SAX2XMLReader* reader =
446 XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager,411 XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager,
447 theGrammarPool);412 theGrammarPool);
448413
449 parser.reset(reader);414 parser.reset(reader);
450 // Perform namespace processing415 // Perform namespace processing
@@ -879,7 +844,8 @@
879 baseXQType,844 baseXQType,
880 TypeConstants::QUANT_ONE,845 TypeConstants::QUANT_ONE,
881 XQType::ATOMIC_UDT,846 XQType::ATOMIC_UDT,
882 XQType::SIMPLE_CONTENT_KIND);847 XQType::SIMPLE_CONTENT_KIND,
848 false);
883849
884 TRACE("created atomic " << qname->getStringValue()850 TRACE("created atomic " << qname->getStringValue()
885 << " base:" << baseXQType->toString());851 << " base:" << baseXQType->toString());
@@ -913,7 +879,8 @@
913 xsTypeDef->getAnonymous(),879 xsTypeDef->getAnonymous(),
914 qname,880 qname,
915 NULL,881 NULL,
916 itemXQType.getp());882 itemXQType.getp(),
883 false);
917884
918 //cout << " created UDT Simple List Type: " << xqType->toString() <<885 //cout << " created UDT Simple List Type: " << xqType->toString() <<
919 // endl; cout.flush();886 // endl; cout.flush();
@@ -970,7 +937,8 @@
970 qname,937 qname,
971 baseXQType,938 baseXQType,
972 TypeConstants::QUANT_ONE,939 TypeConstants::QUANT_ONE,
973 unionItemTypes);940 unionItemTypes,
941 false);
974942
975 //std::cout << " created UDT Union Type: " << xqType->toString() << std::endl;943 //std::cout << " created UDT Union Type: " << xqType->toString() << std::endl;
976 // std::cout.flush();944 // std::cout.flush();
@@ -1073,7 +1041,8 @@
1073 baseXQType,1041 baseXQType,
1074 TypeConstants::QUANT_ONE,1042 TypeConstants::QUANT_ONE,
1075 XQType::COMPLEX_UDT,1043 XQType::COMPLEX_UDT,
1076 contentType);1044 contentType,
1045 false);
10771046
1078 result = xqType;1047 result = xqType;
10791048
@@ -1330,7 +1299,8 @@
1330 }1299 }
13311300
1332 XSNamedMap<XSObject> * elemDefs =1301 XSNamedMap<XSObject> * elemDefs =
1333 model->getComponents(XSConstants::ELEMENT_DECLARATION);1302 model->getComponents(XSConstants::ELEMENT_DECLARATION);
1303
1334 for( uint i = 0; i<elemDefs->getLength(); i++)1304 for( uint i = 0; i<elemDefs->getLength(); i++)
1335 {1305 {
1336 XSElementDeclaration* elemDecl = (XSElementDeclaration*)(elemDefs->item(i));1306 XSElementDeclaration* elemDecl = (XSElementDeclaration*)(elemDefs->item(i));
@@ -1539,13 +1509,14 @@
1539 }1509 }
15401510
1541 xqtref_t xqType =1511 xqtref_t xqType =
1542 xqtref_t(new UserDefinedXQType(typeManager,1512 xqtref_t(new UserDefinedXQType(typeManager,
1543 xsTypeDef->getAnonymous(),1513 xsTypeDef->getAnonymous(),
1544 qname,1514 qname,
1545 baseXQType,1515 baseXQType,
1546 TypeConstants::QUANT_ONE,1516 TypeConstants::QUANT_ONE,
1547 XQType::COMPLEX_UDT,1517 XQType::COMPLEX_UDT,
1548 contentType));1518 contentType,
1519 false));
15491520
1550 addTypeToCache(xqType);1521 addTypeToCache(xqType);
15511522
15521523
=== modified file 'src/types/schema/schema.h'
--- src/types/schema/schema.h 2013-05-16 17:38:41 +0000
+++ src/types/schema/schema.h 2013-09-20 12:27:16 +0000
@@ -68,23 +68,15 @@
68 static const char* XSD_NAMESPACE;68 static const char* XSD_NAMESPACE;
6969
70private:70private:
71 static bool theIsInitialized;
72
73 TypeManager * theTypeManager;71 TypeManager * theTypeManager;
7472
75 bool theHasXSD;73 bool theHasXSD;
76#ifndef ZORBA_NO_XMLSCHEMA74#ifndef ZORBA_NO_XMLSCHEMA
77 XERCES_CPP_NAMESPACE::XMLGrammarPool * theGrammarPool;75 XERCES_CPP_NAMESPACE::XMLGrammarPool * theGrammarPool;
78 // QQQ use zstring?
79 UdTypesCache * theUdTypesCache;76 UdTypesCache * theUdTypesCache;
80#endif // ZORBA_NO_XMLSCHEMA77#endif // ZORBA_NO_XMLSCHEMA
8178
82public:79public:
83 static void initialize();
84
85 static void terminate();
86
87public:
88 SERIALIZABLE_CLASS(Schema)80 SERIALIZABLE_CLASS(Schema)
89 Schema(::zorba::serialization::Archiver& ar);81 Schema(::zorba::serialization::Archiver& ar);
90 void serialize(::zorba::serialization::Archiver& ar);82 void serialize(::zorba::serialization::Archiver& ar);
9183
=== modified file 'src/types/typeimpl.cpp'
--- src/types/typeimpl.cpp 2013-07-23 17:34:35 +0000
+++ src/types/typeimpl.cpp 2013-09-20 12:27:16 +0000
@@ -174,6 +174,7 @@
174 TypeConstants::quantifier_t quantifier,174 TypeConstants::quantifier_t quantifier,
175 bool builtin)175 bool builtin)
176 :176 :
177 theRefCount(0),
177 theManager((TypeManager*)manager),178 theManager((TypeManager*)manager),
178 theKind(type_kind),179 theKind(type_kind),
179 theQuantifier(quantifier),180 theQuantifier(quantifier),
@@ -182,13 +183,33 @@
182 if (theIsBuiltin)183 if (theIsBuiltin)
183 {184 {
184#ifndef NDEBUG185#ifndef NDEBUG
185 theRefCount = 1000000;186 //theRefCount = 1000000;
186#endif187#endif
187 // register this hardcoded object to help plan serialization188 // register this hardcoded object to help plan serialization
188 XQType* this_ptr = this;189 XQType* this_ptr = this;
189 *::zorba::serialization::ClassSerializer::getInstance()->190 *::zorba::serialization::ClassSerializer::getInstance()->
190 getArchiverForHardcodedObjects() & this_ptr;191 getArchiverForHardcodedObjects() & this_ptr;
191 }192 }
193#if 0
194 else
195 {
196 std::cout << "allocated type " << this << " of kind "
197 << KIND_STRINGS[type_kind] << std::endl;
198 }
199#endif
200}
201
202
203/*******************************************************************************
204
205********************************************************************************/
206XQType::~XQType()
207{
208 if (theIsBuiltin)
209 {
210 assert(theRefCount == 0);
211 theRefCount = 0;
212 }
192}213}
193214
194215
@@ -796,6 +817,21 @@
796 (contentType == NULL ||817 (contentType == NULL ||
797 contentType->type_kind() == XQType::UNTYPED_KIND ||818 contentType->type_kind() == XQType::UNTYPED_KIND ||
798 contentType->type_kind() == XQType::ANY_TYPE_KIND));819 contentType->type_kind() == XQType::ANY_TYPE_KIND));
820
821#if 0
822 if (theIsBuiltin == false &&
823 nodeKind == store::StoreConsts::elementNode &&
824 contentType == NULL &&
825 nodeName == NULL)
826 {
827 ZORBA_ASSERT(false);
828 }
829
830 if (!theIsBuiltin)
831 {
832 std::cout << "allocated type " << this << " : " << toSchemaString() << std::endl;
833 }
834#endif
799}835}
800836
801837
@@ -804,15 +840,31 @@
804********************************************************************************/840********************************************************************************/
805NodeXQType::NodeXQType(841NodeXQType::NodeXQType(
806 const NodeXQType& source,842 const NodeXQType& source,
807 TypeConstants::quantifier_t quantifier)843 TypeConstants::quantifier_t quantifier,
844 bool builtin)
808 :845 :
809 XQType(source.theManager, NODE_TYPE_KIND, quantifier, false),846 XQType(source.theManager, NODE_TYPE_KIND, quantifier, builtin),
810 theNodeKind(source.theNodeKind),847 theNodeKind(source.theNodeKind),
811 theNodeName(source.theNodeName),848 theNodeName(source.theNodeName),
812 theContentType(source.theContentType),849 theContentType(source.theContentType),
813 theNillable(source.theNillable),850 theNillable(source.theNillable),
814 theIsSchemaTest(source.theIsSchemaTest)851 theIsSchemaTest(source.theIsSchemaTest)
815{852{
853#if 0
854 if (theIsBuiltin == false &&
855 theNodeKind == store::StoreConsts::elementNode &&
856 theContentType == NULL &&
857 theNodeName == NULL)
858 {
859 std::cerr << "STRANGE TYPE" << std::endl;
860 theNodeKind = store::StoreConsts::elementNode;
861 }
862
863 if (!theIsBuiltin)
864 {
865 std::cout << "allocated copy type " << this << " : " << toSchemaString() << std::endl;
866 }
867#endif
816}868}
817869
818870
819871
=== modified file 'src/types/typeimpl.h'
--- src/types/typeimpl.h 2013-08-02 21:35:01 +0000
+++ src/types/typeimpl.h 2013-09-20 12:27:16 +0000
@@ -264,11 +264,7 @@
264 TypeManager is deleted during engine shutdown.264 TypeManager is deleted during engine shutdown.
265265
266********************************************************************************/266********************************************************************************/
267#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY 267class XQType : public serialization::SerializeBaseClass
268class XQType : public SimpleRCObject
269#else
270class XQType : public SyncedRCObject
271#endif
272{268{
273public:269public:
274 //270 //
@@ -341,6 +337,8 @@
341protected:337protected:
342 static const char * KIND_STRINGS[XQType::MAX_TYPE_KIND];338 static const char * KIND_STRINGS[XQType::MAX_TYPE_KIND];
343339
340 mutable long theRefCount;
341
344 TypeManager * theManager;342 TypeManager * theManager;
345 TypeKind theKind;343 TypeKind theKind;
346 TypeConstants::quantifier_t theQuantifier;344 TypeConstants::quantifier_t theQuantifier;
@@ -349,21 +347,42 @@
349347
350public:348public:
351 SERIALIZABLE_ABSTRACT_CLASS(XQType)349 SERIALIZABLE_ABSTRACT_CLASS(XQType)
352#if defined NDEBUG || defined ZORBA_FOR_ONE_THREAD_ONLY350
353 SERIALIZABLE_CLASS_CONSTRUCTOR2(XQType, SimpleRCObject)351 XQType(::zorba::serialization::Archiver& ar)
354#else352 :
355 SERIALIZABLE_CLASS_CONSTRUCTOR2(XQType, SyncedRCObject)353 serialization::SerializeBaseClass(),
356#endif354 theRefCount(0),
355 theIsBuiltin(false)
356 {
357 }
358
357 void serialize(::zorba::serialization::Archiver& ar);359 void serialize(::zorba::serialization::Archiver& ar);
358360
359public:361public:
360 virtual ~XQType() { }362 long getRefCount() const
361363 {
362 void free()364 return theRefCount;
363 {365 }
364 if (!theIsBuiltin)366
365 delete this;367 void addReference() const
366 }368 {
369 if (!theIsBuiltin)
370 ++theRefCount;
371 }
372
373 void removeReference()
374 {
375 if (!theIsBuiltin)
376 {
377 assert(getRefCount() > 0);
378
379 if (--theRefCount == 0)
380 delete this;
381 }
382 }
383
384public:
385 virtual ~XQType();
367386
368 TypeManager* get_manager() const { return theManager; }387 TypeManager* get_manager() const { return theManager; }
369388
@@ -421,6 +440,9 @@
421 TypeKind kind,440 TypeKind kind,
422 TypeConstants::quantifier_t quant,441 TypeConstants::quantifier_t quant,
423 bool builtin);442 bool builtin);
443
444private:
445 XQType& operator=(const XQType& t);
424};446};
425447
426448
@@ -435,7 +457,7 @@
435class NoneXQType : public XQType457class NoneXQType : public XQType
436{458{
437public:459public:
438 NoneXQType(const TypeManager* manager, bool builtin = false);460 NoneXQType(const TypeManager* manager, bool builtin);
439461
440 public:462 public:
441 SERIALIZABLE_CLASS(NoneXQType)463 SERIALIZABLE_CLASS(NoneXQType)
@@ -450,7 +472,7 @@
450class EmptyXQType : public XQType472class EmptyXQType : public XQType
451{473{
452public:474public:
453 EmptyXQType(const TypeManager* manager, bool builtin = false);475 EmptyXQType(const TypeManager* manager, bool builtin);
454476
455 public:477 public:
456 SERIALIZABLE_CLASS(EmptyXQType)478 SERIALIZABLE_CLASS(EmptyXQType)
@@ -468,7 +490,7 @@
468 ItemXQType(490 ItemXQType(
469 const TypeManager* tm,491 const TypeManager* tm,
470 TypeConstants::quantifier_t q,492 TypeConstants::quantifier_t q,
471 bool builtin = false);493 bool builtin);
472494
473 public:495 public:
474 SERIALIZABLE_CLASS(ItemXQType)496 SERIALIZABLE_CLASS(ItemXQType)
@@ -501,7 +523,7 @@
501 const TypeManager* manager,523 const TypeManager* manager,
502 store::SchemaTypeCode code,524 store::SchemaTypeCode code,
503 TypeConstants::quantifier_t quant,525 TypeConstants::quantifier_t quant,
504 bool builtin = false)526 bool builtin)
505 :527 :
506 XQType(manager, ATOMIC_TYPE_KIND, quant, builtin),528 XQType(manager, ATOMIC_TYPE_KIND, quant, builtin),
507 theAtomicCode(code)529 theAtomicCode(code)
@@ -524,7 +546,7 @@
524 StructuredItemXQType(546 StructuredItemXQType(
525 const TypeManager* tm,547 const TypeManager* tm,
526 TypeConstants::quantifier_t quant,548 TypeConstants::quantifier_t quant,
527 bool builtin = false);549 bool builtin);
528550
529 public:551 public:
530 SERIALIZABLE_CLASS(StructuredItemXQType)552 SERIALIZABLE_CLASS(StructuredItemXQType)
@@ -552,7 +574,7 @@
552 const TypeManager* manager,574 const TypeManager* manager,
553 store::StoreConsts::JSONItemKind kind,575 store::StoreConsts::JSONItemKind kind,
554 TypeConstants::quantifier_t quantifier,576 TypeConstants::quantifier_t quantifier,
555 bool builtin = false);577 bool builtin);
556578
557 store::StoreConsts::JSONItemKind get_json_kind() const { return theJSONKind; }579 store::StoreConsts::JSONItemKind get_json_kind() const { return theJSONKind; }
558580
@@ -589,9 +611,12 @@
589 TypeConstants::quantifier_t quantifier,611 TypeConstants::quantifier_t quantifier,
590 bool nillable,612 bool nillable,
591 bool schematest,613 bool schematest,
592 bool builtin = false);614 bool builtin);
593615
594 NodeXQType(const NodeXQType& source, TypeConstants::quantifier_t quant);616 NodeXQType(
617 const NodeXQType& source,
618 TypeConstants::quantifier_t quant,
619 bool builtin);
595620
596 store::StoreConsts::NodeKind get_node_kind() const { return theNodeKind; }621 store::StoreConsts::NodeKind get_node_kind() const { return theNodeKind; }
597622
@@ -630,7 +655,7 @@
630class AnyFunctionXQType : public XQType655class AnyFunctionXQType : public XQType
631{656{
632public:657public:
633 AnyFunctionXQType(const TypeManager* manager, bool builtin = false)658 AnyFunctionXQType(const TypeManager* manager, bool builtin)
634 :659 :
635 XQType(manager, ANY_FUNCTION_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)660 XQType(manager, ANY_FUNCTION_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)
636 {661 {
@@ -639,7 +664,7 @@
639 AnyFunctionXQType(664 AnyFunctionXQType(
640 const TypeManager* manager,665 const TypeManager* manager,
641 TypeConstants::quantifier_t quantifier,666 TypeConstants::quantifier_t quantifier,
642 bool builtin = false)667 bool builtin)
643 :668 :
644 XQType(manager, ANY_FUNCTION_TYPE_KIND, quantifier, builtin)669 XQType(manager, ANY_FUNCTION_TYPE_KIND, quantifier, builtin)
645 {670 {
@@ -673,7 +698,7 @@
673 const std::vector<xqtref_t>& aParamTypes,698 const std::vector<xqtref_t>& aParamTypes,
674 const xqtref_t& aReturnType,699 const xqtref_t& aReturnType,
675 TypeConstants::quantifier_t quantifier,700 TypeConstants::quantifier_t quantifier,
676 bool builtin = false);701 bool builtin);
677702
678 const std::vector<xqtref_t>&703 const std::vector<xqtref_t>&
679 get_param_types() const { return m_param_types; }704 get_param_types() const { return m_param_types; }
@@ -773,7 +798,7 @@
773 TypeConstants::quantifier_t quantifier,798 TypeConstants::quantifier_t quantifier,
774 UDTKind typeCategory,799 UDTKind typeCategory,
775 content_kind_t contentKind,800 content_kind_t contentKind,
776 bool builtin = false);801 bool builtin);
777802
778 // Constructor for List types803 // Constructor for List types
779 UserDefinedXQType(804 UserDefinedXQType(
@@ -782,7 +807,7 @@
782 store::Item_t qname,807 store::Item_t qname,
783 const xqtref_t& baseType,808 const xqtref_t& baseType,
784 const XQType* listItemType,809 const XQType* listItemType,
785 bool builtin = false);810 bool builtin);
786811
787 // Constructor for Union types812 // Constructor for Union types
788 UserDefinedXQType(813 UserDefinedXQType(
@@ -792,7 +817,7 @@
792 const xqtref_t& baseType,817 const xqtref_t& baseType,
793 TypeConstants::quantifier_t quantifier,818 TypeConstants::quantifier_t quantifier,
794 const std::vector<xqtref_t>& unionItemTypes,819 const std::vector<xqtref_t>& unionItemTypes,
795 bool builtin = false);820 bool builtin);
796821
797 virtual ~UserDefinedXQType() {}822 virtual ~UserDefinedXQType() {}
798823
@@ -823,7 +848,7 @@
823class AnyXQType : public XQType848class AnyXQType : public XQType
824{849{
825public:850public:
826 AnyXQType(const TypeManager* manager, bool builtin = false)851 AnyXQType(const TypeManager* manager, bool builtin)
827 :852 :
828 XQType(manager, ANY_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)853 XQType(manager, ANY_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)
829 {854 {
@@ -842,7 +867,7 @@
842class UntypedXQType : public XQType867class UntypedXQType : public XQType
843{868{
844public:869public:
845 UntypedXQType(const TypeManager* manager, bool builtin = false)870 UntypedXQType(const TypeManager* manager, bool builtin)
846 :871 :
847 XQType(manager, UNTYPED_KIND, TypeConstants::QUANT_STAR, builtin)872 XQType(manager, UNTYPED_KIND, TypeConstants::QUANT_STAR, builtin)
848 {873 {
@@ -861,7 +886,7 @@
861class AnySimpleXQType : public XQType886class AnySimpleXQType : public XQType
862{887{
863public:888public:
864 AnySimpleXQType(const TypeManager* manager, bool builtin = false)889 AnySimpleXQType(const TypeManager* manager, bool builtin)
865 :890 :
866 XQType(manager, ANY_SIMPLE_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)891 XQType(manager, ANY_SIMPLE_TYPE_KIND, TypeConstants::QUANT_STAR, builtin)
867 {892 {
868893
=== modified file 'src/types/typemanagerimpl.cpp'
--- src/types/typemanagerimpl.cpp 2013-07-01 18:59:06 +0000
+++ src/types/typemanagerimpl.cpp 2013-09-20 12:27:16 +0000
@@ -112,6 +112,8 @@
112********************************************************************************/112********************************************************************************/
113void TypeManagerImpl::initializeSchema()113void TypeManagerImpl::initializeSchema()
114{114{
115 ZORBA_ASSERT(this != &GENV_TYPESYSTEM);
116
115 if ( m_schema == NULL )117 if ( m_schema == NULL )
116 m_schema = new Schema(this);118 m_schema = new Schema(this);
117}119}
@@ -223,7 +225,7 @@
223 const xqtref_t& returnType,225 const xqtref_t& returnType,
224 TypeConstants::quantifier_t quant) const226 TypeConstants::quantifier_t quant) const
225{227{
226 return new FunctionXQType(this, paramTypes, returnType, quant);228 return new FunctionXQType(this, paramTypes, returnType, quant, false);
227}229}
228230
229231
@@ -532,7 +534,14 @@
532 }534 }
533 else535 else
534 {536 {
535 return new NodeXQType(this, nodeKind, NULL, contentType, quant, false, false);537 return new NodeXQType(this,
538 nodeKind,
539 NULL,
540 contentType,
541 quant,
542 false,
543 false,
544 false);
536 }545 }
537 }546 }
538547
@@ -548,7 +557,8 @@
548 contentType,557 contentType,
549 quant,558 quant,
550 nillable,559 nillable,
551 schematest);560 schematest,
561 false);
552 }562 }
553 else563 else
554 {564 {
@@ -567,7 +577,8 @@
567 contentType,577 contentType,
568 quant,578 quant,
569 false,579 false,
570 schematest);580 schematest,
581 false);
571 }582 }
572 else583 else
573 {584 {
@@ -594,6 +605,7 @@
594 RTM.STRING_TYPE_ONE,605 RTM.STRING_TYPE_ONE,
595 quant,606 quant,
596 nillable,607 nillable,
608 false,
597 false);609 false);
598 }610 }
599 }611 }
@@ -861,7 +873,8 @@
861 return new FunctionXQType(this,873 return new FunctionXQType(this,
862 paramTypes,874 paramTypes,
863 nonOptimizedRetType.getp() ? nonOptimizedRetType : retType,875 nonOptimizedRetType.getp() ? nonOptimizedRetType : retType,
864 quant);876 quant,
877 false);
865 }878 }
866879
867 else880 else
@@ -1006,7 +1019,7 @@
1006 }1019 }
1007 else1020 else
1008 {1021 {
1009 return new NodeXQType(nt, quantifier);1022 return new NodeXQType(nt, quantifier, false);
1010 }1023 }
1011 }1024 }
10121025
@@ -1027,7 +1040,8 @@
1027 return new FunctionXQType(this,1040 return new FunctionXQType(this,
1028 ft.get_param_types(),1041 ft.get_param_types(),
1029 ft.get_return_type(),1042 ft.get_return_type(),
1030 quantifier);1043 quantifier,
1044 false);
1031 }1045 }
10321046
1033 case XQType::ITEM_KIND:1047 case XQType::ITEM_KIND:
@@ -1064,7 +1078,8 @@
1064 udt.isAnonymous(),1078 udt.isAnonymous(),
1065 udt.getQName(),1079 udt.getQName(),
1066 udt.getBaseType(),1080 udt.getBaseType(),
1067 udt.getListItemType());1081 udt.getListItemType(),
1082 false);
1068 }1083 }
1069 else if (udt.isUnion())1084 else if (udt.isUnion())
1070 {1085 {
@@ -1073,7 +1088,8 @@
1073 udt.getQName(),1088 udt.getQName(),
1074 udt.getBaseType(),1089 udt.getBaseType(),
1075 quantifier,1090 quantifier,
1076 udt.getUnionItemTypes());1091 udt.getUnionItemTypes(),
1092 false);
1077 }1093 }
1078 else1094 else
1079 {1095 {
@@ -1083,7 +1099,8 @@
1083 udt.getBaseType(),1099 udt.getBaseType(),
1084 quantifier,1100 quantifier,
1085 udt.getUDTKind(),1101 udt.getUDTKind(),
1086 udt.contentKind());1102 udt.contentKind(),
1103 false);
1087 }1104 }
1088 }1105 }
1089 default:1106 default:
10901107
=== modified file 'src/types/typeops.cpp'
--- src/types/typeops.cpp 2013-06-24 07:56:21 +0000
+++ src/types/typeops.cpp 2013-09-20 12:27:16 +0000
@@ -322,7 +322,6 @@
322322
323 case XQType::JSON_TYPE_KIND: 323 case XQType::JSON_TYPE_KIND:
324 case XQType::NODE_TYPE_KIND:324 case XQType::NODE_TYPE_KIND:
325
326 {325 {
327 if (type.get_quantifier() == TypeConstants::QUANT_ONE)326 if (type.get_quantifier() == TypeConstants::QUANT_ONE)
328 return &type;327 return &type;
329328
=== modified file 'src/zorbaserialization/class_serializer.cpp'
--- src/zorbaserialization/class_serializer.cpp 2013-02-07 17:24:36 +0000
+++ src/zorbaserialization/class_serializer.cpp 2013-09-20 12:27:16 +0000
@@ -40,6 +40,16 @@
40/*******************************************************************************40/*******************************************************************************
4141
42********************************************************************************/42********************************************************************************/
43ClassSerializer* ClassSerializer::getInstance()
44{
45 static ClassSerializer theInstance;
46 return &theInstance;
47}
48
49
50/*******************************************************************************
51
52********************************************************************************/
43ClassSerializer::ClassSerializer() 53ClassSerializer::ClassSerializer()
44{54{
45 theClassFactories.resize(TYPE_LAST);55 theClassFactories.resize(TYPE_LAST);
@@ -60,12 +70,21 @@
6070
6171
62/*******************************************************************************72/*******************************************************************************
6373 called from GlobalEnvironment::destroy()
64********************************************************************************/74********************************************************************************/
65ClassSerializer* ClassSerializer::getInstance()75void ClassSerializer::destroyArchiverForHardcodedObjects()
66{76{
67 static ClassSerializer theInstance;77 delete harcoded_objects_archive;
68 return &theInstance;78 harcoded_objects_archive = new MemArchiver(true, true);;
79}
80
81
82/*******************************************************************************
83
84********************************************************************************/
85Archiver* ClassSerializer::getArchiverForHardcodedObjects()
86{
87 return harcoded_objects_archive;
69}88}
7089
7190
@@ -93,26 +112,6 @@
93}112}
94113
95114
96/*******************************************************************************
97
98********************************************************************************/
99Archiver* ClassSerializer::getArchiverForHardcodedObjects()
100{
101 return harcoded_objects_archive;
102}
103
104
105/*******************************************************************************
106 called at shutdown
107********************************************************************************/
108void ClassSerializer::destroyArchiverForHardcodedObjects()
109{
110 delete harcoded_objects_archive;
111 harcoded_objects_archive = NULL;
112 harcoded_objects_archive = new MemArchiver(true, true);
113}
114
115
116} // namespace serialization115} // namespace serialization
117} // namespace zorba116} // namespace zorba
118/* vim:set et sw=2 ts=2: */117/* vim:set et sw=2 ts=2: */
119118
=== modified file 'src/zorbaserialization/class_serializer.h'
--- src/zorbaserialization/class_serializer.h 2013-03-05 00:45:43 +0000
+++ src/zorbaserialization/class_serializer.h 2013-09-20 12:27:16 +0000
@@ -125,7 +125,7 @@
125 void operator&(Archiver& ar, T*& obj).125 void operator&(Archiver& ar, T*& obj).
126126
127********************************************************************************/127********************************************************************************/
128class ZORBA_DLL_PUBLIC SerializeBaseClass128class SerializeBaseClass
129{129{
130public:130public:
131 virtual ~SerializeBaseClass() {}131 virtual ~SerializeBaseClass() {}

Subscribers

People subscribed via source and target branches