Class: YARD::MRuby::CodeObjects::FunctionObject

Inherits:
HeaderBaseObject
  • Object
show all
Defined in:
lib/yard/mruby/code_objects/function_object.rb

Overview

A FunctionObject represents a MRuby C API function declaration inside a header inside an include directory

Defined Under Namespace

Classes: ParameterType

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HeaderBaseObject

#header, #path

Constructor Details

#initialize(header, name, &block) ⇒ FunctionObject

Returns a new instance of FunctionObject.



14
15
16
# File 'lib/yard/mruby/code_objects/function_object.rb', line 14

def initialize(header, name, &block)
  super
end

Instance Attribute Details

#parametersArray<Array(String, String)>

Returns the list of parameters parsed out of the method signature with their default values.

Returns:

  • (Array<Array(String, String)>)

    a list of parameter names followed by their default values (or nil)



12
13
14
# File 'lib/yard/mruby/code_objects/function_object.rb', line 12

def parameters
  @parameters
end

Instance Method Details

#aliasesArray<Symbol>

Returns all alias names of the object

Returns:

  • (Array<Symbol>)

    the alias names



62
63
64
65
66
67
68
69
# File 'lib/yard/mruby/code_objects/function_object.rb', line 62

def aliases
  list = []
  return list unless namespace.is_a?(HeaderObject)
  namespace.aliases.each do |o, aname|
    list << o if aname == name && o.scope == scope
  end
  list
end

#attr_infoObject



18
19
20
# File 'lib/yard/mruby/code_objects/function_object.rb', line 18

def attr_info
  nil
end

#parameter_typesObject



43
44
45
# File 'lib/yard/mruby/code_objects/function_object.rb', line 43

def parameter_types
  @parameter_types || []
end

#parse_parameter_types(parameters) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/yard/mruby/code_objects/function_object.rb', line 47

def parse_parameter_types(parameters)
  @parameter_types = []
  return if parameters.match /^\s*void\s*$/

  parameters.split(',').each do |parameter|
    parameter.scan(/((?:const\s+)?(?:struct\s+)?(?:\w+|\.\.\.)(?:\s*\*)?)\s*(\w+)?/) do |type,name|
      @parameter_types << ParameterType.new(type,name)
    end
  end

end

#return_typeObject



26
27
28
# File 'lib/yard/mruby/code_objects/function_object.rb', line 26

def return_type
  @return_type
end

#return_type=(type) ⇒ Object



30
31
32
# File 'lib/yard/mruby/code_objects/function_object.rb', line 30

def return_type=(type)
  @return_type = (type == 'void' ? nil : type)
end

#scopeObject



22
23
24
# File 'lib/yard/mruby/code_objects/function_object.rb', line 22

def scope
  ''
end