Class: FFI::Generator::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/generator/application.rb

Constant Summary collapse

OPTIONS =
[
 [ "--help", "-u", GetoptLong::NO_ARGUMENT,
   "Display help information." ],
 [ "--version", "-v", GetoptLong::NO_ARGUMENT,
   "Display the version number and quit." ],
]
USAGE_PREAMBLE =
<<-EOU
Usage: ffi-gen [options] <input_file> <output_file>

<input_file> is the xml parse tree generated by swig -xml command.
<output_file> is the ruby-ffi wrapper file.

EOU

Class Method Summary collapse

Class Method Details

.runObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generator/application.rb', line 21

def run      
  process_args
  if ARGV.size == 2
    File.open(ARGV[1], 'w') do |file|
      file << FFI::Generator::Parser.new.generate(Nokogiri::XML(File.open(ARGV[0])))
    end
  else
    help
    raise "Invalid number of arguments!"
  end
end