PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 44 lines | 40 code | 4 blank | 0 comment | 0 complexity | 57c125e173b847ac9e2d2da8c6de8482 MD5 | raw file
 1// Tests SWIG's *default* handling of overloading varargs (function varargs, not preprocessor varargs).
 2// The default behavior is to simply ignore the varargs.
 3%module varargs_overload
 4
 5%inline %{
 6const char *vararg_over1(const char *fmt, ...) {
 7  return fmt;
 8}
 9const char *vararg_over1(int i) {
10  static char buffer[256];
11  sprintf(buffer, "%d", i);
12  return buffer;
13}
14
15const char *vararg_over2(const char *fmt, ...) {
16  return fmt;
17}
18const char *vararg_over2(int i, double j) {
19  static char buffer[256];
20  sprintf(buffer, "%d %g", i, j);
21  return buffer;
22}
23
24const char *vararg_over3(const char *fmt, ...) {
25  return fmt;
26}
27const char *vararg_over3(int i, double j, const char *s) {
28  static char buffer[256];
29  sprintf(buffer, "%d %g %s", i, j, s);
30  return buffer;
31}
32%}
33
34%varargs(int mode = 0) vararg_over4;
35%inline %{
36const char *vararg_over4(const char *fmt, ...) {
37  return fmt;
38}
39const char *vararg_over4(int i) {
40  static char buffer[256];
41  sprintf(buffer, "%d", i);
42  return buffer;
43}
44%}