@@ -144,35 +144,9 @@ template <>
144144const std::string c2py::tp_doc<dummy_class> =
145145 R"DOC( test implementation outside of class)DOC" + std::string{" \n\n ----------\n\n " } + c2py::tp_ctor_doc<dummy_class>;
146146template <> inline constexpr auto c2py::tp_name<some_class> = " cls_basic.renamed_class" ;
147-
148- static int synth_constructor_0 (PyObject *self, PyObject *args, PyObject *kwargs) {
149- if (args and PyTuple_Check (args) and (PyTuple_Size (args) > 0 )) {
150- PyErr_SetString (PyExc_RuntimeError, (" Error in constructing some_class.\n No positional arguments allowed. Use keywords arguments" ));
151- return -1 ;
152- }
153- c2py::pydict_extractor de{kwargs};
154- try {
155- ((c2py::wrap<some_class> *)self)->_c = new some_class{};
156- } catch (std::exception const &e) {
157- PyErr_SetString (PyExc_RuntimeError, (" Error in constructing some_class from a Python dict.\n " s + e.what ()).c_str ());
158- return -1 ;
159- }
160- auto &self_c = *(((c2py::wrap<some_class> *)self)->_c );
161- de (" x" , self_c.x , true );
162- return de.check ();
163- }
164-
165- template <> constexpr initproc c2py::tp_init<some_class> = synth_constructor_0;
166-
167- template <>
168- const std::string c2py::tp_ctor_doc<some_class> = c2py::replace_tags(R"DOC( Synthesized constructor with the following keyword arguments:
169-
170- Parameters
171- ----------
172- x : {par_0}, default=0
173-
174- )DOC" ,
175- " par" , {c2py::python_typename<int >()});
147+ static auto init_2 = c2py::dispatcher_c_kw_t {c2py::c_constructor<some_class>()};
148+ template <> constexpr initproc c2py::tp_init<some_class> = c2py::pyfkw_constructor<init_2>;
149+ template <> const std::string c2py::tp_ctor_doc<some_class> = init_2.doc(R"DOC( )DOC" );
176150// renamed_method
177151static auto const fun_10 = c2py::dispatcher_f_kw_t {c2py::cmethod ([](some_class &self, int y) { return self.some_method (y); }, " self" , " y" )};
178152
@@ -186,18 +160,12 @@ PyMethodDef c2py::tp_methods<some_class>[] = {
186160};
187161
188162constexpr auto doc_member_3 = R"DOC( )DOC" ;
189- static PyObject *prop_get_dict_0 (PyObject *self, void *) {
190- auto &self_c = *(((c2py::wrap<some_class> *)self)->_c );
191- c2py::pydict dic;
192- dic[" x" ] = self_c.x ;
193- return dic.new_ref ();
194- }
195163
196164// ----- Method table ----
197165
198166template <>
199167constinit PyGetSetDef c2py::tp_getset<some_class>[] = {c2py::getsetdef_from_member<&some_class::x, some_class>(" x" , doc_member_3),
200- { " __dict__ " , (getter)prop_get_dict_0, nullptr , " " , nullptr },
168+
201169 {nullptr , nullptr , nullptr , nullptr , nullptr }};
202170
203171template <> const std::string c2py::tp_doc<some_class> = R"DOC( )DOC" + c2py::tp_ctor_doc<some_class>;
0 commit comments