Class: AutoC::Module::Header

Inherits:
File
  • Object
show all
Defined in:
lib/autoc/code.rb

Instance Attribute Summary collapse

Attributes inherited from File

#entities

Instance Method Summary collapse

Methods inherited from File

#<<, #generate

Constructor Details

#initialize(*args) ⇒ Header

Returns a new instance of Header.



170
171
172
173
174
# File 'lib/autoc/code.rb', line 170

def initialize(*args)
  super
  @file_name = "#{@module.name.downcase}_auto.h"
  @guard_macro = "#{@module.name.upcase}_AUTO_H"
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



168
169
170
# File 'lib/autoc/code.rb', line 168

def file_name
  @file_name
end

Instance Method Details

#new_streamObject



176
177
178
# File 'lib/autoc/code.rb', line 176

def new_stream
  ::File.new(@file_name, "w")
end

#write(stream) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/autoc/code.rb', line 180

def write(stream)
  stream << %$
    /* AUTOMATICALLY GENERATED HEADER FILE. DO NOT MODIFY. */
    #ifndef #{@guard_macro}
    #define #{@guard_macro}
  $
  AutoC.priority_sort(entities).each {|e| e.write_intf(stream)}
  stream << %$
    #endif
  $
  stream << "\n" # DigitalMars C in strict ANSI (-A) mode complains about absent empty line at the very end so let's make it happy
end