@@ -567,46 +567,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
567
567
static char FigureCanvas_doc[] =
568
568
" A FigureCanvas object wraps a Cocoa NSView object.\n " ;
569
569
570
- static PyTypeObject FigureCanvasType = {
571
- PyVarObject_HEAD_INIT (NULL , 0 )
572
- " _macosx.FigureCanvas" , /* tp_name*/
573
- sizeof (FigureCanvas), /* tp_basicsize*/
574
- 0 , /* tp_itemsize*/
575
- (destructor)FigureCanvas_dealloc, /* tp_dealloc*/
576
- 0 , /* tp_print*/
577
- 0 , /* tp_getattr*/
578
- 0 , /* tp_setattr*/
579
- 0 , /* tp_compare*/
580
- (reprfunc)FigureCanvas_repr, /* tp_repr*/
581
- 0 , /* tp_as_number*/
582
- 0 , /* tp_as_sequence*/
583
- 0 , /* tp_as_mapping*/
584
- 0 , /* tp_hash */
585
- 0 , /* tp_call*/
586
- 0 , /* tp_str*/
587
- 0 , /* tp_getattro*/
588
- 0 , /* tp_setattro*/
589
- 0 , /* tp_as_buffer*/
590
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags*/
591
- FigureCanvas_doc, /* tp_doc */
592
- 0 , /* tp_traverse */
593
- 0 , /* tp_clear */
594
- 0 , /* tp_richcompare */
595
- 0 , /* tp_weaklistoffset */
596
- 0 , /* tp_iter */
597
- 0 , /* tp_iternext */
598
- FigureCanvas_methods, /* tp_methods */
599
- 0 , /* tp_members */
600
- 0 , /* tp_getset */
601
- 0 , /* tp_base */
602
- 0 , /* tp_dict */
603
- 0 , /* tp_descr_get */
604
- 0 , /* tp_descr_set */
605
- 0 , /* tp_dictoffset */
606
- (initproc)FigureCanvas_init, /* tp_init */
607
- 0 , /* tp_alloc */
608
- FigureCanvas_new, /* tp_new */
609
- };
570
+ static PyTypeObject FigureCanvasType;
610
571
611
572
typedef struct {
612
573
PyObject_HEAD
@@ -810,46 +771,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
810
771
static char FigureManager_doc[] =
811
772
" A FigureManager object wraps a Cocoa NSWindow object.\n " ;
812
773
813
- static PyTypeObject FigureManagerType = {
814
- PyVarObject_HEAD_INIT (NULL , 0 )
815
- " _macosx.FigureManager" , /* tp_name*/
816
- sizeof (FigureManager), /* tp_basicsize*/
817
- 0 , /* tp_itemsize*/
818
- (destructor)FigureManager_dealloc, /* tp_dealloc*/
819
- 0 , /* tp_print*/
820
- 0 , /* tp_getattr*/
821
- 0 , /* tp_setattr*/
822
- 0 , /* tp_compare*/
823
- (reprfunc)FigureManager_repr, /* tp_repr*/
824
- 0 , /* tp_as_number*/
825
- 0 , /* tp_as_sequence*/
826
- 0 , /* tp_as_mapping*/
827
- 0 , /* tp_hash */
828
- 0 , /* tp_call*/
829
- 0 , /* tp_str*/
830
- 0 , /* tp_getattro*/
831
- 0 , /* tp_setattro*/
832
- 0 , /* tp_as_buffer*/
833
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags*/
834
- FigureManager_doc, /* tp_doc */
835
- 0 , /* tp_traverse */
836
- 0 , /* tp_clear */
837
- 0 , /* tp_richcompare */
838
- 0 , /* tp_weaklistoffset */
839
- 0 , /* tp_iter */
840
- 0 , /* tp_iternext */
841
- FigureManager_methods, /* tp_methods */
842
- 0 , /* tp_members */
843
- 0 , /* tp_getset */
844
- 0 , /* tp_base */
845
- 0 , /* tp_dict */
846
- 0 , /* tp_descr_get */
847
- 0 , /* tp_descr_set */
848
- 0 , /* tp_dictoffset */
849
- (initproc)FigureManager_init, /* tp_init */
850
- 0 , /* tp_alloc */
851
- FigureManager_new, /* tp_new */
852
- };
774
+ static PyTypeObject FigureManagerType;
853
775
854
776
@interface NavigationToolbar2Handler : NSObject {
855
777
PyObject* toolbar;
@@ -1061,9 +983,6 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
1061
983
return PyUnicode_FromFormat (" NavigationToolbar2 object %p " , (void *)self);
1062
984
}
1063
985
1064
- static char NavigationToolbar2_doc[] =
1065
- " NavigationToolbar2\n " ;
1066
-
1067
986
static PyObject*
1068
987
NavigationToolbar2_set_message (NavigationToolbar2 *self, PyObject* args)
1069
988
{
@@ -1103,46 +1022,10 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
1103
1022
{NULL } /* Sentinel */
1104
1023
};
1105
1024
1106
- static PyTypeObject NavigationToolbar2Type = {
1107
- PyVarObject_HEAD_INIT (NULL , 0 )
1108
- " _macosx.NavigationToolbar2" , /* tp_name*/
1109
- sizeof (NavigationToolbar2), /* tp_basicsize*/
1110
- 0 , /* tp_itemsize*/
1111
- (destructor)NavigationToolbar2_dealloc, /* tp_dealloc*/
1112
- 0 , /* tp_print*/
1113
- 0 , /* tp_getattr*/
1114
- 0 , /* tp_setattr*/
1115
- 0 , /* tp_compare*/
1116
- (reprfunc)NavigationToolbar2_repr, /* tp_repr*/
1117
- 0 , /* tp_as_number*/
1118
- 0 , /* tp_as_sequence*/
1119
- 0 , /* tp_as_mapping*/
1120
- 0 , /* tp_hash */
1121
- 0 , /* tp_call*/
1122
- 0 , /* tp_str*/
1123
- 0 , /* tp_getattro*/
1124
- 0 , /* tp_setattro*/
1125
- 0 , /* tp_as_buffer*/
1126
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags*/
1127
- NavigationToolbar2_doc, /* tp_doc */
1128
- 0 , /* tp_traverse */
1129
- 0 , /* tp_clear */
1130
- 0 , /* tp_richcompare */
1131
- 0 , /* tp_weaklistoffset */
1132
- 0 , /* tp_iter */
1133
- 0 , /* tp_iternext */
1134
- NavigationToolbar2_methods, /* tp_methods */
1135
- 0 , /* tp_members */
1136
- 0 , /* tp_getset */
1137
- 0 , /* tp_base */
1138
- 0 , /* tp_dict */
1139
- 0 , /* tp_descr_get */
1140
- 0 , /* tp_descr_set */
1141
- 0 , /* tp_dictoffset */
1142
- (initproc)NavigationToolbar2_init, /* tp_init */
1143
- 0 , /* tp_alloc */
1144
- NavigationToolbar2_new, /* tp_new */
1145
- };
1025
+ static char NavigationToolbar2_doc[] =
1026
+ " NavigationToolbar2\n " ;
1027
+
1028
+ static PyTypeObject NavigationToolbar2Type;
1146
1029
1147
1030
static PyObject*
1148
1031
choose_save_file (PyObject* unused, PyObject* args)
@@ -1888,9 +1771,6 @@ - (void)flagsChanged:(NSEvent*)event
1888
1771
(void *) self, (void *)(self->timer ));
1889
1772
}
1890
1773
1891
- static char Timer_doc[] =
1892
- " A Timer object wraps a CFRunLoopTimerRef and can add it to the event loop.\n " ;
1893
-
1894
1774
static void timer_callback (CFRunLoopTimerRef timer, void * info)
1895
1775
{
1896
1776
gil_call_method (info, " _on_timer" );
@@ -1987,6 +1867,9 @@ static void context_cleanup(const void* info)
1987
1867
Py_TYPE (self)->tp_free ((PyObject*)self);
1988
1868
}
1989
1869
1870
+ static char Timer_doc[] =
1871
+ " A Timer object wraps a CFRunLoopTimerRef and can add it to the event loop.\n " ;
1872
+
1990
1873
static PyMethodDef Timer_methods[] = {
1991
1874
{" _timer_start" ,
1992
1875
(PyCFunction)Timer__timer_start,
@@ -2001,48 +1884,9 @@ static void context_cleanup(const void* info)
2001
1884
{NULL } /* Sentinel */
2002
1885
};
2003
1886
2004
- static PyTypeObject TimerType = {
2005
- PyVarObject_HEAD_INIT (NULL , 0 )
2006
- " _macosx.Timer" , /* tp_name*/
2007
- sizeof (Timer), /* tp_basicsize*/
2008
- 0 , /* tp_itemsize*/
2009
- (destructor)Timer_dealloc, /* tp_dealloc*/
2010
- 0 , /* tp_print*/
2011
- 0 , /* tp_getattr*/
2012
- 0 , /* tp_setattr*/
2013
- 0 , /* tp_compare*/
2014
- (reprfunc)Timer_repr, /* tp_repr*/
2015
- 0 , /* tp_as_number*/
2016
- 0 , /* tp_as_sequence*/
2017
- 0 , /* tp_as_mapping*/
2018
- 0 , /* tp_hash */
2019
- 0 , /* tp_call*/
2020
- 0 , /* tp_str*/
2021
- 0 , /* tp_getattro*/
2022
- 0 , /* tp_setattro*/
2023
- 0 , /* tp_as_buffer*/
2024
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags*/
2025
- Timer_doc, /* tp_doc */
2026
- 0 , /* tp_traverse */
2027
- 0 , /* tp_clear */
2028
- 0 , /* tp_richcompare */
2029
- 0 , /* tp_weaklistoffset */
2030
- 0 , /* tp_iter */
2031
- 0 , /* tp_iternext */
2032
- Timer_methods, /* tp_methods */
2033
- 0 , /* tp_members */
2034
- 0 , /* tp_getset */
2035
- 0 , /* tp_base */
2036
- 0 , /* tp_dict */
2037
- 0 , /* tp_descr_get */
2038
- 0 , /* tp_descr_set */
2039
- 0 , /* tp_dictoffset */
2040
- 0 , /* tp_init */
2041
- 0 , /* tp_alloc */
2042
- Timer_new, /* tp_new */
2043
- };
1887
+ static PyTypeObject TimerType;
2044
1888
2045
- static struct PyMethodDef methods[] = {
1889
+ static PyMethodDef methods[] = {
2046
1890
{" event_loop_is_running" ,
2047
1891
(PyCFunction)event_loop_is_running,
2048
1892
METH_NOARGS,
@@ -2077,23 +1921,56 @@ static void context_cleanup(const void* info)
2077
1921
2078
1922
PyObject* PyInit__macosx (void )
2079
1923
{
2080
- PyObject *module;
1924
+ FigureCanvasType.tp_name = " _macosx.FigureCanvas" ;
1925
+ FigureCanvasType.tp_basicsize = sizeof (FigureCanvas);
1926
+ FigureCanvasType.tp_dealloc = FigureCanvas_dealloc;
1927
+ FigureCanvasType.tp_repr = FigureCanvas_repr;
1928
+ FigureCanvasType.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
1929
+ FigureCanvasType.tp_doc = FigureCanvas_doc;
1930
+ FigureCanvasType.tp_methods = FigureCanvas_methods;
1931
+ FigureCanvasType.tp_init = FigureCanvas_init;
1932
+ FigureCanvasType.tp_new = FigureCanvas_new;
1933
+
1934
+ FigureManagerType.tp_name = " _macosx.FigureManager" ;
1935
+ FigureManagerType.tp_basicsize = sizeof (FigureManager);
1936
+ FigureManagerType.tp_dealloc = FigureManager_dealloc;
1937
+ FigureManagerType.tp_repr = FigureManager_repr;
1938
+ FigureManagerType.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
1939
+ FigureManagerType.tp_doc = FigureManager_doc;
1940
+ FigureManagerType.tp_methods = FigureManager_methods;
1941
+ FigureManagerType.tp_init = FigureManager_init;
1942
+ FigureManagerType.tp_new = FigureManager_new;
1943
+
1944
+ NavigationToolbar2Type.tp_name = " _macosx.NavigationToolbar2" ;
1945
+ NavigationToolbar2Type.tp_basicsize = sizeof (NavigationToolbar2);
1946
+ NavigationToolbar2Type.tp_dealloc = NavigationToolbar2_dealloc;
1947
+ NavigationToolbar2Type.tp_repr = NavigationToolbar2_repr;
1948
+ NavigationToolbar2Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
1949
+ NavigationToolbar2Type.tp_doc = NavigationToolbar2_doc;
1950
+ NavigationToolbar2Type.tp_methods = NavigationToolbar2_methods;
1951
+ NavigationToolbar2Type.tp_init = NavigationToolbar2_init;
1952
+ NavigationToolbar2Type.tp_new = NavigationToolbar2_new;
1953
+
1954
+ TimerType.tp_name = " _macosx.Timer" ;
1955
+ TimerType.tp_basicsize = sizeof (Timer);
1956
+ TimerType.tp_dealloc = Timer_dealloc;
1957
+ TimerType.tp_repr = Timer_repr;
1958
+ TimerType.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
1959
+ TimerType.tp_doc = Timer_doc;
1960
+ TimerType.tp_methods = Timer_methods;
1961
+ TimerType.tp_new = Timer_new;
2081
1962
2082
1963
if (PyType_Ready (&FigureCanvasType) < 0
2083
1964
|| PyType_Ready (&FigureManagerType) < 0
2084
1965
|| PyType_Ready (&NavigationToolbar2Type) < 0
2085
1966
|| PyType_Ready (&TimerType) < 0 )
2086
1967
return NULL ;
2087
1968
2088
- module = PyModule_Create (&moduledef);
1969
+ PyObject * module = PyModule_Create (&moduledef);
2089
1970
if (!module) {
2090
1971
return NULL ;
2091
1972
}
2092
1973
2093
- Py_INCREF (&FigureCanvasType);
2094
- Py_INCREF (&FigureManagerType);
2095
- Py_INCREF (&NavigationToolbar2Type);
2096
- Py_INCREF (&TimerType);
2097
1974
PyModule_AddObject (module, " FigureCanvas" , (PyObject*) &FigureCanvasType);
2098
1975
PyModule_AddObject (module, " FigureManager" , (PyObject*) &FigureManagerType);
2099
1976
PyModule_AddObject (module, " NavigationToolbar2" , (PyObject*) &NavigationToolbar2Type);
0 commit comments