@@ -327,10 +327,26 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
327
327
enterBlockType ( ctx ) {
328
328
if ( this . currentContext instanceof DNMethodContext ) {
329
329
this . currentContext . returnType = 'Block'
330
+ } else if ( this . currentContext instanceof DNArgumentContext ) {
331
+ this . currentContext . isBlock = true
332
+ this . currentContext . blockRetType = null
333
+ this . currentContext . blockArgTypes = [ ]
334
+ this . currentContext . blockArgNames = [ ]
330
335
}
331
336
}
332
337
// Exit a parse tree produced by ObjectiveCParser#blockType.
333
338
exitBlockType ( ctx ) {
339
+ if ( this . currentContext instanceof DNArgumentContext ) {
340
+ var blockArgs = ''
341
+ this . currentContext . blockArgTypes . forEach ( ( argType , index ) => {
342
+ var argName = this . currentContext . blockArgNames [ index ]
343
+ if ( argName && argType ) {
344
+ blockArgs += argType + ' ' + argName + ', '
345
+ }
346
+ } )
347
+ blockArgs = '(' + blockArgs . substring ( 0 , blockArgs . length - 2 ) + ')' // remove ', ' symbol
348
+ this . currentContext . type += this . currentContext . blockRetType + ' ' + this . currentContext . name + blockArgs
349
+ }
334
350
}
335
351
// Enter a parse tree produced by ObjectiveCParser#genericsSpecifier.
336
352
enterGenericsSpecifier ( ctx ) {
@@ -377,25 +393,9 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
377
393
}
378
394
// Enter a parse tree produced by ObjectiveCParser#blockParameters.
379
395
enterBlockParameters ( ctx ) {
380
- if ( this . currentContext instanceof DNArgumentContext ) {
381
- this . currentContext . isBlock = true
382
- this . currentContext . blockArgTypes = [ ]
383
- this . currentContext . blockArgNames = [ ]
384
- }
385
396
}
386
397
// Exit a parse tree produced by ObjectiveCParser#blockParameters.
387
398
exitBlockParameters ( ctx ) {
388
- if ( this . currentContext instanceof DNArgumentContext ) {
389
- var blockArgs = ''
390
- this . currentContext . blockArgTypes . forEach ( ( argType , index ) => {
391
- var argName = this . currentContext . blockArgNames [ index ]
392
- if ( argName && argType ) {
393
- blockArgs += argType + ' ' + argName + ', '
394
- }
395
- } )
396
- blockArgs = '(' + blockArgs . substring ( 0 , blockArgs . length - 2 ) + ')' // remove ', ' symbol
397
- this . currentContext . type += ' ' + this . currentContext . name + blockArgs
398
- }
399
399
}
400
400
// Enter a parse tree produced by ObjectiveCParser#typeVariableDeclaratorOrName.
401
401
enterTypeVariableDeclaratorOrName ( ctx ) {
@@ -754,8 +754,13 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
754
754
if ( ! this . currentContext . isBlock ) {
755
755
let isArgInBlock = this . currentContext . parent instanceof DNBlockDefContext
756
756
this . currentContext . type = TC . convert ( type , isArgInBlock )
757
- } else {
758
- this . currentContext . blockArgTypes . push ( type )
757
+ } else {
758
+ let convertedType = TC . convert ( type , true )
759
+ if ( ! this . currentContext . blockRetType ) {
760
+ this . currentContext . blockRetType = convertedType
761
+ } else {
762
+ this . currentContext . blockArgTypes . push ( convertedType )
763
+ }
759
764
}
760
765
// case:(NSError ** )error
761
766
this . currentContext . isOutParam = isPointer2Pointer
0 commit comments