Method: CGenerator::CFile#initialize

Defined in:
lib/cgen/cgen.rb

#initialize(name, library, include_file = nil, bare = !!include_file) ⇒ CFile

Returns a new instance of CFile.



1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
# File 'lib/cgen/cgen.rb', line 1387

def initialize name, library, include_file = nil, bare = !!include_file
  super name, library
  @include_file = include_file
  if bare
    add preamble!, include!, declare!, define!
  else
    ## it's a little hacky to decide in this way that this is a .h file
    sym = name.gsub(/\W/, '_')
    add "#ifndef #{sym}\n#define #{sym}",
        preamble!, include!, declare!, define!,
        "#endif"
  end
end