diff --git a/Modules/HeaderDoc/HeaderElement.pm b/Modules/HeaderDoc/HeaderElement.pm index 531d8c7..8db6ccd 100644 --- a/Modules/HeaderDoc/HeaderElement.pm +++ b/Modules/HeaderDoc/HeaderElement.pm @@ -3,7 +3,7 @@ # Class name: HeaderElement # Synopsis: Root class for Function, Typedef, Constant, etc. -- used by HeaderDoc. # -# Last Updated: $Date: 2014/03/06 09:31:57 $ +# Last Updated: $Date: 2014/03/06 11:05:55 $ # # Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved. # @@ -388,7 +388,7 @@ if ($^O =~ /MacOS/io) { # In the git repository, contains the number of seconds since # January 1, 1970. # */ -$HeaderDoc::HeaderElement::VERSION = '$Revision: 1394127117 $'; +$HeaderDoc::HeaderElement::VERSION = '$Revision: 1394132755 $'; # /*! # @abstract @@ -5198,9 +5198,11 @@ sub documentationBlock if ($self->lang eq "applescript" && $class eq "HeaderDoc::Function") { if (!$self->{ASCONTENTSPROCESSED}) { $class_self = $self->processAppleScriptFunctionContents(); - my @classes = $class_self->classes(); - foreach my $obj (@classes) { - push(@embeddedClasses, $obj); + if ($class_self) { + my @classes = $class_self->classes(); + foreach my $obj (@classes) { + push(@embeddedClasses, $obj); + } } } } @@ -9517,11 +9519,16 @@ sub cloneAppleScriptFunctionContents my $orig_ptref = $self->{PARSETREE}; bless($orig_ptref, "HeaderDoc::ParseTree"); my $parseTree = ${$orig_ptref}; + + $parseTree = $parseTree->ASFunctionBodyStart(); + my $tree = $parseTree->clone(); + $tree->parserState($self->{PARSERSTATE}); # Don't copy the name here, because it hasn't been set yet, but copy # the parse tree, because otherwise it gets stomped. $class_self->{PARSETREE} = \$tree; + $class_self->{PARSERSTATE} = $self->{PARSERSTATE}; $class_self->{SUBLANG} = $self->{SUBLANG}; $class_self->{APIOWNER} = $self->{APIOWNER}; $class_self->{FILENAME} = $self->{FILENAME}; @@ -9587,6 +9594,16 @@ sub processAppleScriptFunctionContents bless($ptref, "HeaderDoc::ParseTree"); my $parseTree = ${$ptref}; + # Process the embedded tags and write out the contents. + $parseTree->processEmbeddedTags($xml_output, $class_self); + + # print STDERR "PROCESSED ".$class_self->name()."\n"; + my @has_classes = $class_self->classes(); + # print STDERR "WRITING ".scalar(@has_classes)." CLASSES\n"; + if (!scalar(@has_classes)) { + return undef; + } + # Compute the name of the directory where the contents should be written (in HTML mode) if (!$xml_output) { my $className = $class_self->name(); @@ -9594,22 +9611,19 @@ sub processAppleScriptFunctionContents if (1 || $isMacOS) {$className = &safeName(filename => $className);}; $className = "parsedFunctionContents_$className"; - my $classesDir = $self->apiOwner()->classesDir(); + # my $classesDir = $self->apiOwner()->classesDir(); - if (!$HeaderDoc::running_test) { - if (! -e $classesDir) { - unless (mkdir ("$classesDir", 0777)) {die ("Can't create output folder $classesDir. \n$!");}; - } - } + # if (!$HeaderDoc::running_test) { + # if (! -e $classesDir) { + # unless (mkdir ("$classesDir", 0777)) {die ("Can't create output folder $classesDir. \n$!");}; + # } + # } my $classRootDir = $self->apiOwner()->{OUTPUTDIR}; $class_self->outputDir("$classRootDir$pathSeparator$className"); $class_self->{PARSEDPSEUDOCLASSNAME} = $className; } - # Process the embedded tags and write out the contents. - $parseTree->processEmbeddedTags($xml_output, $class_self); - # Write the output (in HTML mode) if (!$xml_output) { if ($class_self->classes()) { diff --git a/Modules/HeaderDoc/ParseTree.pm b/Modules/HeaderDoc/ParseTree.pm index e0405e4..ac11b91 100644 --- a/Modules/HeaderDoc/ParseTree.pm +++ b/Modules/HeaderDoc/ParseTree.pm @@ -2,7 +2,7 @@ # # Class name: ParseTree # Synopsis: Used by headerdoc2html to hold parse trees -# Last Updated: $Date: 2014/03/05 14:20:14 $ +# Last Updated: $Date: 2014/03/06 11:20:09 $ # # Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved. # @@ -177,7 +177,7 @@ use Carp qw(cluck); # In the git repository, contains the number of seconds since # January 1, 1970. # */ -$HeaderDoc::ParseTree::VERSION = '$Revision: 1394058014 $'; +$HeaderDoc::ParseTree::VERSION = '$Revision: 1394133609 $'; ################ General Constants ################################### my $debugging = 0; @@ -1089,6 +1089,13 @@ sub processEmbeddedTags my $hashtreecur = undef; my $hashtreeroot = undef; + print STDERR "BEFORE APIOprocessEmbeddedTagsRec for $apio (".$apio->name().")\n" if ($localDebug > 1); + print STDERR "PS: $parserState\n" if ($localDebug > 1); + cluck("bt\n") if ($localDebug > 1); + $self->dbprint() if ($localDebug > 1); + # $self->printTree() if ($localDebug > 1); + + $self->APIOprocessEmbeddedTagsRec($apiOwner, $case_sensitive, \%parseTokens, $lastnode, 0, 1, $enable_javadoc_comments, $xmlmode, $apio->lang(), $apio->sublang(), $hashtreecur, $hashtreeroot); } else { print STDERR "calling processEmbeddedTagsRec for $apio (".$apio->name().") for parse tree $self.\n" if ($localDebug); @@ -5310,4 +5317,37 @@ sub translateTreeRec { print STDERR "Returning.\n" if ($localDebug); return \%state; } + +# /*! +# @abstract Returns the first token inside the body of an AppleScript +# function. +# */ +sub ASFunctionBodyStart +{ + my $self = shift; + + my $localDebug = 0; + + while ($self && + ($self->token() ne "\n") && + ($self->token() ne "\r") && + ($self->token() ne "(")) { + print STDERR "SKIPPING ".$self->token()." (LOOP 1)\n" if ($localDebug); + $self = $self->next(); + } + while ($self && + ($self->token() eq "\n") || + ($self->token() eq "\r") || + ($self->token() eq "(")) { + print STDERR "SKIPPING ".$self->token()." (LOOP 2)\n" if ($localDebug); + $self = $self->next(); + } + + print STDERR "RETURNING TREE.\n" if ($localDebug); + $self->dbprint() if ($localDebug); + + return $self; +} + + 1;