@@ -187,6 +187,8 @@ get_cursesmodule_state_by_win(PyCursesWindowObject *win)
187
187
return get_cursesmodule_state_by_cls (Py_TYPE (win ));
188
188
}
189
189
190
+ #define _PyCursesWindowObject_CAST (op ) ((PyCursesWindowObject *)(op))
191
+
190
192
/*[clinic input]
191
193
module _curses
192
194
class _curses.window "PyCursesWindowObject *" "clinic_state()->window_type"
@@ -654,53 +656,80 @@ class component_converter(CConverter):
654
656
PARSESTR - format string for argument parsing
655
657
*/
656
658
657
- #define Window_NoArgNoReturnFunction (X ) \
658
- static PyObject *PyCursesWindow_ ## X \
659
- (PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) \
660
- { return PyCursesCheckERR_ForWin(self, X(self->win), # X); }
659
+ #define Window_NoArgNoReturnFunction (X ) \
660
+ static PyObject *PyCursesWindow_ ## X \
661
+ (PyObject *op, PyObject *Py_UNUSED(ignored)) \
662
+ { \
663
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
664
+ int code = X(self->win); \
665
+ return PyCursesCheckERR_ForWin(self, code, # X); \
666
+ }
661
667
662
668
#define Window_NoArgTrueFalseFunction (X ) \
663
669
static PyObject * PyCursesWindow_ ## X \
664
- (PyCursesWindowObject *self , PyObject *Py_UNUSED(ignored)) \
670
+ (PyObject *op , PyObject *Py_UNUSED(ignored)) \
665
671
{ \
666
- return PyBool_FromLong(X(self->win)); }
672
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
673
+ return PyBool_FromLong(X(self->win)); \
674
+ }
667
675
668
- #define Window_NoArgNoReturnVoidFunction (X ) \
669
- static PyObject * PyCursesWindow_ ## X \
670
- (PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) \
671
- { \
672
- X(self->win); Py_RETURN_NONE; }
676
+ #define Window_NoArgNoReturnVoidFunction (X ) \
677
+ static PyObject * PyCursesWindow_ ## X \
678
+ (PyObject *op, PyObject *Py_UNUSED(ignored)) \
679
+ { \
680
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
681
+ X(self->win); \
682
+ Py_RETURN_NONE; \
683
+ }
673
684
674
685
#define Window_NoArg2TupleReturnFunction (X , TYPE , ERGSTR ) \
675
686
static PyObject * PyCursesWindow_ ## X \
676
- (PyCursesWindowObject *self , PyObject *Py_UNUSED(ignored)) \
687
+ (PyObject *op , PyObject *Py_UNUSED(ignored)) \
677
688
{ \
678
689
TYPE arg1, arg2; \
679
- X(self->win,arg1,arg2); return Py_BuildValue(ERGSTR, arg1, arg2); }
690
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
691
+ X(self->win, arg1, arg2); \
692
+ return Py_BuildValue(ERGSTR, arg1, arg2); \
693
+ }
680
694
681
695
#define Window_OneArgNoReturnVoidFunction (X , TYPE , PARSESTR ) \
682
696
static PyObject * PyCursesWindow_ ## X \
683
- (PyCursesWindowObject *self , PyObject *args) \
697
+ (PyObject *op , PyObject *args) \
684
698
{ \
685
699
TYPE arg1; \
686
- if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL; \
687
- X(self->win,arg1); Py_RETURN_NONE; }
700
+ if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) { \
701
+ return NULL; \
702
+ } \
703
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
704
+ X(self->win, arg1); \
705
+ Py_RETURN_NONE; \
706
+ }
688
707
689
708
#define Window_OneArgNoReturnFunction (X , TYPE , PARSESTR ) \
690
709
static PyObject * PyCursesWindow_ ## X \
691
- (PyCursesWindowObject *self , PyObject *args) \
710
+ (PyObject *op , PyObject *args) \
692
711
{ \
693
712
TYPE arg1; \
694
- if (!PyArg_ParseTuple(args,PARSESTR, &arg1)) return NULL; \
695
- return PyCursesCheckERR_ForWin(self, X(self->win, arg1), # X); }
713
+ if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) { \
714
+ return NULL; \
715
+ } \
716
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
717
+ int code = X(self->win, arg1); \
718
+ return PyCursesCheckERR_ForWin(self, code, # X); \
719
+ }
696
720
697
721
#define Window_TwoArgNoReturnFunction (X , TYPE , PARSESTR ) \
698
722
static PyObject * PyCursesWindow_ ## X \
699
- (PyCursesWindowObject *self , PyObject *args) \
723
+ (PyObject *op , PyObject *args) \
700
724
{ \
701
725
TYPE arg1, arg2; \
702
- if (!PyArg_ParseTuple(args,PARSESTR, &arg1, &arg2)) return NULL; \
703
- return PyCursesCheckERR_ForWin(self, X(self->win, arg1, arg2), # X); }
726
+ if (!PyArg_ParseTuple(args,PARSESTR, &arg1, &arg2)) { \
727
+ return NULL; \
728
+ } \
729
+ PyCursesWindowObject *self = _PyCursesWindowObject_CAST(op); \
730
+ int code = X(self->win, arg1, arg2); \
731
+ return PyCursesCheckERR_ForWin(self, code, # X); \
732
+ }
704
733
705
734
/* ------------- WINDOW routines --------------- */
706
735
@@ -1302,8 +1331,10 @@ the touchline() method so that the contents will be redisplayed by the next
1302
1331
window refresh.
1303
1332
[-clinic start generated code]*/
1304
1333
static PyObject *
1305
- PyCursesWindow_ChgAt (PyCursesWindowObject * self , PyObject * args )
1334
+ PyCursesWindow_ChgAt (PyObject * op , PyObject * args )
1306
1335
{
1336
+ PyCursesWindowObject * self = _PyCursesWindowObject_CAST (op );
1337
+
1307
1338
int rtn ;
1308
1339
int x , y ;
1309
1340
int num = -1 ;
@@ -1656,8 +1687,10 @@ Read a string from the user, with primitive line editing capacity.
1656
1687
[-clinic start generated code]*/
1657
1688
1658
1689
static PyObject *
1659
- PyCursesWindow_GetStr (PyCursesWindowObject * self , PyObject * args )
1690
+ PyCursesWindow_GetStr (PyObject * op , PyObject * args )
1660
1691
{
1692
+ PyCursesWindowObject * self = _PyCursesWindowObject_CAST (op );
1693
+
1661
1694
int x , y , n ;
1662
1695
char rtn [1024 ]; /* This should be big enough.. I hope */
1663
1696
int rtn2 ;
@@ -1860,8 +1893,10 @@ from the characters. If n is specified, instr() returns a string at most
1860
1893
n characters long (exclusive of the trailing NUL).
1861
1894
[-clinic start generated code]*/
1862
1895
static PyObject *
1863
- PyCursesWindow_InStr (PyCursesWindowObject * self , PyObject * args )
1896
+ PyCursesWindow_InStr (PyObject * op , PyObject * args )
1864
1897
{
1898
+ PyCursesWindowObject * self = _PyCursesWindowObject_CAST (op );
1899
+
1865
1900
int x , y , n ;
1866
1901
char rtn [1024 ]; /* This should be big enough.. I hope */
1867
1902
int rtn2 ;
@@ -2557,14 +2592,17 @@ _curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1,
2557
2592
}
2558
2593
2559
2594
static PyObject *
2560
- PyCursesWindow_get_encoding (PyCursesWindowObject * self , void * closure )
2595
+ PyCursesWindow_get_encoding (PyObject * op , void * closure )
2561
2596
{
2597
+ PyCursesWindowObject * self = _PyCursesWindowObject_CAST (op );
2562
2598
return PyUnicode_FromString (self -> encoding );
2563
2599
}
2564
2600
2565
2601
static int
2566
- PyCursesWindow_set_encoding (PyCursesWindowObject * self , PyObject * value , void * Py_UNUSED (ignored ))
2602
+ PyCursesWindow_set_encoding (PyObject * op , PyObject * value , void * Py_UNUSED (ignored ))
2567
2603
{
2604
+ PyCursesWindowObject * self = _PyCursesWindowObject_CAST (op );
2605
+
2568
2606
PyObject * ascii ;
2569
2607
char * encoding ;
2570
2608
@@ -2607,88 +2645,90 @@ static PyMethodDef PyCursesWindow_methods[] = {
2607
2645
_CURSES_WINDOW_ATTRSET_METHODDEF
2608
2646
_CURSES_WINDOW_BKGD_METHODDEF
2609
2647
#ifdef HAVE_CURSES_WCHGAT
2610
- {"chgat" , ( PyCFunction ) PyCursesWindow_ChgAt , METH_VARARGS },
2648
+ {"chgat" , PyCursesWindow_ChgAt , METH_VARARGS },
2611
2649
#endif
2612
2650
_CURSES_WINDOW_BKGDSET_METHODDEF
2613
2651
_CURSES_WINDOW_BORDER_METHODDEF
2614
2652
_CURSES_WINDOW_BOX_METHODDEF
2615
- {"clear" , ( PyCFunction ) PyCursesWindow_wclear , METH_NOARGS },
2616
- {"clearok" , ( PyCFunction ) PyCursesWindow_clearok , METH_VARARGS },
2617
- {"clrtobot" , ( PyCFunction ) PyCursesWindow_wclrtobot , METH_NOARGS },
2618
- {"clrtoeol" , ( PyCFunction ) PyCursesWindow_wclrtoeol , METH_NOARGS },
2619
- {"cursyncup" , ( PyCFunction ) PyCursesWindow_wcursyncup , METH_NOARGS },
2653
+ {"clear" , PyCursesWindow_wclear , METH_NOARGS },
2654
+ {"clearok" , PyCursesWindow_clearok , METH_VARARGS },
2655
+ {"clrtobot" , PyCursesWindow_wclrtobot , METH_NOARGS },
2656
+ {"clrtoeol" , PyCursesWindow_wclrtoeol , METH_NOARGS },
2657
+ {"cursyncup" , PyCursesWindow_wcursyncup , METH_NOARGS },
2620
2658
_CURSES_WINDOW_DELCH_METHODDEF
2621
- {"deleteln" , ( PyCFunction ) PyCursesWindow_wdeleteln , METH_NOARGS },
2659
+ {"deleteln" , PyCursesWindow_wdeleteln , METH_NOARGS },
2622
2660
_CURSES_WINDOW_DERWIN_METHODDEF
2623
2661
_CURSES_WINDOW_ECHOCHAR_METHODDEF
2624
2662
_CURSES_WINDOW_ENCLOSE_METHODDEF
2625
- {"erase ", ( PyCFunction ) PyCursesWindow_werase , METH_NOARGS },
2626
- {"getbegyx ", (PyCFunction) PyCursesWindow_getbegyx, METH_NOARGS},
2663
+ {"erase ", PyCursesWindow_werase , METH_NOARGS },
2664
+ {"getbegyx ", PyCursesWindow_getbegyx , METH_NOARGS },
2627
2665
_CURSES_WINDOW_GETBKGD_METHODDEF
2628
2666
_CURSES_WINDOW_GETCH_METHODDEF
2629
2667
_CURSES_WINDOW_GETKEY_METHODDEF
2630
2668
_CURSES_WINDOW_GET_WCH_METHODDEF
2631
- {"getmaxyx" , ( PyCFunction ) PyCursesWindow_getmaxyx , METH_NOARGS },
2632
- {"getparyx" , ( PyCFunction ) PyCursesWindow_getparyx , METH_NOARGS },
2633
- {"getstr" , ( PyCFunction ) PyCursesWindow_GetStr , METH_VARARGS },
2634
- {"getyx" , ( PyCFunction ) PyCursesWindow_getyx , METH_NOARGS },
2669
+ {"getmaxyx ", PyCursesWindow_getmaxyx , METH_NOARGS },
2670
+ {"getparyx ", PyCursesWindow_getparyx , METH_NOARGS },
2671
+ {"getstr ", PyCursesWindow_GetStr , METH_VARARGS },
2672
+ {"getyx ", PyCursesWindow_getyx , METH_NOARGS },
2635
2673
_CURSES_WINDOW_HLINE_METHODDEF
2636
- {"idcok" , ( PyCFunction ) PyCursesWindow_idcok , METH_VARARGS },
2637
- {"idlok" , ( PyCFunction ) PyCursesWindow_idlok , METH_VARARGS },
2674
+ {"idcok ", PyCursesWindow_idcok, METH_VARARGS},
2675
+ {"idlok" , PyCursesWindow_idlok , METH_VARARGS },
2638
2676
#ifdef HAVE_CURSES_IMMEDOK
2639
- {"immedok" , ( PyCFunction ) PyCursesWindow_immedok , METH_VARARGS },
2677
+ {"immedok" , PyCursesWindow_immedok , METH_VARARGS },
2640
2678
#endif
2641
2679
_CURSES_WINDOW_INCH_METHODDEF
2642
2680
_CURSES_WINDOW_INSCH_METHODDEF
2643
- {"insdelln" , ( PyCFunction ) PyCursesWindow_winsdelln , METH_VARARGS },
2644
- {"insertln" , ( PyCFunction ) PyCursesWindow_winsertln , METH_NOARGS },
2681
+ {"insdelln" , PyCursesWindow_winsdelln , METH_VARARGS },
2682
+ {"insertln" , PyCursesWindow_winsertln , METH_NOARGS },
2645
2683
_CURSES_WINDOW_INSNSTR_METHODDEF
2646
2684
_CURSES_WINDOW_INSSTR_METHODDEF
2647
- {"instr" , ( PyCFunction ) PyCursesWindow_InStr , METH_VARARGS },
2685
+ {"instr" , PyCursesWindow_InStr , METH_VARARGS },
2648
2686
_CURSES_WINDOW_IS_LINETOUCHED_METHODDEF
2649
- {"is_wintouched" , ( PyCFunction ) PyCursesWindow_is_wintouched , METH_NOARGS },
2650
- {"keypad" , ( PyCFunction ) PyCursesWindow_keypad , METH_VARARGS },
2651
- {"leaveok" , ( PyCFunction ) PyCursesWindow_leaveok , METH_VARARGS },
2652
- {"move" , ( PyCFunction ) PyCursesWindow_wmove , METH_VARARGS },
2653
- {"mvderwin" , ( PyCFunction ) PyCursesWindow_mvderwin , METH_VARARGS },
2654
- {"mvwin" , ( PyCFunction ) PyCursesWindow_mvwin , METH_VARARGS },
2655
- {"nodelay" , ( PyCFunction ) PyCursesWindow_nodelay , METH_VARARGS },
2656
- {"notimeout" , ( PyCFunction ) PyCursesWindow_notimeout , METH_VARARGS },
2687
+ {"is_wintouched" , PyCursesWindow_is_wintouched , METH_NOARGS },
2688
+ {"keypad" , PyCursesWindow_keypad , METH_VARARGS },
2689
+ {"leaveok" , PyCursesWindow_leaveok , METH_VARARGS },
2690
+ {"move" , PyCursesWindow_wmove , METH_VARARGS },
2691
+ {"mvderwin" , PyCursesWindow_mvderwin , METH_VARARGS },
2692
+ {"mvwin" , PyCursesWindow_mvwin , METH_VARARGS },
2693
+ {"nodelay" , PyCursesWindow_nodelay , METH_VARARGS },
2694
+ {"notimeout" , PyCursesWindow_notimeout , METH_VARARGS },
2657
2695
_CURSES_WINDOW_NOUTREFRESH_METHODDEF
2658
2696
_CURSES_WINDOW_OVERLAY_METHODDEF
2659
2697
_CURSES_WINDOW_OVERWRITE_METHODDEF
2660
2698
_CURSES_WINDOW_PUTWIN_METHODDEF
2661
2699
_CURSES_WINDOW_REDRAWLN_METHODDEF
2662
- {"redrawwin" , ( PyCFunction ) PyCursesWindow_redrawwin , METH_NOARGS },
2700
+ {"redrawwin" , PyCursesWindow_redrawwin , METH_NOARGS },
2663
2701
_CURSES_WINDOW_REFRESH_METHODDEF
2664
2702
#ifndef STRICT_SYSV_CURSES
2665
- {"resize" , ( PyCFunction ) PyCursesWindow_wresize , METH_VARARGS },
2703
+ {"resize" , PyCursesWindow_wresize , METH_VARARGS },
2666
2704
#endif
2667
2705
_CURSES_WINDOW_SCROLL_METHODDEF
2668
- {"scrollok" , ( PyCFunction ) PyCursesWindow_scrollok , METH_VARARGS },
2706
+ {"scrollok" , PyCursesWindow_scrollok , METH_VARARGS },
2669
2707
_CURSES_WINDOW_SETSCRREG_METHODDEF
2670
- {"standend" , ( PyCFunction ) PyCursesWindow_wstandend , METH_NOARGS },
2671
- {"standout" , ( PyCFunction ) PyCursesWindow_wstandout , METH_NOARGS },
2708
+ {"standend" , PyCursesWindow_wstandend , METH_NOARGS },
2709
+ {"standout" , PyCursesWindow_wstandout , METH_NOARGS },
2672
2710
{"subpad" , (PyCFunction )_curses_window_subwin , METH_VARARGS , _curses_window_subwin__doc__ },
2673
2711
_CURSES_WINDOW_SUBWIN_METHODDEF
2674
- {"syncdown" , ( PyCFunction ) PyCursesWindow_wsyncdown , METH_NOARGS },
2712
+ {"syncdown" , PyCursesWindow_wsyncdown , METH_NOARGS },
2675
2713
#ifdef HAVE_CURSES_SYNCOK
2676
- {"syncok" , ( PyCFunction ) PyCursesWindow_syncok , METH_VARARGS },
2714
+ {"syncok" , PyCursesWindow_syncok , METH_VARARGS },
2677
2715
#endif
2678
- {"syncup" , ( PyCFunction ) PyCursesWindow_wsyncup , METH_NOARGS },
2679
- {"timeout" , ( PyCFunction ) PyCursesWindow_wtimeout , METH_VARARGS },
2716
+ {"syncup" , PyCursesWindow_wsyncup , METH_NOARGS },
2717
+ {"timeout" , PyCursesWindow_wtimeout , METH_VARARGS },
2680
2718
_CURSES_WINDOW_TOUCHLINE_METHODDEF
2681
- {"touchwin" , ( PyCFunction ) PyCursesWindow_touchwin , METH_NOARGS },
2682
- {"untouchwin" , ( PyCFunction ) PyCursesWindow_untouchwin , METH_NOARGS },
2719
+ {"touchwin" , PyCursesWindow_touchwin , METH_NOARGS },
2720
+ {"untouchwin" , PyCursesWindow_untouchwin , METH_NOARGS },
2683
2721
_CURSES_WINDOW_VLINE_METHODDEF
2684
2722
{NULL, NULL } /* sentinel */
2685
2723
};
2686
2724
2687
2725
static PyGetSetDef PyCursesWindow_getsets [] = {
2688
- {"encoding" ,
2689
- (getter )PyCursesWindow_get_encoding ,
2690
- (setter )PyCursesWindow_set_encoding ,
2691
- "the typecode character used to create the array" },
2726
+ {
2727
+ "encoding" ,
2728
+ PyCursesWindow_get_encoding ,
2729
+ PyCursesWindow_set_encoding ,
2730
+ "the typecode character used to create the array"
2731
+ },
2692
2732
{NULL , NULL , NULL , NULL } /* sentinel */
2693
2733
};
2694
2734
0 commit comments