Class: Burn::Generator::RomBuilder
- Inherits:
-
Object
- Object
- Burn::Generator::RomBuilder
- Defined in:
- lib/burn/generator/rom_builder.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(workspace_root) ⇒ RomBuilder
constructor
A new instance of RomBuilder.
- #load(dsl_raw_text) ⇒ Object
- #method_missing(method_symbol, *args, &block) ⇒ Object
- #verbose(flag) ⇒ Object
Methods included from Debug
Constructor Details
#initialize(workspace_root) ⇒ RomBuilder
Returns a new instance of RomBuilder.
8 9 10 11 12 13 14 |
# File 'lib/burn/generator/rom_builder.rb', line 8 def initialize(workspace_root) @workspace_root = workspace_root @game_generator = CSource.new(@workspace_root) @music_generator = AssemblyMusic.new(@workspace_root) @sound_effect_generator = AssemblySoundEffect.new(@workspace_root) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_symbol, *args, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/burn/generator/rom_builder.rb', line 30 def method_missing(method_symbol, *args, &block) log :method_symbol=>method_symbol, :args=>args, :block=>block if method_symbol == :music then Music.new(args[0], @music_generator.get_context).instance_eval(&block) elsif method_symbol == :scene then # preprocess args[0] = "main" if args[0].nil? @game_generator.get_context.instance_exec args[0], &lambda{|resource_name| [ "", "//#{resource_name} label starts", "#{resource_name}:" ].each {|p| @code_blocks.push p} } # execute dsls Scene.new(args[0], @game_generator.get_context).instance_eval(&block) # postprocess - To deal with the case of on_enter_frame not found, adding while loop at the end of program @game_generator.get_context.instance_exec {@code_blocks.push "ppu_on_all();", "while(1);"} elsif method_symbol == :declare then Declare.new(args[0], @game_generator.get_context).instance_eval(&block) elsif method_symbol == :sound then Sound.new(args[0], @sound_effect_generator.get_context).instance_eval(&block) # postprocess @game_generator.get_context.instance_exec(@sound_effect_generator.resources.count-1) do |count| @global.push "#define SFX_#{args[0].upcase} #{count.to_s}" end end end |
Instance Method Details
#generate ⇒ Object
24 25 26 27 28 |
# File 'lib/burn/generator/rom_builder.rb', line 24 def generate @game_generator.generate @music_generator.generate @sound_effect_generator.generate end |
#load(dsl_raw_text) ⇒ Object
20 21 22 |
# File 'lib/burn/generator/rom_builder.rb', line 20 def load(dsl_raw_text) self.instance_eval dsl_raw_text end |