40 #define VTOPERATOR_WRAP_PYTYPE_BASE(op,method,pytype,rettype,expr) \
41 template <typename T> static \
42 VtArray<rettype> method##pytype(VtArray<T> vec, pytype obj) \
44 size_t length = len(obj); \
45 if (length != vec.size()) { \
46 TfPyThrowValueError("Non-conforming inputs for operator " #op); \
47 return VtArray<T>(); \
49 VtArray<rettype> ret(vec.size()); \
50 for (size_t i = 0; i < length; ++i) { \
51 if (!extract<T>(obj[i]).check()) \
52 TfPyThrowValueError("Element is of incorrect type."); \
59 #define VTOPERATOR_WRAP_PYTYPE(op,lmethod,tuple,T) \
60 VTOPERATOR_WRAP_PYTYPE_BASE(op,lmethod,tuple,T, \
61 (vec[i] op (T)extract<T>(obj[i])) )
64 #define VTOPERATOR_WRAP_PYTYPE_R(op,lmethod,tuple,T) \
65 VTOPERATOR_WRAP_PYTYPE_BASE(op,lmethod,tuple,T, \
66 ((T)extract<T>(obj[i]) op vec[i]) )
71 #define VTOPERATOR_WRAP(op,lmethod,rmethod) \
72 VTOPERATOR_WRAP_PYTYPE(op,lmethod,tuple,T) \
73 VTOPERATOR_WRAP_PYTYPE(op,lmethod,list,T) \
74 VTOPERATOR_WRAP_PYTYPE(op,rmethod,tuple,T) \
75 VTOPERATOR_WRAP_PYTYPE(op,rmethod,list,T)
78 #define VTOPERATOR_WRAP_NONCOMM(op,lmethod,rmethod) \
79 VTOPERATOR_WRAP_PYTYPE(op,lmethod,tuple,T) \
80 VTOPERATOR_WRAP_PYTYPE(op,lmethod,list,T) \
81 VTOPERATOR_WRAP_PYTYPE_R(op,rmethod,tuple,T) \
82 VTOPERATOR_WRAP_PYTYPE_R(op,rmethod,list,T)
85 #define VTOPERATOR_WRAPDECLARE_BASE(op,method,rettype) \
87 .def(self op Type()) \
88 .def(Type() op self) \
89 .def(#method,method##tuple<rettype>) \
90 .def(#method,method##list<rettype>)
92 #define VTOPERATOR_WRAPDECLARE(op,lmethod,rmethod) \
93 VTOPERATOR_WRAPDECLARE_BASE(op,lmethod,Type) \
94 .def(#rmethod,rmethod##tuple<Type>) \
95 .def(#rmethod,rmethod##list<Type>)
99 #define VTOPERATOR_WRAP_PYTYPE_BOOL_BASE(func,arg1,arg2,expr) \
100 template <typename T> static \
101 VtArray<bool> Vt##func(arg1, arg2) \
103 size_t length = len(obj); \
104 if (length != vec.size()) { \
105 TfPyThrowValueError("Non-conforming inputs for " #func); \
106 return VtArray<bool>(); \
108 VtArray<bool> ret(vec.size()); \
109 for (size_t i = 0; i < length; ++i) { \
110 if (!extract<T>(obj[i]).check()) \
111 TfPyThrowValueError("Element is of incorrect type."); \
119 #define VTOPERATOR_WRAP_PYTYPE_BOOL(func,pytype,op) \
120 VTOPERATOR_WRAP_PYTYPE_BOOL_BASE(func, \
121 VtArray<T> const &vec, pytype const &obj, \
122 (vec[i] op (T)extract<T>(obj[i])) ) \
123 VTOPERATOR_WRAP_PYTYPE_BOOL_BASE(func, \
124 pytype const &obj,VtArray<T> const &vec, \
125 ((T)extract<T>(obj[i]) op vec[i]) )
127 #define VTOPERATOR_WRAP_BOOL(func,op) \
128 VTOPERATOR_WRAP_PYTYPE_BOOL(func,list,op) \
129 VTOPERATOR_WRAP_PYTYPE_BOOL(func,tuple,op)
132 #define VTOPERATOR_WRAPDECLARE_BOOL(func) \
133 def(#func,(VtArray<bool> (*) \
134 (VtArray<Type> const &,VtArray<Type> const &)) \
136 def(#func,(VtArray<bool> (*) \
137 (Type const &,VtArray<Type> const &)) \
139 def(#func,(VtArray<bool> (*) \
140 (VtArray<Type> const &,Type const &)) \
142 def(#func,(VtArray<bool> (*) \
143 (VtArray<Type> const &,tuple const &)) \
145 def(#func,(VtArray<bool> (*) \
146 (tuple const &,VtArray<Type> const &)) \
148 def(#func,(VtArray<bool> (*) \
149 (VtArray<Type> const &,list const &)) \
151 def(#func,(VtArray<bool> (*) \
152 (list const &,VtArray<Type> const &)) \
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE