Module: FFI::Tcl

Extended by:
Library
Defined in:
lib/ffi-tk/ffi/tcl.rb,
lib/ffi-tk/ffi/tcl/obj.rb,
lib/ffi-tk/ffi/tcl/time.rb,
lib/ffi-tk/ffi/tcl/interp.rb,
lib/ffi-tk/ffi/tcl/cmd_proc.rb,
lib/ffi-tk/ffi/tcl/eval_result.rb

Defined Under Namespace

Classes: CmdProc, EvalResult, Interp, Obj, ObjType, PrettyStruct, TclTime

Constant Summary collapse

ATTACHED_FUNCTIONS =
{}
BINDING =
binding

Class Method Summary collapse

Class Method Details

.setup_eventloop_on_main_threadObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ffi-tk/ffi/tcl.rb', line 75

def setup_eventloop_on_main_thread
  puts "Run eventloop on main thread" if $DEBUG

  code = <<-'RUBY'.strip
def self.%s(*args, &block)
  %s(*args, &block)
end
  RUBY

  binding, file, line = BINDING, __FILE__, __LINE__ - 5
  ATTACHED_FUNCTIONS.each do |function, ruby_name|
    eval(code % [ruby_name, function], binding, file, line)
  end

  Interp.new(create_interp)
end

.setup_eventloop_on_new_threadObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ffi-tk/ffi/tcl.rb', line 56

def setup_eventloop_on_new_thread
  puts "Run eventloop on new thread" if $DEBUG

  code = <<-RUBY.strip
def self.%s(*args, &block)
  @thread_sender.thread_send{ %s(*args, &block) }
end
  RUBY

  binding, file, line = BINDING, __FILE__, __LINE__ - 5
  ATTACHED_FUNCTIONS.each do |function, ruby_name|
    eval(code % [ruby_name, function], binding, file, line)
  end

  @thread_sender = ThreadSender.new
  class << self; attr_reader :thread_sender; end
  @thread_sender.thread_send{ Interp.new(create_interp) }
end