| 1 | // |
| 2 | // SWIG typemaps for STL - common utilities |
| 3 | // Luigi Ballabio |
| 4 | // Aug 3, 2002 |
| 5 | // |
| 6 | // Ruby implementation |
| 7 | |
| 8 | %include <std/std_except.i> |
| 9 | |
| 10 | %apply size_t { std::size_t }; |
| 11 | |
| 12 | %{ |
| 13 | #include <string> |
| 14 | |
| 15 | #define SWIG_FLOAT_P(x) ((TYPE(x) == T_FLOAT) || FIXNUM_P(x)) |
| 16 | |
| 17 | bool SWIG_BOOL_P(VALUE) { |
| 18 | // dummy test, RTEST should take care of everything |
| 19 | return true; |
| 20 | } |
| 21 | bool SWIG_RB2BOOL(VALUE x) { |
| 22 | return RTEST(x); |
| 23 | } |
| 24 | VALUE SWIG_BOOL2RB(bool b) { |
| 25 | return b ? Qtrue : Qfalse; |
| 26 | } |
| 27 | double SWIG_NUM2DBL(VALUE x) { |
| 28 | return (FIXNUM_P(x) ? FIX2INT(x) : NUM2DBL(x)); |
| 29 | } |
| 30 | bool SWIG_STRING_P(VALUE x) { |
| 31 | return TYPE(x) == T_STRING; |
| 32 | } |
| 33 | std::string SWIG_RB2STR(VALUE x) { |
| 34 | return std::string(StringValuePtr(x)); |
| 35 | } |
| 36 | VALUE SWIG_STR2RB(const std::string& s) { |
| 37 | return rb_str_new2(s.c_str()); |
| 38 | } |
| 39 | %} |