PageRenderTime 30ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/varargs.i

#
Swig | 44 lines | 38 code | 6 blank | 0 comment | 0 complexity | 195f7b3ed56e8421b1c798cdfceca226 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. // Tests SWIG's *default* handling of varargs (function varargs, not preprocessor varargs).
  2. // The default behavior is to simply ignore the varargs.
  3. %module varargs
  4. %varargs(int mode = 0) test_def;
  5. %varargs(int mode = 0) Foo::Foo;
  6. %varargs(int mode = 0) Foo::statictest(const char*fmt, ...);
  7. %varargs(2, int mode = 0) test_plenty(const char*fmt, ...);
  8. %inline %{
  9. char *test(const char *fmt, ...) {
  10. return (char *) fmt;
  11. }
  12. const char *test_def(const char *fmt, ...) {
  13. return fmt;
  14. }
  15. class Foo {
  16. public:
  17. char *str;
  18. Foo() {
  19. str = NULL;
  20. }
  21. Foo(const char *fmt, ...) {
  22. str = new char[strlen(fmt) + 1];
  23. strcpy(str, fmt);
  24. }
  25. ~Foo() {
  26. delete [] str;
  27. }
  28. char *test(const char *fmt, ...) {
  29. return (char *) fmt;
  30. }
  31. static char *statictest(const char *fmt, ...) {
  32. return (char *) fmt;
  33. }
  34. };
  35. const char *test_plenty(const char *fmt, ...) {
  36. return fmt;
  37. }
  38. %}