2007-02-14 14:56:16 -05:00
|
|
|
#! /usr/bin/ruby
|
|
|
|
|
|
|
|
require 'erb'
|
2007-03-09 15:46:46 -05:00
|
|
|
|
|
|
|
require File.dirname(__FILE__) + '/controls.rb'
|
2007-02-14 14:56:16 -05:00
|
|
|
|
|
|
|
cc_template = ''
|
2007-03-09 15:46:46 -05:00
|
|
|
File.open( File.dirname(__FILE__) + "/surface-cc-template.erb", "r" ) { |f| cc_template = f.read }
|
2007-02-14 14:56:16 -05:00
|
|
|
|
|
|
|
h_template = ''
|
2007-03-09 15:46:46 -05:00
|
|
|
File.open( File.dirname(__FILE__) + "/surface-h-template.erb", "r" ) { |f| h_template = f.read }
|
2007-02-14 14:56:16 -05:00
|
|
|
|
|
|
|
sf = Surface.new( ARGV[0] )
|
|
|
|
control_data = ''
|
2007-03-09 15:46:46 -05:00
|
|
|
File.open( File.dirname(__FILE__) + "/#{sf.name.downcase}-controls.csv", "r") { |f| control_data = f.read }
|
2007-02-14 14:56:16 -05:00
|
|
|
sf.parse control_data
|
|
|
|
|
|
|
|
@result = ""
|
|
|
|
erb = ERB.new( cc_template , 0, "%<>-", "@result" )
|
|
|
|
erb.result
|
|
|
|
File.open( "#{sf.name.downcase}_surface.cc", "w" ) { |f| f.write @result }
|
|
|
|
|
|
|
|
erb = ERB.new( h_template , 0, "%<>-", "@result" )
|
|
|
|
erb.result
|
|
|
|
File.open( "#{sf.name.downcase}_surface.h", "w" ) { |f| f.write @result }
|
|
|
|
|