| 46 | |
| 47 | template <class T> |
| 48 | static Box<T> * box2TupleConstructor1(const tuple &t) |
| 49 | { |
| 50 | if(t.attr("__len__")() == 2) |
| 51 | { |
| 52 | // The constructor was called like this: |
| 53 | // Box2f ((V2f(1,2), V2f(3,4))) or |
| 54 | // Box2f (((1,2), (3,4))) |
| 55 | |
| 56 | PyObject *t0Obj = extract <object> (t[0])().ptr(); |
| 57 | PyObject *t1Obj = extract <object> (t[1])().ptr(); |
| 58 | T t0, t1; |
| 59 | if (V2<typename T::BaseType>::convert (t0Obj, &t0) && |
| 60 | V2<typename T::BaseType>::convert (t1Obj, &t1)) |
| 61 | { |
| 62 | return new Box<T> (t0, t1); |
| 63 | } |
| 64 | |
| 65 | // The constructor was called like this: |
| 66 | // Box2f ((1,2)) |
| 67 | |
| 68 | else |
| 69 | { |
| 70 | T point; |
| 71 | point.x = extract<typename T::BaseType>(t[0]); |
| 72 | point.y = extract<typename T::BaseType>(t[1]); |
| 73 | return new Box<T>(point); |
| 74 | } |
| 75 | } |
| 76 | else |
| 77 | throw std::invalid_argument ( "Invalid input to Box tuple constructor"); |
| 78 | } |
| 79 | |
| 80 | template <class T> |
| 81 | static Box<T> * box2TupleConstructor2(const tuple &t0, const tuple &t1) |
nothing calls this directly
no outgoing calls
no test coverage detected