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::Fontchooser, 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
-
.children(*args) ⇒ Object
-
.code(script = nil, &block) ⇒ Object
-
.current ⇒ Object
-
.current_path ⇒ Object
-
.delete(*ns_list) ⇒ Object
-
.ensemble_configinfo(cmd, slot = nil) ⇒ Object
-
.ensemble_configure(cmd, slot, value = None) ⇒ Object
-
.ensemble_create(*keys) ⇒ Object
-
.ensemble_exist?(cmd) ⇒ Boolean
-
.eval(namespace, cmd = nil, *args, &block) ⇒ Object
-
.exist?(ns) ⇒ Boolean
-
.export(*patterns) ⇒ Object
-
.export_with_clear(*patterns) ⇒ Object
-
.force_import(*patterns) ⇒ Object
-
.forget(*patterns) ⇒ Object
-
.get_path ⇒ Object
-
.get_unknown_handler ⇒ Object
-
.id2obj(id) ⇒ Object
-
.import(*patterns) ⇒ Object
-
.inscope(namespace, script, *args) ⇒ Object
-
.origin(cmd) ⇒ Object
-
.parent(namespace = None) ⇒ Object
-
.qualifiers(str) ⇒ Object
-
.set_path(*namespace_list) ⇒ Object
-
.set_unknown_handler(cmd = nil, &block) ⇒ Object
-
.tail(str) ⇒ Object
-
.upvar(namespace, *var_pairs) ⇒ Object
-
.which(name) ⇒ Object
-
.which_command(name) ⇒ Object
-
.which_variable(name) ⇒ Object
Instance Method Summary
collapse
Methods included from Tk
BinaryString, EncodedString, Grid, Pack, Place, UTF8_String, __create_widget_set__, __disable_toplevel_control__, __import_toplevel_aliases__, __regist_toplevel_aliases__, __remove_toplevel_aliases__, __reset_toplevel_owner__, __set_loaded_toplevel_aliases__, __set_toplevel_aliases__, __toplevel_alias_setup_proc__, _replace_toplevel_aliases, add_kinsoku, backup_current_topdef, bell, bell_on_display, const_missing, current_grabs, cursor_display, default_widget_set, default_widget_set=, define_topalias, define_topobj, 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, regist_sym_for_loaded_file, replace_topalias, replace_topobj, root, set_topalias, 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, topalias_defined?, toplevel_aliases_on_widget_set, topobj_defined?, ungrid, unload_tcllibrary, unpack, unplace, update, update, update_idletasks, utf_to_backslash, utf_to_backslash_sequence, wakeup, widget_set_symbols
#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_nil, num_or_str, number, procedure, simplelist, slice_ary, 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_nil, num_or_nil, num_or_str, #num_or_str, number, #number, string, #string, uninstall_cmd, untrust
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, #cget_tkstring, #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.
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
290
|
# File 'lib/tk/namespace.rb', line 246
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
# File 'lib/tk/namespace.rb', line 292
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 = nil, &block) ⇒ Object
310
311
312
|
# File 'lib/tk/namespace.rb', line 310
def self.code(script = nil, &block)
TkNamespace.new('').code(script || block)
end
|
.current_path ⇒ Object
343
344
345
|
# File 'lib/tk/namespace.rb', line 343
def self.current_path
tk_call('namespace', 'current')
end
|
.ensemble_configinfo(cmd, slot = nil) ⇒ Object
393
394
395
396
397
398
399
400
401
|
# File 'lib/tk/namespace.rb', line 393
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
|
386
387
388
389
390
391
392
|
# File 'lib/tk/namespace.rb', line 386
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
383
384
385
|
# File 'lib/tk/namespace.rb', line 383
def self.ensemble_create(*keys)
tk_call('namespace', 'ensemble', 'create', *hash_kv(keys))
end
|
.ensemble_exist?(cmd) ⇒ Boolean
402
403
404
|
# File 'lib/tk/namespace.rb', line 402
def self.ensemble_exist?(cmd)
bool(tk_call('namespace', 'ensemble', 'exists', cmd))
end
|
.eval(namespace, cmd = nil, *args, &block) ⇒ Object
406
407
408
409
410
|
# File 'lib/tk/namespace.rb', line 406
def self.eval(namespace, cmd = nil, *args, &block)
cmd ||= block
TkNamespace.new(namespace).eval(cmd, *args)
end
|
.exist?(ns) ⇒ Boolean
419
420
421
|
# File 'lib/tk/namespace.rb', line 419
def self.exist?(ns)
bool(tk_call('namespace', 'exists', ns))
end
|
.export(*patterns) ⇒ Object
426
427
428
|
# File 'lib/tk/namespace.rb', line 426
def self.export(*patterns)
tk_call('namespace', 'export', *patterns)
end
|
.export_with_clear(*patterns) ⇒ Object
429
430
431
|
# File 'lib/tk/namespace.rb', line 429
def self.export_with_clear(*patterns)
tk_call('namespace', 'export', '-clear', *patterns)
end
|
.force_import(*patterns) ⇒ Object
449
450
451
|
# File 'lib/tk/namespace.rb', line 449
def self.force_import(*patterns)
tk_call('namespace', 'import', '-force', *patterns)
end
|
.forget(*patterns) ⇒ Object
439
440
441
|
# File 'lib/tk/namespace.rb', line 439
def self.forget(*patterns)
tk_call('namespace', 'forget', *patterns)
end
|
484
485
486
|
# File 'lib/tk/namespace.rb', line 484
def self.get_path
tk_call('namespace', 'path')
end
|
.get_unknown_handler ⇒ Object
509
510
511
|
# File 'lib/tk/namespace.rb', line 509
def self.get_unknown_handler
tk_tcl2ruby(tk_call('namespace', 'unknown'))
end
|
.import(*patterns) ⇒ Object
446
447
448
|
# File 'lib/tk/namespace.rb', line 446
def self.import(*patterns)
tk_call('namespace', 'import', *patterns)
end
|
.inscope(namespace, script, *args) ⇒ Object
459
460
461
|
# File 'lib/tk/namespace.rb', line 459
def self.inscope(namespace, script, *args)
tk_call('namespace', 'inscope', namespace, script, *args)
end
|
.origin(cmd) ⇒ Object
466
467
468
|
# File 'lib/tk/namespace.rb', line 466
def self.origin(cmd)
tk_call('namespace', 'origin', cmd)
end
|
.parent(namespace = None) ⇒ Object
.qualifiers(str) ⇒ Object
494
495
496
|
# File 'lib/tk/namespace.rb', line 494
def self.qualifiers(str)
tk_call('namespace', 'qualifiers', str)
end
|
.set_path(*namespace_list) ⇒ Object
487
488
489
|
# File 'lib/tk/namespace.rb', line 487
def self.set_path(*namespace_list)
tk_call('namespace', 'path', array2tk_list(namespace_list))
end
|
.set_unknown_handler(cmd = nil, &block) ⇒ Object
512
513
514
|
# File 'lib/tk/namespace.rb', line 512
def self.set_unknown_handler(cmd = nil, &block)
tk_call('namespace', 'unknown', cmd || block)
end
|
.tail(str) ⇒ Object
498
499
500
|
# File 'lib/tk/namespace.rb', line 498
def self.tail(str)
tk_call('namespace', 'tail', str)
end
|
.upvar(namespace, *var_pairs) ⇒ Object
502
503
504
|
# File 'lib/tk/namespace.rb', line 502
def self.upvar(namespace, *var_pairs)
tk_call('namespace', 'upvar', namespace, *(var_pairs.flatten))
end
|
.which(name) ⇒ Object
516
517
518
|
# File 'lib/tk/namespace.rb', line 516
def self.which(name)
tk_call('namespace', 'which', name)
end
|
.which_command(name) ⇒ Object
519
520
521
|
# File 'lib/tk/namespace.rb', line 519
def self.which_command(name)
tk_call('namespace', 'which', '-command', name)
end
|
.which_variable(name) ⇒ Object
522
523
524
|
# File 'lib/tk/namespace.rb', line 522
def self.which_variable(name)
tk_call('namespace', 'which', '-variable', name)
end
|
Instance Method Details
#__tk_call ⇒ Object
221
|
# File 'lib/tk/namespace.rb', line 221
alias __tk_call tk_call
|
#__tk_call_with_enc ⇒ Object
223
|
# File 'lib/tk/namespace.rb', line 223
alias __tk_call_with_enc tk_call_with_enc
|
#__tk_call_without_enc ⇒ Object
222
|
# File 'lib/tk/namespace.rb', line 222
alias __tk_call_without_enc tk_call_without_enc
|
#children(pattern = None) ⇒ Object
306
307
308
|
# File 'lib/tk/namespace.rb', line 306
def children(pattern=None)
TkNamespace.children(@fullname, pattern)
end
|
#code(script = nil, &block) ⇒ Object
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
# File 'lib/tk/namespace.rb', line 314
def code(script = nil, &block)
script ||= block
if script.kind_of?(String)
cmd = proc{|*args|
ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
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
360
361
362
363
364
|
# File 'lib/tk/namespace.rb', line 360
def current_namespace
self
end
|
#current_path ⇒ Object
346
347
348
|
# File 'lib/tk/namespace.rb', line 346
def current_path
@fullname
end
|
379
380
381
|
# File 'lib/tk/namespace.rb', line 379
def delete
TkNamespece.delete(@fullname)
end
|
#eval(cmd = nil, *args, &block) ⇒ Object
411
412
413
414
415
416
417
|
# File 'lib/tk/namespace.rb', line 411
def eval(cmd = nil, *args, &block)
cmd ||= block
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
422
423
424
|
# File 'lib/tk/namespace.rb', line 422
def exist?
TkNamespece.exist?(@fullname)
end
|
432
433
434
|
# File 'lib/tk/namespace.rb', line 432
def export
TkNamespace.export(@fullname)
end
|
442
443
444
|
# File 'lib/tk/namespace.rb', line 442
def forget
TkNamespace.forget(@fullname)
end
|
452
453
454
|
# File 'lib/tk/namespace.rb', line 452
def import
TkNamespace.import(@fullname)
end
|
#inscope(script, *args) ⇒ Object
462
463
464
|
# File 'lib/tk/namespace.rb', line 462
def inscope(script, *args)
TkNamespace.inscope(@fullname, script, *args)
end
|
#install_cmd(cmd) ⇒ Object
211
212
213
214
215
216
217
218
219
|
# File 'lib/tk/namespace.rb', line 211
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
|
480
481
482
|
# File 'lib/tk/namespace.rb', line 480
def parent
tk_call('namespace', 'parent', @fullname)
end
|
490
491
492
|
# File 'lib/tk/namespace.rb', line 490
def set_path
tk_call('namespace', 'path', @fullname)
end
|
#tk_call(*args) ⇒ Object
Also known as:
ns_tk_call
224
225
226
227
228
229
|
# File 'lib/tk/namespace.rb', line 224
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
236
237
238
239
240
241
|
# File 'lib/tk/namespace.rb', line 236
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
230
231
232
233
234
235
|
# File 'lib/tk/namespace.rb', line 230
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
505
506
507
|
# File 'lib/tk/namespace.rb', line 505
def upvar(*var_pairs)
TkNamespace.inscope(@fullname, *(var_pairs.flatten))
end
|