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