class RubimCode::Printer

Attributes

sandbox[RW]

Public Class Methods

code_type() click to toggle source
# File lib/rubimc/printer.rb, line 100
def self.code_type
        if not Controllers.all.empty?
                "avr-gcc" 
        elsif Controllers.all.empty? and eval("self.private_methods.include? :main")
                "gcc"
        else
                RubimCode.perror "Can not to define type of code"
        end
end
generate_cc() click to toggle source
# File lib/rubimc/printer.rb, line 169
def self.generate_cc
        if Controllers.all.count > 1
                RubimCode.perror "In current version in one file you can define only one Controller Class"
        end

        if self.code_type == "avr-gcc" # if compile program for MCU
                Controllers.all.each do |mcu_class|
                        print_layout(:before_main) do
                                mcu_class.mcu_layout if mcu_class.respond_to? :mcu_layout
                        end
                        mcu = mcu_class.new # print initialize section
                        print_main_loop {mcu.main_loop} # print body of main loop
                        print_layout(:after_main) 
                        RubimCode::Interrupts.print()
                        RubimCode::Printer.print_instance_vars()
                end # each Controllers.all

        elsif self.code_type == "gcc" # if compile clear-C program
                if Controllers.all.empty? and eval("self.private_methods.include? :main")
                        print_layout(:before_main)
                        eval("main(RubimCode::CC_ARGS.new)") # execute user`s method :main (CC_ARGS - helper for C agruments argc/argv)
                        print_layout(:after_main)
                end
        end
end
instance_vars_cc() click to toggle source
# File lib/rubimc/printer.rb, line 80
def self.instance_vars_cc
        @@instance_vars_cc
end
mcu_type() click to toggle source
# File lib/rubimc/printer.rb, line 110
def self.mcu_type
        code_type == "avr-gcc" ? Controllers.all.first::MCU_NAME : "undefined"
end
pout_destination() click to toggle source
# File lib/rubimc/printer.rb, line 85
def self.pout_destination
        @@pout_destination
end
pout_destination=(dest) click to toggle source
# File lib/rubimc/printer.rb, line 88
def self.pout_destination=(dest)
        if dest.nil?
                perror "Wrong parameter for method #{__method__}. Set destination string"
        end

        if dest.class.name == "String" or dest.in? [:default, :h_file] # dest.is_a?(String) not work...WTF
                @@pout_destination = dest
        else
                perror "Wrong parameter for method #{__method__}. Only string variable or ':default' value is permit as a parameters"
        end
end
print_instance_vars() click to toggle source
print_layout(position) { || ... } click to toggle source
print_main_loop() { || ... } click to toggle source