@@ -235,7 +235,8 @@ def parse_typeref_type(definition:, function_name:, typeref_field:, filepath:, l
235235 typeref_field . gsub ( /[A-Z_]+\s *\( \( .*\) \) / , "" ) . gsub ( "RUBY_SYMBOL_EXPORT_BEGIN" , "" )
236236 else
237237 # parse typeref in definition
238- definition [ 0 ...definition . index ( function_name ) ] . gsub ( "char *" , "char*" ) . strip
238+ type = definition [ 0 ...definition . index ( function_name ) ] || ""
239+ type . gsub ( "char *" , "char*" ) . strip
239240 end
240241
241242 typeref_type = Util . sanitize_type ( typeref_type )
@@ -301,7 +302,8 @@ def generate_argument_definition(function_name:, arg:, arg_pos:)
301302 # - length [Integer]
302303 def analyze_argument_type ( function_name :, arg_pos :, parts :)
303304 pointer , length = prepare_argument_parts ( arg_pos :, parts :)
304- original_type = Util . sanitize_type ( parts [ 0 ...-1 ] . join ( " " ) )
305+ type = parts [ 0 ...-1 ] || [ ]
306+ original_type = Util . sanitize_type ( type . join ( " " ) )
305307
306308 case original_type
307309 when /\* +$/
@@ -329,27 +331,30 @@ def analyze_argument_type(function_name:, arg_pos:, parts:)
329331 # - pointer [Symbol,nil]
330332 # - length [Integer]
331333 def prepare_argument_parts ( parts :, arg_pos :)
332- pointer = nil
333- length = 0
334-
335334 if parts [ -1 ] =~ /\[ ([0-9]+)?\] $/
336335 parts [ -1 ] . gsub! ( /\[ ([0-9]+)?\] $/ , "" )
337336 length = ::Regexp . last_match ( 1 ) . to_i
338- pointer = :array
337+
338+ unless parts [ -1 ] =~ /^[0-9a-zA-Z_]+$/
339+ # last elements isn't dummy argument
340+ parts << "arg#{ arg_pos } "
341+ end
342+
343+ return [ :array , length ]
339344 end
340345
341346 unless parts [ -1 ] =~ /^[0-9a-zA-Z_]+$/
342347 # last elements isn't dummy argument
343348 parts << "arg#{ arg_pos } "
344349 end
345350
346- [ pointer , length ]
351+ [ nil , 0 ]
347352 end
348353
349354 # @param type [String]
350355 def pointer_length ( type )
351356 type =~ /(\* +)$/
352- ::Regexp . last_match ( 1 ) . length
357+ ::Regexp . last_match ( 1 ) & .length || 0
353358 end
354359 end
355360end
0 commit comments