Class: LazyPP::ClassDecl
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#parents ⇒ Object
Returns the value of attribute parents.
Instance Method Summary collapse
-
#initialize(n, t, b, p) ⇒ ClassDecl
constructor
A new instance of ClassDecl.
- #scan(p) ⇒ Object
- #to_cpp(rs) ⇒ Object
- #to_hpp(rs) ⇒ Object
- #type=(val) ⇒ Object
Constructor Details
#initialize(n, t, b, p) ⇒ ClassDecl
Returns a new instance of ClassDecl.
344 345 346 |
# File 'lib/readable-cpp/nodes.rb', line 344 def initialize(n,t,b,p) self.name=n;self.type=t;self.body=b;self.parents=p end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
343 344 345 |
# File 'lib/readable-cpp/nodes.rb', line 343 def body @body end |
#parents ⇒ Object
Returns the value of attribute parents.
343 344 345 |
# File 'lib/readable-cpp/nodes.rb', line 343 def parents @parents end |
Instance Method Details
#scan(p) ⇒ Object
348 |
# File 'lib/readable-cpp/nodes.rb', line 348 def scan p; body.scan(p) unless body.nil? end |
#to_cpp(rs) ⇒ Object
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/readable-cpp/nodes.rb', line 355 def to_cpp rs #rs = rs.add_parent(self) ##rs = rs.new(parent: rs.p#rent<<self) <<-"C++" #{ to_hpp(rs.add_parent(self)) unless rs.gen_header? }#{ ##mark it as generating headers so nested classes arent declared twice body.to_cpp(rs.gen_header!.add_parent(self)){|n| if n.is_a?(VarDeclInitializer) || n.is_a?(VarDeclSimple) || n.instance_of?(TypeDecl) || n.is_a?(EnumDecl) false else n end } unless body.nil?} C++ end |
#to_hpp(rs) ⇒ Object
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/readable-cpp/nodes.rb', line 372 def to_hpp(rs) rs = rs.add_parent(self) ##rs = rs.new parent: self <<-"C++" #{rs.indentation}#{type}#{" #{name} " if name}#{ unless parents.nil? ": #{parents.map { |p| "#{p[:vis].to_cpp(rs)} #{p[:parent].to_cpp(rs)}" }.join', '} \n" end }#{if body.nil? ';' else "\n#{rs.indentation}{\n#{body.to_hpp(rs.indent)}\n#{rs.indentation}};" end} C++ # "#{rs.indentation}#{type} #{name} #{ # ": #{ # parents.map { |p| # "#{p[:vis].to_cpp(rs)} #{p[:parent].to_cpp(rs)}" # }.join', '} \n" unless parents.nil?}" + # (body.nil? ? ';' : "{\n#{ # body.to_hpp(rs.indent) unless body.nil? # }\n"\ # "#{rs.indentation}};") end |
#type=(val) ⇒ Object
349 350 351 |
# File 'lib/readable-cpp/nodes.rb', line 349 def type= val @type = (val.to_s.downcase.intern rescue :class) end |