Module: Raudi::Source::Variable

Included in:
Base
Defined in:
lib/raudi/source/variable.rb

Instance Method Summary collapse

Instance Method Details

#generate_variable(variable) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/raudi/source/variable.rb', line 7

def generate_variable(variable)
  source = ""

  [:static, :const, :unsigned].each do |prefix|
    source << "#{prefix} " if variable[prefix] or variable[prefix.to_s]
  end

  source << variable[:type].to_s
  source << ' '

  variable[:pointer] ||= variable[:array]
  if variable[:pointer]
    variable[:pointer] = 1 unless variable[:pointer].is_a?(Integer)
    source << ('*' * variable[:pointer])
  end

  source << variable[:name].to_s
  source
end