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

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