summaryrefslogtreecommitdiff
path: root/NaturalDocs/ObjC.pm
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-08-29 16:26:18 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-08-29 16:26:18 +0200
commitb7dd2dfe91dd1f6ef9b0a4fed64360c816f0b1b2 (patch)
treeadeea596c250807f4065f3893ac1a7c483434be5 /NaturalDocs/ObjC.pm
parent6db2297be23390eb580e4632e9968dab80a22ea6 (diff)
Add Natural Docs configuration.
Diffstat (limited to 'NaturalDocs/ObjC.pm')
-rwxr-xr-xNaturalDocs/ObjC.pm93
1 files changed, 93 insertions, 0 deletions
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;