Class: CGenerator::Structure

Inherits:
CFragment show all
Defined in:
lib/cgen/cgen.rb

Overview

A Structure instance keeps track of data members added to a struct.

declare :x => "int x"

Adds the specified string to define a structure member.

Defined Under Namespace

Classes: InheritAccumulator

Instance Attribute Summary

Attributes inherited from Accumulator

#name, #parent

Instance Method Summary collapse

Methods inherited from Template

accumulator

Methods inherited from Accumulator

#accept?, #add, #add_one, #add_one_really, #inspect, #inspect_one, #output, #output_one, #to_s

Constructor Details

#initialize(name, parent, attribute = nil) ⇒ Structure

Returns a new instance of Structure.



1979
1980
1981
1982
1983
1984
1985
1986
1987
# File 'lib/cgen/cgen.rb', line 1979

def initialize name, parent, attribute = nil
  super(name, parent)
  if attribute
    add "typedef struct #{name}", block!, "#{attribute} #{name}"
  else
    add "typedef struct #{name}", block!, name
  end
  block inherit!, declare!
end

Instance Method Details

#separatorObject



1989
# File 'lib/cgen/cgen.rb', line 1989

def separator; " "; end