Class: YARD::MRuby::CodeObjects::FunctionObject
- Inherits:
-
HeaderBaseObject
- Object
- CodeObjects::Base
- HeaderBaseObject
- YARD::MRuby::CodeObjects::FunctionObject
- 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
-
#parameters ⇒ Array<Array(String, String)>
Returns the list of parameters parsed out of the method signature with their default values.
Instance Method Summary collapse
-
#aliases ⇒ Array<Symbol>
Returns all alias names of the object.
- #attr_info ⇒ Object
-
#initialize(header, name, &block) ⇒ FunctionObject
constructor
A new instance of FunctionObject.
- #parameter_types ⇒ Object
- #parse_parameter_types(parameters) ⇒ Object
- #return_type ⇒ Object
- #return_type=(type) ⇒ Object
- #scope ⇒ Object
Methods inherited from HeaderBaseObject
Constructor Details
#initialize(header, name, &block) ⇒ 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
#parameters ⇒ Array<Array(String, String)>
Returns the list of parameters parsed out of the method signature with their default values.
12 13 14 |
# File 'lib/yard/mruby/code_objects/function_object.rb', line 12 def parameters @parameters end |
Instance Method Details
#aliases ⇒ Array<Symbol>
Returns all alias names of the object
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_info ⇒ Object
18 19 20 |
# File 'lib/yard/mruby/code_objects/function_object.rb', line 18 def attr_info nil end |
#parameter_types ⇒ Object
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_type ⇒ Object
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 |
#scope ⇒ Object
22 23 24 |
# File 'lib/yard/mruby/code_objects/function_object.rb', line 22 def scope '' end |