@@ -898,17 +898,29 @@ Dec_CONTEXT_GET_ULONG(traps)
898
898
Dec_CONTEXT_GET_ULONG (status )
899
899
#endif
900
900
901
+ /*[clinic input]
902
+ @getter
903
+ _decimal.Context.rounding
904
+ [clinic start generated code]*/
905
+
901
906
static PyObject *
902
- context_getround (PyObject * self , void * Py_UNUSED (closure ))
907
+ _decimal_Context_rounding_get_impl (PyObject * self )
908
+ /*[clinic end generated code: output=d51ea72c02519e0e input=b2e141a5321a8ca5]*/
903
909
{
904
910
int i = mpd_getround (CTX (self ));
905
911
decimal_state * state = get_module_state_from_ctx (self );
906
912
907
913
return Py_NewRef (state -> round_map [i ]);
908
914
}
909
915
916
+ /*[clinic input]
917
+ @getter
918
+ _decimal.Context.capitals
919
+ [clinic start generated code]*/
920
+
910
921
static PyObject *
911
- context_getcapitals (PyObject * self , void * Py_UNUSED (closure ))
922
+ _decimal_Context_capitals_get_impl (PyObject * self )
923
+ /*[clinic end generated code: output=1fad922d399d298d input=1a3170642a406774]*/
912
924
{
913
925
return PyLong_FromLong (CtxCaps (self ));
914
926
}
@@ -1084,8 +1096,14 @@ _decimal_Context__unsafe_setemax_impl(PyObject *self, Py_ssize_t x)
1084
1096
}
1085
1097
#endif
1086
1098
1099
+ /*[clinic input]
1100
+ @setter
1101
+ _decimal.Context.rounding
1102
+ [clinic start generated code]*/
1103
+
1087
1104
static int
1088
- context_setround (PyObject * self , PyObject * value , void * Py_UNUSED (closure ))
1105
+ _decimal_Context_rounding_set_impl (PyObject * self , PyObject * value )
1106
+ /*[clinic end generated code: output=f090920a8cb03d2d input=beb560982050fb94]*/
1089
1107
{
1090
1108
mpd_context_t * ctx ;
1091
1109
int x ;
@@ -1104,8 +1122,14 @@ context_setround(PyObject *self, PyObject *value, void *Py_UNUSED(closure))
1104
1122
return 0 ;
1105
1123
}
1106
1124
1125
+ /*[clinic input]
1126
+ @setter
1127
+ _decimal.Context.capitals
1128
+ [clinic start generated code]*/
1129
+
1107
1130
static int
1108
- context_setcapitals (PyObject * self , PyObject * value , void * Py_UNUSED (closure ))
1131
+ _decimal_Context_capitals_set_impl (PyObject * self , PyObject * value )
1132
+ /*[clinic end generated code: output=3320d89e359b51d5 input=5a9ffb955d18f727]*/
1109
1133
{
1110
1134
mpd_ssize_t x ;
1111
1135
@@ -1345,7 +1369,7 @@ context_setattrs(PyObject *self, PyObject *prec, PyObject *rounding,
1345
1369
if (prec != Py_None && context_setprec (self , prec , NULL ) < 0 ) {
1346
1370
return -1 ;
1347
1371
}
1348
- if (rounding != Py_None && context_setround (self , rounding , NULL ) < 0 ) {
1372
+ if (rounding != Py_None && _decimal_Context_rounding_set (self , rounding , NULL ) < 0 ) {
1349
1373
return -1 ;
1350
1374
}
1351
1375
if (emin != Py_None && context_setemin (self , emin , NULL ) < 0 ) {
@@ -1354,7 +1378,7 @@ context_setattrs(PyObject *self, PyObject *prec, PyObject *rounding,
1354
1378
if (emax != Py_None && context_setemax (self , emax , NULL ) < 0 ) {
1355
1379
return -1 ;
1356
1380
}
1357
- if (capitals != Py_None && context_setcapitals (self , capitals , NULL ) < 0 ) {
1381
+ if (capitals != Py_None && _decimal_Context_capitals_set (self , capitals , NULL ) < 0 ) {
1358
1382
return -1 ;
1359
1383
}
1360
1384
if (clamp != Py_None && context_setclamp (self , clamp , NULL ) < 0 ) {
@@ -1759,8 +1783,8 @@ static PyGetSetDef context_getsets [] =
1759
1783
{ "prec" , context_getprec , context_setprec , NULL , NULL },
1760
1784
{ "Emax" , context_getemax , context_setemax , NULL , NULL },
1761
1785
{ "Emin" , context_getemin , context_setemin , NULL , NULL },
1762
- { "rounding" , context_getround , context_setround , NULL , NULL },
1763
- { "capitals" , context_getcapitals , context_setcapitals , NULL , NULL },
1786
+ _DECIMAL_CONTEXT_ROUNDING_GETSETDEF
1787
+ _DECIMAL_CONTEXT_CAPITALS_GETSETDEF
1764
1788
{ "clamp" , context_getclamp , context_setclamp , NULL , NULL },
1765
1789
#ifdef EXTRA_FUNCTIONALITY
1766
1790
{ "_allcr ", context_getallcr , context_setallcr , NULL , NULL },
@@ -6163,19 +6187,30 @@ _decimal_Decimal___trunc___impl(PyObject *self, PyTypeObject *cls)
6163
6187
return dec_as_long (self , context , MPD_ROUND_DOWN );
6164
6188
}
6165
6189
6166
- /* real and imag */
6190
+ /*[clinic input]
6191
+ @getter
6192
+ _decimal.Decimal.real
6193
+ [clinic start generated code]*/
6194
+
6167
6195
static PyObject *
6168
- dec_real (PyObject * self , void * Py_UNUSED (closure ))
6196
+ _decimal_Decimal_real_get_impl (PyObject * self )
6197
+ /*[clinic end generated code: output=a21e0af6b45ef7cb input=79fe3da48f0903a2]*/
6169
6198
{
6170
6199
return Py_NewRef (self );
6171
6200
}
6172
6201
6202
+ /*[clinic input]
6203
+ @getter
6204
+ _decimal.Decimal.imag
6205
+ [clinic start generated code]*/
6206
+
6173
6207
static PyObject *
6174
- dec_imag (PyObject * self , void * Py_UNUSED (closure ))
6208
+ _decimal_Decimal_imag_get_impl (PyObject * self )
6209
+ /*[clinic end generated code: output=74a3c50f9e0099f9 input=f0e73326a2ef2706]*/
6175
6210
{
6176
6211
PyObject * result ;
6177
6212
6178
- decimal_state * state = get_module_state_by_def (Py_TYPE (self ));
6213
+ decimal_state * state = get_module_state_by_def (Py_TYPE (self ));
6179
6214
result = dec_alloc (state );
6180
6215
if (result == NULL ) {
6181
6216
return NULL ;
@@ -6185,11 +6220,10 @@ dec_imag(PyObject *self, void *Py_UNUSED(closure))
6185
6220
return result ;
6186
6221
}
6187
6222
6188
-
6189
6223
static PyGetSetDef dec_getsets [] =
6190
6224
{
6191
- { "real" , dec_real , NULL , NULL , NULL },
6192
- { "imag" , dec_imag , NULL , NULL , NULL },
6225
+ _DECIMAL_DECIMAL_REAL_GETSETDEF
6226
+ _DECIMAL_DECIMAL_IMAG_GETSETDEF
6193
6227
{NULL }
6194
6228
};
6195
6229
0 commit comments