eserte / perl-tk

the perl module Tk
https://metacpan.org/release/Tk
Other
44 stars 31 forks source link

Tk.xs: Grab() method should not return anything #81

Open chrstphrchvz opened 3 years ago

chrstphrchvz commented 3 years ago

Address ParseXS warning:

Warning: Found a 'CODE' section which seems to be using 'RETVAL' but no 'OUTPUT' section. in Tk.xs, line 1030

Not sure if this is 100% correct or whether it fixes any actual bugs.

eserte commented 3 years ago

The current situation is for sure wrong. Currently the method seems to return whatever is on top of the perl stack, which is probably not intended. However, the Grab() method (unlike the lowercase counterpart grab()) is not documented, nor can I find any usages of Grab() in the Tk code or even on CPAN. The original Tcl function returns TCL_OK or TCL_ERROR, which suggests that the method should rather return nothing, just throw an exception on errors. So maybe it would be better to change it to

  int result = Tk_Grab(info->interp,info->tkwin,global);
  if (result != TCL_OK)
   {
    croak("%s",Tcl_GetStringResult(info->interp));
   }

and change the return value of Tk_Grab to void.