summaryrefslogtreecommitdiffhomepage
path: root/lib/yard/mruby/code_objects/function_object.rb
blob: 35b8e4f766e26485fd857b926ddead7c5ad09120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module YARD::MRuby::CodeObjects

  # A FunctionObject represents a MRuby C API function declaration inside a header inside an include directory
  class FunctionObject < HeaderBaseObject

    # Returns the list of parameters parsed out of the method signature
    # with their default values.
    #
    # @return [Array<Array(String, String)>] a list of parameter names followed
    #   by their default values (or nil)
    attr_accessor :parameters

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

    def attr_info
      nil
    end

    def scope
      ''
    end

    def return_type
      obj.tag(:return).types.first
    end

    def return_type=(type)
      return if type == 'void'
      add_tag(YARD::Tags::Tag.new(:return,"", "")) unless has_tag?(:return)
      tag(:return).types = [type]
    end


    # Returns all alias names of the object
    # @return [Array<Symbol>] the alias names
    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
  end
end