Class: FFI::Tcl::Interp
Constant Summary
Constants inherited
from PrettyStruct
PrettyStruct::ACCESSOR_CODE
Instance Method Summary
collapse
layout
Instance Method Details
#do_events_until(flag = 0) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 59
def do_events_until(flag = 0)
begin
wait_for_event(0.1)
Tcl.do_one_event(flag)
end until yield
end
|
#do_events_while(flag = 0) ⇒ Object
66
67
68
69
70
71
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 66
def do_events_while(flag = 0)
begin
wait_for_event(0.1)
Tcl.do_one_event(flag)
end while yield
end
|
#do_one_event(flag = 0) ⇒ Object
55
56
57
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 55
def do_one_event(flag = 0)
Tcl.do_one_event(flag)
end
|
#eval(string) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 73
def eval(string)
if $DEBUG
if string =~ /\n/
puts "eval: %p" % [string]
else
puts "eval: %s" % [string]
end
end
code = Tcl.eval_ex(self, string, string.bytesize, 0x40000)
return true if code == 0
message = guess_result.to_s
if message.empty?
raise 'Failure during eval of: %p' % [string]
else
raise '%s during eval of: %p' % [message, string]
end
end
|
#guess_result ⇒ Object
14
15
16
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 14
def guess_result
EvalResult.guess(self, Obj.new(Tcl.get_obj_result(self)))
end
|
10
11
12
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 10
def inspect
"Interp"
end
|
#obj_result ⇒ Object
18
19
20
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 18
def obj_result
Obj.new(Tcl.get_obj_result(self))
end
|
#obj_result=(ruby_obj) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 22
def obj_result=(ruby_obj)
obj =
case ruby_obj
when true
Tcl.new_boolean_obj(1)
when false
Tcl.new_boolean_obj(0)
when String
Tcl.new_string_obj(ruby_obj, ruby_obj.bytesize)
when Fixnum
Tcl.new_int_obj(ruby_obj)
else
if ruby_obj.respond_to?(:to_tcl)
ruby_obj.to_tcl
else
raise ArgumentError, "Don't know how to set %p automatically" % [ruby_obj]
end
end
Tcl.set_obj_result(self, obj)
end
|
#wait_for_event(seconds = 0.0) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/ffi-tk/ffi/tcl/interp.rb', line 44
def wait_for_event(seconds = 0.0)
if seconds && seconds > 0.0
seconds, microseconds = (seconds * 1000).divmod(1000)
time = TclTime.new(seconds, microseconds)
else
time = nil
end
Tcl.wait_for_event(time)
end
|