PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
Swig | 44 lines | 38 code | 6 blank | 0 comment | 0 complexity | 195f7b3ed56e8421b1c798cdfceca226 MD5 | raw file
 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
 5%varargs(int mode = 0) test_def;
 6%varargs(int mode = 0) Foo::Foo;
 7%varargs(int mode = 0) Foo::statictest(const char*fmt, ...);
 8%varargs(2, int mode = 0) test_plenty(const char*fmt, ...);
 9
10%inline %{
11char *test(const char *fmt, ...) {
12  return (char *) fmt;
13}
14
15const char *test_def(const char *fmt, ...) {
16  return fmt;
17}
18
19class Foo {
20public:
21    char *str;
22    Foo() {
23        str = NULL;
24    }
25    Foo(const char *fmt, ...) {
26        str = new char[strlen(fmt) + 1];
27        strcpy(str, fmt);
28    }
29    ~Foo() {
30        delete [] str;
31    }
32    char *test(const char *fmt, ...) {
33        return (char *) fmt;
34    }
35    static char *statictest(const char *fmt, ...) {
36        return (char *) fmt;
37    }
38};
39
40const char *test_plenty(const char *fmt, ...) {
41  return fmt;
42}
43
44%}