Class: TkNamespace
Defined Under Namespace
Classes: Ensemble, NsCode, ScopeArgs
Constant Summary
collapse
- TkCommandNames =
[
'namespace'.freeze,
].freeze
- Tk_Namespace_ID_TBL =
TkCore::INTERP.create_table
- Tk_NsCode_RetObjID_TBL =
TkCore::INTERP.create_table
- Global =
TkNamespace.new('::')
Constants included
from Tk
Tk::AUTO_PATH, Tk::Checkbutton, Tk::CloneMenu, Tk::JAPANIZED_TK, Tk::LIBRARY_PATH, Tk::Labelframe, Tk::MenuButton, Tk::OptionMenuButton, Tk::PACKAGE_PATH, Tk::Panedwindow, Tk::RELEASE_DATE, Tk::Radiobutton, Tk::TCL_LIBRARY_PATH, Tk::TCL_MAJOR_VERSION, Tk::TCL_MINOR_VERSION, Tk::TCL_PACKAGE_PATH, Tk::TCL_PATCHLEVEL, Tk::TCL_PRECISION, Tk::TCL_VERSION, Tk::TK_MAJOR_VERSION, Tk::TK_MINOR_VERSION, Tk::TK_PATCHLEVEL, Tk::TK_VERSION, Tk::Tkextlib_RELEASE_DATE, Tk::TreeCtrl_Widget, Tk::X_Scrollable, Tk::Y_Scrollable
Tk::Encoding::BINARY, Tk::Encoding::BINARY_NAME, Tk::Encoding::DEFAULT_EXTERNAL_NAME, Tk::Encoding::DEFAULT_INTERNAL_NAME, Tk::Encoding::ENCODING_TABLE, Tk::Encoding::RubyEncoding, Tk::Encoding::UNKNOWN, Tk::Encoding::UTF8_NAME
Constants included
from TkCore
TkCore::EventFlag, TkCore::INTERP, TkCore::INTERP_MUTEX, TkCore::INTERP_ROOT_CHECK, TkCore::INTERP_THREAD, TkCore::INTERP_THREAD_STATUS, TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD, TkCore::WIDGET_DESTROY_HOOK, TkCore::WITH_ENCODING, TkCore::WITH_RUBY_VM
Constants included
from TkComm
TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames
Constants included
from TkUtil
TkUtil::None, TkUtil::RELEASE_DATE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Tk
BinaryString, EncodedString, Grid, Pack, Place, UTF8_String, __set_toplevel_aliases__, add_kinsoku, bell, bell_on_display, const_missing, current_grabs, cursor_display, default_widget_set, default_widget_set=, delete_kinsoku, destroy, errorCode, errorInfo, exit, focus, focus_lastfor, focus_next, focus_prev, focus_to, fromUTF8, grid, grid_forget, has_mainwindow?, load_tcllibrary, load_tclscript, load_tclscript_rsrc, load_tclscript_rsrcid, lower_window, pack, pack_forget, pkgconfig_get, pkgconfig_list, place, place_forget, raise_window, root, show_kinsoku, sleep, strictMotif, subst_tk_backslash, subst_utf_backslash, tcl_pkgconfig_get, tcl_pkgconfig_list, thread_update, thread_update_idletasks, tk_pkgconfig_get, tk_pkgconfig_list, toUTF8, to_backslash_sequence, ungrid, unload_tcllibrary, unpack, unplace, update, update, update_idletasks, utf_to_backslash, utf_to_backslash_sequence, wakeup
#default_encoding=, #encoding=, #encoding_convertfrom, #encoding_convertto, #encoding_dirs, #encoding_dirs=, #encoding_name, #encoding_names, #encoding_obj, #encoding_objs, #encoding_system=, #encoding_system_name, #encoding_system_obj, #force_default_encoding, #force_default_encoding=, #force_default_encoding?, #tk_encoding_names
Methods included from TkCore
#_tk_call_to_list_core, #after, #after_cancel, #after_idle, #appname, #appsend, #appsend_deny, #appsend_displayof, callback, #callback_break, #callback_continue, #callback_return, #chooseColor, #chooseDirectory, #do_one_event, #event_generate, #getMultipleOpenFile, #getMultipleSaveFile, #getOpenFile, #getSaveFile, #get_eventloop_tick, #get_eventloop_weight, #get_no_event_wait, #inactive, #inactive_displayof, #info, #ip_eval, #ip_eval_with_enc, #ip_eval_without_enc, #ip_invoke, #ip_invoke_with_enc, #ip_invoke_without_enc, #is_mainloop?, #load_cmd_on_ip, #mainloop, #mainloop_exist?, #mainloop_thread?, #mainloop_watchdog, #messageBox, #rb_appsend, #rb_appsend_displayof, #reset_inactive, #reset_inactive_displayof, #restart, #scaling, #scaling_displayof, #set_eventloop_tick, #set_eventloop_weight, #set_no_event_wait, #tk_call_to_list, #tk_call_to_list_with_enc, #tk_call_to_list_without_enc, #tk_call_to_simplelist, #tk_call_to_simplelist_with_enc, #tk_call_to_simplelist_without_enc, #windowingsystem
Methods included from TkComm
_at, _callback_entry?, _callback_entry_class?, _curr_cmd_id, _fromUTF8, _genobj_for_tkwidget, _next_cmd_id, _toUTF8, array2tk_list, #bind, #bind_all, #bind_append, #bind_append_all, #bind_remove, #bind_remove_all, #bindinfo, #bindinfo_all, bool, image_obj, install_cmd, list, num_or_str, number, procedure, simplelist, string, #subst, tk_tcl2ruby, uninstall_cmd, #uninstall_cmd, window
Methods included from TkUtil
_conv_args, #_conv_args, #_fromUTF8, _get_eval_enc_str, #_get_eval_enc_str, #_get_eval_string, _get_eval_string, _symbolkey2str, #_symbolkey2str, #_toUTF8, bool, #bool, callback, eval_cmd, #hash_kv, hash_kv, install_cmd, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd
Methods included from TkEvent
#install_bind, #install_bind_for_event_class
Methods inherited from TkObject
#destroy, #epath, #event_generate, #method_missing, #path, #tk_send, #tk_send_to_list, #tk_send_to_list_with_enc, #tk_send_to_list_without_enc, #tk_send_to_simplelist, #tk_send_to_simplelist_with_enc, #tk_send_to_simplelist_without_enc, #tk_send_with_enc, #tk_send_without_enc, #to_eval
Methods included from TkBindCore
#bind, #bind_append, #bind_remove, #bindinfo
#[], #[]=, __IGNORE_UNKNOWN_CONFIGURE_OPTION__, #__check_available_configure_options, __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!, #cget, #cget_strict, #config_hash_kv, #configinfo, #configure, #configure_cmd, #current_configinfo
#font_configinfo, #font_configure, #font_copy, #kanjifont_configure, #kanjifont_copy, #latinfont_configure, #latinfont_copy
Methods inherited from TkKernel
new
Constructor Details
#initialize(name = nil, parent = nil) ⇒ TkNamespace
Returns a new instance of TkNamespace.
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
# File 'ext/lib/tk/namespace.rb', line 245
def initialize(name = nil, parent = nil)
unless name
Tk_Namespace_ID.mutex.synchronize{
name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
Tk_Namespace_ID[1].succ!
}
end
name = __tk_call('namespace', 'current') if name == ''
if parent
if parent =~ /^::/
if name =~ /^::/
@fullname = parent + name
else
@fullname = parent +'::'+ name
end
else
ancestor = __tk_call('namespace', 'current')
ancestor = '' if ancestor == '::'
if name =~ /^::/
@fullname = ancestor + '::' + parent + name
else
@fullname = ancestor + '::'+ parent +'::'+ name
end
end
else ancestor = __tk_call('namespace', 'current')
ancestor = '' if ancestor == '::'
if name =~ /^::/
@fullname = name
else
@fullname = ancestor + '::' + name
end
end
@path = @fullname
@parent = __tk_call('namespace', 'qualifiers', @fullname)
@name = __tk_call('namespace', 'tail', @fullname)
__tk_call('namespace', 'eval', @fullname, '')
Tk_Namespace_ID_TBL.mutex.synchronize{
Tk_Namespace_ID_TBL[@fullname] = self
}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class TkObject
Class Method Details
.children(*args) ⇒ Object
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
# File 'ext/lib/tk/namespace.rb', line 291
def self.children(*args)
tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
Tk_Namespace_ID_TBL.mutex.synchronize{
if Tk_Namespace_ID_TBL.key?(ns)
Tk_Namespace_ID_TBL[ns]
else
ns
end
}
}
end
|
.code(script = Proc.new) ⇒ Object
309
310
311
|
# File 'ext/lib/tk/namespace.rb', line 309
def self.code(script = Proc.new)
TkNamespace.new('').code(script)
end
|
.current_path ⇒ Object
358
359
360
|
# File 'ext/lib/tk/namespace.rb', line 358
def self.current_path
tk_call('namespace', 'current')
end
|
.ensemble_configinfo(cmd, slot = nil) ⇒ Object
408
409
410
411
412
413
414
415
416
|
# File 'ext/lib/tk/namespace.rb', line 408
def self.ensemble_configinfo(cmd, slot = nil)
if slot
tk_call('namespace', 'ensemble', 'configure', cmd, '-' + slot.to_s)
else
inf = {}
Hash(*tk_split_simplelist(tk_call('namespace', 'ensemble', 'configure', cmd))).each{|k, v| inf[k[1..-1]] = v}
inf
end
end
|
401
402
403
404
405
406
407
|
# File 'ext/lib/tk/namespace.rb', line 401
def self.ensemble_configure(cmd, slot, value=None)
if slot.kind_of?(Hash)
tk_call('namespace', 'ensemble', 'configure', cmd, *hash_kv(slot))
else
tk_call('namespace', 'ensemble', 'configure', cmd, '-'+slot.to_s, value)
end
end
|
.ensemble_create(*keys) ⇒ Object
398
399
400
|
# File 'ext/lib/tk/namespace.rb', line 398
def self.ensemble_create(*keys)
tk_call('namespace', 'ensemble', 'create', *hash_kv(keys))
end
|
.ensemble_exist?(cmd) ⇒ Boolean
417
418
419
|
# File 'ext/lib/tk/namespace.rb', line 417
def self.ensemble_exist?(cmd)
bool(tk_call('namespace', 'ensemble', 'exists', cmd))
end
|
.eval(namespace, cmd = Proc.new, *args) ⇒ Object
421
422
423
424
|
# File 'ext/lib/tk/namespace.rb', line 421
def self.eval(namespace, cmd = Proc.new, *args)
TkNamespace.new(namespace).eval(cmd, *args)
end
|
.exist?(ns) ⇒ Boolean
443
444
445
|
# File 'ext/lib/tk/namespace.rb', line 443
def self.exist?(ns)
bool(tk_call('namespace', 'exists', ns))
end
|
.export(*patterns) ⇒ Object
450
451
452
|
# File 'ext/lib/tk/namespace.rb', line 450
def self.export(*patterns)
tk_call('namespace', 'export', *patterns)
end
|
.export_with_clear(*patterns) ⇒ Object
453
454
455
|
# File 'ext/lib/tk/namespace.rb', line 453
def self.export_with_clear(*patterns)
tk_call('namespace', 'export', '-clear', *patterns)
end
|
.force_import(*patterns) ⇒ Object
473
474
475
|
# File 'ext/lib/tk/namespace.rb', line 473
def self.force_import(*patterns)
tk_call('namespace', 'import', '-force', *patterns)
end
|
.forget(*patterns) ⇒ Object
463
464
465
|
# File 'ext/lib/tk/namespace.rb', line 463
def self.forget(*patterns)
tk_call('namespace', 'forget', *patterns)
end
|
508
509
510
|
# File 'ext/lib/tk/namespace.rb', line 508
def self.get_path
tk_call('namespace', 'path')
end
|
.get_unknown_handler ⇒ Object
533
534
535
|
# File 'ext/lib/tk/namespace.rb', line 533
def self.get_unknown_handler
tk_tcl2ruby(tk_call('namespace', 'unknown'))
end
|
.import(*patterns) ⇒ Object
470
471
472
|
# File 'ext/lib/tk/namespace.rb', line 470
def self.import(*patterns)
tk_call('namespace', 'import', *patterns)
end
|
.inscope(namespace, script, *args) ⇒ Object
483
484
485
|
# File 'ext/lib/tk/namespace.rb', line 483
def self.inscope(namespace, script, *args)
tk_call('namespace', 'inscope', namespace, script, *args)
end
|
.origin(cmd) ⇒ Object
490
491
492
|
# File 'ext/lib/tk/namespace.rb', line 490
def self.origin(cmd)
tk_call('namespace', 'origin', cmd)
end
|
.parent(namespace = None) ⇒ Object
.qualifiers(str) ⇒ Object
518
519
520
|
# File 'ext/lib/tk/namespace.rb', line 518
def self.qualifiers(str)
tk_call('namespace', 'qualifiers', str)
end
|
.set_path(*namespace_list) ⇒ Object
511
512
513
|
# File 'ext/lib/tk/namespace.rb', line 511
def self.set_path(*namespace_list)
tk_call('namespace', 'path', array2tk_list(namespace_list))
end
|
.set_unknown_handler(cmd = Proc.new) ⇒ Object
536
537
538
|
# File 'ext/lib/tk/namespace.rb', line 536
def self.set_unknown_handler(cmd = Proc.new)
tk_call('namespace', 'unknown', cmd)
end
|
.tail(str) ⇒ Object
522
523
524
|
# File 'ext/lib/tk/namespace.rb', line 522
def self.tail(str)
tk_call('namespace', 'tail', str)
end
|
.upvar(namespace, *var_pairs) ⇒ Object
526
527
528
|
# File 'ext/lib/tk/namespace.rb', line 526
def self.upvar(namespace, *var_pairs)
tk_call('namespace', 'upvar', namespace, *(var_pairs.flatten))
end
|
.which(name) ⇒ Object
540
541
542
|
# File 'ext/lib/tk/namespace.rb', line 540
def self.which(name)
tk_call('namespace', 'which', name)
end
|
.which_command(name) ⇒ Object
543
544
545
|
# File 'ext/lib/tk/namespace.rb', line 543
def self.which_command(name)
tk_call('namespace', 'which', '-command', name)
end
|
.which_variable(name) ⇒ Object
546
547
548
|
# File 'ext/lib/tk/namespace.rb', line 546
def self.which_variable(name)
tk_call('namespace', 'which', '-variable', name)
end
|
Instance Method Details
#__tk_call ⇒ Object
220
|
# File 'ext/lib/tk/namespace.rb', line 220
alias __tk_call tk_call
|
#__tk_call_with_enc ⇒ Object
222
|
# File 'ext/lib/tk/namespace.rb', line 222
alias __tk_call_with_enc tk_call_with_enc
|
#__tk_call_without_enc ⇒ Object
221
|
# File 'ext/lib/tk/namespace.rb', line 221
alias __tk_call_without_enc tk_call_without_enc
|
#children(pattern = None) ⇒ Object
305
306
307
|
# File 'ext/lib/tk/namespace.rb', line 305
def children(pattern=None)
TkNamespace.children(@fullname, pattern)
end
|
#code(script = Proc.new) ⇒ Object
def code(script = Proc.new)
if script.kind_of?(String)
cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(script)}
elsif script.kind_of?(Proc)
cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(&script)}
else
fail ArgumentError, "String or Proc is expected"
end
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
_get_eval_string(cmd, false)))
end
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
# File 'ext/lib/tk/namespace.rb', line 325
def code(script = Proc.new)
if script.kind_of?(String)
cmd = proc{|*args|
if TkCore::WITH_RUBY_VM obj = ScopeArgs.new(@fullname,*args)
ret = obj.instance_exec(obj, script)
else
ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
end
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
}
elsif script.kind_of?(Proc)
cmd = proc{|*args|
if TkCore::WITH_RUBY_VM obj = ScopeArgs.new(@fullname,*args)
ret = obj.instance_exec(obj, &script)
else
ret = ScopeArgs.new(@fullname,*args).instance_eval(&script)
end
id = ret.object_id
TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
id
}
else
fail ArgumentError, "String or Proc is expected"
end
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
_get_eval_string(cmd, false)),
true)
end
|
#current_namespace ⇒ Object
Also known as:
current
375
376
377
378
379
|
# File 'ext/lib/tk/namespace.rb', line 375
def current_namespace
self
end
|
#current_path ⇒ Object
361
362
363
|
# File 'ext/lib/tk/namespace.rb', line 361
def current_path
@fullname
end
|
394
395
396
|
# File 'ext/lib/tk/namespace.rb', line 394
def delete
TkNamespece.delete(@fullname)
end
|
#eval(cmd = Proc.new, *args) ⇒ Object
def eval(cmd = Proc.new, *args)
#TkNamespace.eval(@fullname, cmd, *args)
#ns_tk_call(cmd, *args)
code_obj = code(cmd)
ret = code_obj.call(*args)
# uninstall_cmd(TkCore::INTERP._split_tklist(code_obj.path)[-1])
uninstall_cmd(_fromUTF8(TkCore::INTERP._split_tklist(_toUTF8(code_obj.path))[-1]))
tk_tcl2ruby(ret)
end
436
437
438
439
440
441
|
# File 'ext/lib/tk/namespace.rb', line 436
def eval(cmd = Proc.new, *args)
code_obj = code(cmd)
ret = code_obj.call(*args)
uninstall_cmd(_fromUTF8(TkCore::INTERP._split_tklist(_toUTF8(code_obj.path))[-1]))
ret
end
|
#exist? ⇒ Boolean
446
447
448
|
# File 'ext/lib/tk/namespace.rb', line 446
def exist?
TkNamespece.exist?(@fullname)
end
|
456
457
458
|
# File 'ext/lib/tk/namespace.rb', line 456
def export
TkNamespace.export(@fullname)
end
|
466
467
468
|
# File 'ext/lib/tk/namespace.rb', line 466
def forget
TkNamespace.forget(@fullname)
end
|
476
477
478
|
# File 'ext/lib/tk/namespace.rb', line 476
def import
TkNamespace.import(@fullname)
end
|
#inscope(script, *args) ⇒ Object
486
487
488
|
# File 'ext/lib/tk/namespace.rb', line 486
def inscope(script, *args)
TkNamespace.inscope(@fullname, script, *args)
end
|
#install_cmd(cmd) ⇒ Object
210
211
212
213
214
215
216
217
218
|
# File 'ext/lib/tk/namespace.rb', line 210
def install_cmd(cmd)
lst = tk_split_simplelist(super(cmd), false, false)
if lst[1] =~ /^::/
lst[1] = @fullname
else
lst.insert(1, @fullname)
end
TkCore::INTERP._merge_tklist(*lst)
end
|
504
505
506
|
# File 'ext/lib/tk/namespace.rb', line 504
def parent
tk_call('namespace', 'parent', @fullname)
end
|
514
515
516
|
# File 'ext/lib/tk/namespace.rb', line 514
def set_path
tk_call('namespace', 'path', @fullname)
end
|
#tk_call(*args) ⇒ Object
Also known as:
ns_tk_call
223
224
225
226
227
228
|
# File 'ext/lib/tk/namespace.rb', line 223
def tk_call(*args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
|
#tk_call_with_enc(*args) ⇒ Object
Also known as:
ns_tk_call_with_enc
235
236
237
238
239
240
|
# File 'ext/lib/tk/namespace.rb', line 235
def tk_call_with_enc(*args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
|
#tk_call_without_enc(*args) ⇒ Object
Also known as:
ns_tk_call_without_enc
229
230
231
232
233
234
|
# File 'ext/lib/tk/namespace.rb', line 229
def tk_call_without_enc(*args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args))
end
|
#upvar(*var_pairs) ⇒ Object
529
530
531
|
# File 'ext/lib/tk/namespace.rb', line 529
def upvar(*var_pairs)
TkNamespace.inscope(@fullname, *(var_pairs.flatten))
end
|