/trunk/Examples/test-suite/overload_extend.i
Swig | 66 lines | 53 code | 13 blank | 0 comment | 0 complexity | b4cdad9ff410fe84325ae98855e64f68 MD5 | raw file
1%module overload_extend 2 3#ifndef __cplusplus 4%{ 5#include <stdlib.h> 6%} 7 8%typemap(default) double y "$1=1000;"; 9#endif 10 11#ifdef SWIGLUA 12// lua only has one numeric type, so some overloads shadow each other creating warnings 13%warnfilter(SWIGWARN_PARSE_REDEFINED, SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test; 14#else 15%warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test; 16#endif 17 18 19 20%extend Foo { 21 int test() { return 0; } 22 int test(int x) { x = 0; return 1; } 23 int test(char *s) { s = 0; return 2; } 24#ifdef __cplusplus 25 double test(double x, double y = 1000) { return x + y; } 26#else 27 double test(double x, double y) { return x + y; } 28#endif 29}; 30 31 32%inline %{ 33struct Foo { 34 int variable; 35#ifdef __cplusplus 36 int test() { return -1; } 37#endif 38}; 39%} 40 41 42%extend Bar { 43#ifdef __cplusplus 44 Bar() { 45 return new Bar(); 46 } 47 ~Bar() { 48 delete $self; 49 } 50#else 51 Bar() { 52 return (Bar *) malloc(sizeof(Bar)); 53 } 54 ~Bar() { 55 free($self); 56 } 57#endif 58} 59 60%inline %{ 61typedef struct { 62 int variable; 63} Bar; 64%} 65 66