Merge lp:~zorba-coders/zorba/bug-1188058 into lp:zorba/system-module
- bug-1188058
- Merge into system-module
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 37 | ||||
Proposed branch: | lp:~zorba-coders/zorba/bug-1188058 | ||||
Merge into: | lp:zorba/system-module | ||||
Diff against target: |
718 lines (+217/-140) 8 files modified
src/CMakeLists.txt (+1/-3) src/com/CMakeLists.txt (+0/-14) src/com/zorba-xquery/CMakeLists.txt (+0/-14) src/com/zorba-xquery/www/CMakeLists.txt (+0/-14) src/com/zorba-xquery/www/modules/CMakeLists.txt (+0/-14) src/system.xq (+52/-35) src/system.xq.src/system.cpp (+128/-45) src/system.xq.src/system.h (+36/-1) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-1188058 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Hillery | Approve | ||
Luis Rodriguez Gonzalez | Approve | ||
Review via email: mp+178905@code.launchpad.net |
Commit message
Update non-core "system" module to Zorba 3.0 standards. Added system:
Description of the change
- 37. By Luis Rodriguez Gonzalez
-
Changes for Zorba 3.0 done
- 38. By Luis Rodriguez Gonzalez
-
Forgot to add SystemModule:
:getKey( )
Luis Rodriguez Gonzalez (kuraru) : | # |
- 39. By Luis Rodriguez Gonzalez
-
Fixed XQDoc
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> Looks very good, nice work. However, the moduleDocumentation test doesn't
> pass, so there must be a typo somewhere in the XQDoc. Also, I suspect once you
> fix that, it will complain that all those public variable declarations need to
> have XQDoc; you'll probably need to restore the doc from the old version.
> (%private variables, like errors codes, don't need XQDoc, but public ones do
> as far as I know.)
Done.
Chris Hillery (ceejatec) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Voting criteria failed for the following merge proposals:
https:/
Votes: {'Approve': 2, 'Needs commit message': 1}
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "CommitZorba" failed.
Check console output at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded - proposal merged!
Preview Diff
1 | === modified file 'src/CMakeLists.txt' | |||
2 | --- src/CMakeLists.txt 2011-07-26 10:43:21 +0000 | |||
3 | +++ src/CMakeLists.txt 2013-08-08 20:52:48 +0000 | |||
4 | @@ -14,6 +14,4 @@ | |||
5 | 14 | 14 | ||
6 | 15 | # all external module libraries are generated in the directory | 15 | # all external module libraries are generated in the directory |
7 | 16 | # of the corresponding .xq file | 16 | # of the corresponding .xq file |
11 | 17 | MESSAGE(STATUS "Add com") | 17 | DECLARE_ZORBA_MODULE (URI "http://zorba.io/modules/system" VERSION 1.0 FILE "system.xq") |
9 | 18 | ADD_SUBDIRECTORY(com) | ||
10 | 19 | MESSAGE(STATUS "End modules") | ||
12 | 20 | 18 | ||
13 | === removed directory 'src/com' | |||
14 | === removed file 'src/com/CMakeLists.txt' | |||
15 | --- src/com/CMakeLists.txt 2011-10-06 08:19:44 +0000 | |||
16 | +++ src/com/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
17 | @@ -1,14 +0,0 @@ | |||
18 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
19 | 2 | # | ||
20 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
21 | 4 | # you may not use this file except in compliance with the License. | ||
22 | 5 | # You may obtain a copy of the License at | ||
23 | 6 | # | ||
24 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
25 | 8 | # | ||
26 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
27 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
28 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
29 | 12 | # See the License for the specific language governing permissions and | ||
30 | 13 | # limitations under the License. | ||
31 | 14 | ADD_SUBDIRECTORY(zorba-xquery) | ||
32 | 15 | 0 | ||
33 | === removed directory 'src/com/zorba-xquery' | |||
34 | === removed file 'src/com/zorba-xquery/CMakeLists.txt' | |||
35 | --- src/com/zorba-xquery/CMakeLists.txt 2011-10-06 08:19:44 +0000 | |||
36 | +++ src/com/zorba-xquery/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
37 | @@ -1,14 +0,0 @@ | |||
38 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
39 | 2 | # | ||
40 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
41 | 4 | # you may not use this file except in compliance with the License. | ||
42 | 5 | # You may obtain a copy of the License at | ||
43 | 6 | # | ||
44 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
45 | 8 | # | ||
46 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
47 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
48 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
49 | 12 | # See the License for the specific language governing permissions and | ||
50 | 13 | # limitations under the License. | ||
51 | 14 | ADD_SUBDIRECTORY(www) | ||
52 | 15 | 0 | ||
53 | === removed directory 'src/com/zorba-xquery/www' | |||
54 | === removed file 'src/com/zorba-xquery/www/CMakeLists.txt' | |||
55 | --- src/com/zorba-xquery/www/CMakeLists.txt 2011-10-06 08:19:44 +0000 | |||
56 | +++ src/com/zorba-xquery/www/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
57 | @@ -1,14 +0,0 @@ | |||
58 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
59 | 2 | # | ||
60 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
61 | 4 | # you may not use this file except in compliance with the License. | ||
62 | 5 | # You may obtain a copy of the License at | ||
63 | 6 | # | ||
64 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
65 | 8 | # | ||
66 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
67 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
68 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
69 | 12 | # See the License for the specific language governing permissions and | ||
70 | 13 | # limitations under the License. | ||
71 | 14 | ADD_SUBDIRECTORY(modules) | ||
72 | 15 | 0 | ||
73 | === removed directory 'src/com/zorba-xquery/www/modules' | |||
74 | === removed file 'src/com/zorba-xquery/www/modules/CMakeLists.txt' | |||
75 | --- src/com/zorba-xquery/www/modules/CMakeLists.txt 2011-07-01 09:24:04 +0000 | |||
76 | +++ src/com/zorba-xquery/www/modules/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
77 | @@ -1,14 +0,0 @@ | |||
78 | 1 | # Copyright 2006-2008 The FLWOR Foundation. | ||
79 | 2 | # | ||
80 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
81 | 4 | # you may not use this file except in compliance with the License. | ||
82 | 5 | # You may obtain a copy of the License at | ||
83 | 6 | # | ||
84 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
85 | 8 | # | ||
86 | 9 | # Unless required by applicable law or agreed to in writing, software | ||
87 | 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
88 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
89 | 12 | # See the License for the specific language governing permissions and | ||
90 | 13 | # limitations under the License. | ||
91 | 14 | DECLARE_ZORBA_MODULE (URI "http://www.zorba-xquery.com/modules/system" VERSION 1.0 FILE "system.xq") | ||
92 | 15 | 0 | ||
93 | === renamed file 'src/com/zorba-xquery/www/modules/system.xq' => 'src/system.xq' | |||
94 | --- src/com/zorba-xquery/www/modules/system.xq 2013-06-15 19:49:56 +0000 | |||
95 | +++ src/system.xq 2013-08-08 20:52:48 +0000 | |||
96 | @@ -1,4 +1,4 @@ | |||
98 | 1 | xquery version "3.0"; | 1 | jsoniq version "1.0"; |
99 | 2 | 2 | ||
100 | 3 | (: | 3 | (: |
101 | 4 | : Copyright 2006-2009 The FLWOR Foundation. | 4 | : Copyright 2006-2009 The FLWOR Foundation. |
102 | @@ -18,12 +18,10 @@ | |||
103 | 18 | (:~ | 18 | (:~ |
104 | 19 | : The system module allows developers to access system properties. | 19 | : The system module allows developers to access system properties. |
105 | 20 | : Part of these system properties are environment variables, | 20 | : Part of these system properties are environment variables, |
108 | 21 | : local variable to the process running Zorba, and properties defined by Zorba. | 21 | : local variable to the process running Zorba, and properties defined by Zorba.<p/> |
107 | 22 | : <br /> | ||
109 | 23 | : To avoid conflicts between environment variables and properties defined by Zorba, | 22 | : To avoid conflicts between environment variables and properties defined by Zorba, |
113 | 24 | : all environment variables are prefixed with <i>env.</i>. | 23 | : all environment variables are prefixed with <i>env.</i>.<p/> |
114 | 25 | : <br /> | 24 | : For instance, the following query: <p/> |
112 | 26 | : For instance, the following query: <br /> | ||
115 | 27 | : <pre class="ace-static"> | 25 | : <pre class="ace-static"> |
116 | 28 | : import module namespace system = "http://www.zorba-xquery.com/modules/system"; | 26 | : import module namespace system = "http://www.zorba-xquery.com/modules/system"; |
117 | 29 | : | 27 | : |
118 | @@ -31,19 +29,19 @@ | |||
119 | 31 | : return concat($prop, ": ", system:property($prop), " | 29 | : return concat($prop, ": ", system:property($prop), " |
120 | 32 | : ") | 30 | : ") |
121 | 33 | : </pre> | 31 | : </pre> |
123 | 34 | : <br /> | 32 | : <p/> |
124 | 35 | : Will output: | 33 | : Will output: |
125 | 36 | : <pre class="ace-static"> | 34 | : <pre class="ace-static"> |
126 | 37 | : env.TERM_PROGRAM: Apple_Terminal | 35 | : env.TERM_PROGRAM: Apple_Terminal |
127 | 38 | : ... | 36 | : ... |
128 | 39 | : </pre> | 37 | : </pre> |
129 | 40 | : In this example, it is important to notice that the environnement variable PATH | 38 | : In this example, it is important to notice that the environnement variable PATH |
131 | 41 | : with the key env.PATH. | 39 | : with the key env.PATH.<p/> |
132 | 42 | : | 40 | : |
133 | 43 | : @author Markus Pilman | 41 | : @author Markus Pilman |
134 | 44 | : @project Zorba/Input Output/System | 42 | : @project Zorba/Input Output/System |
135 | 45 | :) | 43 | :) |
137 | 46 | module namespace system = 'http://www.zorba-xquery.com/modules/system'; | 44 | module namespace system = "http://zorba.io/modules/system"; |
138 | 47 | 45 | ||
139 | 48 | declare namespace an = "http://www.zorba-xquery.com/annotations"; | 46 | declare namespace an = "http://www.zorba-xquery.com/annotations"; |
140 | 49 | 47 | ||
141 | @@ -53,12 +51,12 @@ | |||
142 | 53 | (:~ | 51 | (:~ |
143 | 54 | : The name of the operating system (os.name). | 52 | : The name of the operating system (os.name). |
144 | 55 | :) | 53 | :) |
146 | 56 | declare variable $system:os-name as xs:string := "os.name"; | 54 | declare variable $system:OS-NAME as xs:string := "os.name"; |
147 | 57 | 55 | ||
148 | 58 | (:~ | 56 | (:~ |
149 | 59 | : The name of the computer the process is running on (os.node.name). | 57 | : The name of the computer the process is running on (os.node.name). |
150 | 60 | :) | 58 | :) |
152 | 61 | declare variable $system:os-node-name as xs:string := "os.node.name"; | 59 | declare variable $system:OS-NODE-NAME as xs:string := "os.node.name"; |
153 | 62 | 60 | ||
154 | 63 | (:~ | 61 | (:~ |
155 | 64 | : The major version number of the Windows installation or | 62 | : The major version number of the Windows installation or |
156 | @@ -66,7 +64,7 @@ | |||
157 | 66 | : (os.version.major). | 64 | : (os.version.major). |
158 | 67 | : <b>Works on Windows only.</b> | 65 | : <b>Works on Windows only.</b> |
159 | 68 | :) | 66 | :) |
161 | 69 | declare variable $system:os-version-major as xs:string := "os.version.major"; | 67 | declare variable $system:OS-VERSION-MAJOR as xs:string := "os.version.major"; |
162 | 70 | 68 | ||
163 | 71 | (:~ | 69 | (:~ |
164 | 72 | : The minor version number of the Windows installation or | 70 | : The minor version number of the Windows installation or |
165 | @@ -74,7 +72,7 @@ | |||
166 | 74 | : (os.version.minor). | 72 | : (os.version.minor). |
167 | 75 | : <b>Works on Windows only.</b> | 73 | : <b>Works on Windows only.</b> |
168 | 76 | :) | 74 | :) |
170 | 77 | declare variable $system:os-version-minor as xs:string := "os.version.minor"; | 75 | declare variable $system:OS-VERSION-MINOR as xs:string := "os.version.minor"; |
171 | 78 | 76 | ||
172 | 79 | (:~ | 77 | (:~ |
173 | 80 | : The build number of the Windows installation or | 78 | : The build number of the Windows installation or |
174 | @@ -82,7 +80,7 @@ | |||
175 | 82 | : (os.version.build). | 80 | : (os.version.build). |
176 | 83 | : <b>Works on Windows only.</b> | 81 | : <b>Works on Windows only.</b> |
177 | 84 | :) | 82 | :) |
179 | 85 | declare variable $system:os-version-build as xs:string := "os.version.build"; | 83 | declare variable $system:OS-VERSION-BUILD as xs:string := "os.version.build"; |
180 | 86 | 84 | ||
181 | 87 | (:~ | 85 | (:~ |
182 | 88 | : The release of this UNIX installation or | 86 | : The release of this UNIX installation or |
183 | @@ -90,105 +88,108 @@ | |||
184 | 90 | : (os.version.release). | 88 | : (os.version.release). |
185 | 91 | : <b>Works on UNIX based operating systems only.</b> | 89 | : <b>Works on UNIX based operating systems only.</b> |
186 | 92 | :) | 90 | :) |
188 | 93 | declare variable $system:os-version-release as xs:string := "os.version.release"; | 91 | declare variable $system:OS-VERSION-RELEASE as xs:string := "os.version.release"; |
189 | 92 | |||
190 | 94 | (:~ | 93 | (:~ |
191 | 95 | : The version of this UNIX installation or | 94 | : The version of this UNIX installation or |
192 | 96 | : an empty string if the process does not run on a UNIX/Linux installation | 95 | : an empty string if the process does not run on a UNIX/Linux installation |
193 | 97 | : (os.version.version). | 96 | : (os.version.version). |
194 | 98 | : <b>Works on UNIX based operating systems only.</b> | 97 | : <b>Works on UNIX based operating systems only.</b> |
195 | 99 | :) | 98 | :) |
197 | 100 | declare variable $system:os-version-version as xs:string := "os.version.version"; | 99 | declare variable $system:OS-VERSION-VERSION as xs:string := "os.version.version"; |
198 | 101 | 100 | ||
199 | 102 | (:~ | 101 | (:~ |
200 | 103 | : The version of the Operating System. | 102 | : The version of the Operating System. |
201 | 104 | :) | 103 | :) |
203 | 105 | declare variable $system:os-version as xs:string := "os.version"; | 104 | declare variable $system:OS-VERSION as xs:string := "os.version"; |
204 | 106 | 105 | ||
205 | 107 | (:~ | 106 | (:~ |
206 | 108 | : The name of the processor architecture (os.arch). | 107 | : The name of the processor architecture (os.arch). |
207 | 109 | : For example x86 or x86_64. | 108 | : For example x86 or x86_64. |
208 | 110 | :) | 109 | :) |
210 | 111 | declare variable $system:os-arch as xs:string := "os.arch"; | 110 | declare variable $system:OS-ARCH as xs:string := "os.arch"; |
211 | 112 | 111 | ||
212 | 113 | (:~ | 112 | (:~ |
213 | 114 | : True if system architecture is 64bits (os.is64). | 113 | : True if system architecture is 64bits (os.is64). |
214 | 115 | :) | 114 | :) |
216 | 116 | declare variable $system:os-is64 as xs:string := "os.is64"; | 115 | declare variable $system:OS-IS64 as xs:string := "os.is64"; |
217 | 117 | 116 | ||
218 | 118 | (:~ | 117 | (:~ |
219 | 119 | : Number of logical processors in the system (hardware.logical.cpu). | 118 | : Number of logical processors in the system (hardware.logical.cpu). |
220 | 120 | : This information is not available under Mac OS X. | 119 | : This information is not available under Mac OS X. |
221 | 121 | :) | 120 | :) |
223 | 122 | declare variable $system:hardware-logical-cpu as xs:string := "hardware.logical.cpu"; | 121 | declare variable $system:HARDWARE-LOGICAL-CPU as xs:string := "hardware.logical.cpu"; |
224 | 123 | 122 | ||
225 | 124 | (:~ | 123 | (:~ |
227 | 125 | : Number of physical processors in the system (hardware.logical.cpu). | 124 | : Number of physical processors in the system (hardware.physical.cpu). |
228 | 126 | :) | 125 | :) |
230 | 127 | declare variable $system:hardware-physical-cpu as xs:string := "hardware.physical.cpu"; | 126 | declare variable $system:HARDWARE-PHYSICAL-CPU as xs:string := "hardware.physical.cpu"; |
231 | 128 | 127 | ||
232 | 129 | (:~ | 128 | (:~ |
233 | 130 | : number of logical per physical processors in the system (hardware.logical.per.physical.cpu). | 129 | : number of logical per physical processors in the system (hardware.logical.per.physical.cpu). |
234 | 131 | : This information is not available under Mac OS X. | 130 | : This information is not available under Mac OS X. |
235 | 132 | :) | 131 | :) |
237 | 133 | declare variable $system:hardware-logical-per-physical-cpu as xs:string := "hardware.logical.per.physical.cpu"; | 132 | declare variable $system:HARDWARE-LOGICAL-PER-PHYSICAL-CPU as xs:string := "hardware.logical.per.physical.cpu"; |
238 | 134 | 133 | ||
239 | 135 | (:~ | 134 | (:~ |
240 | 136 | : Physical memory available (hardware.physical.memory). | 135 | : Physical memory available (hardware.physical.memory). |
241 | 137 | :) | 136 | :) |
243 | 138 | declare variable $system:hardware-physical-memory as xs:string := "hardware.physical.memory"; | 137 | declare variable $system:HARDWARE-PHSICAL-MEMORY as xs:string := "hardware.physical.memory"; |
244 | 138 | |||
245 | 139 | (:~ | 139 | (:~ |
246 | 140 | : Virtual memory available (hardware.virtual.memory). | 140 | : Virtual memory available (hardware.virtual.memory). |
247 | 141 | :) | 141 | :) |
249 | 142 | declare variable $system:hardware-virtual-memory as xs:string := "hardware.virtual.memory"; | 142 | declare variable $system:HARDWARE-VIRTUAL-MEMORY as xs:string := "hardware.virtual.memory"; |
250 | 143 | |||
251 | 143 | (:~ | 144 | (:~ |
252 | 144 | : Gets the hardware manufacturer (hardware.manufacturer). | 145 | : Gets the hardware manufacturer (hardware.manufacturer). |
253 | 145 | :) | 146 | :) |
255 | 146 | declare variable $system:hardware-manufacturer as xs:string := "hardware.manufacturer"; | 147 | declare variable $system:HARDWARE-MANUFACTURER as xs:string := "hardware.manufacturer"; |
256 | 147 | 148 | ||
257 | 148 | (:~ | 149 | (:~ |
258 | 149 | : The Linux distribution, Zorba is running on (linux.distributor). | 150 | : The Linux distribution, Zorba is running on (linux.distributor). |
259 | 150 | : <b>Works on UNIX based operating systems only.</b> | 151 | : <b>Works on UNIX based operating systems only.</b> |
260 | 151 | :) | 152 | :) |
262 | 152 | declare variable $system:linux-distributor as xs:string := "linux.distributor"; | 153 | declare variable $system:LINUX-DISTRIBUTOR as xs:string := "linux.distributor"; |
263 | 153 | 154 | ||
264 | 154 | (:~ | 155 | (:~ |
265 | 155 | : The version of the Linux distribution, Zorba is running on (linux.distributor.version). | 156 | : The version of the Linux distribution, Zorba is running on (linux.distributor.version). |
266 | 156 | : <b>Works on UNIX based operating systems only.</b> | 157 | : <b>Works on UNIX based operating systems only.</b> |
267 | 157 | :) | 158 | :) |
269 | 158 | declare variable $system:linux-distributor-version as xs:string := "linux.distributor.version"; | 159 | declare variable $system:LINUX-DISTRIBUTOR-VERSION as xs:string := "linux.distributor.version"; |
270 | 159 | 160 | ||
271 | 160 | (:~ | 161 | (:~ |
272 | 161 | : The username, with which this process was started (user.name). | 162 | : The username, with which this process was started (user.name). |
273 | 162 | : On Unix, this variable is only available if the USER environment | 163 | : On Unix, this variable is only available if the USER environment |
274 | 163 | : variable is set (e.g. it might not be available in a cronjob). | 164 | : variable is set (e.g. it might not be available in a cronjob). |
275 | 164 | :) | 165 | :) |
277 | 165 | declare variable $system:user-name as xs:string := "user.name"; | 166 | declare variable $system:USER-NAME as xs:string := "user.name"; |
278 | 166 | 167 | ||
279 | 167 | (:~ | 168 | (:~ |
280 | 168 | : The Zorba module path, that is the paths in which Zorba looks | 169 | : The Zorba module path, that is the paths in which Zorba looks |
281 | 169 | : for modules (zorba.module.path). | 170 | : for modules (zorba.module.path). |
282 | 170 | :) | 171 | :) |
284 | 171 | declare variable $system:zorba-module-path as xs:string := "zorba.module.path"; | 172 | declare variable $system:ZORBA-MODULE-PATH as xs:string := "zorba.module.path"; |
285 | 172 | 173 | ||
286 | 173 | (:~ | 174 | (:~ |
287 | 174 | : Zorba version in the format Major.Minor.Patch (zorba.version). | 175 | : Zorba version in the format Major.Minor.Patch (zorba.version). |
288 | 175 | :) | 176 | :) |
290 | 176 | declare variable $system:zorba-version as xs:string := "zorba.version"; | 177 | declare variable $system:ZORBA-VERSION as xs:string := "zorba.version"; |
291 | 177 | 178 | ||
292 | 178 | (:~ | 179 | (:~ |
293 | 179 | : Zorba major version (zorba.version.major). | 180 | : Zorba major version (zorba.version.major). |
294 | 180 | :) | 181 | :) |
296 | 181 | declare variable $system:zorba-version-major as xs:string := "zorba.version.major"; | 182 | declare variable $system:ZORBA-VERSION-MAJOR as xs:string := "zorba.version.major"; |
297 | 182 | 183 | ||
298 | 183 | (:~ | 184 | (:~ |
299 | 184 | : Zorba minor version (zorba.version.minor). | 185 | : Zorba minor version (zorba.version.minor). |
300 | 185 | :) | 186 | :) |
302 | 186 | declare variable $system:zorba-version-minor as xs:string := "zorba.version.minor"; | 187 | declare variable $system:ZORBA-VERSION-MINOR as xs:string := "zorba.version.minor"; |
303 | 187 | 188 | ||
304 | 188 | (:~ | 189 | (:~ |
305 | 189 | : Zorba patch version (zorba.version.patch). | 190 | : Zorba patch version (zorba.version.patch). |
306 | 190 | :) | 191 | :) |
308 | 191 | declare variable $system:zorba-version-patch as xs:string := "zorba.version.patch"; | 192 | declare variable $system:ZORBA-VERSION-PATCH as xs:string := "zorba.version.patch"; |
309 | 192 | 193 | ||
310 | 193 | (:~ | 194 | (:~ |
311 | 194 | : Gets the system property indicated by the specified key. | 195 | : Gets the system property indicated by the specified key. |
312 | @@ -201,7 +202,7 @@ | |||
313 | 201 | (:~ | 202 | (:~ |
314 | 202 | : This function retrieves the names of the current system properties. | 203 | : This function retrieves the names of the current system properties. |
315 | 203 | : This list includes environment variables, local variable to the process running Zorba, and properties defined by Zorba. | 204 | : This list includes environment variables, local variable to the process running Zorba, and properties defined by Zorba. |
317 | 204 | : <br /> | 205 | : <p/> |
318 | 205 | : To avoid conflicts between environment variables and properties defined by Zorba, | 206 | : To avoid conflicts between environment variables and properties defined by Zorba, |
319 | 206 | : all environment variables are prefixed with <i>env.</i>. | 207 | : all environment variables are prefixed with <i>env.</i>. |
320 | 207 | : | 208 | : |
321 | @@ -209,3 +210,19 @@ | |||
322 | 209 | :) | 210 | :) |
323 | 210 | declare %an:nondeterministic function system:properties() as xs:string* external; | 211 | declare %an:nondeterministic function system:properties() as xs:string* external; |
324 | 211 | 212 | ||
325 | 213 | (:~ | ||
326 | 214 | : This function retrieves all names and values from the current system properties. | ||
327 | 215 | : This list includes environment variables, local variable to the process running Zorba, and properties defined by Zorba. | ||
328 | 216 | : <p/> | ||
329 | 217 | : To avoid conflicts between environment variables and properties defined by Zorba, | ||
330 | 218 | : all environment variables are prefixed with <i>env.</i>. | ||
331 | 219 | : | ||
332 | 220 | : @return List of all system properties as a JSONiq Object sequence. | ||
333 | 221 | :) | ||
334 | 222 | declare %an:nondeterministic function system:all-properties() as object() { | ||
335 | 223 | { | ||
336 | 224 | for $prop in system:properties() | ||
337 | 225 | return { $prop : system:property($prop) } | ||
338 | 226 | } | ||
339 | 227 | }; | ||
340 | 228 | |||
341 | 212 | 229 | ||
342 | === renamed directory 'src/com/zorba-xquery/www/modules/system.xq.src' => 'src/system.xq.src' | |||
343 | === modified file 'src/system.xq.src/system.cpp' | |||
344 | --- src/com/zorba-xquery/www/modules/system.xq.src/system.cpp 2012-07-19 12:29:57 +0000 | |||
345 | +++ src/system.xq.src/system.cpp 2013-08-08 20:52:48 +0000 | |||
346 | @@ -55,7 +55,33 @@ | |||
347 | 55 | 55 | ||
348 | 56 | namespace zorba { namespace system { | 56 | namespace zorba { namespace system { |
349 | 57 | 57 | ||
351 | 58 | const String SystemModule::SYSTEM_MODULE_NAMESPACE = "http://www.zorba-xquery.com/modules/system"; | 58 | const String SystemModule::SYSTEM_MODULE_NAMESPACE = "http://zorba.io/modules/system"; |
352 | 59 | |||
353 | 60 | // global keys | ||
354 | 61 | zorba::Item SystemModule::globalOSName; | ||
355 | 62 | zorba::Item SystemModule::globalOSNodeName; | ||
356 | 63 | zorba::Item SystemModule::globalOSVersionMajor; | ||
357 | 64 | zorba::Item SystemModule::globalOSVersionMinor; | ||
358 | 65 | zorba::Item SystemModule::globalOSVersionBuild; | ||
359 | 66 | zorba::Item SystemModule::globalOSVersionRelease; | ||
360 | 67 | zorba::Item SystemModule::globalOSVersionVersion; | ||
361 | 68 | zorba::Item SystemModule::globalOSVersion; | ||
362 | 69 | zorba::Item SystemModule::globalOSArch; | ||
363 | 70 | zorba::Item SystemModule::globalOSis64; | ||
364 | 71 | zorba::Item SystemModule::globalHWLogicalCPU; | ||
365 | 72 | zorba::Item SystemModule::globalHWPhysicalCPU; | ||
366 | 73 | zorba::Item SystemModule::globalHWLogicalPerPhysicalCPU; | ||
367 | 74 | zorba::Item SystemModule::globalHWPhysicalMemory; | ||
368 | 75 | zorba::Item SystemModule::globalHWVirtualMemory; | ||
369 | 76 | zorba::Item SystemModule::globalHWManufacturer; | ||
370 | 77 | zorba::Item SystemModule::globalLinuxDistributor; | ||
371 | 78 | zorba::Item SystemModule::globalLinuxDistributorVersion; | ||
372 | 79 | zorba::Item SystemModule::globalUserName; | ||
373 | 80 | zorba::Item SystemModule::globalZorbaModulePath; | ||
374 | 81 | zorba::Item SystemModule::globalZorbaVersion; | ||
375 | 82 | zorba::Item SystemModule::globalZorbaVersionMajor; | ||
376 | 83 | zorba::Item SystemModule::globalZorbaVersionMinor; | ||
377 | 84 | zorba::Item SystemModule::globalZorbaVersionPatch; | ||
378 | 59 | 85 | ||
379 | 60 | #ifdef WIN32 | 86 | #ifdef WIN32 |
380 | 61 | typedef BOOL (WINAPI *LPFN_GLPI)( | 87 | typedef BOOL (WINAPI *LPFN_GLPI)( |
381 | @@ -252,6 +278,30 @@ | |||
382 | 252 | SystemModule::SystemModule() | 278 | SystemModule::SystemModule() |
383 | 253 | : thePropertyFunction(0), thePropertiesFunction(0) | 279 | : thePropertyFunction(0), thePropertiesFunction(0) |
384 | 254 | { | 280 | { |
385 | 281 | globalOSName = Zorba::getInstance(0)->getItemFactory()->createString("os.name"); | ||
386 | 282 | globalOSNodeName = Zorba::getInstance(0)->getItemFactory()->createString("os.node.name"); | ||
387 | 283 | globalOSVersionMajor = Zorba::getInstance(0)->getItemFactory()->createString("os.version.major"); | ||
388 | 284 | globalOSVersionMinor = Zorba::getInstance(0)->getItemFactory()->createString("os.version.minor"); | ||
389 | 285 | globalOSVersionBuild = Zorba::getInstance(0)->getItemFactory()->createString("os.version.build"); | ||
390 | 286 | globalOSVersionRelease = Zorba::getInstance(0)->getItemFactory()->createString("os.version.release"); | ||
391 | 287 | globalOSVersionVersion = Zorba::getInstance(0)->getItemFactory()->createString("os.version.version"); | ||
392 | 288 | globalOSVersion = Zorba::getInstance(0)->getItemFactory()->createString("os.version"); | ||
393 | 289 | globalOSArch = Zorba::getInstance(0)->getItemFactory()->createString("os.arch"); | ||
394 | 290 | globalOSis64 = Zorba::getInstance(0)->getItemFactory()->createString("os.is64"); | ||
395 | 291 | globalHWLogicalCPU = Zorba::getInstance(0)->getItemFactory()->createString("hardware.logical.cpu"); | ||
396 | 292 | globalHWPhysicalCPU = Zorba::getInstance(0)->getItemFactory()->createString("hardware.physical.cpu"); | ||
397 | 293 | globalHWLogicalPerPhysicalCPU = Zorba::getInstance(0)->getItemFactory()->createString("hardware.logical.per.physical.cpu"); | ||
398 | 294 | globalHWPhysicalMemory = Zorba::getInstance(0)->getItemFactory()->createString("hardware.physical.memory"); | ||
399 | 295 | globalHWVirtualMemory = Zorba::getInstance(0)->getItemFactory()->createString("hardware.virtual.memory"); | ||
400 | 296 | globalHWManufacturer = Zorba::getInstance(0)->getItemFactory()->createString("hardware.manufacturer"); | ||
401 | 297 | globalLinuxDistributor = Zorba::getInstance(0)->getItemFactory()->createString("linux.distributor"); | ||
402 | 298 | globalLinuxDistributorVersion = Zorba::getInstance(0)->getItemFactory()->createString("linux.distributor.version"); | ||
403 | 299 | globalUserName = Zorba::getInstance(0)->getItemFactory()->createString("user.name"); | ||
404 | 300 | globalZorbaModulePath = Zorba::getInstance(0)->getItemFactory()->createString("zorba.module.path"); | ||
405 | 301 | globalZorbaVersion = Zorba::getInstance(0)->getItemFactory()->createString("zorba.version"); | ||
406 | 302 | globalZorbaVersionMajor = Zorba::getInstance(0)->getItemFactory()->createString("zorba.version.major"); | ||
407 | 303 | globalZorbaVersionMinor = Zorba::getInstance(0)->getItemFactory()->createString("zorba.version.minor"); | ||
408 | 304 | globalZorbaVersionPatch = Zorba::getInstance(0)->getItemFactory()->createString("zorba.version.patch"); | ||
409 | 255 | } | 305 | } |
410 | 256 | 306 | ||
411 | 257 | ExternalFunction* SystemModule::getExternalFunction(const String& localName) { | 307 | ExternalFunction* SystemModule::getExternalFunction(const String& localName) { |
412 | @@ -276,6 +326,39 @@ | |||
413 | 276 | delete thePropertiesFunction; | 326 | delete thePropertiesFunction; |
414 | 277 | } | 327 | } |
415 | 278 | 328 | ||
416 | 329 | zorba::Item& | ||
417 | 330 | SystemModule::getGlobalKey(SystemModule::GLOBAL_KEY g) | ||
418 | 331 | { | ||
419 | 332 | switch(g) | ||
420 | 333 | { | ||
421 | 334 | case OS_NAME: return globalOSName; | ||
422 | 335 | case OS_NODE_NAME: return globalOSNodeName; | ||
423 | 336 | case OS_VER_MAJOR: return globalOSVersionMajor; | ||
424 | 337 | case OS_VER_MINOR: return globalOSVersionMinor; | ||
425 | 338 | case OS_VER_BUILD: return globalOSVersionBuild; | ||
426 | 339 | case OS_VER_RELEASE: return globalOSVersionRelease; | ||
427 | 340 | case OS_VER_VERSION: return globalOSVersionVersion; | ||
428 | 341 | case OS_VER: return globalOSVersion; | ||
429 | 342 | case OS_ARCH: return globalOSArch; | ||
430 | 343 | case OS_IS64: return globalOSis64; | ||
431 | 344 | case HARDWARE_lOGICAL_CPU: return globalHWLogicalCPU; | ||
432 | 345 | case HARDWARE_PHYSICAL_CPU: return globalHWPhysicalCPU; | ||
433 | 346 | case HARDWARE_LOGICAL_PER_PHYSICAL_CPU: return globalHWLogicalPerPhysicalCPU; | ||
434 | 347 | case HARDWARE_PHYSICAL_MEMORY: return globalHWPhysicalMemory; | ||
435 | 348 | case HARDWARE_VIRTUAL_MEMORY: return globalHWVirtualMemory; | ||
436 | 349 | case HARDWARE_MANUFACTURER: return globalHWManufacturer; | ||
437 | 350 | case LINUX_DISTRIBUTOR: return globalLinuxDistributor; | ||
438 | 351 | case LINUX_DISTRIBUTOR_VERSION: return globalLinuxDistributorVersion; | ||
439 | 352 | case USER_NAME: return globalUserName; | ||
440 | 353 | case ZORBA_MODULE_PATH: return globalZorbaModulePath; | ||
441 | 354 | case ZORBA_VER: return globalZorbaVersion; | ||
442 | 355 | case ZORBA_VER_MAJOR: return globalZorbaVersionMajor; | ||
443 | 356 | case ZORBA_VER_MINOR: return globalZorbaVersionMinor; | ||
444 | 357 | case ZORBA_VER_PATCH: return globalZorbaVersionPatch; | ||
445 | 358 | // should never hit this code but still ... | ||
446 | 359 | default: return globalOSName; | ||
447 | 360 | } | ||
448 | 361 | } | ||
449 | 279 | 362 | ||
450 | 280 | SystemFunction::SystemFunction(const ExternalModule* aModule) | 363 | SystemFunction::SystemFunction(const ExternalModule* aModule) |
451 | 281 | : theModule(aModule), theFactory(Zorba::getInstance(0)->getItemFactory()) | 364 | : theModule(aModule), theFactory(Zorba::getInstance(0)->getItemFactory()) |
452 | @@ -291,7 +374,7 @@ | |||
453 | 291 | nodeNameC[i] = static_cast<char>(nodeName[i]); | 374 | nodeNameC[i] = static_cast<char>(nodeName[i]); |
454 | 292 | } | 375 | } |
455 | 293 | nodeNameC[nodeNameLength] = NULL; // Terminate string | 376 | nodeNameC[nodeNameLength] = NULL; // Terminate string |
457 | 294 | theProperties.insert(std::make_pair("os.node.name", nodeNameC)); | 377 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_NODE_NAME).getStringValue(), nodeNameC)); |
458 | 295 | } | 378 | } |
459 | 296 | 379 | ||
460 | 297 | { | 380 | { |
461 | @@ -325,13 +408,13 @@ | |||
462 | 325 | minor = sMinor.str(); | 408 | minor = sMinor.str(); |
463 | 326 | build = sBuild.str(); | 409 | build = sBuild.str(); |
464 | 327 | } | 410 | } |
469 | 328 | theProperties.insert(std::make_pair("os.version.major", major)); | 411 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER_MAJOR).getStringValue(), major)); |
470 | 329 | theProperties.insert(std::make_pair("os.version.minor", minor)); | 412 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER_MINOR).getStringValue(), minor)); |
471 | 330 | theProperties.insert(std::make_pair("os.version.build", build)); | 413 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER_BUILD).getStringValue(), build)); |
472 | 331 | theProperties.insert(std::make_pair("os.version", major + "." + minor + "." + build)); | 414 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER).getString(), major + "." + minor + "." + build)); |
473 | 332 | // http://msdn.microsoft.com/en-us/library/ms724832(v=VS.85).aspx | 415 | // http://msdn.microsoft.com/en-us/library/ms724832(v=VS.85).aspx |
474 | 333 | std::string operativeSystem; | 416 | std::string operativeSystem; |
476 | 334 | theProperties.insert(std::make_pair("os.name", "Windows")); | 417 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_NAME).getStringValue(), "Windows")); |
477 | 335 | { | 418 | { |
478 | 336 | countProcessors(); | 419 | countProcessors(); |
479 | 337 | std::stringstream logicalProcessors; | 420 | std::stringstream logicalProcessors; |
480 | @@ -340,9 +423,9 @@ | |||
481 | 340 | physicalProcessors << logicalProcessorCount; | 423 | physicalProcessors << logicalProcessorCount; |
482 | 341 | std::stringstream logicalPerPhysicalProcessors; | 424 | std::stringstream logicalPerPhysicalProcessors; |
483 | 342 | logicalPerPhysicalProcessors << (logicalProcessorCount / processorPackageCount ); | 425 | logicalPerPhysicalProcessors << (logicalProcessorCount / processorPackageCount ); |
487 | 343 | theProperties.insert(std::make_pair("hardware.physical.cpu", logicalProcessors.str() )); | 426 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_PHYSICAL_CPU).getStringValue(), logicalProcessors.str() )); |
488 | 344 | theProperties.insert(std::make_pair("hardware.logical.cpu", physicalProcessors.str() )); | 427 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_lOGICAL_CPU).getStringValue(), physicalProcessors.str() )); |
489 | 345 | theProperties.insert(std::make_pair("hardware.logical.per.physical.cpu", logicalPerPhysicalProcessors.str() )); | 428 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_LOGICAL_PER_PHYSICAL_CPU).getStringValue(), logicalPerPhysicalProcessors.str() )); |
490 | 346 | } | 429 | } |
491 | 347 | { | 430 | { |
492 | 348 | MEMORYSTATUSEX statex; | 431 | MEMORYSTATUSEX statex; |
493 | @@ -352,8 +435,8 @@ | |||
494 | 352 | virtualMemory << statex.ullTotalVirtual; | 435 | virtualMemory << statex.ullTotalVirtual; |
495 | 353 | std::stringstream physicalMemory; | 436 | std::stringstream physicalMemory; |
496 | 354 | physicalMemory << statex.ullTotalPhys; | 437 | physicalMemory << statex.ullTotalPhys; |
499 | 355 | theProperties.insert(std::make_pair("hardware.virtual.memory", virtualMemory.str() )); | 438 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_VIRTUAL_MEMORY).getStringValue(), virtualMemory.str() )); |
500 | 356 | theProperties.insert(std::make_pair("hardware.physical.memory", physicalMemory.str() )); | 439 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_PHYSICAL_MEMORY).getStringValue(), physicalMemory.str() )); |
501 | 357 | } | 440 | } |
502 | 358 | 441 | ||
503 | 359 | } | 442 | } |
504 | @@ -365,20 +448,20 @@ | |||
505 | 365 | for (DWORD i = 0; i < userNameLength; ++i) { | 448 | for (DWORD i = 0; i < userNameLength; ++i) { |
506 | 366 | userNameC[i] = static_cast<char>(userName[i]); | 449 | userNameC[i] = static_cast<char>(userName[i]); |
507 | 367 | } | 450 | } |
509 | 368 | theProperties.insert(std::make_pair("user.name", userNameC)); | 451 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::USER_NAME).getStringValue(), userNameC)); |
510 | 369 | } | 452 | } |
511 | 370 | { | 453 | { |
512 | 371 | SYSTEM_INFO info; | 454 | SYSTEM_INFO info; |
513 | 372 | GetSystemInfo(&info); | 455 | GetSystemInfo(&info); |
514 | 373 | if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { | 456 | if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { |
517 | 374 | theProperties.insert(std::make_pair("os.arch", "x86_64")); | 457 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_ARCH).getStringValue(), "x86_64")); |
518 | 375 | theProperties.insert(std::make_pair("os.is64", "true")); | 458 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_IS64).getStringValue(), "true")); |
519 | 376 | } else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) { | 459 | } else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) { |
522 | 377 | theProperties.insert(std::make_pair("os.arch", "ia64")); | 460 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_ARCH).getStringValue(), "ia64")); |
523 | 378 | theProperties.insert(std::make_pair("os.is64", "true")); | 461 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_IS64).getStringValue(), "true")); |
524 | 379 | } else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { | 462 | } else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { |
527 | 380 | theProperties.insert(std::make_pair("os.arch", "i386")); | 463 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_ARCH).getStringValue(), "i386")); |
528 | 381 | theProperties.insert(std::make_pair("os.is64", "false")); | 464 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_IS64).getStringValue(), "false")); |
529 | 382 | } | 465 | } |
530 | 383 | } | 466 | } |
531 | 384 | 467 | ||
532 | @@ -395,7 +478,7 @@ | |||
533 | 395 | valueC[i] = static_cast<char>(value[i]); | 478 | valueC[i] = static_cast<char>(value[i]); |
534 | 396 | } | 479 | } |
535 | 397 | if (size > 0) | 480 | if (size > 0) |
537 | 398 | theProperties.insert(std::make_pair("hardware.manufacturer", valueC)); | 481 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_MANUFACTURER).getStringValue(), valueC)); |
538 | 399 | } | 482 | } |
539 | 400 | RegCloseKey(keyHandle); | 483 | RegCloseKey(keyHandle); |
540 | 401 | } | 484 | } |
541 | @@ -405,19 +488,19 @@ | |||
542 | 405 | struct utsname osname; | 488 | struct utsname osname; |
543 | 406 | if (uname(&osname) == 0) | 489 | if (uname(&osname) == 0) |
544 | 407 | { | 490 | { |
551 | 408 | theProperties.insert(std::make_pair("os.name", osname.sysname)); | 491 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_NAME).getStringValue(), osname.sysname)); |
552 | 409 | theProperties.insert(std::make_pair("os.node.name", osname.nodename)); | 492 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_NODE_NAME).getStringValue(), osname.nodename)); |
553 | 410 | theProperties.insert(std::make_pair("os.version.release", osname.release)); | 493 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER_RELEASE).getStringValue(), osname.release)); |
554 | 411 | theProperties.insert(std::make_pair("os.version.version", osname.version)); | 494 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER_VERSION).getStringValue(), osname.version)); |
555 | 412 | theProperties.insert(std::make_pair("os.version", osname.release)); | 495 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_VER).getStringValue(), osname.release)); |
556 | 413 | theProperties.insert(std::make_pair("os.arch", osname.machine)); | 496 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_ARCH).getStringValue(), osname.machine)); |
557 | 414 | } | 497 | } |
558 | 415 | char* lUser = getenv("USER"); | 498 | char* lUser = getenv("USER"); |
559 | 416 | if (lUser) | 499 | if (lUser) |
560 | 417 | { | 500 | { |
562 | 418 | theProperties.insert(std::make_pair("user.name", lUser)); | 501 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::USER_NAME).getStringValue(), lUser)); |
563 | 419 | } | 502 | } |
565 | 420 | theProperties.insert(std::make_pair("os.is64", "false")); | 503 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::OS_IS64).getStringValue(), "false")); |
566 | 421 | { | 504 | { |
567 | 422 | #ifdef __APPLE__ | 505 | #ifdef __APPLE__ |
568 | 423 | int mib[2]; | 506 | int mib[2]; |
569 | @@ -429,7 +512,7 @@ | |||
570 | 429 | sysctl(mib, 2, &res, &len, NULL, NULL); | 512 | sysctl(mib, 2, &res, &len, NULL, NULL); |
571 | 430 | std::stringstream lStream; | 513 | std::stringstream lStream; |
572 | 431 | lStream << res; | 514 | lStream << res; |
574 | 432 | theProperties.insert(std::make_pair("hardware.physical.cpu", lStream.str())); | 515 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_PHYSICAL_CPU).getStringValue(), lStream.str())); |
575 | 433 | #else | 516 | #else |
576 | 434 | countProcessors(); | 517 | countProcessors(); |
577 | 435 | std::stringstream logicalProcessor; | 518 | std::stringstream logicalProcessor; |
578 | @@ -438,9 +521,9 @@ | |||
579 | 438 | logicalProcessor << logical; | 521 | logicalProcessor << logical; |
580 | 439 | physicalProcessor << physical; | 522 | physicalProcessor << physical; |
581 | 440 | logicalPerPhysicalProcessors << cores; | 523 | logicalPerPhysicalProcessors << cores; |
585 | 441 | theProperties.insert(std::make_pair("hardware.logical.per.physical.cpu", logicalPerPhysicalProcessors.str() )); | 524 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_LOGICAL_PER_PHYSICAL_CPU).getStringValue(), logicalPerPhysicalProcessors.str() )); |
586 | 442 | theProperties.insert(std::make_pair("hardware.physical.cpu", physicalProcessor.str() )); | 525 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_PHYSICAL_CPU).getStringValue(), physicalProcessor.str() )); |
587 | 443 | theProperties.insert(std::make_pair("hardware.logical.cpu", logicalProcessor.str() )); | 526 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_lOGICAL_CPU).getStringValue(), logicalProcessor.str() )); |
588 | 444 | #endif | 527 | #endif |
589 | 445 | } | 528 | } |
590 | 446 | { | 529 | { |
591 | @@ -451,8 +534,8 @@ | |||
592 | 451 | memory << sys_info.totalram; | 534 | memory << sys_info.totalram; |
593 | 452 | std::stringstream swap; | 535 | std::stringstream swap; |
594 | 453 | swap << sys_info.totalswap; | 536 | swap << sys_info.totalswap; |
597 | 454 | theProperties.insert(std::make_pair("hardware.virtual.memory", swap.str() )); | 537 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_VIRTUAL_MEMORY).getStringValue(), swap.str() )); |
598 | 455 | theProperties.insert(std::make_pair("hardware.physical.memory", memory.str() )); | 538 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_PHYSICAL_MEMORY).getStringValue(), memory.str() )); |
599 | 456 | } | 539 | } |
600 | 457 | # elif defined __APPLE__ | 540 | # elif defined __APPLE__ |
601 | 458 | int mib[2]; | 541 | int mib[2]; |
602 | @@ -464,19 +547,19 @@ | |||
603 | 464 | sysctl(mib, 2, &res, &len, NULL, NULL); | 547 | sysctl(mib, 2, &res, &len, NULL, NULL); |
604 | 465 | std::stringstream lStream; | 548 | std::stringstream lStream; |
605 | 466 | lStream << res; | 549 | lStream << res; |
607 | 467 | theProperties.insert(std::make_pair("hardware.physical.memory", lStream.str())); | 550 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::HARDWARE_PHYSICAL_MEMORY).getStringValue(), lStream.str())); |
608 | 468 | # endif | 551 | # endif |
609 | 469 | } | 552 | } |
610 | 470 | 553 | ||
611 | 471 | #endif | 554 | #endif |
612 | 472 | #ifdef LINUX | 555 | #ifdef LINUX |
615 | 473 | theProperties.insert(std::make_pair("linux.distributor", "")); | 556 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::LINUX_DISTRIBUTOR).getStringValue(), "")); |
616 | 474 | theProperties.insert(std::make_pair("linux.distributor.version", "")); | 557 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::LINUX_DISTRIBUTOR_VERSION).getStringValue(), "")); |
617 | 475 | #endif | 558 | #endif |
622 | 476 | theProperties.insert(std::make_pair("zorba.version", Zorba::version().getVersion())); | 559 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::ZORBA_VER).getStringValue(), Zorba::version().getVersion())); |
623 | 477 | theProperties.insert(std::make_pair("zorba.version.major", intToString(Zorba::version().getMajorVersion()))); | 560 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::ZORBA_VER_MAJOR).getStringValue(), intToString(Zorba::version().getMajorVersion()))); |
624 | 478 | theProperties.insert(std::make_pair("zorba.version.minor", intToString(Zorba::version().getMinorVersion()))); | 561 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::ZORBA_VER_MINOR).getStringValue(), intToString(Zorba::version().getMinorVersion()))); |
625 | 479 | theProperties.insert(std::make_pair("zorba.version.patch", intToString(Zorba::version().getPatchVersion()))); | 562 | theProperties.insert(std::make_pair(SystemModule::getGlobalKey(SystemModule::ZORBA_VER_PATCH).getStringValue(), intToString(Zorba::version().getPatchVersion()))); |
626 | 480 | } | 563 | } |
627 | 481 | 564 | ||
628 | 482 | String SystemFunction::intToString(int v) { | 565 | String SystemFunction::intToString(int v) { |
629 | @@ -552,7 +635,7 @@ | |||
630 | 552 | lRes.push_back(lItem); | 635 | lRes.push_back(lItem); |
631 | 553 | } | 636 | } |
632 | 554 | // insert the zorba module path | 637 | // insert the zorba module path |
634 | 555 | lRes.push_back(theFactory->createString("zorba.module.path")); | 638 | lRes.push_back(SystemModule::getGlobalKey(SystemModule::ZORBA_MODULE_PATH)); |
635 | 556 | return ItemSequence_t(new VectorItemSequence(lRes)); | 639 | return ItemSequence_t(new VectorItemSequence(lRes)); |
636 | 557 | } | 640 | } |
637 | 558 | 641 | ||
638 | @@ -567,7 +650,7 @@ | |||
639 | 567 | arg0_iter->close(); | 650 | arg0_iter->close(); |
640 | 568 | String envS = item.getStringValue(); | 651 | String envS = item.getStringValue(); |
641 | 569 | String lRes; | 652 | String lRes; |
643 | 570 | if (envS == "zorba.module.path") { | 653 | if (envS == SystemModule::getGlobalKey(SystemModule::ZORBA_MODULE_PATH).getStringValue().str()) { |
644 | 571 | std::vector<String> lModulePaths; | 654 | std::vector<String> lModulePaths; |
645 | 572 | sctx->getFullModulePaths(lModulePaths); | 655 | sctx->getFullModulePaths(lModulePaths); |
646 | 573 | if (lModulePaths.size() == 0) | 656 | if (lModulePaths.size() == 0) |
647 | @@ -587,9 +670,9 @@ | |||
648 | 587 | return ItemSequence_t(new EmptySequence()); | 670 | return ItemSequence_t(new EmptySequence()); |
649 | 588 | } | 671 | } |
650 | 589 | #ifdef LINUX | 672 | #ifdef LINUX |
652 | 590 | } else if (envS == "linux.distributor") { | 673 | } else if (envS == SystemModule::getGlobalKey(SystemModule::LINUX_DISTRIBUTOR).getStringValue().str()) { |
653 | 591 | lRes = getDistribution().first; | 674 | lRes = getDistribution().first; |
655 | 592 | } else if (envS == "linux.distributor.version") { | 675 | } else if (envS == SystemModule::getGlobalKey(SystemModule::LINUX_DISTRIBUTOR_VERSION).getStringValue().str()) { |
656 | 593 | lRes = getDistribution().second; | 676 | lRes = getDistribution().second; |
657 | 594 | #endif | 677 | #endif |
658 | 595 | } else { | 678 | } else { |
659 | 596 | 679 | ||
660 | === modified file 'src/system.xq.src/system.h' | |||
661 | --- src/com/zorba-xquery/www/modules/system.xq.src/system.h 2011-08-05 02:22:28 +0000 | |||
662 | +++ src/system.xq.src/system.h 2013-08-08 20:52:48 +0000 | |||
663 | @@ -25,19 +25,54 @@ | |||
664 | 25 | 25 | ||
665 | 26 | namespace zorba { namespace system { | 26 | namespace zorba { namespace system { |
666 | 27 | class SystemModule : public ExternalModule { | 27 | class SystemModule : public ExternalModule { |
667 | 28 | protected: | ||
668 | 29 | static zorba::Item globalOSName; | ||
669 | 30 | static zorba::Item globalOSNodeName; | ||
670 | 31 | static zorba::Item globalOSVersionMajor; | ||
671 | 32 | static zorba::Item globalOSVersionMinor; | ||
672 | 33 | static zorba::Item globalOSVersionBuild; | ||
673 | 34 | static zorba::Item globalOSVersionRelease; | ||
674 | 35 | static zorba::Item globalOSVersionVersion; | ||
675 | 36 | static zorba::Item globalOSVersion; | ||
676 | 37 | static zorba::Item globalOSArch; | ||
677 | 38 | static zorba::Item globalOSis64; | ||
678 | 39 | static zorba::Item globalHWLogicalCPU; | ||
679 | 40 | static zorba::Item globalHWPhysicalCPU; | ||
680 | 41 | static zorba::Item globalHWLogicalPerPhysicalCPU; | ||
681 | 42 | static zorba::Item globalHWPhysicalMemory; | ||
682 | 43 | static zorba::Item globalHWVirtualMemory; | ||
683 | 44 | static zorba::Item globalHWManufacturer; | ||
684 | 45 | static zorba::Item globalLinuxDistributor; | ||
685 | 46 | static zorba::Item globalLinuxDistributorVersion; | ||
686 | 47 | static zorba::Item globalUserName; | ||
687 | 48 | static zorba::Item globalZorbaModulePath; | ||
688 | 49 | static zorba::Item globalZorbaVersion; | ||
689 | 50 | static zorba::Item globalZorbaVersionMajor; | ||
690 | 51 | static zorba::Item globalZorbaVersionMinor; | ||
691 | 52 | static zorba::Item globalZorbaVersionPatch; | ||
692 | 28 | private: | 53 | private: |
693 | 29 | ExternalFunction* thePropertyFunction; | 54 | ExternalFunction* thePropertyFunction; |
694 | 30 | ExternalFunction* thePropertiesFunction; | 55 | ExternalFunction* thePropertiesFunction; |
695 | 31 | const static String SYSTEM_MODULE_NAMESPACE; | 56 | const static String SYSTEM_MODULE_NAMESPACE; |
696 | 32 | public: | 57 | public: |
697 | 58 | enum GLOBAL_KEY { OS_NAME, OS_NODE_NAME, OS_VER_MAJOR, OS_VER_MINOR, | ||
698 | 59 | OS_VER_BUILD, OS_VER_RELEASE, OS_VER_VERSION, OS_VER, | ||
699 | 60 | OS_ARCH, OS_IS64, HARDWARE_lOGICAL_CPU, HARDWARE_PHYSICAL_CPU, | ||
700 | 61 | HARDWARE_LOGICAL_PER_PHYSICAL_CPU, HARDWARE_PHYSICAL_MEMORY, | ||
701 | 62 | HARDWARE_VIRTUAL_MEMORY, HARDWARE_MANUFACTURER, LINUX_DISTRIBUTOR, | ||
702 | 63 | LINUX_DISTRIBUTOR_VERSION, USER_NAME, ZORBA_MODULE_PATH, ZORBA_VER, ZORBA_VER_MAJOR, | ||
703 | 64 | ZORBA_VER_MINOR, ZORBA_VER_PATCH }; | ||
704 | 65 | |||
705 | 33 | SystemModule(); | 66 | SystemModule(); |
706 | 34 | virtual ~SystemModule(); | 67 | virtual ~SystemModule(); |
708 | 35 | public: | 68 | |
709 | 36 | virtual String getURI() const { return SYSTEM_MODULE_NAMESPACE; } | 69 | virtual String getURI() const { return SYSTEM_MODULE_NAMESPACE; } |
710 | 37 | 70 | ||
711 | 38 | virtual ExternalFunction* getExternalFunction(const String& localName); | 71 | virtual ExternalFunction* getExternalFunction(const String& localName); |
712 | 39 | 72 | ||
713 | 40 | virtual void destroy(); | 73 | virtual void destroy(); |
714 | 74 | |||
715 | 75 | static zorba::Item& getGlobalKey(enum GLOBAL_KEY g); | ||
716 | 41 | }; | 76 | }; |
717 | 42 | 77 | ||
718 | 43 | class SystemFunction { | 78 | class SystemFunction { |
Looks very good, nice work. However, the moduleDocumentation test doesn't pass, so there must be a typo somewhere in the XQDoc. Also, I suspect once you fix that, it will complain that all those public variable declarations need to have XQDoc; you'll probably need to restore the doc from the old version. (%private variables, like errors codes, don't need XQDoc, but public ones do as far as I know.)