#!/usr/bin/perl # $Header: /home/cvs/objc_lib/bin/objcdoc,v 1.3 2000/12/08 00:06:05 djedi Exp $ # Usage : objcdoc FILE.h ... # La sortie se fait sur la sortie standard. # $state: # 0 hors commentaire # 1 dans commentaire print " Objective-C Doc Valvassori Moïse djedi\@altern.org

"; foreach $file (@ARGV) { open (f,$file); $state = 0; foreach $i () { if ($state == 0) { # hors commentaire if ($i =~ /^\@interface/) { # interface analyse_interface($i); &reset_comm; } elsif ($i =~ /^[-+]/) { # léthode analyse_method($i); } elsif ($i =~ /\/\*\*/) { # commentaire $state = 1; $comm = ""; } elsif ($i =~ /^\@end/) { # fin print "\n"; } } elsif ($state == 1) { # dans un commentaire if ($i =~ /\*\//) { $state = 0; } elsif ($i =~ /\s*\@author\s+(.*)$/) { $author = $1; } elsif ($i =~ /\s*\@return\s+(.*)$/) { $return = $1; } elsif ($i =~ /\s*\@param\s+(\w+)\s+(.*)$/) { $param{$1}=$2; } else { $comm = "$comm $i"; } } } close(f); } print "

"; sub analyse_interface { local ($i) = @_; if ($i =~ /^\@interface\s+(\w+)\s*:\s*(\w+)/) { print " $1 $2

$comm"; if ($author ne "") { print "

Auteur: $author\n"; } print"

"; } } sub analyse_method { local ($l) = @_; local @p,$prefix; local $i; if ($l =~ /^([-+])(\(\w+\s*\*?\))?\s*(\w+)\s*:?([^;]*);/){ print " $1\n"; print "$2\n"; print "$3\n"; @p = split(/:/, $4); foreach $i (@p) { $i =~ /(\(\w+\s*\*?\))?\s*(\w+)\s*(\w+)?/; if ($2 ne ""){ print "\n"; if ($prefix ne ""){ print "$prefix\n"; } if ($2 eq "") { print "id\n"; } else { print "$1\n"; } print "$2\n"; if ($param{$2} ne "") { print "

"; print $param{$2}; print "

\n"; } print "
\n"; $prefix = $3; } } print "

$comm

"; if ($return ne "") { print "

Return

$return

"; } print "
\n"; print "
\n"; &reset_comm; } } sub reset_comm { $comm =""; $author = ""; $return = ""; $param =""; }