#!/usr/local/bin/php class=$name; $this->functions=array(); $this->properties=array(); $this->constants=array(); $this->parmas=array(); } function add_content($content) { if ($content->type==0) { if (!in_array($content->name,$this->properties)) { $this->properties[]=$content->name; $this->readonly[$content->name]=$content->readonly; } } elseif ($content->type==1) { if (!in_array($content->name,$this->functions)) { $this->functions[]=$content->name; $this->params[$content->name]=$content->params; } } elseif ($content->type==2) { if (!in_array($content->name,$this->constants)) $this->constants[]=$content->name; } } function to_text() { $headline=$this->class." (".(sizeof($this->properties))." Properties and ".(sizeof($this->functions))." Functions and ".(sizeof($this->constants))." Constants)"; echo($headline."\n"); echo("===================="); echo("\n\n"); echo("Properties\n"); echo("----------\n"); for ($i=0;$iproperties);$i++) { echo($this->properties[$i]."\n"); } echo("\n"); echo("Functions\n"); echo("----------\n"); for ($i=0;$ifunctions);$i++) { echo($this->functions[$i]."\n"); } echo("\n"); echo("Constants\n"); echo("----------\n"); for ($i=0;$iconstants);$i++) { echo($this->constants[$i]."\n"); } echo("\n%%%%%%%%%%%%%%%%%%%%%%%%\n\n"); } function to_html() { echo("class."\">"); echo("Back to Index"); echo("\n"); echo("\n"); if (sizeof($this->functions)>0) { echo("\n"); for ($i=0;$ifunctions);$i++) { echo("\n"); } } if (sizeof($this->properties)>0) { echo("\n"); for ($i=0;$iproperties);$i++) { if ($this->readonly[$this->properties[$i]]) $readonly="Property is ReadOnly"; else $readonly="Property is ReadWrite"; echo("\n"); } } if (sizeof($this->constants)>0) { echo("\n"); for ($i=0;$iconstants);$i++) { echo("\n"); } } echo("

".$this->class."

Functions

 ".$this->functions[$i]."".$this->params[$this->functions[$i]]." Parameter(s)

Properties

 ".$this->properties[$i]."$readonly

Constants

 ".$this->constants[$i]."


"); } function to_svg(&$x,&$y) { $xtemp=$x+50; $ytemp=$y+50; echo("".$this->class.""); $ytemp+=10; if (sizeof($this->functions)>0) { echo("Functions\n"); $ytemp+=10; for ($i=0;$ifunctions);$i++) { echo("".$this->functions[$i]." with ".$this->params[$this->functions[$i]]." Parameter(s)\n"); $ytemp+=10; } } if (sizeof($this->properties)>0) { echo("Properties\n"); $ytemp+=10; for ($i=0;$iproperties);$i++) { if ($this->readonly[$this->properties[$i]]) $readonly="Property is ReadOnly"; else $readonly="Property is ReadWrite"; echo("".$this->properties[$i]." $readonly\n"); $ytemp+=10; } } if (sizeof($this->constants)>0) { echo("Constants\n"); $ytemp+=10; for ($i=0;$iconstants);$i++) { echo("".$this->constants[$i]."\n"); $ytemp+=10; } } $x=$xtemp+200; } } class kalyptus_result { var $class; var $type; // 0 = Property ; 1 = Function ; 2 = Constant var $name; var $params; var $readonly; function kalyptus_result($class,$type,$name,$params=0) { $this->class=$class; $this->type=$type; $this->name=$name; $this->params=$params; } function setReadOnly($value) { $this->readonly=$value; } } function parse_kalyptus($line,&$fp,&$last_constructor) { if (preg_match("/^[ \t^#]*([a-zA-Z_]*)[ \t]*KSVG::.*DontDelete/",$line,$match)) { if (DEBUG) fputs($fp,"MATCH => Constant ".$match[1]." in class ".$match[2]."\n"); return new kalyptus_result($last_constructor,2,$match[1]); } elseif (preg_match("/^[ \t^#]*([a-zA-Z_]*)[ \t]*([a-zA-Z_]*)::.*Function ([0-9])/",$line,$match)) { if (DEBUG) fputs($fp,"MATCH => Function ".$match[1]." in class ".$match[2]."\n"); return new kalyptus_result($match[2],1,$match[1],$match[3]); } elseif (preg_match("/^[ \t^#]*([a-zA-Z_]*)[ \t]*([a-zA-Z_]*)::.*DontDelete\|ReadOnly/",$line,$match)) { if (DEBUG) fputs($fp,"MATCH => Property ".$match[1]." in class ".$match[2]."\n"); $property=new kalyptus_result($match[2],0,$match[1]); $property->setReadOnly(true); return $property; } elseif (preg_match("/^[ \t^#]*([a-zA-Z_]*)[ \t]*([a-zA-Z_]*)::.*DontDelete/",$line,$match)) { if (DEBUG) fputs($fp,"MATCH => Property ".$match[1]." in class ".$match[2]."\n"); $property=new kalyptus_result($match[2],0,$match[1]); $property->setReadOnly(false); return $property; } elseif (preg_match("/^[ \t@begin^#]*([a-zA-Z_]*)Constructor::s_hashTable.*/",$line,$match)) { if (DEBUG) fputs($fp,"Constructor => ".$match[1]."\n"); $last_constructor=$match[1]; return false; } else { if (DEBUG) fputs($fp,"Ignored => ".$line."\n"); return false; } } function do_output($output,$ecma_classes) { ksort($ecma_classes); reset($ecma_classes); switch($output) { case "txt": foreach ($ecma_classes as $classname => $obj) { $obj->to_text(); } break; case "svg": echo("\n"); $x=0; $y=0; foreach ($ecma_classes as $classname => $obj) { $obj->to_svg($x,$y); } echo(""); break; default: echo("\n\n"); echo("

Contents


\n"); foreach ($ecma_classes as $classname => $obj) { echo("$classname
\n"); } echo("
\n"); foreach ($ecma_classes as $classname => $obj) { $obj->to_html(); } echo("\n"); } } function searchKalyptusCode($file,&$fp) { global $ecma_classes; ob_start(); readfile($file); $content=ob_get_contents(); ob_end_clean(); if (preg_match("/@begin(.*)@end/s",$content,$matches)) // FIXME broken....if several @end's are there it takes always the last { if (DEBUG) fputs($fp,"Found ".(sizeof($matches)-1)." Matches in ".$file."\n"); for ($i=1;$iclass]) $ecma_classes[$results[$i]->class]->add_content($results[$i]); else { $ecma_classes[$results[$i]->class]=new ecma_class($results[$i]->class); $ecma_classes[$results[$i]->class]->add_content($results[$i]); } } } } function crawlFiles($path) { global $ecma_classes; $fp=fopen("php://stderr","w+"); if ($dir = @opendir($path)) { while (($file = readdir($dir)) !== false) { if (($file!=".") && ($file!="..")) { if (is_dir($path."/".$file)) { fputs($fp,"Entering directory ".$file."\n"); crawlFiles($path."/".$file); fputs($fp,"Leaving directory ".$file."\n"); } elseif (is_file($path."/".$file) && preg_match("/^[A-Za-z0-9_]+(\.cc|\.cpp|\.h|\.hpp)$/",$file)) { fputs($fp,"\tchecking $file\n"); searchKalyptusCode($path."/".$file,$fp); } } } closedir($dir); } } define(DEBUG,0); $ecma_classes=array(); $ksvg_path="../"; $path=basename(realpath($ksvg_path)); if ($path!="ksvg") { echo "Execute it in base ksvg dir please :S\n"; return false; } crawlFiles($ksvg_path); do_output($argv[1],$ecma_classes); ?>