diff options
| author | Seba Gamboa <[email protected]> | 2015-09-29 12:26:52 -0300 |
|---|---|---|
| committer | Seba Gamboa <[email protected]> | 2015-09-29 12:26:52 -0300 |
| commit | b8602d593eff73609e2f2682375f546f61b58f73 (patch) | |
| tree | 3628717151b604383024e5680928ddeea19a9a2c /lib/yard/mruby/code_objects | |
| parent | be49b0e4472afbc98c386f1c14afd1598ee14d16 (diff) | |
| download | yard-mruby-b8602d593eff73609e2f2682375f546f61b58f73.tar.gz yard-mruby-b8602d593eff73609e2f2682375f546f61b58f73.zip | |
parse parameter types
Diffstat (limited to 'lib/yard/mruby/code_objects')
| -rw-r--r-- | lib/yard/mruby/code_objects/function_object.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/yard/mruby/code_objects/function_object.rb b/lib/yard/mruby/code_objects/function_object.rb index 35b8e4f..2fdc0b7 100644 --- a/lib/yard/mruby/code_objects/function_object.rb +++ b/lib/yard/mruby/code_objects/function_object.rb @@ -2,6 +2,7 @@ module YARD::MRuby::CodeObjects # A FunctionObject represents a MRuby C API function declaration inside a header inside an include directory class FunctionObject < HeaderBaseObject + ParameterType = Struct.new(:type,:name) # Returns the list of parameters parsed out of the method signature # with their default values. @@ -23,13 +24,27 @@ module YARD::MRuby::CodeObjects end def return_type - obj.tag(:return).types.first + @return_type end def return_type=(type) - return if type == 'void' - add_tag(YARD::Tags::Tag.new(:return,"", "")) unless has_tag?(:return) - tag(:return).types = [type] + @return_type = (type == 'void' ? nil : type) + end + + def parameter_types + @parameter_types || [] + end + + def parse_parameter_types(parameters) + @parameter_types = [] + return if parameters.match /^\s*void\s*$/ + + parameters.split(',').each do |parameter| + parameter.scan(/((:?struct\s+)?\w+(:?\s*\*)?)\s*(\w+)?/) do |type,_,_,name| + @parameter_types << ParameterType.new(type,name) + end + end + end |
