44 static bool __add__(
bool l,
bool r) {
return l |
r; }
45 static bool __sub__(
bool l,
bool r) {
return l ^
r; }
46 static bool __mul__(
bool l,
bool r) {
return l &
r; }
47 static bool __div__(
bool l,
bool r) {
return l; }
48 static bool __mod__(
bool l,
bool r) {
return false; }
60 #define VTOPERATOR_WRAP_PYTYPE_BASE(op, method, pytype, isRightVer) \
61 template <typename T> static \
62 VtArray<T> method##pytype(VtArray<T> vec, pytype obj) { \
63 size_t length = len(obj); \
64 if (length != vec.size()) { \
65 TfPyThrowValueError("Non-conforming inputs for operator " \
67 return VtArray<T>(); \
69 VtArray<T> ret(vec.size()); \
70 for (size_t i = 0; i < length; ++i) { \
71 if (!extract<T>(obj[i]).check()) \
72 TfPyThrowValueError("Element is of incorrect type."); \
74 ret[i] = _ArrayPyOpHelp<T>:: op ( \
75 (T)extract<T>(obj[i]), vec[i]); \
78 ret[i] = _ArrayPyOpHelp<T>:: op ( \
79 vec[i], (T)extract<T>(obj[i])); \
86 #define VTOPERATOR_WRAP_PYTYPE(op, method, pytype) \
87 VTOPERATOR_WRAP_PYTYPE_BASE(op, method, pytype, false)
90 #define VTOPERATOR_WRAP_PYTYPE_R(op, method, pytype) \
91 VTOPERATOR_WRAP_PYTYPE_BASE(op, method, pytype, true)
96 #define VTOPERATOR_WRAP(lmethod,rmethod) \
97 VTOPERATOR_WRAP_PYTYPE(lmethod,lmethod,tuple) \
98 VTOPERATOR_WRAP_PYTYPE(lmethod,lmethod,list) \
99 VTOPERATOR_WRAP_PYTYPE(lmethod,rmethod,tuple) \
100 VTOPERATOR_WRAP_PYTYPE(lmethod,rmethod,list)
103 #define VTOPERATOR_WRAP_NONCOMM(lmethod,rmethod) \
104 VTOPERATOR_WRAP_PYTYPE(lmethod,lmethod,tuple) \
105 VTOPERATOR_WRAP_PYTYPE(lmethod,lmethod,list) \
106 VTOPERATOR_WRAP_PYTYPE_R(lmethod,rmethod,tuple) \
107 VTOPERATOR_WRAP_PYTYPE_R(lmethod,rmethod,list)
110 #define VTOPERATOR_WRAPDECLARE_BASE(op,method,rettype) \
112 .def(self op Type()) \
113 .def(Type() op self) \
114 .def(#method,method##tuple<rettype>) \
115 .def(#method,method##list<rettype>)
117 #define VTOPERATOR_WRAPDECLARE(op,lmethod,rmethod) \
118 VTOPERATOR_WRAPDECLARE_BASE(op,lmethod,Type) \
119 .def(#rmethod,rmethod##tuple<Type>) \
120 .def(#rmethod,rmethod##list<Type>)
124 #define VTOPERATOR_WRAP_PYTYPE_BOOL_BASE(func,arg1,arg2,expr) \
125 template <typename T> static \
126 VtArray<bool> Vt##func(arg1, arg2) \
128 size_t length = len(obj); \
129 if (length != vec.size()) { \
130 TfPyThrowValueError("Non-conforming inputs for " #func); \
131 return VtArray<bool>(); \
133 VtArray<bool> ret(vec.size()); \
134 for (size_t i = 0; i < length; ++i) { \
135 if (!extract<T>(obj[i]).check()) \
136 TfPyThrowValueError("Element is of incorrect type."); \
144 #define VTOPERATOR_WRAP_PYTYPE_BOOL(func,pytype,op) \
145 VTOPERATOR_WRAP_PYTYPE_BOOL_BASE(func, \
146 VtArray<T> const &vec, pytype const &obj, \
147 (vec[i] op (T)extract<T>(obj[i])) ) \
148 VTOPERATOR_WRAP_PYTYPE_BOOL_BASE(func, \
149 pytype const &obj,VtArray<T> const &vec, \
150 ((T)extract<T>(obj[i]) op vec[i]) )
152 #define VTOPERATOR_WRAP_BOOL(func,op) \
153 VTOPERATOR_WRAP_PYTYPE_BOOL(func,list,op) \
154 VTOPERATOR_WRAP_PYTYPE_BOOL(func,tuple,op)
157 #define VTOPERATOR_WRAPDECLARE_BOOL(func) \
158 def(#func,(VtArray<bool> (*) \
159 (VtArray<Type> const &,VtArray<Type> const &)) \
161 def(#func,(VtArray<bool> (*) \
162 (Type const &,VtArray<Type> const &)) \
164 def(#func,(VtArray<bool> (*) \
165 (VtArray<Type> const &,Type const &)) \
167 def(#func,(VtArray<bool> (*) \
168 (VtArray<Type> const &,tuple const &)) \
170 def(#func,(VtArray<bool> (*) \
171 (tuple const &,VtArray<Type> const &)) \
173 def(#func,(VtArray<bool> (*) \
174 (VtArray<Type> const &,list const &)) \
176 def(#func,(VtArray<bool> (*) \
177 (list const &,VtArray<Type> const &)) \
static bool __mod__(bool l, bool r)
static bool __div__(bool l, bool r)
static T __mul__(T l, T r)
static bool __sub__(bool l, bool r)
static T __mod__(T l, T r)
static T __sub__(T l, T r)
static bool __mul__(bool l, bool r)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
static T __add__(T l, T r)
#define PXR_NAMESPACE_CLOSE_SCOPE
static T __div__(T l, T r)
static bool __add__(bool l, bool r)