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