mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/tk/lib/remote-tk.rb: bug fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
db71ceb9c0
commit
3676a70e7b
2 changed files with 51 additions and 20 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Mon Jun 14 18:23:27 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* ext/tk/lib/remote-tk.rb: bug fix
|
||||||
|
|
||||||
Sun Jun 13 00:23:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Sun Jun 13 00:23:04 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tcltklib/extconf.rb: [EXPERIMENTAL] MacOS X (darwin) support
|
* ext/tcltklib/extconf.rb: [EXPERIMENTAL] MacOS X (darwin) support
|
||||||
|
|
|
@ -11,11 +11,11 @@ class RemoteTkIp < MultiTkIp; end
|
||||||
|
|
||||||
class MultiTkIp
|
class MultiTkIp
|
||||||
@@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
|
@@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
|
||||||
@@TK_TABLE_LIST = {}.taint unless defined?(@@TK_TABLE_LIST)
|
@@TK_TABLE_LIST = [].taint unless defined?(@@TK_TABLE_LIST)
|
||||||
def self._IP_TABLE; @@IP_TABLE; end
|
def self._IP_TABLE; @@IP_TABLE; end
|
||||||
def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
|
def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
|
||||||
end
|
end
|
||||||
class RemoteTkIp < MultiTkIp
|
class RemoteTkIp
|
||||||
@@IP_TABLE = MultiTkIp._IP_TABLE unless defined?(@@IP_TABLE)
|
@@IP_TABLE = MultiTkIp._IP_TABLE unless defined?(@@IP_TABLE)
|
||||||
@@TK_TABLE_LIST = MultiTkIp._TK_TABLE_LIST unless defined?(@@TK_TABLE_LIST)
|
@@TK_TABLE_LIST = MultiTkIp._TK_TABLE_LIST unless defined?(@@TK_TABLE_LIST)
|
||||||
end
|
end
|
||||||
|
@ -28,10 +28,21 @@ require 'multi-tk'
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
|
|
||||||
class RemoteTkIp < MultiTkIp
|
class << RemoteTkIp
|
||||||
|
undef new_master, new_slave, new_safe_slave
|
||||||
|
undef new_trusted_slave, new_safeTk
|
||||||
|
|
||||||
|
def new(*args, &b)
|
||||||
|
ip = __new(*args)
|
||||||
|
ip.eval_proc(&b) if b
|
||||||
|
ip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class RemoteTkIp
|
||||||
include TkUtil
|
include TkUtil
|
||||||
|
|
||||||
def initialize(remote_ip, displayof=nil)
|
def initialize(remote_ip, displayof=nil, timeout=5)
|
||||||
if $SAFE >= 4
|
if $SAFE >= 4
|
||||||
fail SecurityError, "cannot access another interpreter at level #{$SAFE}"
|
fail SecurityError, "cannot access another interpreter at level #{$SAFE}"
|
||||||
end
|
end
|
||||||
|
@ -77,6 +88,10 @@ class RemoteTkIp < MultiTkIp
|
||||||
@tk_table_list << tbl
|
@tk_table_list << tbl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ret_val = TkVariable.new
|
||||||
|
if timeout > 0 && ! _available_check(timeout)
|
||||||
|
fail RuntimeError, "cannot create connection"
|
||||||
|
end
|
||||||
@ip_id = _create_connection
|
@ip_id = _create_connection
|
||||||
|
|
||||||
self.freeze # defend against modification
|
self.freeze # defend against modification
|
||||||
|
@ -86,6 +101,24 @@ class RemoteTkIp < MultiTkIp
|
||||||
@ip_id
|
@ip_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def _available_check(timeout = 5)
|
||||||
|
return nil if timeout < 1
|
||||||
|
@ret_val.value = ''
|
||||||
|
@interp._invoke('send', '-async', @remote,
|
||||||
|
'send', '-async', Tk.appname,
|
||||||
|
"set #{@ret_val.id} ready")
|
||||||
|
Tk.update
|
||||||
|
if @ret_val != 'ready'
|
||||||
|
(1..(timeout*5)).each{
|
||||||
|
sleep 0.2
|
||||||
|
Tk.update
|
||||||
|
break if @ret_val == 'ready'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
@ret_val.value == 'ready'
|
||||||
|
end
|
||||||
|
private :_available_check
|
||||||
|
|
||||||
def _create_connection
|
def _create_connection
|
||||||
ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_'
|
ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_'
|
||||||
if {[catch {set _rubytk_control_ip_id_} ret] != 0} {
|
if {[catch {set _rubytk_control_ip_id_} ret] != 0} {
|
||||||
|
@ -133,12 +166,17 @@ class RemoteTkIp < MultiTkIp
|
||||||
end
|
end
|
||||||
private :_appsend
|
private :_appsend
|
||||||
|
|
||||||
def is_rubytk?
|
def ready?(timeout=5)
|
||||||
if _appsend(false, false, 'info', 'command', 'ruby') == ""
|
if timeout < 0
|
||||||
false
|
fail ArgumentError, "timeout must be positive number"
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
_available_check(timeout)
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_rubytk?
|
||||||
|
return false if _appsend(false, false, 'info', 'command', 'ruby') == ""
|
||||||
|
[ _appsend(false, false, 'ruby', 'RUBY_VERSION'),
|
||||||
|
_appsend(false, false, 'set', 'tk_patchLevel') ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def appsend(async, *args)
|
def appsend(async, *args)
|
||||||
|
@ -349,17 +387,6 @@ class RemoteTkIp < MultiTkIp
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class << RemoteTkIp
|
|
||||||
undef new_master, new_slave, new_safe_slave
|
|
||||||
undef new_trusted_slave, new_safeTk
|
|
||||||
|
|
||||||
def new(ip_name, displayof=nil, &b)
|
|
||||||
ip = __new(ip_name, displayof)
|
|
||||||
ip.eval_proc(&b) if b
|
|
||||||
ip
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class << RemoteTkIp
|
class << RemoteTkIp
|
||||||
def mainloop
|
def mainloop
|
||||||
fail RuntimeError, 'not support "mainloop" on the remote interpreter'
|
fail RuntimeError, 'not support "mainloop" on the remote interpreter'
|
||||||
|
|
Loading…
Reference in a new issue