|
9 | 9 |
|
10 | 10 | #include "Python.h"
|
11 | 11 |
|
| 12 | + |
| 13 | +// Used for clone_with_conv_f1 and clone_with_conv_v2 |
| 14 | +typedef struct { |
| 15 | + const char *name; |
| 16 | +} custom_t; |
| 17 | + |
| 18 | +static int |
| 19 | +custom_converter(PyObject *obj, custom_t *val) |
| 20 | +{ |
| 21 | + return 1; |
| 22 | +} |
| 23 | + |
| 24 | + |
12 | 25 | #include "clinic/_testclinic.c.h"
|
13 | 26 |
|
14 | 27 |
|
@@ -1117,6 +1130,70 @@ gh_99240_double_free_impl(PyObject *module, char *a, char *b)
|
1117 | 1130 | }
|
1118 | 1131 |
|
1119 | 1132 |
|
| 1133 | +/*[clinic input] |
| 1134 | +_testclinic.clone_f1 as clone_f1 |
| 1135 | + path: str |
| 1136 | +[clinic start generated code]*/ |
| 1137 | + |
| 1138 | +static PyObject * |
| 1139 | +clone_f1_impl(PyObject *module, const char *path) |
| 1140 | +/*[clinic end generated code: output=8c30b5620ba86715 input=9c614b7f025ebf70]*/ |
| 1141 | +{ |
| 1142 | + Py_RETURN_NONE; |
| 1143 | +} |
| 1144 | + |
| 1145 | + |
| 1146 | +/*[clinic input] |
| 1147 | +_testclinic.clone_f2 as clone_f2 = _testclinic.clone_f1 |
| 1148 | +[clinic start generated code]*/ |
| 1149 | + |
| 1150 | +static PyObject * |
| 1151 | +clone_f2_impl(PyObject *module, const char *path) |
| 1152 | +/*[clinic end generated code: output=6aa1c39bec3f5d9b input=1aaaf47d6ed2324a]*/ |
| 1153 | +{ |
| 1154 | + Py_RETURN_NONE; |
| 1155 | +} |
| 1156 | + |
| 1157 | + |
| 1158 | +/*[python input] |
| 1159 | +class custom_t_converter(CConverter): |
| 1160 | + type = 'custom_t' |
| 1161 | + converter = 'custom_converter' |
| 1162 | +
|
| 1163 | + def pre_render(self): |
| 1164 | + self.c_default = f'''{{ |
| 1165 | + .name = "{self.function.name}", |
| 1166 | + }}''' |
| 1167 | +
|
| 1168 | +[python start generated code]*/ |
| 1169 | +/*[python end generated code: output=da39a3ee5e6b4b0d input=b2fb801e99a06bf6]*/ |
| 1170 | + |
| 1171 | + |
| 1172 | +/*[clinic input] |
| 1173 | +_testclinic.clone_with_conv_f1 as clone_with_conv_f1 |
| 1174 | + path: custom_t = None |
| 1175 | +[clinic start generated code]*/ |
| 1176 | + |
| 1177 | +static PyObject * |
| 1178 | +clone_with_conv_f1_impl(PyObject *module, custom_t path) |
| 1179 | +/*[clinic end generated code: output=f7e030ffd5439cb0 input=bc77bc80dec3f46d]*/ |
| 1180 | +{ |
| 1181 | + return PyUnicode_FromString(path.name); |
| 1182 | +} |
| 1183 | + |
| 1184 | + |
| 1185 | +/*[clinic input] |
| 1186 | +_testclinic.clone_with_conv_f2 as clone_with_conv_f2 = _testclinic.clone_with_conv_f1 |
| 1187 | +[clinic start generated code]*/ |
| 1188 | + |
| 1189 | +static PyObject * |
| 1190 | +clone_with_conv_f2_impl(PyObject *module, custom_t path) |
| 1191 | +/*[clinic end generated code: output=9d7fdd6a75eecee4 input=cff459a205fa83bb]*/ |
| 1192 | +{ |
| 1193 | + return PyUnicode_FromString(path.name); |
| 1194 | +} |
| 1195 | + |
| 1196 | + |
1120 | 1197 | static PyMethodDef tester_methods[] = {
|
1121 | 1198 | TEST_EMPTY_FUNCTION_METHODDEF
|
1122 | 1199 | OBJECTS_CONVERTER_METHODDEF
|
@@ -1168,6 +1245,10 @@ static PyMethodDef tester_methods[] = {
|
1168 | 1245 | GH_32092_KW_PASS_METHODDEF
|
1169 | 1246 | GH_99233_REFCOUNT_METHODDEF
|
1170 | 1247 | GH_99240_DOUBLE_FREE_METHODDEF
|
| 1248 | + CLONE_F1_METHODDEF |
| 1249 | + CLONE_F2_METHODDEF |
| 1250 | + CLONE_WITH_CONV_F1_METHODDEF |
| 1251 | + CLONE_WITH_CONV_F2_METHODDEF |
1171 | 1252 | {NULL, NULL}
|
1172 | 1253 | };
|
1173 | 1254 |
|
|
0 commit comments