Merge lp:~zorba-coders/zorba/stack into lp:~zorba-coders/zorba/zorba-experimental

Proposed by Matthias Brantner
Status: Merged
Merged at revision: 10634
Proposed branch: lp:~zorba-coders/zorba/stack
Merge into: lp:~zorba-coders/zorba/zorba-experimental
Diff against target: 89328 lines (+46801/-14845)
822 files modified
CMakeConfiguration.txt (+0/-4)
CMakeLists.txt (+29/-7)
CPackSourceConfig.cmake.in (+1/-1)
ChangeLog (+88/-12)
NOTICE.txt (+1/-1)
bin/CMakeLists.txt (+58/-19)
bin/debug_client/debug_command.cpp (+0/-99)
bin/debug_client/event_handler_init.cpp.in (+0/-41)
bin/debug_client/lock_free_queue.cpp (+0/-16)
bin/debug_client/message-handler.xq (+0/-165)
bin/debugger/command.h (+164/-211)
bin/debugger/command_arg.h (+237/-0)
bin/debugger/command_line_handler.cpp (+364/-204)
bin/debugger/command_line_handler.h (+116/-58)
bin/debugger/command_prompt.cpp (+287/-0)
bin/debugger/command_prompt.h (+72/-0)
bin/debugger/config.h.cmake (+24/-0)
bin/debugger/event_handler.cpp (+81/-76)
bin/debugger/event_handler.h (+25/-12)
bin/debugger/lock_free_queue.h (+10/-2)
bin/debugger/main.cpp (+340/-18)
bin/debugger/process_listener.cpp (+105/-0)
bin/debugger/process_listener.h (+75/-0)
bin/debugger/tuple.h (+6/-0)
bin/debugger/xqdb_client.cpp (+63/-0)
bin/debugger/xqdb_client.h (+51/-0)
bin/path_util.cpp (+60/-45)
bin/path_util.h (+9/-24)
bin/zorbacmd.cpp (+87/-50)
bin/zorbacmdproperties.cpp (+14/-5)
bin/zorbacmdproperties.h (+7/-1)
bin/zorbacmdproperties.txt (+3/-1)
bin/zorbacmdproperties_base.h (+19/-3)
cmake_modules/FindLibedit.cmake (+46/-0)
cmake_modules/FindPHP5.cmake (+5/-0)
cmake_modules/ZorbaModule.cmake (+57/-29)
config/CMakeLists.txt (+5/-5)
config/ZorbaConfig.cmake.in (+7/-4)
doc/cxx/examples/errors.cpp (+4/-4)
doc/cxx/examples/simple.cpp (+17/-10)
doc/php/CMakeLists.txt (+1/-1)
doc/php/examples/CMakeLists.txt (+14/-4)
doc/php/examples/php.ini.in (+1/-0)
doc/php/examples/simple.php.in (+2/-2)
doc/php/examples/test.php.in (+120/-0)
doc/php/examples/zorba_api.php (+1/-1)
doc/zorba/commandline.dox (+7/-1)
doc/zorba/conformance.dox (+4/-4)
doc/zorba/conformanceXQFTTS.dox (+74/-74)
doc/zorba/external_functions.dox (+2/-2)
doc/zorba/ft_thesaurus.dox (+34/-33)
doc/zorba/impl_dep_features.dox (+2/-2)
doc/zorba/modules_authoring.dox (+2/-3)
doc/zorba/modules_authoring_2.dox (+4/-3)
doc/zorba/modules_building_in.dox (+1/-1)
doc/zorba/options.dox (+233/-54)
doc/zorba/uriresolvers.dox (+120/-38)
doc/zorba/xqddf.dox (+206/-153)
doc/zorba/xqdoc/templates/main.html (+36/-24)
include/zorba/config.h.cmake (+12/-10)
include/zorba/debugger_client.h (+14/-2)
include/zorba/dynamic_context.h (+14/-1)
include/zorba/internal/type_traits.h (+3/-1)
include/zorba/internal/unique_ptr.h (+2/-2)
include/zorba/item.h (+29/-3)
include/zorba/item_factory.h (+60/-1)
include/zorba/options.h (+19/-4)
include/zorba/pregenerated/diagnostic_list.h (+12/-4)
include/zorba/static_collection_manager.h (+66/-3)
include/zorba/static_context.h (+619/-529)
include/zorba/thesaurus.h (+24/-28)
include/zorba/uri_resolvers.h (+18/-3)
include/zorba/xquery.h (+19/-1)
include/zorba/zorba.h (+1/-0)
modules/ExternalModules.conf (+16/-13)
modules/com/zorba-xquery/www/modules/CMakeLists.txt (+10/-1)
modules/com/zorba-xquery/www/modules/debugger/dbgp-message-handler.xq (+277/-0)
modules/com/zorba-xquery/www/modules/http-client.xq.src/http_response_handler.cpp (+4/-4)
modules/com/zorba-xquery/www/modules/node-position.xq (+524/-0)
modules/com/zorba-xquery/www/modules/pregenerated/errors.xq (+16/-8)
modules/com/zorba-xquery/www/modules/pregenerated/warnings.xq (+20/-1)
modules/com/zorba-xquery/www/modules/store/static/indexes/dml.xq (+187/-60)
modules/com/zorba-xquery/www/modules/string.xq (+21/-1)
modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq (+20/-13)
scripts/sanity_checks/README.txt (+2/-2)
scripts/sanity_checks/conformance_xqftts.xqi (+4/-5)
scripts/sanity_checks/conformance_xqts.xqi (+3/-3)
src/annotations/annotations.cpp (+324/-292)
src/annotations/annotations.h (+100/-59)
src/api/annotationimpl.cpp (+1/-1)
src/api/collectionimpl.cpp (+4/-9)
src/api/dynamiccontextimpl.cpp (+33/-0)
src/api/dynamiccontextimpl.h (+7/-0)
src/api/functionimpl.cpp (+1/-1)
src/api/item.cpp (+26/-0)
src/api/itemfactoryimpl.cpp (+61/-4)
src/api/itemfactoryimpl.h (+25/-3)
src/api/options.cpp (+26/-12)
src/api/serialization/serializer.cpp (+123/-51)
src/api/serialization/serializer.h (+4/-4)
src/api/staticcollectionmanagerimpl.cpp (+287/-0)
src/api/staticcollectionmanagerimpl.h (+37/-0)
src/api/staticcontextimpl.cpp (+207/-80)
src/api/staticcontextimpl.h (+26/-23)
src/api/thesaurus.cpp (+0/-4)
src/api/uri_resolver_wrappers.cpp (+66/-30)
src/api/uri_resolver_wrappers.h (+6/-6)
src/api/uriresolverimpl.cpp (+5/-0)
src/api/uriresolverimpl.h (+2/-0)
src/api/xmldatamanagerimpl.cpp (+5/-6)
src/api/xqueryimpl.cpp (+118/-4)
src/api/xqueryimpl.h (+6/-0)
src/api/zorbaimpl.cpp (+1/-1)
src/compiler/api/compiler_api.cpp (+19/-13)
src/compiler/api/compiler_api.h (+3/-2)
src/compiler/api/compilercb.cpp (+4/-0)
src/compiler/api/compilercb.h (+12/-2)
src/compiler/codegen/plan_visitor.cpp (+112/-79)
src/compiler/expression/abstract_expr_visitor.h (+1/-0)
src/compiler/expression/expr.cpp (+49/-52)
src/compiler/expression/expr.h (+97/-55)
src/compiler/expression/expr_annotations.cpp (+0/-58)
src/compiler/expression/expr_base.cpp (+119/-26)
src/compiler/expression/expr_base.h (+66/-26)
src/compiler/expression/expr_classes.h (+1/-0)
src/compiler/expression/expr_iter.cpp (+11/-2)
src/compiler/expression/expr_put.cpp (+53/-25)
src/compiler/expression/expr_type.cpp (+46/-61)
src/compiler/expression/expr_visitor.h (+1/-0)
src/compiler/expression/flwor_expr.cpp (+41/-16)
src/compiler/expression/flwor_expr.h (+41/-18)
src/compiler/expression/fo_expr.cpp (+4/-17)
src/compiler/expression/fo_expr.h (+5/-5)
src/compiler/expression/ft_expr.h (+2/-1)
src/compiler/expression/path_expr.h (+5/-5)
src/compiler/expression/script_exprs.cpp (+163/-17)
src/compiler/expression/script_exprs.h (+101/-12)
src/compiler/expression/update_exprs.cpp (+60/-73)
src/compiler/expression/update_exprs.h (+51/-50)
src/compiler/expression/var_expr.cpp (+55/-1)
src/compiler/expression/var_expr.h (+110/-32)
src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp (+1/-1)
src/compiler/rewriter/framework/rewriter_context.h (+59/-31)
src/compiler/rewriter/rewriters/default_optimizer.cpp (+10/-0)
src/compiler/rewriter/rules/fold_rules.cpp (+0/-1)
src/compiler/rewriter/rules/nodeid_rules.cpp (+785/-26)
src/compiler/rewriter/rules/path_rules.cpp (+4/-4)
src/compiler/rewriter/rules/rule_base.h (+1/-0)
src/compiler/rewriter/rules/ruleset.h (+52/-5)
src/compiler/rewriter/rules/type_rules.cpp (+51/-40)
src/compiler/rewriter/tools/dataflow_annotations.cpp (+542/-5)
src/compiler/rewriter/tools/dataflow_annotations.h (+37/-1)
src/compiler/rewriter/tools/expr_tools.cpp (+536/-6)
src/compiler/rewriter/tools/udf_graph.cpp (+6/-4)
src/compiler/translator/translator.cpp (+320/-241)
src/compiler/xqddf/value_index.cpp (+35/-22)
src/compiler/xqddf/value_index.h (+53/-27)
src/compiler/xqueryx/xqueryx_to_xquery.cpp (+4/-1)
src/compiler/xqueryx/xqueryx_xslt.cpp (+578/-86)
src/compiler/xqueryx/xqueryx_xslt.h (+2/-1)
src/context/default_uri_mappers.cpp (+2/-2)
src/context/default_uri_mappers.h (+6/-6)
src/context/default_url_resolvers.cpp (+5/-5)
src/context/default_url_resolvers.h (+19/-5)
src/context/dynamic_context.cpp (+45/-22)
src/context/dynamic_context.h (+30/-19)
src/context/dynamic_loader.cpp (+8/-17)
src/context/dynamic_loader.h (+2/-3)
src/context/namespace_context.cpp (+4/-2)
src/context/namespace_context.h (+5/-1)
src/context/root_static_context.cpp (+78/-37)
src/context/root_static_context.h (+5/-3)
src/context/root_static_context_init.cpp.in (+9/-2)
src/context/static_context.cpp (+431/-391)
src/context/static_context.h (+105/-123)
src/context/static_context_consts.h (+1/-34)
src/context/thesaurus_wrappers.cpp (+0/-21)
src/context/thesaurus_wrappers.h (+0/-10)
src/context/uri_resolver.cpp (+32/-12)
src/context/uri_resolver.h (+34/-8)
src/debugger/debugger_client.cpp (+0/-2)
src/debugger/debugger_clientimpl.cpp (+549/-453)
src/debugger/debugger_clientimpl.h (+17/-10)
src/debugger/debugger_common.h (+3/-10)
src/debugger/debugger_commons.cpp (+128/-25)
src/debugger/debugger_commons.h (+11/-15)
src/debugger/debugger_communicator.cpp (+12/-9)
src/debugger/debugger_communicator.h (+4/-4)
src/debugger/debugger_protocol.cpp (+40/-16)
src/debugger/debugger_protocol.h (+3/-0)
src/debugger/debugger_runtime.cpp (+330/-104)
src/debugger/debugger_runtime.h (+37/-20)
src/debugger/debugger_server.cpp (+292/-90)
src/debugger/debugger_server.h (+24/-1)
src/debugger/socket_streambuf.cpp (+68/-55)
src/debugger/socket_streambuf.h (+20/-9)
src/diagnostics/diagnostic_en.xml (+65/-26)
src/diagnostics/dict_XX_cpp.xq (+1/-0)
src/diagnostics/pregenerated/diagnostic_list.cpp (+18/-6)
src/diagnostics/pregenerated/dict_en.cpp (+12/-3)
src/functions/CMakeLists.txt (+1/-0)
src/functions/external_function.cpp (+85/-5)
src/functions/external_function.h (+5/-1)
src/functions/func_accessors_impl.cpp (+81/-61)
src/functions/func_accessors_impl.h (+5/-0)
src/functions/func_apply.cpp (+1/-1)
src/functions/func_arithmetic.cpp (+23/-20)
src/functions/func_booleans_impl.cpp (+60/-39)
src/functions/func_collections_impl.cpp (+44/-2)
src/functions/func_durations_dates_times_impl.cpp (+2/-2)
src/functions/func_enclosed.cpp (+14/-11)
src/functions/func_errors_and_diagnostics_impl.cpp (+11/-2)
src/functions/func_eval.cpp (+4/-4)
src/functions/func_hoist.cpp (+40/-34)
src/functions/func_index_ddl.cpp (+1/-1)
src/functions/func_index_ddl.h (+11/-11)
src/functions/func_node_sort_distinct.cpp (+48/-13)
src/functions/func_node_sort_distinct.h (+8/-6)
src/functions/func_numerics_impl.cpp (+152/-152)
src/functions/func_reflection.cpp (+7/-4)
src/functions/func_sequences_impl.cpp (+277/-209)
src/functions/func_sequences_impl.h (+97/-56)
src/functions/func_serialize_impl.cpp (+38/-0)
src/functions/func_strings_impl.cpp (+21/-2)
src/functions/func_var_decl.cpp (+6/-64)
src/functions/function.cpp (+57/-18)
src/functions/function.h (+15/-13)
src/functions/function_consts.h (+5/-6)
src/functions/library.cpp (+2/-0)
src/functions/pregenerated/func_accessors.cpp (+0/-20)
src/functions/pregenerated/func_accessors.h (+70/-58)
src/functions/pregenerated/func_any_uri.h (+4/-2)
src/functions/pregenerated/func_base64.h (+8/-4)
src/functions/pregenerated/func_booleans.h (+21/-9)
src/functions/pregenerated/func_collections.h (+171/-65)
src/functions/pregenerated/func_context.h (+32/-16)
src/functions/pregenerated/func_documents.h (+22/-10)
src/functions/pregenerated/func_durations_dates_times.h (+84/-42)
src/functions/pregenerated/func_errors_and_diagnostics.h (+21/-11)
src/functions/pregenerated/func_fetch.h (+8/-4)
src/functions/pregenerated/func_fnput.h (+6/-2)
src/functions/pregenerated/func_function_item_iter.h (+12/-6)
src/functions/pregenerated/func_ic_ddl.h (+12/-6)
src/functions/pregenerated/func_maps.h (+32/-16)
src/functions/pregenerated/func_maths.h (+104/-52)
src/functions/pregenerated/func_node_position.cpp (+584/-0)
src/functions/pregenerated/func_node_position.h (+409/-0)
src/functions/pregenerated/func_nodes.h (+128/-54)
src/functions/pregenerated/func_numerics.h (+35/-21)
src/functions/pregenerated/func_other_diagnostics.h (+8/-4)
src/functions/pregenerated/func_parse_fragment.h (+4/-2)
src/functions/pregenerated/func_parsing_and_serializing.h (+10/-4)
src/functions/pregenerated/func_qnames.h (+41/-19)
src/functions/pregenerated/func_random.h (+12/-6)
src/functions/pregenerated/func_schema.h (+27/-11)
src/functions/pregenerated/func_sctx.h (+100/-50)
src/functions/pregenerated/func_sequences.h (+255/-185)
src/functions/pregenerated/func_strings.cpp (+60/-0)
src/functions/pregenerated/func_strings.h (+154/-63)
src/functions/pregenerated/func_xqdoc.h (+8/-4)
src/functions/pregenerated/function_enum.h (+27/-1)
src/functions/signature.cpp (+92/-62)
src/functions/signature.h (+9/-1)
src/functions/udf.cpp (+218/-11)
src/functions/udf.h (+47/-4)
src/runtime/booleans/BooleanImpl.cpp (+174/-195)
src/runtime/booleans/BooleanImpl.h (+1/-1)
src/runtime/collections/collections_impl.cpp (+21/-21)
src/runtime/core/arithmetic_impl.cpp (+45/-45)
src/runtime/core/arithmetic_impl.h (+18/-15)
src/runtime/core/constructors.cpp (+81/-77)
src/runtime/core/constructors.h (+15/-44)
src/runtime/core/flwor_iterator.cpp (+27/-30)
src/runtime/core/flwor_iterator.h (+1/-0)
src/runtime/core/fncall_iterator.cpp (+171/-25)
src/runtime/core/fncall_iterator.h (+39/-6)
src/runtime/core/gflwor/common.cpp (+45/-27)
src/runtime/core/gflwor/common.h (+4/-2)
src/runtime/core/gflwor/groupby_iterator.cpp (+9/-14)
src/runtime/core/gflwor/window_iterator.cpp (+3/-5)
src/runtime/core/path_iterators.h (+1/-1)
src/runtime/core/sequencetypes.cpp (+30/-47)
src/runtime/core/trycatch.cpp (+1/-1)
src/runtime/core/var_iterators.cpp (+67/-90)
src/runtime/core/var_iterators.h (+13/-13)
src/runtime/eval/eval.cpp (+71/-35)
src/runtime/eval/eval.h (+18/-9)
src/runtime/fetch/fetch_impl.cpp (+11/-9)
src/runtime/full_text/apply.cpp (+19/-12)
src/runtime/full_text/ft_stop_words_set.cpp (+4/-4)
src/runtime/full_text/icu_tokenizer.cpp (+44/-24)
src/runtime/full_text/icu_tokenizer.h (+2/-2)
src/runtime/full_text/thesauri/wn_synset.cpp (+4/-2)
src/runtime/full_text/thesaurus.cpp (+22/-27)
src/runtime/full_text/thesaurus.h (+2/-27)
src/runtime/indexing/index_ddl.cpp (+52/-15)
src/runtime/indexing/index_ddl.h (+37/-30)
src/runtime/introspection/sctx_impl.cpp (+1/-1)
src/runtime/misc/materialize.cpp (+1/-1)
src/runtime/nodes/node_position_impl.cpp (+756/-0)
src/runtime/nodes/pregenerated/node_position.cpp (+710/-0)
src/runtime/nodes/pregenerated/node_position.h (+858/-0)
src/runtime/numerics/NumericsImpl.cpp (+76/-76)
src/runtime/numerics/NumericsImpl.h (+2/-2)
src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp (+13/-6)
src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h (+2/-0)
src/runtime/qnames/qnames_impl.cpp (+41/-48)
src/runtime/scripting/scripting.cpp (+7/-8)
src/runtime/sequences/sequences_impl.cpp (+12/-12)
src/runtime/spec/accessors/accessors.xml (+48/-14)
src/runtime/spec/booleans/booleans.xml (+28/-15)
src/runtime/spec/codegen-h.xq (+36/-12)
src/runtime/spec/collections/collections.xml (+22/-0)
src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml (+3/-0)
src/runtime/spec/fnput/fnput.xml (+2/-1)
src/runtime/spec/mappings.xml (+5/-1)
src/runtime/spec/nodes/node_position.xml (+439/-0)
src/runtime/spec/nodes/nodes.xml (+320/-236)
src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml (+5/-0)
src/runtime/spec/plan_iter_visitor_h.xq (+4/-4)
src/runtime/spec/printer_visitor_cpp.xq (+2/-2)
src/runtime/spec/printer_visitor_h.xq (+1/-1)
src/runtime/spec/qnames/qnames.xml (+17/-0)
src/runtime/spec/schema/schema.xml (+19/-0)
src/runtime/spec/sequences/sequences.xml (+17/-0)
src/runtime/spec/store/documents.xml (+1/-0)
src/runtime/spec/strings/strings.xml (+61/-7)
src/runtime/store/maps_impl.cpp (+16/-3)
src/runtime/strings/pregenerated/strings.cpp (+70/-0)
src/runtime/strings/pregenerated/strings.h (+89/-0)
src/runtime/strings/strings_impl.cpp (+428/-101)
src/runtime/update/update.cpp (+2/-1)
src/runtime/visitors/planiter_visitor_impl_code.h (+51/-52)
src/runtime/visitors/planiter_visitor_impl_include.h (+5/-6)
src/runtime/visitors/pregenerated/planiter_visitor.h (+131/-1)
src/runtime/visitors/pregenerated/printer_visitor.cpp (+365/-0)
src/runtime/visitors/pregenerated/printer_visitor.h (+78/-0)
src/runtime/visitors/printer_visitor_impl.cpp (+233/-171)
src/runtime/visitors/printer_visitor_impl.h (+56/-51)
src/runtime/xqdoc/xqdoc_impl.cpp (+4/-4)
src/store/api/annotation.h (+17/-15)
src/store/api/index.h (+60/-22)
src/store/api/item.h (+98/-25)
src/store/api/item_factory.h (+4/-145)
src/store/api/shared_types.h (+3/-0)
src/store/api/store.h (+20/-9)
src/store/api/temp_seq.h (+47/-47)
src/store/api/update_consts.h (+1/-1)
src/store/api/xs_type_codes.h (+94/-0)
src/store/naive/atomic_items.cpp (+857/-100)
src/store/naive/atomic_items.h (+247/-67)
src/store/naive/item.cpp (+141/-0)
src/store/naive/loader_dtd.cpp (+92/-56)
src/store/naive/loader_fast.cpp (+31/-36)
src/store/naive/node_factory.cpp (+2/-2)
src/store/naive/node_factory.h (+2/-2)
src/store/naive/node_items.cpp (+636/-266)
src/store/naive/node_items.h (+175/-73)
src/store/naive/node_iterators.cpp (+35/-9)
src/store/naive/node_iterators.h (+63/-9)
src/store/naive/node_updates.cpp (+10/-10)
src/store/naive/nsbindings.cpp (+3/-3)
src/store/naive/nsbindings.h (+3/-2)
src/store/naive/ordpath.cpp (+94/-0)
src/store/naive/ordpath.h (+11/-4)
src/store/naive/pul_primitives.cpp (+25/-26)
src/store/naive/pul_primitives.h (+5/-1)
src/store/naive/qname_pool.cpp (+2/-2)
src/store/naive/qname_pool.h (+1/-1)
src/store/naive/shared_types.h (+3/-0)
src/store/naive/simple_collection.cpp (+4/-2)
src/store/naive/simple_collection.h (+2/-3)
src/store/naive/simple_index.cpp (+312/-302)
src/store/naive/simple_index.h (+163/-204)
src/store/naive/simple_index_general.cpp (+1560/-2172)
src/store/naive/simple_index_general.h (+313/-174)
src/store/naive/simple_index_value.cpp (+187/-51)
src/store/naive/simple_index_value.h (+84/-39)
src/store/naive/simple_item_factory.cpp (+86/-4)
src/store/naive/simple_item_factory.h (+21/-0)
src/store/naive/simple_lazy_temp_seq.cpp (+158/-96)
src/store/naive/simple_lazy_temp_seq.h (+29/-144)
src/store/naive/simple_pul.cpp (+7/-7)
src/store/naive/simple_store.cpp (+202/-181)
src/store/naive/simple_store.h (+71/-48)
src/store/naive/simple_temp_seq.cpp (+166/-219)
src/store/naive/simple_temp_seq.h (+42/-43)
src/store/naive/store_defs.h (+0/-78)
src/store/naive/store_properties.h (+36/-17)
src/system/globalenv.cpp (+73/-25)
src/system/globalenv.h (+41/-22)
src/system/zorba_properties.h (+50/-12)
src/system/zorba_properties.txt (+4/-2)
src/types/casting.cpp (+420/-195)
src/types/casting.h (+37/-15)
src/types/root_typemanager.cpp (+11/-11)
src/types/root_typemanager.h (+6/-9)
src/types/schema/revalidateUtils.cpp (+3/-3)
src/types/schema/schema.cpp (+7/-7)
src/types/schema/schema.h (+2/-2)
src/types/typeconstants.h (+1/-51)
src/types/typeimpl.cpp (+1/-1)
src/types/typeimpl.h (+7/-7)
src/types/typemanager.h (+6/-3)
src/types/typemanagerimpl.cpp (+3/-3)
src/types/typemanagerimpl.h (+1/-1)
src/types/typeops.cpp (+31/-11)
src/types/typeops.h (+21/-5)
src/unit_tests/CMakeLists.txt (+0/-6)
src/unit_tests/test_debugger_protocol.cpp (+0/-414)
src/util/http_util.cpp (+2/-2)
src/util/string_util.h (+6/-0)
src/util/unicode_util.h (+4/-0)
src/util/utf8_util.cpp (+17/-0)
src/util/utf8_util_base.h (+27/-0)
src/zorbamisc/ns_consts.h (+1/-5)
src/zorbaserialization/zorba_class_serializer.cpp (+1/-0)
src/zorbatypes/URI.cpp (+0/-3)
src/zorbautils/hashmap_itemh.h (+112/-0)
swig/CMakeLists.txt (+2/-7)
swig/ItemFactory.h (+69/-0)
swig/ItemFactory.i (+192/-0)
swig/StaticContext.h (+69/-0)
swig/StaticContext.i (+43/-107)
swig/XQuery.i (+14/-0)
swig/Zorba.i (+28/-1)
swig/java/CMakeLists.txt (+2/-0)
swig/php/CMakeLists.txt (+23/-6)
swig/php/XQueryProcessor.php (+397/-0)
swig/php/generate_proxy.php.in (+7/-4)
swig/php/test.xq (+1/-0)
swig/php/zorba_api.i (+7/-1)
swig/python/CMakeLists.txt (+2/-0)
swig/ruby/CMakeLists.txt (+10/-0)
swig/zorba_api.i (+4/-1)
test/apitest.cpp (+21/-6)
test/rbkt/ExpCompilerResults/IterPlan/iterscript.cmake (+14/-10)
test/rbkt/ExpCompilerResults/IterPlan/zorba/error/trace1.iter (+8/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter (+1/-1)
test/rbkt/ExpCompilerResults/IterPlan/zorba/misc/hoist4.iter (+7/-7)
test/rbkt/ExpCompilerResults/IterPlan/zorba/misc/inline_var1.iter (+2/-2)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-c.iter (+375/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide-nc.iter (+375/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide2-c.iter (+139/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dataguide2-nc.iter (+139/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/dblp-q0.iter (+182/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9065.iter (+62/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9198.iter (+75/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9199.iter (+75/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9212.iter (+83/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9389.iter (+70/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9390.iter (+70/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-9392.iter (+71/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-gary1.iter (+227/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx1.iter (+105/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-idx4.iter (+168/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/hashjoin-q8.iter (+102/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/path17.iter (+70/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q1.iter (+49/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q10.iter (+246/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q11.iter (+103/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q12.iter (+115/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q13.iter (+45/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q14.iter (+39/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q15.iter (+50/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q16.iter (+65/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q17.iter (+47/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q18.iter (+38/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q19.iter (+56/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q2.iter (+43/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q20.iter (+192/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q3.iter (+139/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q4.iter (+126/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q5.iter (+41/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q6.iter (+29/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q7.iter (+39/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q8.iter (+107/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/q9.iter (+169/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/no-copy/udfs1.iter (+58/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/paths/pred_order.iter (+2/-2)
test/rbkt/ExpCompilerResults/IterPlan/zorba/string/SubstringFunc/SubstringFunc2.iter (+10/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/string/SubstringFunc/SubstringFunc3.iter (+14/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf-fib-rec.iter (+42/-0)
test/rbkt/ExpCompilerResults/IterPlan/zorba/udf/udf1.iter (+5/-5)
test/rbkt/ExpQueryResults/zorba/debugger/dmh/break_response.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/debugger/dmh/break_response_no_info.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/error/trace1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/eval/eval9.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/eval/invoke1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/fulltext/ft-same-sentence-false-2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/groupby/posvar.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/index/auctions1.xml.res (+3/-3)
test/rbkt/ExpQueryResults/zorba/index/numbers.xml.res (+21/-0)
test/rbkt/ExpQueryResults/zorba/misc/baseuri.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/dataguide-c.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/dataguide-nc.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/dataguide2-c.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/dataguide2-nc.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/dblp-q0.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-9198.xml.res (+19/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-9199.xml.res (+19/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-9212.xml.res (+49/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-9389.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-9390.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-9392.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-gary1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-idx1.xml.res (+254/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-idx4.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/hashjoin-q8.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/parser_test.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/path17.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q1.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q10.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q11.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q12.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q13.xml.res (+18/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q14.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q17.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q18.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q19.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q2.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q20.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q3.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q5.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q6.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q7.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q8.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/q9.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/no-copy/udfs1.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_1.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_1_parsed.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_2.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_2_parsed.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_3.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_3_parsed.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_4.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_4_parsed.xml.res (+2/-0)
test/rbkt/ExpQueryResults/zorba/nodes/position_err.xml.res (+6/-0)
test/rbkt/ExpQueryResults/zorba/schemas/validate_xqdoc_01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/schemas/validate_xqdoc_02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/string/Regex/regex_a4.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/string/tokenize01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/string/tokenize02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/string/tokenize03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/string/tokenize04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/udf/udf-fib-rec-BIG_INTEGER.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/udf/udf-fib-rec.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding03.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding06.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding07.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding09.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding10.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding11.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding12.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding13.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/sliding14.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling01.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling02.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling04.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling05.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling07.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling08.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling09.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling10.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling24.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling26.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling27.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling28.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling29.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling30.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling32.xml.res (+12/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling33.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling34.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling35.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling36.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling38.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling39.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling40.xml.res (+24/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling41.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling45.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling46.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling47.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/tumbling48.xml.res (+1/-0)
test/rbkt/ExpQueryResults/zorba/windowing/windowing12.xml.res (+1/-0)
test/rbkt/Queries/CMakeLists.txt (+272/-18)
test/rbkt/Queries/w3c_known_failures.txt (+49/-90)
test/rbkt/Queries/w3c_known_failures_XQueryX.txt (+88/-0)
test/rbkt/Queries/zorba/annotations/annot-unknown-02.spec (+1/-1)
test/rbkt/Queries/zorba/annotations/annot-unknown-02.xq (+10/-6)
test/rbkt/Queries/zorba/annotations/annot-unknown-04.spec (+1/-1)
test/rbkt/Queries/zorba/annotations/annot-unknown-04.xq (+9/-6)
test/rbkt/Queries/zorba/debugger/dmh/break_response.xq (+5/-0)
test/rbkt/Queries/zorba/debugger/dmh/break_response_no_info.xq (+7/-0)
test/rbkt/Queries/zorba/error/trace1.xq (+6/-0)
test/rbkt/Queries/zorba/eval/eval9.xq (+6/-0)
test/rbkt/Queries/zorba/eval/invoke1.xq (+5/-0)
test/rbkt/Queries/zorba/eval/invoke1_1.xqlib (+10/-0)
test/rbkt/Queries/zorba/eval/invoke1_2.xqlib (+3/-0)
test/rbkt/Queries/zorba/fulltext/ft-same-sentence-false-2.xq (+2/-0)
test/rbkt/Queries/zorba/groupby/posvar.xq (+17/-0)
test/rbkt/Queries/zorba/index/auctions1.xml (+1/-0)
test/rbkt/Queries/zorba/index/auctions1.xq (+1/-1)
test/rbkt/Queries/zorba/index/numbers.xml (+10/-0)
test/rbkt/Queries/zorba/index/numbers.xq (+75/-0)
test/rbkt/Queries/zorba/index/numbers.xqlib (+28/-0)
test/rbkt/Queries/zorba/misc/baseuri.xml (+1/-0)
test/rbkt/Queries/zorba/misc/baseuri.xq (+2/-0)
test/rbkt/Queries/zorba/modules/libraryModule15.xqlib (+8/-3)
test/rbkt/Queries/zorba/no-copy/auction.xml (+2182/-0)
test/rbkt/Queries/zorba/no-copy/books.xml (+25/-0)
test/rbkt/Queries/zorba/no-copy/dataguide-c.xq (+87/-0)
test/rbkt/Queries/zorba/no-copy/dataguide-nc.xq (+91/-0)
test/rbkt/Queries/zorba/no-copy/dataguide2-c.xq (+33/-0)
test/rbkt/Queries/zorba/no-copy/dataguide2-nc.xq (+38/-0)
test/rbkt/Queries/zorba/no-copy/dblp-q0.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/dblp-q0.xq (+32/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9065.xq (+9/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9198.xq (+13/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9199.xq (+11/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9212.xq (+15/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9389.xq (+13/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9390.xq (+15/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-9392.xq (+14/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-gary1.xq (+42/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-idx1.xq (+12/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-idx4.xq (+33/-0)
test/rbkt/Queries/zorba/no-copy/hashjoin-q8.xq (+17/-0)
test/rbkt/Queries/zorba/no-copy/parser_test.xq (+3/-0)
test/rbkt/Queries/zorba/no-copy/path17.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/path17.xq (+12/-0)
test/rbkt/Queries/zorba/no-copy/q1.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q1.xq (+9/-0)
test/rbkt/Queries/zorba/no-copy/q10.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q10.xq (+36/-0)
test/rbkt/Queries/zorba/no-copy/q11.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q11.xq (+13/-0)
test/rbkt/Queries/zorba/no-copy/q12.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q12.xq (+16/-0)
test/rbkt/Queries/zorba/no-copy/q13.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q13.xq (+9/-0)
test/rbkt/Queries/zorba/no-copy/q14.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q14.xq (+11/-0)
test/rbkt/Queries/zorba/no-copy/q15.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q15.xq (+10/-0)
test/rbkt/Queries/zorba/no-copy/q16.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q16.xq (+17/-0)
test/rbkt/Queries/zorba/no-copy/q17.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q17.xq (+10/-0)
test/rbkt/Queries/zorba/no-copy/q18.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q18.xq (+17/-0)
test/rbkt/Queries/zorba/no-copy/q19.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q19.xq (+13/-0)
test/rbkt/Queries/zorba/no-copy/q2.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q2.xq (+10/-0)
test/rbkt/Queries/zorba/no-copy/q20.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q20.xq (+34/-0)
test/rbkt/Queries/zorba/no-copy/q3.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q3.xq (+14/-0)
test/rbkt/Queries/zorba/no-copy/q4.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q4.xq (+14/-0)
test/rbkt/Queries/zorba/no-copy/q5.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q5.xq (+13/-0)
test/rbkt/Queries/zorba/no-copy/q6.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q6.xq (+10/-0)
test/rbkt/Queries/zorba/no-copy/q7.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q7.xq (+11/-0)
test/rbkt/Queries/zorba/no-copy/q8.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q8.xq (+14/-0)
test/rbkt/Queries/zorba/no-copy/q9.spec (+3/-0)
test/rbkt/Queries/zorba/no-copy/q9.xq (+20/-0)
test/rbkt/Queries/zorba/no-copy/simple_parser.xqlib (+2207/-0)
test/rbkt/Queries/zorba/no-copy/test1.xq (+17/-0)
test/rbkt/Queries/zorba/no-copy/udfs1.xq (+31/-0)
test/rbkt/Queries/zorba/no-copy/udfs2.xq (+31/-0)
test/rbkt/Queries/zorba/nodes/position.xml (+15/-0)
test/rbkt/Queries/zorba/nodes/position_1.xq (+97/-0)
test/rbkt/Queries/zorba/nodes/position_1_parsed.xq (+98/-0)
test/rbkt/Queries/zorba/nodes/position_2.xq (+157/-0)
test/rbkt/Queries/zorba/nodes/position_2_parsed.xq (+156/-0)
test/rbkt/Queries/zorba/nodes/position_3.xq (+32/-0)
test/rbkt/Queries/zorba/nodes/position_3_parsed.xq (+34/-0)
test/rbkt/Queries/zorba/nodes/position_4.xq (+84/-0)
test/rbkt/Queries/zorba/nodes/position_4_parsed.xq (+81/-0)
test/rbkt/Queries/zorba/nodes/position_err.xq (+60/-0)
test/rbkt/Queries/zorba/schemas/validate_xqdoc_01.xq (+4/-0)
test/rbkt/Queries/zorba/schemas/validate_xqdoc_02.xq (+4/-0)
test/rbkt/Queries/zorba/store/documents.xq (+1/-0)
test/rbkt/Queries/zorba/string/Regex/regex_a4.xq (+1/-0)
test/rbkt/Queries/zorba/string/token01.txt (+1/-0)
test/rbkt/Queries/zorba/string/token02.txt (+1/-0)
test/rbkt/Queries/zorba/string/token03.txt (+1/-0)
test/rbkt/Queries/zorba/string/token04.txt (+1/-0)
test/rbkt/Queries/zorba/string/tokenize01.xq (+5/-0)
test/rbkt/Queries/zorba/string/tokenize02.xq (+5/-0)
test/rbkt/Queries/zorba/string/tokenize03.xq (+5/-0)
test/rbkt/Queries/zorba/string/tokenize04.xq (+5/-0)
test/rbkt/Queries/zorba/udf/udf-fib-rec.spec (+1/-0)
test/rbkt/Queries/zorba/udf/udf-fib-rec.xq (+8/-0)
test/rbkt/Queries/zorba/windowing/sliding01.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/sliding02.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/sliding03.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/sliding04.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/sliding05.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/sliding06.xq (+6/-0)
test/rbkt/Queries/zorba/windowing/sliding07.xq (+10/-0)
test/rbkt/Queries/zorba/windowing/sliding08.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/sliding08.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/sliding09.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/sliding10.xq (+18/-0)
test/rbkt/Queries/zorba/windowing/sliding11.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/sliding12.xq (+7/-0)
test/rbkt/Queries/zorba/windowing/sliding13.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/sliding14.xq (+12/-0)
test/rbkt/Queries/zorba/windowing/tumbling01.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling02.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/tumbling04.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling05.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/tumbling06.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling07.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling08.xq (+6/-0)
test/rbkt/Queries/zorba/windowing/tumbling09.xq (+6/-0)
test/rbkt/Queries/zorba/windowing/tumbling10.xq (+10/-0)
test/rbkt/Queries/zorba/windowing/tumbling11.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling11.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling14.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling14.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling15.spec (+2/-0)
test/rbkt/Queries/zorba/windowing/tumbling15.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling16.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling16.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling17.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling17.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling18.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling18.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling19.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling19.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling20.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling20.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling21.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling21.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling22.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling22.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling24.xq (+6/-0)
test/rbkt/Queries/zorba/windowing/tumbling25.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/tumbling26.xq (+3/-0)
test/rbkt/Queries/zorba/windowing/tumbling27.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling28.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling29.xq (+17/-0)
test/rbkt/Queries/zorba/windowing/tumbling31.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling31.xq (+3/-0)
test/rbkt/Queries/zorba/windowing/tumbling32.xq (+19/-0)
test/rbkt/Queries/zorba/windowing/tumbling33.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/tumbling34.xq (+6/-0)
test/rbkt/Queries/zorba/windowing/tumbling35.xq (+8/-0)
test/rbkt/Queries/zorba/windowing/tumbling36.xq (+5/-0)
test/rbkt/Queries/zorba/windowing/tumbling37.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling37.xq (+8/-0)
test/rbkt/Queries/zorba/windowing/tumbling38.xq (+8/-0)
test/rbkt/Queries/zorba/windowing/tumbling39.xq (+12/-0)
test/rbkt/Queries/zorba/windowing/tumbling40.xq (+27/-0)
test/rbkt/Queries/zorba/windowing/tumbling41.xq (+9/-0)
test/rbkt/Queries/zorba/windowing/tumbling42.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling42.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling43.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling43.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling44.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/tumbling44.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling45.xq (+4/-0)
test/rbkt/Queries/zorba/windowing/tumbling46.xq (+17/-0)
test/rbkt/Queries/zorba/windowing/tumbling47.xq (+20/-0)
test/rbkt/Queries/zorba/windowing/tumbling48.xq (+18/-0)
test/rbkt/Queries/zorba/windowing/tumbling49.xq (+12/-0)
test/rbkt/Queries/zorba/windowing/windowing12.xq (+9/-0)
test/rbkt/Queries/zorba/windowing/windowing13.spec (+1/-0)
test/rbkt/Queries/zorba/windowing/windowing13.xq (+4/-0)
test/rbkt/Queries/zorba/xmark/q10.xq (+8/-4)
test/rbkt/Queries/zorba/xqddf/test-node-reference.xq (+2/-0)
test/rbkt/Scripts/w3c/Readme.txt (+17/-7)
test/rbkt/Scripts/w3c/Submit_xqts.cmake (+23/-9)
test/rbkt/Scripts/w3c/generate-submission-xqftts.xq (+4/-4)
test/rbkt/Scripts/w3c/generate-submission-xqts.xq (+4/-9)
test/rbkt/Scripts/w3c/import_w3c_full_text_testsuite.sh (+1/-1)
test/rbkt/Scripts/w3c/import_w3c_testsuite.sh (+1/-1)
test/rbkt/itertest.xq.in (+58/-44)
test/rbkt/specification.h (+1/-1)
test/rbkt/testdriver_common.cpp (+14/-3)
test/rbkt/testdriver_mt.cpp (+32/-5)
test/unit/CMakeLists.txt (+23/-0)
test/unit/context_item.cpp (+158/-0)
test/unit/context_item1.xq (+4/-0)
test/unit/context_item2.xq (+6/-0)
test/unit/cxx_api_ch1.xq (+26/-0)
test/unit/cxx_api_ch2.xq (+17/-0)
test/unit/cxx_api_ch3.xq (+20/-0)
test/unit/cxx_api_ch4.xq (+19/-0)
test/unit/cxx_api_changes.cpp (+345/-0)
test/unit/datetime.cpp (+2/-0)
test/unit/ext_main3.xq (+21/-0)
test/unit/ext_mod2.xq (+19/-0)
test/unit/external_function.cpp (+59/-1)
test/unit/guestbook.xq (+9/-0)
test/unit/guestbook_main.xq (+1/-1)
test/unit/main_invoke.xq (+9/-0)
test/unit/module2.xq (+6/-0)
test/unit/module4.xq (+6/-0)
test/unit/static_context.cpp (+75/-0)
test/unit/staticcollectionmanager.cpp (+65/-2)
test/unit/testGetExtVarA.xq (+13/-0)
test/unit/testGetExtVarB.xq (+6/-0)
test/unit/thesaurus.cpp (+9/-13)
test/update/CMakeLists.txt (+1/-1)
test/update/Queries/zorba/store/sc3.spec (+0/-2)
test/update/Scripts/Readme.txt (+8/-5)
test/update/Scripts/XQUTS.xml (+1/-1)
test/update/Scripts/generate-submission-xquts.xq (+11/-4)
test/update/Scripts/import_w3c_update_testsuite.sh (+1/-1)
test/update/Scripts/zorba-xquts-submission.xml (+858/-0)
test/update/Scripts/zorba-xqutsx-submission.xml (+858/-0)
test/zperf/src/start.xq (+154/-100)
To merge this branch: bzr merge lp:~zorba-coders/zorba/stack
Reviewer Review Type Date Requested Status
Zorba Coders Pending
Review via email: mp+91380@code.launchpad.net

This proposal supersedes a proposal from 2012-02-01.

Commit message

...

Description of the change

...

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/stack into lp:~zorba-coders/zorba/zorba-experimental failed. Below is the output from the failed tests.

experimental build started for lp:~zorba-coders/zorba/stack. Check out http://stack.zorba-xquery.com/ in half an hour or so. Logfile at http://zorbatest.lambda.nu:8080/remotequeue/experimental/stack.log .

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/stack into lp:~zorba-coders/zorba/zorba-experimental failed. Below is the output from the failed tests.

experimental build started for lp:~zorba-coders/zorba/stack. Check out http://stack.zorba-xquery.com/ in half an hour or so. Logfile at http://zorbatest.lambda.nu:8080/remotequeue/experimental/stack.log .

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

The attempt to merge lp:~zorba-coders/zorba/stack into lp:~zorba-coders/zorba/zorba-experimental failed. Below is the output from the failed tests.

experimental build started for lp:~zorba-coders/zorba/stack. Check out http://stack.zorba-xquery.com/ in half an hour or so. Logfile at http://zorbatest.lambda.nu:8080/remotequeue/experimental/stack.log .

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeConfiguration.txt'
2--- CMakeConfiguration.txt 2011-09-16 19:55:59 +0000
3+++ CMakeConfiguration.txt 2012-02-03 01:13:24 +0000
4@@ -70,10 +70,6 @@
5 SET(ZORBA_FOR_ONE_THREAD_ONLY OFF CACHE BOOL "compile zorba for single threaded use")
6 MESSAGE(STATUS "ZORBA_FOR_ONE_THREAD_ONLY: " ${ZORBA_FOR_ONE_THREAD_ONLY})
7
8-# by default the zorba command line client is deactivated until it gets to a more stable and userfriendly state
9-SET(ZORBA_WITH_DEBUGGER_CLIENT OFF CACHE BOOL "build and install zorbas command line debugger client")
10-MESSAGE(STATUS "ZORBA_WITH_DEBUGGER_CLIENT: " ${ZORBA_WITH_DEBUGGER_CLIENT})
11-
12 IF (DEFINED UNIX)
13 IF (NOT DEFINED ZORBA_HAVE_PTHREAD_H AND NOT DEFINED ZORBA_FOR_ONE_THREAD_ONLY)
14 MESSAGE(FATAL_ERROR "pthread is not available")
15
16=== modified file 'CMakeLists.txt'
17--- CMakeLists.txt 2011-10-09 13:56:39 +0000
18+++ CMakeLists.txt 2012-02-03 01:13:24 +0000
19@@ -417,13 +417,35 @@
20
21 # zorba versioning
22 SET(ZORBA_MAJOR_NUMBER "2")
23-SET(ZORBA_MINOR_NUMBER "0")
24-SET(ZORBA_PATCH_NUMBER "1")
25+SET(ZORBA_MINOR_NUMBER "1")
26+SET(ZORBA_PATCH_NUMBER "0")
27 SET(ZORBA_VERSION ${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER})
28 MESSAGE(STATUS "Zorba version number: ${ZORBA_VERSION}")
29-SET(ZORBA_MODULES_INSTALL_DIR "share/zorba-${ZORBA_VERSION}/modules"
30- CACHE STRING "Path (relative to installdir) to modules" FORCE)
31-MARK_AS_ADVANCED(ZORBA_MODULES_INSTALL_DIR)
32+
33+SET(ZORBA_LIB_DIRNAME "lib" CACHE STRING
34+ "directory name for libs (may want to set to 'lib64' on 64-bit Linux platforms)")
35+
36+# Directories for modules and schemas. "Core" are those which are
37+# shipped with Zorba and must be present for correct Zorba
38+# functionality. "Non-core" are developed independently of Zorba and
39+# have different version lifecycles.
40+#
41+# URI dir is for things resolved by URI - specifically modules (.xq
42+# files) and schemas (.xsd files) - which are platform-
43+# independent. Lib dir is for platform-specific files, specifically
44+# shared libraries for module external functions.
45+SET(ZORBA_NONCORE_URI_DIR "share/zorba/uris"
46+ CACHE STRING "Path (relative to installdir) to non-core modules/schemas")
47+MARK_AS_ADVANCED(ZORBA_NONCORE_URI_DIR)
48+SET(ZORBA_CORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}/core/${ZORBA_VERSION}"
49+ CACHE STRING "Path (relative to installdir) to core modules/schemas")
50+MARK_AS_ADVANCED(ZORBA_CORE_URI_DIR)
51+SET(ZORBA_NONCORE_LIB_DIR "${ZORBA_LIB_DIRNAME}/zorba"
52+ CACHE STRING "Path (relative to installdir) to non-core libraries")
53+MARK_AS_ADVANCED(ZORBA_NONCORE_LIB_DIR)
54+SET(ZORBA_CORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}/core/${ZORBA_VERSION}"
55+ CACHE STRING "Path (relative to installdir) to core libraries")
56+MARK_AS_ADVANCED(ZORBA_CORE_LIB_DIR)
57
58 # add compiler variables
59 ADD_DEFINITIONS(${DEFINITIONS})
60@@ -460,7 +482,7 @@
61 SET(ZORBA_CMAKE_DIR "cmake" CACHE STRING
62 "Relative path to CMake files in Zorba installation")
63 ELSE (WIN32)
64- SET(ZORBA_CMAKE_DIR "share/zorba-${ZORBA_VERSION}/cmake" CACHE STRING
65+ SET(ZORBA_CMAKE_DIR "share/cmake/zorba-${ZORBA_VERSION}" CACHE STRING
66 "Relative path to CMake files in Zorba installation")
67 ENDIF (WIN32)
68
69@@ -534,4 +556,4 @@
70 # This dependency is zorba-only related, which is why it's added here
71 # and not within zorba-modules, which is for general use in other
72 # non-zorba modules.
73-ADD_DEPENDENCIES(check_uris gen_diag_modules)
74+ADD_DEPENDENCIES(check_core_uris gen_diag_modules)
75
76=== modified file 'CPackSourceConfig.cmake.in'
77--- CPackSourceConfig.cmake.in 2009-10-30 16:24:51 +0000
78+++ CPackSourceConfig.cmake.in 2012-02-03 01:13:24 +0000
79@@ -19,7 +19,7 @@
80
81 SET(CPACK_CMAKE_GENERATOR "Unix Makefiles")
82 SET(CPACK_GENERATOR "TGZ;TZ")
83-SET(CPACK_IGNORE_FILES "test/coverity/;dist/;_CPack_Packages/;build/;build./;CVS/;/\\.svn/;\\.swp$;\\.#;/#")
84+SET(CPACK_IGNORE_FILES "test/coverity/;dist/;_CPack_Packages/;build/;build./;CVS/;/\\.svn/;\\.swp$;\\.#;/#;\\.bzr/")
85 SET(CPACK_INSTALLED_DIRECTORIES "@CMAKE_SOURCE_DIR@;/")
86 SET(CPACK_INSTALL_CMAKE_PROJECTS "")
87 SET(CPACK_MODULE_PATH "")
88
89=== modified file 'ChangeLog'
90--- ChangeLog 2011-10-20 23:05:55 +0000
91+++ ChangeLog 2012-02-03 01:13:24 +0000
92@@ -1,13 +1,61 @@
93 Zorba - The XQuery Processor
94
95-version 2.x
96-
97- * Custom Full-text thesaurus.
98- * Fixed bug #3401971 (node-by-reference on dynamic collections)
99+version 2.2
100+
101+ * No-copy optimization: avoids copying nodes during node-constructor expressions.
102+ * Added external function annotations %ann:propagates-input-nodes and
103+ %ann:must-copy-input-nodes to be used by the no-copy optimization.
104+ * Caching of results for recursive functions with atomic parameter and return types.
105+ * Added %ann:cache and %ann:no-cache to enable or disable caching of results of functions with atomic parameter and return types.
106+ * Fixed bug 917923 (bug in copying outer var values into the eval dynamic context)
107+ * Fixed bug 909126 (bug in cloning of var_expr)
108+ * Fixed bug in destruction of exit_catcher_expr
109+ * Types-related optimization for the comparison operators
110+ * Fixed bug #911585 (management of variables during eval)
111+ * Fixed bug #866423 (fn:empty and fn:exists iterators must reset their input in
112+ case of early-out)
113+ * Added index management function to the C++ api's StaticCollectionManager.
114+ * Fixed bug #905041 (allow for the default element and function namespaces to be
115+ set multiple times via the c++ api).
116+ * Fixed bug #907872 (segfault when returning an input ItemSequence from an external function).
117+ * Fixed bug #905050 (setting and getting the context item type via the c++ api).
118+ * Added createDayTimeDuration, createYearMonthDuration, createDocumentNode, createCommentNode, createPiNode to api's ItemFactory.
119+ * Added split function to the string module that allows for streamable tokenization but doesn't have regular expression
120+ support.
121+ * Fixed bug involving positional var and groupby
122+ * zerr is not predeclared anymore to be http://www.zorba-xquery.com/errors
123+ * Add new XQuery interface for the PHP bindings.
124+ * Added API method Item::getNamespaceBindings().
125+ * Added API method StaticContext::getNamespaceBindings() (see bug #905035)
126+ * Deprecated StaticContext:getNamespaceURIByPrefix()
127+ * Fixed bug #918211 (xqueryx fulltext w3c conformance generation)
128+ * Fixed bug #918157 (Add XQFTTS to validation queue)
129+
130+version 2.1
131+
132+New Features:
133+ * New node-position module. This module allows to obtain a representation of a node position, which
134+ can be used to assess structural relationships with other nodes.
135+ * New node-reference module. References can be obtained for any node, and
136+ different nodes cannot have the same identifier.
137+ * Custom Full-text thesaurus using Zorba URI resolver mechanism.
138+ * Modified C++ API to add isSequential, getExternalVariables, isBoundContextItem and
139+ isBoundExternalVariable Functions
140+ * Collection allows to retrieve information about the type
141+ and the annotations of a static collection.
142+ * Implemented the probe-index-range-value for general indexes
143+ * Added ExternalFunctionParameter class to be registered in the DynamicContext
144+ * New module for compiling and executing XQueries from XQuery (xqxq)
145+ * External functions are allowed to be updating (i.e. return a pending update list)
146+
147+Optimization:
148 * Optimization for positioned sequence access (e.g. $x[$x[1]] where $x is a
149 sequence of integers)
150- * documentation improvements
151- * installer improvements
152+ * Optimization for count(collection()) expressions
153+ * Optimization of the fn:substring function in the case when its $start and $length arguments
154+ are integers
155+
156+Bug Fixes/Other Changes:
157 * Fixed bug #3403291 (build for Fedora 15)
158 * Fixed bug #3397293 (Incorrect XQueryX error message)
159 * Fixed bug #3398637 (Nested element constructors cause loss of namespace bindings)
160@@ -15,20 +63,19 @@
161 * Fixed bug #3404689 (assignment problem in flwor)
162 * Fix for bug #3404450 (testdriver_mt problem: caching and validation of docs)
163 * Fixed installation bug to not install the .so for test modules
164- * Fix for running ctest on Windows
165 * Fixed bug #3390410 (Adding a node to a collection causes out of bound in vector)
166 * Fixed bug #3406200 (node types were not being moved to new tree during node detach)
167 * Fixed bug #3406191 (Namespace bindings lost after update due to bug in node detach)
168 * Fixed bug #3290122 (ZDST0003 needs collection name)
169- * Collection allows to retrieve information about the type
170- and the annotations of a static collection.
171 * Fixed bug #3406272 (merging of adjacent text nodes must be done after all
172 updates have been applied).
173+ * Don't raise warnings for unknown annotations.
174 * Fixed bug #3409344 (during detach, if the node being detached is the root of
175 its tree, it should be detached from the tree as well; otherwise memory
176 corruption will occur)
177 * Fixed bug # (Should not destroy the parent of a node that is being detached
178 before the detach is done).
179+ * Added const qualifier to StaticContext::getAuditEvent()
180 * Fixed bug #3408181 (available-collection() returns undeclared collections)
181 * Fixed bug #859465 (Fatal error if a PUL contains two deactivate IC primitives)
182 * Fixed bug #859467 (Fatal error if a PUL contains two activate Foreign Key primitives)
183@@ -36,11 +83,10 @@
184 * Fixed bug #859522 (Fatal error if a PUL contains two delete document primitives)
185 * Fixed bug #859968 (Using put on an attribute produces an invalid XDM instance and may cause segmentation faults)
186 * Fixed bug #855314 (should not fold a constant expr that returns an error item)
187- * Added ExternalFunctionParameter class to be registered in the DynamicContext
188+ * Fixed bug when parsing a document with a base-uri attribute.
189 * Fixed bug #863320 (Sentence is incorrectly incremented when token characters end without sentence terminator)
190 * Fixed bug #863730 (static delete-node* functions don't raise ZDDY0012)
191- * Implemented the probe-index-range-value for general indexes
192- * Fixed bug #867662 ("nullptr" warning)
193+ * Removed ZSTR0005 and ZSTR0006 error codes
194 * Fixed bug #868258 (Assertion failure with two delete collection)
195 * Fixed bug #871623 and #871629 (assertion failures with insertions in dynamic collections)
196 * Fixed bug #867262 (allow reuse of iterator over ExtFuncArgItemSequence)
197@@ -54,6 +100,36 @@
198 * Fixed bug #872796 (validate-in-place can interfere with other update primitives)
199 * Fixed bug #872799 (validate-in-place can set incorrect types)
200 * Fixed bug #855715 (Invalid escaped characters in regex not caught)
201+ * Fixed bug #868325 (fn:analyze-string fails with some recursive subgroups)
202+ * Fixed bug #872697 (segmentation fault with validation of NMTOKENS)
203+ * General index cannot be declared as unique if the type of its key is
204+ xs:anyAtomicType or xs:untypedAtomic.
205+ * Added undo for node revalidation
206+ * Optimization for count(collection()) expressions
207+ * Fixed bug #867133 (SWIG PHP build failure on Mac OSX)
208+ * Fixed bug #872796 (validate-in-place can interfere with other update primitives)
209+ * Fixed bug #872799 (validate-in-place can set incorrect types)
210+ * Fixed bug #872850 (Serialization of Tumbling Window For fails)
211+ * Fixed bug #855715 (Invalid escaped characters in regex not caught)
212+ * Fixed bug #862089 (Split binary/xq install directories for modules) by
213+ splitting "module path" into separate URI and Library paths
214+ * Fixed bug #872502 (validation of the JSON module xqdoc fails)
215+ * Fixed bug #897619 (testdriver_mt can not run the XQueryX tests)
216+ * Fixed bug #867107 (xqdoc dependency to zorba is wrong)
217+ * Fixed bug #897616 (Fix the generation of the XQFTTS report results for
218+ W3C)
219+
220+version 2.0.3
221+ * Fixed bug #867662 ("nullptr" warning)
222+ * documentation improvements
223+
224+version 2.0.2
225+ * Fixed bug #3401971 (node-by-reference on dynamic collections)
226+ * documentation improvements
227+ * installer improvements
228+ * Fixed bug #3403291 (build for Fedora 15)
229+ * Don't install the .so for test modules
230+ * Fix for running ctest on Windows
231
232 version 2.0.1
233
234
235=== modified file 'NOTICE.txt'
236--- NOTICE.txt 2011-10-19 15:28:51 +0000
237+++ NOTICE.txt 2012-02-03 01:13:24 +0000
238@@ -1,5 +1,5 @@
239 -----------
240-Zorba 2.0.1
241+Zorba 2.1.0
242 -----------
243
244 (Note: This file is generated automatically from NOTICE.xml.
245
246=== modified file 'bin/CMakeLists.txt'
247--- bin/CMakeLists.txt 2011-08-05 02:21:55 +0000
248+++ bin/CMakeLists.txt 2012-02-03 01:13:24 +0000
249@@ -15,33 +15,38 @@
250 INCLUDE_DIRECTORIES(AFTER ${CMAKE_SOURCE_DIR}/src/)
251 INCLUDE_DIRECTORIES(AFTER ${CMAKE_CURRENT_SOURCE_DIR})
252
253-IF(ZORBA_WITH_DEBUGGER_CLIENT)
254- CONFIGURE_FILE (debug_client/event_handler_init.cpp.in debug_client/event_handler_init.cpp)
255-
256- SET(DEBUG_CLIENT_SRCS
257- debug_client/tuple.h
258- debug_client/main.cpp
259- debug_client/debug_command.h
260- debug_client/debug_command.cpp
261- debug_client/command_line_handler.h
262- debug_client/command_line_handler.cpp
263- debug_client/lock_free_queue.h
264- debug_client/event_handler.h
265- debug_client/event_handler.cpp
266- ${CMAKE_CURRENT_BINARY_DIR}/debug_client/event_handler_init.cpp
267+IF (ZORBA_WITH_DEBUGGER)
268+ IF (NOT WIN32)
269+ FIND_PACKAGE (Libedit)
270+ IF (LIBEDIT_FOUND)
271+ INCLUDE_DIRECTORIES (${LIBEDIT_INCLUDE_DIRS})
272+ SET (LIBEDIT_LIBS ${LIBEDIT_LIBRARIES})
273+ SET (ZORBA_HAVE_LIBEDIT_H ${LIBEDIT_FOUND})
274+ ENDIF (LIBEDIT_FOUND)
275+ ENDIF (NOT WIN32)
276+
277+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h)
278+ MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake --> ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h")
279+ INCLUDE_DIRECTORIES (BEFORE ${CMAKE_CURRENT_BINARY_DIR}/debugger)
280+
281+ SET (DEBUG_CLIENT_SRCS
282+ debugger/main.cpp
283+ debugger/xqdb_client.cpp
284+ debugger/process_listener.cpp
285+ debugger/command_prompt.cpp
286+ debugger/command_line_handler.cpp
287+ debugger/event_handler.cpp
288 )
289
290- CONFIGURE_FILE (debug_client/message-handler.xq message-handler.xq)
291-
292- ZORBA_GENERATE_EXE("debuggercmd" "${DEBUG_CLIENT_SRCS}" "" "debugger" "bin")
293-ENDIF(ZORBA_WITH_DEBUGGER_CLIENT)
294+ ZORBA_GENERATE_EXE ("xqdb" "${DEBUG_CLIENT_SRCS}" "${LIBEDIT_LIBS}" "xqdb" "bin")
295+ENDIF (ZORBA_WITH_DEBUGGER)
296
297 SET(SRCS
298 zorbacmd.cpp
299 zorbacmdproperties.cpp
300 error_printer.cpp
301 util.cpp
302- module_path.cpp
303+ path_util.cpp
304 )
305
306 INCLUDE("${CMAKE_SOURCE_DIR}/cmake_modules/ZorbaGenerateExe.cmake")
307@@ -84,3 +89,37 @@
308 # test the --option option to set an option in the static context
309 ZORBA_ADD_TEST(bin/zorba_option zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/test/option.xq" -f --option "{http://www.zorba-xquery.com}option=value")
310 ZORBA_SET_TEST_PROPERTY(bin/zorba_option PASS_REGULAR_EXPRESSION "value")
311+
312+# test the --uri-path, --lib-path, and --module-path args.
313+# Use the versioning tests as they utilize test modules already.
314+SET (_testdir
315+ "${CMAKE_CURRENT_SOURCE_DIR}/../test/rbkt/Queries/zorba/versioning")
316+SET (_uridir "${CMAKE_BINARY_DIR}/TEST_URI_PATH")
317+SET (_libdir "${CMAKE_BINARY_DIR}/TEST_LIB_PATH")
318+ZORBA_ADD_TEST(bin/zorba_uri_path_1 zorbacmd -f -q "${_testdir}/import1.xq"
319+ --uri-path "${_uridir}")
320+ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_1
321+ PASS_REGULAR_EXPRESSION "hello, v2")
322+
323+ZORBA_ADD_TEST(bin/zorba_uri_path_2 zorbacmd -f -q "${_testdir}/external1.xq"
324+ --uri-path "${_uridir}")
325+ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_2
326+ PASS_REGULAR_EXPRESSION "ZXQP0008")
327+
328+ZORBA_ADD_TEST(bin/zorba_uri_path_3 zorbacmd -f -q "${_testdir}/external1.xq"
329+ --uri-path "${_uridir}" --lib-path "${_libdir}")
330+ZORBA_SET_TEST_PROPERTY(bin/zorba_uri_path_3
331+ PASS_REGULAR_EXPRESSION "hello, v2")
332+
333+IF(WIN32)
334+ SET(PATH_SEP ";")
335+ELSE(WIN32)
336+ SET(PATH_SEP ":")
337+ENDIF(WIN32)
338+ZORBA_ADD_TEST(bin/zorba_module_path_1 zorbacmd -f -q "${_testdir}/external1.xq"
339+ --module-path "${_libdir}${PATH_SEP}${_uridir}")
340+ZORBA_SET_TEST_PROPERTY(bin/zorba_module_path_1
341+ PASS_REGULAR_EXPRESSION "hello, v2")
342+
343+# test compilation of the perf script
344+ZORBA_ADD_TEST(bin/zorba_compilechk4 zorbacmd -q "${CMAKE_CURRENT_SOURCE_DIR}/../test/zperf/src/start.xq" -f --compile-only)
345
346=== removed file 'bin/debug_client/debug_command.cpp'
347--- bin/debug_client/debug_command.cpp 2011-07-01 01:53:24 +0000
348+++ bin/debug_client/debug_command.cpp 1970-01-01 00:00:00 +0000
349@@ -1,99 +0,0 @@
350-/*
351- * Copyright 2006-2008 The FLWOR Foundation.
352- *
353- * Licensed under the Apache License, Version 2.0 (the "License");
354- * you may not use this file except in compliance with the License.
355- * You may obtain a copy of the License at
356- *
357- * http://www.apache.org/licenses/LICENSE-2.0
358- *
359- * Unless required by applicable law or agreed to in writing, software
360- * distributed under the License is distributed on an "AS IS" BASIS,
361- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
362- * See the License for the specific language governing permissions and
363- * limitations under the License.
364- */
365-#include <iostream>
366-#include "debug_client/debug_command.h"
367-
368-namespace zorba { namespace debugclient {
369-
370-
371- void CommandLine::execute()
372- {
373- for (;;) {
374- std::cout << "zdb>> ";
375- std::string command;
376- std::getline(std::cin, command);
377- std::vector<std::string> args;
378- args << command;
379- std::map<std::string, UntypedCommand*>::iterator lIter = theCommands.find(args[0]);
380- if (lIter == theCommands.end()) {
381- std::cout << args[0] << ": Command not found" << std::endl;
382- continue;
383- }
384- if (!lIter->second->execute(args))
385- continue;
386- return;
387- }
388- }
389-
390-
391- CommandLine::~CommandLine()
392- {
393- for (std::map<std::string, UntypedCommand*>::iterator i = theCommands.begin();
394- i != theCommands.end(); ++i)
395- {
396- delete i->second;
397- }
398- }
399-
400- CommandLine& CommandLine::operator<<(UntypedCommand *aCommand)
401- {
402- theCommands.insert(std::make_pair(aCommand->get_name(), aCommand));
403- return *this;
404- }
405-}}
406-
407-namespace std {
408- vector<string>& operator<< (vector<string>& vec, const string& str)
409- {
410- string::size_type before = 0;
411- string::size_type pos = str.find(" ", 0);
412- while (pos != str.npos) {
413- std::string lSub = str.substr(before, pos - before);
414- if (lSub[0] == '"') {
415- std::string::size_type lBeforeCopy = before;
416- do {
417- lBeforeCopy = str.find("\"", lBeforeCopy + 1);
418- } while (pos != str.npos && str.size() > pos + 1 && str[pos + 1] == '\\');
419- pos = lBeforeCopy;
420- lSub = str.substr(before + 1, pos - before - 1);
421- }
422- vec.push_back(lSub);
423- before = pos + 1;
424- pos = str.find(" ", before);
425- }
426- std::string lSub = str.substr(before);
427- if (lSub[0] == '"') {
428- pos = str.find("\"", before + 1);
429- lSub = str.substr(before + 1, pos - before - 1);
430- }
431- vec.push_back(lSub);
432- return vec;
433- }
434-
435- set<string>& operator<< (set<string>& vec, const string& str)
436- {
437- string::size_type before = 0;
438- string::size_type pos = str.find(" ", 0);
439- while (pos != str.npos) {
440- vec.insert(str.substr(before, pos));
441- before = pos + 1;
442- pos = str.find(" ", before);
443- }
444- vec.insert(str.substr(before));
445- return vec;
446- }
447-
448-}
449
450=== removed file 'bin/debug_client/event_handler_init.cpp.in'
451--- bin/debug_client/event_handler_init.cpp.in 2011-07-01 01:53:24 +0000
452+++ bin/debug_client/event_handler_init.cpp.in 1970-01-01 00:00:00 +0000
453@@ -1,41 +0,0 @@
454-/*
455- * Copyright 2006-2008 The FLWOR Foundation.
456- *
457- * Licensed under the Apache License, Version 2.0 (the "License");
458- * you may not use this file except in compliance with the License.
459- * You may obtain a copy of the License at
460- *
461- * http://www.apache.org/licenses/LICENSE-2.0
462- *
463- * Unless required by applicable law or agreed to in writing, software
464- * distributed under the License is distributed on an "AS IS" BASIS,
465- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
466- * See the License for the specific language governing permissions and
467- * limitations under the License.
468- */
469-#include <fstream>
470-#include "debug_client/event_handler.h"
471-
472-namespace zorba { namespace debugclient {
473-
474- std::istream* EventHandler::getCurrentDirectory() {
475- const char* build_dir = "@CMAKE_BINARY_DIR@/bin/message-handler.xq";
476- const char* install_dir =
477-#ifndef WIN32
478- "@CMAKE_INSTALL_PREFIX@/bin/";
479-#else
480- "C:/Program Files/Zorba XQuery Processor @ZORBA_MAJOR_NUMBER@.@ZORBA_MINOR_NUMBER@.@ZORBA_PATCH_NUMBER@/bin/";
481-#endif
482- std::auto_ptr<std::ifstream> stream(new std::ifstream(build_dir));
483- if (stream->good()) {
484- return stream.release();
485- }
486- stream.reset(new std::ifstream(install_dir));
487- if (stream->good()) {
488- return stream.release();
489- }
490- return 0;
491- }
492-
493-}} // end of namespace zorba::debugclient
494-
495
496=== removed file 'bin/debug_client/lock_free_queue.cpp'
497--- bin/debug_client/lock_free_queue.cpp 2011-07-01 01:53:24 +0000
498+++ bin/debug_client/lock_free_queue.cpp 1970-01-01 00:00:00 +0000
499@@ -1,16 +0,0 @@
500-/*
501- * Copyright 2006-2008 The FLWOR Foundation.
502- *
503- * Licensed under the Apache License, Version 2.0 (the "License");
504- * you may not use this file except in compliance with the License.
505- * You may obtain a copy of the License at
506- *
507- * http://www.apache.org/licenses/LICENSE-2.0
508- *
509- * Unless required by applicable law or agreed to in writing, software
510- * distributed under the License is distributed on an "AS IS" BASIS,
511- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
512- * See the License for the specific language governing permissions and
513- * limitations under the License.
514- */
515-#include "lock_free_queue.h"
516
517=== removed file 'bin/debug_client/message-handler.xq'
518--- bin/debug_client/message-handler.xq 2011-08-26 23:36:24 +0000
519+++ bin/debug_client/message-handler.xq 1970-01-01 00:00:00 +0000
520@@ -1,165 +0,0 @@
521-(:
522- : Copyright 2006-2009 The FLWOR Foundation.
523- :
524- : Licensed under the Apache License, Version 2.0 (the "License");
525- : you may not use this file except in compliance with the License.
526- : You may obtain a copy of the License at
527- :
528- : http://www.apache.org/licenses/LICENSE-2.0
529- :
530- : Unless required by applicable law or agreed to in writing, software
531- : distributed under the License is distributed on an "AS IS" BASIS,
532- : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
533- : See the License for the specific language governing permissions and
534- : limitations under the License.
535-:)
536-
537-import module namespace refl = 'http://www.zorba-xquery.com/modules/reflection';
538-import module namespace sctx = "http://www.zorba-xquery.com/modules/introspection/sctx";
539-import module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";
540-
541-
542-declare variable $local:localns as xs:string := 'http://www.w3.org/2005/xquery-local-functions';
543-
544-
545-declare variable $local:endl as xs:string := '
546-';
547-
548-declare function local:has-to-stop($resp as element())
549-{
550- fn:not(($resp/@command/data(.) eq "stop" and $resp/@reason/data(.) eq "ok")
551- or ($resp/@status/data(.) eq "stopped")
552- or ($resp/@status/data(.) eq "stopping"))
553-};
554-
555-declare function local:status($resp as element())
556-{
557- fn:concat(
558- "Status: ", $resp/@status/data(.), $local:endl,
559- "Reason: ", $resp/@reason/data(.), $local:endl,
560- let $msg := $resp/text()
561- return
562- if (fn:empty($msg) or $msg eq "") then
563- ""
564- else
565- fn:concat($msg, $local:endl)
566- )
567-};
568-
569-
570-declare function local:run($resp as element()) {
571- if ($resp/@status/data(.) eq "starting") then
572- "Starting query"
573- else
574- local:status($resp)
575-};
576-
577-declare function local:stop($resp as element())
578-{
579- local:status($resp)
580-};
581-
582-declare function local:breakpoint_set($resp as element())
583-{
584- if ($resp/error) then
585- fn:concat("Error when setting a breakpoint: ", if ($resp/error/message) then $resp/error/message/text() else concat(" errcode: ", data($resp/error/@code)))
586- else
587- fn:concat("set breakpoint with id ", data($resp/@id), " and state ", data($resp/@state))
588-};
589-
590-declare function local:breakpoint_list($resp as element())
591-{
592- string-join(
593- for $b in $resp/breakpoint
594- return concat("Breakpoint ", data($b/@id), " at ", data($b/@filename), ":", data($b/@lineno), " ", data($b/@state)),
595- $local:endl
596- )
597-};
598-
599-declare function local:breakpoint_remove($resp as element())
600-{
601- "Breakpoint removed"
602-};
603-
604-declare function local:stack_depth($resp as element())
605-{
606- concat("Depth: ", data($resp/@depth))
607-};
608-
609-declare function local:stack_get($resp as element())
610-{
611- string-join(
612- for $s in $resp/stack
613- return concat("Level ", data($s/@level), " at ", data($s/@filename), ":", data($s/@lineno)),
614- $local:endl
615- )
616-};
617-
618-
619-declare function local:context_names($resp as element())
620-{
621- string-join(
622- for $c in $resp/context
623- return concat("Context: ", data($c/@name), " id: ", data($c/@id)),
624- $local:endl
625- )
626-};
627-
628-declare function local:context_get($resp as element())
629-{
630- string-join(
631- for $p in $resp/property
632- return concat(data($p/@fullname), ": [", data($p/@type), "]",
633- if ($p/text() ne "") then concat(": ", base64:decode($p/text())) else ""),
634- $local:endl
635- )
636-};
637-
638-declare function local:eval($resp as element())
639-{
640- if (data($resp/@success) eq "1") then
641- local:context_get($resp)
642- else
643- concat("Eval failed", ":", $resp/error/message/text())
644-};
645-
646-declare function local:process-response($resp as element())
647-{
648- if (data($resp/@command) eq "") then
649- (fn:true(), $resp/@transaction_id/data(.), local:status($resp))
650- else
651- let $fun-cont-name := fn:QName($local:localns, concat("local:", $resp/@command/data(.), "-cont"))
652- let $fun-msg-name := fn:QName($local:localns, concat("local:", $resp/@command/data(.)))
653- return (
654- if (sctx:function-arguments-count($fun-cont-name) = 1) then
655- refl:invoke($fun-cont-name, $resp)
656- else
657- local:has-to-stop($resp),
658- $resp/@transaction_id/data(.),
659- if (sctx:function-arguments-count($fun-msg-name) = 1) then
660- refl:invoke($fun-msg-name, $resp)
661- else
662- "Recieved a message - command not implemented"
663- )
664-};
665-
666-declare function local:process-init($init as element())
667-{
668- fn:true(),
669- 0,
670- fn:concat(fn:string-join(
671- ('Established connection with', $init/@language/data(.), 'client', $init/@appid/data(.)), ' '), '
672-')
673-};
674-
675-declare function local:main($response as element()) {
676- let $process-fun as xs:QName := fn:QName($local:localns, concat("local:process-", node-name($response)))
677- return
678- if (sctx:function-arguments-count($process-fun) = 1) then
679- refl:invoke($process-fun, $response)
680- else (
681- true(),
682- ($response/@transaction_id, 0)[1]/data(.),
683- "ERROR: Recieved unknown node from client"
684- )
685-};
686
687=== renamed directory 'bin/debug_client' => 'bin/debugger'
688=== renamed file 'bin/debug_client/debug_command.h' => 'bin/debugger/command.h'
689--- bin/debug_client/debug_command.h 2011-07-04 08:05:46 +0000
690+++ bin/debugger/command.h 2012-02-03 01:13:24 +0000
691@@ -14,7 +14,9 @@
692 * limitations under the License.
693 */
694 #pragma once
695-#include <zorba/config.h>
696+#ifndef ZORBA_DEBUGGER_COMMAND_H
697+#define ZORBA_DEBUGGER_COMMAND_H
698+
699 #include <string>
700 #include <vector>
701 #include <iostream>
702@@ -23,151 +25,18 @@
703 #include <sstream>
704 #include <memory>
705 #include <typeinfo>
706-#include "debug_client/tuple.h"
707-
708-namespace zorba { namespace debugclient {
709+
710+#include <zorba/config.h>
711+
712+#include "command_arg.h"
713+#include "tuple.h"
714+
715+
716+namespace zorba { namespace debugger {
717
718 class DebugClientParseException : public std::exception {
719 };
720
721- template<typename Tuple>
722- class CommandArg;
723-
724- template<typename Tuple>
725- class CommandArgInstance {
726- public:
727- virtual int get_index() const = 0;
728- virtual const CommandArg<Tuple>* get_arg() const = 0;
729- virtual void insertValue(Tuple& t) = 0;
730- virtual bool isSet(Tuple& t) const = 0;
731- };
732-
733- template<typename T, int Idx, typename Tuple>
734- class TypedCommandArgInstance : public CommandArgInstance<Tuple>
735- {
736- public:
737- TypedCommandArgInstance(T aValue, const CommandArg<Tuple>* aArg)
738- : theValue(aValue), theArg(aArg) {}
739- virtual int get_index() const { return Idx; }
740- virtual const CommandArg<Tuple>* get_arg() const { return theArg; }
741- virtual void insertValue(Tuple& t)
742- {
743- ZORBA_TR1_NS::get<Idx>(t).first = true;
744- ZORBA_TR1_NS::get<Idx>(t).second = theValue;
745- }
746- virtual bool isSet(Tuple& t) const
747- {
748- return ZORBA_TR1_NS::get<Idx>(t).first;
749- }
750- private:
751- T theValue;
752- const CommandArg<Tuple>* theArg;
753- };
754-
755- template<typename Tuple>
756- class CommandArgType {
757- public:
758- virtual CommandArgInstance<Tuple>* parse(const std::string& str,
759- const CommandArg<Tuple>* arg) = 0;
760- virtual bool isVoid() const = 0;
761- virtual bool isSet(Tuple& t) const = 0;
762- virtual ~CommandArgType() {}
763- };
764-
765- template<typename T, int Idx, typename Tuple>
766- class TypedCommandArgType : public CommandArgType<Tuple> {
767- public:
768- typedef T Type;
769- public: // implementation
770- TypedCommandArgType(bool aIsVoid) : theIsVoid(aIsVoid) {}
771- TypedCommandArgType(const T& aValue,
772- bool aIsVoid)
773- : theDefault(aValue), theIsVoid(aIsVoid) {}
774- virtual CommandArgInstance<Tuple>* parse(const std::string& str,
775- const CommandArg<Tuple>* arg)
776- {
777- T aValue;
778- std::stringstream stream(str);
779- stream >> aValue;
780- if (stream.fail()) {
781- std::cerr << "Could not parse argument of type "
782- << typeid(T).name()
783- << std::endl;
784- return 0;
785- }
786- return new TypedCommandArgInstance<T, Idx, Tuple>(aValue, arg);
787- }
788- virtual bool isVoid() const { return theIsVoid; }
789- virtual bool isSet(Tuple& t) const
790- {
791- return ZORBA_TR1_NS::get<Idx>(t).first;
792- }
793- private:
794- TypedCommandArgType<T, Idx, Tuple>() {}
795- T theDefault;
796- bool theIsVoid;
797- };
798-
799- template<typename Tuple>
800- class CommandArg {
801- public:
802- CommandArg(unsigned aId,
803- CommandArgType<Tuple>* aType,
804- const std::set<std::string>& aFlags,
805- const std::string& aDescription,
806- bool aIsRequired)
807- : theId(aId),
808- theType(aType),
809- theFlags(aFlags),
810- theDescription(aDescription),
811- theIsRequired(aIsRequired)
812- {
813- }
814- ~CommandArg() { delete theType; }
815- unsigned get_id() const { return theId; }
816- bool canHandle(const std::string& arg) const
817- {
818- if (theFlags.find(arg) != theFlags.end()) {
819- return true;
820- }
821- return false;
822- }
823- CommandArgInstance<Tuple>* parse(const std::string& str) const
824- {
825- return theType->parse(str, this);
826- }
827- bool isVoid() const {
828- return theType->isVoid();
829- }
830- bool isRequired() const { return theIsRequired; }
831- std::string get_name() const {
832- return *(theFlags.begin());
833- }
834- bool isSet(Tuple& t) const
835- {
836- return theType->isSet(t);
837- }
838- private:
839- unsigned theId;
840- CommandArgType<Tuple>* theType;
841- std::set<std::string> theFlags;
842- std::string theDescription;
843- bool theIsRequired;
844- };
845-}} // end namespace zorba
846-
847-namespace std {
848-
849- /**
850- * This is a helper split function
851- */
852- vector<string>& operator<< (vector<string>& vec, const string& str);
853-
854- set<string>& operator<< (set<string>& vec, const string& str);
855-} //end namespace std
856-
857-namespace zorba { namespace debugclient {
858-
859 template<typename Func, typename Tuple, int CommandIdx>
860 class CommandInstance
861 {
862@@ -188,8 +57,10 @@
863
864 class UntypedCommand {
865 public:
866- virtual std::string get_name() const = 0;
867- virtual std::string get_description() const = 0;
868+ virtual std::string getName() const = 0;
869+ virtual std::set<std::string> getAliases() const = 0;
870+ virtual std::string getDescription() const = 0;
871+ virtual void printHelp() const = 0;
872 virtual bool execute(const std::vector<std::string>& args) = 0;
873 };
874
875@@ -197,77 +68,141 @@
876 class Command : public UntypedCommand {
877 public:
878 Command(const std::string& aName, Func& aFunction, const std::string& aDescription)
879- : theName(aName), theFunction(aFunction), theDescription(aDescription) {}
880+ : theName(aName), theFunction(aFunction), theDescription(aDescription)
881+ {}
882+
883+ Command(const std::string& aName, const std::set<std::string> aAliases, Func& aFunction, const std::string& aDescription)
884+ : theName(aName), theAliases(aAliases), theFunction(aFunction), theDescription(aDescription)
885+ {}
886+
887 ~Command();
888+
889 public:
890- Command& operator() (unsigned aId,
891- const std::string& aFlags,
892- CommandArgType<Tuple>* aType,
893- const std::string& aDescription = "",
894- bool isRequired = false);
895- virtual std::string get_name() const { return theName; }
896- virtual std::string get_description() const { return theDescription; }
897+
898+ void
899+ addArgument(
900+ unsigned aId,
901+ const std::string& aFlags,
902+ CommandArgType<Tuple>* aType,
903+ const std::string& aDescription = "",
904+ bool isRequired = false);
905+
906+ static void
907+ splitNames(
908+ const std::string& names,
909+ std::set<std::string>& set);
910+
911+ virtual std::string
912+ getName() const
913+ {
914+ return theName;
915+ }
916+
917+ virtual std::set<std::string> getAliases() const
918+ {
919+ return theAliases;
920+ }
921+
922+ virtual std::string
923+ getDescription() const
924+ {
925+ return theDescription;
926+ }
927+
928+ virtual void
929+ printHelp() const;
930+
931 virtual bool execute(const std::vector<std::string>& args)
932 {
933 CommandInstance<Func, Tuple, CommandIdx> instance(theFunction, theTuple);
934- if (instance.parseArguments(args, theArgs))
935+ if (instance.parseArguments(args, theArgs)) {
936 instance.execute();
937- else
938- return false;
939- return true;
940+ return true;
941+ }
942+ return false;
943 }
944 private:
945 std::string theName;
946+ std::set<std::string> theAliases;
947 Func& theFunction;
948 Tuple theTuple;
949 std::string theDescription;
950- std::map<std::string, CommandArg<Tuple>* > theArgs;
951- };
952-
953- class CommandLine {
954- public:
955- ~CommandLine();
956- public:
957- void execute();
958- CommandLine& operator<< (UntypedCommand* aCommand);
959- private:
960- std::map<std::string, UntypedCommand*> theCommands;
961- };
962-
963- template<typename Func, typename Tuple, int CommandIdx>
964- Command<Func, Tuple, CommandIdx>::~Command()
965- {
966- typedef std::map<std::string, CommandArg<Tuple>* > ArgType;
967- for (typename ArgType::iterator i = theArgs.begin(); i != theArgs.end(); ++i) {
968- delete i->second;
969- }
970- }
971-
972-
973- template<typename Func, typename Tuple, int CommandIdx>
974- Command<Func, Tuple, CommandIdx>&
975- Command<Func, Tuple, CommandIdx>::operator() (unsigned aId,
976- const std::string& aFlags,
977- CommandArgType<Tuple>* aType,
978- const std::string& aDescription,
979- bool isRequired)
980- {
981- std::set<std::string> args;
982- args << aFlags;
983- for (std::set<std::string>::iterator i = args.begin(); i != args.end(); ++i) {
984- std::string toAdd = (i->size() == 1) ? "-" + *i : "--" + *i;
985- theArgs.insert(std::make_pair(toAdd,
986- new CommandArg<Tuple>(aId,
987- aType,
988- args,
989- aDescription,
990- isRequired)
991- )
992- );
993- }
994- return *this;
995- }
996-
997+ std::map<std::string, CommandArg<Tuple>*> theArgs;
998+ };
999+
1000+/*****************************************************************************/
1001+/*****************************************************************************/
1002+
1003+template<typename Func, typename Tuple, int CommandIdx>
1004+Command<Func, Tuple, CommandIdx>::~Command()
1005+{
1006+ typedef std::map<std::string, CommandArg<Tuple>*> ArgType;
1007+ for (typename ArgType::iterator i = theArgs.begin(); i != theArgs.end(); ++i) {
1008+ delete i->second;
1009+ }
1010+}
1011+
1012+template<typename Func, typename Tuple, int CommandIdx>
1013+void
1014+Command<Func, Tuple, CommandIdx>::printHelp() const
1015+{
1016+ std::cout << "Purpose: " << getDescription() << std::endl;
1017+
1018+ typename std::map<std::string, CommandArg<Tuple>*>::const_iterator lIter = theArgs.begin();
1019+ if (lIter == theArgs.end()) {
1020+ std::cout << "This command has no arguments." << std::endl;
1021+ std::cout << std::endl;
1022+ return;
1023+ }
1024+
1025+ std::cout << "Arguments:" << std::endl << std::endl;
1026+ for (; lIter != theArgs.end(); ++lIter) {
1027+ std::cout << " " << lIter->first << "\t" << lIter->second->getDescription() << std::endl;
1028+ }
1029+ std::cout << std::endl;
1030+}
1031+
1032+template<typename Func, typename Tuple, int CommandIdx>
1033+void
1034+Command<Func, Tuple, CommandIdx>::splitNames(const std::string& aNames, std::set<std::string>& aSet)
1035+{
1036+ std::string::size_type before = 0;
1037+ std::string::size_type pos = aNames.find(" ", 0);
1038+ while (pos != aNames.npos) {
1039+ std::string lName = aNames.substr(before, pos);
1040+ if (lName != "") {
1041+ aSet.insert(lName);
1042+ }
1043+ before = pos + 1;
1044+ pos = aNames.find(" ", before);
1045+ }
1046+ std::string lName = aNames.substr(before);
1047+ if (lName != "") {
1048+ aSet.insert(lName);
1049+ }
1050+}
1051+
1052+template<typename Func, typename Tuple, int CommandIdx>
1053+void
1054+Command<Func, Tuple, CommandIdx>::addArgument(
1055+ unsigned aId,
1056+ const std::string& aFlags,
1057+ CommandArgType<Tuple>* aType,
1058+ const std::string& aDescription,
1059+ bool isRequired)
1060+{
1061+ std::set<std::string> lNames;
1062+ splitNames(aFlags, lNames);
1063+
1064+ for (std::set<std::string>::iterator i = lNames.begin(); i != lNames.end(); ++i) {
1065+ std::string toAdd = (i->size() == 1) ? "-" + *i : "--" + *i;
1066+ CommandArg<Tuple>* lArg = new CommandArg<Tuple>(aId, aType, lNames, aDescription, isRequired);
1067+ theArgs.insert(std::make_pair(toAdd, lArg));
1068+ }
1069+}
1070+
1071+/*****************************************************************************/
1072+
1073 template<typename Tuple, typename T, int Idx>
1074 CommandArgType<Tuple>* createArgType(Tuple t)
1075 {
1076@@ -290,6 +225,16 @@
1077 return new Command<Func, Tuple, CommandIdx>(aName, aFunction, aDescription);
1078 }
1079
1080+ template<int CommandIdx, typename Tuple, typename Func>
1081+ Command<Func, Tuple, CommandIdx>* createCommand(Tuple t,
1082+ const std::string& aName,
1083+ const std::set<std::string>& aAliases,
1084+ Func& aFunction,
1085+ const std::string& aDescription)
1086+ {
1087+ return new Command<Func, Tuple, CommandIdx>(aName, aAliases, aFunction, aDescription);
1088+ }
1089+
1090 template<typename Func, typename Tuple, int CommandIdx>
1091 bool CommandInstance<Func, Tuple, CommandIdx>::
1092 parseArguments(const std::vector<std::string>& args,
1093@@ -301,29 +246,34 @@
1094 for (ArgType::size_type i = 1; i < size; ++i) {
1095 typename CArgType::const_iterator pos = aCommandArgs.find(args[i]);
1096 if (pos == aCommandArgs.end()) {
1097- std::cerr << "Error: Unknown Argument " << args[i] << std::endl;
1098+ std::cerr << "Error: Unknown option " << args[i] << std::endl;
1099 parseError = true;
1100 return false;
1101 }
1102 const CommandArg<Tuple>& arg = *(pos->second);
1103- if (!arg.isVoid() && args[++i][0] == '-') {
1104- std::cerr << "Did not expect parameter for option " << args[i] << std::endl;
1105- return false;
1106- }
1107 std::auto_ptr<CommandArgInstance<Tuple> > instance;
1108 if (arg.isVoid()) {
1109 instance.reset(arg.parse("1"));
1110 } else {
1111+ ++i;
1112+ if (i >= size) {
1113+ std::cerr << "Error: Missing value for argument " << args[i - 1] << std::endl;
1114+ parseError = true;
1115+ allSet = false;
1116+ return false;
1117+ }
1118 instance.reset(arg.parse(args[i]));
1119 }
1120- instance->insertValue(theTuple);
1121+ if (instance.get()) {
1122+ instance->insertValue(theTuple);
1123+ }
1124 }
1125 bool allSet = true;
1126 for (typename CArgType::const_iterator i = aCommandArgs.begin();
1127 i != aCommandArgs.end(); ++i)
1128 {
1129 if (i->second->isRequired() && !i->second->isSet(theTuple)) {
1130- std::cerr << "Error: Argument " << i->second->get_name() << " not set" << std::endl;
1131+ std::cerr << "Error: Argument -" << i->second->getName() << " not set" << std::endl;
1132 allSet = false;
1133 }
1134 }
1135@@ -336,4 +286,7 @@
1136 theFunction.template handle<CommandIdx>(this->theTuple);
1137 }
1138
1139-}} // end of namespace zorba::debugclient
1140+} // namespace zorba
1141+} // namespace debugger
1142+
1143+#endif // ZORBA_DEBUGGER_COMMAND_H
1144
1145=== added file 'bin/debugger/command_arg.h'
1146--- bin/debugger/command_arg.h 1970-01-01 00:00:00 +0000
1147+++ bin/debugger/command_arg.h 2012-02-03 01:13:24 +0000
1148@@ -0,0 +1,237 @@
1149+/*
1150+ * Copyright 2006-2008 The FLWOR Foundation.
1151+ *
1152+ * Licensed under the Apache License, Version 2.0 (the "License");
1153+ * you may not use this file except in compliance with the License.
1154+ * You may obtain a copy of the License at
1155+ *
1156+ * http://www.apache.org/licenses/LICENSE-2.0
1157+ *
1158+ * Unless required by applicable law or agreed to in writing, software
1159+ * distributed under the License is distributed on an "AS IS" BASIS,
1160+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1161+ * See the License for the specific language governing permissions and
1162+ * limitations under the License.
1163+ */
1164+#pragma once
1165+#ifndef ZORBA_DEBUGGER_COMMAND_ARG_H
1166+#define ZORBA_DEBUGGER_COMMAND_ARG_H
1167+
1168+#include <string>
1169+#include <iostream>
1170+#include <set>
1171+#include <sstream>
1172+
1173+#include "tuple.h"
1174+
1175+
1176+namespace zorba { namespace debugger {
1177+
1178+template<typename Tuple>
1179+class CommandArg;
1180+
1181+template<typename Tuple>
1182+class CommandArgInstance {
1183+ public:
1184+ virtual int get_index() const = 0;
1185+ virtual const CommandArg<Tuple>* get_arg() const = 0;
1186+ virtual void insertValue(Tuple& t) = 0;
1187+ virtual bool isSet(Tuple& t) const = 0;
1188+};
1189+
1190+template<typename T, int Idx, typename Tuple>
1191+class TypedCommandArgInstance : public CommandArgInstance<Tuple>
1192+{
1193+ public:
1194+ TypedCommandArgInstance(T aValue, const CommandArg<Tuple>* aArg)
1195+ : theValue(aValue), theArg(aArg)
1196+ {
1197+ }
1198+
1199+ virtual int
1200+ get_index() const
1201+ {
1202+ return Idx;
1203+ }
1204+
1205+ virtual const CommandArg<Tuple>*
1206+ get_arg() const
1207+ {
1208+ return theArg;
1209+ }
1210+
1211+ virtual void
1212+ insertValue(Tuple& t)
1213+ {
1214+ ZORBA_TR1_NS::get<Idx>(t).first = true;
1215+ ZORBA_TR1_NS::get<Idx>(t).second = theValue;
1216+ }
1217+
1218+ virtual bool isSet(Tuple& t) const
1219+ {
1220+ return ZORBA_TR1_NS::get<Idx>(t).first;
1221+ }
1222+
1223+ private:
1224+
1225+ T theValue;
1226+ const CommandArg<Tuple>* theArg;
1227+};
1228+
1229+template<typename Tuple>
1230+class CommandArgType
1231+{
1232+ public:
1233+ virtual CommandArgInstance<Tuple>*
1234+ parse(
1235+ const std::string& str,
1236+ const CommandArg<Tuple>* arg) = 0;
1237+
1238+ virtual bool
1239+ isVoid() const = 0;
1240+
1241+ virtual bool
1242+ isSet(Tuple& t) const = 0;
1243+
1244+ virtual ~CommandArgType() {}
1245+};
1246+
1247+ template<typename T, int Idx, typename Tuple>
1248+ class TypedCommandArgType : public CommandArgType<Tuple> {
1249+ public:
1250+ typedef T Type;
1251+ public: // implementation
1252+ TypedCommandArgType(bool aIsVoid) : theIsVoid(aIsVoid) {}
1253+ TypedCommandArgType(const T& aValue,
1254+ bool aIsVoid)
1255+ : theDefault(aValue), theIsVoid(aIsVoid) {}
1256+ virtual CommandArgInstance<Tuple>* parse(const std::string& str,
1257+ const CommandArg<Tuple>* arg)
1258+ {
1259+ T aValue;
1260+
1261+ // special treatment for strings
1262+ // this is a double hack:
1263+ // - we check the type name if this starts with: class std::basic_string
1264+ // - we use void* in readEntireString to workaround the template type T
1265+ // which would otherwise complain during compilation if types and
1266+ // operators do not match
1267+ // TOSO: probably someone can find a more elegant solution
1268+ std::string lTypeName(typeid(T).name());
1269+ if (lTypeName.find("class std::basic_string") == 0) {
1270+ readEntireString(str, &aValue);
1271+ } else {
1272+ std::stringstream stream(str);
1273+ std::stringstream out;
1274+ stream >> aValue;
1275+ if (stream.fail()) {
1276+ std::cerr << "Error: Could not parse value \"" << str << "\" as type "
1277+ << typeid(T).name()
1278+ << std::endl;
1279+ return 0;
1280+ }
1281+ }
1282+
1283+ return new TypedCommandArgInstance<T, Idx, Tuple>(aValue, arg);
1284+ }
1285+ virtual bool isVoid() const { return theIsVoid; }
1286+ virtual bool isSet(Tuple& t) const
1287+ {
1288+ return ZORBA_TR1_NS::get<Idx>(t).first;
1289+ }
1290+ private:
1291+ void readEntireString(std::string aIn, void* aValue)
1292+ {
1293+ *((std::string*)aValue) = aIn;
1294+ }
1295+
1296+ TypedCommandArgType<T, Idx, Tuple>() {}
1297+ T theDefault;
1298+ bool theIsVoid;
1299+ };
1300+
1301+ template<typename Tuple>
1302+ class CommandArg {
1303+ public:
1304+ CommandArg(unsigned aId,
1305+ CommandArgType<Tuple>* aType,
1306+ const std::set<std::string>& aNames,
1307+ const std::string& aDescription,
1308+ bool aIsRequired)
1309+ : theId(aId),
1310+ theType(aType),
1311+ theNames(aNames),
1312+ theDescription(aDescription),
1313+ theIsRequired(aIsRequired)
1314+ {
1315+ }
1316+
1317+ ~CommandArg()
1318+ {
1319+ delete theType;
1320+ }
1321+
1322+ unsigned
1323+ get_id() const
1324+ {
1325+ return theId;
1326+ }
1327+
1328+ bool
1329+ canHandle(const std::string& arg) const
1330+ {
1331+ if (theNames.find(arg) != theNames.end()) {
1332+ return true;
1333+ }
1334+ return false;
1335+ }
1336+
1337+ CommandArgInstance<Tuple>*
1338+ parse(const std::string& str) const
1339+ {
1340+ return theType->parse(str, this);
1341+ }
1342+
1343+ bool
1344+ isVoid() const
1345+ {
1346+ return theType->isVoid();
1347+ }
1348+
1349+ bool
1350+ isRequired() const
1351+ {
1352+ return theIsRequired;
1353+ }
1354+
1355+ std::string
1356+ getName() const
1357+ {
1358+ return *(theNames.begin());
1359+ }
1360+
1361+ std::string
1362+ getDescription() const
1363+ {
1364+ return theDescription;
1365+ }
1366+
1367+ bool
1368+ isSet(Tuple& t) const
1369+ {
1370+ return theType->isSet(t);
1371+ }
1372+
1373+ private:
1374+
1375+ unsigned theId;
1376+ CommandArgType<Tuple>* theType;
1377+ std::set<std::string> theNames;
1378+ std::string theDescription;
1379+ bool theIsRequired;
1380+ };
1381+
1382+} // namespace zorba
1383+} // namespace debugger
1384+
1385+#endif // ZORBA_DEBUGGER_COMMAND_ARG_H
1386
1387=== modified file 'bin/debugger/command_line_handler.cpp'
1388--- bin/debug_client/command_line_handler.cpp 2011-07-01 01:53:24 +0000
1389+++ bin/debugger/command_line_handler.cpp 2012-02-03 01:13:24 +0000
1390@@ -1,4 +1,4 @@
1391-/*
1392+ /*
1393 * Copyright 2006-2008 The FLWOR Foundation.
1394 *
1395 * Licensed under the Apache License, Version 2.0 (the "License");
1396@@ -23,225 +23,385 @@
1397 # define msleep Sleep
1398 #endif
1399
1400-namespace zorba { namespace debugclient {
1401+#include "command_prompt.h"
1402+
1403+
1404+namespace zorba { namespace debugger {
1405
1406- using namespace ::std;
1407 using namespace ::ZORBA_TR1_NS;
1408
1409- CommandLineHandler::CommandLineHandler(unsigned short port,
1410- LockFreeConsumer<std::size_t>& aConsumer,
1411- LockFreeConsumer<bool>& aContinueQueue,
1412- EventHandler& aHandler,
1413- CommandLine& aCommandLine)
1414+CommandLineHandler::CommandLineHandler(
1415+ unsigned short port,
1416+ LockFreeConsumer<std::size_t>& aConsumer,
1417+ LockFreeConsumer<bool>& aContinueQueue,
1418+ EventHandler* aHandler,
1419+ CommandPrompt* aCommandPrompt)
1420 : theConsumer(aConsumer),
1421 theContinueQueue(aContinueQueue),
1422- theClient(DebuggerClient::createDebuggerClient(&aHandler, port, "localhost")),
1423- theCommandLine(aCommandLine),
1424- theQuit(false), theContinue(false), theWaitFor(0)
1425+ theClient(DebuggerClient::createDebuggerClient(aHandler, port, "localhost")),
1426+ theCommandLine(aCommandPrompt),
1427+ theQuit(false), theTerminated(true), theContinue(false), theWaitFor(0)
1428 {
1429 addCommands();
1430 }
1431
1432- CommandLineHandler::~CommandLineHandler()
1433- {
1434- }
1435+CommandLineHandler::~CommandLineHandler()
1436+{
1437+}
1438
1439- void CommandLineHandler::execute()
1440- {
1441- theClient->accept();
1442- std::set<std::size_t> lIdList;
1443- do {
1444+void
1445+CommandLineHandler::execute()
1446+{
1447+ theClient->accept();
1448+ std::set<std::size_t> lIdList;
1449+ do {
1450+ getNextId(lIdList);
1451+ while (lIdList.find(theWaitFor) == lIdList.end()) {
1452 getNextId(lIdList);
1453- while (!theQuit && lIdList.find(theWaitFor) == lIdList.end()) {
1454- getNextId(lIdList);
1455- msleep(20);
1456- }
1457- while (!theContinueQueue.consume(theQuit)) {
1458- msleep(20);
1459- }
1460- theQuit = !theQuit;
1461- if (!theQuit) {
1462- theCommandLine.execute();
1463- while (theContinue) {
1464- theContinue = false;
1465- theCommandLine.execute();
1466- }
1467- }
1468- } while (!theQuit);
1469- }
1470-
1471- void CommandLineHandler::getNextId(std::set<std::size_t>& aIdList)
1472- {
1473- std::size_t result;
1474- if (theConsumer.consume(result)) {
1475- aIdList.insert(result);
1476- }
1477- }
1478-
1479- template<>
1480- void CommandLineHandler::handle<Status>(ZORBA_TR1_NS::tuple<> &t)
1481- {
1482- theWaitFor = theClient->status();
1483- }
1484-
1485- template<>
1486- void CommandLineHandler::handle<Quit>(ZORBA_TR1_NS::tuple<> &t)
1487- {
1488+ msleep(20);
1489+ }
1490+ bool lCanQuit;
1491+ while (!theContinueQueue.consume(lCanQuit)) {
1492+ msleep(20);
1493+ }
1494+ if (lCanQuit) {
1495+ theTerminated = true;
1496+ }
1497+ theCommandLine->execute();
1498+ while (theContinue) {
1499+ theContinue = false;
1500+ theCommandLine->execute();
1501+ }
1502+ } while (!theQuit);
1503+}
1504+
1505+void
1506+CommandLineHandler::getNextId(std::set<std::size_t>& aIdList)
1507+{
1508+ std::size_t result;
1509+ if (theConsumer.consume(result)) {
1510+ aIdList.insert(result);
1511+ }
1512+}
1513+
1514+template<>
1515+void
1516+CommandLineHandler::handle<Status>(ZORBA_TR1_NS::tuple<> &t)
1517+{
1518+ theWaitFor = theClient->status();
1519+}
1520+
1521+template<>
1522+void
1523+CommandLineHandler::handle<Variables>(ZORBA_TR1_NS::tuple<> &t)
1524+{
1525+ theWaitFor = theClient->variables();
1526+}
1527+
1528+template<>
1529+void
1530+CommandLineHandler::handle<Quit>(ZORBA_TR1_NS::tuple<> &t)
1531+{
1532+ if (!theTerminated) {
1533 bool answered = false;
1534 while (!answered) {
1535 std::cout << "Do you really want to stop debugging and exit? (y/n) ";
1536- char answer;
1537- std::cin >> answer;
1538- std::cout << std::endl;
1539- if (answer == 'y') {
1540+ std::string lAnswer;
1541+ std::getline(std::cin, lAnswer);
1542+ if (lAnswer == "y" || lAnswer == "yes") {
1543 answered = true;
1544- } else if (answered == 'n') {
1545+ } else if (lAnswer == "n" || lAnswer == "no") {
1546 theContinue = true;
1547 return;
1548 }
1549 }
1550- theWaitFor = theClient->stop();
1551- theClient->quit();
1552- }
1553-
1554- template<>
1555- void CommandLineHandler::handle<Run>(ZORBA_TR1_NS::tuple<> &t)
1556- {
1557- theWaitFor = theClient->run();
1558- }
1559-
1560- template<>
1561- void CommandLineHandler::handle<BreakpointSet>(std::tr1::tuple<bstring, bstring, bint> &t)
1562- {
1563- DebuggerClient::BreakpointType lType = DebuggerClient::Line;
1564- bool lEnabled = true;
1565- if (get<0>(t).first) {
1566- if (get<0>(t).second == "disabled") {
1567- lEnabled = false;
1568- }
1569- }
1570- theWaitFor = theClient->breakpoint_set(lType,
1571- lEnabled,
1572- get<1>(t).second,
1573- get<2>(t).second);
1574- }
1575-
1576- template<>
1577- void CommandLineHandler::handle<BreakpointGet>(tuple<bint> &aTuple)
1578- {
1579- theWaitFor = theClient->breakpoint_get(get<0>(aTuple).second);
1580- }
1581-
1582- template<>
1583- void CommandLineHandler::handle<BreakpointDel>(tuple<bint> &aTuple)
1584- {
1585- theWaitFor = theClient->breakpoint_remove(get<0>(aTuple).second);
1586- }
1587-
1588- template<>
1589- void CommandLineHandler::handle<BreakpointList>(tuple<> &t)
1590- {
1591- theWaitFor = theClient->breakpoint_list();
1592- }
1593-
1594- template<>
1595- void CommandLineHandler::handle<StackDepth>(tuple<> &t)
1596- {
1597- theWaitFor = theClient->stack_depth();
1598- }
1599-
1600- template<>
1601- void CommandLineHandler::handle<StackGet>(tuple<bint> &aTuple)
1602- {
1603- if (get<0>(aTuple).first) {
1604- theWaitFor = theClient->stack_get(get<0>(aTuple).second);
1605- } else {
1606- theWaitFor = theClient->stack_get();
1607- }
1608- }
1609-
1610- template<>
1611- void CommandLineHandler::handle<ContextNames>(tuple<>& aTuple)
1612- {
1613- theWaitFor = theClient->context_names();
1614- }
1615-
1616- template<>
1617- void CommandLineHandler::handle<ContextGet>(tuple<bint> &aTuple)
1618- {
1619- if (get<0>(aTuple).first)
1620- theWaitFor = theClient->context_get(get<0>(aTuple).second);
1621- else
1622- theWaitFor = theClient->context_get();
1623- }
1624-
1625- template<>
1626- void CommandLineHandler::handle<Eval>(tuple<bstring>& aTuple)
1627- {
1628- theWaitFor = theClient->eval(get<0>(aTuple).second);
1629- }
1630-
1631- void CommandLineHandler::addCommands()
1632- {
1633- theCommandLine << createCommand<Status>(tuple<>(), "status", *this,
1634- "Gets the status of the server");
1635- theCommandLine << createCommand<Quit>(tuple<>(), "quit", *this,
1636- "Stops debugging and quits the client");
1637- theCommandLine << createCommand<Run>(tuple<>(), "run", *this, "Run the Query");
1638- {
1639- Command<CommandLineHandler, tuple<bstring, bstring, bint>, BreakpointSet>* lCommand =
1640- createCommand<BreakpointSet>(tuple<bstring, bstring, bint>(), "break", *this, "Set a breakpoint");
1641- (*lCommand)(0, "s", createArgType<tuple<bstring, bstring, bint>, std::string, 0>(tuple<bstring, bstring, bint>()),
1642- "breakpoint state (enabled or disabled - default: enabled)", false);
1643- (*lCommand)(1, "f", createArgType<tuple<bstring, bstring, bint>, std::string, 1>(tuple<bstring, bstring, bint>()),
1644- "The name of the file where to stop", true);
1645- (*lCommand)(2, "l", createArgType<tuple<bstring, bstring, bint>, int, 2>(tuple<bstring, bstring, bint>()),
1646- "The line number", true);
1647-
1648- theCommandLine << lCommand;
1649- }
1650- {
1651- Command<CommandLineHandler, tuple<bint>, BreakpointGet>* lCommand
1652- = createCommand<BreakpointGet>(tuple<bint>(), "binfo", *this,
1653- "Get information about a given breakpoint");
1654- (*lCommand)(0, "i", createArgType<tuple<bint>, int, 0>(tuple<bint>()),
1655- "The id of the breakpoint", true);
1656-
1657- theCommandLine << lCommand;
1658- }
1659- {
1660- Command<CommandLineHandler, tuple<bint>, BreakpointDel>* lCommand
1661- = createCommand<BreakpointDel>(tuple<bint>(), "bdel", *this, "Delete a breakpoint with a given id");
1662- (*lCommand)(0, "i", createArgType<tuple<bint>, int, 0>(tuple<bint>()), "The id of the breakpoint", true);
1663-
1664- theCommandLine << lCommand;
1665- }
1666- theCommandLine << createCommand<BreakpointList>(tuple<>(), "blist", *this, "List all set breakpoints");
1667- theCommandLine << createCommand<StackDepth>(tuple<>(), "sdepth", *this, "Get the depth of the stack");
1668- {
1669- Command<CommandLineHandler, tuple<bint>, StackGet>* lCommand
1670- = createCommand<StackGet>(tuple<bint>(), "sget", *this, "Get information about one or all stack frames");
1671- (*lCommand)(0, "d", createArgType<tuple<bint>, int, 0>(tuple<bint>()), "The stack entry two show (show all if not provided)", false);
1672- theCommandLine << lCommand;
1673- }
1674- theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts");
1675- {
1676- Command<CommandLineHandler, tuple<bint>, ContextGet>* lCommand
1677- = createCommand<ContextGet>(tuple<bint>(), "cget", *this, "Get a context");
1678-
1679- (*lCommand)(0, "c", createArgType<tuple<bint>, int, 0>(tuple<bint>()), "The id of the context", false);
1680-
1681- theCommandLine << lCommand;
1682- }
1683- {
1684- Command<CommandLineHandler, tuple<bstring>, Eval>* lCommand
1685- = createCommand<Eval>(tuple<bstring>(), "eval", *this, "Evaluate a function");
1686-
1687- (*lCommand)(0, "c", createArgType<tuple<bstring>, std::string, 0>(tuple<bstring>()), "The command to evaluate", true);
1688-
1689- theCommandLine << lCommand;
1690- }
1691- }
1692-
1693-}} // namespace zorba::debugclient
1694-
1695+ }
1696+ theWaitFor = theClient->stop(true);
1697+ theClient->quit();
1698+ theQuit = true;
1699+}
1700+
1701+template<>
1702+void
1703+CommandLineHandler::handle<Run>(ZORBA_TR1_NS::tuple<> &t)
1704+{
1705+ theTerminated = false;
1706+ theWaitFor = theClient->run();
1707+}
1708+
1709+template<>
1710+void
1711+CommandLineHandler::handle<Stop>(ZORBA_TR1_NS::tuple<> &t)
1712+{
1713+ theWaitFor = theClient->stop(false);
1714+}
1715+
1716+template<>
1717+void
1718+CommandLineHandler::handle<BreakpointSet>(std::tr1::tuple<bstring, bstring, bint> &aTuple)
1719+{
1720+ DebuggerClient::BreakpointType lType = DebuggerClient::Line;
1721+ bool lEnabled = true;
1722+ if (get<0>(aTuple).first) {
1723+ if (get<0>(aTuple).second == "disabled") {
1724+ lEnabled = false;
1725+ }
1726+ }
1727+ theWaitFor = theClient->breakpoint_set(lType,
1728+ lEnabled,
1729+ get<1>(aTuple).second,
1730+ get<2>(aTuple).second);
1731+}
1732+
1733+template<>
1734+void
1735+CommandLineHandler::handle<BreakpointGet>(tuple<bint> &aTuple)
1736+{
1737+ theWaitFor = theClient->breakpoint_get(get<0>(aTuple).second);
1738+}
1739+
1740+template<>
1741+void
1742+CommandLineHandler::handle<BreakpointRemove>(tuple<bint> &aTuple)
1743+{
1744+ theWaitFor = theClient->breakpoint_remove(get<0>(aTuple).second);
1745+}
1746+
1747+template<>
1748+void
1749+CommandLineHandler::handle<BreakpointList>(tuple<> &aTuple)
1750+{
1751+ theWaitFor = theClient->breakpoint_list();
1752+}
1753+
1754+template<>
1755+void
1756+CommandLineHandler::handle<StackDepth>(tuple<> &aTuple)
1757+{
1758+ theWaitFor = theClient->stack_depth();
1759+}
1760+
1761+template<>
1762+void
1763+CommandLineHandler::handle<StackGet>(tuple<bint> &aTuple)
1764+{
1765+ if (get<0>(aTuple).first) {
1766+ theWaitFor = theClient->stack_get(get<0>(aTuple).second);
1767+ } else {
1768+ theWaitFor = theClient->stack_get();
1769+ }
1770+}
1771+
1772+template<>
1773+void
1774+CommandLineHandler::handle<ContextNames>(tuple<>& aTuple)
1775+{
1776+ theWaitFor = theClient->context_names();
1777+}
1778+
1779+template<>
1780+void CommandLineHandler::handle<ContextGet>(tuple<bint, bint> &aTuple)
1781+{
1782+ int lDepth = -1;
1783+ int lContext = -1;
1784+
1785+ if (get<0>(aTuple).first) {
1786+ lDepth = get<0>(aTuple).second;
1787+ }
1788+ if (get<1>(aTuple).first) {
1789+ lContext = get<1>(aTuple).second;
1790+ }
1791+ theWaitFor = theClient->context_get(lDepth, lContext);
1792+}
1793+
1794+template<>
1795+void CommandLineHandler::handle<Source>(tuple<bint, bint, bstring> &aTuple)
1796+{
1797+ theWaitFor = theClient->source(
1798+ get<2>(aTuple).second,
1799+ get<0>(aTuple).second,
1800+ get<1>(aTuple).second);
1801+}
1802+
1803+template<>
1804+void CommandLineHandler::handle<Eval>(tuple<bstring>& aTuple)
1805+{
1806+ theWaitFor = theClient->eval(get<0>(aTuple).second);
1807+}
1808+
1809+template<>
1810+void
1811+CommandLineHandler::handle<StepIn>(ZORBA_TR1_NS::tuple<> &t)
1812+{
1813+ theTerminated = false;
1814+ theWaitFor = theClient->step_into();
1815+}
1816+
1817+template<>
1818+void
1819+CommandLineHandler::handle<StepOut>(ZORBA_TR1_NS::tuple<> &t)
1820+{
1821+ theWaitFor = theClient->step_out();
1822+}
1823+
1824+template<>
1825+void
1826+CommandLineHandler::handle<StepOver>(ZORBA_TR1_NS::tuple<> &t)
1827+{
1828+ theTerminated = false;
1829+ theWaitFor = theClient->step_over();
1830+}
1831+
1832+void
1833+CommandLineHandler::addCommands()
1834+{
1835+ typedef tuple<> TUPLE;
1836+ typedef tuple<bint> TUPLE_INT;
1837+ typedef tuple<bstring> TUPLE_STR;
1838+ typedef tuple<bint, bint> TUPLE_INT_INT;
1839+ typedef tuple<bstring, bstring, bint> TUPLE_STR_STR_INT;
1840+ typedef tuple<bint, bint, bstring> TUPLE_INT_INT_STR;
1841+
1842+ // DBGP: status
1843+ *theCommandLine << createCommand<Status>(TUPLE(), "status", *this, "Gets the status of the server");
1844+
1845+ // ALIAS: variables (context_get -c -1)
1846+ {
1847+ std::set<std::string> lAliases;
1848+ lAliases.insert("vars");
1849+ *theCommandLine << createCommand<Variables>(TUPLE(), "variables", lAliases, *this, "Gets the variables visible in the current scope");
1850+ }
1851+
1852+ // META: quit
1853+ *theCommandLine << createCommand<Quit>(TUPLE(), "quit", *this, "Stops debugging and quits the client");
1854+
1855+ // DBGP: run
1856+ *theCommandLine << createCommand<Run>(TUPLE(), "run", *this, "Run the query");
1857+
1858+ // DBGP: stop
1859+ *theCommandLine << createCommand<Stop>(TUPLE(), "stop", *this, "Stop the query");
1860+
1861+ // DBGP: breakpoint_set
1862+ {
1863+ std::set<std::string> lAliases;
1864+ lAliases.insert("break");
1865+ Command<CommandLineHandler, TUPLE_STR_STR_INT, BreakpointSet>* lCommand =
1866+ createCommand<BreakpointSet>(TUPLE_STR_STR_INT(), "bset", lAliases, *this, "Set a breakpoint");
1867+
1868+ lCommand->addArgument(0, "s", createArgType<TUPLE_STR_STR_INT, std::string, 0>(TUPLE_STR_STR_INT()), "breakpoint state (optional, 'enabled' or 'disabled', default: enabled)", false);
1869+ lCommand->addArgument(1, "f", createArgType<TUPLE_STR_STR_INT, std::string, 1>(TUPLE_STR_STR_INT()), "name of the file where to stop", true);
1870+ lCommand->addArgument(2, "l", createArgType<TUPLE_STR_STR_INT, int, 2>(TUPLE_STR_STR_INT()), "line number", true);
1871+
1872+ *theCommandLine << lCommand;
1873+ }
1874+
1875+ // DBGP: breakpoint_get
1876+ {
1877+ Command<CommandLineHandler, TUPLE_INT, BreakpointGet>* lCommand =
1878+ createCommand<BreakpointGet>(TUPLE_INT(), "bget", *this, "Get information about a given breakpoint");
1879+
1880+ lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true);
1881+
1882+ *theCommandLine << lCommand;
1883+ }
1884+
1885+ // DBGP: breakpoint_remove
1886+ {
1887+ std::set<std::string> lAliases;
1888+ lAliases.insert("clear");
1889+ lAliases.insert("delete");
1890+ Command<CommandLineHandler, TUPLE_INT, BreakpointRemove>* lCommand =
1891+ createCommand<BreakpointRemove>(TUPLE_INT(), "bremove", lAliases, *this, "Delete a breakpoint");
1892+
1893+ lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "breakpoint ID", true);
1894+
1895+ *theCommandLine << lCommand;
1896+ }
1897+
1898+ // DBGP: breakpoint_list
1899+ *theCommandLine << createCommand<BreakpointList>(TUPLE(), "blist", *this, "List all set breakpoints");
1900+
1901+ // DBGP: stack_depth
1902+ *theCommandLine << createCommand<StackDepth>(TUPLE(), "sdepth", *this, "Get the depth of the stack");
1903+
1904+ // DBGP: stack_get
1905+ {
1906+ Command<CommandLineHandler, TUPLE_INT, StackGet>* lCommand =
1907+ createCommand<StackGet>(TUPLE_INT(), "sget", *this, "Get information about one or all stack frames");
1908+
1909+ lCommand->addArgument(0, "d", createArgType<TUPLE_INT, int, 0>(TUPLE_INT()), "stack frame to show: 0 for current stack frame, N for the main module (optional, all frames are shown if not provided)", false);
1910+
1911+ *theCommandLine << lCommand;
1912+ }
1913+
1914+ // DBGP: context_names
1915+ *theCommandLine << createCommand<ContextNames>(tuple<>(), "cnames", *this, "Get the names of the avilable contexts");
1916+ // the DBGP -d arguments for this command is omitted since we always have/return: 0 - Local, 1 - Global
1917+
1918+ // DBGP: context_get
1919+ {
1920+ Command<CommandLineHandler, TUPLE_INT_INT, ContextGet>* lCommand =
1921+ createCommand<ContextGet>(TUPLE_INT_INT(), "cget", *this, "Get a context (list variables in this context)");
1922+
1923+ lCommand->addArgument(0, "d", createArgType<TUPLE_INT_INT, int, 0>(TUPLE_INT_INT()), "stack depth (optional, default: 0)", false);
1924+ lCommand->addArgument(0, "c", createArgType<TUPLE_INT_INT, int, 1>(TUPLE_INT_INT()), "context ID: 0 for Local, 1 for Global (optional, default: 0)", false);
1925+
1926+ *theCommandLine << lCommand;
1927+ }
1928+
1929+ // DBGP: source
1930+ {
1931+ std::set<std::string> lAliases;
1932+ lAliases.insert("list");
1933+ Command<CommandLineHandler, TUPLE_INT_INT_STR, Source>* lCommand =
1934+ createCommand<Source>(TUPLE_INT_INT_STR(), "source", lAliases, *this, "List source code");
1935+
1936+ lCommand->addArgument(0, "b", createArgType<TUPLE_INT_INT_STR, int, 0>(TUPLE_INT_INT_STR()), "begin line (optional, default: first line)", false);
1937+ lCommand->addArgument(1, "e", createArgType<TUPLE_INT_INT_STR, int, 1>(TUPLE_INT_INT_STR()), "end line (optional, default: last line)", false);
1938+ lCommand->addArgument(2, "f", createArgType<TUPLE_INT_INT_STR, std::string, 2>(TUPLE_INT_INT_STR()), "file URI (optional, default: the file in the top-most stack frame during execution, main module otherwise)", false);
1939+
1940+ *theCommandLine << lCommand;
1941+ }
1942+
1943+ // DBGP: eval
1944+ {
1945+ std::set<std::string> lAliases;
1946+ lAliases.insert("print");
1947+ Command<CommandLineHandler, TUPLE_STR, Eval>* lCommand =
1948+ createCommand<Eval>(TUPLE_STR(), "eval", lAliases, *this, "Evaluate an expression");
1949+
1950+ // TODO: this argument should not be here at all. Eval has the form: eval -i transaction_id -- {DATA}
1951+ // Eval should be called with a command like: eval 1 + 3
1952+ // - no need for an argument name
1953+ // - everything following the fist contiguous set of whitespaces are sent as string
1954+ lCommand->addArgument(0, "c", createArgType<TUPLE_STR, std::string, 0>(TUPLE_STR()), "expression to evaluate", true);
1955+
1956+ *theCommandLine << lCommand;
1957+ }
1958+
1959+ // DBGP: step_in
1960+ {
1961+ std::set<std::string> lAliases;
1962+ lAliases.insert("step");
1963+ lAliases.insert("s");
1964+ *theCommandLine << createCommand<StepIn>(TUPLE(), "in", lAliases, *this, "Step in");
1965+ }
1966+
1967+ // DBGP: step_out
1968+ {
1969+ std::set<std::string> lAliases;
1970+ lAliases.insert("finish");
1971+ *theCommandLine << createCommand<StepOut>(TUPLE(), "out", lAliases, *this, "Step out");
1972+ }
1973+
1974+ // DBGP: step_over
1975+ {
1976+ std::set<std::string> lAliases;
1977+ lAliases.insert("next");
1978+ lAliases.insert("n");
1979+ *theCommandLine << createCommand<StepOver>(TUPLE(), "over", lAliases, *this, "Step over");
1980+ }
1981+}
1982+
1983+} // namespace zorba
1984+} // namespace debugger
1985
1986=== modified file 'bin/debugger/command_line_handler.h'
1987--- bin/debug_client/command_line_handler.h 2011-07-01 01:53:24 +0000
1988+++ bin/debugger/command_line_handler.h 2012-02-03 01:13:24 +0000
1989@@ -14,46 +14,71 @@
1990 * limitations under the License.
1991 */
1992 #pragma once
1993+#ifndef ZORBA_DEBUGGER_COMMAND_LINE_HANDLER_H
1994+#define ZORBA_DEBUGGER_COMMAND_LINE_HANDLER_H
1995
1996 #include <set>
1997 #include <cassert>
1998+
1999 #include <zorba/debugger_client.h>
2000-#include "debug_command.h"
2001+
2002+#include "command.h"
2003 #include "event_handler.h"
2004
2005-namespace zorba { namespace debugclient {
2006-
2007+
2008+namespace zorba { namespace debugger {
2009+
2010+ class CommandPrompt;
2011+
2012 enum Commands {
2013 Status,
2014+ Variables,
2015+ Quit,
2016 Run,
2017+ Stop,
2018 BreakpointSet,
2019 BreakpointGet,
2020- BreakpointDel,
2021+ BreakpointRemove,
2022 BreakpointList,
2023 StackDepth,
2024 StackGet,
2025 ContextNames,
2026 ContextGet,
2027+ Source,
2028 Eval,
2029- Quit
2030+ StepIn,
2031+ StepOut,
2032+ StepOver
2033 };
2034
2035- class CommandLineHandler {
2036+class CommandLineHandler
2037+{
2038 private:
2039+
2040 typedef std::pair<bool, std::string> bstring;
2041 typedef std::pair<bool, int> bint;
2042+
2043 public:
2044- CommandLineHandler(unsigned short port,
2045- LockFreeConsumer<std::size_t>& aConsumer,
2046- LockFreeConsumer<bool>& aContinueQueue,
2047- EventHandler& aHandler,
2048- CommandLine& aCommandLine);
2049+
2050+ CommandLineHandler(
2051+ unsigned short port,
2052+ LockFreeConsumer<std::size_t>& aConsumer,
2053+ LockFreeConsumer<bool>& aContinueQueue,
2054+ EventHandler* aHandler,
2055+ CommandPrompt* aCommandPrompt);
2056+
2057 ~CommandLineHandler();
2058+
2059 public:
2060 void execute();
2061+
2062 public: // Handlers
2063+
2064 template<int>
2065- void handle(ZORBA_TR1_NS::tuple<>& aTuple) { assert(false); }
2066+ void handle(ZORBA_TR1_NS::tuple<>& aTuple)
2067+ {
2068+ assert(false);
2069+ }
2070
2071 template<int>
2072 void handle(ZORBA_TR1_NS::tuple<bstring, bstring, bint>& t)
2073@@ -62,63 +87,96 @@
2074 }
2075
2076 template<int>
2077+ void handle(ZORBA_TR1_NS::tuple<bint, bint, bstring>& t)
2078+ {
2079+ assert(false);
2080+ }
2081+
2082+ template<int>
2083 void handle(ZORBA_TR1_NS::tuple<bint>& aTuple)
2084 {
2085 assert(false);
2086 }
2087
2088 template<int>
2089+ void handle(ZORBA_TR1_NS::tuple<bint, bint>& aTuple)
2090+ {
2091+ assert(false);
2092+ }
2093+
2094+ template<int>
2095 void handle(ZORBA_TR1_NS::tuple<bstring>& aTuple)
2096 {
2097 assert(false);
2098 }
2099+
2100 private:
2101- LockFreeConsumer<std::size_t>& theConsumer;
2102- LockFreeConsumer<bool>& theContinueQueue;
2103- DebuggerClient* theClient;
2104- CommandLine& theCommandLine;
2105- bool theQuit;
2106- bool theContinue;
2107- std::size_t theWaitFor;
2108+ LockFreeConsumer<std::size_t>& theConsumer;
2109+ LockFreeConsumer<bool>& theContinueQueue;
2110+ DebuggerClient* theClient;
2111+ CommandPrompt* theCommandLine;
2112+ bool theQuit;
2113+ bool theTerminated;
2114+ bool theContinue;
2115+ std::size_t theWaitFor;
2116+
2117 private:
2118 void getNextId(std::set<std::size_t>& aIdList);
2119 void addCommands();
2120- };
2121-
2122- template<>
2123- void CommandLineHandler::handle<Status> (ZORBA_TR1_NS::tuple<>& t);
2124-
2125- template<>
2126- void CommandLineHandler::handle<Quit> (ZORBA_TR1_NS::tuple<>& t);
2127-
2128- template<>
2129- void CommandLineHandler::handle<Run> (ZORBA_TR1_NS::tuple<> &t);
2130-
2131- template<>
2132- void CommandLineHandler::handle<StackDepth> (ZORBA_TR1_NS::tuple<>& t);
2133-
2134- template<>
2135- void CommandLineHandler::handle<BreakpointList> (ZORBA_TR1_NS::tuple<>& aTuple);
2136-
2137- template<>
2138- void CommandLineHandler::handle<BreakpointSet> (ZORBA_TR1_NS::tuple<bstring, bstring, bint> &t);
2139-
2140- template<>
2141- void CommandLineHandler::handle<BreakpointGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
2142-
2143- template<>
2144- void CommandLineHandler::handle<BreakpointDel>(ZORBA_TR1_NS::tuple<bint> &aTuple);
2145-
2146- template<>
2147- void CommandLineHandler::handle<StackGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
2148-
2149- template<>
2150- void CommandLineHandler::handle<ContextNames>(ZORBA_TR1_NS::tuple<> &aTuple);
2151-
2152- template<>
2153- void CommandLineHandler::handle<ContextGet>(ZORBA_TR1_NS::tuple<bint> &aTuple);
2154-
2155- template<>
2156- void CommandLineHandler::handle<Eval>(ZORBA_TR1_NS::tuple<bstring>& aTuple);
2157-
2158-}} // close namespaces zorba::debugclient
2159+};
2160+
2161+template<>
2162+void CommandLineHandler::handle<Status> (ZORBA_TR1_NS::tuple<>& t);
2163+
2164+template<>
2165+void CommandLineHandler::handle<Quit> (ZORBA_TR1_NS::tuple<>& t);
2166+
2167+template<>
2168+void CommandLineHandler::handle<Run> (ZORBA_TR1_NS::tuple<> &t);
2169+
2170+template<>
2171+void CommandLineHandler::handle<Stop> (ZORBA_TR1_NS::tuple<> &t);
2172+
2173+template<>
2174+void CommandLineHandler::handle<StackDepth> (ZORBA_TR1_NS::tuple<>& t);
2175+
2176+template<>
2177+void CommandLineHandler::handle<BreakpointList> (ZORBA_TR1_NS::tuple<>& aTuple);
2178+
2179+template<>
2180+void CommandLineHandler::handle<BreakpointSet> (ZORBA_TR1_NS::tuple<bstring, bstring, bint> &t);
2181+
2182+template<>
2183+void CommandLineHandler::handle<BreakpointGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
2184+
2185+template<>
2186+void CommandLineHandler::handle<BreakpointRemove>(ZORBA_TR1_NS::tuple<bint> &aTuple);
2187+
2188+template<>
2189+void CommandLineHandler::handle<StackGet> (ZORBA_TR1_NS::tuple<bint>& aTuple);
2190+
2191+template<>
2192+void CommandLineHandler::handle<ContextNames>(ZORBA_TR1_NS::tuple<> &aTuple);
2193+
2194+template<>
2195+void CommandLineHandler::handle<ContextGet>(ZORBA_TR1_NS::tuple<bint, bint> &aTuple);
2196+
2197+template<>
2198+void CommandLineHandler::handle<Source>(ZORBA_TR1_NS::tuple<bint, bint, bstring> &aTuple);
2199+
2200+template<>
2201+void CommandLineHandler::handle<Eval>(ZORBA_TR1_NS::tuple<bstring>& aTuple);
2202+
2203+template<>
2204+void CommandLineHandler::handle<StepIn> (ZORBA_TR1_NS::tuple<> &t);
2205+
2206+template<>
2207+void CommandLineHandler::handle<StepOut> (ZORBA_TR1_NS::tuple<> &t);
2208+
2209+template<>
2210+void CommandLineHandler::handle<StepOver> (ZORBA_TR1_NS::tuple<> &t);
2211+
2212+} // namespace zorba
2213+} // namespace debugger
2214+
2215+#endif // ZORBA_DEBUGGER_COMMAND_LINE_HANDLER_H
2216
2217=== added file 'bin/debugger/command_prompt.cpp'
2218--- bin/debugger/command_prompt.cpp 1970-01-01 00:00:00 +0000
2219+++ bin/debugger/command_prompt.cpp 2012-02-03 01:13:24 +0000
2220@@ -0,0 +1,287 @@
2221+/*
2222+ * Copyright 2006-2008 The FLWOR Foundation.
2223+ *
2224+ * Licensed under the Apache License, Version 2.0 (the "License");
2225+ * you may not use this file except in compliance with the License.
2226+ * You may obtain a copy of the License at
2227+ *
2228+ * http://www.apache.org/licenses/LICENSE-2.0
2229+ *
2230+ * Unless required by applicable law or agreed to in writing, software
2231+ * distributed under the License is distributed on an "AS IS" BASIS,
2232+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2233+ * See the License for the specific language governing permissions and
2234+ * limitations under the License.
2235+ */
2236+#include "command_prompt.h"
2237+
2238+#include <string>
2239+#include <vector>
2240+#include <map>
2241+#include <iostream>
2242+
2243+#include "command.h"
2244+
2245+
2246+namespace zorba { namespace debugger {
2247+
2248+#ifdef ZORBA_HAVE_LIBEDIT_H
2249+const char*
2250+prompt(EditLine* aEl) {
2251+ return "(xqdb) ";
2252+}
2253+#endif
2254+
2255+CommandPrompt::CommandPrompt()
2256+{
2257+#ifdef ZORBA_HAVE_LIBEDIT_H
2258+ theEditLine = el_init("xqdb", stdin, stdout, stderr);
2259+ theHistory = history_init();
2260+ HistEvent lHistoryEvent;
2261+ history(theHistory, &lHistoryEvent, H_SETSIZE, 100);
2262+
2263+ el_set(theEditLine, EL_PROMPT, prompt);
2264+
2265+ el_set(theEditLine, EL_HIST, history, theHistory);
2266+ el_set(theEditLine, EL_EDITOR, "emacs");
2267+#endif
2268+}
2269+
2270+CommandPrompt::~CommandPrompt()
2271+{
2272+#ifdef ZORBA_HAVE_LIBEDIT_H
2273+ history_end(theHistory);
2274+ el_end(theEditLine);
2275+#endif
2276+
2277+ std::map<std::string, UntypedCommand*>::iterator lIter;
2278+ for (lIter = theCommands.begin(); lIter != theCommands.end(); ++lIter) {
2279+ delete lIter->second;
2280+ }
2281+}
2282+
2283+void
2284+CommandPrompt::printHelp(UntypedCommand* aCommand)
2285+{
2286+ // if no command is provided, print all the available commands
2287+ if (!aCommand) {
2288+ std::cout << "Available commands:" << std::endl;
2289+
2290+ // print the names of all commands
2291+ std::map<std::string, UntypedCommand*>::iterator lIter = theCommands.begin();
2292+ while (lIter != theCommands.end()) {
2293+ std::cout << " " << (*lIter).first;
2294+ std::set<std::string> lAliases = (*lIter).second->getAliases();
2295+ std::set<std::string>::const_iterator lAliasIter = lAliases.begin();
2296+ while (lAliasIter != lAliases.end()) {
2297+ std::cout << ", " << *lAliasIter;
2298+ lAliasIter++;
2299+ }
2300+ std::cout << std::endl;
2301+ lIter++;
2302+ }
2303+
2304+ // some hints for detailed help
2305+ std::cout << std::endl;
2306+ std::cout << "Type help <command> to get more information about one command." << std::endl;
2307+ std::cout << std::endl;
2308+ } else {
2309+ // ok, so we have a command; then print the help
2310+ aCommand->printHelp();
2311+ }
2312+}
2313+
2314+void
2315+CommandPrompt::execute()
2316+{
2317+ bool lWithOutput = true;
2318+
2319+ for (;;) {
2320+#ifdef ZORBA_HAVE_LIBEDIT_H
2321+ const char* lBuf;
2322+ int lCharsRead = -1;
2323+ lBuf = el_gets(theEditLine, &lCharsRead);
2324+ std::string lCommandLine(lBuf, lCharsRead - 1);
2325+#else
2326+ if (lWithOutput) {
2327+ std::cout << "(xqdb) ";
2328+ }
2329+ lWithOutput = true;
2330+ std::string lCommandLine;
2331+ std::getline(std::cin, lCommandLine);
2332+ if (std::cin.fail()) {
2333+ lWithOutput = false;
2334+ std::cin.clear();
2335+ continue;
2336+ }
2337+#endif
2338+
2339+ std::vector<std::string> lArgs;
2340+
2341+ // split the command into arguments
2342+ parseLine(lCommandLine, lArgs);
2343+ std::string::size_type lSize = lArgs.size();
2344+
2345+ // empty command? do nothing!
2346+ if (lSize == 0) {
2347+ lArgs = theLastArgs;
2348+ if (lArgs.size() == 0) {
2349+ continue;
2350+ }
2351+ }
2352+#ifdef ZORBA_HAVE_LIBEDIT_H
2353+ else {
2354+ HistEvent lHistoryEvent;
2355+ history(theHistory, &lHistoryEvent, H_ENTER, lCommandLine.c_str());
2356+ }
2357+#endif
2358+ theLastArgs = lArgs;
2359+
2360+ UntypedCommand* lCommand = NULL;
2361+
2362+ // help is not a command but a hook here
2363+ if (lArgs.at(0) == "h" || lArgs.at(0) == "help") {
2364+ std::string lCmd = "";
2365+
2366+ // if the user needs the help for a specific command
2367+ if (lSize > 1) {
2368+ // do nothing if we don't have a command starting with this prefix?
2369+ // findCommand will print the appropriate errors
2370+ if (!findCommand(lArgs[1], lCommand)) {
2371+ continue;
2372+ }
2373+ }
2374+ printHelp(lCommand);
2375+ continue;
2376+ }
2377+ if (findCommand(lArgs[0], lCommand) && lCommand->execute(lArgs)) {
2378+ return;
2379+ }
2380+ continue;
2381+ }
2382+}
2383+
2384+CommandPrompt&
2385+CommandPrompt::operator<<(UntypedCommand *aCommand)
2386+{
2387+ theCommands.insert(std::make_pair(aCommand->getName(), aCommand));
2388+ return *this;
2389+}
2390+
2391+bool
2392+CommandPrompt::findCommand(const std::string& aPrefix, UntypedCommand*& aCommand)
2393+{
2394+ std::vector<UntypedCommand*> lFoundCommands;
2395+
2396+ std::map<std::string, UntypedCommand*>::iterator lIter = theCommands.begin();
2397+ while (lIter != theCommands.end()) {
2398+ // if a command name is equal with the prefix, this is the command we want
2399+ if ((*lIter).first == aPrefix) {
2400+ aCommand = (*lIter).second;
2401+ return true;
2402+ }
2403+
2404+ bool lIsCandidate = false;
2405+
2406+ // add this command to candidate commands if the prefix matches
2407+ if ((*lIter).first.find(aPrefix) == 0) {
2408+ lFoundCommands.push_back((*lIter).second);
2409+ lIsCandidate = true;
2410+ }
2411+
2412+ // now process the aliases
2413+ std::set<std::string> lAliases = (*lIter).second->getAliases();
2414+ std::set<std::string>::const_iterator lAliasIter = lAliases.begin();
2415+ while (lAliasIter != lAliases.end()) {
2416+ // if a command alias is equal with the prefix, this is the command we want
2417+ if (*lAliasIter == aPrefix) {
2418+ aCommand = (*lIter).second;
2419+ return true;
2420+ }
2421+
2422+ // add this command to candidate commands if the prefix matches one alias
2423+ // and if the command is not already added
2424+ if (!lIsCandidate && (*lAliasIter).find(aPrefix) == 0) {
2425+ lFoundCommands.push_back((*lIter).second);
2426+ break;
2427+ }
2428+ lAliasIter++;
2429+ }
2430+
2431+ lIter++;
2432+ }
2433+
2434+ if (lFoundCommands.empty()) {
2435+ std::cout << "Command not found: " << aPrefix << std::endl;
2436+ return false;
2437+ }
2438+
2439+ if (lFoundCommands.size() > 1) {
2440+ std::cout << "Ambigous command: " << aPrefix << std::endl;
2441+ // show all possible commands that start with this prefix
2442+ for (std::string::size_type i = 0; i < lFoundCommands.size(); i++) {
2443+ UntypedCommand* lCommand = lFoundCommands.at(i);
2444+
2445+ // commands
2446+ if (lCommand->getName().find(aPrefix) == 0) {
2447+ std::cout << " " << lCommand->getName() << std::endl;
2448+ }
2449+
2450+ // and aliases
2451+ std::set<std::string> lAliases = lCommand->getAliases();
2452+ std::set<std::string>::const_iterator lAliasIter = lAliases.begin();
2453+ while (lAliasIter != lAliases.end()) {
2454+ if ((*lAliasIter).find(aPrefix) == 0) {
2455+ std::cout << " " << *lAliasIter << std::endl;
2456+ }
2457+ lAliasIter++;
2458+ }
2459+ }
2460+ return false;
2461+ }
2462+
2463+ aCommand = lFoundCommands[0];
2464+ return true;
2465+}
2466+
2467+void
2468+CommandPrompt::parseLine(const std::string& aLine, std::vector<std::string>& aVector)
2469+{
2470+ std::string::size_type lBefore = 0;
2471+ std::string::size_type lPos = aLine.find_first_of(" \t", 0);
2472+
2473+ while (lPos != aLine.npos) {
2474+ std::string lSub = aLine.substr(lBefore, lPos - lBefore);
2475+
2476+ // if two consecutive spaces, you get an empty string here
2477+ if (lSub != "") {
2478+ if (lSub[0] == '"') {
2479+ std::string::size_type lBeforeCopy = lBefore;
2480+ do {
2481+ lBeforeCopy = aLine.find("\"", lBeforeCopy + 1);
2482+ } while (lPos != aLine.npos && aLine.size() > lPos + 1 && aLine[lPos + 1] == '\\');
2483+ lPos = lBeforeCopy;
2484+ lSub = aLine.substr(lBefore + 1, lPos - lBefore - 1);
2485+ }
2486+ aVector.push_back(lSub);
2487+ }
2488+
2489+ lBefore = lPos + 1;
2490+ lPos = aLine.find_first_of(" \t", lBefore);
2491+ }
2492+ std::string lSub = aLine.substr(lBefore);
2493+
2494+ // catching the case when the command ends with a space
2495+ if (lSub == "") {
2496+ return;
2497+ }
2498+
2499+ if (lSub[0] == '"') {
2500+ lPos = aLine.find("\"", lBefore + 1);
2501+ lSub = aLine.substr(lBefore + 1, lPos - lBefore - 1);
2502+ }
2503+ aVector.push_back(lSub);
2504+}
2505+
2506+} // namespace zorba
2507+} // namespace debugger
2508
2509=== added file 'bin/debugger/command_prompt.h'
2510--- bin/debugger/command_prompt.h 1970-01-01 00:00:00 +0000
2511+++ bin/debugger/command_prompt.h 2012-02-03 01:13:24 +0000
2512@@ -0,0 +1,72 @@
2513+/*
2514+ * Copyright 2006-2008 The FLWOR Foundation.
2515+ *
2516+ * Licensed under the Apache License, Version 2.0 (the "License");
2517+ * you may not use this file except in compliance with the License.
2518+ * You may obtain a copy of the License at
2519+ *
2520+ * http://www.apache.org/licenses/LICENSE-2.0
2521+ *
2522+ * Unless required by applicable law or agreed to in writing, software
2523+ * distributed under the License is distributed on an "AS IS" BASIS,
2524+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2525+ * See the License for the specific language governing permissions and
2526+ * limitations under the License.
2527+ */
2528+#pragma once
2529+#ifndef ZORBA_DEBUGGER_COMMAND_PROMPT_H
2530+#define ZORBA_DEBUGGER_COMMAND_PROMPT_H
2531+
2532+#include <string>
2533+#include <map>
2534+#include <vector>
2535+
2536+#include "config.h"
2537+
2538+#ifdef ZORBA_HAVE_LIBEDIT_H
2539+# include <histedit.h>
2540+#endif
2541+
2542+
2543+namespace zorba { namespace debugger {
2544+
2545+class UntypedCommand;
2546+
2547+class CommandPrompt
2548+{
2549+ public:
2550+ CommandPrompt();
2551+ ~CommandPrompt();
2552+
2553+ public:
2554+
2555+ void execute();
2556+
2557+ CommandPrompt& operator<< (UntypedCommand* command);
2558+
2559+ private:
2560+
2561+ void
2562+ printHelp(UntypedCommand* command);
2563+
2564+ bool
2565+ findCommand(const std::string& prefix, UntypedCommand*& command);
2566+
2567+ void
2568+ parseLine(const std::string& line, std::vector<std::string>& vector);
2569+
2570+ private:
2571+ std::map<std::string, UntypedCommand*> theCommands;
2572+ std::vector<std::string> theLastArgs;
2573+
2574+#ifdef ZORBA_HAVE_LIBEDIT_H
2575+ EditLine* theEditLine;
2576+ History* theHistory;
2577+#endif
2578+};
2579+
2580+
2581+} // namespace zorba
2582+} // namespace debugger
2583+
2584+#endif // ZORBA_DEBUGGER_COMMAND_PROMPT_H
2585
2586=== added file 'bin/debugger/config.h.cmake'
2587--- bin/debugger/config.h.cmake 1970-01-01 00:00:00 +0000
2588+++ bin/debugger/config.h.cmake 2012-02-03 01:13:24 +0000
2589@@ -0,0 +1,24 @@
2590+/*
2591+ * Copyright 2006-2008 The FLWOR Foundation.
2592+ *
2593+ * Licensed under the Apache License, Version 2.0 (the "License");
2594+ * you may not use this file except in compliance with the License.
2595+ * You may obtain a copy of the License at
2596+ *
2597+ * http://www.apache.org/licenses/LICENSE-2.0
2598+ *
2599+ * Unless required by applicable law or agreed to in writing, software
2600+ * distributed under the License is distributed on an "AS IS" BASIS,
2601+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2602+ * See the License for the specific language governing permissions and
2603+ * limitations under the License.
2604+ */
2605+
2606+// This header is configured by Zorba's build process -- DO NOT EDIT!
2607+
2608+#ifndef ZORBA_DEBUGGER_CONFIG_H
2609+#define ZORBA_DEBUGGER_CONFIG_H
2610+
2611+#cmakedefine ZORBA_HAVE_LIBEDIT_H
2612+
2613+#endif /* ZORBA_DEBUGGER_CONFIG_H */
2614
2615=== modified file 'bin/debugger/event_handler.cpp'
2616--- bin/debug_client/event_handler.cpp 2011-07-01 01:53:24 +0000
2617+++ bin/debugger/event_handler.cpp 2012-02-03 01:13:24 +0000
2618@@ -13,88 +13,93 @@
2619 * See the License for the specific language governing permissions and
2620 * limitations under the License.
2621 */
2622+
2623+#include "event_handler.h"
2624+
2625+#include <sstream>
2626+
2627 #include <zorba/zorba.h>
2628 #include <zorba/store_manager.h>
2629 #include <zorba/iterator.h>
2630-#include <sstream>
2631-#include "debug_client/event_handler.h"
2632
2633-namespace zorba { namespace debugclient {
2634+namespace zorba { namespace debugger {
2635
2636- EventHandler::EventHandler(LockFreeProducer<std::size_t>& aQueue, LockFreeProducer<bool>& aContProducer)
2637+EventHandler::EventHandler(LockFreeProducer<std::size_t>& aQueue, LockFreeProducer<bool>& aContProducer)
2638 : theIdQueue(aQueue), theContinueProducer(aContProducer),
2639 theStore(StoreManager::getStore()),
2640 theZorbaInstance(Zorba::getInstance(theStore)),
2641 theStaticContext(theZorbaInstance->createStaticContext())
2642-
2643- {
2644- try {
2645- Zorba_CompilerHints_t lHints;
2646- lHints.opt_level = ZORBA_OPT_LEVEL_O1;
2647- std::auto_ptr<std::istream> stream(getCurrentDirectory());
2648- zorba::String query;
2649- char buffer[1024];
2650- std::string::size_type s;
2651- while ((s = stream->readsome(buffer, 1024))) {
2652- query.append(std::string(buffer, s));
2653- }
2654- theStaticContext->loadProlog(query, lHints);
2655- } catch (zorba::ZorbaException& e) {
2656- std::cerr << "Exception: I was not able to load the query file:" << std::endl;
2657- std::cerr << e.what() << std::endl;
2658- throw;
2659- }
2660- }
2661-
2662- EventHandler::~EventHandler()
2663- {
2664- theStaticContext = 0;
2665- theZorbaInstance->shutdown();
2666- StoreManager::shutdownStore(theStore);
2667- }
2668-
2669- void EventHandler::parseMessage(const std::string &aMessage)
2670- {
2671- try {
2672- zorba::String queryString = "local:main(";
2673- queryString += aMessage + ")";
2674- XQuery_t query = theZorbaInstance->compileQuery(queryString, theStaticContext);
2675- Iterator_t lIter = query->iterator();
2676- Item item;
2677- lIter->open();
2678- bool doContinue = false;
2679- lIter->next(item);
2680- {
2681- const std::string& continueString = item.getStringValue().str();
2682- if (continueString == "true") {
2683- doContinue = true;
2684- } else if (continueString == "false") {
2685- doContinue = false;
2686- } else {
2687- std::stringstream stream(continueString);
2688- stream >> doContinue;
2689- }
2690- }
2691- lIter->next(item);
2692- std::size_t lId;
2693- {
2694- std::stringstream stream(item.getStringValue().c_str());
2695- stream >> lId;
2696- }
2697- lIter->next(item);
2698- std::cout << item.getStringValue() << std::endl;
2699- theContinueProducer.produce(doContinue);
2700- theIdQueue.produce(lId);
2701- } catch (ZorbaException& e) {
2702- std::cerr << "FATAL: could not execute query: " << std::endl;
2703- std::cerr << e << std::endl;
2704- std::cerr << "This is a bug, please report to zorba-users@lists.sourceforge.net" << std::endl;
2705- theContinueProducer.produce(false);
2706- }
2707- }
2708-
2709- void EventHandler::error(unsigned int errcode, const std::string &msg)
2710- {
2711- std::cerr << "Error " << errcode << ": " << msg << std::endl;
2712- }
2713-}}
2714+{
2715+}
2716+
2717+EventHandler::~EventHandler()
2718+{
2719+ theStaticContext = 0;
2720+ theZorbaInstance->shutdown();
2721+ StoreManager::shutdownStore(theStore);
2722+}
2723+
2724+void
2725+EventHandler::init()
2726+{
2727+ try {
2728+ Zorba_CompilerHints_t lHints;
2729+ lHints.opt_level = ZORBA_OPT_LEVEL_O1;
2730+ zorba::String lProlog("import module namespace dmh = 'http://www.zorba-xquery.com/modules/debugger/dbgp-message-handler';");
2731+ theStaticContext->loadProlog(lProlog, lHints);
2732+ } catch (zorba::ZorbaException& e) {
2733+ std::cerr << "Exception: I was not able to load the query file:" << std::endl;
2734+ std::cerr << e.what() << std::endl;
2735+ throw;
2736+ }
2737+}
2738+
2739+void
2740+EventHandler::parseMessage(const std::string &aMessage)
2741+{
2742+ try {
2743+#ifndef NDEBUG
2744+ // uncomment this to see the raw messages received by the event handler
2745+ //std::cout << "Processing response: " << aMessage << std::endl;
2746+#endif
2747+ // the query to process the response
2748+ std::stringstream lQueryStream;
2749+ lQueryStream << "dmh:process(" << aMessage << ")";
2750+ XQuery_t lQuery = theZorbaInstance->compileQuery(lQueryStream.str(), theStaticContext);
2751+
2752+ // get the query result sequrence:
2753+ // 1. a message
2754+ Iterator_t lIter = lQuery->iterator();
2755+ Item lItem;
2756+ lIter->open();
2757+ lIter->next(lItem);
2758+ std::size_t lId;
2759+ std::stringstream lStream(lItem.getStringValue().c_str());
2760+ lStream >> lId;
2761+
2762+ // 2. an "idle" flag (to disable quit confirmation)
2763+ bool lCanQuit = false;
2764+ if (lIter->next(lItem)) {
2765+ String lMessage = lItem.getStringValue();
2766+ lCanQuit = lMessage == "idle";
2767+ std::cout << std::endl << lItem.getStringValue() << std::endl;
2768+ }
2769+ theContinueProducer.produce(lCanQuit);
2770+
2771+ // go and solve the event with this id
2772+ theIdQueue.produce(lId);
2773+ } catch (ZorbaException& e) {
2774+ std::cerr << "FATAL: could not execute query: " << std::endl;
2775+ std::cerr << e << std::endl;
2776+ std::cerr << "This is a bug, please report it at http://bugs.launchpad.net/zorba" << std::endl;
2777+ }
2778+}
2779+
2780+void
2781+EventHandler::error(unsigned int errcode, const std::string &msg)
2782+{
2783+ std::cerr << "Error " << errcode << ": " << msg << std::endl;
2784+}
2785+
2786+} // namespace zorba
2787+} // namespace debugger
2788
2789=== modified file 'bin/debugger/event_handler.h'
2790--- bin/debug_client/event_handler.h 2011-07-01 01:53:24 +0000
2791+++ bin/debugger/event_handler.h 2012-02-03 01:13:24 +0000
2792@@ -14,33 +14,46 @@
2793 * limitations under the License.
2794 */
2795 #pragma once
2796+#ifndef ZORBA_DEBUGGER_EVENT_HANDLER_H
2797+#define ZORBA_DEBUGGER_EVENT_HANDLER_H
2798+
2799 #include <string>
2800 #include <iostream>
2801+
2802 #include <zorba/debugger_event_handler.h>
2803 #include <zorba/static_context.h>
2804+
2805 #include "lock_free_queue.h"
2806
2807-namespace zorba {
2808- class Zorba;
2809-}
2810-
2811-namespace zorba { namespace debugclient {
2812-
2813- class EventHandler : public zorba::DebuggerEventHandler
2814- {
2815+
2816+namespace zorba { namespace debugger {
2817+
2818+class EventHandler : public zorba::DebuggerEventHandler
2819+{
2820 public:
2821- EventHandler(LockFreeProducer<std::size_t>& aQueue, LockFreeProducer<bool>& aContQueue);
2822+ EventHandler(
2823+ LockFreeProducer<std::size_t>& aQueue,
2824+ LockFreeProducer<bool>& aContQueue);
2825+
2826 ~EventHandler();
2827+
2828 public:
2829 virtual void parseMessage(const std::string& aMessage);
2830+
2831 virtual void error(unsigned int errcode, const std::string& msg);
2832+
2833+ virtual void init();
2834+
2835 private:
2836- static std::istream* getCurrentDirectory();
2837 LockFreeProducer<std::size_t>& theIdQueue;
2838 LockFreeProducer<bool>& theContinueProducer;
2839 void* theStore;
2840 Zorba* theZorbaInstance;
2841 StaticContext_t theStaticContext;
2842- };
2843+
2844+};
2845
2846-}} // end of namespace zorba::debugclient
2847+} // namespace zorba
2848+} // namespace debugger
2849+
2850+#endif // ZORBA_DEBUGGER_EVENT_HANDLER_H
2851
2852=== modified file 'bin/debugger/lock_free_queue.h'
2853--- bin/debug_client/lock_free_queue.h 2011-07-01 01:53:24 +0000
2854+++ bin/debugger/lock_free_queue.h 2012-02-03 01:13:24 +0000
2855@@ -14,10 +14,14 @@
2856 * limitations under the License.
2857 */
2858 #pragma once
2859+#ifndef ZORBA_DEBUGGER_LOCK_FREE_QUEUE_H
2860+#define ZORBA_DEBUGGER_LOCK_FREE_QUEUE_H
2861+
2862 #include <iostream>
2863 #include <list>
2864
2865-namespace zorba { namespace debugclient {
2866+
2867+namespace zorba { namespace debugger {
2868
2869 template<typename T>
2870 class LockFreeProducer
2871@@ -80,4 +84,8 @@
2872 }
2873 return false;
2874 }
2875-}} // namespace zorba::debugclient
2876+
2877+} // namespace zorba
2878+} // namespace debugger
2879+
2880+#endif // ZORBA_DEBUGGER_LOCK_FREE_QUEUE_H
2881
2882=== modified file 'bin/debugger/main.cpp'
2883--- bin/debug_client/main.cpp 2011-07-01 01:53:24 +0000
2884+++ bin/debugger/main.cpp 2012-02-03 01:13:24 +0000
2885@@ -13,12 +13,286 @@
2886 * See the License for the specific language governing permissions and
2887 * limitations under the License.
2888 */
2889+
2890+#ifdef WIN32
2891+# include <windows.h>
2892+# include <string.h>
2893+# include <strsafe.h>
2894+#endif
2895+
2896+#include <vector>
2897+
2898 #include <zorba/config.h>
2899-#include "debug_command.h"
2900-#include "command_line_handler.h"
2901+
2902+#include "xqdb_client.h"
2903+#include "process_listener.h"
2904+
2905
2906 using namespace zorba;
2907-using namespace zorba::debugclient;
2908+using namespace zorba::debugger;
2909+
2910+
2911+std::auto_ptr<XqdbClient> theClient;
2912+
2913+// this will make sure the xqdb process will not quit when Ctrl-C is pressed
2914+#ifdef WIN32
2915+BOOL WINAPI
2916+ctrlC_Handler(DWORD aCtrlType)
2917+{
2918+ if (CTRL_C_EVENT == aCtrlType) {
2919+ return true;
2920+ }
2921+ return false;
2922+}
2923+#else
2924+void
2925+ctrlC_Handler(int lParam)
2926+{
2927+ // an empty sugnal handler on Linux should do the job
2928+}
2929+#endif
2930+
2931+
2932+// this handler function is passed the the zorba process listener and will
2933+// the client if the zorba process terminates
2934+void
2935+onExitProcess(ExitCode aExitCode) {
2936+ std::cout << std::endl << "Terminating debugger client." << std::endl;
2937+
2938+#ifndef WIN32
2939+ XqdbClient* lClient = theClient.release();
2940+ if (lClient) {
2941+ delete lClient;
2942+ }
2943+#endif
2944+
2945+ exit(aExitCode);
2946+}
2947+
2948+
2949+int
2950+startZorba(std::string& aExec, std::vector<std::string>& aArgs, std::auto_ptr<ProcessListener>& aProcessListener)
2951+{
2952+#ifdef WIN32
2953+ // **************************
2954+ // start a process on Windows
2955+
2956+ DWORD iReturnVal = 0;
2957+
2958+ std::wstring lExec;
2959+ std::wstring lArgs;
2960+
2961+ lExec.assign(aExec.begin(), aExec.end());
2962+
2963+ // the executable must be the first in the list of arguments
2964+ lArgs.append(L"\"");
2965+ lArgs.append(lExec);
2966+ lArgs.append(L"\"");
2967+
2968+ for (std::vector<std::string>::size_type j = 0; j < aArgs.size(); j++) {
2969+ std::string lArg(aArgs.at(j));
2970+ std::wstring lArgW;
2971+ lArgW.assign(lArg.begin(), lArg.end());
2972+ lArgs.append(L" ");
2973+ lArgs.append(lArgW);
2974+ }
2975+
2976+ // CreateProcessW can modify Parameters thus we allocate needed memory
2977+ wchar_t * pwszParam = new wchar_t[lArgs.size() + 1];
2978+ if (pwszParam == 0) {
2979+ return 1;
2980+ }
2981+ const wchar_t* pchrTemp = lArgs.c_str();
2982+ wcscpy_s(pwszParam, lArgs.size() + 1, pchrTemp);
2983+
2984+ // CreateProcess API initialization
2985+ STARTUPINFOW siStartupInfo;
2986+ PROCESS_INFORMATION piProcessInfo;
2987+ memset(&siStartupInfo, 0, sizeof(siStartupInfo));
2988+ memset(&piProcessInfo, 0, sizeof(piProcessInfo));
2989+ siStartupInfo.cb = sizeof(siStartupInfo);
2990+
2991+ BOOL lResult = CreateProcessW(
2992+ const_cast<LPCWSTR>(lExec.c_str()),
2993+ pwszParam, 0, 0, false,
2994+ CREATE_DEFAULT_ERROR_MODE, 0, 0,
2995+ &siStartupInfo, &piProcessInfo);
2996+
2997+ if (lResult) {
2998+ // Watch the process
2999+ aProcessListener.reset(new ProcessListener(piProcessInfo.dwProcessId, &onExitProcess));
3000+ }
3001+ else {
3002+ // CreateProcess failed
3003+ iReturnVal = GetLastError();
3004+ LPVOID lpMsgBuf;
3005+ LPVOID lpDisplayBuf;
3006+
3007+ FormatMessage(
3008+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
3009+ NULL,
3010+ iReturnVal,
3011+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
3012+ (LPTSTR) &lpMsgBuf,
3013+ 0, NULL);
3014+
3015+ // Display the error message and exit the process
3016+
3017+ lpDisplayBuf = (LPVOID)LocalAlloc(
3018+ LMEM_ZEROINIT,
3019+ (lstrlen((LPCTSTR)lpMsgBuf) + 40) * sizeof(TCHAR));
3020+
3021+ StringCchPrintf(
3022+ (LPTSTR)lpDisplayBuf,
3023+ LocalSize(lpDisplayBuf) / sizeof(TCHAR),
3024+ TEXT("Error (%d) when starting zorba: %s"),
3025+ iReturnVal,
3026+ lpMsgBuf);
3027+
3028+ std::wstring lErrorW((wchar_t*)lpDisplayBuf);
3029+ std::string lError;
3030+ lError.assign(lErrorW.begin(), lErrorW.end());
3031+ std::cout << lError << std::endl;
3032+
3033+ LocalFree(lpMsgBuf);
3034+ LocalFree(lpDisplayBuf);
3035+ }
3036+
3037+ // Free memory
3038+ delete[]pwszParam;
3039+ pwszParam = 0;
3040+
3041+ // Release handles
3042+ CloseHandle(piProcessInfo.hProcess);
3043+ CloseHandle(piProcessInfo.hThread);
3044+
3045+ return iReturnVal;
3046+
3047+#else
3048+ // ************************
3049+ // start a process on Linux
3050+
3051+ pid_t pID = fork();
3052+ if (pID == 0) {
3053+ // Code only executed by child process
3054+ std::stringstream lCommand;
3055+ lCommand << aExec;
3056+ for (std::vector<std::string>::size_type j = 0; j < aArgs.size(); j++) {
3057+ lCommand << " " << aArgs.at(j);
3058+ }
3059+
3060+ int lRes = system(lCommand.str().c_str());
3061+ exit(lRes);
3062+ }
3063+ else {
3064+ // Code only executed by parent process
3065+ if (pID < 0) {
3066+ std::cerr << "Failed to fork Zorba" << std::endl;
3067+ return pID;
3068+ }
3069+
3070+ // Watch the process
3071+ aProcessListener.reset(new ProcessListener(pID, &onExitProcess));
3072+
3073+ return 0;
3074+ }
3075+#endif
3076+}
3077+
3078+void printUsage(std::string& aProgram)
3079+{
3080+ std::cerr << "Usage:" << std::endl
3081+ << " " << aProgram << " <zorba_arguments>" << std::endl
3082+ << " this will start a debugger command line and a zorba process with the given arguments" << std::endl;
3083+}
3084+
3085+bool
3086+processArguments(
3087+ int argc,
3088+ char* argv[],
3089+ std::string& aProgram,
3090+ bool& aStandalone,
3091+ std::string& aZorba,
3092+ unsigned int& aPort,
3093+ std::vector<std::string>& aZorbaArgs)
3094+{
3095+ aPort = 28028;
3096+
3097+ // find the path to Zorba and this executable name
3098+ aProgram = argv[0];
3099+
3100+#ifdef WIN32
3101+ char lSep = '\\';
3102+#else
3103+ char lSep = '/';
3104+#endif
3105+ std::string::size_type lPos = aProgram.find_last_of(lSep);
3106+
3107+ std::stringstream lZs;
3108+
3109+ if (lPos == aProgram.npos) {
3110+ lZs << "." << lSep;
3111+ } else {
3112+ lZs << aProgram.substr(0, lPos + 1);
3113+ aProgram = aProgram.substr(lPos + 1);
3114+ }
3115+ lZs << "zorba";
3116+#ifdef WIN32
3117+ lZs << ".exe";
3118+#endif
3119+ aZorba = lZs.str();
3120+
3121+
3122+ bool lHasFileArg = false;
3123+ bool lHasQueryArg = false;
3124+ bool lHasQueryVal = false;
3125+
3126+ // find if the user asked for help or specified a specific port
3127+ for (int i = 1; i < argc; i++) {
3128+ std::string lArg = argv[i];
3129+ if (lArg == "-h" || lArg == "--help") {
3130+ return false;
3131+ }
3132+ else if (lArg == "-p" || lArg == "--debug-port") {
3133+ // if there is one more argument
3134+ if (i < argc - 1) {
3135+ // get the port value
3136+ int lPort;
3137+ std::stringstream lStream(argv[i + 1]);
3138+ lStream >> lPort;
3139+ if (!lStream.fail()) {
3140+ aPort = lPort;
3141+ }
3142+ }
3143+ }
3144+ else if (lArg == "-f") {
3145+ lHasFileArg = true;
3146+ }
3147+ else if (lArg == "-q") {
3148+ lHasQueryArg = true;
3149+ if (++i < argc) {
3150+ lHasQueryVal = true;
3151+ }
3152+ }
3153+ }
3154+
3155+ if (!lHasFileArg || !lHasQueryArg || !lHasQueryVal) {
3156+ std::cout << "Not enough arguments to start Zorba." << std::endl;
3157+ std::cout << "Running the standalone XQuery debugger client on port: " << aPort << std::endl;
3158+ return true;
3159+ }
3160+
3161+ // zorba will need the -d flag
3162+ aZorbaArgs.push_back("-d");
3163+
3164+ // gather all arguments (excepting the program name)
3165+ for (int i = 1; i < argc; i++) {
3166+ aZorbaArgs.push_back(argv[i]);
3167+ }
3168+
3169+ aStandalone = false;
3170+ return true;
3171+}
3172
3173 #ifndef _WIN32_WCE
3174 int
3175@@ -28,24 +302,72 @@
3176 _tmain(int argc, _TCHAR* argv[])
3177 #endif
3178 {
3179- int port = 28028;
3180- if (argv[1]) {
3181- std::stringstream stream(argv[1]);
3182- stream >> port;
3183- if (stream.fail() || argv[2]) {
3184- std::cerr << "Unknown argument. USAGE: " << argv[0] << " [PORT]" << std::endl;
3185- return 2;
3186+#ifdef WIN32
3187+ SetConsoleCtrlHandler(ctrlC_Handler, TRUE);
3188+#else
3189+ signal(SIGINT, ctrlC_Handler);
3190+#endif
3191+
3192+ // **************************************************************************
3193+ // processing arguments
3194+
3195+ std::string lProgram, lZorbaExec;
3196+ unsigned int lPort = 28028;
3197+ std::vector<std::string> lZorbaArgs;
3198+
3199+ bool lStandalone = true;
3200+ if (!processArguments(argc, argv, lProgram, lStandalone, lZorbaExec, lPort, lZorbaArgs)) {
3201+ printUsage(lProgram);
3202+ return 1;
3203+ }
3204+
3205+#ifndef NDEBUG
3206+ // **************************************************************************
3207+ // debug reporting
3208+
3209+ if (!lStandalone) {
3210+ std::cout << "Communication port: " << lPort << std::endl;
3211+ std::cout << "Zorba executable: " << lZorbaExec << std::endl;
3212+ std::cout << "Zorba arguments: ";
3213+ for (std::vector<std::string>::size_type j = 0; j < lZorbaArgs.size(); j++) {
3214+ std::cout << lZorbaArgs.at(j) << " ";
3215 }
3216+ std::cout << std::endl;
3217 }
3218+#endif
3219+
3220 try {
3221- LockFreeQueue<std::size_t> lQueue;
3222- LockFreeQueue<bool> lContEvent;
3223- EventHandler lHandler(lQueue, lContEvent);
3224- CommandLine cli;
3225- CommandLineHandler handler(port, lQueue, lContEvent, lHandler, cli);
3226- handler.execute();
3227+ // **************************************************************************
3228+ // start a zorba
3229+
3230+ // This is a process listener used to watch the Zorba process termination.
3231+ std::auto_ptr<ProcessListener> lProcessListener;
3232+
3233+ if (!lStandalone) {
3234+ int lResult = startZorba(lZorbaExec, lZorbaArgs, lProcessListener);
3235+ if (lResult) {
3236+ return lResult;
3237+ }
3238+ } else {
3239+ std::cout << "Listening for an incomming Zorba connection on port " << lPort << "..." << std::endl;
3240+ }
3241+
3242+ // **************************************************************************
3243+ // start the debugger command line
3244+
3245+ theClient.reset(new XqdbClient(lPort));
3246+ theClient->start();
3247+
3248 } catch (...) {
3249- return 4;
3250- }
3251+ return -1;
3252+ }
3253+
3254+#ifndef WIN32
3255+ XqdbClient* lClient = theClient.release();
3256+ if (lClient) {
3257+ delete lClient;
3258+ }
3259+#endif
3260+
3261 return 0;
3262 }
3263
3264=== added file 'bin/debugger/process_listener.cpp'
3265--- bin/debugger/process_listener.cpp 1970-01-01 00:00:00 +0000
3266+++ bin/debugger/process_listener.cpp 2012-02-03 01:13:24 +0000
3267@@ -0,0 +1,105 @@
3268+/*
3269+ * Copyright 2006-2008 The FLWOR Foundation.
3270+ *
3271+ * Licensed under the Apache License, Version 2.0 (the "License");
3272+ * you may not use this file except in compliance with the License.
3273+ * You may obtain a copy of the License at
3274+ *
3275+ * http://www.apache.org/licenses/LICENSE-2.0
3276+ *
3277+ * Unless required by applicable law or agreed to in writing, software
3278+ * distributed under the License is distributed on an "AS IS" BASIS,
3279+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3280+ * See the License for the specific language governing permissions and
3281+ * limitations under the License.
3282+ */
3283+
3284+#include "process_listener.h"
3285+
3286+#include <iostream>
3287+
3288+#ifdef ZORBA_HAVE_PTHREAD_H
3289+# include <cassert>
3290+#endif
3291+
3292+
3293+namespace zorba { namespace debugger {
3294+
3295+ProcessListener::ProcessListener(ProcessId aProcessID, ExitCallbackType aCallback)
3296+ : theProcessID(aProcessID), theCallback(aCallback)
3297+{
3298+#ifdef WIN32
3299+ theThread = CreateThread(NULL, 0, &run, (void*) this, 0, &theThreadId);
3300+#else
3301+ if (pthread_create(&theThread, NULL, &run, (void*) this)) {
3302+ assert(false);
3303+ }
3304+#endif
3305+}
3306+
3307+ProcessListener::~ProcessListener()
3308+{
3309+}
3310+
3311+ProcessId
3312+ProcessListener::getProcessID()
3313+{
3314+ return theProcessID;
3315+}
3316+
3317+ExitCallbackType
3318+ProcessListener::getCallback()
3319+{
3320+ return theCallback;
3321+}
3322+
3323+
3324+ZORBA_THREAD_RETURN
3325+ProcessListener::run(void* params)
3326+{
3327+ ProcessListener* lThis = static_cast<ProcessListener*>(params);
3328+ ExitCode lExitCode = -1;
3329+ ProcessId lPid = lThis->getProcessID();
3330+
3331+#ifdef WIN32
3332+ HANDLE lProcessHandle = OpenProcess(SYNCHRONIZE, false, lPid);
3333+ if (lProcessHandle != NULL) {
3334+ // wait for the process to exit
3335+ DWORD lResult = WaitForSingleObject(lProcessHandle, INFINITE);
3336+
3337+ // find out the process exit code if possible
3338+ if (!GetExitCodeProcess(lProcessHandle, &lExitCode)) {
3339+ lExitCode = -1;
3340+ }
3341+ DWORD dw = GetLastError();
3342+
3343+ // wait a little for zorba to dump the garbage
3344+ Sleep(1000);
3345+ }
3346+#else
3347+ int lChildExitStatus;
3348+
3349+ // wait for the process to exit
3350+ waitpid(lPid, &lChildExitStatus, 0);
3351+
3352+ // find out the process exit code if possible
3353+ if (WIFEXITED(lChildExitStatus)) {
3354+ lExitCode = WEXITSTATUS(lChildExitStatus);
3355+ }
3356+
3357+ // wait a little for zorba to dump the garbage
3358+ sleep(1);
3359+#endif
3360+
3361+ // and call the callback when this happened
3362+ ExitCallbackType lCallback = lThis->getCallback();
3363+ lCallback(lExitCode);
3364+
3365+ for (int i = 0; i < 10; i++) {
3366+ std::cout << i << std::endl;
3367+ }
3368+ return NULL;
3369+}
3370+
3371+} // namespace zorba
3372+} // namespace debugger
3373
3374=== added file 'bin/debugger/process_listener.h'
3375--- bin/debugger/process_listener.h 1970-01-01 00:00:00 +0000
3376+++ bin/debugger/process_listener.h 2012-02-03 01:13:24 +0000
3377@@ -0,0 +1,75 @@
3378+/*
3379+ * Copyright 2006-2008 The FLWOR Foundation.
3380+ *
3381+ * Licensed under the Apache License, Version 2.0 (the "License");
3382+ * you may not use this file except in compliance with the License.
3383+ * You may obtain a copy of the License at
3384+ *
3385+ * http://www.apache.org/licenses/LICENSE-2.0
3386+ *
3387+ * Unless required by applicable law or agreed to in writing, software
3388+ * distributed under the License is distributed on an "AS IS" BASIS,
3389+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3390+ * See the License for the specific language governing permissions and
3391+ * limitations under the License.
3392+ */
3393+#pragma once
3394+#ifndef ZORBA_DEBUGGER_PROCESS_LISTENER_H
3395+#define ZORBA_DEBUGGER_PROCESS_LISTENER_H
3396+
3397+#include <zorba/config.h>
3398+
3399+#ifdef ZORBA_HAVE_PTHREAD_H
3400+# include <pthread.h>
3401+# include <sys/wait.h>
3402+ typedef pthread_t ThreadId;
3403+ typedef pid_t ProcessId;
3404+ typedef int ExitCode;
3405+# define ZORBA_THREAD_RETURN void *
3406+#else
3407+# include <windows.h>
3408+ typedef DWORD ThreadId;
3409+ typedef DWORD ProcessId;
3410+ typedef DWORD ExitCode;
3411+# define ZORBA_THREAD_RETURN DWORD WINAPI
3412+#endif
3413+
3414+typedef void (*ExitCallbackType)(ExitCode);
3415+
3416+
3417+namespace zorba { namespace debugger {
3418+
3419+class ProcessListener
3420+{
3421+ public:
3422+ ProcessListener(ProcessId processID, ExitCallbackType callback);
3423+
3424+ ~ProcessListener();
3425+
3426+ ProcessId
3427+ getProcessID();
3428+
3429+ ExitCallbackType
3430+ getCallback();
3431+
3432+ private:
3433+
3434+ static ZORBA_THREAD_RETURN run(void* params);
3435+
3436+ private:
3437+
3438+#ifdef ZORBA_HAVE_PTHREAD_H
3439+ pthread_t theThread;
3440+#else
3441+ ThreadId theThreadId;
3442+ HANDLE theThread;
3443+#endif
3444+
3445+ ProcessId theProcessID;
3446+ ExitCallbackType theCallback;
3447+};
3448+
3449+} // namespace zorba
3450+} // namespace debugger
3451+
3452+#endif // ZORBA_DEBUGGER_PROCESS_LISTENER_H
3453
3454=== modified file 'bin/debugger/tuple.h'
3455--- bin/debug_client/tuple.h 2011-07-04 08:05:46 +0000
3456+++ bin/debugger/tuple.h 2012-02-03 01:13:24 +0000
3457@@ -14,9 +14,15 @@
3458 * limitations under the License.
3459 */
3460 #pragma once
3461+#ifndef ZORBA_DEBUGGER_TUPLE_H
3462+#define ZORBA_DEBUGGER_TUPLE_H
3463+
3464 #include <zorba/config.h>
3465+
3466 #if ZORBA_TR1_IN_TR1_SUBDIRECTORY
3467 # include <tr1/tuple>
3468 #else
3469 # include <tuple>
3470 #endif
3471+
3472+#endif // ZORBA_DEBUGGER_TUPLE_H
3473
3474=== added file 'bin/debugger/xqdb_client.cpp'
3475--- bin/debugger/xqdb_client.cpp 1970-01-01 00:00:00 +0000
3476+++ bin/debugger/xqdb_client.cpp 2012-02-03 01:13:24 +0000
3477@@ -0,0 +1,63 @@
3478+/*
3479+ * Copyright 2006-2008 The FLWOR Foundation.
3480+ *
3481+ * Licensed under the Apache License, Version 2.0 (the "License");
3482+ * you may not use this file except in compliance with the License.
3483+ * You may obtain a copy of the License at
3484+ *
3485+ * http://www.apache.org/licenses/LICENSE-2.0
3486+ *
3487+ * Unless required by applicable law or agreed to in writing, software
3488+ * distributed under the License is distributed on an "AS IS" BASIS,
3489+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3490+ * See the License for the specific language governing permissions and
3491+ * limitations under the License.
3492+ */
3493+
3494+#include "xqdb_client.h"
3495+
3496+#include <iostream>
3497+
3498+#ifdef ZORBA_HAVE_PTHREAD_H
3499+# include <cassert>
3500+#endif
3501+
3502+
3503+namespace zorba { namespace debugger {
3504+
3505+XqdbClient::XqdbClient(unsigned int aPort)
3506+{
3507+ theIdQueue = new LockFreeQueue<std::size_t>();
3508+ theQuitQueue = new LockFreeQueue<bool>();
3509+ theEventHandler = new EventHandler(*theIdQueue, *theQuitQueue);
3510+ theEventHandler->init();
3511+
3512+ theCommandPrompt = new CommandPrompt();
3513+ theCommandLineHandler = new CommandLineHandler(aPort, *theIdQueue, *theQuitQueue, theEventHandler, theCommandPrompt);
3514+}
3515+
3516+XqdbClient::~XqdbClient()
3517+{
3518+ if (theCommandLineHandler) {
3519+ delete theCommandLineHandler;
3520+ }
3521+ if (theCommandPrompt) {
3522+ delete theCommandPrompt;
3523+ }
3524+ if (theEventHandler) {
3525+ delete theEventHandler;
3526+ }
3527+
3528+ delete theIdQueue;
3529+ delete theQuitQueue;
3530+}
3531+
3532+void
3533+XqdbClient::start()
3534+{
3535+ theCommandLineHandler->execute();
3536+}
3537+
3538+
3539+} // namespace zorba
3540+} // namespace debugger
3541
3542=== added file 'bin/debugger/xqdb_client.h'
3543--- bin/debugger/xqdb_client.h 1970-01-01 00:00:00 +0000
3544+++ bin/debugger/xqdb_client.h 2012-02-03 01:13:24 +0000
3545@@ -0,0 +1,51 @@
3546+/*
3547+ * Copyright 2006-2008 The FLWOR Foundation.
3548+ *
3549+ * Licensed under the Apache License, Version 2.0 (the "License");
3550+ * you may not use this file except in compliance with the License.
3551+ * You may obtain a copy of the License at
3552+ *
3553+ * http://www.apache.org/licenses/LICENSE-2.0
3554+ *
3555+ * Unless required by applicable law or agreed to in writing, software
3556+ * distributed under the License is distributed on an "AS IS" BASIS,
3557+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3558+ * See the License for the specific language governing permissions and
3559+ * limitations under the License.
3560+ */
3561+#pragma once
3562+#ifndef ZORBA_DEBUGGER_XQDB_CLIENT_H
3563+#define ZORBA_DEBUGGER_XQDB_CLIENT_H
3564+
3565+#include "command_prompt.h"
3566+#include "command_line_handler.h"
3567+
3568+
3569+namespace zorba { namespace debugger {
3570+
3571+class XqdbClient {
3572+
3573+ public:
3574+
3575+ XqdbClient(unsigned int aPort);
3576+
3577+ ~XqdbClient();
3578+
3579+ void
3580+ start();
3581+
3582+ private:
3583+
3584+ LockFreeQueue<std::size_t>* theIdQueue;
3585+ LockFreeQueue<bool>* theQuitQueue;
3586+
3587+ EventHandler* theEventHandler;
3588+ CommandPrompt* theCommandPrompt;
3589+ CommandLineHandler* theCommandLineHandler;
3590+};
3591+
3592+
3593+} // namespace zorba
3594+} // namespace debugger
3595+
3596+#endif // ZORBA_DEBUGGER_XQDB_CLIENT_H
3597
3598=== renamed file 'bin/module_path.cpp' => 'bin/path_util.cpp'
3599--- bin/module_path.cpp 2011-05-25 16:40:26 +0000
3600+++ bin/path_util.cpp 2012-02-03 01:13:24 +0000
3601@@ -14,85 +14,100 @@
3602 * limitations under the License.
3603 */
3604
3605-#include "module_path.h"
3606+#include "path_util.h"
3607
3608 #include <stdlib.h>
3609-#include "zorba/zorba_string.h"
3610+//#include "zorba/zorba_string.h"
3611 #include "zorba/util/path.h"
3612
3613 #include "util.h"
3614 #include "zorbacmdproperties.h"
3615+#include <zorba/static_context.h>
3616
3617 namespace zorba {
3618
3619-std::string
3620-ModulePath::getEnvironmentModulePath()
3621+namespace PathUtil {
3622+
3623+static std::string
3624+getPathFromEnvironment(std::string const& aEnvVar)
3625 {
3626- std::string lEnvName("ZORBA_MODULE_PATH");
3627 #ifdef WIN32
3628 char* lBuffer;
3629 size_t lLen=0;
3630- errno_t lErr = getenv_s(&lLen, NULL, 0, lEnvName.c_str());
3631+ errno_t lErr = getenv_s(&lLen, NULL, 0, aEnvVar.c_str());
3632 if (lErr || !lLen) return "";
3633 lBuffer = (char*)malloc(lLen * sizeof(char));
3634 if (!lBuffer) return "";
3635- getenv_s(&lLen, lBuffer, lLen, lEnvName.c_str());
3636+ getenv_s(&lLen, lBuffer, lLen, aEnvVar.c_str());
3637 std::string lRes(lBuffer);
3638 free(lBuffer);
3639 return lRes;
3640 #else
3641- const char* lEnvValue = getenv(lEnvName.c_str());
3642- return lEnvValue!=0?lEnvValue:"";
3643+ const char* lEnvValue = getenv(aEnvVar.c_str());
3644+ return lEnvValue != 0 ? lEnvValue : "";
3645 #endif
3646 }
3647
3648-void
3649-ModulePath::convertVector(
3650- const std::vector<std::string>& aSource,
3651- std::vector<String>& aDest)
3652-{
3653- for (std::vector<std::string>::const_iterator lIter = aSource.begin();
3654- lIter != aSource.end(); ++lIter) {
3655- aDest.push_back(*lIter);
3656- }
3657-}
3658
3659-void
3660-ModulePath::tokenizeModulePath(
3661- const std::string& aModulePath,
3662- std::vector<std::string>& aResult)
3663+static void
3664+tokenizePath(
3665+ const std::string& aPathStr,
3666+ std::vector<String>& aResult)
3667 {
3668+ std::vector<std::string> lPath;
3669 #ifdef WIN32
3670- Util::tokenize(aModulePath, ";", aResult);
3671+ Util::tokenize(aPathStr, ";", lPath);
3672 #else
3673- Util::tokenize(aModulePath, ":", aResult);
3674+ Util::tokenize(aPathStr, ":", lPath);
3675 #endif
3676+ for (std::vector<std::string>::iterator lIter = lPath.begin();
3677+ lIter != lPath.end(); ++lIter) {
3678+ aResult.push_back(*lIter);
3679+ }
3680 }
3681
3682 void
3683-ModulePath::getModulePaths(
3684+setPathsOnContext(
3685 const ZorbaCMDProperties& aProperties,
3686- std::vector<String>& aModulePaths)
3687+ StaticContext_t& aStaticCtx)
3688 {
3689- std::vector<std::string> lModulePaths; // result vector
3690- std::string lModulePath; // temporary variable for collections paths
3691-
3692- // 1. add the module paths from the command line properties
3693- aProperties.getModulePaths(lModulePath);
3694-
3695- tokenizeModulePath(lModulePath, lModulePaths);
3696-
3697- // 2. add the module paths from the environment
3698- lModulePath = ModulePath::getEnvironmentModulePath();
3699-
3700- tokenizeModulePath(lModulePath, lModulePaths);
3701-
3702- // 3. add the current working directory as module path
3703+ std::vector<String> lPath;
3704+ std::string lPathStr, lEnvStr;
3705+
3706+ // Compute the current working directory to append to all paths.
3707 filesystem_path lCWD;
3708- lModulePaths.push_back(lCWD.get_path());
3709-
3710- // convert std::string to zorba::String
3711- convertVector(lModulePaths, aModulePaths);
3712+
3713+ // setModulePaths() *overwrites* the URI path and lib path, so there's no
3714+ // sense in calling both. So if either --module-path or ZORBA_MODULE_PATH
3715+ // exists, just use those.
3716+ aProperties.getModulePath(lPathStr);
3717+ lEnvStr = getPathFromEnvironment("ZORBA_MODULE_PATH");
3718+ if (lPathStr.length() > 0 || lEnvStr.length() > 0) {
3719+ tokenizePath(lPathStr, lPath);
3720+ tokenizePath(lEnvStr, lPath);
3721+ lPath.push_back(lCWD.get_path());
3722+ aStaticCtx->setModulePaths(lPath);
3723+ }
3724+ else {
3725+ // Compute and set URI path
3726+ aProperties.getURIPath(lPathStr);
3727+ tokenizePath(lPathStr, lPath);
3728+ lEnvStr = getPathFromEnvironment("ZORBA_URI_PATH");
3729+ tokenizePath(lEnvStr, lPath);
3730+ lPath.push_back(lCWD.get_path());
3731+ aStaticCtx->setURIPath(lPath);
3732+ lPath.clear();
3733+
3734+ // Compute and set lib path
3735+ aProperties.getLibPath(lPathStr);
3736+ tokenizePath(lPathStr, lPath);
3737+ lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
3738+ lPath.push_back(lCWD.get_path());
3739+ tokenizePath(lEnvStr, lPath);
3740+ aStaticCtx->setLibPath(lPath);
3741+ }
3742 }
3743
3744+} /* namespace ModulePath */
3745+
3746 } /* namespace zorba */
3747
3748=== renamed file 'bin/module_path.h' => 'bin/path_util.h'
3749--- bin/module_path.h 2010-02-12 08:57:04 +0000
3750+++ bin/path_util.h 2012-02-03 01:13:24 +0000
3751@@ -18,6 +18,7 @@
3752
3753 #include <vector>
3754 #include <string>
3755+#include <zorba/api_shared_types.h>
3756
3757 class ZorbaCMDProperties;
3758
3759@@ -25,30 +26,14 @@
3760
3761 class String;
3762
3763- class ModulePath {
3764- protected:
3765- static std::string
3766- getEnvironmentModulePath();
3767-
3768- static void
3769- convertVector(const std::vector<std::string>& aSource,
3770- std::vector<String>& aDest);
3771-
3772- static void
3773- tokenizeModulePath(const std::string& aModulePath,
3774- std::vector<std::string>& aResult);
3775-
3776- static void
3777- getInstalledModulePath(const std::string& aModulePath,
3778- std::vector<std::string>& aResult);
3779-
3780- public:
3781- static void
3782- getModulePaths(const ZorbaCMDProperties& aProperties,
3783- std::vector<String>& aModulePaths);
3784-
3785-
3786- };
3787+ namespace PathUtil {
3788+
3789+ void
3790+ setPathsOnContext(const ZorbaCMDProperties& aProperties,
3791+ zorba::StaticContext_t& aStaticCtx);
3792+
3793+
3794+ }
3795 } /* namespace zorba */
3796
3797 #endif
3798
3799=== modified file 'bin/zorbacmd.cpp'
3800--- bin/zorbacmd.cpp 2011-07-11 11:12:23 +0000
3801+++ bin/zorbacmd.cpp 2012-02-03 01:13:24 +0000
3802@@ -43,7 +43,7 @@
3803
3804 #include "error_printer.h"
3805 #include "util.h"
3806-#include "module_path.h"
3807+#include "path_util.h"
3808
3809 // For setting the base URI from the current directory
3810 #include <zorba/util/path.h>
3811@@ -70,7 +70,7 @@
3812
3813 #ifndef ZORBA_NO_FULL_TEXT
3814 OneToOneURIMapper theStopWordsMapper(EntityData::STOP_WORDS);
3815-OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS, URIMapper::COMPONENT);
3816+OneToOneURIMapper theThesaurusMapper(EntityData::THESAURUS);
3817 #endif
3818
3819 bool
3820@@ -85,10 +85,8 @@
3821 // 2. environment ZORBA_MODULE_PATH
3822 // 3. current working directory
3823 {
3824- std::vector<String> lModulePaths;
3825- ModulePath::getModulePaths(aProperties, lModulePaths);
3826-
3827- aStaticContext->setModulePaths(lModulePaths);
3828+ std::vector<String> lModulePath;
3829+ PathUtil::setPathsOnContext(aProperties, aStaticContext);
3830 }
3831
3832 if (aProperties.boundarySpace().size() != 0 )
3833@@ -509,12 +507,24 @@
3834 Zorba_CompilerHints lHints;
3835
3836 // default is O1 in the Zorba_CompilerHints constructor
3837- if (properties.optimizationLevel() == "O0") {
3838+ if (properties.optimizationLevel() == "O0")
3839+ {
3840 lHints.opt_level = ZORBA_OPT_LEVEL_O0;
3841- } else if (properties.optimizationLevel() == "O2") {
3842+ }
3843+ else if (properties.optimizationLevel() == "O2")
3844+ {
3845 lHints.opt_level = ZORBA_OPT_LEVEL_O2;
3846 }
3847
3848+ lHints.for_serialization_only = true;
3849+
3850+#if ZORBACMD_LOAD_SYSTEM_PROPERTIES
3851+ if (Properties::instance()->serializeOnlyQuery() == 0)
3852+ {
3853+ lHints.for_serialization_only = false;
3854+ }
3855+#endif
3856+
3857 // default is false
3858 if (properties.libModule())
3859 {
3860@@ -577,8 +587,6 @@
3861 return 12;
3862 }
3863
3864- // if (diagnosticHandler.
3865-
3866 //
3867 // Create and populate the dynamic context
3868 //
3869@@ -661,19 +669,22 @@
3870 XmlDataManager* store = zorbaInstance->getXmlDataManager();
3871
3872 timing.startTimer(TimingInfo::UNLOAD_TIMER, i);
3873+
3874 DocumentManager* lMgr = store->getDocumentManager();
3875 ItemSequence_t lSeq = lMgr->availableDocuments();
3876 Iterator_t lIter = lSeq->getIterator();
3877 lIter->open();
3878 Item lURI;
3879- while (lIter->next(lURI)) {
3880+ while (lIter->next(lURI))
3881+ {
3882 lMgr->remove(lURI.getStringValue());
3883 }
3884+
3885 timing.stopTimer(TimingInfo::UNLOAD_TIMER, i);
3886
3887 timing.stopTimer(TimingInfo::TOTAL_TIMER, i);
3888 }
3889- }
3890+ } // for each execution
3891
3892 return 0;
3893 }
3894@@ -704,7 +715,7 @@
3895 return 1;
3896 }
3897
3898- TimingInfo timing(lProperties.multiple());
3899+ TimingInfo engineTiming(lProperties.multiple());
3900
3901 bool doTiming = lProperties.timing();
3902 bool debug = false;
3903@@ -741,14 +752,14 @@
3904
3905 // Start the engine
3906
3907- timing.startTimer(TimingInfo::INIT_TIMER, 2);
3908+ engineTiming.startTimer(TimingInfo::INIT_TIMER, 2);
3909
3910 void* store = zorba::StoreManager::getStore();
3911
3912 zorba::Zorba* lZorbaInstance = zorba::Zorba::getInstance(store);
3913
3914 {
3915- timing.stopTimer(TimingInfo::INIT_TIMER, 2);
3916+ engineTiming.stopTimer(TimingInfo::INIT_TIMER, 2);
3917
3918 // For each query ...
3919
3920@@ -770,14 +781,14 @@
3921 if (asFile)
3922 {
3923 path.resolve_relative ();
3924- qfile.reset (new std::ifstream (path.c_str ()));
3925+ qfile.reset(new std::ifstream (path.c_str ()));
3926 }
3927 else
3928 {
3929- qfile.reset (new std::istringstream(fURI));
3930+ qfile.reset(new std::istringstream(fURI));
3931 }
3932
3933- if ( asFile && (!qfile->good() || qfile->eof()) )
3934+ if (asFile && (!qfile->good() || qfile->eof()))
3935 {
3936 std::cerr << "file {" << fname << "} not found or not readable." << std::endl;
3937 lProperties.printHelp(std::cout);
3938@@ -793,7 +804,8 @@
3939 //
3940 // Print the query if requested
3941 //
3942- if (lProperties.printQuery()) {
3943+ if (lProperties.printQuery())
3944+ {
3945 *lOutputStream << "\nQuery number " << queryNo << " :\n";
3946 std::copy (std::istreambuf_iterator<char> (*qfile),
3947 std::istreambuf_iterator<char> (),
3948@@ -836,8 +848,10 @@
3949 }
3950
3951 // Parse the query
3952- if (lProperties.parseOnly()) {
3953- try {
3954+ if (lProperties.parseOnly())
3955+ {
3956+ try
3957+ {
3958 zorba::XQuery_t lQuery = lZorbaInstance->createQuery();
3959 if (asFile) {
3960 lQuery->setFileName(path.get_path());
3961@@ -845,7 +859,8 @@
3962
3963 lQuery->parse (*qfile);
3964 }
3965- catch (zorba::ZorbaException const& ze) {
3966+ catch (zorba::ZorbaException const& ze)
3967+ {
3968 std::cerr << ze << std::endl;
3969 return 6;
3970 }
3971@@ -853,30 +868,44 @@
3972
3973 // Compile and run it if necessary.
3974 // Print timing information if requested.
3975- else if (!debug) {
3976- if (compileOnly) {
3977- try {
3978+ else if (!debug)
3979+ {
3980+ if (compileOnly)
3981+ {
3982+ try
3983+ {
3984 zorba::XQuery_t aQuery = lZorbaInstance->createQuery();
3985- if (asFile) {
3986+ if (asFile)
3987+ {
3988 aQuery->setFileName(path.get_path());
3989 }
3990+
3991 aQuery->parse(*qfile);
3992+
3993 qfile->clear();
3994 qfile->seekg(0); // go back to the beginning
3995- } catch (zorba::XQueryException const& qe) {
3996- ErrorPrinter::print(qe, std::cerr, lProperties.printErrorsAsXml(), lProperties.indent());
3997+ }
3998+ catch (zorba::XQueryException const& qe)
3999+ {
4000+ ErrorPrinter::print(qe,
4001+ std::cerr,
4002+ lProperties.printErrorsAsXml(),
4003+ lProperties.indent());
4004 return 6;
4005 }
4006 }
4007
4008+ TimingInfo queryTiming(lProperties.multiple());
4009+
4010 int status = compileAndExecute(lZorbaInstance,
4011 lProperties,
4012 lStaticContext,
4013 path.get_path(),
4014 *qfile,
4015 *lOutputStream,
4016- timing);
4017- if (status != 0) {
4018+ queryTiming);
4019+ if (status != 0)
4020+ {
4021 // reset the file handler (in case output option was provided)
4022 // in order to delete the created output file
4023 lFileStream.reset();
4024@@ -884,21 +913,25 @@
4025 return status;
4026 }
4027
4028- if (doTiming) {
4029- timing.print(std::cout);
4030+ if (doTiming)
4031+ {
4032+ queryTiming.print(std::cout);
4033 }
4034 }
4035
4036 #ifdef ZORBA_WITH_DEBUGGER
4037 // Debug the query. Do not allow "compileOnly" flags and inline queries
4038- else if (debug) {
4039- if (compileOnly) {
4040+ else if (debug)
4041+ {
4042+ if (compileOnly)
4043+ {
4044 std::cerr << "cannot debug a query if the compileOnly option is specified"
4045 << std::endl;
4046 return 7;
4047 }
4048
4049- if (!asFile) {
4050+ if (!asFile)
4051+ {
4052 std::cerr << "Cannot debug inline queries." << std::endl;
4053 return 8;
4054 }
4055@@ -908,7 +941,8 @@
4056
4057 zorba::XQuery_t lQuery;
4058
4059- try {
4060+ try
4061+ {
4062 lQuery = lZorbaInstance->createQuery();
4063 lQuery->setFileName(lFileName);
4064 lQuery->setDebugMode(true);
4065@@ -927,21 +961,24 @@
4066 lHost = "127.0.0.1";
4067 }
4068
4069- if (lProperties.debug()) {
4070- Zorba_SerializerOptions lSerOptions =
4071- Zorba_SerializerOptions::SerializerOptionsFromStringParams(
4072- lProperties.getSerializerParameters());
4073- createSerializerOptions(lSerOptions, lProperties);
4074+ Zorba_SerializerOptions lSerOptions =
4075+ Zorba_SerializerOptions::SerializerOptionsFromStringParams(
4076+ lProperties.getSerializerParameters());
4077+ createSerializerOptions(lSerOptions, lProperties);
4078
4079- if (!lProperties.hasNoLogo() && !lProperties.debug()) {
4080- std::cout << "Zorba XQuery Debugger Server\n" << copyright_str << std::endl;
4081- }
4082- lQuery->debug(*lOutputStream, lSerOptions, lHost, lProperties.getDebugPort());
4083+ if (!lProperties.hasNoLogo())
4084+ {
4085+ std::cout << "Zorba XQuery Debugger Server\n" << copyright_str << std::endl;
4086 }
4087+
4088+ lQuery->debug(*lOutputStream, lSerOptions, lHost, lProperties.getDebugPort());
4089 }
4090 catch (zorba::XQueryException const& qe)
4091 {
4092- ErrorPrinter::print(qe, std::cerr, lProperties.printErrorsAsXml(), lProperties.indent());
4093+ ErrorPrinter::print(qe,
4094+ std::cerr,
4095+ lProperties.printErrorsAsXml(),
4096+ lProperties.indent());
4097 return 5;
4098 }
4099 catch (zorba::ZorbaException const& ze)
4100@@ -958,7 +995,7 @@
4101
4102 if (doTiming)
4103 {
4104- timing.startTimer(TimingInfo::DEINIT_TIMER, 2);
4105+ engineTiming.startTimer(TimingInfo::DEINIT_TIMER, 2);
4106 }
4107
4108 lZorbaInstance->shutdown();
4109@@ -966,11 +1003,11 @@
4110
4111 if (doTiming)
4112 {
4113- timing.stopTimer(TimingInfo::DEINIT_TIMER, 2);
4114+ engineTiming.stopTimer(TimingInfo::DEINIT_TIMER, 2);
4115
4116 std::cout << std::endl << "Engine Shutdown Time : "
4117- << timing.elapsedDeinitWalltime
4118- << " (user: " << timing.elapsedDeinitCputime << ")"
4119+ << engineTiming.elapsedDeinitWalltime
4120+ << " (user: " << engineTiming.elapsedDeinitCputime << ")"
4121 << " milliseconds" << std::endl;
4122 }
4123 return 0;
4124
4125=== modified file 'bin/zorbacmdproperties.cpp'
4126--- bin/zorbacmdproperties.cpp 2011-07-21 19:21:25 +0000
4127+++ bin/zorbacmdproperties.cpp 2012-02-03 01:13:24 +0000
4128@@ -166,11 +166,20 @@
4129 }
4130
4131
4132-void ZorbaCMDProperties::getModulePaths(std::string& aPaths) const
4133-{
4134- aPaths = theModulePath;
4135-}
4136-
4137+void ZorbaCMDProperties::getModulePath(std::string& aPath) const
4138+{
4139+ aPath = theModulePath;
4140+}
4141+
4142+void ZorbaCMDProperties::getURIPath(std::string& aPath) const
4143+{
4144+ aPath = theUriPath;
4145+}
4146+
4147+void ZorbaCMDProperties::getLibPath(std::string& aPath) const
4148+{
4149+ aPath = theLibPath;
4150+}
4151
4152 std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const
4153 {
4154
4155=== modified file 'bin/zorbacmdproperties.h'
4156--- bin/zorbacmdproperties.h 2011-06-29 17:25:50 +0000
4157+++ bin/zorbacmdproperties.h 2012-02-03 01:13:24 +0000
4158@@ -84,8 +84,14 @@
4159 getSerializerParameters() const;
4160
4161 void
4162- getModulePaths(std::string&) const;
4163+ getModulePath(std::string&) const;
4164
4165+ void
4166+ getURIPath(std::string&) const;
4167+
4168+ void
4169+ getLibPath(std::string&) const;
4170+
4171 bool isDebug(){ return theDebug; }
4172
4173 bool hasNoLogo(){ return theNoLogo; }
4174
4175=== modified file 'bin/zorbacmdproperties.txt'
4176--- bin/zorbacmdproperties.txt 2011-07-04 08:31:01 +0000
4177+++ bin/zorbacmdproperties.txt 2012-02-03 01:13:24 +0000
4178@@ -28,7 +28,9 @@
4179 ("debug-port,p", po::value<unsigned int>()->default_value (28028), "The port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028")
4180 ("no-logo", "Print no logo when starting.")
4181 ("timeout", po::value<long>()->default_value(-1), "Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.")
4182-("module-path", po::value<std::string>(), "Module paths added to the built-in resolver, i.e. where module imports are looking for modules.")
4183+("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")
4184+("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
4185+("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
4186 ("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value").
4187 ("trailing-nl", "Output a trailing newline after the result of the query.")
4188 ("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
4189
4190=== modified file 'bin/zorbacmdproperties_base.h'
4191--- bin/zorbacmdproperties_base.h 2011-07-04 08:31:01 +0000
4192+++ bin/zorbacmdproperties_base.h 2012-02-03 01:13:24 +0000
4193@@ -34,7 +34,7 @@
4194 class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {
4195 protected:
4196 const char **get_all_options () const {
4197- static const char *result [] = { "--timing", "--output-file", "--serialization-parameter", "--serialize-html", "--serialize-text", "--indent", "--print-query", "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration", "--base-uri", "--boundary-space", "--default-collation", "--construction-mode", "--ordering-mode", "--multiple", "--query", "--as-files", "--external-variable", "--context-item", "--optimization-level", "--lib-module", "--parse-only", "--compile-only", "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo", "--timeout", "--module-path", "--option", "--trailing-nl", "--stop-words", "--thesaurus", NULL };
4198+ static const char *result [] = { "--timing", "--output-file", "--serialization-parameter", "--serialize-html", "--serialize-text", "--indent", "--print-query", "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration", "--base-uri", "--boundary-space", "--default-collation", "--construction-mode", "--ordering-mode", "--multiple", "--query", "--as-files", "--external-variable", "--context-item", "--optimization-level", "--lib-module", "--parse-only", "--compile-only", "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo", "--timeout", "--uri-path", "--lib-path", "--module-path", "--option", "--trailing-nl", "--stop-words", "--thesaurus", NULL };
4199 return result;
4200 }
4201 bool theTiming;
4202@@ -67,6 +67,8 @@
4203 unsigned int theDebugPort;
4204 bool theNoLogo;
4205 long theTimeout;
4206+ std::string theUriPath;
4207+ std::string theLibPath;
4208 std::string theModulePath;
4209 std::vector<std::string> theOption;
4210 bool theTrailingNl;
4211@@ -127,6 +129,8 @@
4212 const unsigned int &debugPort () const { return theDebugPort; }
4213 const bool &noLogo () const { return theNoLogo; }
4214 const long &timeout () const { return theTimeout; }
4215+ const std::string &uriPath () const { return theUriPath; }
4216+ const std::string &libPath () const { return theLibPath; }
4217 const std::string &modulePath () const { return theModulePath; }
4218 const std::vector<std::string> &option () const { return theOption; }
4219 const bool &trailingNl () const { return theTrailingNl; }
4220@@ -262,6 +266,16 @@
4221 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
4222 if (*argv == NULL) { result = "No value given for --timeout option"; break; } init_val (*argv, theTimeout, d);
4223 }
4224+ else if (strcmp (*argv, "--uri-path") == 0) {
4225+ int d = 2;
4226+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
4227+ if (*argv == NULL) { result = "No value given for --uri-path option"; break; } init_val (*argv, theUriPath, d);
4228+ }
4229+ else if (strcmp (*argv, "--lib-path") == 0) {
4230+ int d = 2;
4231+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
4232+ if (*argv == NULL) { result = "No value given for --lib-path option"; break; } init_val (*argv, theLibPath, d);
4233+ }
4234 else if (strcmp (*argv, "--module-path") == 0) {
4235 int d = 2;
4236 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
4237@@ -327,11 +341,13 @@
4238 "--compile-only\nOnly compile (don't execute)\n\n"
4239 "--no-serializer\nDo not serialize (discard) result.\n\n"
4240 "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
4241-"--debug-host, -p\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
4242+"--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
4243 "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
4244 "--no-logo\nPrint no logo when starting.\n\n"
4245 "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
4246-"--module-path\nModule paths added to the built-in resolver, i.e. where module imports are looking for modules.\n\n"
4247+"--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
4248+"--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
4249+"--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
4250 "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value\n\n"
4251 "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
4252 "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
4253
4254=== added file 'cmake_modules/FindLibedit.cmake'
4255--- cmake_modules/FindLibedit.cmake 1970-01-01 00:00:00 +0000
4256+++ cmake_modules/FindLibedit.cmake 2012-02-03 01:13:24 +0000
4257@@ -0,0 +1,46 @@
4258+# Copyright 2011 The FLWOR Foundation.
4259+#
4260+# Licensed under the Apache License, Version 2.0 (the "License");
4261+# you may not use this file except in compliance with the License.
4262+# You may obtain a copy of the License at
4263+#
4264+# http://www.apache.org/licenses/LICENSE-2.0
4265+#
4266+# Unless required by applicable law or agreed to in writing, software
4267+# distributed under the License is distributed on an "AS IS" BASIS,
4268+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4269+# See the License for the specific language governing permissions and
4270+# limitations under the License.
4271+#
4272+# - Try to find the libedit library
4273+#
4274+# Once done this will define
4275+#
4276+# LIBEDIT_FOUND - True if libedit library is found
4277+# LIBEDIT_INCLUDE_DIRS - Directory to include to get libedit headers
4278+# LIBEDIT_LIBRARIES - Libraries to link against for the libedit library
4279+#
4280+
4281+FIND_PATH (
4282+ LIBEDIT_INCLUDE
4283+ editline/readline.h
4284+ PATHS ${LIBEDIT_INCLUDE_DIR} /usr/include /usr/local/include
4285+)
4286+MESSAGE(STATUS ${LIBEDIT_INCLUDE})
4287+
4288+FIND_LIBRARY (
4289+ LIBEDIT_LIBRARY
4290+ NAMES edit
4291+ PATHS ${LIBEDIT_LIBRARY_DIR} /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
4292+)
4293+MESSAGE(STATUS ${LIBEDIT_LIBRARY})
4294+
4295+SET (LIBEDIT_INCLUDE_DIRS ${LIBEDIT_INCLUDE})
4296+SET (LIBEDIT_LIBRARIES ${LIBEDIT_LIBRARY})
4297+
4298+FIND_PACKAGE_HANDLE_STANDARD_ARGS (
4299+ Libedit
4300+ DEFAULT_MSG
4301+ LIBEDIT_INCLUDE LIBEDIT_LIBRARY
4302+)
4303+
4304
4305=== modified file 'cmake_modules/FindPHP5.cmake'
4306--- cmake_modules/FindPHP5.cmake 2011-08-19 00:03:31 +0000
4307+++ cmake_modules/FindPHP5.cmake 2012-02-03 01:13:24 +0000
4308@@ -97,6 +97,11 @@
4309 _zend_rsrc_list_get_rsrc_type
4310 _zend_wrong_param_count
4311 _zval_used_for_init
4312+ _zval_is_true
4313+ _zend_lookup_class
4314+ __object_init
4315+ __zend_hash_add_or_update
4316+ _php_strtolower
4317 )
4318 SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
4319 "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS},-U,${symbol}")
4320
4321=== modified file 'cmake_modules/ZorbaModule.cmake'
4322--- cmake_modules/ZorbaModule.cmake 2011-10-10 10:31:20 +0000
4323+++ cmake_modules/ZorbaModule.cmake 2012-02-03 01:13:24 +0000
4324@@ -272,12 +272,12 @@
4325 IF(NOT ${PROJECT_NAME} STREQUAL "zorba")
4326 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME})
4327 INSTALL(TARGETS ${module_lib_target}
4328- ${target_type} DESTINATION ${ZORBA_MODULES_INSTALL_DIR}/${module_path}
4329+ ${target_type} DESTINATION ${ZORBA_NONCORE_LIB_DIR}/${module_path}
4330 COMPONENT ${component_name})
4331
4332 ELSE(NOT ${PROJECT_NAME} STREQUAL "zorba")
4333 INSTALL(TARGETS ${module_lib_target}
4334- ${target_type} DESTINATION ${ZORBA_MODULES_INSTALL_DIR}/${module_path})
4335+ ${target_type} DESTINATION ${ZORBA_CORE_LIB_DIR}/${module_path})
4336 ENDIF(NOT ${PROJECT_NAME} STREQUAL "zorba")
4337 ENDIF (NOT MODULE_TEST_ONLY)
4338
4339@@ -296,7 +296,7 @@
4340 ENDIF (patch_ver)
4341 ENDIF (MODULE_VERSION)
4342 FOREACH (version_infix "" ${version_infixes})
4343- ADD_COPY_RULE ("${SOURCE_FILE}" "${module_path}/${module_filename}"
4344+ ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"
4345 "${version_infix}" "" "${MODULE_TEST_ONLY}")
4346 ENDFOREACH (version_infix)
4347
4348@@ -304,7 +304,7 @@
4349 IF (module_lib_target)
4350 GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION)
4351 GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME)
4352- ADD_COPY_RULE ("${lib_location}" "${module_path}/${lib_filename}"
4353+ ADD_COPY_RULE ("LIB" "${lib_location}" "${module_path}/${lib_filename}"
4354 "" "${module_lib_target}" "${MODULE_TEST_ONLY}")
4355 ENDIF (module_lib_target)
4356
4357@@ -357,27 +357,30 @@
4358 ADD_ZORBA_MANIFEST_ENTRY("schema" ${SCHEMA_URI} "")
4359 ENDIF (NOT SCHEMA_TEST_ONLY)
4360
4361- ADD_COPY_RULE ("${SOURCE_FILE}" "${schema_path}/${schema_filename}"
4362+ ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"
4363 "" "" "${SCHEMA_TEST_ONLY}")
4364
4365 ENDMACRO (DECLARE_ZORBA_SCHEMA)
4366
4367 # Utility macro for setting up a build rule to copy a file to a
4368-# particular (possible versioned) file in URI_PATH if such a file has
4369+# particular (possibly versioned) file in a shared directory if such a file has
4370 # not already been output.
4371+# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared
4372+# directory to place output in (URI_PATH or LIB_PATH).
4373 # INPUT_FILE: Absolute path to file to copy.
4374 # OUTPUT_FILE: Relative path to output file (relative to URI_PATH).
4375 # VERSION_ARG: Version; may be "" for non-versioned files.
4376 # DEPEND_TARGET: A CMake target name upon which the copy rule should depend;
4377 # may be "".
4378 # TEST_ONLY: If 1, file is for testcases only; will be copied into
4379-# TEST_URI_PATH and will not be installed
4380-MACRO (ADD_COPY_RULE INPUT_FILE OUTPUT_FILE VERSION_ARG DEPEND_TARGET TEST_ONLY)
4381+# TEST_URI_PATH/TEST_LIB_PATH and will not be installed
4382+MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG
4383+ DEPEND_TARGET TEST_ONLY)
4384 # Choose output base directory
4385 IF (${TEST_ONLY} EQUAL 1)
4386- SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_URI_PATH")
4387+ SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")
4388 ELSE (${TEST_ONLY} EQUAL 1)
4389- SET (_output_basedir "${CMAKE_BINARY_DIR}/URI_PATH")
4390+ SET (_output_basedir "${CMAKE_BINARY_DIR}/${FILE_TYPE}_PATH")
4391 ENDIF (${TEST_ONLY} EQUAL 1)
4392
4393 # Compute the modified output filename by inserting VERSION_ARG (if
4394@@ -404,19 +407,27 @@
4395 IF (file_found EQUAL -1)
4396 SET_PROPERTY (GLOBAL APPEND PROPERTY "${_dir_sym}-output-files"
4397 "${_output_file}")
4398- # Save the input file, output file, and any library dependency
4399- # target for this rule in a global property
4400+ # Detect whether this is a core URI or not
4401+ IF (PROJECT_NAME STREQUAL "zorba")
4402+ SET (_is_core 1)
4403+ ELSE (PROJECT_NAME STREQUAL "zorba")
4404+ SET (_is_core 0)
4405+ ENDIF (PROJECT_NAME STREQUAL "zorba")
4406+
4407+ # Save the (input file, output file, any library dependency
4408+ # target, and whether this is a core or non-core file) for this
4409+ # rule in a global property
4410 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES
4411- "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}")
4412+ "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")
4413
4414 # For .xq and .xsd files, also set up an INSTALL rule (if not TEST_ONLY).
4415 IF (NOT ${TEST_ONLY} EQUAL 1)
4416 IF (${_output_ext} STREQUAL ".xq" OR ${_output_ext} STREQUAL ".xsd")
4417
4418- IF(NOT PROJECT_NAME STREQUAL "zorba")
4419+ IF(NOT _is_core)
4420 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME})
4421 INSTALL (FILES "${INPUT_FILE}"
4422- DESTINATION "${ZORBA_MODULES_INSTALL_DIR}/${_output_path}"
4423+ DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}"
4424 RENAME "${_output_filename}"
4425 COMPONENT "${component_name}")
4426
4427@@ -434,13 +445,11 @@
4428 FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeCPackModules.cmake "SET(CPACK_COMPONENT_${component_name2}_INSTALL_TYPES Full)\n")
4429 ENDIF (NOT ${component_name}_cpack)
4430
4431- ELSE(NOT PROJECT_NAME STREQUAL "zorba")
4432+ ELSE(NOT _is_core)
4433 INSTALL (FILES "${INPUT_FILE}"
4434- DESTINATION "${ZORBA_MODULES_INSTALL_DIR}/${_output_path}"
4435+ DESTINATION "${ZORBA_CORE_URI_DIR}/${_output_path}"
4436 RENAME "${_output_filename}")
4437- ENDIF(NOT PROJECT_NAME STREQUAL "zorba")
4438-
4439-
4440+ ENDIF(NOT _is_core)
4441
4442 ENDIF (${_output_ext} STREQUAL ".xq" OR ${_output_ext} STREQUAL ".xsd")
4443 ENDIF (NOT ${TEST_ONLY} EQUAL 1)
4444@@ -485,16 +494,17 @@
4445 IF (POLICY CMP0007)
4446 CMAKE_POLICY (SET CMP0007 NEW)
4447 ENDIF (POLICY CMP0007)
4448- MESSAGE (STATUS "Creating check_uris target")
4449+ MESSAGE (STATUS "Creating check_core_uris and check_uris targets")
4450 GET_PROPERTY (copy_rules GLOBAL PROPERTY ZORBA_URI_FILES)
4451 SET (_output_files)
4452 WHILE (copy_rules)
4453- # Pop three items off the list, and set up the corresponding
4454+ # Pop four items off the list, and set up the corresponding
4455 # rule
4456 LIST (GET copy_rules 0 _input_file)
4457 LIST (GET copy_rules 1 _output_file)
4458 LIST (GET copy_rules 2 _depend_target)
4459- LIST (REMOVE_AT copy_rules 0 1 2)
4460+ LIST (GET copy_rules 3 _is_core)
4461+ LIST (REMOVE_AT copy_rules 0 1 2 3)
4462 SET (_depends "${_input_file}")
4463 IF (_depend_target)
4464 LIST (APPEND _depends "${_depend_target}")
4465@@ -504,12 +514,30 @@
4466 "${_input_file}" "${_output_file}"
4467 DEPENDS ${_depends}
4468 COMMENT "Copying ${_input_file} to URI path" VERBATIM)
4469- LIST (APPEND _output_files "${_output_file}")
4470+ IF (_is_core)
4471+ LIST (APPEND _core_output_files "${_output_file}")
4472+ ELSE (_is_core)
4473+ LIST (APPEND _noncore_output_files "${_output_file}")
4474+ ENDIF (_is_core)
4475 ENDWHILE (copy_rules)
4476- ADD_CUSTOM_TARGET (check_uris ALL DEPENDS ${_output_files} VERBATIM)
4477- SET_TARGET_PROPERTIES(check_uris PROPERTIES
4478- FOLDER "Modules"
4479- )
4480+
4481+ # Targets and dependencies:
4482+ # ALL depends on check_uris; check_uris depends on check_core_uris;
4483+ # zorbacmd depends on check_core_uris.
4484+ ADD_CUSTOM_TARGET (check_uris ALL
4485+ DEPENDS ${_noncore_output_files} VERBATIM)
4486+ SET_TARGET_PROPERTIES(check_uris PROPERTIES FOLDER "Modules")
4487+ # Only create check_core_uris target and associated dependencies if
4488+ # there are any core URIs; there should never be any when building a
4489+ # standalone module project.
4490+ LIST (LENGTH _core_output_files _num_core)
4491+ IF (_num_core GREATER 0)
4492+ ADD_CUSTOM_TARGET (check_core_uris
4493+ DEPENDS ${_core_output_files} VERBATIM)
4494+ ADD_DEPENDENCIES(check_uris check_core_uris)
4495+ ADD_DEPENDENCIES(zorbacmd check_core_uris)
4496+ SET_TARGET_PROPERTIES(check_core_uris PROPERTIES FOLDER "Modules")
4497+ ENDIF (_num_core GREATER 0)
4498 SET_PROPERTY (GLOBAL PROPERTY ZORBA_URI_FILES)
4499
4500 #add 'xqdoc' and 'xqdoc-xml' targets
4501@@ -695,7 +723,7 @@
4502 COMMENT "Building XQDoc XML documentation ..."
4503 )
4504 MESSAGE(STATUS " added target xqdoc-xml")
4505- ADD_DEPENDENCIES(xqdoc-xml zorba_simplestore)
4506+ ADD_DEPENDENCIES(xqdoc-xml zorbacmd check_core_uris)
4507
4508 SET_TARGET_PROPERTIES (xqdoc-xml PROPERTIES
4509 EXCLUDE_FROM_DEFAULT_BUILD 1
4510
4511=== modified file 'config/CMakeLists.txt'
4512--- config/CMakeLists.txt 2011-09-08 19:19:54 +0000
4513+++ config/CMakeLists.txt 2012-02-03 01:13:24 +0000
4514@@ -34,7 +34,8 @@
4515 SET(Zorba_EXE_PATH "${ZORBA_ROOT}/bin/zorba")
4516 SET(Zorba_EXTERNALMODULECONFIG_FILE
4517 "${ZORBA_ROOT}/${ZORBA_CMAKE_DIR}/ExternalModuleConfig.cmake.in")
4518-SET(Zorba_MODULES_INSTALL_DIR "${ZORBA_ROOT}/${ZORBA_MODULES_INSTALL_DIR}")
4519+SET(Zorba_NONCORE_URI_DIR "${ZORBA_ROOT}/${ZORBA_NONCORE_URI_DIR}")
4520+SET(Zorba_NONCORE_LIB_DIR "${ZORBA_ROOT}/${ZORBA_NONCORE_LIB_DIR}")
4521
4522 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaConfig.cmake.in"
4523 "${CMAKE_CURRENT_BINARY_DIR}/ZorbaConfig.cmake" @ONLY)
4524@@ -58,7 +59,7 @@
4525 STRING (REPLACE ".exe" ".bat" Zorba_TESTDRIVER ${Zorba_TESTDRIVER})
4526 ENDIF (WIN32)
4527
4528-SET(Zorba_EXE_PATH "${ZORBA_EXE}")
4529+SET(Zorba_EXE_PATH "${ZORBA_EXE}")
4530 SET(Zorba_EXTERNALMODULECONFIG_FILE
4531 "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in")
4532 # Note: We also set these two into the parent's scope, so that it is
4533@@ -67,10 +68,9 @@
4534 "${CMAKE_CURRENT_SOURCE_DIR}/ExternalModuleConfig.cmake.in"
4535 PARENT_SCOPE)
4536 SET(Zorba_EXE "${ZORBA_EXE}" PARENT_SCOPE)
4537+SET(Zorba_NONCORE_URI_DIR "${ZORBA_NONCORE_URI_DIR}")
4538+SET(Zorba_NONCORE_LIB_DIR "${ZORBA_NONCORE_LIB_DIR}")
4539
4540-# Note: This value doesn't really make much sense, but neither does any
4541-# other value
4542-SET(Zorba_MODULES_INSTALL_DIR "${ZORBA_MODULES_INSTALL_DIR}")
4543 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ZorbaConfig.cmake.in"
4544 "${CMAKE_BINARY_DIR}/ZorbaConfig.cmake" @ONLY)
4545
4546
4547=== modified file 'config/ZorbaConfig.cmake.in'
4548--- config/ZorbaConfig.cmake.in 2011-08-24 09:09:02 +0000
4549+++ config/ZorbaConfig.cmake.in 2012-02-03 01:13:24 +0000
4550@@ -47,10 +47,13 @@
4551 "Path to Zorba's testdriver" FORCE)
4552 SET_NORMALIZED (Zorba_EXE "@Zorba_EXE_PATH@" CACHE PATH "Path to Zorba executable" FORCE)
4553
4554-# Tell the user project where modules are installed. Note: This variable
4555-# is all-uppercase because it is also used internally by Zorba's build.
4556-SET (ZORBA_MODULES_INSTALL_DIR "@Zorba_MODULES_INSTALL_DIR@"
4557- CACHE STRING "Path to Zorba modules in this Zorba installation" FORCE)
4558+# Tell the user project where (non-core) modules are installed. Note:
4559+# These variables are all-uppercase because they are also used
4560+# internally by Zorba's build.
4561+SET (ZORBA_NONCORE_URI_DIR "@Zorba_NONCORE_URI_DIR@"
4562+ CACHE STRING "Path to Zorba to non-core modules/schemas in this Zorba installation" FORCE)
4563+SET (ZORBA_NONCORE_LIB_DIR "@Zorba_NONCORE_LIB_DIR@"
4564+ CACHE STRING "Path to Zorba to non-core libraries in this Zorba installation" FORCE)
4565
4566 # Tell the user project where to find the "USE" file.
4567 # This file uses the above settings to configure the user project.
4568
4569=== modified file 'doc/cxx/examples/errors.cpp'
4570--- doc/cxx/examples/errors.cpp 2011-08-11 05:11:12 +0000
4571+++ doc/cxx/examples/errors.cpp 2012-02-03 01:13:24 +0000
4572@@ -139,12 +139,12 @@
4573 // make sure that the warning zwarn::ZWST0002 is turned
4574 // into an error
4575 StaticContext_t lCtx = aZorba->createStaticContext();
4576- lCtx->declareOption(lQName, "ZWST0002");
4577+ lCtx->declareOption(lQName, "ZWST0003");
4578
4579 std::ostringstream s;
4580- s << "declare namespace unknown = 'unknown-annotation';" << std::endl
4581- << "declare %unknown:test variable $var := 3;" << std::endl
4582- << "$var" << std::endl;
4583+ s << "declare namespace z = 'http://www.zorba-xquery.com/annotations';" << std::endl
4584+ << "declare %z:sequential function local:foo() { 1 };" << std::endl
4585+ << "local:foo()" << std::endl;
4586 XQuery_t lQuery = aZorba->compileQuery(s.str(), lCtx);
4587
4588 std::cout << lQuery << std::endl;
4589
4590=== modified file 'doc/cxx/examples/simple.cpp'
4591--- doc/cxx/examples/simple.cpp 2011-06-14 14:21:49 +0000
4592+++ doc/cxx/examples/simple.cpp 2012-02-03 01:13:24 +0000
4593@@ -33,14 +33,14 @@
4594
4595 std::cout << lQuery << std::endl;
4596
4597- return true;
4598+ return true;
4599 }
4600
4601
4602 bool
4603 example_2(Zorba* aZorba)
4604 {
4605- XQuery_t lQuery = aZorba->compileQuery("1+2");
4606+ XQuery_t lQuery = aZorba->compileQuery("1+2");
4607
4608 Iterator_t lIterator = lQuery->iterator();
4609 lIterator->open();
4610@@ -53,7 +53,7 @@
4611
4612 lIterator->close();
4613
4614- return true;
4615+ return true;
4616 }
4617
4618
4619@@ -61,7 +61,7 @@
4620 example_3(Zorba* aZorba)
4621 {
4622
4623- XQuery_t lQuery = aZorba->compileQuery("1 div 0");
4624+ XQuery_t lQuery = aZorba->compileQuery("1 div 0");
4625 try {
4626 std::cout << lQuery << std::endl;
4627 } catch ( ZorbaException& e ) {
4628@@ -69,7 +69,7 @@
4629 return true;
4630 }
4631
4632- return false;
4633+ return false;
4634 }
4635
4636
4637@@ -125,9 +125,7 @@
4638 bool
4639 example_7()
4640 {
4641-
4642 std::cout << Zorba::version() << std::endl;
4643-
4644 return true;
4645 }
4646
4647@@ -246,7 +244,8 @@
4648 bool
4649 example_12(Zorba* aZorba)
4650 {
4651- XQuery_t lQuery = aZorba->compileQuery("<a><b attr='1'/><b attr='2'/></a>");
4652+ XQuery_t lQuery = aZorba->compileQuery
4653+ ("<a xmlns:foo='http://www.zorba-xquery.com/'><b attr='1' xmlns:bar='http://www.zorba-xquery.com/uri2'/><b attr='2'/></a>");
4654
4655 Iterator_t lIterator = lQuery->iterator();
4656 lIterator->open();
4657@@ -263,16 +262,24 @@
4658 Item lNodeName;
4659 lChild.getNodeName(lNodeName);
4660 std::cout << "node name " << lNodeName.getStringValue() << std::endl;
4661+
4662 Iterator_t lAttrIter = lChild.getAttributes();
4663-
4664 lAttrIter->open();
4665-
4666 Item lAttr;
4667 while (lAttrIter->next(lAttr))
4668 {
4669 std::cout << " attribute value " << lAttr.getStringValue() << std::endl;
4670 }
4671 lAttrIter->close();
4672+
4673+ NsBindings lBindings;
4674+ lChild.getNamespaceBindings(lBindings,
4675+ store::StoreConsts::ONLY_LOCAL_NAMESPACES);
4676+ for (NsBindings::const_iterator ite = lBindings.begin();
4677+ ite != lBindings.end(); ++ite) {
4678+ std::cout << " namespace binding " << ite->first
4679+ << "->" << ite->second << std::endl;
4680+ }
4681 }
4682 lChildIter->close();
4683 }
4684
4685=== modified file 'doc/php/CMakeLists.txt'
4686--- doc/php/CMakeLists.txt 2011-06-20 12:44:21 +0000
4687+++ doc/php/CMakeLists.txt 2012-02-03 01:13:24 +0000
4688@@ -1,4 +1,4 @@
4689-# Copyright 2006-2008 The FLWOR Foundation.
4690+# Copyright 2006-2012 The FLWOR Foundation.
4691 #
4692 # Licensed under the Apache License, Version 2.0 (the "License");
4693 # you may not use this file except in compliance with the License.
4694
4695=== modified file 'doc/php/examples/CMakeLists.txt'
4696--- doc/php/examples/CMakeLists.txt 2011-08-19 00:03:31 +0000
4697+++ doc/php/examples/CMakeLists.txt 2012-02-03 01:13:24 +0000
4698@@ -1,4 +1,4 @@
4699-# Copyright 2006-2008 The FLWOR Foundation.
4700+# Copyright 2006-2012 The FLWOR Foundation.
4701 #
4702 # Licensed under the Apache License, Version 2.0 (the "License");
4703 # you may not use this file except in compliance with the License.
4704@@ -20,14 +20,24 @@
4705 MESSAGE(STATUS "PHP Path:" ${phpPath})
4706 SET(phpExtensionPath ${CMAKE_BINARY_DIR}/swig/php)
4707 MESSAGE(STATUS "PHP Extension Path: " ${phpExtensionPath})
4708+ SET(phpIncludePath ${CMAKE_BINARY_DIR}/swig/php)
4709+ MESSAGE(STATUS "PHP Include Path: " ${phpExtensionPath})
4710 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/php.ini.in ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
4711 MESSAGE(STATUS "Configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/php.ini)
4712 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/simple.php.in ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
4713 MESSAGE(STATUS "Simple configuration file: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
4714- ADD_TEST("php" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
4715+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test.php.in ${CMAKE_CURRENT_BINARY_DIR}/test.php)
4716+ MESSAGE(STATUS "PHP test file configured: " ${CMAKE_CURRENT_BINARY_DIR}/test.php)
4717+ ADD_TEST("php1" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
4718 MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/simple.php)
4719-
4720- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/simple.php
4721+ ADD_TEST("php2" ${PHP5_EXECUTABLE} -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/test.php)
4722+
4723+ EXPECTED_FAILURE(php2 918592)
4724+
4725+ MESSAGE(STATUS "Installing: " ${CMAKE_CURRENT_BINARY_DIR}/test.php)
4726+
4727+
4728+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/simple.php ${CMAKE_CURRENT_BINARY_DIR}/test.php
4729 COMPONENT "php_examples"
4730 DESTINATION
4731 share/doc/zorba-${ZORBA_MAJOR_NUMBER}.${ZORBA_MINOR_NUMBER}.${ZORBA_PATCH_NUMBER}/php/examples)
4732
4733=== modified file 'doc/php/examples/php.ini.in'
4734--- doc/php/examples/php.ini.in 2009-10-30 16:34:37 +0000
4735+++ doc/php/examples/php.ini.in 2012-02-03 01:13:24 +0000
4736@@ -1,2 +1,3 @@
4737 enable_dl=On
4738 extension_dir=@phpExtensionPath@
4739+include_path=".:@phpIncludePath@"
4740\ No newline at end of file
4741
4742=== modified file 'doc/php/examples/simple.php.in'
4743--- doc/php/examples/simple.php.in 2011-08-04 02:14:56 +0000
4744+++ doc/php/examples/simple.php.in 2012-02-03 01:13:24 +0000
4745@@ -1,6 +1,6 @@
4746 <?php
4747 /*
4748- * Copyright 2006-2008 The FLWOR Foundation.
4749+ * Copyright 2006-2012 The FLWOR Foundation.
4750 *
4751 * Licensed under the Apache License, Version 2.0 (the "License");
4752 * you may not use this file except in compliance with the License.
4753@@ -14,7 +14,7 @@
4754 * See the License for the specific language governing permissions and
4755 * limitations under the License.
4756 */
4757-require '@phpPath@/zorba_api_wrapper.php';
4758+require '@phpPath@/Zorba/zorba_api_wrapper.php';
4759
4760 function example_1(Zorba $aZorba)
4761 {
4762
4763=== added file 'doc/php/examples/test.php.in'
4764--- doc/php/examples/test.php.in 1970-01-01 00:00:00 +0000
4765+++ doc/php/examples/test.php.in 2012-02-03 01:13:24 +0000
4766@@ -0,0 +1,120 @@
4767+<?php
4768+/*
4769+ * Copyright 2006-2012 The FLWOR Foundation.
4770+ *
4771+ * Licensed under the Apache License, Version 2.0 (the "License");
4772+ * you may not use this file except in compliance with the License.
4773+ * You may obtain a copy of the License at
4774+ *
4775+ * http://www.apache.org/licenses/LICENSE-2.0
4776+ *
4777+ * Unless required by applicable law or agreed to in writing, software
4778+ * distributed under the License is distributed on an "AS IS" BASIS,
4779+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4780+ * See the License for the specific language governing permissions and
4781+ * limitations under the License.
4782+ */
4783+require '@phpPath@/Zorba/XQueryProcessor.php';
4784+
4785+function omitXMLDecl($xml)
4786+{
4787+ $xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $xml);
4788+ $xml = trim($xml);
4789+ return $xml;
4790+}
4791+
4792+function assertEquality($test, $reference, $label)
4793+{
4794+ $test = omitXMLDecl($test);
4795+ echo "=====================================\n";
4796+ var_dump($test);
4797+ var_dump($reference);
4798+ if($test != $reference) {
4799+ throw new Exception(
4800+ "Test "
4801+ . $label
4802+ . " failed. Result:\n"
4803+ . $test
4804+ . "\nDoesn't match reference:\n"
4805+ . $reference
4806+ );
4807+ }
4808+}
4809+/* Test 1 */
4810+$xquery = new XQueryProcessor();
4811+$xquery->importQuery('1+1');
4812+$result = $xquery->execute();
4813+assertEquality($result, '2', "1+1");
4814+
4815+/* Test 2 */
4816+$query = '
4817+declare variable $foo as xs:string external;
4818+declare variable $bar as xs:integer external;
4819+declare variable $doc1 as document-node() external;
4820+declare variable $doc2-str as xs:string external;
4821+declare variable $doc2 as document-node() := parse-xml($doc2-str);
4822+
4823+$foo, $bar, $doc1 , $doc2
4824+';
4825+
4826+$xquery->importQuery($query);
4827+
4828+$xquery->setVariable("foo", "bar");
4829+$xquery->setVariable("bar", 3);
4830+
4831+$doc = simplexml_load_string('<root />');
4832+$xquery->setVariable("doc1", $doc);
4833+
4834+$doc = "<root />";
4835+$xquery->setVariable("doc2-str", $doc);
4836+
4837+$result = trim($xquery->execute());
4838+assertEquality($result, "bar 3<root/><root/>", "Test PHP Types Mapping");
4839+
4840+/* Test 3 */
4841+$xquery->importQuery("(1, 2, <foo bar='bar' />)");
4842+$it = $xquery->getIterator();
4843+
4844+foreach($it as $pos => $value) {
4845+ switch($pos) {
4846+ case 0:
4847+ assertEquality($value, "1", "Consume the item at position {$pos}");
4848+ break;
4849+ case 1:
4850+ assertEquality($value, "2", "Consume the item at position {$pos}");
4851+ break;
4852+ case 3:
4853+ assertEquality($value, '<foo bar="bar"/>', "Consume the item at position {$pos}");
4854+ break;
4855+ }
4856+}
4857+
4858+//Let's do it again by leveraging the SPL IteratorAggregate
4859+foreach($xquery as $pos => $value) {
4860+ switch($pos) {
4861+ case 0:
4862+ assertEquality($value, "1", "Consume the item at position {$pos}");
4863+ break;
4864+ case 1:
4865+ assertEquality($value, "2", "Consume the item at position {$pos}");
4866+ break;
4867+ case 3:
4868+ assertEquality($value, '<foo bar="bar"/>', "Consume the item at position {$pos}");
4869+ break;
4870+ }
4871+}
4872+
4873+//Try the same query with execute
4874+$result = $xquery->execute();
4875+assertEquality($result, "1 2<foo bar=\"bar\"/>", "Execute To URI");
4876+
4877+/* Test 4 */
4878+$xquery->importQueryFromURI("@phpPath@/test.xq");
4879+$result = $xquery->execute();
4880+assertEquality($result, "2", "Test importQueryFromURI");
4881+
4882+/* Test 5 */
4883+//$xquery->importQueryFromURI("http://zorba.s3.amazonaws.com/test.xq");
4884+//$result = $xquery->execute();
4885+//assertEquality($result, "2", "Test importQueryFromURI");
4886+?>
4887
4888=== modified file 'doc/php/examples/zorba_api.php'
4889--- doc/php/examples/zorba_api.php 2010-01-27 13:25:24 +0000
4890+++ doc/php/examples/zorba_api.php 2012-02-03 01:13:24 +0000
4891@@ -1,6 +1,6 @@
4892 <?php
4893 /*
4894- * Copyright 2006-2008 The FLWOR Foundation.
4895+ * Copyright 2006-2012 The FLWOR Foundation.
4896 *
4897 * Licensed under the Apache License, Version 2.0 (the "License");
4898 * you may not use this file except in compliance with the License.
4899
4900=== modified file 'doc/zorba/commandline.dox'
4901--- doc/zorba/commandline.dox 2011-07-24 22:28:31 +0000
4902+++ doc/zorba/commandline.dox 2012-02-03 01:13:24 +0000
4903@@ -112,8 +112,14 @@
4904 --timeout
4905 Specify a timeout in seconds. After the specified time, the execution of the query will be aborted.
4906
4907+--uri-path
4908+URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.
4909+
4910+--lib-path
4911+Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.
4912+
4913 --module-path
4914-Module paths added to the built-in resolver, i.e. where module imports are looking for modules.
4915+Path (list of directories) to add to both the URI and Library paths.
4916
4917 --option
4918 Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value
4919
4920=== modified file 'doc/zorba/conformance.dox'
4921--- doc/zorba/conformance.dox 2011-09-06 16:39:46 +0000
4922+++ doc/zorba/conformance.dox 2012-02-03 01:13:24 +0000
4923@@ -344,18 +344,18 @@
4924 </tr>
4925 <tr bgcolor="lightcyan">
4926 <td bgcolor="lightcyan">Minimal Conformance</td>
4927- <td align="center" bgcolor="palegreen">384/429<br />89.51%</td>
4928- <td align="center" bgcolor="coral">24/429<br />5.59%</td>
4929+ <td align="center" bgcolor="palegreen">385/429<br />89.74%</td>
4930+ <td align="center" bgcolor="palegreen">374/429<br />87.18%</td>
4931 </tr>
4932 <tr bgcolor="lightcyan">
4933 <td bgcolor="lightcyan">Optional Features</td>
4934 <td align="center" bgcolor="palegreen">106/125<br />84.8%</td>
4935- <td align="center" bgcolor="coral">0/125<br />0%</td>
4936+ <td align="center" bgcolor="palegreen">97/125<br />77.6%</td>
4937 </tr>
4938 <tr bgcolor="lightcyan">
4939 <td bgcolor="lightcyan">Use Cases</td>
4940 <td align="center" bgcolor="palegreen">121/135<br />89.63%</td>
4941- <td align="center" bgcolor="coral">0/135<br />0%</td>
4942+ <td align="center" bgcolor="palegreen">103/135<br />76.3%</td>
4943 </tr>
4944 <tr bgcolor="lightcyan">
4945 <td bgcolor="lightcyan">Consistency in XQFTTS Catalog</td>
4946
4947=== modified file 'doc/zorba/conformanceXQFTTS.dox'
4948--- doc/zorba/conformanceXQFTTS.dox 2011-09-06 16:21:54 +0000
4949+++ doc/zorba/conformanceXQFTTS.dox 2012-02-03 01:13:24 +0000
4950@@ -1,8 +1,8 @@
4951 /** \page conformanceXQFTTS W3C XQuery and XPath Full Text 1.0 Conformance
4952
4953-Zorba achieves 89.51% on minimal conformance (and 84.8% on Optional Features) for the W3C XPath Full Text 1.0 Test Suite.
4954-Please see the table below for more details.
4955-
4956+ Zorba achieves 89.74% on minimal conformance (84.8% on Optional Features) for the W3C XPath Full Text 1.0 Test Suite.
4957+
4958+Please see the table below for more details.
4959 <table bgcolor="lightcyan">
4960 <tr>
4961 <td>W3C XQuery and XPath Full Text 1.0 features</td>
4962@@ -27,7 +27,7 @@
4963 <tr bgcolor="lightcyan">
4964 <td bgcolor="lightcyan">    Section 2.2.2</td>
4965 <td align="center" bgcolor="mediumseagreen">4/4</td>
4966- <td align="center" bgcolor="coral">0/4</td>
4967+ <td align="center" bgcolor="mediumseagreen">4/4</td>
4968 </tr>
4969 <tr bgcolor="lightcyan">
4970 <td bgcolor="lightcyan">    Section 2.3</td>
4971@@ -42,27 +42,27 @@
4972 <tr bgcolor="lightcyan">
4973 <td bgcolor="lightcyan">    Section 3.2</td>
4974 <td align="center" bgcolor="palegreen">4/5</td>
4975- <td align="center" bgcolor="coral">0/5</td>
4976+ <td align="center" bgcolor="palegreen">4/5</td>
4977 </tr>
4978 <tr bgcolor="lightcyan">
4979 <td bgcolor="lightcyan">    Section 3.3</td>
4980 <td align="center" bgcolor="mediumseagreen">2/2</td>
4981- <td align="center" bgcolor="coral">0/2</td>
4982+ <td align="center" bgcolor="mediumseagreen">2/2</td>
4983 </tr>
4984 <tr bgcolor="lightcyan">
4985 <td bgcolor="lightcyan">    Section 3.4</td>
4986 <td align="center" bgcolor="mediumseagreen">2/2</td>
4987- <td align="center" bgcolor="coral">0/2</td>
4988+ <td align="center" bgcolor="mediumseagreen">2/2</td>
4989 </tr>
4990 <tr bgcolor="lightcyan">
4991 <td bgcolor="lightcyan">    Section 3.4.1</td>
4992 <td align="center" bgcolor="mediumseagreen">1/1</td>
4993- <td align="center" bgcolor="coral">0/1</td>
4994+ <td align="center" bgcolor="mediumseagreen">1/1</td>
4995 </tr>
4996 <tr bgcolor="lightcyan">
4997 <td bgcolor="lightcyan">    Section 3.4.2</td>
4998 <td align="center" bgcolor="mediumseagreen">4/4</td>
4999- <td align="center" bgcolor="coral">0/4</td>
5000+ <td align="center" bgcolor="mediumseagreen">4/4</td>
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: