Class: Rbind::GeneratorExtern
- Inherits:
-
Object
- Object
- Rbind::GeneratorExtern
- Defined in:
- lib/rbind/generator_extern.rb
Defined Under Namespace
Classes: Config
Instance Attribute Summary collapse
-
#file_prefix ⇒ Object
Returns the value of attribute file_prefix.
-
#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, file_prefix = @file_prefix) ⇒ Object
-
#initialize(root) ⇒ GeneratorExtern
constructor
A new instance of GeneratorExtern.
Constructor Details
#initialize(root) ⇒ GeneratorExtern
Returns a new instance of GeneratorExtern.
14 15 16 |
# File 'lib/rbind/generator_extern.rb', line 14 def initialize(root) @root = root end |
Instance Attribute Details
#file_prefix ⇒ Object
Returns the value of attribute file_prefix.
9 10 11 |
# File 'lib/rbind/generator_extern.rb', line 9 def file_prefix @file_prefix end |
#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
10 11 12 |
# File 'lib/rbind/generator_extern.rb', line 10 def self.normalize_type_name(name) name.gsub('::','.') end |
Instance Method Details
#generate(path = @output_path, ruby_module_name = @ruby_module_name, file_prefix = @file_prefix) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rbind/generator_extern.rb', line 18 def generate(path = @output_path,ruby_module_name = @ruby_module_name,file_prefix = @file_prefix) @output_path = path @ruby_module_name = ruby_module_name @file_prefix = file_prefix 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,file_prefix).to_yaml end |