PageRenderTime 34ms CodeModel.GetById 27ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/java/constants/index.html

#
HTML | 52 lines | 40 code | 12 blank | 0 comment | 0 complexity | 1950dabe143cada0399149b3d7e021a7 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1<html>
 2<head>
 3<title>SWIG:Examples:java:constants</title>
 4</head>
 5
 6<body bgcolor="#ffffff">
 7
 8<tt>SWIG/Examples/java/constants/</tt>
 9<hr>
10
11<H2>Wrapping C Constants</H2>
12
13<p>
14When SWIG encounters C preprocessor macros and C declarations that look like constants,
15it creates Java constant with an identical value.  Click <a href="example.i">here</a>
16to see a SWIG interface with some constant declarations in it.
17
18
19<h2>Accessing Constants from Java</h2>
20Click <a href="../../../Doc/Manual/Java.html#constants">here</a> for the section on constants in the SWIG and Java documentation.
21<p>
22
23Click <a href="main.java">here</a> to see a Java program that prints out the values
24of the constants contained in the above file.</p>
25<h2>Key points</h2>
26<ul>
27<li>The values of preprocessor macros are converted into Java constants.
28<li>Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float).
29<li>Character constants such as 'x' are converted into Java strings.
30<li>C string literals such as "Hello World" are converted into Java strings.
31<li>Macros that are not fully defined are simply ignored.  For example:
32<blockquote>
33<pre>
34#define EXTERN extern
35</pre>
36</blockquote>
37is ignored because SWIG has no idea what type of variable this would be.
38
39<p>
40<li>Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored.
41
42<li>Certain C declarations involving 'const' are also turned into Java constants. 
43<li>The constants that appear in a SWIG interface file do not have to appear in any sort
44of matching C source file since the creation of a constant does not require linkage
45to a stored value (i.e., a value held in a C global variable or memory location).
46</ul>
47
48<hr>
49
50
51</body>
52</html>