PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-15/SWIG/Examples/test-suite/java_typemaps_typewrapper.i

#
Swig | 57 lines | 43 code | 13 blank | 1 comment | 0 complexity | b2690b733e78c75a7008dd09a58a0ca0 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* Contrived example to test the Java specific directives on the type wrapper classes */
  2. %module java_typemaps_typewrapper
  3. %typemap(javaimports) SWIGTYPE * "import java.math.*;";
  4. %typemap(javacode) Farewell * %{
  5. public static $javaclassname CreateNullPointer() {
  6. return new $javaclassname();
  7. }
  8. public void saybye(BigDecimal num_times) {
  9. // BigDecimal requires the java.math library
  10. }
  11. %}
  12. %typemap(javaclassmodifiers) Farewell * "public final";
  13. %typemap(javaimports) Greeting * %{
  14. import java.util.*; // for EventListener
  15. import java.lang.*; // for Exception
  16. %};
  17. %typemap(javabase) Greeting * "Exception";
  18. %typemap(javainterfaces) Greeting * "EventListener";
  19. %typemap(javacode) Greeting * %{
  20. // Pure Java code generated using %typemap(javacode)
  21. public static $javaclassname CreateNullPointer() {
  22. return new $javaclassname();
  23. }
  24. public void sayhello() {
  25. $javaclassname.cheerio(new $javaclassname());
  26. }
  27. public static void cheerio(EventListener e) {
  28. }
  29. %}
  30. // Create a new getCPtr() function which takes Java null
  31. %typemap(javagetcptr) Farewell * %{
  32. public static long getCPtr($javaclassname obj) {
  33. return (obj == null) ? 0 : obj.swigCPtr;
  34. }
  35. %}
  36. // Make the pointer constructor public
  37. %typemap(javaptrconstructormodifiers) Farewell * "public";
  38. %{
  39. class Greeting {};
  40. class Farewell {};
  41. %}
  42. %inline %{
  43. Greeting* solong(Farewell* f) { return NULL; }
  44. %}