From 728481bbf48b2665702fd3678bcdd938a2cacec1 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 29 Aug 2008 17:30:12 +0200 Subject: NaturalDocs/ObjC.pm: Make the prototype parser aware of ordinary C function prototypes. --- NaturalDocs/ObjC.pm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'NaturalDocs') diff --git a/NaturalDocs/ObjC.pm b/NaturalDocs/ObjC.pm index ad726a1..64b948d 100755 --- a/NaturalDocs/ObjC.pm +++ b/NaturalDocs/ObjC.pm @@ -69,10 +69,13 @@ sub ParsePrototype $_ = $prototype; if ($topic_type == ::TOPIC_FUNCTION and /([-+]\s*\((.*?)\)\s*)(.*)/) { + # An Objective-C method. my $return_type = $2; my $p = NaturalDocs::Languages::Prototype->New ($1, ""); my $args_p = 0; + # FIXME: This doesn't work for argument types that contain commas. + # We should use a recursive-descent parser or something... $_ = $3; while (/(\S+)\((.*?)\)\s*(\S+)(?:(\s+(.*))?|$)/) { @@ -95,8 +98,33 @@ sub ParsePrototype return NaturalDocs::Languages::Prototype->New ($prototype, ""); } } + elsif ($topic_type == ::TOPIC_FUNCTION and /((?:\S+\s+)?\S+\s*)\((.*)\)/) + { + # An ordinary C function. + my $p = NaturalDocs::Languages::Prototype->New ("$1 (", ")"); + + # FIXME: Same as the FIXME above. (It's even hairier here because + # something like “char *str” is read as a variable called “*str” + # whose type is “char”. (Actually, this isn't quite that wrong + # either, as “*str” _is_, in fact, of type char in this case -- by + # design! Still, it's hard to parse...)) + $_ = $2; + while (/(.+?)\s*(\S+)\s*(?:,(.*)|$)/) + { + $p->AddParameter (NaturalDocs::Languages::Prototype::Parameter->New ($1, + undef, + $2, + undef, + undef, + undef)); + $_ = $3; + } + + return $p; + } else { + print "Nope.\n$prototype\n"; return $self->SUPER::ParsePrototype ($topic_type, $prototype); } }; -- cgit v1.2.3