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
1=== modified file 'NOTICE.txt'
2--- NOTICE.txt 2012-03-14 15:28:15 +0000
3+++ NOTICE.txt 2012-03-19 16:17:13 +0000
4@@ -459,6 +459,24 @@
5 suitability of this software for any purpose. It is provided "as is"
6 without express or implied warranty.
7
8+----------------------------------------------------
9+
10+src/util/win32/dirent.h
11+
12+Copyright: 2006 Toni Ronkko
13+
14+
15+ Permission is hereby granted, free of charge, to any person obtaining
16+ a copy of this software and associated documentation files (the
17+ ``Software''), to deal in the Software without restriction, including
18+ without limitation the rights to use, copy, modify, merge, publish,
19+ distribute, sublicense, and/or sell copies of the Software, and to
20+ permit persons to whom the Software is furnished to do so, subject to
21+ the following conditions:
22+
23+ The above copyright notice and this permission notice shall be included
24+ in all copies or substantial portions of the Software.
25+
26
27 External libraries used by this project:
28 ----------------------------------------------------
29
30=== modified file 'NOTICE.xml'
31--- NOTICE.xml 2012-01-11 15:56:57 +0000
32+++ NOTICE.xml 2012-03-19 16:17:13 +0000
33@@ -423,6 +423,22 @@
34 without express or implied warranty.
35 </foreign-notice>
36 </foreign-files>
37+ <foreign-files>
38+ <file>src/util/win32/dirent.h</file>
39+ <copyright>2006 Toni Ronkko</copyright>
40+ <foreign-notice>
41+ Permission is hereby granted, free of charge, to any person obtaining
42+ a copy of this software and associated documentation files (the
43+ ``Software''), to deal in the Software without restriction, including
44+ without limitation the rights to use, copy, modify, merge, publish,
45+ distribute, sublicense, and/or sell copies of the Software, and to
46+ permit persons to whom the Software is furnished to do so, subject to
47+ the following conditions:
48+
49+ The above copyright notice and this permission notice shall be included
50+ in all copies or substantial portions of the Software.
51+ </foreign-notice>
52+ </foreign-files>
53
54 <external-lib mandatory="true">
55 <name>LIBXML2</name>
56
57=== modified file 'bin/path_util.cpp'
58--- bin/path_util.cpp 2012-01-11 15:56:57 +0000
59+++ bin/path_util.cpp 2012-03-19 16:17:13 +0000
60@@ -49,7 +49,7 @@
61 }
62
63
64-static void
65+void
66 tokenizePath(
67 const std::string& aPathStr,
68 std::vector<String>& aResult)
69@@ -66,6 +66,23 @@
70 }
71 }
72
73+
74+String
75+concatenatePaths( const std::vector<String>& aPathList)
76+{
77+ String delimiter(filesystem_path::get_path_separator());
78+
79+ String lResult;
80+ for (std::vector<String>::const_iterator lIter = aPathList.begin();
81+ lIter != aPathList.end(); ++lIter)
82+ {
83+ lResult += delimiter + *lIter;
84+ }
85+
86+ return lResult;
87+}
88+
89+
90 void
91 setPathsOnContext(
92 const ZorbaCMDProperties& aProperties,
93@@ -101,8 +118,8 @@
94 // Compute and set lib path
95 aProperties.getLibPath(lPathStr);
96 tokenizePath(lPathStr, lPath);
97+ lPath.push_back(lCWD.get_path());
98 lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
99- lPath.push_back(lCWD.get_path());
100 tokenizePath(lEnvStr, lPath);
101 aStaticCtx->setLibPath(lPath);
102 }
103
104=== modified file 'bin/path_util.h'
105--- bin/path_util.h 2012-01-11 15:56:57 +0000
106+++ bin/path_util.h 2012-03-19 16:17:13 +0000
107@@ -32,6 +32,12 @@
108 setPathsOnContext(const ZorbaCMDProperties& aProperties,
109 zorba::StaticContext_t& aStaticCtx);
110
111+ void
112+ tokenizePath(const std::string& aPathStr, std::vector<String>& aResult);
113+
114+
115+ String
116+ concatenatePaths( const std::vector<String>& aPathList);
117
118 }
119 } /* namespace zorba */
120
121=== modified file 'bin/zorbacmd.cpp'
122--- bin/zorbacmd.cpp 2012-03-14 15:28:15 +0000
123+++ bin/zorbacmd.cpp 2012-03-19 16:17:13 +0000
124@@ -787,6 +787,14 @@
125 return 3;
126 }
127
128+ // Add command line --classpath option in front of config/env CLASSPATH
129+ Properties* globalProperties = Properties::instance();
130+ std::string cmdJvmClassPath;
131+ lProperties.getJVMClassPath(cmdJvmClassPath);
132+ std::string configJvmClassPath;
133+ globalProperties->getJVMClassPath(configJvmClassPath);
134+ globalProperties->setJVMClassPath(cmdJvmClassPath +
135+ filesystem_path::get_path_separator() + configJvmClassPath);
136
137 // Start the engine
138
139
140=== modified file 'bin/zorbacmdproperties.cpp'
141--- bin/zorbacmdproperties.cpp 2012-01-11 15:56:57 +0000
142+++ bin/zorbacmdproperties.cpp 2012-03-19 16:17:13 +0000
143@@ -181,6 +181,11 @@
144 aPath = theLibPath;
145 }
146
147+void ZorbaCMDProperties::getJVMClassPath(std::string& aPath) const
148+{
149+ aPath = theClasspath;
150+}
151+
152 std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const
153 {
154 std::vector<std::pair<std::string,std::string> > lResult;
155
156=== modified file 'bin/zorbacmdproperties.h'
157--- bin/zorbacmdproperties.h 2012-01-11 15:56:57 +0000
158+++ bin/zorbacmdproperties.h 2012-03-19 16:17:13 +0000
159@@ -92,6 +92,9 @@
160 void
161 getLibPath(std::string&) const;
162
163+ void
164+ getJVMClassPath(std::string&) const;
165+
166 bool isDebug(){ return theDebug; }
167
168 bool hasNoLogo(){ return theNoLogo; }
169
170=== modified file 'bin/zorbacmdproperties.txt'
171--- bin/zorbacmdproperties.txt 2012-02-29 11:10:30 +0000
172+++ bin/zorbacmdproperties.txt 2012-03-19 16:17:13 +0000
173@@ -31,6 +31,7 @@
174 ("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.")
175 ("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
176 ("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
177+("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
178 ("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").
179 ("trailing-nl", "Output a trailing newline after the result of the query.")
180 ("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
181
182=== modified file 'bin/zorbacmdproperties_base.h'
183--- bin/zorbacmdproperties_base.h 2012-02-29 11:10:30 +0000
184+++ bin/zorbacmdproperties_base.h 2012-03-19 16:17:13 +0000
185@@ -15,13 +15,6 @@
186 */
187 /* vim:set et sw=2 ts=2: */
188
189-// ******************************************
190-// * *
191-// * THIS IS A GENERATED FILE. DO NOT EDIT! *
192-// * SEE .txt FILE WITH SAME NAME *
193-// * *
194-// ******************************************
195-
196 #include <string>
197 #include <sstream>
198 #include <zorba/config.h>
199@@ -30,13 +23,29 @@
200
201 #ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
202 #define ZORBACMD_ZORBACMDPROPERTIESBASE
203-namespace zorbacmd {
204-class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {
205+namespace zorbacmd
206+{
207+
208+class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase
209+{
210 protected:
211- const char **get_all_options () const {
212- 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 };
213+ const char **get_all_options () const
214+ {
215+ static const char *result [] = {
216+ "--timing", "--output-file", "--serialization-parameter",
217+ "--serialize-html", "--serialize-text", "--indent", "--print-query",
218+ "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration",
219+ "--base-uri", "--boundary-space", "--default-collation",
220+ "--construction-mode", "--ordering-mode", "--multiple", "--query",
221+ "--as-files", "--external-variable", "--context-item",
222+ "--optimization-level", "--lib-module", "--parse-only", "--compile-only",
223+ "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo",
224+ "--timeout", "--uri-path", "--lib-path", "--module-path", "--classpath",
225+ "--option", "--trailing-nl", "--stop-words", "--thesaurus",
226+ "--compile-plan", "--execute-plan", NULL };
227 return result;
228 }
229+
230 bool theTiming;
231 std::string theOutputFile;
232 std::vector<std::string> theSerializationParameter;
233@@ -70,6 +79,7 @@
234 std::string theUriPath;
235 std::string theLibPath;
236 std::string theModulePath;
237+ std::string theClasspath;
238 std::vector<std::string> theOption;
239 bool theTrailingNl;
240 std::vector<std::string> theStopWords;
241@@ -136,6 +146,7 @@
242 const std::string &uriPath () const { return theUriPath; }
243 const std::string &libPath () const { return theLibPath; }
244 const std::string &modulePath () const { return theModulePath; }
245+ const std::string &classpath () const { return theClasspath; }
246 const std::vector<std::string> &option () const { return theOption; }
247 const bool &trailingNl () const { return theTrailingNl; }
248 const std::vector<std::string> &stopWords () const { return theStopWords; }
249@@ -158,12 +169,16 @@
250 else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) {
251 int d = 2;
252 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
253- if (*argv == NULL) { result = "No value given for --output-file option"; break; } init_val (*argv, theOutputFile, d);
254+ if (*argv == NULL) { result = "No value given for --output-file option"; break; }
255+
256+ init_val (*argv, theOutputFile, d);
257 }
258 else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) {
259 int d = 2;
260 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
261- if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; } init_val (*argv, theSerializationParameter, d);
262+ if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }
263+
264+ init_val (*argv, theSerializationParameter, d);
265 }
266 else if (strcmp (*argv, "--serialize-html") == 0) {
267 theSerializeHtml = true;
268@@ -189,37 +204,51 @@
269 else if (strcmp (*argv, "--base-uri") == 0) {
270 int d = 2;
271 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
272- if (*argv == NULL) { result = "No value given for --base-uri option"; break; } init_val (*argv, theBaseUri, d);
273+ if (*argv == NULL) { result = "No value given for --base-uri option"; break; }
274+
275+ init_val (*argv, theBaseUri, d);
276 }
277 else if (strcmp (*argv, "--boundary-space") == 0) {
278 int d = 2;
279 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
280- if (*argv == NULL) { result = "No value given for --boundary-space option"; break; } init_val (*argv, theBoundarySpace, d);
281+ if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }
282+
283+ init_val (*argv, theBoundarySpace, d);
284 }
285 else if (strcmp (*argv, "--default-collation") == 0) {
286 int d = 2;
287 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
288- if (*argv == NULL) { result = "No value given for --default-collation option"; break; } init_val (*argv, theDefaultCollation, d);
289+ if (*argv == NULL) { result = "No value given for --default-collation option"; break; }
290+
291+ init_val (*argv, theDefaultCollation, d);
292 }
293 else if (strcmp (*argv, "--construction-mode") == 0) {
294 int d = 2;
295 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
296- if (*argv == NULL) { result = "No value given for --construction-mode option"; break; } init_val (*argv, theConstructionMode, d);
297+ if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }
298+
299+ init_val (*argv, theConstructionMode, d);
300 }
301 else if (strcmp (*argv, "--ordering-mode") == 0) {
302 int d = 2;
303 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
304- if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; } init_val (*argv, theOrderingMode, d);
305+ if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }
306+
307+ init_val (*argv, theOrderingMode, d);
308 }
309 else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) {
310 int d = 2;
311 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
312- if (*argv == NULL) { result = "No value given for --multiple option"; break; } init_val (*argv, theMultiple, d);
313+ if (*argv == NULL) { result = "No value given for --multiple option"; break; }
314+
315+ init_val (*argv, theMultiple, d);
316 }
317 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) {
318 int d = 2;
319 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
320- if (*argv == NULL) { result = "No value given for --query option"; break; } init_val (*argv, theQueriesOrFiles, d);
321+ if (*argv == NULL) { result = "No value given for --query option"; break; }
322+
323+ init_val (*argv, theQueriesOrFiles, d);
324 }
325 else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) {
326 theAsFiles = true;
327@@ -227,17 +256,23 @@
328 else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) {
329 int d = 2;
330 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
331- if (*argv == NULL) { result = "No value given for --external-variable option"; break; } init_val (*argv, theExternalVariable, d);
332+ if (*argv == NULL) { result = "No value given for --external-variable option"; break; }
333+
334+ init_val (*argv, theExternalVariable, d);
335 }
336 else if (strcmp (*argv, "--context-item") == 0) {
337 int d = 2;
338 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
339- if (*argv == NULL) { result = "No value given for --context-item option"; break; } init_val (*argv, theContextItem, d);
340+ if (*argv == NULL) { result = "No value given for --context-item option"; break; }
341+
342+ init_val (*argv, theContextItem, d);
343 }
344 else if (strcmp (*argv, "--optimization-level") == 0) {
345 int d = 2;
346 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
347- if (*argv == NULL) { result = "No value given for --optimization-level option"; break; } init_val (*argv, theOptimizationLevel, d);
348+ if (*argv == NULL) { result = "No value given for --optimization-level option"; break; }
349+
350+ init_val (*argv, theOptimizationLevel, d);
351 }
352 else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) {
353 theLibModule = true;
354@@ -257,12 +292,16 @@
355 else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) {
356 int d = 2;
357 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
358- if (*argv == NULL) { result = "No value given for --debug-host option"; break; } init_val (*argv, theDebugHost, d);
359+ if (*argv == NULL) { result = "No value given for --debug-host option"; break; }
360+
361+ init_val (*argv, theDebugHost, d);
362 }
363 else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) {
364 int d = 2;
365 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
366- if (*argv == NULL) { result = "No value given for --debug-port option"; break; } init_val (*argv, theDebugPort, d);
367+ if (*argv == NULL) { result = "No value given for --debug-port option"; break; }
368+
369+ init_val (*argv, theDebugPort, d);
370 }
371 else if (strcmp (*argv, "--no-logo") == 0) {
372 theNoLogo = true;
373@@ -270,27 +309,44 @@
374 else if (strcmp (*argv, "--timeout") == 0) {
375 int d = 2;
376 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
377- if (*argv == NULL) { result = "No value given for --timeout option"; break; } init_val (*argv, theTimeout, d);
378+ if (*argv == NULL) { result = "No value given for --timeout option"; break; }
379+
380+ init_val (*argv, theTimeout, d);
381 }
382 else if (strcmp (*argv, "--uri-path") == 0) {
383 int d = 2;
384 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
385- if (*argv == NULL) { result = "No value given for --uri-path option"; break; } init_val (*argv, theUriPath, d);
386+ if (*argv == NULL) { result = "No value given for --uri-path option"; break; }
387+
388+ init_val (*argv, theUriPath, d);
389 }
390 else if (strcmp (*argv, "--lib-path") == 0) {
391 int d = 2;
392 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
393- if (*argv == NULL) { result = "No value given for --lib-path option"; break; } init_val (*argv, theLibPath, d);
394+ if (*argv == NULL) { result = "No value given for --lib-path option"; break; }
395+
396+ init_val (*argv, theLibPath, d);
397 }
398 else if (strcmp (*argv, "--module-path") == 0) {
399 int d = 2;
400 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
401- if (*argv == NULL) { result = "No value given for --module-path option"; break; } init_val (*argv, theModulePath, d);
402+ if (*argv == NULL) { result = "No value given for --module-path option"; break; }
403+
404+ init_val (*argv, theModulePath, d);
405+ }
406+ else if (strcmp (*argv, "--classpath") == 0) {
407+ int d = 2;
408+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
409+ if (*argv == NULL) { result = "No value given for --classpath option"; break; }
410+
411+ init_val (*argv, theClasspath, d);
412 }
413 else if (strcmp (*argv, "--option") == 0) {
414 int d = 2;
415 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
416- if (*argv == NULL) { result = "No value given for --option option"; break; } init_val (*argv, theOption, d);
417+ if (*argv == NULL) { result = "No value given for --option option"; break; }
418+
419+ init_val (*argv, theOption, d);
420 }
421 else if (strcmp (*argv, "--trailing-nl") == 0) {
422 theTrailingNl = true;
423@@ -298,12 +354,16 @@
424 else if (strcmp (*argv, "--stop-words") == 0) {
425 int d = 2;
426 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
427- if (*argv == NULL) { result = "No value given for --stop-words option"; break; } init_val (*argv, theStopWords, d);
428+ if (*argv == NULL) { result = "No value given for --stop-words option"; break; }
429+
430+ init_val (*argv, theStopWords, d);
431 }
432 else if (strcmp (*argv, "--thesaurus") == 0) {
433 int d = 2;
434 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
435- if (*argv == NULL) { result = "No value given for --thesaurus option"; break; } init_val (*argv, theThesaurus, d);
436+ if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }
437+
438+ init_val (*argv, theThesaurus, d);
439 }
440 else if (strcmp (*argv, "--compile-plan") == 0 || strncmp (*argv, "-c", 2) == 0) {
441 theCompilePlan = true;
442@@ -327,46 +387,47 @@
443
444 const char *get_help_msg () const {
445 return
446-"--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"
447-"--output-file, -o\nWrite the result to the given file.\n\n"
448-"--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"
449-"--serialize-html\nSerialize the result as HTML.\n\n"
450-"--serialize-text\nSerialize the result as Text.\n\n"
451-"--indent, -i\nIndent output.\n\n"
452-"--print-query\nPrint the queries.\n\n"
453-"--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
454-"--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
455-"--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
456-"--base-uri\nSet the base URI property of the static context.\n\n"
457-"--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
458-"--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
459-"--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
460-"--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
461-"--multiple, -m\nExecute the given queries multiple times.\n\n"
462-"--query, -q\nQuery test or file URI (file://...)\n\n"
463-"--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"
464-"--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
465-"--context-item\nSet the context item to the XML document in a given file.\n\n"
466-"--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
467-"--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"
468-"--parse-only\nStop after parsing the query.\n\n"
469-"--compile-only\nOnly compile (don't execute)\n\n"
470-"--no-serializer\nDo not serialize (discard) result.\n\n"
471-"--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
472-"--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
473-"--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
474-"--no-logo\nPrint no logo when starting.\n\n"
475-"--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
476-"--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"
477-"--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
478-"--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
479-"--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"
480-"--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
481-"--stop-words\nMapping specifying a stop-words URI to another.\n\n"
482-"--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
483-"--compile-plan, -c\nOutput the query plan as binary.\n\n"
484-"--execute-plan\nTake a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.\n\n"
485-;
486+ "--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"
487+ "--output-file, -o\nWrite the result to the given file.\n\n"
488+ "--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"
489+ "--serialize-html\nSerialize the result as HTML.\n\n"
490+ "--serialize-text\nSerialize the result as Text.\n\n"
491+ "--indent, -i\nIndent output.\n\n"
492+ "--print-query\nPrint the queries.\n\n"
493+ "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
494+ "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
495+ "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
496+ "--base-uri\nSet the base URI property of the static context.\n\n"
497+ "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
498+ "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
499+ "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
500+ "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
501+ "--multiple, -m\nExecute the given queries multiple times.\n\n"
502+ "--query, -q\nQuery test or file URI (file://...)\n\n"
503+ "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"
504+ "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
505+ "--context-item\nSet the context item to the XML document in a given file.\n\n"
506+ "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
507+ "--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"
508+ "--parse-only\nStop after parsing the query.\n\n"
509+ "--compile-only\nOnly compile (don't execute)\n\n"
510+ "--no-serializer\nDo not serialize (discard) result.\n\n"
511+ "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
512+ "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
513+ "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
514+ "--no-logo\nPrint no logo when starting.\n\n"
515+ "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
516+ "--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"
517+ "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
518+ "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
519+ "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
520+ "--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"
521+ "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
522+ "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
523+ "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
524+ "--compile-plan, -c\nOutput the query plan as binary.\n\n"
525+ "--execute-plan\nTake a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.\n\n"
526+ ;
527 }
528
529 static const ZorbaCMDPropertiesBase *instance () {
530
531=== modified file 'cmake_modules/ZorbaModule.cmake'
532--- cmake_modules/ZorbaModule.cmake 2012-02-23 16:48:01 +0000
533+++ cmake_modules/ZorbaModule.cmake 2012-03-19 16:17:13 +0000
534@@ -140,7 +140,6 @@
535 ENDIF (NOT IS_ABSOLUTE "${MODULE_FILE}")
536 GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)
537
538-
539 MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename)
540
541 # Compute a CMake-symbol-safe version of the target URI, for storing
542@@ -314,7 +313,7 @@
543 ENDIF (MODULE_VERSION)
544 FOREACH (version_infix "" ${version_infixes})
545 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"
546- "${version_infix}" "" "${MODULE_TEST_ONLY}")
547+ "${version_infix}" "" 1 "${MODULE_TEST_ONLY}")
548 ENDFOREACH (version_infix)
549
550 # Also copy the dynamic library from the location it was built.
551@@ -322,7 +321,7 @@
552 GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION)
553 GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME)
554 ADD_COPY_RULE ("LIB" "${lib_location}" "${module_path}/${lib_filename}"
555- "" "${module_lib_target}" "${MODULE_TEST_ONLY}")
556+ "" "${module_lib_target}" 0 "${MODULE_TEST_ONLY}")
557 ENDIF (module_lib_target)
558
559 # Last but not least, whip up a test case that ensures the module
560@@ -375,7 +374,7 @@
561 ENDIF (NOT SCHEMA_TEST_ONLY)
562
563 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"
564- "" "" "${SCHEMA_TEST_ONLY}")
565+ "" "" 1 "${SCHEMA_TEST_ONLY}")
566
567 ENDMACRO (DECLARE_ZORBA_SCHEMA)
568
569@@ -407,25 +406,70 @@
570 MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename)
571
572 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}"
573- "" "" "${URI_FILE_TEST_ONLY}")
574+ "" "" 1 "${URI_FILE_TEST_ONLY}")
575
576 ENDMACRO (DECLARE_ZORBA_URI_FILE)
577
578+
579+# Inform Zorba of a .jar file that should be made available on the CLASSPATH
580+# of the JVM, should the JVM be started. QQQ more doc needed
581+#
582+# Args: FILE - path to file (must be absolute)
583+# EXTERNAL - (optional) FILE specifies a path that should be added
584+# to CLASSPATH as-is
585+# TEST_ONLY - (optional) Jar file is for testcases only and should not
586+# be installed
587+MACRO (DECLARE_ZORBA_JAR)
588+ PARSE_ARGUMENTS (JAR "FILE" "" "TEST_ONLY;EXTERNAL" ${ARGN})
589+ IF (NOT JAR_FILE)
590+ MESSAGE (FATAL_ERROR "'FILE' argument is required for DECLARE_ZORBA_JAR")
591+ ENDIF (NOT JAR_FILE)
592+
593+ # Initialize classpath file and set up copy rule (once per project)
594+ SET (_CP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-classpath.txt")
595+ GET_PROPERTY (_known_project GLOBAL PROPERTY "${PROJECT_NAME}-jars")
596+ IF (NOT _known_project)
597+ FILE (REMOVE "${_CP_FILE}")
598+ SET_PROPERTY (GLOBAL PROPERTY "${PROJECT_NAME}-jars" 1)
599+ ADD_COPY_RULE ("LIB" "${_CP_FILE}" "jars/${PROJECT_NAME}-classpath.txt"
600+ "" "" 1 "${JAR_TEST_ONLY}")
601+ ENDIF (NOT _known_project)
602+
603+ # Iterate over all supplied jar files
604+ FOREACH (_jar_file ${JAR_FILE})
605+
606+ IF (JAR_EXTERNAL)
607+ # Put absolute path into classpath file
608+ FILE (APPEND "${_CP_FILE}" "${_jar_file}\n")
609+ ELSE (JAR_EXTERNAL)
610+ # Copy jar to jars/ directory and add relative path to classpath file
611+ GET_FILENAME_COMPONENT (_output_filename "${_jar_file}" NAME)
612+ ADD_COPY_RULE ("LIB" "${_jar_file}" "jars/${_output_filename}" "" ""
613+ 1 "${JAR_TEST_ONLY}")
614+ FILE (APPEND "${_CP_FILE}" "${_output_filename}\n")
615+ ENDIF (JAR_EXTERNAL)
616+
617+ ENDFOREACH (_jar_file)
618+ENDMACRO (DECLARE_ZORBA_JAR)
619+
620+
621 # Utility macro for setting up a build rule to copy a file to a
622-# particular (possibly versioned) file in a shared directory if such a file has
623-# not already been output.
624+# particular (possibly versioned) file in a shared directory if such a
625+# file has not already been output.
626+#
627 # FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared
628-# directory to place output in (URI_PATH or LIB_PATH). Also, "URI" files
629-# will have an INSTALL() directive to put them in the install image.
630+# directory to place output in (URI_PATH or LIB_PATH).
631 # INPUT_FILE: Absolute path to file to copy.
632 # OUTPUT_FILE: Relative path to output file (relative to URI_PATH).
633 # VERSION_ARG: Version; may be "" for non-versioned files.
634 # DEPEND_TARGET: A CMake target name upon which the copy rule should depend;
635 # may be "".
636+# INSTALL: If 1, an INSTALL() directive will be executed to put the
637+# file into the install image.
638 # TEST_ONLY: If 1, file is for testcases only; will be copied into
639-# TEST_URI_PATH/TEST_LIB_PATH and will not be installed
640+# TEST_URI_PATH/TEST_LIB_PATH and will not be installed.
641 MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG
642- DEPEND_TARGET TEST_ONLY)
643+ DEPEND_TARGET INSTALL TEST_ONLY)
644 # Choose output base directory
645 IF (${TEST_ONLY} EQUAL 1)
646 SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")
647@@ -470,13 +514,13 @@
648 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES
649 "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")
650
651- # Also set up an INSTALL rule (unless TEST_ONLY or LIB).
652- IF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) )
653+ # Also set up an INSTALL rule (unless TEST_ONLY).
654+ IF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
655
656 IF(NOT _is_core)
657 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME})
658 INSTALL (FILES "${INPUT_FILE}"
659- DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}"
660+ DESTINATION "${ZORBA_NONCORE_${FILE_TYPE}_DIR}/${_output_path}"
661 RENAME "${_output_filename}"
662 COMPONENT "${component_name}")
663
664@@ -496,11 +540,11 @@
665
666 ELSE(NOT _is_core)
667 INSTALL (FILES "${INPUT_FILE}"
668- DESTINATION "${ZORBA_CORE_URI_DIR}/${_output_path}"
669+ DESTINATION "${ZORBA_CORE_${FILE_TYPE}_DIR}/${_output_path}"
670 RENAME "${_output_filename}")
671 ENDIF(NOT _is_core)
672
673- ENDIF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) )
674+ ENDIF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
675 ENDIF (file_found EQUAL -1)
676 ENDMACRO (ADD_COPY_RULE)
677
678
679=== modified file 'include/zorba/properties_base.h'
680--- include/zorba/properties_base.h 2012-01-11 15:56:57 +0000
681+++ include/zorba/properties_base.h 2012-03-19 16:17:13 +0000
682@@ -101,8 +101,44 @@
683 std::vector<std::string>& val,
684 unsigned delta);
685
686+/**
687+ * \brief This class provides access to global properties.
688+ *
689+ * This class provides access to global properties set for Zorba in environment
690+ * and configuration file.
691+ * It is available using Zorba.getProperties() method.
692+ * \see { Zorba::getProperties() }
693+ */
694+class ZORBA_DLL_PUBLIC PropertiesGlobal : public PropertiesBase
695+{
696+public:
697+ virtual ~PropertiesGlobal() {}
698+
699+ /**
700+ * \brief Get global JVM classpath property.
701+ *
702+ * Before the JVM is started this will return the classpath set by
703+ * command line option, the CLASSPATH environment variable and in Zorba
704+ * config file.
705+ *
706+ * After the JVM is started this will contain in addition the paths to jars
707+ * used by modules that make use of the JVM.
708+ */
709+ virtual void getJVMClassPath(std::string & jvmClasspath) {}
710+
711+ /**
712+ * \brief Set global JVM classpath property.
713+ *
714+ * This method should be used to set additional JVM classpath for modules
715+ * that make use of JVM. This will overide the classpath set by CLASSPATH
716+ * environment variable or Zorba config file.
717+ *
718+ * Once the JVM is started this method doesn't have any effect.
719+ */
720+ virtual void setJVMClassPath(const std::string & jvmClasspath) {}
721+};
722+
723 }
724-
725 #endif // ZORBA_PROPERTIES_BASE_H
726 /*
727 * Local variables:
728
729=== modified file 'include/zorba/util/file.h'
730--- include/zorba/util/file.h 2012-01-11 15:56:57 +0000
731+++ include/zorba/util/file.h 2012-03-19 16:17:13 +0000
732@@ -24,6 +24,7 @@
733 #include <cstdio>
734 #include <string>
735 #include <time.h>
736+#include <vector>
737
738 #include <zorba/config.h>
739 #include <zorba/file.h>
740@@ -84,6 +85,7 @@
741 void mkdir();
742 void deep_mkdir();
743 void rmdir(bool ignore = true);
744+ void lsdir(std::vector<std::string> &list);
745 #ifndef _WIN32_WCE
746 void chdir();
747 #endif
748
749=== modified file 'include/zorba/zorba.h'
750--- include/zorba/zorba.h 2012-01-11 15:56:57 +0000
751+++ include/zorba/zorba.h 2012-03-19 16:17:13 +0000
752@@ -34,14 +34,18 @@
753 #include <zorba/xquery.h>
754 #include <zorba/zorba_string.h>
755 #include <zorba/iterator.h>
756+#include <zorba/properties_base.h>
757
758 namespace zorba {
759
760 /**
761 * The Zorba class is the single point of access to the %Zorba engine.
762 * There exists one instance of the Zorba class per process.
763- * It can be used to (1) create and compile queries, (2) create static contexts,
764- * (3) provides access to the XmlDataManager, and (4) provides access to the ItemFactory.
765+ * It can be used to (1) create and compile queries,
766+ * (2) create static contexts,
767+ * (3) provides access to the XmlDataManager,
768+ * (4) provides access to the ItemFactory, and
769+ * (5) provides access to the PropertiesGlobal.
770 */
771 class ZORBA_DLL_PUBLIC Zorba
772 {
773@@ -301,7 +305,7 @@
774 virtual StaticContext_t
775 createStaticContext(DiagnosticHandler* aDiagnosticHandler = 0) = 0;
776
777- /** \brief Gets the singelton instance of the ItemFactory.
778+ /** \brief Gets the singleton instance of the ItemFactory.
779 *
780 * @return ItemFactory the singleton instance of the ItemFactory.
781 */
782@@ -310,18 +314,24 @@
783
784 /** \brief Gets the singleton instance of the XmlDataManager object.
785 *
786- * @return XmlDataManager the singelton instance of the XmlDataManager.
787+ * @return XmlDataManager the singleton instance of the XmlDataManager.
788 */
789 virtual XmlDataManager*
790 getXmlDataManager() = 0;
791
792 /** \brief Gets the singleton instance of Zorba's audit provider object.
793 *
794- * @return audit::Provider the singelton instance of Zorba's audit provider.
795+ * @return audit::Provider the singeleton instance of Zorba's audit provider.
796 */
797 virtual audit::Provider*
798 getAuditProvider() = 0;
799
800+ /** \brief Gets the singleton instance of Zorba's properties object.
801+ *
802+ * @return zorba::Properties the singleton instance of Zorba's properties object.
803+ */
804+ virtual PropertiesGlobal* getPropertiesGlobal() = 0;
805+
806 }; /* class Zorba */
807
808
809
810=== modified file 'src/api/staticcontextimpl.h'
811--- src/api/staticcontextimpl.h 2012-02-29 11:10:30 +0000
812+++ src/api/staticcontextimpl.h 2012-03-19 16:17:13 +0000
813@@ -281,6 +281,7 @@
814 virtual void
815 getFullLibPath(std::vector<String>& aLibPath) const;
816
817+
818 protected:
819 String
820 createInvokeQuery(const Function_t&, size_t aArity) const;
821
822=== modified file 'src/api/zorbaimpl.cpp'
823--- src/api/zorbaimpl.cpp 2012-01-31 19:47:57 +0000
824+++ src/api/zorbaimpl.cpp 2012-03-19 16:17:13 +0000
825@@ -35,6 +35,7 @@
826 #include "diagnostics/xquery_diagnostics.h"
827
828 #include "system/globalenv.h"
829+#include "system/properties.h"
830
831 #include "context/static_context.h"
832
833@@ -269,6 +270,15 @@
834 }
835
836
837+/*******************************************************************************
838+
839+********************************************************************************/
840+PropertiesGlobal* ZorbaImpl::getPropertiesGlobal()
841+{
842+ return Properties::instance();
843+}
844+
845+
846 void ZorbaImpl::notifyError( DiagnosticHandler *eh, ZorbaException const &ze ) {
847 eh->error( ze );
848 }
849
850=== modified file 'src/api/zorbaimpl.h'
851--- src/api/zorbaimpl.h 2012-01-11 15:56:57 +0000
852+++ src/api/zorbaimpl.h 2012-03-19 16:17:13 +0000
853@@ -134,6 +134,8 @@
854
855 audit::Provider* getAuditProvider();
856
857+ PropertiesGlobal* getPropertiesGlobal();
858+
859 protected:
860 ZorbaImpl();
861
862
863=== modified file 'src/context/dynamic_loader.cpp'
864--- src/context/dynamic_loader.cpp 2012-01-18 13:57:48 +0000
865+++ src/context/dynamic_loader.cpp 2012-03-19 16:17:13 +0000
866@@ -132,8 +132,15 @@
867 ExternalModule*
868 DynamicLoader::loadModule(const zstring& aFile) const
869 {
870- // function pointer to create a module
871- ExternalModule* (*createModule)() = NULL;
872+ handle_t handle;
873+ std::map<const zstring, handle_t>::const_iterator lIter;
874+
875+ lIter = theLibraries.find(aFile);
876+ if (lIter != theLibraries.end())
877+ {
878+ handle = lIter->second;
879+ return createModule(handle, aFile);
880+ }
881
882 #ifdef WIN32
883 WCHAR wpath_str[1024];
884@@ -146,43 +153,51 @@
885 0, aFile.c_str(), -1,
886 wpath_str, sizeof(wpath_str)/sizeof(WCHAR));
887 }
888- HMODULE handle = LoadLibraryW(wpath_str);
889+
890+ handle = LoadLibraryW(wpath_str);
891 if (!handle)
892 throw ZORBA_EXCEPTION(
893 zerr::ZOSE0005_DLL_LOAD_FAILED,
894 ERROR_PARAMS( aFile, os_error::get_err_string() )
895 );
896-
897+#else
898+ handle = dlopen(aFile.c_str(), RTLD_NOW);
899+ if (!handle)
900+ throw ZORBA_EXCEPTION(
901+ zerr::ZOSE0005_DLL_LOAD_FAILED, ERROR_PARAMS( aFile, zstring(dlerror()) )
902+ );
903+#endif
904+
905+ theLibraries[aFile] = handle;
906+ return createModule(handle, aFile);
907+}
908+
909+
910+ExternalModule*
911+DynamicLoader::createModule(handle_t handle, const zstring& aFile) const
912+{
913+ // function pointer to create a module
914+ ExternalModule* (*createModuleFunction)() = NULL;
915+
916+#ifdef WIN32
917 createModule = (ExternalModule* (*)())GetProcAddress(handle, "createModule");
918- if (createModule == NULL)
919+ if (createModuleFunction == NULL)
920 throw ZORBA_EXCEPTION(
921 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
922 ERROR_PARAMS( aFile, os_error::get_err_string() )
923 );
924-
925 #else
926- void* handle = dlopen(aFile.c_str(), RTLD_NOW);
927- if (!handle)
928- throw ZORBA_EXCEPTION(
929- zerr::ZOSE0005_DLL_LOAD_FAILED, ERROR_PARAMS( aFile, zstring(dlerror()) )
930- );
931-
932- createModule = (ExternalModule* (*)()) dlsym(handle, "createModule");
933- if (createModule == NULL)
934+ createModuleFunction = (ExternalModule* (*)()) dlsym(handle, "createModule");
935+ if (createModuleFunction == NULL)
936 {
937 dlclose(handle);
938 throw ZORBA_EXCEPTION(
939- zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
940- ERROR_PARAMS( aFile, dlerror() )
941- );
942+ zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
943+ ERROR_PARAMS( aFile, dlerror() )
944+ );
945 }
946 #endif
947- if (theLibraries.find(handle) == theLibraries.end())
948- {
949- theLibraries.insert(handle);
950- }
951-
952- return createModule();
953+ return createModuleFunction();
954 }
955
956
957@@ -193,13 +208,13 @@
958
959 DynamicLoader::~DynamicLoader()
960 {
961- for (LibrarySet_t::const_iterator lIter = theLibraries.begin();
962+ for (LibraryMap_t::const_iterator lIter = theLibraries.begin();
963 lIter != theLibraries.end(); ++lIter)
964 {
965 #ifdef WIN32
966- FreeLibrary(*lIter);
967+ FreeLibrary(lIter->second);
968 #else
969- dlclose(*lIter);
970+ dlclose(lIter->second);
971 #endif
972 }
973 }
974
975=== modified file 'src/context/dynamic_loader.h'
976--- src/context/dynamic_loader.h 2012-01-11 15:56:57 +0000
977+++ src/context/dynamic_loader.h 2012-03-19 16:17:13 +0000
978@@ -18,7 +18,7 @@
979 #define ZORBA_DYNAMIC_LOADER_H
980
981 #include "common/common.h"
982-#include <set>
983+#include <map>
984 #include "common/shared_types.h"
985
986 namespace zorba {
987@@ -40,15 +40,20 @@
988
989 ~DynamicLoader();
990
991- ExternalModule* loadModule(const zstring& aFile) const;
992
993 #ifdef WIN32
994- typedef std::set<HMODULE> LibrarySet_t;
995+ typedef HMODULE handle_t;
996 #else
997- typedef std::set<void*> LibrarySet_t;
998+ typedef void * handle_t;
999 #endif
1000
1001- mutable LibrarySet_t theLibraries;
1002+ ExternalModule* loadModule(const zstring& aFile) const;
1003+ ExternalModule* createModule(handle_t handle, const zstring& aFile) const;
1004+
1005+
1006+ typedef std::map<const zstring, handle_t> LibraryMap_t;
1007+
1008+ mutable LibraryMap_t theLibraries;
1009 };
1010
1011 } /* namespace zorba */
1012
1013=== modified file 'src/context/static_context.cpp'
1014--- src/context/static_context.cpp 2012-03-15 15:27:46 +0000
1015+++ src/context/static_context.cpp 2012-03-19 16:17:13 +0000
1016@@ -1699,6 +1699,43 @@
1017 }
1018
1019
1020+////////////////////////////////////////////////////////////////////////////////
1021+// //
1022+// JVM Classpath //
1023+// //
1024+////////////////////////////////////////////////////////////////////////////////
1025+
1026+/*******************************************************************************
1027+
1028+********************************************************************************/
1029+void static_context::set_jvm_class_path(const std::vector<zstring>& path)
1030+{
1031+ theJVMClassPath = path;
1032+}
1033+
1034+
1035+/*******************************************************************************
1036+
1037+********************************************************************************/
1038+void static_context::get_jvm_class_path(std::vector<zstring>& path) const
1039+{
1040+ path.insert(path.end(), theJVMClassPath.begin(), theJVMClassPath.end());
1041+}
1042+
1043+/*******************************************************************************
1044+
1045+********************************************************************************/
1046+void static_context::get_full_jvm_class_path(std::vector<zstring>& path) const
1047+{
1048+ if (theParent != NULL)
1049+ {
1050+ theParent->get_full_jvm_class_path(path);
1051+ }
1052+
1053+ get_jvm_class_path(path);
1054+}
1055+
1056+
1057 /////////////////////////////////////////////////////////////////////////////////
1058 // //
1059 // Validating Items //
1060
1061=== modified file 'src/context/static_context.h'
1062--- src/context/static_context.h 2012-03-14 15:28:15 +0000
1063+++ src/context/static_context.h 2012-03-19 16:17:13 +0000
1064@@ -510,6 +510,8 @@
1065
1066 ExternalModuleMap * theExternalModulesMap;
1067
1068+ checked_vector<zstring> theJVMClassPath;
1069+
1070 rchandle<TypeManager> theTypeManager;
1071
1072 NamespaceBindings * theNamespaceBindings;
1073@@ -713,6 +715,15 @@
1074 void get_full_lib_path(std::vector<zstring>& oLibPath) const;
1075
1076 //
1077+ // JVM classpath
1078+ //
1079+ void set_jvm_class_path(const std::vector<zstring>& aClassPath);
1080+
1081+ void get_jvm_class_path(std::vector<zstring>& oClassPath) const;
1082+
1083+ void get_full_jvm_class_path(std::vector<zstring>& path) const;
1084+
1085+ //
1086 // Validating Items
1087 //
1088 bool validate(
1089
1090=== modified file 'src/precompiled/stdafx.h'
1091--- src/precompiled/stdafx.h 2012-03-15 15:30:19 +0000
1092+++ src/precompiled/stdafx.h 2012-03-19 16:17:13 +0000
1093@@ -80,7 +80,7 @@
1094 // #include "compiler/expression/ft_expr.h"
1095 // #include "compiler/expression/ftnode.h"
1096 // #include "compiler/parser/query_loc.h"
1097- #include "util/cxx_util.h"
1098+// #include "util/cxx_util.h"
1099 // #include "util/indent.h"
1100 // #include "util/stl_util.h"
1101 // #include "diagnostics/xquery_diagnostics.h"
1102@@ -166,7 +166,7 @@
1103 // #include "compiler/api/compiler_api.h"
1104 // #include "compiler/api/compiler_api_impl.h"
1105 // #include "system/globalenv.h"
1106-// #include "system/properties.h"
1107+#include "system/properties.h"
1108 // #include "system/zorba_properties.h"
1109 // #include "context/decimal_format.h"
1110 // #include "context/default_uri_mappers.h"
1111@@ -182,7 +182,7 @@
1112 // #include "context/stemmer_wrappers.h"
1113 // #include "context/uri_resolver.h"
1114 // #include "context/uri_resolver_wrapper.h"
1115-#include "diagnostics/assert.h"
1116+// //#include "diagnostics/assert.h"
1117 // #include "diagnostics/diagnostic.h"
1118 // #include "diagnostics/dict.h"
1119 // #include "diagnostics/dict_impl.h"
1120@@ -370,8 +370,7 @@
1121 #include "zorba/diagnostic_handler.h"
1122 #include "zorba/xquery_warning.h"
1123 #include "runtime/full_text/ftcontains_visitor.h"
1124- #include "store/naive/naive_ft_token_iterator.h"
1125- #include "store/api/ft_token_iterator.h"
1126- #include "store/naive/ft_token_store.h"
1127+ #include "store/naive/node_items.h"
1128+
1129 #endif
1130 /* vim:set et sw=2 ts=2: */
1131
1132=== modified file 'src/system/properties.h'
1133--- src/system/properties.h 2012-01-11 15:56:57 +0000
1134+++ src/system/properties.h 2012-03-19 16:17:13 +0000
1135@@ -67,6 +67,27 @@
1136
1137 std::ostream& debug_out() { return *debug_stream; }
1138
1139+ /**
1140+ * Before the JVM is started this will return the classpath set by
1141+ * command line option, the CLASSPATH environment variable and in Zorba
1142+ * config file.
1143+ *
1144+ * After the JVM is started this will contain in addition the paths to jars
1145+ * used by modules that make use of the JVM.
1146+ */
1147+ void getJVMClassPath(std::string & jvmClasspath)
1148+ { jvmClasspath = theCLASSPATH ; }
1149+
1150+ /**
1151+ * This method should be used to set additional JVM classpath for modules
1152+ * that make use of JVM. This will overide the classpath set by CLASSPATH
1153+ * environment variable or Zorba config file.
1154+ *
1155+ * Once the JVM is started this method doesn't have any effect.
1156+ */
1157+ void setJVMClassPath(const std::string & jvmClasspath)
1158+ { theCLASSPATH = jvmClasspath; }
1159+
1160 protected:
1161 /**
1162 * Gets the Operation System folder where the properties of the current
1163
1164=== modified file 'src/system/zorba_properties.h'
1165--- src/system/zorba_properties.h 2012-02-29 11:10:30 +0000
1166+++ src/system/zorba_properties.h 2012-03-19 16:17:13 +0000
1167@@ -26,13 +26,25 @@
1168 namespace zorba
1169 {
1170
1171-class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesBase
1172+class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesGlobal
1173 {
1174 protected:
1175 const char** get_all_options() const
1176 {
1177- static const char* result [] =
1178- { "--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 };
1179+ static const char* result [] = {
1180+ "--trace-parsing", "--trace-scanning", "--use-serializer", "--optimizer",
1181+ "--result-file", "--debug-file", "--abort", "--query", "--print-query",
1182+ "--print-time", "--print-ast", "--print-xqdoc", "--print-translated",
1183+ "--print-normalized", "--print-optimized", "--print-iterator-tree",
1184+ "--print-item-flow", "--print-static-types", "--dump-lib",
1185+ "--stable-iterator-ids", "--no-tree-ids", "--print-intermediate-opt",
1186+ "--print-locations", "--force-gflwor", "--reorder-globals",
1187+ "--specialize-num", "--specialize-cmp", "--inline-udf", "--loop-hoisting",
1188+ "--infer-joins", "--no-copy-optim", "--serialize-only-query",
1189+ "--trace-translator", "--trace-codegen", "--trace-fulltext", "--debug",
1190+ "--compile-only", "--tz", "--external-var", "--serializer-param",
1191+ "--iter-plan-test", "--dot-plan-file", "--max-udf-call-depth",
1192+ "--CLASSPATH", NULL };
1193
1194 return result;
1195 }
1196@@ -80,6 +92,7 @@
1197 bool theIterPlanTest;
1198 std::string theDotPlanFile;
1199 uint32_t theMaxUdfCallDepth;
1200+ std::string theCLASSPATH;
1201
1202 void initialize()
1203 {
1204@@ -165,6 +178,7 @@
1205 const bool &iterPlanTest () const { return theIterPlanTest; }
1206 const std::string &dotPlanFile () const { return theDotPlanFile; }
1207 const uint32_t &maxUdfCallDepth () const { return theMaxUdfCallDepth; }
1208+ const std::string &CLASSPATH () const { return theCLASSPATH; }
1209
1210 std::string load_argv (int argc, const char **argv)
1211 {
1212@@ -200,7 +214,9 @@
1213 else if (strcmp (*argv, "--debug-file") == 0) {
1214 int d = 2;
1215 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1216- if (*argv == NULL) { result = "No value given for --debug-file option"; break; } init_val (*argv, theDebugFile, d);
1217+ if (*argv == NULL) { result = "No value given for --debug-file option"; break; }
1218+
1219+ init_val (*argv, theDebugFile, d);
1220 }
1221 else if (strcmp (*argv, "--abort") == 0) {
1222 theAbort = true;
1223@@ -208,7 +224,9 @@
1224 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-e", 2) == 0) {
1225 int d = 2;
1226 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1227- if (*argv == NULL) { result = "No value given for --query option"; break; } init_val (*argv, theQuery, d);
1228+ if (*argv == NULL) { result = "No value given for --query option"; break; }
1229+
1230+ init_val (*argv, theQuery, d);
1231 }
1232 else if (strcmp (*argv, "--print-query") == 0 || strncmp (*argv, "-q", 2) == 0) {
1233 thePrintQuery = true;
1234@@ -240,7 +258,9 @@
1235 else if (strcmp (*argv, "--print-static-types") == 0) {
1236 int d = 2;
1237 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1238- if (*argv == NULL) { result = "No value given for --print-static-types option"; break; } init_val (*argv, thePrintStaticTypes, d);
1239+ if (*argv == NULL) { result = "No value given for --print-static-types option"; break; }
1240+
1241+ init_val (*argv, thePrintStaticTypes, d);
1242 }
1243 else if (strcmp (*argv, "--dump-lib") == 0) {
1244 theDumpLib = true;
1245@@ -263,32 +283,44 @@
1246 else if (strcmp (*argv, "--reorder-globals") == 0) {
1247 int d = 2;
1248 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1249- if (*argv == NULL) { result = "No value given for --reorder-globals option"; break; } init_val (*argv, theReorderGlobals, d);
1250+ if (*argv == NULL) { result = "No value given for --reorder-globals option"; break; }
1251+
1252+ init_val (*argv, theReorderGlobals, d);
1253 }
1254 else if (strcmp (*argv, "--specialize-num") == 0) {
1255 int d = 2;
1256 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1257- if (*argv == NULL) { result = "No value given for --specialize-num option"; break; } init_val (*argv, theSpecializeNum, d);
1258+ if (*argv == NULL) { result = "No value given for --specialize-num option"; break; }
1259+
1260+ init_val (*argv, theSpecializeNum, d);
1261 }
1262 else if (strcmp (*argv, "--specialize-cmp") == 0) {
1263 int d = 2;
1264 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1265- if (*argv == NULL) { result = "No value given for --specialize-cmp option"; break; } init_val (*argv, theSpecializeCmp, d);
1266+ if (*argv == NULL) { result = "No value given for --specialize-cmp option"; break; }
1267+
1268+ init_val (*argv, theSpecializeCmp, d);
1269 }
1270 else if (strcmp (*argv, "--inline-udf") == 0) {
1271 int d = 2;
1272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1273- if (*argv == NULL) { result = "No value given for --inline-udf option"; break; } init_val (*argv, theInlineUdf, d);
1274+ if (*argv == NULL) { result = "No value given for --inline-udf option"; break; }
1275+
1276+ init_val (*argv, theInlineUdf, d);
1277 }
1278 else if (strcmp (*argv, "--loop-hoisting") == 0) {
1279 int d = 2;
1280 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1281- if (*argv == NULL) { result = "No value given for --loop-hoisting option"; break; } init_val (*argv, theLoopHoisting, d);
1282+ if (*argv == NULL) { result = "No value given for --loop-hoisting option"; break; }
1283+
1284+ init_val (*argv, theLoopHoisting, d);
1285 }
1286 else if (strcmp (*argv, "--infer-joins") == 0) {
1287 int d = 2;
1288 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1289- if (*argv == NULL) { result = "No value given for --infer-joins option"; break; } init_val (*argv, theInferJoins, d);
1290+ if (*argv == NULL) { result = "No value given for --infer-joins option"; break; }
1291+
1292+ init_val (*argv, theInferJoins, d);
1293 }
1294 else if (strcmp (*argv, "--no-copy-optim") == 0)
1295 {
1296@@ -325,17 +357,23 @@
1297 else if (strcmp (*argv, "--tz") == 0) {
1298 int d = 2;
1299 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1300- if (*argv == NULL) { result = "No value given for --tz option"; break; } init_val (*argv, theTz, d);
1301+ if (*argv == NULL) { result = "No value given for --tz option"; break; }
1302+
1303+ init_val (*argv, theTz, d);
1304 }
1305 else if (strcmp (*argv, "--external-var") == 0 || strncmp (*argv, "-x", 2) == 0) {
1306 int d = 2;
1307 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1308- if (*argv == NULL) { result = "No value given for --external-var option"; break; } init_val (*argv, theExternalVar, d);
1309+ if (*argv == NULL) { result = "No value given for --external-var option"; break; }
1310+
1311+ init_val (*argv, theExternalVar, d);
1312 }
1313 else if (strcmp (*argv, "--serializer-param") == 0 || strncmp (*argv, "-z", 2) == 0) {
1314 int d = 2;
1315 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1316- if (*argv == NULL) { result = "No value given for --serializer-param option"; break; } init_val (*argv, theSerializerParam, d);
1317+ if (*argv == NULL) { result = "No value given for --serializer-param option"; break; }
1318+
1319+ init_val (*argv, theSerializerParam, d);
1320 }
1321 else if (strcmp (*argv, "--iter-plan-test") == 0) {
1322 theIterPlanTest = true;
1323@@ -343,12 +381,23 @@
1324 else if (strcmp (*argv, "--dot-plan-file") == 0) {
1325 int d = 2;
1326 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1327- if (*argv == NULL) { result = "No value given for --dot-plan-file option"; break; } init_val (*argv, theDotPlanFile, d);
1328+ if (*argv == NULL) { result = "No value given for --dot-plan-file option"; break; }
1329+
1330+ init_val (*argv, theDotPlanFile, d);
1331 }
1332 else if (strcmp (*argv, "--max-udf-call-depth") == 0) {
1333 int d = 2;
1334 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1335- if (*argv == NULL) { result = "No value given for --max-udf-call-depth option"; break; } init_val (*argv, theMaxUdfCallDepth, d);
1336+ if (*argv == NULL) { result = "No value given for --max-udf-call-depth option"; break; }
1337+
1338+ init_val (*argv, theMaxUdfCallDepth, d);
1339+ }
1340+ else if (strcmp (*argv, "--CLASSPATH") == 0) {
1341+ int d = 2;
1342+ if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
1343+ if (*argv == NULL) { result = "No value given for --CLASSPATH option"; break; }
1344+
1345+ init_val (*argv, theCLASSPATH, d);
1346 }
1347 else if (strcmp (*argv, "--") == 0) {
1348 copy_args (++argv);
1349@@ -413,6 +462,7 @@
1350 "--iter-plan-test\nrun as iterator plan test\n\n"
1351 "--dot-plan-file\ngenerate the dot iterator plan\n\n"
1352 "--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"
1353+"--CLASSPATH\nJVM classpath to be used by modules using Java implementations\n\n"
1354 ;
1355 }
1356
1357
1358=== modified file 'src/system/zorba_properties.txt'
1359--- src/system/zorba_properties.txt 2012-02-29 11:10:30 +0000
1360+++ src/system/zorba_properties.txt 2012-03-19 16:17:13 +0000
1361@@ -43,3 +43,4 @@
1362 ("iter-plan-test", "run as iterator plan test")
1363 ("dot-plan-file", po::value<std::string>(), "generate the dot iterator plan")
1364 ("max-udf-call-depth", po::value<uint32_t>()->default_value(1024), "maximum stack depth of udf function calls")
1365+ ("CLASSPATH", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
1366\ No newline at end of file
1367
1368=== modified file 'src/util/file.cpp'
1369--- src/util/file.cpp 2012-01-11 15:56:57 +0000
1370+++ src/util/file.cpp 2012-03-19 16:17:13 +0000
1371@@ -277,6 +277,18 @@
1372 #endif
1373 }
1374
1375+void file::lsdir(std::vector<std::string> &list) {
1376+#ifdef ZORBA_WITH_FILE_ACCESS
1377+ try {
1378+ fs::lsdir( c_str(), list );
1379+ set_filetype( type_directory );
1380+ }
1381+ catch ( fs::exception const &e ) {
1382+ throw ZORBA_IO_EXCEPTION( e.function(), e.path() );
1383+ }
1384+#endif
1385+}
1386+
1387 void file::deep_mkdir() {
1388 #ifdef ZORBA_WITH_FILE_ACCESS
1389 vector<file> files;
1390
1391=== modified file 'src/util/fs_util.cpp'
1392--- src/util/fs_util.cpp 2012-01-11 15:56:57 +0000
1393+++ src/util/fs_util.cpp 2012-03-19 16:17:13 +0000
1394@@ -277,6 +277,30 @@
1395 #endif
1396 }
1397
1398+void lsdir( char const *path, std::vector<std::string> &list )
1399+{
1400+ DIR *dir;
1401+ struct dirent *ent;
1402+
1403+ dir = opendir (path);
1404+ if (dir != NULL)
1405+ {
1406+ /* print all the files and directories within directory */
1407+ while ((ent = readdir (dir)) != NULL)
1408+ {
1409+ //printf ("%s\n", ent->d_name);
1410+ std::string item(ent->d_name);
1411+ list.push_back(item);
1412+ }
1413+ closedir (dir);
1414+ }
1415+ else
1416+ {
1417+ /* could not open directory */
1418+ throw fs::exception( "lsdir()", path );
1419+ }
1420+}
1421+
1422 bool remove( char const *path ) {
1423 #ifndef WIN32
1424 return ::remove( path ) == 0;
1425
1426=== modified file 'src/util/fs_util.h'
1427--- src/util/fs_util.h 2012-01-11 15:56:57 +0000
1428+++ src/util/fs_util.h 2012-03-19 16:17:13 +0000
1429@@ -17,6 +17,14 @@
1430 #ifndef ZORBA_FS_UTIL_H
1431 #define ZORBA_FS_UTIL_H
1432
1433+#include <vector>
1434+
1435+#ifdef WIN32
1436+# include "win32/dirent.h"
1437+#else
1438+# include <dirent.h> /* for implementing lsdir */
1439+#endif /* WIN32 */
1440+
1441 #include <zorba/config.h>
1442
1443 #include <stdexcept>
1444@@ -144,6 +152,26 @@
1445 mkdir( path.c_str() );
1446 }
1447
1448+/**
1449+ * List files in dir
1450+ *
1451+ * @param path The full path of the directory to list.
1452+ * @throws fs::exception if the list fails.
1453+ */
1454+void lsdir( char const *path, std::vector<std::string> & list );
1455+
1456+/**
1457+ * List files in dir
1458+ *
1459+ * @tparam PathStringType The \a path string type.
1460+ * @param path The full path of the directory to list.
1461+ * @throws fs::exception if the list fails.
1462+ */
1463+template<class PathStringType> inline
1464+void lsdir( PathStringType const &path, std::vector<std::string> & list ) {
1465+ lsdir( path.c_str(), list );
1466+}
1467+
1468 #endif /* ZORBA_WITH_FILE_ACCESS */
1469
1470 ////////// File creation //////////////////////////////////////////////////////
1471
1472=== added file 'src/util/win32/dirent.h'
1473--- src/util/win32/dirent.h 1970-01-01 00:00:00 +0000
1474+++ src/util/win32/dirent.h 2012-03-19 16:17:13 +0000
1475@@ -0,0 +1,372 @@
1476+/*****************************************************************************
1477+ * dirent.h - dirent API for Microsoft Visual Studio
1478+ *
1479+ * Copyright (C) 2006 Toni Ronkko
1480+ *
1481+ * Permission is hereby granted, free of charge, to any person obtaining
1482+ * a copy of this software and associated documentation files (the
1483+ * ``Software''), to deal in the Software without restriction, including
1484+ * without limitation the rights to use, copy, modify, merge, publish,
1485+ * distribute, sublicense, and/or sell copies of the Software, and to
1486+ * permit persons to whom the Software is furnished to do so, subject to
1487+ * the following conditions:
1488+ *
1489+ * The above copyright notice and this permission notice shall be included
1490+ * in all copies or substantial portions of the Software.
1491+ *
1492+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
1493+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1494+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1495+ * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
1496+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1497+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1498+ * OTHER DEALINGS IN THE SOFTWARE.
1499+ *
1500+ * Mar 15, 2011, Toni Ronkko
1501+ * Defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
1502+ *
1503+ * Aug 11, 2010, Toni Ronkko
1504+ * Added d_type and d_namlen fields to dirent structure. The former is
1505+ * especially useful for determining whether directory entry represents a
1506+ * file or a directory. For more information, see
1507+ * http://www.delorie.com/gnu/docs/glibc/libc_270.html
1508+ *
1509+ * Aug 11, 2010, Toni Ronkko
1510+ * Improved conformance to the standards. For example, errno is now set
1511+ * properly on failure and assert() is never used. Thanks to Peter Brockam
1512+ * for suggestions.
1513+ *
1514+ * Aug 11, 2010, Toni Ronkko
1515+ * Fixed a bug in rewinddir(): when using relative directory names, change
1516+ * of working directory no longer causes rewinddir() to fail.
1517+ *
1518+ * Dec 15, 2009, John Cunningham
1519+ * Added rewinddir member function
1520+ *
1521+ * Jan 18, 2008, Toni Ronkko
1522+ * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
1523+ * between multi-byte and unicode representations. This makes the
1524+ * code simpler and also allows the code to be compiled under MingW. Thanks
1525+ * to Azriel Fasten for the suggestion.
1526+ *
1527+ * Mar 4, 2007, Toni Ronkko
1528+ * Bug fix: due to the strncpy_s() function this file only compiled in
1529+ * Visual Studio 2005. Using the new string functions only when the
1530+ * compiler version allows.
1531+ *
1532+ * Nov 2, 2006, Toni Ronkko
1533+ * Major update: removed support for Watcom C, MS-DOS and Turbo C to
1534+ * simplify the file, updated the code to compile cleanly on Visual
1535+ * Studio 2005 with both unicode and multi-byte character strings,
1536+ * removed rewinddir() as it had a bug.
1537+ *
1538+ * Aug 20, 2006, Toni Ronkko
1539+ * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
1540+ * comments by removing SGML tags.
1541+ *
1542+ * May 14 2002, Toni Ronkko
1543+ * Embedded the function definitions directly to the header so that no
1544+ * source modules need to be included in the Visual Studio project. Removed
1545+ * all the dependencies to other projects so that this very header can be
1546+ * used independently.
1547+ *
1548+ * May 28 1998, Toni Ronkko
1549+ * First version.
1550+ *****************************************************************************/
1551+#ifndef DIRENT_H
1552+#define DIRENT_H
1553+
1554+#define WIN32_LEAN_AND_MEAN
1555+#include <windows.h>
1556+#include <string.h>
1557+#include <stdlib.h>
1558+#include <sys/types.h>
1559+#include <sys/stat.h>
1560+#include <errno.h>
1561+
1562+/* Entries missing from MSVC 6.0 */
1563+#if !defined(FILE_ATTRIBUTE_DEVICE)
1564+# define FILE_ATTRIBUTE_DEVICE 0x40
1565+#endif
1566+
1567+/* File type and permission flags for stat() */
1568+#if defined(_MSC_VER) && !defined(S_IREAD)
1569+# define S_IFMT _S_IFMT /* file type mask */
1570+# define S_IFDIR _S_IFDIR /* directory */
1571+# define S_IFCHR _S_IFCHR /* character device */
1572+# define S_IFFIFO _S_IFFIFO /* pipe */
1573+# define S_IFREG _S_IFREG /* regular file */
1574+# define S_IREAD _S_IREAD /* read permission */
1575+# define S_IWRITE _S_IWRITE /* write permission */
1576+# define S_IEXEC _S_IEXEC /* execute permission */
1577+#endif
1578+#define S_IFBLK 0 /* block device */
1579+#define S_IFLNK 0 /* link */
1580+#define S_IFSOCK 0 /* socket */
1581+
1582+#if defined(_MSC_VER)
1583+# define S_IRUSR S_IREAD /* read, user */
1584+# define S_IWUSR S_IWRITE /* write, user */
1585+# define S_IXUSR 0 /* execute, user */
1586+# define S_IRGRP 0 /* read, group */
1587+# define S_IWGRP 0 /* write, group */
1588+# define S_IXGRP 0 /* execute, group */
1589+# define S_IROTH 0 /* read, others */
1590+# define S_IWOTH 0 /* write, others */
1591+# define S_IXOTH 0 /* execute, others */
1592+#endif
1593+
1594+/* Indicates that d_type field is available in dirent structure */
1595+#define _DIRENT_HAVE_D_TYPE
1596+
1597+/* File type flags for d_type */
1598+#define DT_UNKNOWN 0
1599+#define DT_REG S_IFREG
1600+#define DT_DIR S_IFDIR
1601+#define DT_FIFO S_IFFIFO
1602+#define DT_SOCK S_IFSOCK
1603+#define DT_CHR S_IFCHR
1604+#define DT_BLK S_IFBLK
1605+
1606+/* Macros for converting between st_mode and d_type */
1607+#define IFTODT(mode) ((mode) & S_IFMT)
1608+#define DTTOIF(type) (type)
1609+
1610+/*
1611+ * File type macros. Note that block devices, sockets and links cannot be
1612+ * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
1613+ * only defined for compatibility. These macros should always return false
1614+ * on Windows.
1615+ */
1616+#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
1617+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
1618+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
1619+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
1620+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
1621+#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
1622+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
1623+
1624+#ifdef __cplusplus
1625+extern "C" {
1626+#endif
1627+
1628+
1629+typedef struct dirent
1630+{
1631+ char d_name[MAX_PATH + 1]; /* File name */
1632+ size_t d_namlen; /* Length of name without \0 */
1633+ int d_type; /* File type */
1634+} dirent;
1635+
1636+
1637+typedef struct DIR
1638+{
1639+ dirent curentry; /* Current directory entry */
1640+ WIN32_FIND_DATAA find_data; /* Private file data */
1641+ int cached; /* True if data is valid */
1642+ HANDLE search_handle; /* Win32 search handle */
1643+ char patt[MAX_PATH + 3]; /* Initial directory name */
1644+} DIR;
1645+
1646+
1647+/* Forward declarations */
1648+static DIR *opendir(const char *dirname);
1649+static struct dirent *readdir(DIR *dirp);
1650+static int closedir(DIR *dirp);
1651+static void rewinddir(DIR* dirp);
1652+
1653+
1654+/* Use the new safe string functions introduced in Visual Studio 2005 */
1655+#if defined(_MSC_VER) && _MSC_VER >= 1400
1656+# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
1657+#else
1658+# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
1659+#endif
1660+
1661+/* Set errno variable */
1662+#if defined(_MSC_VER)
1663+#define DIRENT_SET_ERRNO(x) _set_errno (x)
1664+#else
1665+#define DIRENT_SET_ERRNO(x) (errno = (x))
1666+#endif
1667+
1668+
1669+/*****************************************************************************
1670+ * Open directory stream DIRNAME for read and return a pointer to the
1671+ * internal working area that is used to retrieve individual directory
1672+ * entries.
1673+ */
1674+static DIR *opendir(const char *dirname)
1675+{
1676+ DIR *dirp;
1677+
1678+ /* ensure that the resulting search pattern will be a valid file name */
1679+ if (dirname == NULL) {
1680+ DIRENT_SET_ERRNO (ENOENT);
1681+ return NULL;
1682+ }
1683+ if (strlen (dirname) + 3 >= MAX_PATH) {
1684+ DIRENT_SET_ERRNO (ENAMETOOLONG);
1685+ return NULL;
1686+ }
1687+
1688+ /* construct new DIR structure */
1689+ dirp = (DIR*) malloc (sizeof (struct DIR));
1690+ if (dirp != NULL) {
1691+ int error;
1692+
1693+ /*
1694+ * Convert relative directory name to an absolute one. This
1695+ * allows rewinddir() to function correctly when the current working
1696+ * directory is changed between opendir() and rewinddir().
1697+ */
1698+ if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) {
1699+ char *p;
1700+
1701+ /* append the search pattern "\\*\0" to the directory name */
1702+ p = strchr (dirp->patt, '\0');
1703+ if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
1704+ *p++ = '\\';
1705+ }
1706+ *p++ = '*';
1707+ *p = '\0';
1708+
1709+ /* open directory stream and retrieve the first entry */
1710+ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
1711+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
1712+ /* a directory entry is now waiting in memory */
1713+ dirp->cached = 1;
1714+ error = 0;
1715+ } else {
1716+ /* search pattern is not a directory name? */
1717+ DIRENT_SET_ERRNO (ENOENT);
1718+ error = 1;
1719+ }
1720+ } else {
1721+ /* buffer too small */
1722+ DIRENT_SET_ERRNO (ENOMEM);
1723+ error = 1;
1724+ }
1725+
1726+ if (error) {
1727+ free (dirp);
1728+ dirp = NULL;
1729+ }
1730+ }
1731+
1732+ return dirp;
1733+}
1734+
1735+
1736+/*****************************************************************************
1737+ * Read a directory entry, and return a pointer to a dirent structure
1738+ * containing the name of the entry in d_name field. Individual directory
1739+ * entries returned by this very function include regular files,
1740+ * sub-directories, pseudo-directories "." and "..", but also volume labels,
1741+ * hidden files and system files may be returned.
1742+ */
1743+static struct dirent *readdir(DIR *dirp)
1744+{
1745+ DWORD attr;
1746+ if (dirp == NULL) {
1747+ /* directory stream did not open */
1748+ DIRENT_SET_ERRNO (EBADF);
1749+ return NULL;
1750+ }
1751+
1752+ /* get next directory entry */
1753+ if (dirp->cached != 0) {
1754+ /* a valid directory entry already in memory */
1755+ dirp->cached = 0;
1756+ } else {
1757+ /* get the next directory entry from stream */
1758+ if (dirp->search_handle == INVALID_HANDLE_VALUE) {
1759+ return NULL;
1760+ }
1761+ if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) {
1762+ /* the very last entry has been processed or an error occured */
1763+ FindClose (dirp->search_handle);
1764+ dirp->search_handle = INVALID_HANDLE_VALUE;
1765+ return NULL;
1766+ }
1767+ }
1768+
1769+ /* copy as a multibyte character string */
1770+ DIRENT_STRNCPY ( dirp->curentry.d_name,
1771+ dirp->find_data.cFileName,
1772+ sizeof(dirp->curentry.d_name) );
1773+ dirp->curentry.d_name[MAX_PATH] = '\0';
1774+
1775+ /* compute the length of name */
1776+ dirp->curentry.d_namlen = strlen (dirp->curentry.d_name);
1777+
1778+ /* determine file type */
1779+ attr = dirp->find_data.dwFileAttributes;
1780+ if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
1781+ dirp->curentry.d_type = DT_CHR;
1782+ } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
1783+ dirp->curentry.d_type = DT_DIR;
1784+ } else {
1785+ dirp->curentry.d_type = DT_REG;
1786+ }
1787+ return &dirp->curentry;
1788+}
1789+
1790+
1791+/*****************************************************************************
1792+ * Close directory stream opened by opendir() function. Close of the
1793+ * directory stream invalidates the DIR structure as well as any previously
1794+ * read directory entry.
1795+ */
1796+static int closedir(DIR *dirp)
1797+{
1798+ if (dirp == NULL) {
1799+ /* invalid directory stream */
1800+ DIRENT_SET_ERRNO (EBADF);
1801+ return -1;
1802+ }
1803+
1804+ /* release search handle */
1805+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
1806+ FindClose (dirp->search_handle);
1807+ dirp->search_handle = INVALID_HANDLE_VALUE;
1808+ }
1809+
1810+ /* release directory structure */
1811+ free (dirp);
1812+ return 0;
1813+}
1814+
1815+
1816+/*****************************************************************************
1817+ * Resets the position of the directory stream to which dirp refers to the
1818+ * beginning of the directory. It also causes the directory stream to refer
1819+ * to the current state of the corresponding directory, as a call to opendir()
1820+ * would have done. If dirp does not refer to a directory stream, the effect
1821+ * is undefined.
1822+ */
1823+static void rewinddir(DIR* dirp)
1824+{
1825+ if (dirp != NULL) {
1826+ /* release search handle */
1827+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
1828+ FindClose (dirp->search_handle);
1829+ }
1830+
1831+ /* open new search handle and retrieve the first entry */
1832+ dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
1833+ if (dirp->search_handle != INVALID_HANDLE_VALUE) {
1834+ /* a directory entry is now waiting in memory */
1835+ dirp->cached = 1;
1836+ } else {
1837+ /* failed to re-open directory: no directory entry in memory */
1838+ dirp->cached = 0;
1839+ }
1840+ }
1841+}
1842+
1843+
1844+#ifdef __cplusplus
1845+}
1846+#endif
1847+#endif /*DIRENT_H*/
1848
1849=== modified file 'swig/XQuery.i'
1850--- swig/XQuery.i 2012-01-11 15:56:57 +0000
1851+++ swig/XQuery.i 2012-03-19 16:17:13 +0000
1852@@ -14,6 +14,7 @@
1853 * limitations under the License.
1854 */
1855
1856+
1857 %{ // start Implementation
1858
1859 class Iterator
1860@@ -67,6 +68,40 @@
1861 }; // class Iterator
1862
1863
1864+
1865+
1866+
1867+class IStream
1868+{
1869+private:
1870+ std::istream* theIStream;
1871+
1872+public:
1873+ IStream() {}
1874+ IStream(const IStream& anIStream) : theIStream(anIStream.theIStream) {}
1875+ IStream(std::istream& anIStream) : theIStream(&anIStream) {}
1876+
1877+ std::string readToString()
1878+ {
1879+ std::stringstream lStream;
1880+
1881+ lStream << theIStream;
1882+ return lStream.str();
1883+ }
1884+
1885+
1886+ int read(char *BYTE, int LENGTH)
1887+ {
1888+ theIStream->read(BYTE, LENGTH);
1889+ //theIStream->read(byteArray, len);
1890+ int readLength = theIStream->gcount();
1891+ return readLength;
1892+ }
1893+
1894+
1895+}; // class IStream
1896+
1897+
1898 class Item
1899 {
1900 friend class Iterator;
1901@@ -84,13 +119,10 @@
1902 Item(const Item& aItem) : theItem(aItem.theItem) {}
1903 Item(const zorba::Item& aZItem) : theItem(aZItem) {}
1904
1905- static Item createEmptyItem()
1906+ static Item createEmptyItem()
1907 { return Item(); }
1908
1909- std::string getStringValue() const
1910- { return std::string(theItem.getStringValue().c_str()); }
1911-
1912- std::string serialize() const
1913+ std::string serialize() const
1914 {
1915 std::stringstream lStream;
1916 Zorba_SerializerOptions_t lOptions;
1917@@ -100,6 +132,22 @@
1918 return lStream.str();
1919 }
1920
1921+ void serializeToOutputStream(std::ostream &outStream) const
1922+ {
1923+ Zorba_SerializerOptions_t lOptions;
1924+ zorba::Serializer_t lSerializer = zorba::Serializer::createSerializer(lOptions);
1925+ zorba::SingletonItemSequence lSequence(theItem);
1926+ lSerializer->serialize(&lSequence, outStream);
1927+ }
1928+
1929+ IStream getStream()
1930+ {
1931+ return IStream(theItem.getStream());
1932+ }
1933+
1934+ std::string getStringValue() const
1935+ { return std::string(theItem.getStringValue().c_str()); }
1936+
1937 Iterator getAtomizationValue () const
1938 { return Iterator(theItem.getAtomizationValue()); }
1939
1940@@ -274,11 +322,15 @@
1941 }
1942
1943
1944-%} // end Implementation
1945+
1946+%} // end Implementation
1947+
1948
1949
1950 // Interfaces
1951
1952+
1953+
1954 class DynamicContext
1955 {
1956 public:
1957@@ -292,12 +344,25 @@
1958 setContextItem(Item);
1959 };
1960
1961-class Item
1962+
1963+class IStream
1964+{
1965+public:
1966+ std::string readToString();
1967+ int read(char * BYTE, long LENGTH);
1968+}; // class IStream
1969+
1970+
1971+class Item
1972 {
1973 public:
1974 static Item createEmptyItem();
1975+
1976+ std::string serialize() const;
1977+ void serializeToOutputStream(std::ostream &outStream) const;
1978+ IStream getStream();
1979+
1980 std::string getStringValue() const;
1981- std::string serialize() const;
1982 Iterator getAtomizationValue () const;
1983 Iterator getAttributes () const;
1984 bool getBooleanValue () const;
1985@@ -319,6 +384,7 @@
1986 bool isPosOrNegInf () const;
1987 }; // class Item
1988
1989+
1990 class Iterator
1991 {
1992 public:
1993@@ -328,6 +394,7 @@
1994 void destroy();
1995 }; // class Iterator
1996
1997+
1998 class XQuery
1999 {
2000 public:
2001
2002=== modified file 'swig/java/CMakeLists.txt'
2003--- swig/java/CMakeLists.txt 2012-01-11 15:56:57 +0000
2004+++ swig/java/CMakeLists.txt 2012-03-19 16:17:13 +0000
2005@@ -21,7 +21,7 @@
2006 include (CMakeJavaInformation )
2007 MESSAGE(STATUS "SWIG Java: generating Java API")
2008
2009- # EXECUTE_PROCESS( COMMAND ${JAVA_RUNTIME} -version OUTPUT_VARIABLE JAVA_VERSION )
2010+ EXECUTE_PROCESS( COMMAND ${JAVA_RUNTIME} -version OUTPUT_VARIABLE JAVA_VERSION )
2011 MESSAGE(STATUS "SWIG Java: JNI found at: " ${JAVA_INCLUDE_PATH} )
2012
2013 SET_SOURCE_FILES_PROPERTIES( zorba_api.i PROPERTIES CPLUSPLUS ON )
2014@@ -89,6 +89,7 @@
2015 ENDIF(NOT WIN32)
2016 ENDIF ( APPLE )
2017
2018+
2019 ELSE (JAVA_INCLUDE_PATH)
2020 MESSAGE ( STATUS "SWIG Java: not generating JAVA API because jni headers not found.")
2021 ENDIF (JAVA_INCLUDE_PATH)
2022
2023=== added file 'swig/various.i'
2024--- swig/various.i 1970-01-01 00:00:00 +0000
2025+++ swig/various.i 2012-03-19 16:17:13 +0000
2026@@ -0,0 +1,184 @@
2027+/* This is from http://www.opensource.apple.com/source/swig/swig-6/swig/Lib/java/various.i?txt */
2028+
2029+/* -----------------------------------------------------------------------------
2030+ * See the LICENSE file for information on copyright, usage and redistribution
2031+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
2032+ *
2033+ * various.i
2034+ *
2035+ * SWIG Typemap library for Java.
2036+ * Various useful typemaps.
2037+ * ----------------------------------------------------------------------------- */
2038+
2039+#ifdef SWIGJAVA
2040+
2041+/*
2042+ * char **STRING_ARRAY typemaps.
2043+ * These typemaps are for C String arrays which are NULL terminated.
2044+ * char *values[] = { "one", "two", "three", NULL }; // note NULL
2045+ * char ** is mapped to a Java String[].
2046+ *
2047+ * Example usage wrapping:
2048+ * %apply char **STRING_ARRAY { char **input };
2049+ * char ** foo(char **input);
2050+ *
2051+ * Java usage:
2052+ * String numbers[] = { "one", "two", "three" };
2053+ * String[] ret = modulename.foo( numbers };
2054+ */
2055+%typemap(jni) char **STRING_ARRAY "jobjectArray"
2056+%typemap(jtype) char **STRING_ARRAY "String[]"
2057+%typemap(jstype) char **STRING_ARRAY "String[]"
2058+%typemap(in) char **STRING_ARRAY (jint size) {
2059+ int i = 0;
2060+ size = JCALL1(GetArrayLength, jenv, $input);
2061+#ifdef __cplusplus
2062+ $1 = new char*[size+1];
2063+#else
2064+ $1 = (char **)calloc(size+1, sizeof(char *));
2065+#endif
2066+ for (i = 0; i<size; i++) {
2067+ jstring j_string = (jstring)JCALL2(GetObjectArrayElement, jenv, $input, i);
2068+ const char *c_string = JCALL2(GetStringUTFChars, jenv, j_string, 0);
2069+#ifdef __cplusplus
2070+ $1[i] = new char [strlen(c_string)+1];
2071+#else
2072+ $1[i] = (char *)calloc(strlen(c_string)+1, sizeof(const char *));
2073+#endif
2074+ strcpy($1[i], c_string);
2075+ JCALL2(ReleaseStringUTFChars, jenv, j_string, c_string);
2076+ JCALL1(DeleteLocalRef, jenv, j_string);
2077+ }
2078+ $1[i] = 0;
2079+}
2080+
2081+%typemap(freearg) char **STRING_ARRAY {
2082+ int i;
2083+ for (i=0; i<size$argnum-1; i++)
2084+#ifdef __cplusplus
2085+ delete[] $1[i];
2086+ delete[] $1;
2087+#else
2088+ free($1[i]);
2089+ free($1);
2090+#endif
2091+}
2092+
2093+%typemap(out) char **STRING_ARRAY {
2094+ int i;
2095+ int len=0;
2096+ jstring temp_string;
2097+ const jclass clazz = JCALL1(FindClass, jenv, "java/lang/String");
2098+
2099+ while ($1[len]) len++;
2100+ jresult = JCALL3(NewObjectArray, jenv, len, clazz, NULL);
2101+ /* exception checking omitted */
2102+
2103+ for (i=0; i<len; i++) {
2104+ temp_string = JCALL1(NewStringUTF, jenv, *result++);
2105+ JCALL3(SetObjectArrayElement, jenv, jresult, i, temp_string);
2106+ JCALL1(DeleteLocalRef, jenv, temp_string);
2107+ }
2108+}
2109+
2110+%typemap(javain) char **STRING_ARRAY "$javainput"
2111+%typemap(javaout) char **STRING_ARRAY {
2112+ return $jnicall;
2113+ }
2114+
2115+/*
2116+ * char **STRING_OUT typemaps.
2117+ * These are typemaps for returning strings when using a C char ** parameter type.
2118+ * The returned string appears in the 1st element of the passed in Java String array.
2119+ *
2120+ * Example usage wrapping:
2121+ * void foo(char **string_out);
2122+ *
2123+ * Java usage:
2124+ * String stringOutArray[] = { "" };
2125+ * modulename.foo(stringOutArray);
2126+ * System.out.println( stringOutArray[0] );
2127+ */
2128+%typemap(jni) char **STRING_OUT "jobjectArray"
2129+%typemap(jtype) char **STRING_OUT "String[]"
2130+%typemap(jstype) char **STRING_OUT "String[]"
2131+%typemap(javain) char **STRING_OUT "$javainput"
2132+
2133+%typemap(in) char **STRING_OUT($*1_ltype temp) {
2134+ if (!$input) {
2135+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
2136+ return $null;
2137+ }
2138+ if (JCALL1(GetArrayLength, jenv, $input) == 0) {
2139+ SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
2140+ return $null;
2141+ }
2142+ $1 = &temp;
2143+}
2144+
2145+%typemap(argout) char **STRING_OUT {
2146+ jstring jnewstring = NULL;
2147+ if($1) {
2148+ jnewstring = JCALL1(NewStringUTF, jenv, *$1);
2149+ }
2150+ JCALL3(SetObjectArrayElement, jenv, $input, 0, jnewstring);
2151+}
2152+
2153+/*
2154+ * char *BYTE typemaps.
2155+ * These are input typemaps for mapping a Java byte[] array to a C char array.
2156+ * Note that as a Java array is used and thus passeed by reference, the C routine
2157+ * can return data to Java via the parameter.
2158+ *
2159+ * Example usage wrapping:
2160+ * void foo(char *array);
2161+ *
2162+ * Java usage:
2163+ * byte b[] = new byte[20];
2164+ * modulename.foo(b);
2165+ */
2166+%typemap(jni) char *BYTE "jbyteArray"
2167+%typemap(jtype) char *BYTE "byte[]"
2168+%typemap(jstype) char *BYTE "byte[]"
2169+%typemap(in) char *BYTE {
2170+ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
2171+}
2172+
2173+%typemap(argout) char *BYTE {
2174+ JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, 0);
2175+}
2176+
2177+%typemap(javain) char *BYTE "$javainput"
2178+
2179+/* Prevent default freearg typemap from being used */
2180+%typemap(freearg) char *BYTE ""
2181+
2182+#else
2183+
2184+#endif
2185+
2186+
2187+/* %include "typemaps.i"
2188+
2189+#if defined(SWIGJAVA)
2190+
2191+%typemap(in) (char * BYTE, int LENGTH)
2192+{
2193+ // Functions from jni.h
2194+ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
2195+ $2 = (int) JCALL1(GetArrayLength, jenv, $input);
2196+}
2197+
2198+%typemap(jni) (char * BYTE, int LENGTH) "jbyteArray"
2199+%typemap(jtype) (char * BYTE, int LENGTH) "byte[]"
2200+%typemap(jstype) (char * BYTE, int LENGTH) "byte[]"
2201+%typemap(javain) (char * BYTE, int LENGTH) "$javainput"
2202+
2203+// Specify signature of method to handle
2204+%apply (char * BYTE, int LENGTH) { (char * byteArray, long len) };
2205+
2206+#else
2207+%apply (char * BYTE, int LENGTH) { (char * byteArray, long len) };
2208+#endif
2209+
2210+*/
2211
2212=== modified file 'swig/zorba_api.i'
2213--- swig/zorba_api.i 2012-01-11 15:56:57 +0000
2214+++ swig/zorba_api.i 2012-03-19 16:17:13 +0000
2215@@ -14,7 +14,10 @@
2216 * limitations under the License.
2217 */
2218
2219-%module zorba_api
2220+%module(directors="1") zorba_api
2221+
2222+/*%feature("director") IStream;*/
2223+
2224 %include "std_string.i"
2225 %include "exception.i"
2226
2227@@ -34,6 +37,8 @@
2228 }
2229 }
2230
2231+
2232+
2233 %{ // Implementations
2234
2235
2236@@ -52,6 +57,7 @@
2237 class Item;
2238 class Iterator;
2239 class XQuery;
2240+ class IStream;
2241 class Store;
2242 class Zorba;
2243
2244@@ -70,6 +76,7 @@
2245 %}
2246
2247
2248+%include "various.i"
2249
2250 %include "XQuery.i"
2251 %include "Store.i"
2252
2253=== modified file 'test/rbkt/modules/CMakeLists.txt'
2254--- test/rbkt/modules/CMakeLists.txt 2012-02-23 16:48:01 +0000
2255+++ test/rbkt/modules/CMakeLists.txt 2012-03-19 16:17:13 +0000
2256@@ -58,3 +58,5 @@
2257 # This is as good a place as any to test this feature
2258 DECLARE_ZORBA_URI_FILE(FILE "random-file.txt"
2259 URI "http://www.zorba-xquery.com/random-file" TEST_ONLY)
2260+
2261+ADD_SUBDIRECTORY(java)
2262
2263=== added directory 'test/rbkt/modules/java'
2264=== added file 'test/rbkt/modules/java/CMakeLists.txt'
2265--- test/rbkt/modules/java/CMakeLists.txt 1970-01-01 00:00:00 +0000
2266+++ test/rbkt/modules/java/CMakeLists.txt 2012-03-19 16:17:13 +0000
2267@@ -0,0 +1,39 @@
2268+# Copyright 2006-2008 The FLWOR Foundation.
2269+#
2270+# Licensed under the Apache License, Version 2.0 (the "License")
2271+# you may not use this file except in compliance with the License.
2272+# You may obtain a copy of the License at
2273+#
2274+# http://www.apache.org/licenses/LICENSE-2.0
2275+#
2276+# Unless required by applicable law or agreed to in writing, software
2277+# distributed under the License is distributed on an "AS IS" BASIS,
2278+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2279+# See the License for the specific language governing permissions and
2280+# limitations under the License.
2281+
2282+# For now we only test building a .jar that we want Zorba to make available
2283+# on the JVM claspath. This test scenario should be extended to include a
2284+# Zorba module using the .jar, etc.
2285+# We make use of the much-improved Java support added in CMake 2.8.6.
2286+COMPARE_VERSION_STRINGS (${CMAKE_VERSION} "2.8.6" RESULT)
2287+IF (${RESULT} GREATER -1)
2288+ FIND_PACKAGE (Java COMPONENTS Development)
2289+ IF (Java_Development_FOUND)
2290+ INCLUDE (UseJava)
2291+
2292+ # Declare two "different" jars, for testing
2293+ ADD_JAR (JavaTest Test.java)
2294+ ADD_JAR (JavaTest2 Test.java)
2295+
2296+ # Tell Zorba about the jars
2297+ GET_PROPERTY (JavaTest_JAR_FILE TARGET JavaTest PROPERTY JAR_FILE)
2298+ GET_PROPERTY (JavaTest2_JAR_FILE TARGET JavaTest2 PROPERTY JAR_FILE)
2299+ DECLARE_ZORBA_JAR(FILE ${JavaTest_JAR_FILE} ${JavaTest2_JAR_FILE} TEST_ONLY)
2300+
2301+ # Pretend to tell Zorba about some system jars
2302+ DECLARE_ZORBA_JAR(EXTERNAL FILE
2303+ "${PROJECT_SOURCE_DIR}/MyJar.jar" "${PROJECT_SOURCE_DIR}/MyJar2.jar")
2304+
2305+ ENDIF (Java_Development_FOUND)
2306+ENDIF (${RESULT} GREATER -1)
2307
2308=== added file 'test/rbkt/modules/java/Test.java'
2309--- test/rbkt/modules/java/Test.java 1970-01-01 00:00:00 +0000
2310+++ test/rbkt/modules/java/Test.java 2012-03-19 16:17:13 +0000
2311@@ -0,0 +1,7 @@
2312+package org.zorbaxquery;
2313+
2314+public class Test {
2315+ public static void main(String[] args) {
2316+ System.out.println("Hello, world");
2317+ }
2318+}

Subscribers

People subscribed via source and target branches