106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
# File 'lib/tk.rb', line 106
def _genobj_for_tkwidget(path)
return TkRoot.new if path == '.'
begin
tk_class = Tk.ip_invoke_without_enc('winfo', 'class', path)
rescue
return path
end
if ruby_class = WidgetClassNames[tk_class]
ruby_class_name = ruby_class.name
gen_class_name = ruby_class_name
classname_def = ''
else if Tk.const_defined?(tk_class)
Tk.const_get(tk_class) ruby_class = WidgetClassNames[tk_class]
end
unless ruby_class
mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)}
mods.each{|mod|
begin
mod.const_get(tk_class) break if (ruby_class = WidgetClassNames[tk_class])
rescue LoadError
end
}
end
unless ruby_class
std_class = 'Tk' << tk_class
if Object.const_defined?(std_class)
Object.const_get(std_class) ruby_class = WidgetClassNames[tk_class]
end
end
unless ruby_class
if Tk.const_defined?('TOPLEVEL_ALIASES') &&
Tk::TOPLEVEL_ALIASES.const_defined?(std_class)
Tk::TOPLEVEL_ALIASES.const_get(std_class) ruby_class = WidgetClassNames[tk_class]
end
end
if ruby_class
ruby_class_name = ruby_class.name
gen_class_name = ruby_class_name
classname_def = ''
else
ruby_class_name = 'TkWindow'
gen_class_name = 'TkWidget_' + tk_class
classname_def = "WidgetClassName = '#{tk_class}'.freeze"
end
end
=begin
if ruby_class = WidgetClassNames[tk_class]
ruby_class_name = ruby_class.name
# gen_class_name = ruby_class_name + 'GeneratedOnTk'
gen_class_name = ruby_class_name
classname_def = ''
else
mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)}
if mod
ruby_class_name = mod.name + '::' + tk_class
gen_class_name = ruby_class_name
classname_def = ''
elsif Object.const_defined?('Tk' + tk_class)
ruby_class_name = 'Tk' + tk_class
# gen_class_name = ruby_class_name + 'GeneratedOnTk'
gen_class_name = ruby_class_name
classname_def = ''
else
ruby_class_name = 'TkWindow'
# gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk'
gen_class_name = 'TkWidget_' + tk_class
classname_def = "WidgetClassName = '#{tk_class}'.freeze"
end
end
=end
=begin
unless Object.const_defined? gen_class_name
Object.class_eval "class #{gen_class_name}<#{ruby_class_name}
#{classname_def}
end"
end
Object.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}',
'without_creating'=>true)"
=end
base = Object
gen_class_name.split('::').each{|klass|
next if klass == ''
if base.const_defined?(klass)
base = base.class_eval klass
else
base = base.class_eval "class #{klass}<#{ruby_class_name}
#{classname_def}
end
#{klass}"
end
}
base.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}',
'without_creating'=>true)"
end
|