Class RemoteTkIp
In: tk/lib/remote-tk.rb
Parent: MultiTkIp

Methods

Public Class methods

[Source]

# File tk/lib/remote-tk.rb, line 501
  def do_one_evant(flag = nil)
    fail RuntimeError, 'not support "do_one_event" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 513
  def get_eventloop_tick
    fail RuntimeError, 'not support "get_eventloop_tick" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 525
  def get_eventloop_weight
    fail RuntimeError, 'not support "get_eventloop_weight" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 519
  def get_no_event_wait
    fail RuntimeError, 'not support "get_no_event_wait" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 495
  def mainloop(*args)
    fail RuntimeError, 'not support "mainloop" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 504
  def mainloop_abort_on_exception
    fail RuntimeError, 'not support "mainloop_abort_on_exception" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 507
  def mainloop_abort_on_exception=(mode)
    fail RuntimeError, 'not support "mainloop_abort_on_exception=" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 498
  def mainloop_watchdog(*args)
    fail RuntimeError, 'not support "mainloop_watchdog" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 139
  def self.manipulable?
    true
  end

[Source]

# File tk/lib/remote-tk.rb, line 63
  def initialize(remote_ip, displayof=nil, timeout=5)
    if $SAFE >= 4
      fail SecurityError, "cannot access another interpreter at level #{$SAFE}"
    end

    @interp = MultiTkIp.__getip
    if @interp.safe?
      fail SecurityError, "safe-IP cannot create RemoteTkIp"
    end


    @interp.allow_ruby_exit = false
    @appname = @interp._invoke('tk', 'appname')
    @remote = remote_ip.to_s.dup.freeze
    if displayof.kind_of?(TkWindow)
      @displayof = displayof.path.dup.freeze
    else
      @displayof = nil
    end
    if self.deleted?
      fail RuntimeError, "no Tk application named \"#{@remote}\""
    end

    @tk_windows = {}
    @tk_table_list = []
    @slave_ip_tbl = {}
    @slave_ip_top = {}

    @tk_windows.taint unless @tk_windows.tainted?
    @tk_table_list.taint unless @tk_table_list.tainted?
    @slave_ip_tbl.taint unless @slave_ip_tbl.tainted?
    @slave_ip_top.taint unless @slave_ip_top.tainted?

    @system = Object.new

    @threadgroup  = ThreadGroup.new

    @safe_level = [$SAFE]

    @wait_on_mainloop = [true, 0]

    @cmd_queue = Queue.new

??
    @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)

    @@IP_TABLE[@threadgroup] = self
    @@TK_TABLE_LIST.size.times{ 
      (tbl = {}).tainted? || tbl.taint
      @tk_table_list << tbl
    }

    @ret_val = TkVariable.new
    if timeout > 0 && ! _available_check(timeout)
      fail RuntimeError, "cannot create connection"
    end
    @ip_id = _create_connection

    class << self
      undef :instance_eval
    end

    self.freeze  # defend against modification
  end

[Source]

# File tk/lib/remote-tk.rb, line 55
  def new(*args, &b)
    ip = __new(*args)
    ip.eval_proc(&b) if b
    ip
  end

[Source]

# File tk/lib/remote-tk.rb, line 510
  def set_eventloop_tick(*args)
    fail RuntimeError, 'not support "set_eventloop_tick" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 522
  def set_eventloop_weight(*args)
    fail RuntimeError, 'not support "set_eventloop_weight" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 516
  def set_no_event_wait(*args)
    fail RuntimeError, 'not support "set_no_event_wait" on the remote interpreter'
  end

Public Instance methods

[Source]

# File tk/lib/remote-tk.rb, line 339
  def __eval(str)
    _appsend(false, false, str)
  end

[Source]

# File tk/lib/remote-tk.rb, line 356
  def __invoke(*args)
    _appsend(false, false, *args)
  end

[Source]

# File tk/lib/remote-tk.rb, line 450
  def _conv_listelement(str)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?
    @interp._conv_listelement(str)
  end

[Source]

# File tk/lib/remote-tk.rb, line 455
  def _create_console
    fail RuntimeError, 'not support "_create_console" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 342
  def _eval(str)
    _appsend(nil, false, str)
  end

[Source]

# File tk/lib/remote-tk.rb, line 348
  def _eval_with_enc(str)
    _appsend(true, false, str)
  end

[Source]

# File tk/lib/remote-tk.rb, line 345
  def _eval_without_enc(str)
    _appsend(false, false, str)
  end

[Source]

# File tk/lib/remote-tk.rb, line 374
  def _fromUTF8(str, encoding=nil)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?
    @interp._fromUTF8(str, encoding)
  end

[Source]

# File tk/lib/remote-tk.rb, line 419
  def _get_global_var(var_name)
    _appsend(false, 'set', TkComm::_get_eval_string(var_name))
  end

[Source]

# File tk/lib/remote-tk.rb, line 422
  def _get_global_var2(var_name, index_name)
    _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})")
  end

[Source]

# File tk/lib/remote-tk.rb, line 392
  def _get_variable(var_name, flag)
    # ignore flag
    _appsend(false, 'set', TkComm::_get_eval_string(var_name))
  end

[Source]

# File tk/lib/remote-tk.rb, line 396
  def _get_variable2(var_name, index_name, flag)
    # ignore flag
    _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})")
  end

[Source]

# File tk/lib/remote-tk.rb, line 352
  def _invoke(*args)
    _appsend(nil, false, *args)
  end

[Source]

# File tk/lib/remote-tk.rb, line 359
  def _invoke(*args)
    _appsend(nil, false, *args)
  end

[Source]

# File tk/lib/remote-tk.rb, line 365
  def _invoke_with_enc(*args)
    _appsend(true, false, *args)
  end

[Source]

# File tk/lib/remote-tk.rb, line 362
  def _invoke_without_enc(*args)
    _appsend(false, false, *args)
  end

[Source]

# File tk/lib/remote-tk.rb, line 148
  def _ip_id_
    @ip_id
  end

[Source]

# File tk/lib/remote-tk.rb, line 445
  def _merge_tklist(*args)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?
    @interp._merge_tklist(*args)
  end

[Source]

# File tk/lib/remote-tk.rb, line 387
  def _return_value
    raise SecurityError, "no permission to manipulate" unless self.manipulable?
    @interp._return_value
  end

[Source]

# File tk/lib/remote-tk.rb, line 426
  def _set_global_var(var_name, value)
    _appsend(false, 'set', TkComm::_get_eval_string(var_name), TkComm::_get_eval_string(value))
  end

[Source]

# File tk/lib/remote-tk.rb, line 429
  def _set_global_var2(var_name, index_name, value)
    _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})", TkComm::_get_eval_string(value))
  end

[Source]

# File tk/lib/remote-tk.rb, line 401
  def _set_variable(var_name, value, flag)
    # ignore flag
    _appsend(false, 'set', TkComm::_get_eval_string(var_name), TkComm::_get_eval_string(value))
  end

[Source]

# File tk/lib/remote-tk.rb, line 405
  def _set_variable2(var_name, index_name, value, flag)
    # ignore flag
    _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})", TkComm::_get_eval_string(value))
  end

[Source]

# File tk/lib/remote-tk.rb, line 440
  def _split_tklist(str)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?
    @interp._split_tklist(str)
  end

[Source]

# File tk/lib/remote-tk.rb, line 383
  def _thread_tkwait(mode, target)
    _appsend(false, 'thread_tkwait', mode, target)
  end

[Source]

# File tk/lib/remote-tk.rb, line 379
  def _thread_vwait(var_name)
    _appsend(false, 'thread_vwait', varname)
  end

[Source]

# File tk/lib/remote-tk.rb, line 369
  def _toUTF8(str, encoding=nil)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?
    @interp._toUTF8(str, encoding)
  end

[Source]

# File tk/lib/remote-tk.rb, line 433
  def _unset_global_var(var_name)
    _appsend(false, 'unset', TkComm::_get_eval_string(var_name))
  end

[Source]

# File tk/lib/remote-tk.rb, line 436
  def _unset_global_var2(var_name, index_name)
    _appsend(false, 'unset', "#{var_name}(#{index_name})")
  end

[Source]

# File tk/lib/remote-tk.rb, line 410
  def _unset_variable(var_name, flag)
    # ignore flag
    _appsend(false, 'unset', TkComm::_get_eval_string(var_name))
  end

[Source]

# File tk/lib/remote-tk.rb, line 414
  def _unset_variable2(var_name, index_name, flag)
    # ignore flag
    _appsend(false, 'unset', "#{var_name}(#{index_name})")
  end

[Source]

# File tk/lib/remote-tk.rb, line 291
  def allow_ruby_exit= (mode)
    fail RuntimeError, 'cannot change mode of the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 287
  def allow_ruby_exit?
    false
  end

[Source]

# File tk/lib/remote-tk.rb, line 238
  def appsend(async, *args)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?

    if async != true && async != false && async != nil
      args.unshift(async)
      async = false
    end
    if @displayof
      Tk.appsend_displayof(@remote, @displayof, async, *args)
    else
      Tk.appsend(@remote, async, *args)
    end
  end

[Source]

# File tk/lib/remote-tk.rb, line 266
  def create_slave(name, safe=false)
    if safe
      safe_opt = ''
    else
      safe_opt = '-safe'
    end
    _appsend(false, false, "interp create #{safe_opt} -- #{name}")
  end

[Source]

# File tk/lib/remote-tk.rb, line 295
  def delete
    _appsend(false, true, 'exit')
  end

[Source]

# File tk/lib/remote-tk.rb, line 299
  def deleted?
    raise SecurityError, "no permission to manipulate" unless self.manipulable?

    if @displayof
      lst = @interp._invoke_without_enc('winfo', 'interps', 
                                        '-displayof', @displayof)
    else
      lst = @interp._invoke_without_enc('winfo', 'interps')
    end
    # unless @interp._split_tklist(lst).index(@remote)
    unless @interp._split_tklist(lst).index(_toUTF8(@remote))
      true
    else
      false
    end
  end

[Source]

# File tk/lib/remote-tk.rb, line 465
  def do_one_evant(flag = nil)
    fail RuntimeError, 'not support "do_one_event" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 477
  def get_eventloop_tick
    fail RuntimeError, 'not support "get_eventloop_tick" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 489
  def get_eventloop_weight
    fail RuntimeError, 'not support "get_eventloop_weight" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 483
  def get_no_event_wait
    fail RuntimeError, 'not support "get_no_event_wait" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 316
  def has_mainwindow?
    raise SecurityError, "no permission to manipulate" unless self.manipulable?

    begin
      inf = @interp._invoke_without_enc('info', 'command', '.')
    rescue Exception
      return nil
    end
    if !inf.kind_of?(String) || inf != '.'
      false
    else
      true
    end
  end

[Source]

# File tk/lib/remote-tk.rb, line 331
  def invalid_namespace?
    false
  end

[Source]

# File tk/lib/remote-tk.rb, line 232
  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

[Source]

# File tk/lib/remote-tk.rb, line 459
  def mainloop
    fail RuntimeError, 'not support "mainloop" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 468
  def mainloop_abort_on_exception
    fail RuntimeError, 'not support "mainloop_abort_on_exception" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 471
  def mainloop_abort_on_exception=(mode)
    fail RuntimeError, 'not support "mainloop_abort_on_exception=" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 462
  def mainloop_watchdog
    fail RuntimeError, 'not support "mainloop_watchdog" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 275
  def make_safe
    fail RuntimeError, 'cannot change safe mode of the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 135
  def manipulable?
    return true if (Thread.current.group == ThreadGroup::Default)
    MultiTkIp.__getip == @interp && ! @interp.safe?
  end

[Source]

# File tk/lib/remote-tk.rb, line 252
  def rb_appsend(async, *args)
    raise SecurityError, "no permission to manipulate" unless self.manipulable?

    if async != true && async != false && async != nil
      args.unshift(async)
      async = false
    end
    if @displayof
      Tk.rb_appsend_displayof(@remote, @displayof, async, *args)
    else
      Tk.rb_appsend(@remote, async, *args)
    end
  end

[Source]

# File tk/lib/remote-tk.rb, line 225
  def ready?(timeout=5)
    if timeout < 0
      fail ArgumentError, "timeout must be positive number"
    end
    _available_check(timeout)
  end

[Source]

# File tk/lib/remote-tk.rb, line 335
  def restart
    fail RuntimeError, 'cannot restart the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 279
  def safe?
    _appsend(false, false, 'interp issafe')
  end

[Source]

# File tk/lib/remote-tk.rb, line 283
  def safe_base?
    false
  end

[Source]

# File tk/lib/remote-tk.rb, line 474
  def set_eventloop_tick(*args)
    fail RuntimeError, 'not support "set_eventloop_tick" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 486
  def set_eventloop_weight(*args)
    fail RuntimeError, 'not support "set_eventloop_weight" on the remote interpreter'
  end

[Source]

# File tk/lib/remote-tk.rb, line 480
  def set_no_event_wait(*args)
    fail RuntimeError, 'not support "set_no_event_wait" on the remote interpreter'
  end

Protected Instance methods

[Source]

# File tk/lib/remote-tk.rb, line 143
  def _is_master_of?(tcltkip_obj)
    tcltkip_obj == @interp
  end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.