Method: Tk::BLT::Tree::Trace.new

Defined in:
lib/tkextlib/blt/tree.rb

.new(tree, *args, &b) ⇒ Object

[View source]

506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/tkextlib/blt/tree.rb', line 506

def self.new(tree, *args, &b)
  TraceID_TBL.mutex.synchronize{
    if tree.kind_of?(Array)
      # not create
      tpath = tree[0].path
      TraceID_TBL[tpath] ||= {}
      unless (obj = TraceID_TBL[tpath][tree[1]])
        (TraceID_TBL[tpath][tree[1]] =
           obj = self.allocate).instance_eval{
          @parent = @tree = tree
          @tpath = @parent.path
          @path = @id = tree[1]  # == traceID
        }
      end
      return obj
    end

    # super(true, tree, *args, &b)
    (obj = self.allocate).instance_eval{
      initialize(tree, *args, &b)
      TraceID_TBL[@tpath] ||= {}
      TraceID_TBL[@tpath][@id] = self
    }
    return obj
  }
end