Class: LazyPP::Node

Inherits:
Object show all
Defined in:
lib/readable-cpp/nodes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*fields, &b) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/readable-cpp/nodes.rb', line 44

def self.new(*fields, &b)
  cls = Class.new(self)
  fff = fields.join ?,
  cls.class_eval <<-END
    attr_accessor #{fields.map {|f| ":#{f}"}.join ', '}
    def initialize(#{fff})
      #{fields.each_with_index.map { |field, index|
          "self.#{field} = #{field}"
        }.join ?;}
    end
    def self.new(*args)
      o = allocate
      o.send :initialize, *args
      o.send :post_init
      o
    end
  END
  cls.class_eval &b if b
  cls
end

Instance Method Details

#inspectObject



74
75
76
77
78
79
80
# File 'lib/readable-cpp/nodes.rb', line 74

def inspect
  "<#{self.class} #{
    instance_variables.map{|m|
      "#{m}=#{instance_variable_get(m).inspect}"
    }.join(', ')
  }>"
end

#post_initObject



64
# File 'lib/readable-cpp/nodes.rb', line 64

def post_init() end

#scan(prog) ⇒ Object



71
72
73
# File 'lib/readable-cpp/nodes.rb', line 71

def scan(prog)
  nil
end

#to_cppObject



65
66
67
# File 'lib/readable-cpp/nodes.rb', line 65

def to_cpp(*)
  "//(Unimplemented to_cpp) #{inspect}"
end

#to_hpp(*args) ⇒ Object



68
69
70
# File 'lib/readable-cpp/nodes.rb', line 68

def to_hpp(*args)
  to_cpp(*args)
end