PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 92 lines | 78 code | 14 blank | 0 comment | 0 complexity | 23f936023f49c2645c739822f08894ca MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // Simple tests of overloaded functions
  2. %module overload_simple
  3. #ifndef SWIG_NO_OVERLOAD
  4. %immutable Spam::type;
  5. %inline %{
  6. struct Foo {
  7. };
  8. struct Bar {
  9. };
  10. char *foo(int) {
  11. return (char*) "foo:int";
  12. }
  13. char *foo(double) {
  14. return (char*) "foo:double";
  15. }
  16. char *foo(char *) {
  17. return (char*) "foo:char *";
  18. }
  19. char *foo(Foo *) {
  20. return (char*) "foo:Foo *";
  21. }
  22. char *foo(Bar *) {
  23. return (char *) "foo:Bar *";
  24. }
  25. char *foo(void *) {
  26. return (char *) "foo:void *";
  27. }
  28. class Spam {
  29. public:
  30. Spam() { type = "none"; }
  31. Spam(int) { type = "int"; }
  32. Spam(double) { type = "double"; }
  33. Spam(char *) { type = "char *"; }
  34. Spam(Foo *) { type = "Foo *"; }
  35. Spam(Bar *) { type = "Bar *"; }
  36. Spam(void *) { type = "void *"; }
  37. const char *type;
  38. char *foo(int) {
  39. return (char*) "foo:int";
  40. }
  41. char *foo(double) {
  42. return (char*) "foo:double";
  43. }
  44. char *foo(char *) {
  45. return (char*) "foo:char *";
  46. }
  47. char *foo(Foo *) {
  48. return (char*) "foo:Foo *";
  49. }
  50. char *foo(Bar *) {
  51. return (char *) "foo:Bar *";
  52. }
  53. char *foo(void *) {
  54. return (char *) "foo:void *";
  55. }
  56. static char *bar(int) {
  57. return (char*) "bar:int";
  58. }
  59. static char *bar(double) {
  60. return (char*) "bar:double";
  61. }
  62. static char *bar(char *) {
  63. return (char*) "bar:char *";
  64. }
  65. static char *bar(Foo *) {
  66. return (char*) "bar:Foo *";
  67. }
  68. static char *bar(Bar *) {
  69. return (char *) "bar:Bar *";
  70. }
  71. static char *bar(void *) {
  72. return (char *) "bar:void *";
  73. }
  74. };
  75. %}
  76. %include cmalloc.i
  77. %malloc(void);
  78. #endif