Class: Rbind::GeneratorExtern
- Inherits:
-
Object
- Object
- Rbind::GeneratorExtern
- Defined in:
- lib/rbind/generator_extern.rb
Defined Under Namespace
Classes: Config
Instance Attribute Summary collapse
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#ruby_module_name ⇒ Object
Returns the value of attribute ruby_module_name.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(path = @output_path, ruby_module_name = @ruby_module_name) ⇒ Object
-
#initialize(root) ⇒ GeneratorExtern
constructor
A new instance of GeneratorExtern.
Constructor Details
#initialize(root) ⇒ GeneratorExtern
Returns a new instance of GeneratorExtern.
13 14 15 |
# File 'lib/rbind/generator_extern.rb', line 13 def initialize(root) @root = root end |
Instance Attribute Details
#output_path ⇒ Object
Returns the value of attribute output_path.
7 8 9 |
# File 'lib/rbind/generator_extern.rb', line 7 def output_path @output_path end |
#ruby_module_name ⇒ Object
Returns the value of attribute ruby_module_name.
8 9 10 |
# File 'lib/rbind/generator_extern.rb', line 8 def ruby_module_name @ruby_module_name end |
Class Method Details
.normalize_type_name(name) ⇒ Object
9 10 11 |
# File 'lib/rbind/generator_extern.rb', line 9 def self.normalize_type_name(name) name.gsub('::','.') end |
Instance Method Details
#generate(path = @output_path, ruby_module_name = @ruby_module_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rbind/generator_extern.rb', line 17 def generate(path = @output_path,ruby_module_name = @ruby_module_name) @output_path = path @ruby_module_name = ruby_module_name FileUtils.mkdir_p(path) if path && !File.directory?(path) file_extern = File.new(File.join(path,"extern.rbind"),"w") file_config = File.new(File.join(path,"config.rbind"),"w") @root.each_type do |t| if t.is_a? RClass file_extern.write "class #{GeneratorExtern.normalize_type_name(t.full_name)} /Extern\n" elsif t.is_a? RStruct file_extern.write "struct #{GeneratorExtern.normalize_type_name(t.full_name)} /Extern\n" end end @root.each_const do |c| file_extern.write "const #{GeneratorExtern.normalize_type_name(c.full_name)} /Extern\n" end file_extern.write("\n") file_config.write Config.new(ruby_module_name).to_yaml end |