Merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba

Proposed by Cezar Andrei
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/module-schema-tools
Merge into: lp:zorba
Diff against target: 2318 lines (+1282/-160)
35 files modified
NOTICE.txt (+18/-0)
NOTICE.xml (+16/-0)
bin/path_util.cpp (+19/-2)
bin/path_util.h (+6/-0)
bin/zorbacmd.cpp (+8/-0)
bin/zorbacmdproperties.cpp (+5/-0)
bin/zorbacmdproperties.h (+3/-0)
bin/zorbacmdproperties.txt (+1/-0)
bin/zorbacmdproperties_base.h (+133/-72)
cmake_modules/ZorbaModule.cmake (+60/-16)
include/zorba/properties_base.h (+37/-1)
include/zorba/util/file.h (+2/-0)
include/zorba/zorba.h (+15/-5)
src/api/staticcontextimpl.h (+1/-0)
src/api/zorbaimpl.cpp (+10/-0)
src/api/zorbaimpl.h (+2/-0)
src/context/dynamic_loader.cpp (+41/-26)
src/context/dynamic_loader.h (+10/-5)
src/context/static_context.cpp (+37/-0)
src/context/static_context.h (+11/-0)
src/precompiled/stdafx.h (+5/-6)
src/system/properties.h (+21/-0)
src/system/zorba_properties.h (+67/-17)
src/system/zorba_properties.txt (+1/-0)
src/util/file.cpp (+12/-0)
src/util/fs_util.cpp (+24/-0)
src/util/fs_util.h (+28/-0)
src/util/win32/dirent.h (+372/-0)
swig/XQuery.i (+75/-8)
swig/java/CMakeLists.txt (+2/-1)
swig/various.i (+184/-0)
swig/zorba_api.i (+8/-1)
test/rbkt/modules/CMakeLists.txt (+2/-0)
test/rbkt/modules/java/CMakeLists.txt (+39/-0)
test/rbkt/modules/java/Test.java (+7/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/module-schema-tools
Reviewer Review Type Date Requested Status
Chris Hillery Needs Fixing
Matthias Brantner Needs Fixing
Cezar Andrei Pending
Review via email: mp+97978@code.launchpad.net

This proposal supersedes a proposal from 2012-03-16.

This proposal has been superseded by a proposal from 2012-03-19.

Commit message

Merge in branch implementing jvm classpath and fix managing dynamic libraries.

Add java classpath to zorbacmd and to Zorba API.
Fix dynamic libraries loading.
Tested it works on Windows with both xsl-fo and xmlbeans modules. All tests are passing.

Description of the change

Add java classpath to zorbacmd and to Zorba API.
Fix dynamic libraries loading.
Tested it works on Windows with both xsl-fo and xmlbeans modules. All tests are passing.

Removed reference to schema-tools module.

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

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in modules/ExternalModules.conf

Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

- In DynamicLoader::loadModule the code to create the Module is redundant and should be factorized
- Why is DECLARE_ZORBA_JAR in cmake_modules/ZorbaModule.cmake commented out? Should it be removed?
- Why did the file src/store/naive/store_properties.h change? I think Markos has disabled the generation in the trunk. We have to be careful that nothing is removed by this merge (same for all properties).
  For example,
88 -"--no-copy-optim\napply the no-copy optimization (1=enabled (default), 0=off)\n\n"
1089 -"--serialize-only-query\nserialize-only-query (<0=unknown (default), 1=enabled, 0=off)\n\n"
1090 +"--no-copy-optim\nno copy optim (1=enabled (default), 0=off)\n\n"
1091 +"--serialize-only-query\nserialize-only query (1=true, 0=false (default))\n\n"

causes the unknown option for the serialize-only-query param to disappear

- commit of src/util/win32/dirent.h should be mentioned in NOTICE.xml
- I don't really like the name serializeToOutputStream. Why can't it just be serialize with one parameter?
- there is a todo left "# todo cezar compile and jar it up"
- I didn't find a test for the new serializeToOutputStream or getStream functions? I think it would be good to have some tests.

review: Needs Fixing
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Agreed with Matthias's comments.

Regarding DECLARE_ZORBA_JAR(), it looks like the commented-out macro is an older version, and the newer version is not commented-out. The older one should just be deleted.

Couple more comments:

- Do we also need to mention the addition of swig/various.i in NOTICE.xml? It has a comment saying it's from the SWIG package directly.

- Wasn't the class name "IStream" causing a build conflict on Windows?

- The call to init_val() in zorbacmdproperties_base.h should be on a separate line. (I know it was cut-and-pasted from above, but ugh.)

- Why is the method for retrieving the PropertiesGlobal* called "getProperties()"? Shouldn't that be getProperiesGlobal()? (Or, IMHO, getGlobalProperties() and rename the class to GlobalProperties.)

- Similarly, why is the factory method for PropertiesGlobal "Properties::instance()"? (The Zorba Properties stuff has always seemed like a mishmash to me; this isn't helping.)

- Need to fix the conflict in ExternalModules.conf.

- Typo: "singelton" in zorba.h.

review: Needs Fixing
Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

I fixed all of the comments, execept:
- the ones related to swig:
    - the changes are not required, right now but they required for optimizing XQJ, to make swig play nice with streams it's quite a chlange, would be a petty to loose them
    - I don't think various.i should be specified in NOTICE.xml since we already have swig and various.i is part of swig.
- about Properties it's not really the most intuitive way of representing it but I do think PropertiesGlobal is a good name, many projects use kind after the base to explain what it is. I call Properties::instance() because that is the private instantiable implementation class that extends ZorbaProperties which is based on PropertiesGlobal.

Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

See my prevoius comment for fixes in this proposal.

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

Validation queue job module-schema-tools-2012-03-16T20-15-10.551Z is finished. The final status was:

All tests succeeded!

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

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 3 Pending.

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

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

- I think you reverted the changes that have been made in modules/ExternalModules.conf.
- The file src/system/zorba_properties.h also contains changes that have been reverted. For example,

1058 -"--no-copy-optim\napply the no-copy optimization (1=enabled (default), 0=off)\n\n"
1059 -"--serialize-only-query\nserialize-only-query (<0=unknown (default), 1=enabled, 0=off)\n\n"
1060 +"--no-copy-optim\nno copy optim (1=enabled (default), 0=off)\n\n"
1061 +"--serialize-only-query\nserialize-only query (1=true, 0=false (default))\n\n"

review: Needs Fixing
Revision history for this message
Chris Hillery (ceejatec) wrote :

It looks like you didn't fix the indentation of calls to init_val() in zorbacmdproperties_base.h, and in fact it looks like you moved a number of other instances of calls to that method onto the ends of earlier lines of code in zorba_properties.h. It's just not good readability. To be clear, I'm talking about lines like this:

   if (*argv == NULL) { result = "No value given for --classpath option"; break; } init_val (*argv, theClasspath, d);

There's no reason to have that call to init_val() hanging out over there. I count 9 places where this is done, most of which were put that way with this change.

You also didn't rename the class "IStream". Rodolfo reported that that class name conflicted with a Windows class, making the code not compile on Windows. It's not clear to me if this is one of the changes for "optimizing XQJ" you mentioned, but if it actually causes a compilation failure it must be changed.

review: Needs Fixing
Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

> It looks like you didn't fix the indentation of calls to init_val() in
> zorbacmdproperties_base.h, and in fact it looks like you moved a number of
> other instances of calls to that method onto the ends of earlier lines of code
> in zorba_properties.h. It's just not good readability. To be clear, I'm
> talking about lines like this:
>
> if (*argv == NULL) { result = "No value given for --classpath option";
> break; } init_val (*argv, theClasspath, d);
>
> There's no reason to have that call to init_val() hanging out over there. I
> count 9 places where this is done, most of which were put that way with this
> change.

If you take a look at the file there are many places where this strange indentation occurs. Check out the top of the file: THIS IS A GENERATED FILE. DO NOT EDIT!

>
>
> You also didn't rename the class "IStream". Rodolfo reported that that class
> name conflicted with a Windows class, making the code not compile on Windows.
> It's not clear to me if this is one of the changes for "optimizing XQJ" you
> mentioned, but if it actually causes a compilation failure it must be changed.

Rodolfo, checked out the full build and tests on windows, there is no problem with it. I sent an email to clarify it.

10640. By Cezar Andrei <email address hidden>

Fix ExternalModule.conf to the latest in trunk.

10641. By Cezar Andrei <email address hidden>

Fix wrong merge of options.

10642. By Cezar Andrei <email address hidden>

Merge from trunk.

Revision history for this message
Chris Hillery (ceejatec) wrote :

> If you take a look at the file there are many places where this strange
> indentation occurs. Check out the top of the file: THIS IS A GENERATED FILE.
> DO NOT EDIT!

My understanding is that this isn't true anymore, though. Markos removed the script to generate this file, and said that in future changes should be made directly to it. If that's correct, clearly he should have removed the above comment as well.

Did you run a script to generate these files, Cezar? If so, that would explain Matthias's problem as well (about changes to the property descriptions that seem to have been reverted by you).

10643. By Cezar Andrei <email address hidden>

Removed the top comment about this file beeing generated.
Fix some indentation.

10644. By Cezar Andrei <email address hidden>

Fix indentation src/system/zorba_properties.h.

10645. By Cezar Andrei <email address hidden>

Include schema-tools as external module for experimental.

10646. By Cezar Andrei <email address hidden>

Comment out reference to schema-tools module.
Removed swig IStream class and references.

10647. By Chris Hillery

Merge from trunk.

10648. By Chris Hillery

Significantly enhance modules/CMakeLists.txt to automatically figure
out in what order to add non-core module projects to Zorba. This was
necessary to extend the functionality of the automatically-created
moduleConfig.cmake files used in inter-module dependencies. These
files can now reference a "use file" to enable information such as
include directories to be shared to dependent modules.

10649. By Chris Hillery

Tweak DAG-formation algorithm to skip dependencies that aren't on other
module projects.

10650. By Chris Hillery

Move auto-creation of module package Config.cmake file to
DONE_DECLARING_ZORBA_URIS(), and extended it to support _INCLUDE_DIRS
and _LIBRARIES. The latter is automatically populated with all dynamic
libs created by DECLARE_ZORBA_MODULE().

10651. By Chris Hillery

Fix build dependencies for .jar files and inter-dependent modules.

10652. By Chris Hillery

Work around CMake bug with LIST(REMOVE_DUPLICATES).

10653. By Chris Hillery

Add util-jvm module.

10654. By Cezar Andrei <email address hidden>

Merge from trunk.

10655. By Cezar Andrei <email address hidden>

Add entries in ChangeLog.

10656. By Chris Hillery

Removing orphaned JVM classpath fields from static_context.

10657. By Chris Hillery

Merge from trunk.

10658. By Chris Hillery

Yet another crack at making the build dependencies for modules and zorba
completely consistent and correct.

10659. By Chris Hillery

Merge from trunk; remove erroneous swig merge.

10660. By Chris Hillery

Merge from trunk.

10661. By Chris Hillery

Merge from trunk.

10662. By Chris Hillery

Merge from trunk.

10663. By Chris Hillery

Unwanted file.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NOTICE.txt'
--- NOTICE.txt 2012-03-14 15:28:15 +0000
+++ NOTICE.txt 2012-03-19 16:17:13 +0000
@@ -459,6 +459,24 @@
459 suitability of this software for any purpose. It is provided "as is"459 suitability of this software for any purpose. It is provided "as is"
460 without express or implied warranty.460 without express or implied warranty.
461 461
462----------------------------------------------------
463
464src/util/win32/dirent.h
465
466Copyright: 2006 Toni Ronkko
467
468
469 Permission is hereby granted, free of charge, to any person obtaining
470 a copy of this software and associated documentation files (the
471 ``Software''), to deal in the Software without restriction, including
472 without limitation the rights to use, copy, modify, merge, publish,
473 distribute, sublicense, and/or sell copies of the Software, and to
474 permit persons to whom the Software is furnished to do so, subject to
475 the following conditions:
476
477 The above copyright notice and this permission notice shall be included
478 in all copies or substantial portions of the Software.
479
462480
463External libraries used by this project:481External libraries used by this project:
464----------------------------------------------------482----------------------------------------------------
465483
=== modified file 'NOTICE.xml'
--- NOTICE.xml 2012-01-11 15:56:57 +0000
+++ NOTICE.xml 2012-03-19 16:17:13 +0000
@@ -423,6 +423,22 @@
423 without express or implied warranty.423 without express or implied warranty.
424 </foreign-notice>424 </foreign-notice>
425 </foreign-files>425 </foreign-files>
426 <foreign-files>
427 <file>src/util/win32/dirent.h</file>
428 <copyright>2006 Toni Ronkko</copyright>
429 <foreign-notice>
430 Permission is hereby granted, free of charge, to any person obtaining
431 a copy of this software and associated documentation files (the
432 ``Software''), to deal in the Software without restriction, including
433 without limitation the rights to use, copy, modify, merge, publish,
434 distribute, sublicense, and/or sell copies of the Software, and to
435 permit persons to whom the Software is furnished to do so, subject to
436 the following conditions:
437
438 The above copyright notice and this permission notice shall be included
439 in all copies or substantial portions of the Software.
440 </foreign-notice>
441 </foreign-files>
426442
427 <external-lib mandatory="true">443 <external-lib mandatory="true">
428 <name>LIBXML2</name>444 <name>LIBXML2</name>
429445
=== modified file 'bin/path_util.cpp'
--- bin/path_util.cpp 2012-01-11 15:56:57 +0000
+++ bin/path_util.cpp 2012-03-19 16:17:13 +0000
@@ -49,7 +49,7 @@
49}49}
5050
5151
52static void52void
53tokenizePath(53tokenizePath(
54 const std::string& aPathStr,54 const std::string& aPathStr,
55 std::vector<String>& aResult)55 std::vector<String>& aResult)
@@ -66,6 +66,23 @@
66 }66 }
67}67}
6868
69
70String
71concatenatePaths( const std::vector<String>& aPathList)
72{
73 String delimiter(filesystem_path::get_path_separator());
74
75 String lResult;
76 for (std::vector<String>::const_iterator lIter = aPathList.begin();
77 lIter != aPathList.end(); ++lIter)
78 {
79 lResult += delimiter + *lIter;
80 }
81
82 return lResult;
83}
84
85
69void86void
70setPathsOnContext(87setPathsOnContext(
71 const ZorbaCMDProperties& aProperties,88 const ZorbaCMDProperties& aProperties,
@@ -101,8 +118,8 @@
101 // Compute and set lib path118 // Compute and set lib path
102 aProperties.getLibPath(lPathStr);119 aProperties.getLibPath(lPathStr);
103 tokenizePath(lPathStr, lPath);120 tokenizePath(lPathStr, lPath);
121 lPath.push_back(lCWD.get_path());
104 lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");122 lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
105 lPath.push_back(lCWD.get_path());
106 tokenizePath(lEnvStr, lPath);123 tokenizePath(lEnvStr, lPath);
107 aStaticCtx->setLibPath(lPath);124 aStaticCtx->setLibPath(lPath);
108 }125 }
109126
=== modified file 'bin/path_util.h'
--- bin/path_util.h 2012-01-11 15:56:57 +0000
+++ bin/path_util.h 2012-03-19 16:17:13 +0000
@@ -32,6 +32,12 @@
32 setPathsOnContext(const ZorbaCMDProperties& aProperties,32 setPathsOnContext(const ZorbaCMDProperties& aProperties,
33 zorba::StaticContext_t& aStaticCtx);33 zorba::StaticContext_t& aStaticCtx);
3434
35 void
36 tokenizePath(const std::string& aPathStr, std::vector<String>& aResult);
37
38
39 String
40 concatenatePaths( const std::vector<String>& aPathList);
3541
36 }42 }
37} /* namespace zorba */43} /* namespace zorba */
3844
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp 2012-03-14 15:28:15 +0000
+++ bin/zorbacmd.cpp 2012-03-19 16:17:13 +0000
@@ -787,6 +787,14 @@
787 return 3;787 return 3;
788 }788 }
789789
790 // Add command line --classpath option in front of config/env CLASSPATH
791 Properties* globalProperties = Properties::instance();
792 std::string cmdJvmClassPath;
793 lProperties.getJVMClassPath(cmdJvmClassPath);
794 std::string configJvmClassPath;
795 globalProperties->getJVMClassPath(configJvmClassPath);
796 globalProperties->setJVMClassPath(cmdJvmClassPath +
797 filesystem_path::get_path_separator() + configJvmClassPath);
790798
791 // Start the engine799 // Start the engine
792800
793801
=== modified file 'bin/zorbacmdproperties.cpp'
--- bin/zorbacmdproperties.cpp 2012-01-11 15:56:57 +0000
+++ bin/zorbacmdproperties.cpp 2012-03-19 16:17:13 +0000
@@ -181,6 +181,11 @@
181 aPath = theLibPath;181 aPath = theLibPath;
182}182}
183183
184void ZorbaCMDProperties::getJVMClassPath(std::string& aPath) const
185{
186 aPath = theClasspath;
187}
188
184std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const189std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const
185{190{
186 std::vector<std::pair<std::string,std::string> > lResult;191 std::vector<std::pair<std::string,std::string> > lResult;
187192
=== modified file 'bin/zorbacmdproperties.h'
--- bin/zorbacmdproperties.h 2012-01-11 15:56:57 +0000
+++ bin/zorbacmdproperties.h 2012-03-19 16:17:13 +0000
@@ -92,6 +92,9 @@
92 void92 void
93 getLibPath(std::string&) const;93 getLibPath(std::string&) const;
9494
95 void
96 getJVMClassPath(std::string&) const;
97
95 bool isDebug(){ return theDebug; }98 bool isDebug(){ return theDebug; }
9699
97 bool hasNoLogo(){ return theNoLogo; }100 bool hasNoLogo(){ return theNoLogo; }
98101
=== modified file 'bin/zorbacmdproperties.txt'
--- bin/zorbacmdproperties.txt 2012-02-29 11:10:30 +0000
+++ bin/zorbacmdproperties.txt 2012-03-19 16:17:13 +0000
@@ -31,6 +31,7 @@
31("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.")31("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.")
32("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")32("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
33("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")33("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
34("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
34("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").35("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").
35("trailing-nl", "Output a trailing newline after the result of the query.")36("trailing-nl", "Output a trailing newline after the result of the query.")
36("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")37("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
3738
=== modified file 'bin/zorbacmdproperties_base.h'
--- bin/zorbacmdproperties_base.h 2012-02-29 11:10:30 +0000
+++ bin/zorbacmdproperties_base.h 2012-03-19 16:17:13 +0000
@@ -15,13 +15,6 @@
15 */15 */
16/* vim:set et sw=2 ts=2: */16/* vim:set et sw=2 ts=2: */
1717
18// ******************************************
19// * *
20// * THIS IS A GENERATED FILE. DO NOT EDIT! *
21// * SEE .txt FILE WITH SAME NAME *
22// * *
23// ******************************************
24
25#include <string>18#include <string>
26#include <sstream>19#include <sstream>
27#include <zorba/config.h>20#include <zorba/config.h>
@@ -30,13 +23,29 @@
3023
31#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE24#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
32#define ZORBACMD_ZORBACMDPROPERTIESBASE25#define ZORBACMD_ZORBACMDPROPERTIESBASE
33namespace zorbacmd { 26namespace zorbacmd
34class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {27{
28
29class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase
30{
35protected:31protected:
36 const char **get_all_options () const {32 const char **get_all_options () const
37 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", "--compile-plan", "--execute-plan", NULL };33 {
34 static const char *result [] = {
35 "--timing", "--output-file", "--serialization-parameter",
36 "--serialize-html", "--serialize-text", "--indent", "--print-query",
37 "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration",
38 "--base-uri", "--boundary-space", "--default-collation",
39 "--construction-mode", "--ordering-mode", "--multiple", "--query",
40 "--as-files", "--external-variable", "--context-item",
41 "--optimization-level", "--lib-module", "--parse-only", "--compile-only",
42 "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo",
43 "--timeout", "--uri-path", "--lib-path", "--module-path", "--classpath",
44 "--option", "--trailing-nl", "--stop-words", "--thesaurus",
45 "--compile-plan", "--execute-plan", NULL };
38 return result;46 return result;
39 }47 }
48
40 bool theTiming;49 bool theTiming;
41 std::string theOutputFile;50 std::string theOutputFile;
42 std::vector<std::string> theSerializationParameter;51 std::vector<std::string> theSerializationParameter;
@@ -70,6 +79,7 @@
70 std::string theUriPath;79 std::string theUriPath;
71 std::string theLibPath;80 std::string theLibPath;
72 std::string theModulePath;81 std::string theModulePath;
82 std::string theClasspath;
73 std::vector<std::string> theOption;83 std::vector<std::string> theOption;
74 bool theTrailingNl;84 bool theTrailingNl;
75 std::vector<std::string> theStopWords;85 std::vector<std::string> theStopWords;
@@ -136,6 +146,7 @@
136 const std::string &uriPath () const { return theUriPath; }146 const std::string &uriPath () const { return theUriPath; }
137 const std::string &libPath () const { return theLibPath; }147 const std::string &libPath () const { return theLibPath; }
138 const std::string &modulePath () const { return theModulePath; }148 const std::string &modulePath () const { return theModulePath; }
149 const std::string &classpath () const { return theClasspath; }
139 const std::vector<std::string> &option () const { return theOption; }150 const std::vector<std::string> &option () const { return theOption; }
140 const bool &trailingNl () const { return theTrailingNl; }151 const bool &trailingNl () const { return theTrailingNl; }
141 const std::vector<std::string> &stopWords () const { return theStopWords; }152 const std::vector<std::string> &stopWords () const { return theStopWords; }
@@ -158,12 +169,16 @@
158 else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) {169 else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) {
159 int d = 2;170 int d = 2;
160 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }171 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
161 if (*argv == NULL) { result = "No value given for --output-file option"; break; } init_val (*argv, theOutputFile, d);172 if (*argv == NULL) { result = "No value given for --output-file option"; break; }
173
174 init_val (*argv, theOutputFile, d);
162 }175 }
163 else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) {176 else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) {
164 int d = 2;177 int d = 2;
165 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }178 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
166 if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; } init_val (*argv, theSerializationParameter, d);179 if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }
180
181 init_val (*argv, theSerializationParameter, d);
167 }182 }
168 else if (strcmp (*argv, "--serialize-html") == 0) {183 else if (strcmp (*argv, "--serialize-html") == 0) {
169 theSerializeHtml = true;184 theSerializeHtml = true;
@@ -189,37 +204,51 @@
189 else if (strcmp (*argv, "--base-uri") == 0) {204 else if (strcmp (*argv, "--base-uri") == 0) {
190 int d = 2;205 int d = 2;
191 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }206 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
192 if (*argv == NULL) { result = "No value given for --base-uri option"; break; } init_val (*argv, theBaseUri, d);207 if (*argv == NULL) { result = "No value given for --base-uri option"; break; }
208
209 init_val (*argv, theBaseUri, d);
193 }210 }
194 else if (strcmp (*argv, "--boundary-space") == 0) {211 else if (strcmp (*argv, "--boundary-space") == 0) {
195 int d = 2;212 int d = 2;
196 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }213 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
197 if (*argv == NULL) { result = "No value given for --boundary-space option"; break; } init_val (*argv, theBoundarySpace, d);214 if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }
215
216 init_val (*argv, theBoundarySpace, d);
198 }217 }
199 else if (strcmp (*argv, "--default-collation") == 0) {218 else if (strcmp (*argv, "--default-collation") == 0) {
200 int d = 2;219 int d = 2;
201 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }220 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
202 if (*argv == NULL) { result = "No value given for --default-collation option"; break; } init_val (*argv, theDefaultCollation, d);221 if (*argv == NULL) { result = "No value given for --default-collation option"; break; }
222
223 init_val (*argv, theDefaultCollation, d);
203 }224 }
204 else if (strcmp (*argv, "--construction-mode") == 0) {225 else if (strcmp (*argv, "--construction-mode") == 0) {
205 int d = 2;226 int d = 2;
206 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }227 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
207 if (*argv == NULL) { result = "No value given for --construction-mode option"; break; } init_val (*argv, theConstructionMode, d);228 if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }
229
230 init_val (*argv, theConstructionMode, d);
208 }231 }
209 else if (strcmp (*argv, "--ordering-mode") == 0) {232 else if (strcmp (*argv, "--ordering-mode") == 0) {
210 int d = 2;233 int d = 2;
211 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }234 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
212 if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; } init_val (*argv, theOrderingMode, d);235 if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }
236
237 init_val (*argv, theOrderingMode, d);
213 }238 }
214 else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) {239 else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) {
215 int d = 2;240 int d = 2;
216 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }241 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
217 if (*argv == NULL) { result = "No value given for --multiple option"; break; } init_val (*argv, theMultiple, d);242 if (*argv == NULL) { result = "No value given for --multiple option"; break; }
243
244 init_val (*argv, theMultiple, d);
218 }245 }
219 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) {246 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) {
220 int d = 2;247 int d = 2;
221 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }248 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
222 if (*argv == NULL) { result = "No value given for --query option"; break; } init_val (*argv, theQueriesOrFiles, d);249 if (*argv == NULL) { result = "No value given for --query option"; break; }
250
251 init_val (*argv, theQueriesOrFiles, d);
223 }252 }
224 else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) {253 else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) {
225 theAsFiles = true;254 theAsFiles = true;
@@ -227,17 +256,23 @@
227 else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) {256 else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) {
228 int d = 2;257 int d = 2;
229 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }258 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
230 if (*argv == NULL) { result = "No value given for --external-variable option"; break; } init_val (*argv, theExternalVariable, d);259 if (*argv == NULL) { result = "No value given for --external-variable option"; break; }
260
261 init_val (*argv, theExternalVariable, d);
231 }262 }
232 else if (strcmp (*argv, "--context-item") == 0) {263 else if (strcmp (*argv, "--context-item") == 0) {
233 int d = 2;264 int d = 2;
234 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }265 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
235 if (*argv == NULL) { result = "No value given for --context-item option"; break; } init_val (*argv, theContextItem, d);266 if (*argv == NULL) { result = "No value given for --context-item option"; break; }
267
268 init_val (*argv, theContextItem, d);
236 }269 }
237 else if (strcmp (*argv, "--optimization-level") == 0) {270 else if (strcmp (*argv, "--optimization-level") == 0) {
238 int d = 2;271 int d = 2;
239 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
240 if (*argv == NULL) { result = "No value given for --optimization-level option"; break; } init_val (*argv, theOptimizationLevel, d);273 if (*argv == NULL) { result = "No value given for --optimization-level option"; break; }
274
275 init_val (*argv, theOptimizationLevel, d);
241 }276 }
242 else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) {277 else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) {
243 theLibModule = true;278 theLibModule = true;
@@ -257,12 +292,16 @@
257 else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) {292 else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) {
258 int d = 2;293 int d = 2;
259 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }294 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
260 if (*argv == NULL) { result = "No value given for --debug-host option"; break; } init_val (*argv, theDebugHost, d);295 if (*argv == NULL) { result = "No value given for --debug-host option"; break; }
296
297 init_val (*argv, theDebugHost, d);
261 }298 }
262 else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) {299 else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) {
263 int d = 2;300 int d = 2;
264 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }301 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
265 if (*argv == NULL) { result = "No value given for --debug-port option"; break; } init_val (*argv, theDebugPort, d);302 if (*argv == NULL) { result = "No value given for --debug-port option"; break; }
303
304 init_val (*argv, theDebugPort, d);
266 }305 }
267 else if (strcmp (*argv, "--no-logo") == 0) {306 else if (strcmp (*argv, "--no-logo") == 0) {
268 theNoLogo = true;307 theNoLogo = true;
@@ -270,27 +309,44 @@
270 else if (strcmp (*argv, "--timeout") == 0) {309 else if (strcmp (*argv, "--timeout") == 0) {
271 int d = 2;310 int d = 2;
272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }311 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
273 if (*argv == NULL) { result = "No value given for --timeout option"; break; } init_val (*argv, theTimeout, d);312 if (*argv == NULL) { result = "No value given for --timeout option"; break; }
313
314 init_val (*argv, theTimeout, d);
274 }315 }
275 else if (strcmp (*argv, "--uri-path") == 0) {316 else if (strcmp (*argv, "--uri-path") == 0) {
276 int d = 2;317 int d = 2;
277 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }318 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
278 if (*argv == NULL) { result = "No value given for --uri-path option"; break; } init_val (*argv, theUriPath, d);319 if (*argv == NULL) { result = "No value given for --uri-path option"; break; }
320
321 init_val (*argv, theUriPath, d);
279 }322 }
280 else if (strcmp (*argv, "--lib-path") == 0) {323 else if (strcmp (*argv, "--lib-path") == 0) {
281 int d = 2;324 int d = 2;
282 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }325 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
283 if (*argv == NULL) { result = "No value given for --lib-path option"; break; } init_val (*argv, theLibPath, d);326 if (*argv == NULL) { result = "No value given for --lib-path option"; break; }
327
328 init_val (*argv, theLibPath, d);
284 }329 }
285 else if (strcmp (*argv, "--module-path") == 0) {330 else if (strcmp (*argv, "--module-path") == 0) {
286 int d = 2;331 int d = 2;
287 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }332 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
288 if (*argv == NULL) { result = "No value given for --module-path option"; break; } init_val (*argv, theModulePath, d);333 if (*argv == NULL) { result = "No value given for --module-path option"; break; }
334
335 init_val (*argv, theModulePath, d);
336 }
337 else if (strcmp (*argv, "--classpath") == 0) {
338 int d = 2;
339 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
340 if (*argv == NULL) { result = "No value given for --classpath option"; break; }
341
342 init_val (*argv, theClasspath, d);
289 }343 }
290 else if (strcmp (*argv, "--option") == 0) {344 else if (strcmp (*argv, "--option") == 0) {
291 int d = 2;345 int d = 2;
292 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }346 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
293 if (*argv == NULL) { result = "No value given for --option option"; break; } init_val (*argv, theOption, d);347 if (*argv == NULL) { result = "No value given for --option option"; break; }
348
349 init_val (*argv, theOption, d);
294 }350 }
295 else if (strcmp (*argv, "--trailing-nl") == 0) {351 else if (strcmp (*argv, "--trailing-nl") == 0) {
296 theTrailingNl = true;352 theTrailingNl = true;
@@ -298,12 +354,16 @@
298 else if (strcmp (*argv, "--stop-words") == 0) {354 else if (strcmp (*argv, "--stop-words") == 0) {
299 int d = 2;355 int d = 2;
300 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }356 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
301 if (*argv == NULL) { result = "No value given for --stop-words option"; break; } init_val (*argv, theStopWords, d);357 if (*argv == NULL) { result = "No value given for --stop-words option"; break; }
358
359 init_val (*argv, theStopWords, d);
302 }360 }
303 else if (strcmp (*argv, "--thesaurus") == 0) {361 else if (strcmp (*argv, "--thesaurus") == 0) {
304 int d = 2;362 int d = 2;
305 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }363 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
306 if (*argv == NULL) { result = "No value given for --thesaurus option"; break; } init_val (*argv, theThesaurus, d);364 if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }
365
366 init_val (*argv, theThesaurus, d);
307 }367 }
308 else if (strcmp (*argv, "--compile-plan") == 0 || strncmp (*argv, "-c", 2) == 0) {368 else if (strcmp (*argv, "--compile-plan") == 0 || strncmp (*argv, "-c", 2) == 0) {
309 theCompilePlan = true;369 theCompilePlan = true;
@@ -327,46 +387,47 @@
327387
328 const char *get_help_msg () const {388 const char *get_help_msg () const {
329 return389 return
330"--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"390 "--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
331"--output-file, -o\nWrite the result to the given file.\n\n"391 "--output-file, -o\nWrite the result to the given file.\n\n"
332"--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"392 "--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
333"--serialize-html\nSerialize the result as HTML.\n\n"393 "--serialize-html\nSerialize the result as HTML.\n\n"
334"--serialize-text\nSerialize the result as Text.\n\n"394 "--serialize-text\nSerialize the result as Text.\n\n"
335"--indent, -i\nIndent output.\n\n"395 "--indent, -i\nIndent output.\n\n"
336"--print-query\nPrint the queries.\n\n"396 "--print-query\nPrint the queries.\n\n"
337"--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"397 "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
338"--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"398 "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
339"--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"399 "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
340"--base-uri\nSet the base URI property of the static context.\n\n"400 "--base-uri\nSet the base URI property of the static context.\n\n"
341"--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"401 "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
342"--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"402 "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
343"--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"403 "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
344"--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"404 "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
345"--multiple, -m\nExecute the given queries multiple times.\n\n"405 "--multiple, -m\nExecute the given queries multiple times.\n\n"
346"--query, -q\nQuery test or file URI (file://...)\n\n"406 "--query, -q\nQuery test or file URI (file://...)\n\n"
347"--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"407 "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"
348"--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"408 "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
349"--context-item\nSet the context item to the XML document in a given file.\n\n"409 "--context-item\nSet the context item to the XML document in a given file.\n\n"
350"--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"410 "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
351"--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"411 "--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
352"--parse-only\nStop after parsing the query.\n\n"412 "--parse-only\nStop after parsing the query.\n\n"
353"--compile-only\nOnly compile (don't execute)\n\n"413 "--compile-only\nOnly compile (don't execute)\n\n"
354"--no-serializer\nDo not serialize (discard) result.\n\n"414 "--no-serializer\nDo not serialize (discard) result.\n\n"
355"--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"415 "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
356"--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"416 "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
357"--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"417 "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
358"--no-logo\nPrint no logo when starting.\n\n"418 "--no-logo\nPrint no logo when starting.\n\n"
359"--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"419 "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
360"--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"420 "--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"
361"--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"421 "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
362"--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"422 "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
363"--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"423 "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
364"--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"424 "--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"
365"--stop-words\nMapping specifying a stop-words URI to another.\n\n"425 "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
366"--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"426 "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
367"--compile-plan, -c\nOutput the query plan as binary.\n\n"427 "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
368"--execute-plan\nTake a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.\n\n"428 "--compile-plan, -c\nOutput the query plan as binary.\n\n"
369;429 "--execute-plan\nTake a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.\n\n"
430 ;
370 }431 }
371432
372 static const ZorbaCMDPropertiesBase *instance () {433 static const ZorbaCMDPropertiesBase *instance () {
373434
=== modified file 'cmake_modules/ZorbaModule.cmake'
--- cmake_modules/ZorbaModule.cmake 2012-02-23 16:48:01 +0000
+++ cmake_modules/ZorbaModule.cmake 2012-03-19 16:17:13 +0000
@@ -140,7 +140,6 @@
140 ENDIF (NOT IS_ABSOLUTE "${MODULE_FILE}")140 ENDIF (NOT IS_ABSOLUTE "${MODULE_FILE}")
141 GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)141 GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)
142142
143
144 MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename)143 MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename)
145144
146 # Compute a CMake-symbol-safe version of the target URI, for storing145 # Compute a CMake-symbol-safe version of the target URI, for storing
@@ -314,7 +313,7 @@
314 ENDIF (MODULE_VERSION)313 ENDIF (MODULE_VERSION)
315 FOREACH (version_infix "" ${version_infixes})314 FOREACH (version_infix "" ${version_infixes})
316 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"315 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"
317 "${version_infix}" "" "${MODULE_TEST_ONLY}")316 "${version_infix}" "" 1 "${MODULE_TEST_ONLY}")
318 ENDFOREACH (version_infix)317 ENDFOREACH (version_infix)
319318
320 # Also copy the dynamic library from the location it was built.319 # Also copy the dynamic library from the location it was built.
@@ -322,7 +321,7 @@
322 GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION)321 GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION)
323 GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME)322 GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME)
324 ADD_COPY_RULE ("LIB" "${lib_location}" "${module_path}/${lib_filename}"323 ADD_COPY_RULE ("LIB" "${lib_location}" "${module_path}/${lib_filename}"
325 "" "${module_lib_target}" "${MODULE_TEST_ONLY}")324 "" "${module_lib_target}" 0 "${MODULE_TEST_ONLY}")
326 ENDIF (module_lib_target)325 ENDIF (module_lib_target)
327326
328 # Last but not least, whip up a test case that ensures the module327 # Last but not least, whip up a test case that ensures the module
@@ -375,7 +374,7 @@
375 ENDIF (NOT SCHEMA_TEST_ONLY)374 ENDIF (NOT SCHEMA_TEST_ONLY)
376375
377 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"376 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"
378 "" "" "${SCHEMA_TEST_ONLY}")377 "" "" 1 "${SCHEMA_TEST_ONLY}")
379378
380ENDMACRO (DECLARE_ZORBA_SCHEMA)379ENDMACRO (DECLARE_ZORBA_SCHEMA)
381380
@@ -407,25 +406,70 @@
407 MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename)406 MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename)
408407
409 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}"408 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}"
410 "" "" "${URI_FILE_TEST_ONLY}")409 "" "" 1 "${URI_FILE_TEST_ONLY}")
411410
412ENDMACRO (DECLARE_ZORBA_URI_FILE)411ENDMACRO (DECLARE_ZORBA_URI_FILE)
413412
413
414# Inform Zorba of a .jar file that should be made available on the CLASSPATH
415# of the JVM, should the JVM be started. QQQ more doc needed
416#
417# Args: FILE - path to file (must be absolute)
418# EXTERNAL - (optional) FILE specifies a path that should be added
419# to CLASSPATH as-is
420# TEST_ONLY - (optional) Jar file is for testcases only and should not
421# be installed
422MACRO (DECLARE_ZORBA_JAR)
423 PARSE_ARGUMENTS (JAR "FILE" "" "TEST_ONLY;EXTERNAL" ${ARGN})
424 IF (NOT JAR_FILE)
425 MESSAGE (FATAL_ERROR "'FILE' argument is required for DECLARE_ZORBA_JAR")
426 ENDIF (NOT JAR_FILE)
427
428 # Initialize classpath file and set up copy rule (once per project)
429 SET (_CP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-classpath.txt")
430 GET_PROPERTY (_known_project GLOBAL PROPERTY "${PROJECT_NAME}-jars")
431 IF (NOT _known_project)
432 FILE (REMOVE "${_CP_FILE}")
433 SET_PROPERTY (GLOBAL PROPERTY "${PROJECT_NAME}-jars" 1)
434 ADD_COPY_RULE ("LIB" "${_CP_FILE}" "jars/${PROJECT_NAME}-classpath.txt"
435 "" "" 1 "${JAR_TEST_ONLY}")
436 ENDIF (NOT _known_project)
437
438 # Iterate over all supplied jar files
439 FOREACH (_jar_file ${JAR_FILE})
440
441 IF (JAR_EXTERNAL)
442 # Put absolute path into classpath file
443 FILE (APPEND "${_CP_FILE}" "${_jar_file}\n")
444 ELSE (JAR_EXTERNAL)
445 # Copy jar to jars/ directory and add relative path to classpath file
446 GET_FILENAME_COMPONENT (_output_filename "${_jar_file}" NAME)
447 ADD_COPY_RULE ("LIB" "${_jar_file}" "jars/${_output_filename}" "" ""
448 1 "${JAR_TEST_ONLY}")
449 FILE (APPEND "${_CP_FILE}" "${_output_filename}\n")
450 ENDIF (JAR_EXTERNAL)
451
452 ENDFOREACH (_jar_file)
453ENDMACRO (DECLARE_ZORBA_JAR)
454
455
414# Utility macro for setting up a build rule to copy a file to a456# Utility macro for setting up a build rule to copy a file to a
415# particular (possibly versioned) file in a shared directory if such a file has457# particular (possibly versioned) file in a shared directory if such a
416# not already been output.458# file has not already been output.
459#
417# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared460# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared
418# directory to place output in (URI_PATH or LIB_PATH). Also, "URI" files461# directory to place output in (URI_PATH or LIB_PATH).
419# will have an INSTALL() directive to put them in the install image.
420# INPUT_FILE: Absolute path to file to copy.462# INPUT_FILE: Absolute path to file to copy.
421# OUTPUT_FILE: Relative path to output file (relative to URI_PATH).463# OUTPUT_FILE: Relative path to output file (relative to URI_PATH).
422# VERSION_ARG: Version; may be "" for non-versioned files.464# VERSION_ARG: Version; may be "" for non-versioned files.
423# DEPEND_TARGET: A CMake target name upon which the copy rule should depend;465# DEPEND_TARGET: A CMake target name upon which the copy rule should depend;
424# may be "".466# may be "".
467# INSTALL: If 1, an INSTALL() directive will be executed to put the
468# file into the install image.
425# TEST_ONLY: If 1, file is for testcases only; will be copied into469# TEST_ONLY: If 1, file is for testcases only; will be copied into
426# TEST_URI_PATH/TEST_LIB_PATH and will not be installed470# TEST_URI_PATH/TEST_LIB_PATH and will not be installed.
427MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG471MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG
428 DEPEND_TARGET TEST_ONLY)472 DEPEND_TARGET INSTALL TEST_ONLY)
429 # Choose output base directory473 # Choose output base directory
430 IF (${TEST_ONLY} EQUAL 1)474 IF (${TEST_ONLY} EQUAL 1)
431 SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")475 SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")
@@ -470,13 +514,13 @@
470 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES514 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES
471 "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")515 "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")
472516
473 # Also set up an INSTALL rule (unless TEST_ONLY or LIB).517 # Also set up an INSTALL rule (unless TEST_ONLY).
474 IF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) )518 IF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
475 519
476 IF(NOT _is_core)520 IF(NOT _is_core)
477 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME}) 521 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME})
478 INSTALL (FILES "${INPUT_FILE}"522 INSTALL (FILES "${INPUT_FILE}"
479 DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}"523 DESTINATION "${ZORBA_NONCORE_${FILE_TYPE}_DIR}/${_output_path}"
480 RENAME "${_output_filename}"524 RENAME "${_output_filename}"
481 COMPONENT "${component_name}")525 COMPONENT "${component_name}")
482 526
@@ -496,11 +540,11 @@
496 540
497 ELSE(NOT _is_core)541 ELSE(NOT _is_core)
498 INSTALL (FILES "${INPUT_FILE}"542 INSTALL (FILES "${INPUT_FILE}"
499 DESTINATION "${ZORBA_CORE_URI_DIR}/${_output_path}"543 DESTINATION "${ZORBA_CORE_${FILE_TYPE}_DIR}/${_output_path}"
500 RENAME "${_output_filename}")544 RENAME "${_output_filename}")
501 ENDIF(NOT _is_core)545 ENDIF(NOT _is_core)
502 546
503 ENDIF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) )547 ENDIF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
504 ENDIF (file_found EQUAL -1)548 ENDIF (file_found EQUAL -1)
505ENDMACRO (ADD_COPY_RULE)549ENDMACRO (ADD_COPY_RULE)
506550
507551
=== modified file 'include/zorba/properties_base.h'
--- include/zorba/properties_base.h 2012-01-11 15:56:57 +0000
+++ include/zorba/properties_base.h 2012-03-19 16:17:13 +0000
@@ -101,8 +101,44 @@
101 std::vector<std::string>& val,101 std::vector<std::string>& val,
102 unsigned delta);102 unsigned delta);
103103
104/**
105 * \brief This class provides access to global properties.
106 *
107 * This class provides access to global properties set for Zorba in environment
108 * and configuration file.
109 * It is available using Zorba.getProperties() method.
110 * \see { Zorba::getProperties() }
111 */
112class ZORBA_DLL_PUBLIC PropertiesGlobal : public PropertiesBase
113{
114public:
115 virtual ~PropertiesGlobal() {}
116
117 /**
118 * \brief Get global JVM classpath property.
119 *
120 * Before the JVM is started this will return the classpath set by
121 * command line option, the CLASSPATH environment variable and in Zorba
122 * config file.
123 *
124 * After the JVM is started this will contain in addition the paths to jars
125 * used by modules that make use of the JVM.
126 */
127 virtual void getJVMClassPath(std::string & jvmClasspath) {}
128
129 /**
130 * \brief Set global JVM classpath property.
131 *
132 * This method should be used to set additional JVM classpath for modules
133 * that make use of JVM. This will overide the classpath set by CLASSPATH
134 * environment variable or Zorba config file.
135 *
136 * Once the JVM is started this method doesn't have any effect.
137 */
138 virtual void setJVMClassPath(const std::string & jvmClasspath) {}
139};
140
104}141}
105
106#endif // ZORBA_PROPERTIES_BASE_H142#endif // ZORBA_PROPERTIES_BASE_H
107/*143/*
108 * Local variables:144 * Local variables:
109145
=== modified file 'include/zorba/util/file.h'
--- include/zorba/util/file.h 2012-01-11 15:56:57 +0000
+++ include/zorba/util/file.h 2012-03-19 16:17:13 +0000
@@ -24,6 +24,7 @@
24#include <cstdio>24#include <cstdio>
25#include <string>25#include <string>
26#include <time.h>26#include <time.h>
27#include <vector>
2728
28#include <zorba/config.h>29#include <zorba/config.h>
29#include <zorba/file.h>30#include <zorba/file.h>
@@ -84,6 +85,7 @@
84 void mkdir();85 void mkdir();
85 void deep_mkdir();86 void deep_mkdir();
86 void rmdir(bool ignore = true);87 void rmdir(bool ignore = true);
88 void lsdir(std::vector<std::string> &list);
87#ifndef _WIN32_WCE89#ifndef _WIN32_WCE
88 void chdir();90 void chdir();
89#endif91#endif
9092
=== modified file 'include/zorba/zorba.h'
--- include/zorba/zorba.h 2012-01-11 15:56:57 +0000
+++ include/zorba/zorba.h 2012-03-19 16:17:13 +0000
@@ -34,14 +34,18 @@
34#include <zorba/xquery.h>34#include <zorba/xquery.h>
35#include <zorba/zorba_string.h>35#include <zorba/zorba_string.h>
36#include <zorba/iterator.h>36#include <zorba/iterator.h>
37#include <zorba/properties_base.h>
3738
38namespace zorba {39namespace zorba {
3940
40/**41/**
41 * The Zorba class is the single point of access to the %Zorba engine.42 * The Zorba class is the single point of access to the %Zorba engine.
42 * There exists one instance of the Zorba class per process.43 * There exists one instance of the Zorba class per process.
43 * It can be used to (1) create and compile queries, (2) create static contexts,44 * It can be used to (1) create and compile queries,
44 * (3) provides access to the XmlDataManager, and (4) provides access to the ItemFactory.45 * (2) create static contexts,
46 * (3) provides access to the XmlDataManager,
47 * (4) provides access to the ItemFactory, and
48 * (5) provides access to the PropertiesGlobal.
45 */49 */
46class ZORBA_DLL_PUBLIC Zorba50class ZORBA_DLL_PUBLIC Zorba
47{51{
@@ -301,7 +305,7 @@
301 virtual StaticContext_t305 virtual StaticContext_t
302 createStaticContext(DiagnosticHandler* aDiagnosticHandler = 0) = 0;306 createStaticContext(DiagnosticHandler* aDiagnosticHandler = 0) = 0;
303307
304 /** \brief Gets the singelton instance of the ItemFactory.308 /** \brief Gets the singleton instance of the ItemFactory.
305 *309 *
306 * @return ItemFactory the singleton instance of the ItemFactory.310 * @return ItemFactory the singleton instance of the ItemFactory.
307 */311 */
@@ -310,18 +314,24 @@
310314
311 /** \brief Gets the singleton instance of the XmlDataManager object.315 /** \brief Gets the singleton instance of the XmlDataManager object.
312 *316 *
313 * @return XmlDataManager the singelton instance of the XmlDataManager.317 * @return XmlDataManager the singleton instance of the XmlDataManager.
314 */318 */
315 virtual XmlDataManager*319 virtual XmlDataManager*
316 getXmlDataManager() = 0;320 getXmlDataManager() = 0;
317321
318 /** \brief Gets the singleton instance of Zorba's audit provider object.322 /** \brief Gets the singleton instance of Zorba's audit provider object.
319 *323 *
320 * @return audit::Provider the singelton instance of Zorba's audit provider.324 * @return audit::Provider the singeleton instance of Zorba's audit provider.
321 */325 */
322 virtual audit::Provider*326 virtual audit::Provider*
323 getAuditProvider() = 0;327 getAuditProvider() = 0;
324328
329 /** \brief Gets the singleton instance of Zorba's properties object.
330 *
331 * @return zorba::Properties the singleton instance of Zorba's properties object.
332 */
333 virtual PropertiesGlobal* getPropertiesGlobal() = 0;
334
325}; /* class Zorba */335}; /* class Zorba */
326336
327337
328338
=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h 2012-02-29 11:10:30 +0000
+++ src/api/staticcontextimpl.h 2012-03-19 16:17:13 +0000
@@ -281,6 +281,7 @@
281 virtual void281 virtual void
282 getFullLibPath(std::vector<String>& aLibPath) const;282 getFullLibPath(std::vector<String>& aLibPath) const;
283283
284
284protected:285protected:
285 String286 String
286 createInvokeQuery(const Function_t&, size_t aArity) const;287 createInvokeQuery(const Function_t&, size_t aArity) const;
287288
=== modified file 'src/api/zorbaimpl.cpp'
--- src/api/zorbaimpl.cpp 2012-01-31 19:47:57 +0000
+++ src/api/zorbaimpl.cpp 2012-03-19 16:17:13 +0000
@@ -35,6 +35,7 @@
35#include "diagnostics/xquery_diagnostics.h"35#include "diagnostics/xquery_diagnostics.h"
3636
37#include "system/globalenv.h"37#include "system/globalenv.h"
38#include "system/properties.h"
3839
39#include "context/static_context.h"40#include "context/static_context.h"
4041
@@ -269,6 +270,15 @@
269}270}
270271
271272
273/*******************************************************************************
274
275********************************************************************************/
276PropertiesGlobal* ZorbaImpl::getPropertiesGlobal()
277{
278 return Properties::instance();
279}
280
281
272void ZorbaImpl::notifyError( DiagnosticHandler *eh, ZorbaException const &ze ) {282void ZorbaImpl::notifyError( DiagnosticHandler *eh, ZorbaException const &ze ) {
273 eh->error( ze );283 eh->error( ze );
274}284}
275285
=== modified file 'src/api/zorbaimpl.h'
--- src/api/zorbaimpl.h 2012-01-11 15:56:57 +0000
+++ src/api/zorbaimpl.h 2012-03-19 16:17:13 +0000
@@ -134,6 +134,8 @@
134134
135 audit::Provider* getAuditProvider();135 audit::Provider* getAuditProvider();
136136
137 PropertiesGlobal* getPropertiesGlobal();
138
137protected:139protected:
138 ZorbaImpl();140 ZorbaImpl();
139141
140142
=== modified file 'src/context/dynamic_loader.cpp'
--- src/context/dynamic_loader.cpp 2012-01-18 13:57:48 +0000
+++ src/context/dynamic_loader.cpp 2012-03-19 16:17:13 +0000
@@ -132,8 +132,15 @@
132ExternalModule*132ExternalModule*
133DynamicLoader::loadModule(const zstring& aFile) const133DynamicLoader::loadModule(const zstring& aFile) const
134{134{
135 // function pointer to create a module135 handle_t handle;
136 ExternalModule* (*createModule)() = NULL;136 std::map<const zstring, handle_t>::const_iterator lIter;
137
138 lIter = theLibraries.find(aFile);
139 if (lIter != theLibraries.end())
140 {
141 handle = lIter->second;
142 return createModule(handle, aFile);
143 }
137144
138#ifdef WIN32145#ifdef WIN32
139 WCHAR wpath_str[1024];146 WCHAR wpath_str[1024];
@@ -146,43 +153,51 @@
146 0, aFile.c_str(), -1,153 0, aFile.c_str(), -1,
147 wpath_str, sizeof(wpath_str)/sizeof(WCHAR));154 wpath_str, sizeof(wpath_str)/sizeof(WCHAR));
148 }155 }
149 HMODULE handle = LoadLibraryW(wpath_str);156
157 handle = LoadLibraryW(wpath_str);
150 if (!handle)158 if (!handle)
151 throw ZORBA_EXCEPTION(159 throw ZORBA_EXCEPTION(
152 zerr::ZOSE0005_DLL_LOAD_FAILED,160 zerr::ZOSE0005_DLL_LOAD_FAILED,
153 ERROR_PARAMS( aFile, os_error::get_err_string() )161 ERROR_PARAMS( aFile, os_error::get_err_string() )
154 );162 );
155163#else
164 handle = dlopen(aFile.c_str(), RTLD_NOW);
165 if (!handle)
166 throw ZORBA_EXCEPTION(
167 zerr::ZOSE0005_DLL_LOAD_FAILED, ERROR_PARAMS( aFile, zstring(dlerror()) )
168 );
169#endif
170
171 theLibraries[aFile] = handle;
172 return createModule(handle, aFile);
173}
174
175
176ExternalModule*
177DynamicLoader::createModule(handle_t handle, const zstring& aFile) const
178{
179 // function pointer to create a module
180 ExternalModule* (*createModuleFunction)() = NULL;
181
182#ifdef WIN32
156 createModule = (ExternalModule* (*)())GetProcAddress(handle, "createModule");183 createModule = (ExternalModule* (*)())GetProcAddress(handle, "createModule");
157 if (createModule == NULL)184 if (createModuleFunction == NULL)
158 throw ZORBA_EXCEPTION(185 throw ZORBA_EXCEPTION(
159 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,186 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
160 ERROR_PARAMS( aFile, os_error::get_err_string() )187 ERROR_PARAMS( aFile, os_error::get_err_string() )
161 );188 );
162
163#else189#else
164 void* handle = dlopen(aFile.c_str(), RTLD_NOW);190 createModuleFunction = (ExternalModule* (*)()) dlsym(handle, "createModule");
165 if (!handle)191 if (createModuleFunction == NULL)
166 throw ZORBA_EXCEPTION(
167 zerr::ZOSE0005_DLL_LOAD_FAILED, ERROR_PARAMS( aFile, zstring(dlerror()) )
168 );
169
170 createModule = (ExternalModule* (*)()) dlsym(handle, "createModule");
171 if (createModule == NULL)
172 {192 {
173 dlclose(handle);193 dlclose(handle);
174 throw ZORBA_EXCEPTION(194 throw ZORBA_EXCEPTION(
175 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,195 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
176 ERROR_PARAMS( aFile, dlerror() )196 ERROR_PARAMS( aFile, dlerror() )
177 );197 );
178 }198 }
179#endif199#endif
180 if (theLibraries.find(handle) == theLibraries.end())200 return createModuleFunction();
181 {
182 theLibraries.insert(handle);
183 }
184
185 return createModule();
186}201}
187202
188203
@@ -193,13 +208,13 @@
193208
194DynamicLoader::~DynamicLoader()209DynamicLoader::~DynamicLoader()
195{210{
196 for (LibrarySet_t::const_iterator lIter = theLibraries.begin();211 for (LibraryMap_t::const_iterator lIter = theLibraries.begin();
197 lIter != theLibraries.end(); ++lIter)212 lIter != theLibraries.end(); ++lIter)
198 {213 {
199#ifdef WIN32214#ifdef WIN32
200 FreeLibrary(*lIter);215 FreeLibrary(lIter->second);
201#else216#else
202 dlclose(*lIter);217 dlclose(lIter->second);
203#endif218#endif
204 }219 }
205}220}
206221
=== modified file 'src/context/dynamic_loader.h'
--- src/context/dynamic_loader.h 2012-01-11 15:56:57 +0000
+++ src/context/dynamic_loader.h 2012-03-19 16:17:13 +0000
@@ -18,7 +18,7 @@
18#define ZORBA_DYNAMIC_LOADER_H18#define ZORBA_DYNAMIC_LOADER_H
1919
20#include "common/common.h"20#include "common/common.h"
21#include <set>21#include <map>
22#include "common/shared_types.h"22#include "common/shared_types.h"
2323
24namespace zorba {24namespace zorba {
@@ -40,15 +40,20 @@
4040
41 ~DynamicLoader();41 ~DynamicLoader();
4242
43 ExternalModule* loadModule(const zstring& aFile) const;
4443
45#ifdef WIN3244#ifdef WIN32
46 typedef std::set<HMODULE> LibrarySet_t;45 typedef HMODULE handle_t;
47#else46#else
48 typedef std::set<void*> LibrarySet_t;47 typedef void * handle_t;
49#endif48#endif
5049
51 mutable LibrarySet_t theLibraries;50 ExternalModule* loadModule(const zstring& aFile) const;
51 ExternalModule* createModule(handle_t handle, const zstring& aFile) const;
52
53
54 typedef std::map<const zstring, handle_t> LibraryMap_t;
55
56 mutable LibraryMap_t theLibraries;
52};57};
5358
54} /* namespace zorba */59} /* namespace zorba */
5560
=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp 2012-03-15 15:27:46 +0000
+++ src/context/static_context.cpp 2012-03-19 16:17:13 +0000
@@ -1699,6 +1699,43 @@
1699}1699}
17001700
17011701
1702////////////////////////////////////////////////////////////////////////////////
1703// //
1704// JVM Classpath //
1705// //
1706////////////////////////////////////////////////////////////////////////////////
1707
1708/*******************************************************************************
1709
1710********************************************************************************/
1711void static_context::set_jvm_class_path(const std::vector<zstring>& path)
1712{
1713 theJVMClassPath = path;
1714}
1715
1716
1717/*******************************************************************************
1718
1719********************************************************************************/
1720void static_context::get_jvm_class_path(std::vector<zstring>& path) const
1721{
1722 path.insert(path.end(), theJVMClassPath.begin(), theJVMClassPath.end());
1723}
1724
1725/*******************************************************************************
1726
1727********************************************************************************/
1728void static_context::get_full_jvm_class_path(std::vector<zstring>& path) const
1729{
1730 if (theParent != NULL)
1731 {
1732 theParent->get_full_jvm_class_path(path);
1733 }
1734
1735 get_jvm_class_path(path);
1736}
1737
1738
1702/////////////////////////////////////////////////////////////////////////////////1739/////////////////////////////////////////////////////////////////////////////////
1703// //1740// //
1704// Validating Items //1741// Validating Items //
17051742
=== modified file 'src/context/static_context.h'
--- src/context/static_context.h 2012-03-14 15:28:15 +0000
+++ src/context/static_context.h 2012-03-19 16:17:13 +0000
@@ -510,6 +510,8 @@
510510
511 ExternalModuleMap * theExternalModulesMap;511 ExternalModuleMap * theExternalModulesMap;
512512
513 checked_vector<zstring> theJVMClassPath;
514
513 rchandle<TypeManager> theTypeManager;515 rchandle<TypeManager> theTypeManager;
514516
515 NamespaceBindings * theNamespaceBindings;517 NamespaceBindings * theNamespaceBindings;
@@ -713,6 +715,15 @@
713 void get_full_lib_path(std::vector<zstring>& oLibPath) const;715 void get_full_lib_path(std::vector<zstring>& oLibPath) const;
714716
715 //717 //
718 // JVM classpath
719 //
720 void set_jvm_class_path(const std::vector<zstring>& aClassPath);
721
722 void get_jvm_class_path(std::vector<zstring>& oClassPath) const;
723
724 void get_full_jvm_class_path(std::vector<zstring>& path) const;
725
726 //
716 // Validating Items727 // Validating Items
717 //728 //
718 bool validate(729 bool validate(
719730
=== modified file 'src/precompiled/stdafx.h'
--- src/precompiled/stdafx.h 2012-03-15 15:30:19 +0000
+++ src/precompiled/stdafx.h 2012-03-19 16:17:13 +0000
@@ -80,7 +80,7 @@
80// #include "compiler/expression/ft_expr.h"80// #include "compiler/expression/ft_expr.h"
81// #include "compiler/expression/ftnode.h"81// #include "compiler/expression/ftnode.h"
82// #include "compiler/parser/query_loc.h"82// #include "compiler/parser/query_loc.h"
83 #include "util/cxx_util.h"83// #include "util/cxx_util.h"
84// #include "util/indent.h"84// #include "util/indent.h"
85// #include "util/stl_util.h"85// #include "util/stl_util.h"
86// #include "diagnostics/xquery_diagnostics.h"86// #include "diagnostics/xquery_diagnostics.h"
@@ -166,7 +166,7 @@
166// #include "compiler/api/compiler_api.h"166// #include "compiler/api/compiler_api.h"
167// #include "compiler/api/compiler_api_impl.h"167// #include "compiler/api/compiler_api_impl.h"
168// #include "system/globalenv.h"168// #include "system/globalenv.h"
169// #include "system/properties.h"169#include "system/properties.h"
170// #include "system/zorba_properties.h"170// #include "system/zorba_properties.h"
171// #include "context/decimal_format.h"171// #include "context/decimal_format.h"
172// #include "context/default_uri_mappers.h"172// #include "context/default_uri_mappers.h"
@@ -182,7 +182,7 @@
182// #include "context/stemmer_wrappers.h"182// #include "context/stemmer_wrappers.h"
183// #include "context/uri_resolver.h"183// #include "context/uri_resolver.h"
184// #include "context/uri_resolver_wrapper.h"184// #include "context/uri_resolver_wrapper.h"
185#include "diagnostics/assert.h"185// //#include "diagnostics/assert.h"
186// #include "diagnostics/diagnostic.h"186// #include "diagnostics/diagnostic.h"
187// #include "diagnostics/dict.h"187// #include "diagnostics/dict.h"
188// #include "diagnostics/dict_impl.h"188// #include "diagnostics/dict_impl.h"
@@ -370,8 +370,7 @@
370 #include "zorba/diagnostic_handler.h"370 #include "zorba/diagnostic_handler.h"
371 #include "zorba/xquery_warning.h"371 #include "zorba/xquery_warning.h"
372 #include "runtime/full_text/ftcontains_visitor.h"372 #include "runtime/full_text/ftcontains_visitor.h"
373 #include "store/naive/naive_ft_token_iterator.h"373 #include "store/naive/node_items.h"
374 #include "store/api/ft_token_iterator.h"374
375 #include "store/naive/ft_token_store.h"
376#endif375#endif
377/* vim:set et sw=2 ts=2: */376/* vim:set et sw=2 ts=2: */
378377
=== modified file 'src/system/properties.h'
--- src/system/properties.h 2012-01-11 15:56:57 +0000
+++ src/system/properties.h 2012-03-19 16:17:13 +0000
@@ -67,6 +67,27 @@
6767
68 std::ostream& debug_out() { return *debug_stream; }68 std::ostream& debug_out() { return *debug_stream; }
6969
70 /**
71 * Before the JVM is started this will return the classpath set by
72 * command line option, the CLASSPATH environment variable and in Zorba
73 * config file.
74 *
75 * After the JVM is started this will contain in addition the paths to jars
76 * used by modules that make use of the JVM.
77 */
78 void getJVMClassPath(std::string & jvmClasspath)
79 { jvmClasspath = theCLASSPATH ; }
80
81 /**
82 * This method should be used to set additional JVM classpath for modules
83 * that make use of JVM. This will overide the classpath set by CLASSPATH
84 * environment variable or Zorba config file.
85 *
86 * Once the JVM is started this method doesn't have any effect.
87 */
88 void setJVMClassPath(const std::string & jvmClasspath)
89 { theCLASSPATH = jvmClasspath; }
90
70 protected:91 protected:
71 /**92 /**
72 * Gets the Operation System folder where the properties of the current 93 * Gets the Operation System folder where the properties of the current
7394
=== modified file 'src/system/zorba_properties.h'
--- src/system/zorba_properties.h 2012-02-29 11:10:30 +0000
+++ src/system/zorba_properties.h 2012-03-19 16:17:13 +0000
@@ -26,13 +26,25 @@
26namespace zorba 26namespace zorba
27{ 27{
2828
29class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesBase 29class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesGlobal
30{30{
31protected:31protected:
32 const char** get_all_options() const 32 const char** get_all_options() const
33 {33 {
34 static const char* result [] = 34 static const char* result [] = {
35 { "--trace-parsing", "--trace-scanning", "--use-serializer", "--optimizer", "--result-file", "--debug-file", "--abort", "--query", "--print-query", "--print-time", "--print-ast", "--print-xqdoc", "--print-translated", "--print-normalized", "--print-optimized", "--print-iterator-tree", "--print-item-flow", "--print-static-types", "--dump-lib", "--stable-iterator-ids", "--no-tree-ids", "--print-intermediate-opt", "--print-locations", "--force-gflwor", "--reorder-globals", "--specialize-num", "--specialize-cmp", "--inline-udf", "--loop-hoisting", "--infer-joins", "--no-copy-optim", "--serialize-only-query", "--trace-translator", "--trace-codegen", "--trace-fulltext", "--debug", "--compile-only", "--tz", "--external-var", "--serializer-param", "--iter-plan-test", "--dot-plan-file", "--max-udf-call-depth", NULL };35 "--trace-parsing", "--trace-scanning", "--use-serializer", "--optimizer",
36 "--result-file", "--debug-file", "--abort", "--query", "--print-query",
37 "--print-time", "--print-ast", "--print-xqdoc", "--print-translated",
38 "--print-normalized", "--print-optimized", "--print-iterator-tree",
39 "--print-item-flow", "--print-static-types", "--dump-lib",
40 "--stable-iterator-ids", "--no-tree-ids", "--print-intermediate-opt",
41 "--print-locations", "--force-gflwor", "--reorder-globals",
42 "--specialize-num", "--specialize-cmp", "--inline-udf", "--loop-hoisting",
43 "--infer-joins", "--no-copy-optim", "--serialize-only-query",
44 "--trace-translator", "--trace-codegen", "--trace-fulltext", "--debug",
45 "--compile-only", "--tz", "--external-var", "--serializer-param",
46 "--iter-plan-test", "--dot-plan-file", "--max-udf-call-depth",
47 "--CLASSPATH", NULL };
3648
37 return result;49 return result;
38 }50 }
@@ -80,6 +92,7 @@
80 bool theIterPlanTest;92 bool theIterPlanTest;
81 std::string theDotPlanFile;93 std::string theDotPlanFile;
82 uint32_t theMaxUdfCallDepth;94 uint32_t theMaxUdfCallDepth;
95 std::string theCLASSPATH;
8396
84 void initialize() 97 void initialize()
85 {98 {
@@ -165,6 +178,7 @@
165 const bool &iterPlanTest () const { return theIterPlanTest; }178 const bool &iterPlanTest () const { return theIterPlanTest; }
166 const std::string &dotPlanFile () const { return theDotPlanFile; }179 const std::string &dotPlanFile () const { return theDotPlanFile; }
167 const uint32_t &maxUdfCallDepth () const { return theMaxUdfCallDepth; }180 const uint32_t &maxUdfCallDepth () const { return theMaxUdfCallDepth; }
181 const std::string &CLASSPATH () const { return theCLASSPATH; }
168182
169 std::string load_argv (int argc, const char **argv) 183 std::string load_argv (int argc, const char **argv)
170 {184 {
@@ -200,7 +214,9 @@
200 else if (strcmp (*argv, "--debug-file") == 0) {214 else if (strcmp (*argv, "--debug-file") == 0) {
201 int d = 2;215 int d = 2;
202 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }216 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
203 if (*argv == NULL) { result = "No value given for --debug-file option"; break; } init_val (*argv, theDebugFile, d);217 if (*argv == NULL) { result = "No value given for --debug-file option"; break; }
218
219 init_val (*argv, theDebugFile, d);
204 }220 }
205 else if (strcmp (*argv, "--abort") == 0) {221 else if (strcmp (*argv, "--abort") == 0) {
206 theAbort = true;222 theAbort = true;
@@ -208,7 +224,9 @@
208 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-e", 2) == 0) {224 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-e", 2) == 0) {
209 int d = 2;225 int d = 2;
210 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }226 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
211 if (*argv == NULL) { result = "No value given for --query option"; break; } init_val (*argv, theQuery, d);227 if (*argv == NULL) { result = "No value given for --query option"; break; }
228
229 init_val (*argv, theQuery, d);
212 }230 }
213 else if (strcmp (*argv, "--print-query") == 0 || strncmp (*argv, "-q", 2) == 0) {231 else if (strcmp (*argv, "--print-query") == 0 || strncmp (*argv, "-q", 2) == 0) {
214 thePrintQuery = true;232 thePrintQuery = true;
@@ -240,7 +258,9 @@
240 else if (strcmp (*argv, "--print-static-types") == 0) {258 else if (strcmp (*argv, "--print-static-types") == 0) {
241 int d = 2;259 int d = 2;
242 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }260 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
243 if (*argv == NULL) { result = "No value given for --print-static-types option"; break; } init_val (*argv, thePrintStaticTypes, d);261 if (*argv == NULL) { result = "No value given for --print-static-types option"; break; }
262
263 init_val (*argv, thePrintStaticTypes, d);
244 }264 }
245 else if (strcmp (*argv, "--dump-lib") == 0) {265 else if (strcmp (*argv, "--dump-lib") == 0) {
246 theDumpLib = true;266 theDumpLib = true;
@@ -263,32 +283,44 @@
263 else if (strcmp (*argv, "--reorder-globals") == 0) {283 else if (strcmp (*argv, "--reorder-globals") == 0) {
264 int d = 2;284 int d = 2;
265 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }285 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
266 if (*argv == NULL) { result = "No value given for --reorder-globals option"; break; } init_val (*argv, theReorderGlobals, d);286 if (*argv == NULL) { result = "No value given for --reorder-globals option"; break; }
287
288 init_val (*argv, theReorderGlobals, d);
267 }289 }
268 else if (strcmp (*argv, "--specialize-num") == 0) {290 else if (strcmp (*argv, "--specialize-num") == 0) {
269 int d = 2;291 int d = 2;
270 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }292 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
271 if (*argv == NULL) { result = "No value given for --specialize-num option"; break; } init_val (*argv, theSpecializeNum, d);293 if (*argv == NULL) { result = "No value given for --specialize-num option"; break; }
294
295 init_val (*argv, theSpecializeNum, d);
272 }296 }
273 else if (strcmp (*argv, "--specialize-cmp") == 0) {297 else if (strcmp (*argv, "--specialize-cmp") == 0) {
274 int d = 2;298 int d = 2;
275 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }299 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
276 if (*argv == NULL) { result = "No value given for --specialize-cmp option"; break; } init_val (*argv, theSpecializeCmp, d);300 if (*argv == NULL) { result = "No value given for --specialize-cmp option"; break; }
301
302 init_val (*argv, theSpecializeCmp, d);
277 }303 }
278 else if (strcmp (*argv, "--inline-udf") == 0) {304 else if (strcmp (*argv, "--inline-udf") == 0) {
279 int d = 2;305 int d = 2;
280 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }306 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
281 if (*argv == NULL) { result = "No value given for --inline-udf option"; break; } init_val (*argv, theInlineUdf, d);307 if (*argv == NULL) { result = "No value given for --inline-udf option"; break; }
308
309 init_val (*argv, theInlineUdf, d);
282 }310 }
283 else if (strcmp (*argv, "--loop-hoisting") == 0) {311 else if (strcmp (*argv, "--loop-hoisting") == 0) {
284 int d = 2;312 int d = 2;
285 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }313 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
286 if (*argv == NULL) { result = "No value given for --loop-hoisting option"; break; } init_val (*argv, theLoopHoisting, d);314 if (*argv == NULL) { result = "No value given for --loop-hoisting option"; break; }
315
316 init_val (*argv, theLoopHoisting, d);
287 }317 }
288 else if (strcmp (*argv, "--infer-joins") == 0) {318 else if (strcmp (*argv, "--infer-joins") == 0) {
289 int d = 2;319 int d = 2;
290 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }320 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
291 if (*argv == NULL) { result = "No value given for --infer-joins option"; break; } init_val (*argv, theInferJoins, d);321 if (*argv == NULL) { result = "No value given for --infer-joins option"; break; }
322
323 init_val (*argv, theInferJoins, d);
292 }324 }
293 else if (strcmp (*argv, "--no-copy-optim") == 0)325 else if (strcmp (*argv, "--no-copy-optim") == 0)
294 {326 {
@@ -325,17 +357,23 @@
325 else if (strcmp (*argv, "--tz") == 0) {357 else if (strcmp (*argv, "--tz") == 0) {
326 int d = 2;358 int d = 2;
327 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }359 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
328 if (*argv == NULL) { result = "No value given for --tz option"; break; } init_val (*argv, theTz, d);360 if (*argv == NULL) { result = "No value given for --tz option"; break; }
361
362 init_val (*argv, theTz, d);
329 }363 }
330 else if (strcmp (*argv, "--external-var") == 0 || strncmp (*argv, "-x", 2) == 0) {364 else if (strcmp (*argv, "--external-var") == 0 || strncmp (*argv, "-x", 2) == 0) {
331 int d = 2;365 int d = 2;
332 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }366 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
333 if (*argv == NULL) { result = "No value given for --external-var option"; break; } init_val (*argv, theExternalVar, d);367 if (*argv == NULL) { result = "No value given for --external-var option"; break; }
368
369 init_val (*argv, theExternalVar, d);
334 }370 }
335 else if (strcmp (*argv, "--serializer-param") == 0 || strncmp (*argv, "-z", 2) == 0) {371 else if (strcmp (*argv, "--serializer-param") == 0 || strncmp (*argv, "-z", 2) == 0) {
336 int d = 2;372 int d = 2;
337 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }373 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
338 if (*argv == NULL) { result = "No value given for --serializer-param option"; break; } init_val (*argv, theSerializerParam, d);374 if (*argv == NULL) { result = "No value given for --serializer-param option"; break; }
375
376 init_val (*argv, theSerializerParam, d);
339 }377 }
340 else if (strcmp (*argv, "--iter-plan-test") == 0) {378 else if (strcmp (*argv, "--iter-plan-test") == 0) {
341 theIterPlanTest = true;379 theIterPlanTest = true;
@@ -343,12 +381,23 @@
343 else if (strcmp (*argv, "--dot-plan-file") == 0) {381 else if (strcmp (*argv, "--dot-plan-file") == 0) {
344 int d = 2;382 int d = 2;
345 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }383 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
346 if (*argv == NULL) { result = "No value given for --dot-plan-file option"; break; } init_val (*argv, theDotPlanFile, d);384 if (*argv == NULL) { result = "No value given for --dot-plan-file option"; break; }
385
386 init_val (*argv, theDotPlanFile, d);
347 }387 }
348 else if (strcmp (*argv, "--max-udf-call-depth") == 0) {388 else if (strcmp (*argv, "--max-udf-call-depth") == 0) {
349 int d = 2;389 int d = 2;
350 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }390 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
351 if (*argv == NULL) { result = "No value given for --max-udf-call-depth option"; break; } init_val (*argv, theMaxUdfCallDepth, d);391 if (*argv == NULL) { result = "No value given for --max-udf-call-depth option"; break; }
392
393 init_val (*argv, theMaxUdfCallDepth, d);
394 }
395 else if (strcmp (*argv, "--CLASSPATH") == 0) {
396 int d = 2;
397 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
398 if (*argv == NULL) { result = "No value given for --CLASSPATH option"; break; }
399
400 init_val (*argv, theCLASSPATH, d);
352 }401 }
353 else if (strcmp (*argv, "--") == 0) {402 else if (strcmp (*argv, "--") == 0) {
354 copy_args (++argv);403 copy_args (++argv);
@@ -413,6 +462,7 @@
413"--iter-plan-test\nrun as iterator plan test\n\n"462"--iter-plan-test\nrun as iterator plan test\n\n"
414"--dot-plan-file\ngenerate the dot iterator plan\n\n"463"--dot-plan-file\ngenerate the dot iterator plan\n\n"
415"--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"464"--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"
465"--CLASSPATH\nJVM classpath to be used by modules using Java implementations\n\n"
416;466;
417 }467 }
418468
419469
=== modified file 'src/system/zorba_properties.txt'
--- src/system/zorba_properties.txt 2012-02-29 11:10:30 +0000
+++ src/system/zorba_properties.txt 2012-03-19 16:17:13 +0000
@@ -43,3 +43,4 @@
43 ("iter-plan-test", "run as iterator plan test")43 ("iter-plan-test", "run as iterator plan test")
44 ("dot-plan-file", po::value<std::string>(), "generate the dot iterator plan")44 ("dot-plan-file", po::value<std::string>(), "generate the dot iterator plan")
45 ("max-udf-call-depth", po::value<uint32_t>()->default_value(1024), "maximum stack depth of udf function calls")45 ("max-udf-call-depth", po::value<uint32_t>()->default_value(1024), "maximum stack depth of udf function calls")
46 ("CLASSPATH", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
46\ No newline at end of file47\ No newline at end of file
4748
=== modified file 'src/util/file.cpp'
--- src/util/file.cpp 2012-01-11 15:56:57 +0000
+++ src/util/file.cpp 2012-03-19 16:17:13 +0000
@@ -277,6 +277,18 @@
277#endif277#endif
278}278}
279279
280void file::lsdir(std::vector<std::string> &list) {
281#ifdef ZORBA_WITH_FILE_ACCESS
282 try {
283 fs::lsdir( c_str(), list );
284 set_filetype( type_directory );
285 }
286 catch ( fs::exception const &e ) {
287 throw ZORBA_IO_EXCEPTION( e.function(), e.path() );
288 }
289#endif
290}
291
280void file::deep_mkdir() {292void file::deep_mkdir() {
281#ifdef ZORBA_WITH_FILE_ACCESS293#ifdef ZORBA_WITH_FILE_ACCESS
282 vector<file> files;294 vector<file> files;
283295
=== modified file 'src/util/fs_util.cpp'
--- src/util/fs_util.cpp 2012-01-11 15:56:57 +0000
+++ src/util/fs_util.cpp 2012-03-19 16:17:13 +0000
@@ -277,6 +277,30 @@
277#endif277#endif
278}278}
279279
280void lsdir( char const *path, std::vector<std::string> &list )
281{
282 DIR *dir;
283 struct dirent *ent;
284
285 dir = opendir (path);
286 if (dir != NULL)
287 {
288 /* print all the files and directories within directory */
289 while ((ent = readdir (dir)) != NULL)
290 {
291 //printf ("%s\n", ent->d_name);
292 std::string item(ent->d_name);
293 list.push_back(item);
294 }
295 closedir (dir);
296 }
297 else
298 {
299 /* could not open directory */
300 throw fs::exception( "lsdir()", path );
301 }
302}
303
280bool remove( char const *path ) {304bool remove( char const *path ) {
281#ifndef WIN32305#ifndef WIN32
282 return ::remove( path ) == 0;306 return ::remove( path ) == 0;
283307
=== modified file 'src/util/fs_util.h'
--- src/util/fs_util.h 2012-01-11 15:56:57 +0000
+++ src/util/fs_util.h 2012-03-19 16:17:13 +0000
@@ -17,6 +17,14 @@
17#ifndef ZORBA_FS_UTIL_H17#ifndef ZORBA_FS_UTIL_H
18#define ZORBA_FS_UTIL_H18#define ZORBA_FS_UTIL_H
1919
20#include <vector>
21
22#ifdef WIN32
23# include "win32/dirent.h"
24#else
25# include <dirent.h> /* for implementing lsdir */
26#endif /* WIN32 */
27
20#include <zorba/config.h>28#include <zorba/config.h>
2129
22#include <stdexcept>30#include <stdexcept>
@@ -144,6 +152,26 @@
144 mkdir( path.c_str() );152 mkdir( path.c_str() );
145}153}
146154
155/**
156 * List files in dir
157 *
158 * @param path The full path of the directory to list.
159 * @throws fs::exception if the list fails.
160 */
161void lsdir( char const *path, std::vector<std::string> & list );
162
163/**
164 * List files in dir
165 *
166 * @tparam PathStringType The \a path string type.
167 * @param path The full path of the directory to list.
168 * @throws fs::exception if the list fails.
169 */
170template<class PathStringType> inline
171void lsdir( PathStringType const &path, std::vector<std::string> & list ) {
172 lsdir( path.c_str(), list );
173}
174
147#endif /* ZORBA_WITH_FILE_ACCESS */175#endif /* ZORBA_WITH_FILE_ACCESS */
148176
149////////// File creation //////////////////////////////////////////////////////177////////// File creation //////////////////////////////////////////////////////
150178
=== added file 'src/util/win32/dirent.h'
--- src/util/win32/dirent.h 1970-01-01 00:00:00 +0000
+++ src/util/win32/dirent.h 2012-03-19 16:17:13 +0000
@@ -0,0 +1,372 @@
1/*****************************************************************************
2 * dirent.h - dirent API for Microsoft Visual Studio
3 *
4 * Copyright (C) 2006 Toni Ronkko
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * ``Software''), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * Mar 15, 2011, Toni Ronkko
26 * Defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
27 *
28 * Aug 11, 2010, Toni Ronkko
29 * Added d_type and d_namlen fields to dirent structure. The former is
30 * especially useful for determining whether directory entry represents a
31 * file or a directory. For more information, see
32 * http://www.delorie.com/gnu/docs/glibc/libc_270.html
33 *
34 * Aug 11, 2010, Toni Ronkko
35 * Improved conformance to the standards. For example, errno is now set
36 * properly on failure and assert() is never used. Thanks to Peter Brockam
37 * for suggestions.
38 *
39 * Aug 11, 2010, Toni Ronkko
40 * Fixed a bug in rewinddir(): when using relative directory names, change
41 * of working directory no longer causes rewinddir() to fail.
42 *
43 * Dec 15, 2009, John Cunningham
44 * Added rewinddir member function
45 *
46 * Jan 18, 2008, Toni Ronkko
47 * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
48 * between multi-byte and unicode representations. This makes the
49 * code simpler and also allows the code to be compiled under MingW. Thanks
50 * to Azriel Fasten for the suggestion.
51 *
52 * Mar 4, 2007, Toni Ronkko
53 * Bug fix: due to the strncpy_s() function this file only compiled in
54 * Visual Studio 2005. Using the new string functions only when the
55 * compiler version allows.
56 *
57 * Nov 2, 2006, Toni Ronkko
58 * Major update: removed support for Watcom C, MS-DOS and Turbo C to
59 * simplify the file, updated the code to compile cleanly on Visual
60 * Studio 2005 with both unicode and multi-byte character strings,
61 * removed rewinddir() as it had a bug.
62 *
63 * Aug 20, 2006, Toni Ronkko
64 * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
65 * comments by removing SGML tags.
66 *
67 * May 14 2002, Toni Ronkko
68 * Embedded the function definitions directly to the header so that no
69 * source modules need to be included in the Visual Studio project. Removed
70 * all the dependencies to other projects so that this very header can be
71 * used independently.
72 *
73 * May 28 1998, Toni Ronkko
74 * First version.
75 *****************************************************************************/
76#ifndef DIRENT_H
77#define DIRENT_H
78
79#define WIN32_LEAN_AND_MEAN
80#include <windows.h>
81#include <string.h>
82#include <stdlib.h>
83#include <sys/types.h>
84#include <sys/stat.h>
85#include <errno.h>
86
87/* Entries missing from MSVC 6.0 */
88#if !defined(FILE_ATTRIBUTE_DEVICE)
89# define FILE_ATTRIBUTE_DEVICE 0x40
90#endif
91
92/* File type and permission flags for stat() */
93#if defined(_MSC_VER) && !defined(S_IREAD)
94# define S_IFMT _S_IFMT /* file type mask */
95# define S_IFDIR _S_IFDIR /* directory */
96# define S_IFCHR _S_IFCHR /* character device */
97# define S_IFFIFO _S_IFFIFO /* pipe */
98# define S_IFREG _S_IFREG /* regular file */
99# define S_IREAD _S_IREAD /* read permission */
100# define S_IWRITE _S_IWRITE /* write permission */
101# define S_IEXEC _S_IEXEC /* execute permission */
102#endif
103#define S_IFBLK 0 /* block device */
104#define S_IFLNK 0 /* link */
105#define S_IFSOCK 0 /* socket */
106
107#if defined(_MSC_VER)
108# define S_IRUSR S_IREAD /* read, user */
109# define S_IWUSR S_IWRITE /* write, user */
110# define S_IXUSR 0 /* execute, user */
111# define S_IRGRP 0 /* read, group */
112# define S_IWGRP 0 /* write, group */
113# define S_IXGRP 0 /* execute, group */
114# define S_IROTH 0 /* read, others */
115# define S_IWOTH 0 /* write, others */
116# define S_IXOTH 0 /* execute, others */
117#endif
118
119/* Indicates that d_type field is available in dirent structure */
120#define _DIRENT_HAVE_D_TYPE
121
122/* File type flags for d_type */
123#define DT_UNKNOWN 0
124#define DT_REG S_IFREG
125#define DT_DIR S_IFDIR
126#define DT_FIFO S_IFFIFO
127#define DT_SOCK S_IFSOCK
128#define DT_CHR S_IFCHR
129#define DT_BLK S_IFBLK
130
131/* Macros for converting between st_mode and d_type */
132#define IFTODT(mode) ((mode) & S_IFMT)
133#define DTTOIF(type) (type)
134
135/*
136 * File type macros. Note that block devices, sockets and links cannot be
137 * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
138 * only defined for compatibility. These macros should always return false
139 * on Windows.
140 */
141#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
142#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
143#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
144#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
145#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
146#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
147#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
148
149#ifdef __cplusplus
150extern "C" {
151#endif
152
153
154typedef struct dirent
155{
156 char d_name[MAX_PATH + 1]; /* File name */
157 size_t d_namlen; /* Length of name without \0 */
158 int d_type; /* File type */
159} dirent;
160
161
162typedef struct DIR
163{
164 dirent curentry; /* Current directory entry */
165 WIN32_FIND_DATAA find_data; /* Private file data */
166 int cached; /* True if data is valid */
167 HANDLE search_handle; /* Win32 search handle */
168 char patt[MAX_PATH + 3]; /* Initial directory name */
169} DIR;
170
171
172/* Forward declarations */
173static DIR *opendir(const char *dirname);
174static struct dirent *readdir(DIR *dirp);
175static int closedir(DIR *dirp);
176static void rewinddir(DIR* dirp);
177
178
179/* Use the new safe string functions introduced in Visual Studio 2005 */
180#if defined(_MSC_VER) && _MSC_VER >= 1400
181# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
182#else
183# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
184#endif
185
186/* Set errno variable */
187#if defined(_MSC_VER)
188#define DIRENT_SET_ERRNO(x) _set_errno (x)
189#else
190#define DIRENT_SET_ERRNO(x) (errno = (x))
191#endif
192
193
194/*****************************************************************************
195 * Open directory stream DIRNAME for read and return a pointer to the
196 * internal working area that is used to retrieve individual directory
197 * entries.
198 */
199static DIR *opendir(const char *dirname)
200{
201 DIR *dirp;
202
203 /* ensure that the resulting search pattern will be a valid file name */
204 if (dirname == NULL) {
205 DIRENT_SET_ERRNO (ENOENT);
206 return NULL;
207 }
208 if (strlen (dirname) + 3 >= MAX_PATH) {
209 DIRENT_SET_ERRNO (ENAMETOOLONG);
210 return NULL;
211 }
212
213 /* construct new DIR structure */
214 dirp = (DIR*) malloc (sizeof (struct DIR));
215 if (dirp != NULL) {
216 int error;
217
218 /*
219 * Convert relative directory name to an absolute one. This
220 * allows rewinddir() to function correctly when the current working
221 * directory is changed between opendir() and rewinddir().
222 */
223 if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) {
224 char *p;
225
226 /* append the search pattern "\\*\0" to the directory name */
227 p = strchr (dirp->patt, '\0');
228 if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
229 *p++ = '\\';
230 }
231 *p++ = '*';
232 *p = '\0';
233
234 /* open directory stream and retrieve the first entry */
235 dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
236 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
237 /* a directory entry is now waiting in memory */
238 dirp->cached = 1;
239 error = 0;
240 } else {
241 /* search pattern is not a directory name? */
242 DIRENT_SET_ERRNO (ENOENT);
243 error = 1;
244 }
245 } else {
246 /* buffer too small */
247 DIRENT_SET_ERRNO (ENOMEM);
248 error = 1;
249 }
250
251 if (error) {
252 free (dirp);
253 dirp = NULL;
254 }
255 }
256
257 return dirp;
258}
259
260
261/*****************************************************************************
262 * Read a directory entry, and return a pointer to a dirent structure
263 * containing the name of the entry in d_name field. Individual directory
264 * entries returned by this very function include regular files,
265 * sub-directories, pseudo-directories "." and "..", but also volume labels,
266 * hidden files and system files may be returned.
267 */
268static struct dirent *readdir(DIR *dirp)
269{
270 DWORD attr;
271 if (dirp == NULL) {
272 /* directory stream did not open */
273 DIRENT_SET_ERRNO (EBADF);
274 return NULL;
275 }
276
277 /* get next directory entry */
278 if (dirp->cached != 0) {
279 /* a valid directory entry already in memory */
280 dirp->cached = 0;
281 } else {
282 /* get the next directory entry from stream */
283 if (dirp->search_handle == INVALID_HANDLE_VALUE) {
284 return NULL;
285 }
286 if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) {
287 /* the very last entry has been processed or an error occured */
288 FindClose (dirp->search_handle);
289 dirp->search_handle = INVALID_HANDLE_VALUE;
290 return NULL;
291 }
292 }
293
294 /* copy as a multibyte character string */
295 DIRENT_STRNCPY ( dirp->curentry.d_name,
296 dirp->find_data.cFileName,
297 sizeof(dirp->curentry.d_name) );
298 dirp->curentry.d_name[MAX_PATH] = '\0';
299
300 /* compute the length of name */
301 dirp->curentry.d_namlen = strlen (dirp->curentry.d_name);
302
303 /* determine file type */
304 attr = dirp->find_data.dwFileAttributes;
305 if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
306 dirp->curentry.d_type = DT_CHR;
307 } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
308 dirp->curentry.d_type = DT_DIR;
309 } else {
310 dirp->curentry.d_type = DT_REG;
311 }
312 return &dirp->curentry;
313}
314
315
316/*****************************************************************************
317 * Close directory stream opened by opendir() function. Close of the
318 * directory stream invalidates the DIR structure as well as any previously
319 * read directory entry.
320 */
321static int closedir(DIR *dirp)
322{
323 if (dirp == NULL) {
324 /* invalid directory stream */
325 DIRENT_SET_ERRNO (EBADF);
326 return -1;
327 }
328
329 /* release search handle */
330 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
331 FindClose (dirp->search_handle);
332 dirp->search_handle = INVALID_HANDLE_VALUE;
333 }
334
335 /* release directory structure */
336 free (dirp);
337 return 0;
338}
339
340
341/*****************************************************************************
342 * Resets the position of the directory stream to which dirp refers to the
343 * beginning of the directory. It also causes the directory stream to refer
344 * to the current state of the corresponding directory, as a call to opendir()
345 * would have done. If dirp does not refer to a directory stream, the effect
346 * is undefined.
347 */
348static void rewinddir(DIR* dirp)
349{
350 if (dirp != NULL) {
351 /* release search handle */
352 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
353 FindClose (dirp->search_handle);
354 }
355
356 /* open new search handle and retrieve the first entry */
357 dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
358 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
359 /* a directory entry is now waiting in memory */
360 dirp->cached = 1;
361 } else {
362 /* failed to re-open directory: no directory entry in memory */
363 dirp->cached = 0;
364 }
365 }
366}
367
368
369#ifdef __cplusplus
370}
371#endif
372#endif /*DIRENT_H*/
0373
=== modified file 'swig/XQuery.i'
--- swig/XQuery.i 2012-01-11 15:56:57 +0000
+++ swig/XQuery.i 2012-03-19 16:17:13 +0000
@@ -14,6 +14,7 @@
14 * limitations under the License.14 * limitations under the License.
15 */15 */
1616
17
17%{ // start Implementation18%{ // start Implementation
1819
19class Iterator 20class Iterator
@@ -67,6 +68,40 @@
67}; // class Iterator68}; // class Iterator
6869
6970
71
72
73
74class IStream
75{
76private:
77 std::istream* theIStream;
78
79public:
80 IStream() {}
81 IStream(const IStream& anIStream) : theIStream(anIStream.theIStream) {}
82 IStream(std::istream& anIStream) : theIStream(&anIStream) {}
83
84 std::string readToString()
85 {
86 std::stringstream lStream;
87
88 lStream << theIStream;
89 return lStream.str();
90 }
91
92
93 int read(char *BYTE, int LENGTH)
94 {
95 theIStream->read(BYTE, LENGTH);
96 //theIStream->read(byteArray, len);
97 int readLength = theIStream->gcount();
98 return readLength;
99 }
100
101
102}; // class IStream
103
104
70class Item 105class Item
71{106{
72 friend class Iterator;107 friend class Iterator;
@@ -84,13 +119,10 @@
84 Item(const Item& aItem) : theItem(aItem.theItem) {}119 Item(const Item& aItem) : theItem(aItem.theItem) {}
85 Item(const zorba::Item& aZItem) : theItem(aZItem) {}120 Item(const zorba::Item& aZItem) : theItem(aZItem) {}
86121
87 static Item createEmptyItem() 122 static Item createEmptyItem()
88 { return Item(); }123 { return Item(); }
89124
90 std::string getStringValue() const 125 std::string serialize() const
91 { return std::string(theItem.getStringValue().c_str()); }
92
93 std::string serialize() const
94 {126 {
95 std::stringstream lStream; 127 std::stringstream lStream;
96 Zorba_SerializerOptions_t lOptions; 128 Zorba_SerializerOptions_t lOptions;
@@ -100,6 +132,22 @@
100 return lStream.str();132 return lStream.str();
101 }133 }
102 134
135 void serializeToOutputStream(std::ostream &outStream) const
136 {
137 Zorba_SerializerOptions_t lOptions;
138 zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
139 zorba::SingletonItemSequence lSequence(theItem);
140 lSerializer->serialize(&lSequence, outStream);
141 }
142
143 IStream getStream()
144 {
145 return IStream(theItem.getStream());
146 }
147
148 std::string getStringValue() const
149 { return std::string(theItem.getStringValue().c_str()); }
150
103 Iterator getAtomizationValue () const151 Iterator getAtomizationValue () const
104 { return Iterator(theItem.getAtomizationValue()); }152 { return Iterator(theItem.getAtomizationValue()); }
105 153
@@ -274,11 +322,15 @@
274}322}
275323
276324
277%} // end Implementation325
326%} // end Implementation
327
278328
279329
280// Interfaces330// Interfaces
281331
332
333
282class DynamicContext334class DynamicContext
283{335{
284public:336public:
@@ -292,12 +344,25 @@
292 setContextItem(Item);344 setContextItem(Item);
293};345};
294346
295class Item 347
348class IStream
349{
350public:
351 std::string readToString();
352 int read(char * BYTE, long LENGTH);
353}; // class IStream
354
355
356class Item
296{357{
297public: 358public:
298 static Item createEmptyItem();359 static Item createEmptyItem();
360
361 std::string serialize() const;
362 void serializeToOutputStream(std::ostream &outStream) const;
363 IStream getStream();
364
299 std::string getStringValue() const;365 std::string getStringValue() const;
300 std::string serialize() const;
301 Iterator getAtomizationValue () const;366 Iterator getAtomizationValue () const;
302 Iterator getAttributes () const;367 Iterator getAttributes () const;
303 bool getBooleanValue () const;368 bool getBooleanValue () const;
@@ -319,6 +384,7 @@
319 bool isPosOrNegInf () const;384 bool isPosOrNegInf () const;
320}; // class Item385}; // class Item
321386
387
322class Iterator 388class Iterator
323{389{
324public:390public:
@@ -328,6 +394,7 @@
328 void destroy();394 void destroy();
329}; // class Iterator395}; // class Iterator
330396
397
331class XQuery 398class XQuery
332{399{
333public:400public:
334401
=== modified file 'swig/java/CMakeLists.txt'
--- swig/java/CMakeLists.txt 2012-01-11 15:56:57 +0000
+++ swig/java/CMakeLists.txt 2012-03-19 16:17:13 +0000
@@ -21,7 +21,7 @@
21 include (CMakeJavaInformation )21 include (CMakeJavaInformation )
22 MESSAGE(STATUS "SWIG Java: generating Java API")22 MESSAGE(STATUS "SWIG Java: generating Java API")
2323
24 # EXECUTE_PROCESS( COMMAND ${JAVA_RUNTIME} -version OUTPUT_VARIABLE JAVA_VERSION )24 EXECUTE_PROCESS( COMMAND ${JAVA_RUNTIME} -version OUTPUT_VARIABLE JAVA_VERSION )
25 MESSAGE(STATUS "SWIG Java: JNI found at: " ${JAVA_INCLUDE_PATH} )25 MESSAGE(STATUS "SWIG Java: JNI found at: " ${JAVA_INCLUDE_PATH} )
2626
27 SET_SOURCE_FILES_PROPERTIES( zorba_api.i PROPERTIES CPLUSPLUS ON )27 SET_SOURCE_FILES_PROPERTIES( zorba_api.i PROPERTIES CPLUSPLUS ON )
@@ -89,6 +89,7 @@
89 ENDIF(NOT WIN32)89 ENDIF(NOT WIN32)
90 ENDIF ( APPLE )90 ENDIF ( APPLE )
9191
92
92ELSE (JAVA_INCLUDE_PATH)93ELSE (JAVA_INCLUDE_PATH)
93 MESSAGE ( STATUS "SWIG Java: not generating JAVA API because jni headers not found.")94 MESSAGE ( STATUS "SWIG Java: not generating JAVA API because jni headers not found.")
94ENDIF (JAVA_INCLUDE_PATH)95ENDIF (JAVA_INCLUDE_PATH)
9596
=== added file 'swig/various.i'
--- swig/various.i 1970-01-01 00:00:00 +0000
+++ swig/various.i 2012-03-19 16:17:13 +0000
@@ -0,0 +1,184 @@
1/* This is from http://www.opensource.apple.com/source/swig/swig-6/swig/Lib/java/various.i?txt */
2
3/* -----------------------------------------------------------------------------
4 * See the LICENSE file for information on copyright, usage and redistribution
5 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
6 *
7 * various.i
8 *
9 * SWIG Typemap library for Java.
10 * Various useful typemaps.
11 * ----------------------------------------------------------------------------- */
12
13#ifdef SWIGJAVA
14
15/*
16 * char **STRING_ARRAY typemaps.
17 * These typemaps are for C String arrays which are NULL terminated.
18 * char *values[] = { "one", "two", "three", NULL }; // note NULL
19 * char ** is mapped to a Java String[].
20 *
21 * Example usage wrapping:
22 * %apply char **STRING_ARRAY { char **input };
23 * char ** foo(char **input);
24 *
25 * Java usage:
26 * String numbers[] = { "one", "two", "three" };
27 * String[] ret = modulename.foo( numbers };
28 */
29%typemap(jni) char **STRING_ARRAY "jobjectArray"
30%typemap(jtype) char **STRING_ARRAY "String[]"
31%typemap(jstype) char **STRING_ARRAY "String[]"
32%typemap(in) char **STRING_ARRAY (jint size) {
33 int i = 0;
34 size = JCALL1(GetArrayLength, jenv, $input);
35#ifdef __cplusplus
36 $1 = new char*[size+1];
37#else
38 $1 = (char **)calloc(size+1, sizeof(char *));
39#endif
40 for (i = 0; i<size; i++) {
41 jstring j_string = (jstring)JCALL2(GetObjectArrayElement, jenv, $input, i);
42 const char *c_string = JCALL2(GetStringUTFChars, jenv, j_string, 0);
43#ifdef __cplusplus
44 $1[i] = new char [strlen(c_string)+1];
45#else
46 $1[i] = (char *)calloc(strlen(c_string)+1, sizeof(const char *));
47#endif
48 strcpy($1[i], c_string);
49 JCALL2(ReleaseStringUTFChars, jenv, j_string, c_string);
50 JCALL1(DeleteLocalRef, jenv, j_string);
51 }
52 $1[i] = 0;
53}
54
55%typemap(freearg) char **STRING_ARRAY {
56 int i;
57 for (i=0; i<size$argnum-1; i++)
58#ifdef __cplusplus
59 delete[] $1[i];
60 delete[] $1;
61#else
62 free($1[i]);
63 free($1);
64#endif
65}
66
67%typemap(out) char **STRING_ARRAY {
68 int i;
69 int len=0;
70 jstring temp_string;
71 const jclass clazz = JCALL1(FindClass, jenv, "java/lang/String");
72
73 while ($1[len]) len++;
74 jresult = JCALL3(NewObjectArray, jenv, len, clazz, NULL);
75 /* exception checking omitted */
76
77 for (i=0; i<len; i++) {
78 temp_string = JCALL1(NewStringUTF, jenv, *result++);
79 JCALL3(SetObjectArrayElement, jenv, jresult, i, temp_string);
80 JCALL1(DeleteLocalRef, jenv, temp_string);
81 }
82}
83
84%typemap(javain) char **STRING_ARRAY "$javainput"
85%typemap(javaout) char **STRING_ARRAY {
86 return $jnicall;
87 }
88
89/*
90 * char **STRING_OUT typemaps.
91 * These are typemaps for returning strings when using a C char ** parameter type.
92 * The returned string appears in the 1st element of the passed in Java String array.
93 *
94 * Example usage wrapping:
95 * void foo(char **string_out);
96 *
97 * Java usage:
98 * String stringOutArray[] = { "" };
99 * modulename.foo(stringOutArray);
100 * System.out.println( stringOutArray[0] );
101 */
102%typemap(jni) char **STRING_OUT "jobjectArray"
103%typemap(jtype) char **STRING_OUT "String[]"
104%typemap(jstype) char **STRING_OUT "String[]"
105%typemap(javain) char **STRING_OUT "$javainput"
106
107%typemap(in) char **STRING_OUT($*1_ltype temp) {
108 if (!$input) {
109 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
110 return $null;
111 }
112 if (JCALL1(GetArrayLength, jenv, $input) == 0) {
113 SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
114 return $null;
115 }
116 $1 = &temp;
117}
118
119%typemap(argout) char **STRING_OUT {
120 jstring jnewstring = NULL;
121 if($1) {
122 jnewstring = JCALL1(NewStringUTF, jenv, *$1);
123 }
124 JCALL3(SetObjectArrayElement, jenv, $input, 0, jnewstring);
125}
126
127/*
128 * char *BYTE typemaps.
129 * These are input typemaps for mapping a Java byte[] array to a C char array.
130 * Note that as a Java array is used and thus passeed by reference, the C routine
131 * can return data to Java via the parameter.
132 *
133 * Example usage wrapping:
134 * void foo(char *array);
135 *
136 * Java usage:
137 * byte b[] = new byte[20];
138 * modulename.foo(b);
139 */
140%typemap(jni) char *BYTE "jbyteArray"
141%typemap(jtype) char *BYTE "byte[]"
142%typemap(jstype) char *BYTE "byte[]"
143%typemap(in) char *BYTE {
144 $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
145}
146
147%typemap(argout) char *BYTE {
148 JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, 0);
149}
150
151%typemap(javain) char *BYTE "$javainput"
152
153/* Prevent default freearg typemap from being used */
154%typemap(freearg) char *BYTE ""
155
156#else
157
158#endif
159
160
161/* %include "typemaps.i"
162
163#if defined(SWIGJAVA)
164
165%typemap(in) (char * BYTE, int LENGTH)
166{
167 // Functions from jni.h
168 $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
169 $2 = (int) JCALL1(GetArrayLength, jenv, $input);
170}
171
172%typemap(jni) (char * BYTE, int LENGTH) "jbyteArray"
173%typemap(jtype) (char * BYTE, int LENGTH) "byte[]"
174%typemap(jstype) (char * BYTE, int LENGTH) "byte[]"
175%typemap(javain) (char * BYTE, int LENGTH) "$javainput"
176
177// Specify signature of method to handle
178%apply (char * BYTE, int LENGTH) { (char * byteArray, long len) };
179
180#else
181%apply (char * BYTE, int LENGTH) { (char * byteArray, long len) };
182#endif
183
184*/
0185
=== modified file 'swig/zorba_api.i'
--- swig/zorba_api.i 2012-01-11 15:56:57 +0000
+++ swig/zorba_api.i 2012-03-19 16:17:13 +0000
@@ -14,7 +14,10 @@
14 * limitations under the License.14 * limitations under the License.
15 */15 */
1616
17%module zorba_api17%module(directors="1") zorba_api
18
19/*%feature("director") IStream;*/
20
18%include "std_string.i"21%include "std_string.i"
19%include "exception.i"22%include "exception.i"
2023
@@ -34,6 +37,8 @@
34 }37 }
35}38}
3639
40
41
37%{ // Implementations42%{ // Implementations
3843
3944
@@ -52,6 +57,7 @@
52 class Item;57 class Item;
53 class Iterator;58 class Iterator;
54 class XQuery;59 class XQuery;
60 class IStream;
55 class Store;61 class Store;
56 class Zorba;62 class Zorba;
5763
@@ -70,6 +76,7 @@
70%}76%}
7177
7278
79%include "various.i"
7380
74%include "XQuery.i"81%include "XQuery.i"
75%include "Store.i"82%include "Store.i"
7683
=== modified file 'test/rbkt/modules/CMakeLists.txt'
--- test/rbkt/modules/CMakeLists.txt 2012-02-23 16:48:01 +0000
+++ test/rbkt/modules/CMakeLists.txt 2012-03-19 16:17:13 +0000
@@ -58,3 +58,5 @@
58# This is as good a place as any to test this feature58# This is as good a place as any to test this feature
59DECLARE_ZORBA_URI_FILE(FILE "random-file.txt"59DECLARE_ZORBA_URI_FILE(FILE "random-file.txt"
60 URI "http://www.zorba-xquery.com/random-file" TEST_ONLY)60 URI "http://www.zorba-xquery.com/random-file" TEST_ONLY)
61
62ADD_SUBDIRECTORY(java)
6163
=== added directory 'test/rbkt/modules/java'
=== added file 'test/rbkt/modules/java/CMakeLists.txt'
--- test/rbkt/modules/java/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ test/rbkt/modules/java/CMakeLists.txt 2012-03-19 16:17:13 +0000
@@ -0,0 +1,39 @@
1# Copyright 2006-2008 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License")
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# For now we only test building a .jar that we want Zorba to make available
16# on the JVM claspath. This test scenario should be extended to include a
17# Zorba module using the .jar, etc.
18# We make use of the much-improved Java support added in CMake 2.8.6.
19COMPARE_VERSION_STRINGS (${CMAKE_VERSION} "2.8.6" RESULT)
20IF (${RESULT} GREATER -1)
21 FIND_PACKAGE (Java COMPONENTS Development)
22 IF (Java_Development_FOUND)
23 INCLUDE (UseJava)
24
25 # Declare two "different" jars, for testing
26 ADD_JAR (JavaTest Test.java)
27 ADD_JAR (JavaTest2 Test.java)
28
29 # Tell Zorba about the jars
30 GET_PROPERTY (JavaTest_JAR_FILE TARGET JavaTest PROPERTY JAR_FILE)
31 GET_PROPERTY (JavaTest2_JAR_FILE TARGET JavaTest2 PROPERTY JAR_FILE)
32 DECLARE_ZORBA_JAR(FILE ${JavaTest_JAR_FILE} ${JavaTest2_JAR_FILE} TEST_ONLY)
33
34 # Pretend to tell Zorba about some system jars
35 DECLARE_ZORBA_JAR(EXTERNAL FILE
36 "${PROJECT_SOURCE_DIR}/MyJar.jar" "${PROJECT_SOURCE_DIR}/MyJar2.jar")
37
38 ENDIF (Java_Development_FOUND)
39ENDIF (${RESULT} GREATER -1)
040
=== added file 'test/rbkt/modules/java/Test.java'
--- test/rbkt/modules/java/Test.java 1970-01-01 00:00:00 +0000
+++ test/rbkt/modules/java/Test.java 2012-03-19 16:17:13 +0000
@@ -0,0 +1,7 @@
1package org.zorbaxquery;
2
3public class Test {
4 public static void main(String[] args) {
5 System.out.println("Hello, world");
6 }
7}

Subscribers

People subscribed via source and target branches