@@ -525,50 +525,49 @@ static CGFloat _get_device_scale(CGContextRef cr)
525
525
Py_RETURN_NONE;
526
526
}
527
527
528
- static PyMethodDef FigureCanvas_methods[] = {
529
- {" draw" ,
530
- (PyCFunction)FigureCanvas_draw,
531
- METH_NOARGS,
532
- NULL , // docstring inherited.
528
+ static PyTypeObject FigureCanvasType = {
529
+ PyVarObject_HEAD_INIT (NULL , 0 )
530
+ .tp_name = " _macosx.FigureCanvas" ,
531
+ .tp_basicsize = sizeof (FigureCanvas),
532
+ .tp_dealloc = (destructor)FigureCanvas_dealloc,
533
+ .tp_repr = (reprfunc)FigureCanvas_repr,
534
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
535
+ .tp_init = (initproc)FigureCanvas_init,
536
+ .tp_new = (newfunc)FigureCanvas_new,
537
+ .tp_doc = " A FigureCanvas object wraps a Cocoa NSView object." ,
538
+ .tp_methods = (PyMethodDef[]){
539
+ {" draw" ,
540
+ (PyCFunction)FigureCanvas_draw,
541
+ METH_NOARGS,
542
+ NULL }, // docstring inherited
543
+ {" draw_idle" ,
544
+ (PyCFunction)FigureCanvas_draw_idle,
545
+ METH_NOARGS,
546
+ NULL }, // docstring inherited
547
+ {" flush_events" ,
548
+ (PyCFunction)FigureCanvas_flush_events,
549
+ METH_NOARGS,
550
+ NULL }, // docstring inherited
551
+ {" set_rubberband" ,
552
+ (PyCFunction)FigureCanvas_set_rubberband,
553
+ METH_VARARGS,
554
+ " Specifies a new rubberband rectangle and invalidates it." },
555
+ {" remove_rubberband" ,
556
+ (PyCFunction)FigureCanvas_remove_rubberband,
557
+ METH_NOARGS,
558
+ " Removes the current rubberband rectangle." },
559
+ {" start_event_loop" ,
560
+ (PyCFunction)FigureCanvas_start_event_loop,
561
+ METH_KEYWORDS | METH_VARARGS,
562
+ NULL }, // docstring inherited
563
+ {" stop_event_loop" ,
564
+ (PyCFunction)FigureCanvas_stop_event_loop,
565
+ METH_NOARGS,
566
+ NULL }, // docstring inherited
567
+ {} // sentinel
533
568
},
534
- {" draw_idle" ,
535
- (PyCFunction)FigureCanvas_draw_idle,
536
- METH_NOARGS,
537
- NULL , // docstring inherited.
538
- },
539
- {" flush_events" ,
540
- (PyCFunction)FigureCanvas_flush_events,
541
- METH_NOARGS,
542
- NULL , // docstring inherited.
543
- },
544
- {" set_rubberband" ,
545
- (PyCFunction)FigureCanvas_set_rubberband,
546
- METH_VARARGS,
547
- " Specifies a new rubberband rectangle and invalidates it."
548
- },
549
- {" remove_rubberband" ,
550
- (PyCFunction)FigureCanvas_remove_rubberband,
551
- METH_NOARGS,
552
- " Removes the current rubberband rectangle."
553
- },
554
- {" start_event_loop" ,
555
- (PyCFunction)FigureCanvas_start_event_loop,
556
- METH_KEYWORDS | METH_VARARGS,
557
- NULL , // docstring inherited.
558
- },
559
- {" stop_event_loop" ,
560
- (PyCFunction)FigureCanvas_stop_event_loop,
561
- METH_NOARGS,
562
- NULL , // docstring inherited.
563
- },
564
- {NULL } /* Sentinel */
565
569
};
566
570
567
- static char FigureCanvas_doc[] =
568
- " A FigureCanvas object wraps a Cocoa NSView object.\n " ;
569
-
570
- static PyTypeObject FigureCanvasType;
571
-
572
571
typedef struct {
573
572
PyObject_HEAD
574
573
Window* window;
@@ -739,42 +738,38 @@ static CGFloat _get_device_scale(CGContextRef cr)
739
738
Py_RETURN_NONE;
740
739
}
741
740
742
- static PyMethodDef FigureManager_methods[] = {
743
- {" show" ,
744
- (PyCFunction)FigureManager_show,
745
- METH_NOARGS,
746
- NULL , // docstring inherited.
747
- },
748
- {" destroy" ,
749
- (PyCFunction)FigureManager_destroy,
750
- METH_NOARGS,
751
- NULL , // docstring inherited.
752
- },
753
- {" set_window_title" ,
754
- (PyCFunction)FigureManager_set_window_title,
755
- METH_VARARGS,
756
- NULL , // docstring inherited.
757
- },
758
- {" get_window_title" ,
759
- (PyCFunction)FigureManager_get_window_title,
760
- METH_NOARGS,
761
- NULL , // docstring inherited.
741
+ static PyTypeObject FigureManagerType = {
742
+ PyVarObject_HEAD_INIT (NULL , 0 )
743
+ .tp_name = " _macosx.FigureManager" ,
744
+ .tp_basicsize = sizeof (FigureManager),
745
+ .tp_dealloc = (destructor)FigureManager_dealloc,
746
+ .tp_repr = (reprfunc)FigureManager_repr,
747
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
748
+ .tp_init = (initproc)FigureManager_init,
749
+ .tp_new = (newfunc)FigureManager_new,
750
+ .tp_doc = " A FigureManager object wraps a Cocoa NSWindow object." ,
751
+ .tp_methods = (PyMethodDef[]){ // All docstrings are inherited.
752
+ {" show" ,
753
+ (PyCFunction)FigureManager_show,
754
+ METH_NOARGS},
755
+ {" destroy" ,
756
+ (PyCFunction)FigureManager_destroy,
757
+ METH_NOARGS},
758
+ {" set_window_title" ,
759
+ (PyCFunction)FigureManager_set_window_title,
760
+ METH_VARARGS},
761
+ {" get_window_title" ,
762
+ (PyCFunction)FigureManager_get_window_title,
763
+ METH_NOARGS},
764
+ {" resize" ,
765
+ (PyCFunction)FigureManager_resize,
766
+ METH_VARARGS},
767
+ {} // sentinel
762
768
},
763
- {" resize" ,
764
- (PyCFunction)FigureManager_resize,
765
- METH_VARARGS,
766
- NULL , // docstring inherited.
767
- },
768
- {NULL } /* Sentinel */
769
769
};
770
770
771
- static char FigureManager_doc[] =
772
- " A FigureManager object wraps a Cocoa NSWindow object.\n " ;
773
-
774
- static PyTypeObject FigureManagerType;
775
-
776
- @interface NavigationToolbar2Handler : NSObject {
777
- PyObject* toolbar;
771
+ @interface NavigationToolbar2Handler : NSObject
772
+ { PyObject* toolbar;
778
773
NSButton * panbutton;
779
774
NSButton * zoombutton;
780
775
}
@@ -1013,20 +1008,24 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
1013
1008
Py_RETURN_NONE;
1014
1009
}
1015
1010
1016
- static PyMethodDef NavigationToolbar2_methods[] = {
1017
- {" set_message" ,
1018
- (PyCFunction)NavigationToolbar2_set_message,
1019
- METH_VARARGS,
1020
- NULL , // docstring inherited.
1011
+ static PyTypeObject NavigationToolbar2Type = {
1012
+ PyVarObject_HEAD_INIT (NULL , 0 )
1013
+ .tp_name = " _macosx.NavigationToolbar2" ,
1014
+ .tp_basicsize = sizeof (NavigationToolbar2),
1015
+ .tp_dealloc = (destructor)NavigationToolbar2_dealloc,
1016
+ .tp_repr = (reprfunc)NavigationToolbar2_repr,
1017
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1018
+ .tp_init = (initproc)NavigationToolbar2_init,
1019
+ .tp_new = (newfunc)NavigationToolbar2_new,
1020
+ .tp_doc = " NavigationToolbar2" ,
1021
+ .tp_methods = (PyMethodDef[]){ // All docstrings are inherited.
1022
+ {" set_message" ,
1023
+ (PyCFunction)NavigationToolbar2_set_message,
1024
+ METH_VARARGS},
1025
+ {} // sentinel
1021
1026
},
1022
- {NULL } /* Sentinel */
1023
1027
};
1024
1028
1025
- static char NavigationToolbar2_doc[] =
1026
- " NavigationToolbar2\n " ;
1027
-
1028
- static PyTypeObject NavigationToolbar2Type;
1029
-
1030
1029
static PyObject*
1031
1030
choose_save_file (PyObject* unused, PyObject* args)
1032
1031
{
@@ -1867,99 +1866,56 @@ static void context_cleanup(const void* info)
1867
1866
Py_TYPE (self)->tp_free ((PyObject*)self);
1868
1867
}
1869
1868
1870
- static char Timer_doc[] =
1871
- " A Timer object wraps a CFRunLoopTimerRef and can add it to the event loop.\n " ;
1872
-
1873
- static PyMethodDef Timer_methods[] = {
1874
- {" _timer_start" ,
1875
- (PyCFunction)Timer__timer_start,
1876
- METH_VARARGS,
1877
- NULL , // docstring inherited.
1869
+ static PyTypeObject TimerType = {
1870
+ PyVarObject_HEAD_INIT (NULL , 0 )
1871
+ .tp_name = " _macosx.Timer" ,
1872
+ .tp_basicsize = sizeof (Timer),
1873
+ .tp_dealloc = (destructor)Timer_dealloc,
1874
+ .tp_repr = (reprfunc)Timer_repr,
1875
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1876
+ .tp_new = (newfunc)Timer_new,
1877
+ .tp_doc = " A Timer object wraps a CFRunLoopTimerRef and can add it to the event loop." ,
1878
+ .tp_methods = (PyMethodDef[]){ // All docstrings are inherited.
1879
+ {" _timer_start" ,
1880
+ (PyCFunction)Timer__timer_start,
1881
+ METH_VARARGS},
1882
+ {" _timer_stop" ,
1883
+ (PyCFunction)Timer__timer_stop,
1884
+ METH_NOARGS},
1885
+ {} // sentinel
1878
1886
},
1879
- {" _timer_stop" ,
1880
- (PyCFunction)Timer__timer_stop,
1881
- METH_NOARGS,
1882
- NULL , // docstring inherited.
1883
- },
1884
- {NULL } /* Sentinel */
1885
- };
1886
-
1887
- static PyTypeObject TimerType;
1888
-
1889
- static PyMethodDef methods[] = {
1890
- {" event_loop_is_running" ,
1891
- (PyCFunction)event_loop_is_running,
1892
- METH_NOARGS,
1893
- " Return whether the OSX backend has set up the NSApp main event loop."
1894
- },
1895
- {" show" ,
1896
- (PyCFunction)show,
1897
- METH_NOARGS,
1898
- " Show all the figures and enter the main loop.\n "
1899
- " \n "
1900
- " This function does not return until all Matplotlib windows are closed,\n "
1901
- " and is normally not needed in interactive sessions."
1902
- },
1903
- {" choose_save_file" ,
1904
- (PyCFunction)choose_save_file,
1905
- METH_VARARGS,
1906
- " Closes the window."
1907
- },
1908
- {" set_cursor" ,
1909
- (PyCFunction)set_cursor,
1910
- METH_VARARGS,
1911
- " Sets the active cursor."
1912
- },
1913
- {NULL , NULL , 0 , NULL } /* sentinel */
1914
1887
};
1915
1888
1916
1889
static struct PyModuleDef moduledef = {
1917
- PyModuleDef_HEAD_INIT, " _macosx" , " Mac OS X native backend" , -1 , methods
1890
+ PyModuleDef_HEAD_INIT, " _macosx" , " Mac OS X native backend" , -1 ,
1891
+ (PyMethodDef[]){
1892
+ {" event_loop_is_running" ,
1893
+ (PyCFunction)event_loop_is_running,
1894
+ METH_NOARGS,
1895
+ " Return whether the OSX backend has set up the NSApp main event loop." },
1896
+ {" show" ,
1897
+ (PyCFunction)show,
1898
+ METH_NOARGS,
1899
+ " Show all the figures and enter the main loop.\n "
1900
+ " \n "
1901
+ " This function does not return until all Matplotlib windows are closed,\n "
1902
+ " and is normally not needed in interactive sessions." },
1903
+ {" choose_save_file" ,
1904
+ (PyCFunction)choose_save_file,
1905
+ METH_VARARGS,
1906
+ " Closes the window." },
1907
+ {" set_cursor" ,
1908
+ (PyCFunction)set_cursor,
1909
+ METH_VARARGS,
1910
+ " Sets the active cursor." },
1911
+ {} /* Sentinel */
1912
+ },
1918
1913
};
1919
1914
1920
1915
#pragma GCC visibility push(default)
1921
1916
1922
1917
PyObject* PyInit__macosx (void )
1923
1918
{
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;
1962
-
1963
1919
if (PyType_Ready (&FigureCanvasType) < 0
1964
1920
|| PyType_Ready (&FigureManagerType) < 0
1965
1921
|| PyType_Ready (&NavigationToolbar2Type) < 0
0 commit comments