PageRenderTime 65ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Examples/java/constants/index.html

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