From b7dd2dfe91dd1f6ef9b0a4fed64360c816f0b1b2 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 29 Aug 2008 16:26:18 +0200 Subject: Add Natural Docs configuration. --- NaturalDocs/ObjC.pm | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 NaturalDocs/ObjC.pm (limited to 'NaturalDocs/ObjC.pm') diff --git a/NaturalDocs/ObjC.pm b/NaturalDocs/ObjC.pm new file mode 100755 index 0000000..2c78478 --- /dev/null +++ b/NaturalDocs/ObjC.pm @@ -0,0 +1,93 @@ +############################################################################### +# +# Class: NaturalDocs::Languages::ObjC +# +############################################################################### +# +# Handle Objective-C. +# +############################################################################### + +use strict; +use integer; + +package NaturalDocs::Languages::ObjC; + +use base 'NaturalDocs::Languages::Simple'; +use NaturalDocs::Languages; + +sub OnCode +{ + my ($self, $codeLines, $codeLineNumber, $topicList, $lastCommentTopicCount) = @_; + $self->SUPER::OnCode ($codeLines, $codeLineNumber, $topicList, $lastCommentTopicCount); + + my $topic = $topicList->[-1]; + my $line = $codeLines->[0]; + if ($lastCommentTopicCount) + { + #print "$topic\n"; + #print "$line\n"; + unless ($topic->Prototype()) + { + my $code = join ("\n", @{$codeLines}); + if ($topic->Type() eq ::TOPIC_FUNCTION()) + { + if ($code =~ /\s*([-+].*)[;{]/) + { + $topic->SetPrototype($1); + } + } + elsif ($topic->Type() eq ::TOPIC_CLASS()) + { + if ($code =~ /\s*(\@interface.*\n)/) + { + $topic->SetPrototype($1); + } + } + } + } +}; + +sub ParsePrototype +{ + my ($self, $topic_type, $prototype) = @_; + + #print "$prototype\n"; + + $_ = $prototype; + if ($topic_type == ::TOPIC_FUNCTION and /([-+]\s*\((.*?)\)\s*)(.*)/) + { + my $return_type = $2; + my $p = NaturalDocs::Languages::Prototype->New ($1, ""); + my $args_p = 0; + + $_ = $3; + while (/(\S+)\((.*?)\)\s*(\S+)(?:(\s+(.*))?|$)/) + { + #print "$4, $1, $2, $3\n"; + $p->AddParameter (NaturalDocs::Languages::Prototype::Parameter->New ("($2)", + $1, + $3, + "", + "", + "")); + $args_p = 1; + $_ = $4; + } + + if ($args_p) + { + return $p; + } + else + { + return NaturalDocs::Languages::Prototype->New ($prototype, ""); + } + } + else + { + return $self->SUPER::ParsePrototype ($topic_type, $prototype); + } +}; + +1; -- cgit v1.2.3 From a25471b0c682c4e0f04bef536da5c8f248d25c4f Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 29 Aug 2008 16:27:36 +0200 Subject: NaturalDocs/ObjC.pm: Add copyright notice. --- NaturalDocs/ObjC.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'NaturalDocs/ObjC.pm') diff --git a/NaturalDocs/ObjC.pm b/NaturalDocs/ObjC.pm index 2c78478..ad726a1 100755 --- a/NaturalDocs/ObjC.pm +++ b/NaturalDocs/ObjC.pm @@ -8,6 +8,22 @@ # ############################################################################### +## Copyright 2008, Matthias Andreas Benkard. +## +## This package is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This package is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this package; if not, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + use strict; use integer; @@ -25,8 +41,6 @@ sub OnCode my $line = $codeLines->[0]; if ($lastCommentTopicCount) { - #print "$topic\n"; - #print "$line\n"; unless ($topic->Prototype()) { my $code = join ("\n", @{$codeLines}); @@ -52,8 +66,6 @@ sub ParsePrototype { my ($self, $topic_type, $prototype) = @_; - #print "$prototype\n"; - $_ = $prototype; if ($topic_type == ::TOPIC_FUNCTION and /([-+]\s*\((.*?)\)\s*)(.*)/) { @@ -64,7 +76,6 @@ sub ParsePrototype $_ = $3; while (/(\S+)\((.*?)\)\s*(\S+)(?:(\s+(.*))?|$)/) { - #print "$4, $1, $2, $3\n"; $p->AddParameter (NaturalDocs::Languages::Prototype::Parameter->New ("($2)", $1, $3, -- cgit v1.2.3