@@ -291,20 +291,7 @@ def generate_argument_definition(function_name:, arg:, arg_pos:)
291
291
# - pointer [Symbol]
292
292
# - length [Integer]
293
293
def analyze_argument_type ( function_name :, arg_pos :, parts :)
294
- pointer = nil
295
- length = 0
296
-
297
- if parts [ -1 ] =~ /\[ ([0-9]+)?\] $/
298
- parts [ -1 ] . gsub! ( /\[ ([0-9]+)?\] $/ , "" )
299
- length = ::Regexp . last_match ( 1 ) . to_i
300
- pointer = :array
301
- end
302
-
303
- unless parts [ -1 ] =~ /^[0-9a-zA-Z_]+$/
304
- # last elements isn't dummy argument
305
- parts << "arg#{ arg_pos } "
306
- end
307
-
294
+ pointer , length = prepare_argument_parts ( arg_pos :, parts :)
308
295
original_type = Util . sanitize_type ( parts [ 0 ...-1 ] . join ( " " ) )
309
296
310
297
case original_type
@@ -326,6 +313,30 @@ def analyze_argument_type(function_name:, arg_pos:, parts:)
326
313
[ type , pointer , length ]
327
314
end
328
315
316
+ # @param arg_pos [Integer]
317
+ # @param parts [Array<String>]
318
+ #
319
+ # @return [Array<Symbol, Integer>]
320
+ # - pointer [Symbol,nil]
321
+ # - length [Integer]
322
+ def prepare_argument_parts ( parts :, arg_pos :)
323
+ pointer = nil
324
+ length = 0
325
+
326
+ if parts [ -1 ] =~ /\[ ([0-9]+)?\] $/
327
+ parts [ -1 ] . gsub! ( /\[ ([0-9]+)?\] $/ , "" )
328
+ length = ::Regexp . last_match ( 1 ) . to_i
329
+ pointer = :array
330
+ end
331
+
332
+ unless parts [ -1 ] =~ /^[0-9a-zA-Z_]+$/
333
+ # last elements isn't dummy argument
334
+ parts << "arg#{ arg_pos } "
335
+ end
336
+
337
+ [ pointer , length ]
338
+ end
339
+
329
340
# @param type [String]
330
341
def pointer_length ( type )
331
342
type =~ /(\* +)$/
0 commit comments