Method: CSquare::Generator::Index#declaration

Defined in:
lib/csquare/generator/index.rb

#declaration(type_id = nil) ⇒ Object

Return the function pointer array declaration. Count is optional.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/csquare/generator/index.rb', line 149

def declaration type_id=nil
  # Figure out the function pointer type
  sig            = common_signature(type_id)

  unnamed_params = sig.params.map { |p| p.name = nil; p.to_s }.join(", ")

  # Figure out how many [][][] to include and what values to enclose in them
  array_portion = begin
    str = ""
    @on.each_pair do |enum_id, enum_obj|
      str += "[#{enum_obj.enumerees.size}]"
    end
    str
  end

  "#{sig.type.to_s} (*#{decorated_basename(type_id)}#{array_portion})(#{unnamed_params.to_s})"
end