summaryrefslogtreecommitdiff
path: root/NaturalDocs/ObjC.pm
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-29 16:35:14 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-29 16:35:14 +0200
commit43921ef49a4c9a4acf2182728c60a52f71dd95ec (patch)
tree1c3e41ad1f10e191746c7f50dbcde1c5e12d0a1e /NaturalDocs/ObjC.pm
parent63eadba1c4ed6e92aeda0a0691e0ac97ce580a43 (diff)
parentea78de039ba122180ac0fe7ffbdca4073342ad0c (diff)
Merge mulk_benkard@ssh.phx.nearlyfreespeech.net:/home/htdocs/code/mulklisp
Diffstat (limited to 'NaturalDocs/ObjC.pm')
-rwxr-xr-xNaturalDocs/ObjC.pm104
1 files changed, 104 insertions, 0 deletions
diff --git a/NaturalDocs/ObjC.pm b/NaturalDocs/ObjC.pm
new file mode 100755
index 0000000..ad726a1
--- /dev/null
+++ b/NaturalDocs/ObjC.pm
@@ -0,0 +1,104 @@
+###############################################################################
+#
+# Class: NaturalDocs::Languages::ObjC
+#
+###############################################################################
+#
+# Handle Objective-C.
+#
+###############################################################################
+
+## 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;
+
+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)
+ {
+ 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) = @_;
+
+ $_ = $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+(.*))?|$)/)
+ {
+ $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;