@@ -97,12 +97,10 @@ declare_typedesc(nb::module_& m)
9797
9898 nb::class_<TypeDesc>(m, " TypeDesc" )
9999 .def_prop_rw (
100- " basetype" ,
101- [](TypeDesc t) { return BASETYPE (t.basetype ); },
100+ " basetype" , [](TypeDesc t) { return BASETYPE (t.basetype ); },
102101 [](TypeDesc& t, BASETYPE b) { typedesc_property (t, b); })
103102 .def_prop_rw (
104- " aggregate" ,
105- [](TypeDesc t) { return AGGREGATE (t.aggregate ); },
103+ " aggregate" , [](TypeDesc t) { return AGGREGATE (t.aggregate ); },
106104 [](TypeDesc& t, AGGREGATE b) { typedesc_property (t, b); })
107105 .def_prop_rw (
108106 " vecsemantics" ,
@@ -116,33 +114,53 @@ declare_typedesc(nb::module_& m)
116114 .def (nb::init<BASETYPE, AGGREGATE, VECSEMANTICS>())
117115 .def (nb::init<BASETYPE, AGGREGATE, VECSEMANTICS, int >())
118116 .def (nb::init<const char *>())
119- .def (" c_str" , [](const TypeDesc& self) { return std::string (self.c_str ()); })
117+ .def (" c_str" ,
118+ [](const TypeDesc& self) { return std::string (self.c_str ()); })
120119 .def (" numelements" , &TypeDesc::numelements)
121120 .def (" basevalues" , &TypeDesc::basevalues)
122121 .def (" size" , &TypeDesc::size)
123122 .def (" elementtype" , &TypeDesc::elementtype)
124123 .def (" elementsize" , &TypeDesc::elementsize)
125124 .def (" basesize" , &TypeDesc::basesize)
126125 .def (" fromstring" ,
127- [](TypeDesc& t, const char * typestring) { t.fromstring (typestring); })
126+ [](TypeDesc& t, const char * typestring) {
127+ t.fromstring (typestring);
128+ })
128129 .def (" equivalent" , &TypeDesc::equivalent)
129130 .def (" unarray" , &TypeDesc::unarray)
130- .def (" is_vec2" , &TypeDesc::is_vec2)
131- .def (" is_vec3" , &TypeDesc::is_vec3)
132- .def (" is_vec4" , &TypeDesc::is_vec4)
133- .def (" is_box2" , &TypeDesc::is_box2)
134- .def (" is_box3" , &TypeDesc::is_box3)
131+ .def (" is_vec2" ,
132+ [](const TypeDesc& t, BASETYPE b = TypeDesc::FLOAT) {
133+ return t.is_vec2 (b);
134+ })
135+ .def (" is_vec3" ,
136+ [](const TypeDesc& t, BASETYPE b = TypeDesc::FLOAT) {
137+ return t.is_vec3 (b);
138+ })
139+ .def (" is_vec4" ,
140+ [](const TypeDesc& t, BASETYPE b = TypeDesc::FLOAT) {
141+ return t.is_vec4 (b);
142+ })
143+ .def (" is_box2" ,
144+ [](const TypeDesc& t, BASETYPE b = TypeDesc::FLOAT) {
145+ return t.is_box2 (b);
146+ })
147+ .def (" is_box3" ,
148+ [](const TypeDesc& t, BASETYPE b = TypeDesc::FLOAT) {
149+ return t.is_box3 (b);
150+ })
135151 .def_static (" all_types_equal" ,
136152 [](const std::vector<TypeDesc>& types) {
137153 return TypeDesc::all_types_equal (types);
138154 })
139155 .def (nb::self == nb::self)
140156 .def (nb::self != nb::self)
141157 .def (" __str__" , [](TypeDesc t) { return std::string (t.c_str ()); })
142- .def (" __repr__" ,
143- [](TypeDesc t) {
144- return Strutil::fmt::format (" <TypeDesc '{}'>" , t.c_str ());
145- });
158+ .def (" __repr__" , [](TypeDesc t) {
159+ return Strutil::fmt::format (" <TypeDesc '{}'>" , t.c_str ());
160+ });
161+
162+ nb::implicitly_convertible<BASETYPE, TypeDesc>();
163+ nb::implicitly_convertible<nb::str, TypeDesc>();
146164
147165 m.attr (" UNKNOWN" ) = nb::cast (TypeDesc::UNKNOWN);
148166 m.attr (" NONE" ) = nb::cast (TypeDesc::NONE);
0 commit comments