From 4cf5aceb8f3b33ebda40225beb054b834ddfa4af Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 24 Aug 2008 20:26:51 +0200 Subject: MLKMacroCallForm: Handle macro functions returning no values more gracefully. --- MLKForm.m | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'MLKForm.m') diff --git a/MLKForm.m b/MLKForm.m index 848dab3..78d1ff2 100644 --- a/MLKForm.m +++ b/MLKForm.m @@ -207,13 +207,21 @@ inContext:context forCompiler:compiler]; + id expansion; + id macrofun = [context macroForSymbol:_head]; //NSLog (@"Expanding: %@", MLKPrintToString (_form)); - id expansion = denullify ([[macrofun - applyToArray: - [NSArray arrayWithObjects: - _form, context, nil]] - objectAtIndex:0]); + NSArray *expansion_values = [macrofun applyToArray: + [NSArray arrayWithObjects: + _form, context, nil]]; + if ([expansion_values count] > 0) + { + expansion = denullify ([expansion_values objectAtIndex:0]); + } + else + { + expansion = nil; + } //NSLog (@"=> %@", MLKPrintToString (expansion)); return LRETAIN ([MLKForm formWithObject:expansion -- cgit v1.2.3