gitlab-pygments.rb 0.3.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +71 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE +17 -0
  6. data/README.md +28 -1
  7. data/Rakefile +2 -5
  8. data/lexers +0 -0
  9. data/lib/pygments/mentos.py +19 -12
  10. data/lib/pygments/popen.rb +21 -4
  11. data/lib/pygments/version.rb +1 -1
  12. data/pygments.rb.gemspec +2 -0
  13. data/test/test_pygments.rb +13 -2
  14. data/vendor/custom_lexers/github.py +206 -3
  15. data/vendor/pygments-main/AUTHORS +41 -3
  16. data/vendor/pygments-main/CHANGES +132 -5
  17. data/vendor/pygments-main/LICENSE +1 -1
  18. data/vendor/pygments-main/Makefile +1 -1
  19. data/vendor/pygments-main/REVISION +1 -1
  20. data/vendor/pygments-main/docs/generate.py +1 -1
  21. data/vendor/pygments-main/docs/src/api.txt +1 -1
  22. data/vendor/pygments-main/docs/src/index.txt +1 -1
  23. data/vendor/pygments-main/docs/src/integrate.txt +5 -0
  24. data/vendor/pygments-main/docs/src/java.txt +70 -0
  25. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +52 -0
  26. data/vendor/pygments-main/external/autopygmentize +64 -0
  27. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
  28. data/vendor/pygments-main/external/markdown-processor.py +2 -2
  29. data/vendor/pygments-main/external/moin-parser.py +1 -1
  30. data/vendor/pygments-main/external/rst-directive-old.py +1 -1
  31. data/vendor/pygments-main/external/rst-directive.py +1 -1
  32. data/vendor/pygments-main/pygmentize +1 -1
  33. data/vendor/pygments-main/pygments/__init__.py +2 -2
  34. data/vendor/pygments-main/pygments/cmdline.py +14 -6
  35. data/vendor/pygments-main/pygments/console.py +1 -1
  36. data/vendor/pygments-main/pygments/filter.py +1 -1
  37. data/vendor/pygments-main/pygments/filters/__init__.py +3 -4
  38. data/vendor/pygments-main/pygments/formatter.py +4 -1
  39. data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
  40. data/vendor/pygments-main/pygments/formatters/_mapping.py +3 -3
  41. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  42. data/vendor/pygments-main/pygments/formatters/html.py +73 -2
  43. data/vendor/pygments-main/pygments/formatters/img.py +2 -2
  44. data/vendor/pygments-main/pygments/formatters/latex.py +9 -9
  45. data/vendor/pygments-main/pygments/formatters/other.py +1 -3
  46. data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
  47. data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
  48. data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
  49. data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
  50. data/vendor/pygments-main/pygments/lexer.py +78 -10
  51. data/vendor/pygments-main/pygments/lexers/__init__.py +13 -2
  52. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  53. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
  54. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
  55. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
  56. data/vendor/pygments-main/pygments/lexers/_mapping.py +92 -36
  57. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
  58. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
  59. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -3
  60. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
  61. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
  62. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
  63. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
  64. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -3
  65. data/vendor/pygments-main/pygments/lexers/agile.py +525 -38
  66. data/vendor/pygments-main/pygments/lexers/asm.py +45 -7
  67. data/vendor/pygments-main/pygments/lexers/compiled.py +1257 -425
  68. data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
  69. data/vendor/pygments-main/pygments/lexers/dotnet.py +97 -62
  70. data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
  71. data/vendor/pygments-main/pygments/lexers/functional.py +931 -32
  72. data/vendor/pygments-main/pygments/lexers/github.py +206 -3
  73. data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
  74. data/vendor/pygments-main/pygments/lexers/jvm.py +309 -44
  75. data/vendor/pygments-main/pygments/lexers/math.py +876 -30
  76. data/vendor/pygments-main/pygments/lexers/other.py +956 -517
  77. data/vendor/pygments-main/pygments/lexers/parsers.py +85 -2
  78. data/vendor/pygments-main/pygments/lexers/shell.py +81 -18
  79. data/vendor/pygments-main/pygments/lexers/special.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/sql.py +2 -2
  81. data/vendor/pygments-main/pygments/lexers/templates.py +119 -8
  82. data/vendor/pygments-main/pygments/lexers/text.py +155 -15
  83. data/vendor/pygments-main/pygments/lexers/web.py +1578 -397
  84. data/vendor/pygments-main/pygments/modeline.py +40 -0
  85. data/vendor/pygments-main/pygments/plugin.py +1 -1
  86. data/vendor/pygments-main/pygments/scanner.py +1 -1
  87. data/vendor/pygments-main/pygments/style.py +1 -1
  88. data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
  89. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  90. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  91. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  92. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  93. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  94. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  95. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  96. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  97. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  98. data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
  99. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  100. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  101. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  102. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  103. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  104. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  105. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  106. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  107. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  108. data/vendor/pygments-main/pygments/token.py +1 -1
  109. data/vendor/pygments-main/pygments/unistring.py +36 -26
  110. data/vendor/pygments-main/pygments/util.py +46 -1
  111. data/vendor/pygments-main/scripts/check_sources.py +2 -2
  112. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
  113. data/vendor/pygments-main/scripts/find_codetags.py +1 -1
  114. data/vendor/pygments-main/scripts/find_error.py +5 -6
  115. data/vendor/pygments-main/setup.cfg +1 -0
  116. data/vendor/pygments-main/setup.py +6 -4
  117. data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
  118. data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
  119. data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
  120. data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
  121. data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
  122. data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
  123. data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
  124. data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
  125. data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
  126. data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
  127. data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
  128. data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
  129. data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
  130. data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
  131. data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
  132. data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
  133. data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
  134. data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
  135. data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
  136. data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
  137. data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
  138. data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
  139. data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
  140. data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
  141. data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
  142. data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
  143. data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
  144. data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
  145. data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
  146. data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
  147. data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
  148. data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
  149. data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
  150. data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
  151. data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
  152. data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
  153. data/vendor/pygments-main/tests/examplefiles/http_request_example +2 -1
  154. data/vendor/pygments-main/tests/examplefiles/http_response_example +4 -2
  155. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
  156. data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
  157. data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
  158. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
  159. data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
  160. data/vendor/pygments-main/tests/examplefiles/matlab_sample +5 -2
  161. data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
  162. data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
  163. data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
  164. data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
  165. data/vendor/pygments-main/tests/examplefiles/objc_example.m +7 -0
  166. data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
  167. data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
  168. data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
  169. data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
  170. data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
  171. data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
  172. data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
  173. data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
  174. data/vendor/pygments-main/tests/examplefiles/test.R +149 -115
  175. data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
  176. data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
  177. data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
  178. data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
  179. data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
  180. data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
  181. data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
  182. data/vendor/pygments-main/tests/examplefiles/type.lisp +16 -0
  183. data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
  184. data/vendor/pygments-main/tests/old_run.py +1 -1
  185. data/vendor/pygments-main/tests/run.py +3 -2
  186. data/vendor/pygments-main/tests/support/tags +36 -0
  187. data/vendor/pygments-main/tests/test_basic_api.py +4 -3
  188. data/vendor/pygments-main/tests/test_clexer.py +1 -1
  189. data/vendor/pygments-main/tests/test_cmdline.py +1 -1
  190. data/vendor/pygments-main/tests/test_examplefiles.py +3 -1
  191. data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
  192. data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
  193. data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
  194. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  195. data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
  196. data/vendor/pygments-main/tests/test_token.py +1 -1
  197. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  198. data/vendor/pygments-main/tests/test_util.py +22 -3
  199. metadata +84 -16
@@ -0,0 +1,4 @@
1
+ File "<stdin>", line 1
2
+ 1+
3
+ ^
4
+ SyntaxError: invalid syntax
@@ -0,0 +1,4 @@
1
+ >>> 3/"3"
2
+ Traceback (most recent call last):
3
+ File "<stdin>", line 1, in <module>
4
+ TypeError: unsupported operand type(s) for /: 'int' and 'str'
@@ -0,0 +1,39 @@
1
+ *** Settings ***
2
+ Documentation Simple example demonstrating syntax highlighting.
3
+ Library ExampleLibrary
4
+ Test Setup Keyword argument argument with ${VARIABLE}
5
+
6
+ *** Variables ***
7
+ ${VARIABLE} Variable value
8
+ @{LIST} List variable here
9
+
10
+ *** Test Cases ***
11
+ Keyword-driven example
12
+ Initialize System
13
+ Do Something
14
+ Result Should Be 42
15
+ [Teardown] Cleanup System
16
+
17
+ Data-driven example
18
+ [Template] Keyword
19
+ argument1 argument2
20
+ argument ${VARIABLE}
21
+ @{LIST}
22
+
23
+ Gherkin
24
+ Given system is initialized
25
+ When something is done
26
+ Then result should be "42"
27
+
28
+ | Pipes |
29
+ | | [Documentation] | Also pipe separated format is supported. |
30
+ | | Log | As this example demonstrates. |
31
+
32
+ *** Keywords ***
33
+ Result Should Be
34
+ [Arguments] ${expected}
35
+ ${actual} = Get Value
36
+ Should be Equal ${actual} ${expected}
37
+
38
+ Then result should be "${expected}"
39
+ Result Should Be ${expected}
@@ -0,0 +1,233 @@
1
+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // based on:
12
+ // http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java
13
+
14
+ extern mod std;
15
+
16
+ use core::os;
17
+
18
+ // Using sqrt from the standard library is way slower than using libc
19
+ // directly even though std just calls libc, I guess it must be
20
+ // because the the indirection through another dynamic linker
21
+ // stub. Kind of shocking. Might be able to make it faster still with
22
+ // an llvm intrinsic.
23
+ #[nolink]
24
+ extern mod libc {
25
+ #[legacy_exports];
26
+ fn sqrt(n: float) -> float;
27
+ }
28
+
29
+ fn main() {
30
+ let args = os::args();
31
+ let args = if os::getenv(~"RUST_BENCH").is_some() {
32
+ ~[~"", ~"4000000"]
33
+ } else if args.len() <= 1u {
34
+ ~[~"", ~"100000"]
35
+ } else {
36
+ args
37
+ };
38
+ let n = int::from_str(args[1]).get();
39
+ let mut bodies: ~[Body::props] = NBodySystem::make();
40
+ io::println(fmt!("%f", NBodySystem::energy(bodies)));
41
+ let mut i = 0;
42
+ while i < n {
43
+ NBodySystem::advance(bodies, 0.01);
44
+ i += 1;
45
+ }
46
+ io::println(fmt!("%f", NBodySystem::energy(bodies)));
47
+ }
48
+
49
+ mod NBodySystem {
50
+ use Body;
51
+
52
+ pub fn make() -> ~[Body::props] {
53
+ let mut bodies: ~[Body::props] =
54
+ ~[Body::sun(),
55
+ Body::jupiter(),
56
+ Body::saturn(),
57
+ Body::uranus(),
58
+ Body::neptune()];
59
+
60
+ let mut px = 0.0;
61
+ let mut py = 0.0;
62
+ let mut pz = 0.0;
63
+
64
+ let mut i = 0;
65
+ while i < 5 {
66
+ px += bodies[i].vx * bodies[i].mass;
67
+ py += bodies[i].vy * bodies[i].mass;
68
+ pz += bodies[i].vz * bodies[i].mass;
69
+
70
+ i += 1;
71
+ }
72
+
73
+ // side-effecting
74
+ Body::offset_momentum(&mut bodies[0], px, py, pz);
75
+
76
+ return bodies;
77
+ }
78
+
79
+ pub fn advance(bodies: &mut [Body::props], dt: float) {
80
+ let mut i = 0;
81
+ while i < 5 {
82
+ let mut j = i + 1;
83
+ while j < 5 {
84
+ advance_one(&mut bodies[i],
85
+ &mut bodies[j], dt);
86
+ j += 1;
87
+ }
88
+
89
+ i += 1;
90
+ }
91
+
92
+ i = 0;
93
+ while i < 5 {
94
+ move_(&mut bodies[i], dt);
95
+ i += 1;
96
+ }
97
+ }
98
+
99
+ pub fn advance_one(bi: &mut Body::props,
100
+ bj: &mut Body::props,
101
+ dt: float) unsafe {
102
+ let dx = bi.x - bj.x;
103
+ let dy = bi.y - bj.y;
104
+ let dz = bi.z - bj.z;
105
+
106
+ let dSquared = dx * dx + dy * dy + dz * dz;
107
+
108
+ let distance = ::libc::sqrt(dSquared);
109
+ let mag = dt / (dSquared * distance);
110
+
111
+ bi.vx -= dx * bj.mass * mag;
112
+ bi.vy -= dy * bj.mass * mag;
113
+ bi.vz -= dz * bj.mass * mag;
114
+
115
+ bj.vx += dx * bi.mass * mag;
116
+ bj.vy += dy * bi.mass * mag;
117
+ bj.vz += dz * bi.mass * mag;
118
+ }
119
+
120
+ pub fn move_(b: &mut Body::props, dt: float) {
121
+ b.x += dt * b.vx;
122
+ b.y += dt * b.vy;
123
+ b.z += dt * b.vz;
124
+ }
125
+
126
+ pub fn energy(bodies: &[Body::props]) -> float unsafe {
127
+ let mut dx;
128
+ let mut dy;
129
+ let mut dz;
130
+ let mut distance;
131
+ let mut e = 0.0;
132
+
133
+ let mut i = 0;
134
+ while i < 5 {
135
+ e +=
136
+ 0.5 * bodies[i].mass *
137
+ (bodies[i].vx * bodies[i].vx + bodies[i].vy * bodies[i].vy
138
+ + bodies[i].vz * bodies[i].vz);
139
+
140
+ let mut j = i + 1;
141
+ while j < 5 {
142
+ dx = bodies[i].x - bodies[j].x;
143
+ dy = bodies[i].y - bodies[j].y;
144
+ dz = bodies[i].z - bodies[j].z;
145
+
146
+ distance = ::libc::sqrt(dx * dx + dy * dy + dz * dz);
147
+ e -= bodies[i].mass * bodies[j].mass / distance;
148
+
149
+ j += 1;
150
+ }
151
+
152
+ i += 1;
153
+ }
154
+ return e;
155
+
156
+ }
157
+ }
158
+
159
+ mod Body {
160
+ use Body;
161
+
162
+ pub const PI: float = 3.141592653589793;
163
+ pub const SOLAR_MASS: float = 39.478417604357432;
164
+ // was 4 * PI * PI originally
165
+ pub const DAYS_PER_YEAR: float = 365.24;
166
+
167
+ pub type props =
168
+ {mut x: float,
169
+ mut y: float,
170
+ mut z: float,
171
+ mut vx: float,
172
+ mut vy: float,
173
+ mut vz: float,
174
+ mass: float};
175
+
176
+ pub fn jupiter() -> Body::props {
177
+ return {mut x: 4.84143144246472090e+00,
178
+ mut y: -1.16032004402742839e+00,
179
+ mut z: -1.03622044471123109e-01,
180
+ mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
181
+ mut vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
182
+ mut vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
183
+ mass: 9.54791938424326609e-04 * SOLAR_MASS};
184
+ }
185
+
186
+ pub fn saturn() -> Body::props {
187
+ return {mut x: 8.34336671824457987e+00,
188
+ mut y: 4.12479856412430479e+00,
189
+ mut z: -4.03523417114321381e-01,
190
+ mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
191
+ mut vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
192
+ mut vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
193
+ mass: 2.85885980666130812e-04 * SOLAR_MASS};
194
+ }
195
+
196
+ pub fn uranus() -> Body::props {
197
+ return {mut x: 1.28943695621391310e+01,
198
+ mut y: -1.51111514016986312e+01,
199
+ mut z: -2.23307578892655734e-01,
200
+ mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
201
+ mut vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
202
+ mut vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
203
+ mass: 4.36624404335156298e-05 * SOLAR_MASS};
204
+ }
205
+
206
+ pub fn neptune() -> Body::props {
207
+ return {mut x: 1.53796971148509165e+01,
208
+ mut y: -2.59193146099879641e+01,
209
+ mut z: 1.79258772950371181e-01,
210
+ mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
211
+ mut vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
212
+ mut vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
213
+ mass: 5.15138902046611451e-05 * SOLAR_MASS};
214
+ }
215
+
216
+ pub fn sun() -> Body::props {
217
+ return {mut x: 0.0,
218
+ mut y: 0.0,
219
+ mut z: 0.0,
220
+ mut vx: 0.0,
221
+ mut vy: 0.0,
222
+ mut vz: 0.0,
223
+ mass: SOLAR_MASS};
224
+ }
225
+
226
+ pub fn offset_momentum(props: &mut Body::props,
227
+ px: float, py: float, pz: float) {
228
+ props.vx = -px / SOLAR_MASS;
229
+ props.vy = -py / SOLAR_MASS;
230
+ props.vz = -pz / SOLAR_MASS;
231
+ }
232
+
233
+ }
@@ -0,0 +1,9 @@
1
+ ? 7 * 52;
2
+ => 364
3
+ ? define variable *your-variable* = $foo;
4
+ ? begin
5
+ let yours = "apple";
6
+ let mine = yours;
7
+ mine == yours;
8
+ end;
9
+ => #t
@@ -0,0 +1,1329 @@
1
+ /* -----------------------------------------------------------------------------
2
+ * java.swg
3
+ *
4
+ * Java typemaps
5
+ * ----------------------------------------------------------------------------- */
6
+
7
+ %include <javahead.swg>
8
+
9
+ /* The jni, jtype and jstype typemaps work together and so there should be one of each.
10
+ * The jni typemap contains the JNI type used in the JNI (C/C++) code.
11
+ * The jtype typemap contains the Java type used in the JNI intermediary class.
12
+ * The jstype typemap contains the Java type used in the Java proxy classes, type wrapper classes and module class. */
13
+
14
+ /* Fragments */
15
+ %fragment("SWIG_PackData", "header") {
16
+ /* Pack binary data into a string */
17
+ SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
18
+ static const char hex[17] = "0123456789abcdef";
19
+ register const unsigned char *u = (unsigned char *) ptr;
20
+ register const unsigned char *eu = u + sz;
21
+ for (; u != eu; ++u) {
22
+ register unsigned char uu = *u;
23
+ *(c++) = hex[(uu & 0xf0) >> 4];
24
+ *(c++) = hex[uu & 0xf];
25
+ }
26
+ return c;
27
+ }
28
+ }
29
+
30
+ %fragment("SWIG_UnPackData", "header") {
31
+ /* Unpack binary data from a string */
32
+ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
33
+ register unsigned char *u = (unsigned char *) ptr;
34
+ register const unsigned char *eu = u + sz;
35
+ for (; u != eu; ++u) {
36
+ register char d = *(c++);
37
+ register unsigned char uu;
38
+ if ((d >= '0') && (d <= '9'))
39
+ uu = ((d - '0') << 4);
40
+ else if ((d >= 'a') && (d <= 'f'))
41
+ uu = ((d - ('a'-10)) << 4);
42
+ else
43
+ return (char *) 0;
44
+ d = *(c++);
45
+ if ((d >= '0') && (d <= '9'))
46
+ uu |= (d - '0');
47
+ else if ((d >= 'a') && (d <= 'f'))
48
+ uu |= (d - ('a'-10));
49
+ else
50
+ return (char *) 0;
51
+ *u = uu;
52
+ }
53
+ return c;
54
+ }
55
+ }
56
+
57
+ /* Primitive types */
58
+ %typemap(jni) bool, const bool & "jboolean"
59
+ %typemap(jni) char, const char & "jchar"
60
+ %typemap(jni) signed char, const signed char & "jbyte"
61
+ %typemap(jni) unsigned char, const unsigned char & "jshort"
62
+ %typemap(jni) short, const short & "jshort"
63
+ %typemap(jni) unsigned short, const unsigned short & "jint"
64
+ %typemap(jni) int, const int & "jint"
65
+ %typemap(jni) unsigned int, const unsigned int & "jlong"
66
+ %typemap(jni) long, const long & "jint"
67
+ %typemap(jni) unsigned long, const unsigned long & "jlong"
68
+ %typemap(jni) long long, const long long & "jlong"
69
+ %typemap(jni) unsigned long long, const unsigned long long & "jobject"
70
+ %typemap(jni) float, const float & "jfloat"
71
+ %typemap(jni) double, const double & "jdouble"
72
+ %typemap(jni) void "void"
73
+
74
+ %typemap(jtype) bool, const bool & "boolean"
75
+ %typemap(jtype) char, const char & "char"
76
+ %typemap(jtype) signed char, const signed char & "byte"
77
+ %typemap(jtype) unsigned char, const unsigned char & "short"
78
+ %typemap(jtype) short, const short & "short"
79
+ %typemap(jtype) unsigned short, const unsigned short & "int"
80
+ %typemap(jtype) int, const int & "int"
81
+ %typemap(jtype) unsigned int, const unsigned int & "long"
82
+ %typemap(jtype) long, const long & "int"
83
+ %typemap(jtype) unsigned long, const unsigned long & "long"
84
+ %typemap(jtype) long long, const long long & "long"
85
+ %typemap(jtype) unsigned long long, const unsigned long long & "java.math.BigInteger"
86
+ %typemap(jtype) float, const float & "float"
87
+ %typemap(jtype) double, const double & "double"
88
+ %typemap(jtype) void "void"
89
+
90
+ %typemap(jstype) bool, const bool & "boolean"
91
+ %typemap(jstype) char, const char & "char"
92
+ %typemap(jstype) signed char, const signed char & "byte"
93
+ %typemap(jstype) unsigned char, const unsigned char & "short"
94
+ %typemap(jstype) short, const short & "short"
95
+ %typemap(jstype) unsigned short, const unsigned short & "int"
96
+ %typemap(jstype) int, const int & "int"
97
+ %typemap(jstype) unsigned int, const unsigned int & "long"
98
+ %typemap(jstype) long, const long & "int"
99
+ %typemap(jstype) unsigned long, const unsigned long & "long"
100
+ %typemap(jstype) long long, const long long & "long"
101
+ %typemap(jstype) unsigned long long, const unsigned long long & "java.math.BigInteger"
102
+ %typemap(jstype) float, const float & "float"
103
+ %typemap(jstype) double, const double & "double"
104
+ %typemap(jstype) void "void"
105
+
106
+ %typemap(jni) char *, char *&, char[ANY], char[] "jstring"
107
+ %typemap(jtype) char *, char *&, char[ANY], char[] "String"
108
+ %typemap(jstype) char *, char *&, char[ANY], char[] "String"
109
+
110
+ /* JNI types */
111
+ %typemap(jni) jboolean "jboolean"
112
+ %typemap(jni) jchar "jchar"
113
+ %typemap(jni) jbyte "jbyte"
114
+ %typemap(jni) jshort "jshort"
115
+ %typemap(jni) jint "jint"
116
+ %typemap(jni) jlong "jlong"
117
+ %typemap(jni) jfloat "jfloat"
118
+ %typemap(jni) jdouble "jdouble"
119
+ %typemap(jni) jstring "jstring"
120
+ %typemap(jni) jobject "jobject"
121
+ %typemap(jni) jbooleanArray "jbooleanArray"
122
+ %typemap(jni) jcharArray "jcharArray"
123
+ %typemap(jni) jbyteArray "jbyteArray"
124
+ %typemap(jni) jshortArray "jshortArray"
125
+ %typemap(jni) jintArray "jintArray"
126
+ %typemap(jni) jlongArray "jlongArray"
127
+ %typemap(jni) jfloatArray "jfloatArray"
128
+ %typemap(jni) jdoubleArray "jdoubleArray"
129
+ %typemap(jni) jobjectArray "jobjectArray"
130
+
131
+ %typemap(jtype) jboolean "boolean"
132
+ %typemap(jtype) jchar "char"
133
+ %typemap(jtype) jbyte "byte"
134
+ %typemap(jtype) jshort "short"
135
+ %typemap(jtype) jint "int"
136
+ %typemap(jtype) jlong "long"
137
+ %typemap(jtype) jfloat "float"
138
+ %typemap(jtype) jdouble "double"
139
+ %typemap(jtype) jstring "String"
140
+ %typemap(jtype) jobject "Object"
141
+ %typemap(jtype) jbooleanArray "boolean[]"
142
+ %typemap(jtype) jcharArray "char[]"
143
+ %typemap(jtype) jbyteArray "byte[]"
144
+ %typemap(jtype) jshortArray "short[]"
145
+ %typemap(jtype) jintArray "int[]"
146
+ %typemap(jtype) jlongArray "long[]"
147
+ %typemap(jtype) jfloatArray "float[]"
148
+ %typemap(jtype) jdoubleArray "double[]"
149
+ %typemap(jtype) jobjectArray "Object[]"
150
+
151
+ %typemap(jstype) jboolean "boolean"
152
+ %typemap(jstype) jchar "char"
153
+ %typemap(jstype) jbyte "byte"
154
+ %typemap(jstype) jshort "short"
155
+ %typemap(jstype) jint "int"
156
+ %typemap(jstype) jlong "long"
157
+ %typemap(jstype) jfloat "float"
158
+ %typemap(jstype) jdouble "double"
159
+ %typemap(jstype) jstring "String"
160
+ %typemap(jstype) jobject "Object"
161
+ %typemap(jstype) jbooleanArray "boolean[]"
162
+ %typemap(jstype) jcharArray "char[]"
163
+ %typemap(jstype) jbyteArray "byte[]"
164
+ %typemap(jstype) jshortArray "short[]"
165
+ %typemap(jstype) jintArray "int[]"
166
+ %typemap(jstype) jlongArray "long[]"
167
+ %typemap(jstype) jfloatArray "float[]"
168
+ %typemap(jstype) jdoubleArray "double[]"
169
+ %typemap(jstype) jobjectArray "Object[]"
170
+
171
+ /* Non primitive types */
172
+ %typemap(jni) SWIGTYPE "jlong"
173
+ %typemap(jtype) SWIGTYPE "long"
174
+ %typemap(jstype) SWIGTYPE "$&javaclassname"
175
+
176
+ %typemap(jni) SWIGTYPE [] "jlong"
177
+ %typemap(jtype) SWIGTYPE [] "long"
178
+ %typemap(jstype) SWIGTYPE [] "$javaclassname"
179
+
180
+ %typemap(jni) SWIGTYPE * "jlong"
181
+ %typemap(jtype) SWIGTYPE * "long"
182
+ %typemap(jstype) SWIGTYPE * "$javaclassname"
183
+
184
+ %typemap(jni) SWIGTYPE & "jlong"
185
+ %typemap(jtype) SWIGTYPE & "long"
186
+ %typemap(jstype) SWIGTYPE & "$javaclassname"
187
+
188
+ /* pointer to a class member */
189
+ %typemap(jni) SWIGTYPE (CLASS::*) "jstring"
190
+ %typemap(jtype) SWIGTYPE (CLASS::*) "String"
191
+ %typemap(jstype) SWIGTYPE (CLASS::*) "$javaclassname"
192
+
193
+ /* The following are the in, out, freearg, argout typemaps. These are the JNI code generating typemaps for converting from Java to C and visa versa. */
194
+
195
+ /* primitive types */
196
+ %typemap(in) bool
197
+ %{ $1 = $input ? true : false; %}
198
+
199
+ %typemap(directorout) bool
200
+ %{ $result = $input ? true : false; %}
201
+
202
+ %typemap(javadirectorin) bool "$jniinput"
203
+ %typemap(javadirectorout) bool "$javacall"
204
+
205
+ %typemap(in) char,
206
+ signed char,
207
+ unsigned char,
208
+ short,
209
+ unsigned short,
210
+ int,
211
+ unsigned int,
212
+ long,
213
+ unsigned long,
214
+ long long,
215
+ float,
216
+ double
217
+ %{ $1 = ($1_ltype)$input; %}
218
+
219
+ %typemap(directorout) char,
220
+ signed char,
221
+ unsigned char,
222
+ short,
223
+ unsigned short,
224
+ int,
225
+ unsigned int,
226
+ long,
227
+ unsigned long,
228
+ long long,
229
+ float,
230
+ double
231
+ %{ $result = ($1_ltype)$input; %}
232
+
233
+ %typemap(directorin, descriptor="Z") bool "$input = (jboolean) $1;"
234
+ %typemap(directorin, descriptor="C") char "$input = (jint) $1;"
235
+ %typemap(directorin, descriptor="B") signed char "$input = (jbyte) $1;"
236
+ %typemap(directorin, descriptor="S") unsigned char "$input = (jshort) $1;"
237
+ %typemap(directorin, descriptor="S") short "$input = (jshort) $1;"
238
+ %typemap(directorin, descriptor="I") unsigned short "$input = (jint) $1;"
239
+ %typemap(directorin, descriptor="I") int "$input = (jint) $1;"
240
+ %typemap(directorin, descriptor="J") unsigned int "$input = (jlong) $1;"
241
+ %typemap(directorin, descriptor="I") long "$input = (jint) $1;"
242
+ %typemap(directorin, descriptor="J") unsigned long "$input = (jlong) $1;"
243
+ %typemap(directorin, descriptor="J") long long "$input = (jlong) $1;"
244
+ %typemap(directorin, descriptor="F") float "$input = (jfloat) $1;"
245
+ %typemap(directorin, descriptor="D") double "$input = (jdouble) $1;"
246
+
247
+ %typemap(javadirectorin) char,
248
+ signed char,
249
+ unsigned char,
250
+ short,
251
+ unsigned short,
252
+ int,
253
+ unsigned int,
254
+ long,
255
+ unsigned long,
256
+ long long,
257
+ float,
258
+ double
259
+ "$jniinput"
260
+
261
+ %typemap(javadirectorout) char,
262
+ signed char,
263
+ unsigned char,
264
+ short,
265
+ unsigned short,
266
+ int,
267
+ unsigned int,
268
+ long,
269
+ unsigned long,
270
+ long long,
271
+ float,
272
+ double
273
+ "$javacall"
274
+
275
+ %typemap(out) bool %{ $result = (jboolean)$1; %}
276
+ %typemap(out) char %{ $result = (jchar)$1; %}
277
+ %typemap(out) signed char %{ $result = (jbyte)$1; %}
278
+ %typemap(out) unsigned char %{ $result = (jshort)$1; %}
279
+ %typemap(out) short %{ $result = (jshort)$1; %}
280
+ %typemap(out) unsigned short %{ $result = (jint)$1; %}
281
+ %typemap(out) int %{ $result = (jint)$1; %}
282
+ %typemap(out) unsigned int %{ $result = (jlong)$1; %}
283
+ %typemap(out) long %{ $result = (jint)$1; %}
284
+ %typemap(out) unsigned long %{ $result = (jlong)$1; %}
285
+ %typemap(out) long long %{ $result = (jlong)$1; %}
286
+ %typemap(out) float %{ $result = (jfloat)$1; %}
287
+ %typemap(out) double %{ $result = (jdouble)$1; %}
288
+
289
+ /* unsigned long long */
290
+ /* Convert from BigInteger using the toByteArray member function */
291
+ %typemap(in) unsigned long long {
292
+ jclass clazz;
293
+ jmethodID mid;
294
+ jbyteArray ba;
295
+ jbyte* bae;
296
+ jsize sz;
297
+ int i;
298
+
299
+ if (!$input) {
300
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
301
+ return $null;
302
+ }
303
+ clazz = JCALL1(GetObjectClass, jenv, $input);
304
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
305
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
306
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
307
+ sz = JCALL1(GetArrayLength, jenv, ba);
308
+ $1 = 0;
309
+ for(i=0; i<sz; i++) {
310
+ $1 = ($1 << 8) | ($1_type)(unsigned char)bae[i];
311
+ }
312
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
313
+ }
314
+
315
+ %typemap(directorout) unsigned long long {
316
+ jclass clazz;
317
+ jmethodID mid;
318
+ jbyteArray ba;
319
+ jbyte* bae;
320
+ jsize sz;
321
+ int i;
322
+
323
+ if (!$input) {
324
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
325
+ return $null;
326
+ }
327
+ clazz = JCALL1(GetObjectClass, jenv, $input);
328
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
329
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
330
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
331
+ sz = JCALL1(GetArrayLength, jenv, ba);
332
+ $result = 0;
333
+ for(i=0; i<sz; i++) {
334
+ $result = ($result << 8) | ($1_type)(unsigned char)bae[i];
335
+ }
336
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
337
+ }
338
+
339
+
340
+ /* Convert to BigInteger - byte array holds number in 2's complement big endian format */
341
+ %typemap(out) unsigned long long {
342
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
343
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
344
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
345
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
346
+ jobject bigint;
347
+ int i;
348
+
349
+ bae[0] = 0;
350
+ for(i=1; i<9; i++ ) {
351
+ bae[i] = (jbyte)($1>>8*(8-i));
352
+ }
353
+
354
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
355
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
356
+ $result = bigint;
357
+ }
358
+
359
+ /* Convert to BigInteger (see out typemap) */
360
+ %typemap(directorin, descriptor="Ljava/math/BigInteger;") unsigned long long, const unsigned long long & {
361
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
362
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
363
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
364
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
365
+ jobject bigint;
366
+ int swig_i;
367
+
368
+ bae[0] = 0;
369
+ for(swig_i=1; swig_i<9; swig_i++ ) {
370
+ bae[swig_i] = (jbyte)($1>>8*(8-swig_i));
371
+ }
372
+
373
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
374
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
375
+ $input = bigint;
376
+ }
377
+
378
+ %typemap(javadirectorin) unsigned long long "$jniinput"
379
+ %typemap(javadirectorout) unsigned long long "$javacall"
380
+
381
+ /* char * - treat as String */
382
+ %typemap(in, noblock=1) char * {
383
+ $1 = 0;
384
+ if ($input) {
385
+ $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
386
+ if (!$1) return $null;
387
+ }
388
+ }
389
+
390
+ %typemap(directorout, noblock=1, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * {
391
+ $1 = 0;
392
+ if ($input) {
393
+ $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
394
+ if (!$result) return $null;
395
+ }
396
+ }
397
+
398
+ %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * {
399
+ $input = 0;
400
+ if ($1) {
401
+ $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
402
+ if (!$input) return $null;
403
+ }
404
+ }
405
+
406
+ %typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
407
+ %typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
408
+ %typemap(javadirectorin) char * "$jniinput"
409
+ %typemap(javadirectorout) char * "$javacall"
410
+
411
+ /* char *& - treat as String */
412
+ %typemap(in, noblock=1) char *& ($*1_ltype temp = 0) {
413
+ $1 = 0;
414
+ if ($input) {
415
+ temp = ($*1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
416
+ if (!temp) return $null;
417
+ }
418
+ $1 = &temp;
419
+ }
420
+ %typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); }
421
+ %typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); }
422
+
423
+ %typemap(out) void ""
424
+ %typemap(javadirectorin) void "$jniinput"
425
+ %typemap(javadirectorout) void "$javacall"
426
+ %typemap(directorin, descriptor="V") void ""
427
+
428
+ /* primitive types by reference */
429
+ %typemap(in) const bool & ($*1_ltype temp)
430
+ %{ temp = $input ? true : false;
431
+ $1 = &temp; %}
432
+
433
+ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool &
434
+ %{ static $*1_ltype temp;
435
+ temp = $input ? true : false;
436
+ $result = &temp; %}
437
+
438
+ %typemap(javadirectorin) const bool & "$jniinput"
439
+ %typemap(javadirectorout) const bool & "$javacall"
440
+
441
+ %typemap(in) const char & ($*1_ltype temp),
442
+ const signed char & ($*1_ltype temp),
443
+ const unsigned char & ($*1_ltype temp),
444
+ const short & ($*1_ltype temp),
445
+ const unsigned short & ($*1_ltype temp),
446
+ const int & ($*1_ltype temp),
447
+ const unsigned int & ($*1_ltype temp),
448
+ const long & ($*1_ltype temp),
449
+ const unsigned long & ($*1_ltype temp),
450
+ const long long & ($*1_ltype temp),
451
+ const float & ($*1_ltype temp),
452
+ const double & ($*1_ltype temp)
453
+ %{ temp = ($*1_ltype)$input;
454
+ $1 = &temp; %}
455
+
456
+ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &,
457
+ const signed char &,
458
+ const unsigned char &,
459
+ const short &,
460
+ const unsigned short &,
461
+ const int &,
462
+ const unsigned int &,
463
+ const long &,
464
+ const unsigned long &,
465
+ const long long &,
466
+ const float &,
467
+ const double &
468
+ %{ static $*1_ltype temp;
469
+ temp = ($*1_ltype)$input;
470
+ $result = &temp; %}
471
+
472
+ %typemap(directorin, descriptor="Z") const bool & "$input = (jboolean)$1;"
473
+ %typemap(directorin, descriptor="C") const char & "$input = (jchar)$1;"
474
+ %typemap(directorin, descriptor="B") const signed char & "$input = (jbyte)$1;"
475
+ %typemap(directorin, descriptor="S") const unsigned char & "$input = (jshort)$1;"
476
+ %typemap(directorin, descriptor="S") const short & "$input = (jshort)$1;"
477
+ %typemap(directorin, descriptor="I") const unsigned short & "$input = (jint)$1;"
478
+ %typemap(directorin, descriptor="I") const int & "$input = (jint)$1;"
479
+ %typemap(directorin, descriptor="J") const unsigned int & "$input = (jlong)$1;"
480
+ %typemap(directorin, descriptor="I") const long & "$input = (jint)$1;"
481
+ %typemap(directorin, descriptor="J") const unsigned long & "$input = (jlong)$1;"
482
+ %typemap(directorin, descriptor="J") const long long & "$input = (jlong)$1;"
483
+ %typemap(directorin, descriptor="F") const float & "$input = (jfloat)$1;"
484
+ %typemap(directorin, descriptor="D") const double & "$input = (jdouble)$1;"
485
+
486
+ %typemap(javadirectorin) const char & ($*1_ltype temp),
487
+ const signed char & ($*1_ltype temp),
488
+ const unsigned char & ($*1_ltype temp),
489
+ const short & ($*1_ltype temp),
490
+ const unsigned short & ($*1_ltype temp),
491
+ const int & ($*1_ltype temp),
492
+ const unsigned int & ($*1_ltype temp),
493
+ const long & ($*1_ltype temp),
494
+ const unsigned long & ($*1_ltype temp),
495
+ const long long & ($*1_ltype temp),
496
+ const float & ($*1_ltype temp),
497
+ const double & ($*1_ltype temp)
498
+ "$jniinput"
499
+
500
+ %typemap(javadirectorout) const char & ($*1_ltype temp),
501
+ const signed char & ($*1_ltype temp),
502
+ const unsigned char & ($*1_ltype temp),
503
+ const short & ($*1_ltype temp),
504
+ const unsigned short & ($*1_ltype temp),
505
+ const int & ($*1_ltype temp),
506
+ const unsigned int & ($*1_ltype temp),
507
+ const long & ($*1_ltype temp),
508
+ const unsigned long & ($*1_ltype temp),
509
+ const long long & ($*1_ltype temp),
510
+ const float & ($*1_ltype temp),
511
+ const double & ($*1_ltype temp)
512
+ "$javacall"
513
+
514
+
515
+ %typemap(out) const bool & %{ $result = (jboolean)*$1; %}
516
+ %typemap(out) const char & %{ $result = (jchar)*$1; %}
517
+ %typemap(out) const signed char & %{ $result = (jbyte)*$1; %}
518
+ %typemap(out) const unsigned char & %{ $result = (jshort)*$1; %}
519
+ %typemap(out) const short & %{ $result = (jshort)*$1; %}
520
+ %typemap(out) const unsigned short & %{ $result = (jint)*$1; %}
521
+ %typemap(out) const int & %{ $result = (jint)*$1; %}
522
+ %typemap(out) const unsigned int & %{ $result = (jlong)*$1; %}
523
+ %typemap(out) const long & %{ $result = (jint)*$1; %}
524
+ %typemap(out) const unsigned long & %{ $result = (jlong)*$1; %}
525
+ %typemap(out) const long long & %{ $result = (jlong)*$1; %}
526
+ %typemap(out) const float & %{ $result = (jfloat)*$1; %}
527
+ %typemap(out) const double & %{ $result = (jdouble)*$1; %}
528
+
529
+ /* const unsigned long long & */
530
+ /* Similar to unsigned long long */
531
+ %typemap(in) const unsigned long long & ($*1_ltype temp) {
532
+ jclass clazz;
533
+ jmethodID mid;
534
+ jbyteArray ba;
535
+ jbyte* bae;
536
+ jsize sz;
537
+ int i;
538
+
539
+ if (!$input) {
540
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
541
+ return $null;
542
+ }
543
+ clazz = JCALL1(GetObjectClass, jenv, $input);
544
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
545
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
546
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
547
+ sz = JCALL1(GetArrayLength, jenv, ba);
548
+ $1 = &temp;
549
+ temp = 0;
550
+ for(i=0; i<sz; i++) {
551
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
552
+ }
553
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
554
+ }
555
+
556
+ %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const unsigned long long & {
557
+ static $*1_ltype temp;
558
+ jclass clazz;
559
+ jmethodID mid;
560
+ jbyteArray ba;
561
+ jbyte* bae;
562
+ jsize sz;
563
+ int i;
564
+
565
+ if (!$input) {
566
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "BigInteger null");
567
+ return $null;
568
+ }
569
+ clazz = JCALL1(GetObjectClass, jenv, $input);
570
+ mid = JCALL3(GetMethodID, jenv, clazz, "toByteArray", "()[B");
571
+ ba = (jbyteArray)JCALL2(CallObjectMethod, jenv, $input, mid);
572
+ bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
573
+ sz = JCALL1(GetArrayLength, jenv, ba);
574
+ $result = &temp;
575
+ temp = 0;
576
+ for(i=0; i<sz; i++) {
577
+ temp = (temp << 8) | ($*1_ltype)(unsigned char)bae[i];
578
+ }
579
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
580
+ }
581
+
582
+ %typemap(out) const unsigned long long & {
583
+ jbyteArray ba = JCALL1(NewByteArray, jenv, 9);
584
+ jbyte* bae = JCALL2(GetByteArrayElements, jenv, ba, 0);
585
+ jclass clazz = JCALL1(FindClass, jenv, "java/math/BigInteger");
586
+ jmethodID mid = JCALL3(GetMethodID, jenv, clazz, "<init>", "([B)V");
587
+ jobject bigint;
588
+ int i;
589
+
590
+ bae[0] = 0;
591
+ for(i=1; i<9; i++ ) {
592
+ bae[i] = (jbyte)(*$1>>8*(8-i));
593
+ }
594
+
595
+ JCALL3(ReleaseByteArrayElements, jenv, ba, bae, 0);
596
+ bigint = JCALL3(NewObject, jenv, clazz, mid, ba);
597
+ $result = bigint;
598
+ }
599
+
600
+ %typemap(javadirectorin) const unsigned long long & "$jniinput"
601
+ %typemap(javadirectorout) const unsigned long long & "$javacall"
602
+
603
+ /* Default handling. Object passed by value. Convert to a pointer */
604
+ %typemap(in) SWIGTYPE ($&1_type argp)
605
+ %{ argp = *($&1_ltype*)&$input;
606
+ if (!argp) {
607
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
608
+ return $null;
609
+ }
610
+ $1 = *argp; %}
611
+
612
+ %typemap(directorout) SWIGTYPE ($&1_type argp)
613
+ %{ argp = *($&1_ltype*)&$input;
614
+ if (!argp) {
615
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
616
+ return $null;
617
+ }
618
+ $result = *argp; %}
619
+
620
+ %typemap(out) SWIGTYPE
621
+ #ifdef __cplusplus
622
+ %{ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %}
623
+ #else
624
+ {
625
+ $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
626
+ memmove($1ptr, &$1, sizeof($1_type));
627
+ *($&1_ltype*)&$result = $1ptr;
628
+ }
629
+ #endif
630
+
631
+ %typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE
632
+ %{ $input = 0;
633
+ *(($&1_ltype*)&$input) = &$1; %}
634
+ %typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)"
635
+ %typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
636
+
637
+ /* Generic pointers and references */
638
+ %typemap(in) SWIGTYPE * %{ $1 = *($&1_ltype)&$input; %}
639
+ %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) {
640
+ const char *temp = 0;
641
+ if ($input) {
642
+ temp = JCALL2(GetStringUTFChars, jenv, $input, 0);
643
+ if (!temp) return $null;
644
+ }
645
+ SWIG_UnpackData(temp, (void *)&$1, sizeof($1));
646
+ }
647
+ %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
648
+ if (!$1) {
649
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
650
+ return $null;
651
+ } %}
652
+ %typemap(out) SWIGTYPE *
653
+ %{ *($&1_ltype)&$result = $1; %}
654
+ %typemap(out, fragment="SWIG_PackData", noblock=1) SWIGTYPE (CLASS::*) {
655
+ char buf[128];
656
+ char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
657
+ *data = '\0';
658
+ $result = JCALL1(NewStringUTF, jenv, buf);
659
+ }
660
+ %typemap(out) SWIGTYPE &
661
+ %{ *($&1_ltype)&$result = $1; %}
662
+
663
+ %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
664
+ %{ $result = *($&1_ltype)&$input; %}
665
+ %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
666
+ %{ $result = *($&1_ltype)&$input; %}
667
+
668
+ %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *
669
+ %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
670
+ %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE (CLASS::*)
671
+ %{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
672
+
673
+ %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
674
+ %{ if (!$input) {
675
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Unexpected null return for type $1_type");
676
+ return $null;
677
+ }
678
+ $result = *($&1_ltype)&$input; %}
679
+ %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &
680
+ %{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
681
+
682
+ %typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)"
683
+ %typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)"
684
+ %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)"
685
+
686
+ /* Default array handling */
687
+ %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
688
+ %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %}
689
+ %typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] ""
690
+
691
+ /* char arrays - treat as String */
692
+ %typemap(in, noblock=1) char[ANY], char[] {
693
+ $1 = 0;
694
+ if ($input) {
695
+ $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
696
+ if (!$1) return $null;
697
+ }
698
+ }
699
+
700
+ %typemap(directorout, noblock=1) char[ANY], char[] {
701
+ $1 = 0;
702
+ if ($input) {
703
+ $result = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0);
704
+ if (!$result) return $null;
705
+ }
706
+ }
707
+
708
+ %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] {
709
+ $input = 0;
710
+ if ($1) {
711
+ $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
712
+ if (!$input) return $null;
713
+ }
714
+ }
715
+
716
+ %typemap(argout) char[ANY], char[] ""
717
+ %typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
718
+ %typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
719
+ %typemap(javadirectorin) char[ANY], char[] "$jniinput"
720
+ %typemap(javadirectorout) char[ANY], char[] "$javacall"
721
+
722
+ /* JNI types */
723
+ %typemap(in) jboolean,
724
+ jchar,
725
+ jbyte,
726
+ jshort,
727
+ jint,
728
+ jlong,
729
+ jfloat,
730
+ jdouble,
731
+ jstring,
732
+ jobject,
733
+ jbooleanArray,
734
+ jcharArray,
735
+ jbyteArray,
736
+ jshortArray,
737
+ jintArray,
738
+ jlongArray,
739
+ jfloatArray,
740
+ jdoubleArray,
741
+ jobjectArray
742
+ %{ $1 = $input; %}
743
+
744
+ %typemap(directorout) jboolean,
745
+ jchar,
746
+ jbyte,
747
+ jshort,
748
+ jint,
749
+ jlong,
750
+ jfloat,
751
+ jdouble,
752
+ jstring,
753
+ jobject,
754
+ jbooleanArray,
755
+ jcharArray,
756
+ jbyteArray,
757
+ jshortArray,
758
+ jintArray,
759
+ jlongArray,
760
+ jfloatArray,
761
+ jdoubleArray,
762
+ jobjectArray
763
+ %{ $result = $input; %}
764
+
765
+ %typemap(out) jboolean,
766
+ jchar,
767
+ jbyte,
768
+ jshort,
769
+ jint,
770
+ jlong,
771
+ jfloat,
772
+ jdouble,
773
+ jstring,
774
+ jobject,
775
+ jbooleanArray,
776
+ jcharArray,
777
+ jbyteArray,
778
+ jshortArray,
779
+ jintArray,
780
+ jlongArray,
781
+ jfloatArray,
782
+ jdoubleArray,
783
+ jobjectArray
784
+ %{ $result = $1; %}
785
+
786
+ %typemap(directorin,descriptor="Z") jboolean "$input = $1;"
787
+ %typemap(directorin,descriptor="C") jchar "$input = $1;"
788
+ %typemap(directorin,descriptor="B") jbyte "$input = $1;"
789
+ %typemap(directorin,descriptor="S") jshort "$input = $1;"
790
+ %typemap(directorin,descriptor="I") jint "$input = $1;"
791
+ %typemap(directorin,descriptor="J") jlong "$input = $1;"
792
+ %typemap(directorin,descriptor="F") jfloat "$input = $1;"
793
+ %typemap(directorin,descriptor="D") jdouble "$input = $1;"
794
+ %typemap(directorin,descriptor="Ljava/lang/String;") jstring "$input = $1;"
795
+ %typemap(directorin,descriptor="Ljava/lang/Object;",nouse="1") jobject "$input = $1;"
796
+ %typemap(directorin,descriptor="[Z") jbooleanArray "$input = $1;"
797
+ %typemap(directorin,descriptor="[C") jcharArray "$input = $1;"
798
+ %typemap(directorin,descriptor="[B") jbyteArray "$input = $1;"
799
+ %typemap(directorin,descriptor="[S") jshortArray "$input = $1;"
800
+ %typemap(directorin,descriptor="[I") jintArray "$input = $1;"
801
+ %typemap(directorin,descriptor="[J") jlongArray "$input = $1;"
802
+ %typemap(directorin,descriptor="[F") jfloatArray "$input = $1;"
803
+ %typemap(directorin,descriptor="[D") jdoubleArray "$input = $1;"
804
+ %typemap(directorin,descriptor="[Ljava/lang/Object;",nouse="1") jobjectArray "$input = $1;"
805
+
806
+ %typemap(javadirectorin) jboolean,
807
+ jchar,
808
+ jbyte,
809
+ jshort,
810
+ jint,
811
+ jlong,
812
+ jfloat,
813
+ jdouble,
814
+ jstring,
815
+ jobject,
816
+ jbooleanArray,
817
+ jcharArray,
818
+ jbyteArray,
819
+ jshortArray,
820
+ jintArray,
821
+ jlongArray,
822
+ jfloatArray,
823
+ jdoubleArray,
824
+ jobjectArray
825
+ "$jniinput"
826
+
827
+ %typemap(javadirectorout) jboolean,
828
+ jchar,
829
+ jbyte,
830
+ jshort,
831
+ jint,
832
+ jlong,
833
+ jfloat,
834
+ jdouble,
835
+ jstring,
836
+ jobject,
837
+ jbooleanArray,
838
+ jcharArray,
839
+ jbyteArray,
840
+ jshortArray,
841
+ jintArray,
842
+ jlongArray,
843
+ jfloatArray,
844
+ jdoubleArray,
845
+ jobjectArray
846
+ "$javacall"
847
+
848
+ /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions
849
+ * that cannot be overloaded in Java as more than one C++ type maps to a single Java type */
850
+
851
+ %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */
852
+ jboolean,
853
+ bool,
854
+ const bool &
855
+ ""
856
+
857
+ %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */
858
+ jchar,
859
+ char,
860
+ const char &
861
+ ""
862
+
863
+ %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */
864
+ jbyte,
865
+ signed char,
866
+ const signed char &
867
+ ""
868
+
869
+ %typecheck(SWIG_TYPECHECK_INT16) /* Java short */
870
+ jshort,
871
+ unsigned char,
872
+ short,
873
+ const unsigned char &,
874
+ const short &
875
+ ""
876
+
877
+ %typecheck(SWIG_TYPECHECK_INT32) /* Java int */
878
+ jint,
879
+ unsigned short,
880
+ int,
881
+ long,
882
+ const unsigned short &,
883
+ const int &,
884
+ const long &
885
+ ""
886
+
887
+ %typecheck(SWIG_TYPECHECK_INT64) /* Java long */
888
+ jlong,
889
+ unsigned int,
890
+ unsigned long,
891
+ long long,
892
+ const unsigned int &,
893
+ const unsigned long &,
894
+ const long long &
895
+ ""
896
+
897
+ %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */
898
+ unsigned long long,
899
+ const unsigned long long &
900
+ ""
901
+
902
+ %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */
903
+ jfloat,
904
+ float,
905
+ const float &
906
+ ""
907
+
908
+ %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */
909
+ jdouble,
910
+ double,
911
+ const double &
912
+ ""
913
+
914
+ %typecheck(SWIG_TYPECHECK_STRING) /* Java String */
915
+ jstring,
916
+ char *,
917
+ char *&,
918
+ char[ANY],
919
+ char []
920
+ ""
921
+
922
+ %typecheck(SWIG_TYPECHECK_BOOL_ARRAY) /* Java boolean[] */
923
+ jbooleanArray
924
+ ""
925
+
926
+ %typecheck(SWIG_TYPECHECK_CHAR_ARRAY) /* Java char[] */
927
+ jcharArray
928
+ ""
929
+
930
+ %typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */
931
+ jbyteArray
932
+ ""
933
+
934
+ %typecheck(SWIG_TYPECHECK_INT16_ARRAY) /* Java short[] */
935
+ jshortArray
936
+ ""
937
+
938
+ %typecheck(SWIG_TYPECHECK_INT32_ARRAY) /* Java int[] */
939
+ jintArray
940
+ ""
941
+
942
+ %typecheck(SWIG_TYPECHECK_INT64_ARRAY) /* Java long[] */
943
+ jlongArray
944
+ ""
945
+
946
+ %typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) /* Java float[] */
947
+ jfloatArray
948
+ ""
949
+
950
+ %typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) /* Java double[] */
951
+ jdoubleArray
952
+ ""
953
+
954
+ %typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) /* Java jobject[] */
955
+ jobjectArray
956
+ ""
957
+
958
+ %typecheck(SWIG_TYPECHECK_POINTER) /* Default */
959
+ SWIGTYPE,
960
+ SWIGTYPE *,
961
+ SWIGTYPE &,
962
+ SWIGTYPE *const&,
963
+ SWIGTYPE [],
964
+ SWIGTYPE (CLASS::*)
965
+ ""
966
+
967
+
968
+ /* Exception handling */
969
+
970
+ %typemap(throws) int,
971
+ long,
972
+ short,
973
+ unsigned int,
974
+ unsigned long,
975
+ unsigned short
976
+ %{ char error_msg[256];
977
+ sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
978
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg);
979
+ return $null; %}
980
+
981
+ %typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY]
982
+ %{ (void)$1;
983
+ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
984
+ return $null; %}
985
+
986
+ %typemap(throws) char *
987
+ %{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1);
988
+ return $null; %}
989
+
990
+
991
+ /* Typemaps for code generation in proxy classes and Java type wrapper classes */
992
+
993
+ /* The javain typemap is used for converting function parameter types from the type
994
+ * used in the proxy, module or type wrapper class to the type used in the JNI class. */
995
+ %typemap(javain) bool, const bool &,
996
+ char, const char &,
997
+ signed char, const signed char &,
998
+ unsigned char, const unsigned char &,
999
+ short, const short &,
1000
+ unsigned short, const unsigned short &,
1001
+ int, const int &,
1002
+ unsigned int, const unsigned int &,
1003
+ long, const long &,
1004
+ unsigned long, const unsigned long &,
1005
+ long long, const long long &,
1006
+ unsigned long long, const unsigned long long &,
1007
+ float, const float &,
1008
+ double, const double &
1009
+ "$javainput"
1010
+ %typemap(javain) char *, char *&, char[ANY], char[] "$javainput"
1011
+ %typemap(javain) jboolean,
1012
+ jchar,
1013
+ jbyte,
1014
+ jshort,
1015
+ jint,
1016
+ jlong,
1017
+ jfloat,
1018
+ jdouble,
1019
+ jstring,
1020
+ jobject,
1021
+ jbooleanArray,
1022
+ jcharArray,
1023
+ jbyteArray,
1024
+ jshortArray,
1025
+ jintArray,
1026
+ jlongArray,
1027
+ jfloatArray,
1028
+ jdoubleArray,
1029
+ jobjectArray
1030
+ "$javainput"
1031
+ %typemap(javain) SWIGTYPE "$&javaclassname.getCPtr($javainput)"
1032
+ %typemap(javain) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$javaclassname.getCPtr($javainput)"
1033
+ %typemap(javain) SWIGTYPE (CLASS::*) "$javaclassname.getCMemberPtr($javainput)"
1034
+
1035
+ /* The javaout typemap is used for converting function return types from the return type
1036
+ * used in the JNI class to the type returned by the proxy, module or type wrapper class. */
1037
+ %typemap(javaout) bool, const bool &,
1038
+ char, const char &,
1039
+ signed char, const signed char &,
1040
+ unsigned char, const unsigned char &,
1041
+ short, const short &,
1042
+ unsigned short, const unsigned short &,
1043
+ int, const int &,
1044
+ unsigned int, const unsigned int &,
1045
+ long, const long &,
1046
+ unsigned long, const unsigned long &,
1047
+ long long, const long long &,
1048
+ unsigned long long, const unsigned long long &,
1049
+ float, const float &,
1050
+ double, const double & {
1051
+ return $jnicall;
1052
+ }
1053
+ %typemap(javaout) char *, char *&, char[ANY], char[] {
1054
+ return $jnicall;
1055
+ }
1056
+ %typemap(javaout) jboolean,
1057
+ jchar,
1058
+ jbyte,
1059
+ jshort,
1060
+ jint,
1061
+ jlong,
1062
+ jfloat,
1063
+ jdouble,
1064
+ jstring,
1065
+ jobject,
1066
+ jbooleanArray,
1067
+ jcharArray,
1068
+ jbyteArray,
1069
+ jshortArray,
1070
+ jintArray,
1071
+ jlongArray,
1072
+ jfloatArray,
1073
+ jdoubleArray,
1074
+ jobjectArray {
1075
+ return $jnicall;
1076
+ }
1077
+ %typemap(javaout) void {
1078
+ $jnicall;
1079
+ }
1080
+ %typemap(javaout) SWIGTYPE {
1081
+ return new $&javaclassname($jnicall, true);
1082
+ }
1083
+ %typemap(javaout) SWIGTYPE & {
1084
+ return new $javaclassname($jnicall, $owner);
1085
+ }
1086
+ %typemap(javaout) SWIGTYPE *, SWIGTYPE [] {
1087
+ long cPtr = $jnicall;
1088
+ return (cPtr == 0) ? null : new $javaclassname(cPtr, $owner);
1089
+ }
1090
+ %typemap(javaout) SWIGTYPE (CLASS::*) {
1091
+ String cMemberPtr = $jnicall;
1092
+ return (cMemberPtr == null) ? null : new $javaclassname(cMemberPtr, $owner);
1093
+ }
1094
+
1095
+ /* Pointer reference typemaps */
1096
+ %typemap(jni) SWIGTYPE *const& "jlong"
1097
+ %typemap(jtype) SWIGTYPE *const& "long"
1098
+ %typemap(jstype) SWIGTYPE *const& "$*javaclassname"
1099
+ %typemap(javain) SWIGTYPE *const& "$*javaclassname.getCPtr($javainput)"
1100
+ %typemap(javaout) SWIGTYPE *const& {
1101
+ long cPtr = $jnicall;
1102
+ return (cPtr == 0) ? null : new $*javaclassname(cPtr, $owner);
1103
+ }
1104
+ %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
1105
+ %{ temp = *($1_ltype)&$input;
1106
+ $1 = ($1_ltype)&temp; %}
1107
+ %typemap(out) SWIGTYPE *const&
1108
+ %{ *($1_ltype)&$result = *$1; %}
1109
+
1110
+ /* Typemaps used for the generation of proxy and type wrapper class code */
1111
+ %typemap(javabase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
1112
+ %typemap(javaclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
1113
+ %typemap(javacode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
1114
+ %typemap(javaimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
1115
+ %typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
1116
+
1117
+ /* javabody typemaps */
1118
+
1119
+ %define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE) %enddef // legacy name
1120
+
1121
+ %define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
1122
+ // Base proxy classes
1123
+ %typemap(javabody) TYPE %{
1124
+ private long swigCPtr;
1125
+ protected boolean swigCMemOwn;
1126
+
1127
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
1128
+ swigCMemOwn = cMemoryOwn;
1129
+ swigCPtr = cPtr;
1130
+ }
1131
+
1132
+ CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
1133
+ return (obj == null) ? 0 : obj.swigCPtr;
1134
+ }
1135
+ %}
1136
+
1137
+ // Derived proxy classes
1138
+ %typemap(javabody_derived) TYPE %{
1139
+ private long swigCPtr;
1140
+
1141
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
1142
+ super($imclassname.$javaclazznameSWIGUpcast(cPtr), cMemoryOwn);
1143
+ swigCPtr = cPtr;
1144
+ }
1145
+
1146
+ CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
1147
+ return (obj == null) ? 0 : obj.swigCPtr;
1148
+ }
1149
+ %}
1150
+ %enddef
1151
+
1152
+ %define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
1153
+ // Typewrapper classes
1154
+ %typemap(javabody) TYPE *, TYPE &, TYPE [] %{
1155
+ private long swigCPtr;
1156
+
1157
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) {
1158
+ swigCPtr = cPtr;
1159
+ }
1160
+
1161
+ DEFAULTCTOR_VISIBILITY $javaclassname() {
1162
+ swigCPtr = 0;
1163
+ }
1164
+
1165
+ CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
1166
+ return (obj == null) ? 0 : obj.swigCPtr;
1167
+ }
1168
+ %}
1169
+
1170
+ %typemap(javabody) TYPE (CLASS::*) %{
1171
+ private String swigCMemberPtr;
1172
+
1173
+ PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, boolean futureUse) {
1174
+ swigCMemberPtr = cMemberPtr;
1175
+ }
1176
+
1177
+ DEFAULTCTOR_VISIBILITY $javaclassname() {
1178
+ swigCMemberPtr = null;
1179
+ }
1180
+
1181
+ CPTR_VISIBILITY static String getCMemberPtr($javaclassname obj) {
1182
+ return obj.swigCMemberPtr;
1183
+ }
1184
+ %}
1185
+ %enddef
1186
+
1187
+ /* Set the default javabody typemaps to use protected visibility.
1188
+ Use the macros to change to public if using multiple modules. */
1189
+ SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE)
1190
+ SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE)
1191
+
1192
+ %typemap(javafinalize) SWIGTYPE %{
1193
+ protected void finalize() {
1194
+ delete();
1195
+ }
1196
+ %}
1197
+
1198
+ /*
1199
+ * Java constructor typemaps:
1200
+ *
1201
+ * The javaconstruct typemap is inserted when a proxy class's constructor is generated.
1202
+ * This typemap allows control over what code is executed in the constructor as
1203
+ * well as specifying who owns the underlying C/C++ object. Normally, Java has
1204
+ * ownership and the underlying C/C++ object is deallocated when the Java object
1205
+ * is finalized (swigCMemOwn is true.) If swigCMemOwn is false, C/C++ is
1206
+ * ultimately responsible for deallocating the underlying object's memory.
1207
+ *
1208
+ * The SWIG_PROXY_CONSTRUCTOR macro defines the javaconstruct typemap for a proxy
1209
+ * class for a particular TYPENAME. OWNERSHIP is passed as the value of
1210
+ * swigCMemOwn to the pointer constructor method. WEAKREF determines which kind
1211
+ * of Java object reference will be used by the C++ director class (WeakGlobalRef
1212
+ * vs. GlobalRef.)
1213
+ *
1214
+ * The SWIG_DIRECTOR_OWNED macro sets the ownership of director-based proxy
1215
+ * classes and the weak reference flag to false, meaning that the underlying C++
1216
+ * object will be reclaimed by C++.
1217
+ */
1218
+
1219
+ %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...)
1220
+ %typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME {
1221
+ this($imcall, OWNERSHIP);$directorconnect
1222
+ }
1223
+ %enddef
1224
+
1225
+ %define SWIG_DIRECTOR_OWNED(TYPENAME...)
1226
+ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME)
1227
+ %enddef
1228
+
1229
+ // Set the default for SWIGTYPE: Java owns the C/C++ object.
1230
+ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
1231
+
1232
+ %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
1233
+ if (swigCPtr != 0) {
1234
+ if (swigCMemOwn) {
1235
+ swigCMemOwn = false;
1236
+ $jnicall;
1237
+ }
1238
+ swigCPtr = 0;
1239
+ }
1240
+ }
1241
+
1242
+ %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
1243
+ if (swigCPtr != 0) {
1244
+ if (swigCMemOwn) {
1245
+ swigCMemOwn = false;
1246
+ $jnicall;
1247
+ }
1248
+ swigCPtr = 0;
1249
+ }
1250
+ super.delete();
1251
+ }
1252
+
1253
+ %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{
1254
+ protected void $methodname() {
1255
+ swigCMemOwn = false;
1256
+ $jnicall;
1257
+ }
1258
+ %}
1259
+
1260
+ %typemap(directorowner_release, methodname="swigReleaseOwnership") SWIGTYPE %{
1261
+ public void $methodname() {
1262
+ swigCMemOwn = false;
1263
+ $jnicall;
1264
+ }
1265
+ %}
1266
+
1267
+ %typemap(directorowner_take, methodname="swigTakeOwnership") SWIGTYPE %{
1268
+ public void $methodname() {
1269
+ swigCMemOwn = true;
1270
+ $jnicall;
1271
+ }
1272
+ %}
1273
+
1274
+ /* Java specific directives */
1275
+ #define %javaconst(flag) %feature("java:const","flag")
1276
+ #define %javaconstvalue(value) %feature("java:constvalue",value)
1277
+ #define %javaenum(wrapapproach) %feature("java:enum","wrapapproach")
1278
+ #define %javamethodmodifiers %feature("java:methodmodifiers")
1279
+ #define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses)
1280
+ #define %nojavaexception %feature("except","0",throws="")
1281
+ #define %clearjavaexception %feature("except","",throws="")
1282
+
1283
+ %pragma(java) jniclassclassmodifiers="public class"
1284
+ %pragma(java) moduleclassmodifiers="public class"
1285
+
1286
+ /* Some ANSI C typemaps */
1287
+
1288
+ %apply unsigned long { size_t };
1289
+ %apply const unsigned long & { const size_t & };
1290
+
1291
+ /* Array reference typemaps */
1292
+ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
1293
+
1294
+ /* const pointers */
1295
+ %apply SWIGTYPE * { SWIGTYPE *const }
1296
+
1297
+ /* String & length */
1298
+ %typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray"
1299
+ %typemap(jtype) (char *STRING, size_t LENGTH) "byte[]"
1300
+ %typemap(jstype) (char *STRING, size_t LENGTH) "byte[]"
1301
+ %typemap(javain) (char *STRING, size_t LENGTH) "$javainput"
1302
+ %typemap(freearg) (char *STRING, size_t LENGTH) ""
1303
+ %typemap(in) (char *STRING, size_t LENGTH) {
1304
+ if ($input) {
1305
+ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
1306
+ $2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
1307
+ } else {
1308
+ $1 = 0;
1309
+ $2 = 0;
1310
+ }
1311
+ }
1312
+ %typemap(argout) (char *STRING, size_t LENGTH) {
1313
+ if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
1314
+ }
1315
+ %typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) {
1316
+ jbyteArray jb = (jenv)->NewByteArray($2);
1317
+ (jenv)->SetByteArrayRegion(jb, 0, $2, (jbyte *)$1);
1318
+ $input = jb;
1319
+ }
1320
+ %typemap(directorargout) (char *STRING, size_t LENGTH)
1321
+ %{(jenv)->GetByteArrayRegion($input, 0, $2, (jbyte *)$1); %}
1322
+ %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
1323
+
1324
+ /* java keywords */
1325
+ %include <javakw.swg>
1326
+
1327
+ // Default enum handling
1328
+ %include <enumtypesafe.swg>
1329
+