Skip to content

Commit a254b8c

Browse files
authored
Merge pull request #8741 from radarhere/type
2 parents 0e333bf + 422c0f6 commit a254b8c

File tree

9 files changed

+66
-404
lines changed

9 files changed

+66
-404
lines changed

src/_imaging.c

Lines changed: 18 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,102 +3769,26 @@ static PySequenceMethods image_as_sequence = {
37693769
/* type description */
37703770

37713771
static PyTypeObject Imaging_Type = {
3772-
PyVarObject_HEAD_INIT(NULL, 0) "ImagingCore", /*tp_name*/
3773-
sizeof(ImagingObject), /*tp_basicsize*/
3774-
0, /*tp_itemsize*/
3775-
/* methods */
3776-
(destructor)_dealloc, /*tp_dealloc*/
3777-
0, /*tp_vectorcall_offset*/
3778-
0, /*tp_getattr*/
3779-
0, /*tp_setattr*/
3780-
0, /*tp_as_async*/
3781-
0, /*tp_repr*/
3782-
0, /*tp_as_number*/
3783-
&image_as_sequence, /*tp_as_sequence*/
3784-
0, /*tp_as_mapping*/
3785-
0, /*tp_hash*/
3786-
0, /*tp_call*/
3787-
0, /*tp_str*/
3788-
0, /*tp_getattro*/
3789-
0, /*tp_setattro*/
3790-
0, /*tp_as_buffer*/
3791-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
3792-
0, /*tp_doc*/
3793-
0, /*tp_traverse*/
3794-
0, /*tp_clear*/
3795-
0, /*tp_richcompare*/
3796-
0, /*tp_weaklistoffset*/
3797-
0, /*tp_iter*/
3798-
0, /*tp_iternext*/
3799-
methods, /*tp_methods*/
3800-
0, /*tp_members*/
3801-
getsetters, /*tp_getset*/
3772+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingCore",
3773+
.tp_basicsize = sizeof(ImagingObject),
3774+
.tp_dealloc = (destructor)_dealloc,
3775+
.tp_as_sequence = &image_as_sequence,
3776+
.tp_methods = methods,
3777+
.tp_getset = getsetters,
38023778
};
38033779

38043780
static PyTypeObject ImagingFont_Type = {
3805-
PyVarObject_HEAD_INIT(NULL, 0) "ImagingFont", /*tp_name*/
3806-
sizeof(ImagingFontObject), /*tp_basicsize*/
3807-
0, /*tp_itemsize*/
3808-
/* methods */
3809-
(destructor)_font_dealloc, /*tp_dealloc*/
3810-
0, /*tp_vectorcall_offset*/
3811-
0, /*tp_getattr*/
3812-
0, /*tp_setattr*/
3813-
0, /*tp_as_async*/
3814-
0, /*tp_repr*/
3815-
0, /*tp_as_number*/
3816-
0, /*tp_as_sequence*/
3817-
0, /*tp_as_mapping*/
3818-
0, /*tp_hash*/
3819-
0, /*tp_call*/
3820-
0, /*tp_str*/
3821-
0, /*tp_getattro*/
3822-
0, /*tp_setattro*/
3823-
0, /*tp_as_buffer*/
3824-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
3825-
0, /*tp_doc*/
3826-
0, /*tp_traverse*/
3827-
0, /*tp_clear*/
3828-
0, /*tp_richcompare*/
3829-
0, /*tp_weaklistoffset*/
3830-
0, /*tp_iter*/
3831-
0, /*tp_iternext*/
3832-
_font_methods, /*tp_methods*/
3833-
0, /*tp_members*/
3834-
0, /*tp_getset*/
3781+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingFont",
3782+
.tp_basicsize = sizeof(ImagingFontObject),
3783+
.tp_dealloc = (destructor)_font_dealloc,
3784+
.tp_methods = _font_methods,
38353785
};
38363786

38373787
static PyTypeObject ImagingDraw_Type = {
3838-
PyVarObject_HEAD_INIT(NULL, 0) "ImagingDraw", /*tp_name*/
3839-
sizeof(ImagingDrawObject), /*tp_basicsize*/
3840-
0, /*tp_itemsize*/
3841-
/* methods */
3842-
(destructor)_draw_dealloc, /*tp_dealloc*/
3843-
0, /*tp_vectorcall_offset*/
3844-
0, /*tp_getattr*/
3845-
0, /*tp_setattr*/
3846-
0, /*tp_as_async*/
3847-
0, /*tp_repr*/
3848-
0, /*tp_as_number*/
3849-
0, /*tp_as_sequence*/
3850-
0, /*tp_as_mapping*/
3851-
0, /*tp_hash*/
3852-
0, /*tp_call*/
3853-
0, /*tp_str*/
3854-
0, /*tp_getattro*/
3855-
0, /*tp_setattro*/
3856-
0, /*tp_as_buffer*/
3857-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
3858-
0, /*tp_doc*/
3859-
0, /*tp_traverse*/
3860-
0, /*tp_clear*/
3861-
0, /*tp_richcompare*/
3862-
0, /*tp_weaklistoffset*/
3863-
0, /*tp_iter*/
3864-
0, /*tp_iternext*/
3865-
_draw_methods, /*tp_methods*/
3866-
0, /*tp_members*/
3867-
0, /*tp_getset*/
3788+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingDraw",
3789+
.tp_basicsize = sizeof(ImagingDrawObject),
3790+
.tp_dealloc = (destructor)_draw_dealloc,
3791+
.tp_methods = _draw_methods,
38683792
};
38693793

38703794
static PyMappingMethods pixel_access_as_mapping = {
@@ -3876,20 +3800,10 @@ static PyMappingMethods pixel_access_as_mapping = {
38763800
/* type description */
38773801

38783802
static PyTypeObject PixelAccess_Type = {
3879-
PyVarObject_HEAD_INIT(NULL, 0) "PixelAccess", /*tp_name*/
3880-
sizeof(PixelAccessObject), /*tp_basicsize*/
3881-
0, /*tp_itemsize*/
3882-
/* methods */
3883-
(destructor)pixel_access_dealloc, /*tp_dealloc*/
3884-
0, /*tp_vectorcall_offset*/
3885-
0, /*tp_getattr*/
3886-
0, /*tp_setattr*/
3887-
0, /*tp_as_async*/
3888-
0, /*tp_repr*/
3889-
0, /*tp_as_number*/
3890-
0, /*tp_as_sequence*/
3891-
&pixel_access_as_mapping, /*tp_as_mapping*/
3892-
0 /*tp_hash*/
3803+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "PixelAccess",
3804+
.tp_basicsize = sizeof(PixelAccessObject),
3805+
.tp_dealloc = (destructor)pixel_access_dealloc,
3806+
.tp_as_mapping = &pixel_access_as_mapping,
38933807
};
38943808

38953809
/* -------------------------------------------------------------------- */

src/_imagingcms.c

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,73 +1410,22 @@ static struct PyGetSetDef cms_profile_getsetters[] = {
14101410
};
14111411

14121412
static PyTypeObject CmsProfile_Type = {
1413-
PyVarObject_HEAD_INIT(NULL, 0) "PIL.ImageCms.core.CmsProfile", /*tp_name*/
1414-
sizeof(CmsProfileObject), /*tp_basicsize*/
1415-
0, /*tp_itemsize*/
1416-
/* methods */
1417-
(destructor)cms_profile_dealloc, /*tp_dealloc*/
1418-
0, /*tp_vectorcall_offset*/
1419-
0, /*tp_getattr*/
1420-
0, /*tp_setattr*/
1421-
0, /*tp_as_async*/
1422-
0, /*tp_repr*/
1423-
0, /*tp_as_number*/
1424-
0, /*tp_as_sequence*/
1425-
0, /*tp_as_mapping*/
1426-
0, /*tp_hash*/
1427-
0, /*tp_call*/
1428-
0, /*tp_str*/
1429-
0, /*tp_getattro*/
1430-
0, /*tp_setattro*/
1431-
0, /*tp_as_buffer*/
1432-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1433-
0, /*tp_doc*/
1434-
0, /*tp_traverse*/
1435-
0, /*tp_clear*/
1436-
0, /*tp_richcompare*/
1437-
0, /*tp_weaklistoffset*/
1438-
0, /*tp_iter*/
1439-
0, /*tp_iternext*/
1440-
cms_profile_methods, /*tp_methods*/
1441-
0, /*tp_members*/
1442-
cms_profile_getsetters, /*tp_getset*/
1413+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "PIL.ImageCms.core.CmsProfile",
1414+
.tp_basicsize = sizeof(CmsProfileObject),
1415+
.tp_dealloc = (destructor)cms_profile_dealloc,
1416+
.tp_methods = cms_profile_methods,
1417+
.tp_getset = cms_profile_getsetters,
14431418
};
14441419

14451420
static struct PyMethodDef cms_transform_methods[] = {
14461421
{"apply", (PyCFunction)cms_transform_apply, 1}, {NULL, NULL} /* sentinel */
14471422
};
14481423

14491424
static PyTypeObject CmsTransform_Type = {
1450-
PyVarObject_HEAD_INIT(NULL, 0) "PIL.ImageCms.core.CmsTransform", /*tp_name*/
1451-
sizeof(CmsTransformObject), /*tp_basicsize*/
1452-
0, /*tp_itemsize*/
1453-
/* methods */
1454-
(destructor)cms_transform_dealloc, /*tp_dealloc*/
1455-
0, /*tp_vectorcall_offset*/
1456-
0, /*tp_getattr*/
1457-
0, /*tp_setattr*/
1458-
0, /*tp_as_async*/
1459-
0, /*tp_repr*/
1460-
0, /*tp_as_number*/
1461-
0, /*tp_as_sequence*/
1462-
0, /*tp_as_mapping*/
1463-
0, /*tp_hash*/
1464-
0, /*tp_call*/
1465-
0, /*tp_str*/
1466-
0, /*tp_getattro*/
1467-
0, /*tp_setattro*/
1468-
0, /*tp_as_buffer*/
1469-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1470-
0, /*tp_doc*/
1471-
0, /*tp_traverse*/
1472-
0, /*tp_clear*/
1473-
0, /*tp_richcompare*/
1474-
0, /*tp_weaklistoffset*/
1475-
0, /*tp_iter*/
1476-
0, /*tp_iternext*/
1477-
cms_transform_methods, /*tp_methods*/
1478-
0, /*tp_members*/
1479-
0, /*tp_getset*/
1425+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "PIL.ImageCms.core.CmsTransform",
1426+
.tp_basicsize = sizeof(CmsTransformObject),
1427+
.tp_dealloc = (destructor)cms_transform_dealloc,
1428+
.tp_methods = cms_transform_methods,
14801429
};
14811430

14821431
static int

src/_imagingft.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,36 +1518,11 @@ static struct PyGetSetDef font_getsetters[] = {
15181518
};
15191519

15201520
static PyTypeObject Font_Type = {
1521-
PyVarObject_HEAD_INIT(NULL, 0) "Font", /*tp_name*/
1522-
sizeof(FontObject), /*tp_basicsize*/
1523-
0, /*tp_itemsize*/
1524-
/* methods */
1525-
(destructor)font_dealloc, /*tp_dealloc*/
1526-
0, /*tp_vectorcall_offset*/
1527-
0, /*tp_getattr*/
1528-
0, /*tp_setattr*/
1529-
0, /*tp_as_async*/
1530-
0, /*tp_repr*/
1531-
0, /*tp_as_number*/
1532-
0, /*tp_as_sequence*/
1533-
0, /*tp_as_mapping*/
1534-
0, /*tp_hash*/
1535-
0, /*tp_call*/
1536-
0, /*tp_str*/
1537-
0, /*tp_getattro*/
1538-
0, /*tp_setattro*/
1539-
0, /*tp_as_buffer*/
1540-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
1541-
0, /*tp_doc*/
1542-
0, /*tp_traverse*/
1543-
0, /*tp_clear*/
1544-
0, /*tp_richcompare*/
1545-
0, /*tp_weaklistoffset*/
1546-
0, /*tp_iter*/
1547-
0, /*tp_iternext*/
1548-
font_methods, /*tp_methods*/
1549-
0, /*tp_members*/
1550-
font_getsetters, /*tp_getset*/
1521+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "Font",
1522+
.tp_basicsize = sizeof(FontObject),
1523+
.tp_dealloc = (destructor)font_dealloc,
1524+
.tp_methods = font_methods,
1525+
.tp_getset = font_getsetters,
15511526
};
15521527

15531528
static PyMethodDef _functions[] = {

src/_webp.c

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -530,36 +530,10 @@ static struct PyMethodDef _anim_encoder_methods[] = {
530530

531531
// WebPAnimEncoder type definition
532532
static PyTypeObject WebPAnimEncoder_Type = {
533-
PyVarObject_HEAD_INIT(NULL, 0) "WebPAnimEncoder", /*tp_name */
534-
sizeof(WebPAnimEncoderObject), /*tp_basicsize */
535-
0, /*tp_itemsize */
536-
/* methods */
537-
(destructor)_anim_encoder_dealloc, /*tp_dealloc*/
538-
0, /*tp_vectorcall_offset*/
539-
0, /*tp_getattr*/
540-
0, /*tp_setattr*/
541-
0, /*tp_as_async*/
542-
0, /*tp_repr*/
543-
0, /*tp_as_number*/
544-
0, /*tp_as_sequence*/
545-
0, /*tp_as_mapping*/
546-
0, /*tp_hash*/
547-
0, /*tp_call*/
548-
0, /*tp_str*/
549-
0, /*tp_getattro*/
550-
0, /*tp_setattro*/
551-
0, /*tp_as_buffer*/
552-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
553-
0, /*tp_doc*/
554-
0, /*tp_traverse*/
555-
0, /*tp_clear*/
556-
0, /*tp_richcompare*/
557-
0, /*tp_weaklistoffset*/
558-
0, /*tp_iter*/
559-
0, /*tp_iternext*/
560-
_anim_encoder_methods, /*tp_methods*/
561-
0, /*tp_members*/
562-
0, /*tp_getset*/
533+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "WebPAnimEncoder",
534+
.tp_basicsize = sizeof(WebPAnimEncoderObject),
535+
.tp_dealloc = (destructor)_anim_encoder_dealloc,
536+
.tp_methods = _anim_encoder_methods,
563537
};
564538

565539
// WebPAnimDecoder methods
@@ -573,36 +547,10 @@ static struct PyMethodDef _anim_decoder_methods[] = {
573547

574548
// WebPAnimDecoder type definition
575549
static PyTypeObject WebPAnimDecoder_Type = {
576-
PyVarObject_HEAD_INIT(NULL, 0) "WebPAnimDecoder", /*tp_name */
577-
sizeof(WebPAnimDecoderObject), /*tp_basicsize */
578-
0, /*tp_itemsize */
579-
/* methods */
580-
(destructor)_anim_decoder_dealloc, /*tp_dealloc*/
581-
0, /*tp_vectorcall_offset*/
582-
0, /*tp_getattr*/
583-
0, /*tp_setattr*/
584-
0, /*tp_as_async*/
585-
0, /*tp_repr*/
586-
0, /*tp_as_number*/
587-
0, /*tp_as_sequence*/
588-
0, /*tp_as_mapping*/
589-
0, /*tp_hash*/
590-
0, /*tp_call*/
591-
0, /*tp_str*/
592-
0, /*tp_getattro*/
593-
0, /*tp_setattro*/
594-
0, /*tp_as_buffer*/
595-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
596-
0, /*tp_doc*/
597-
0, /*tp_traverse*/
598-
0, /*tp_clear*/
599-
0, /*tp_richcompare*/
600-
0, /*tp_weaklistoffset*/
601-
0, /*tp_iter*/
602-
0, /*tp_iternext*/
603-
_anim_decoder_methods, /*tp_methods*/
604-
0, /*tp_members*/
605-
0, /*tp_getset*/
550+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "WebPAnimDecoder",
551+
.tp_basicsize = sizeof(WebPAnimDecoderObject),
552+
.tp_dealloc = (destructor)_anim_decoder_dealloc,
553+
.tp_methods = _anim_decoder_methods,
606554
};
607555

608556
/* -------------------------------------------------------------------- */

src/decode.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -256,36 +256,11 @@ static struct PyGetSetDef getseters[] = {
256256
};
257257

258258
static PyTypeObject ImagingDecoderType = {
259-
PyVarObject_HEAD_INIT(NULL, 0) "ImagingDecoder", /*tp_name*/
260-
sizeof(ImagingDecoderObject), /*tp_basicsize*/
261-
0, /*tp_itemsize*/
262-
/* methods */
263-
(destructor)_dealloc, /*tp_dealloc*/
264-
0, /*tp_vectorcall_offset*/
265-
0, /*tp_getattr*/
266-
0, /*tp_setattr*/
267-
0, /*tp_as_async*/
268-
0, /*tp_repr*/
269-
0, /*tp_as_number*/
270-
0, /*tp_as_sequence*/
271-
0, /*tp_as_mapping*/
272-
0, /*tp_hash*/
273-
0, /*tp_call*/
274-
0, /*tp_str*/
275-
0, /*tp_getattro*/
276-
0, /*tp_setattro*/
277-
0, /*tp_as_buffer*/
278-
Py_TPFLAGS_DEFAULT, /*tp_flags*/
279-
0, /*tp_doc*/
280-
0, /*tp_traverse*/
281-
0, /*tp_clear*/
282-
0, /*tp_richcompare*/
283-
0, /*tp_weaklistoffset*/
284-
0, /*tp_iter*/
285-
0, /*tp_iternext*/
286-
methods, /*tp_methods*/
287-
0, /*tp_members*/
288-
getseters, /*tp_getset*/
259+
PyVarObject_HEAD_INIT(NULL, 0).tp_name = "ImagingDecoder",
260+
.tp_basicsize = sizeof(ImagingDecoderObject),
261+
.tp_dealloc = (destructor)_dealloc,
262+
.tp_methods = methods,
263+
.tp_getset = getseters,
289264
};
290265

291266
/* -------------------------------------------------------------------- */

0 commit comments

Comments
 (0)