Skip to content

Commit

Permalink
Replace Fixnum with Integer
Browse files Browse the repository at this point in the history
Fixnum was deprecated in Ruby 2.5 and removed in Ruby 3.2. I'm not
sure this is safe, as it is possible Fixnum was used deliberately
instead of Integer, maybe because the integers were going to be
passed to Tcl/Tk.  However, from a partial review, it looks like
the code was just using Fixnum instead of Integer.  For example,
the lib/tkextlib/iwidgets/notebook.rb change passes non-Fixnum
instances directly to tk_send_without_enc, so the only change
is that large negative integers are now changed to nil instead
of being passed directly.
  • Loading branch information
jeremyevans committed Jan 9, 2025
1 parent 5eede1c commit 626e027
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion MANUAL_tcltklib.ja
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ require "tcltklib" すると, 以下のモジュール, クラスが利用可能
メソッド _return_value()
直前の Tcl_Eval の戻り値を返します. 0(TCL_OK) で正常終了です.
引数: 無し
戻り値 (Fixnum): 直前の Tcl_Eval() が返した値.
戻り値 (Integer): 直前の Tcl_Eval() が返した値.

==============================================================

Expand Down
2 changes: 1 addition & 1 deletion lib/multi-tk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ def initialize(master, safeip=true, keys={})

name, safe, safe_opts, tk_opts = _parse_slaveopts(keys)

safe = 1 if safe && !safe.kind_of?(Fixnum)
safe = 1 if safe && !safe.kind_of?(Integer)

@safe_base = false

Expand Down
2 changes: 1 addition & 1 deletion lib/tkextlib/iwidgets/notebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def yscrollbar(bar=nil)
def view(*idxs)
if idxs.size == 0
idx = num_or_str(tk_send_without_enc('view'))
if idx.kind_of?(Fixnum) && idx < 0
if idx.kind_of?(Integer) && idx < 0
nil
else
idx
Expand Down
2 changes: 1 addition & 1 deletion lib/tkextlib/iwidgets/tabnotebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def yscrollbar(bar=nil)
def view(*index)
if index.size == 0
idx = num_or_str(tk_send_without_enc('view'))
if idx.kind_of?(Fixnum) && idx < 0
if idx.kind_of?(Integer) && idx < 0
nil
else
idx
Expand Down
10 changes: 5 additions & 5 deletions lib/tkextlib/tcllib/tablelist_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,15 +482,15 @@ def configrows(*args) # args ==> idx, opt, val, idx, opt, val, ...

def containing(y)
idx = num_or_str(tk_send('containing', y))
(idx.kind_of?(Fixnum) && idx < 0)? nil: idx
(idx.kind_of?(Integer) && idx < 0)? nil: idx
end

def containing_cell(x, y)
idx = _from_idx(tk_send('containingcell', x, y))
if idx.kind_of?(Array)
[
((idx[0].kind_of?(Fixnum) && idx[0] < 0)? nil: idx[0]),
((idx[1].kind_of?(Fixnum) && idx[1] < 0)? nil: idx[1])
((idx[0].kind_of?(Integer) && idx[0] < 0)? nil: idx[0]),
((idx[1].kind_of?(Integer) && idx[1] < 0)? nil: idx[1])
]
else
idx
Expand All @@ -500,7 +500,7 @@ def containing_cell(x, y)

def containing_column(x)
idx = num_or_str(tk_send('containingcolumn', x))
(idx.kind_of?(Fixnum) && idx < 0)? nil: idx
(idx.kind_of?(Integer) && idx < 0)? nil: idx
end
alias containingcolumn containing_column

Expand Down Expand Up @@ -889,7 +889,7 @@ def sort_by_columnlist(idxlist, orderlist=None)

def sortcolumn
idx = num_or_str(tk_send('sortcolumn'))
(idx.kind_of?(Fixnum) && idx < 0)? nil: idx
(idx.kind_of?(Integer) && idx < 0)? nil: idx
end

def sortcolumnlist
Expand Down
2 changes: 1 addition & 1 deletion lib/tkextlib/treectrl/tktreectrl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ def item_order(item, visible=false)
ret = num_or_str(tk_send('item', 'order', item))
end

(ret.kind_of?(Fixnum) && ret < 0)? nil: ret
(ret.kind_of?(Integer) && ret < 0)? nil: ret
end
def item_visible_order(item)
item_order(item, true)
Expand Down
4 changes: 2 additions & 2 deletions sample/tktextio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def printf(*args)

def putc(c)
_check_writable
c = c.chr if c.kind_of?(Fixnum)
c = c.chr if c.kind_of?(Integer)
_write(c)
c
end
Expand Down Expand Up @@ -854,7 +854,7 @@ def ungetc(c)
end

_check_readable
c = c.chr if c.kind_of?(Fixnum)
c = c.chr if c.kind_of?(Integer)
if compare(@txtpos, '>', '1.0')
@txtpos.set(@txtpos - '1 char')
delete(@txtpos)
Expand Down

0 comments on commit 626e027

Please sign in to comment.