Hosted by
|
#!/usr/bin/php -qC <?php
// $Date: 2004/03/08 11:11:40 $ // $Revision: 1.24 $ // $Author: jcrocholl $
require('ado-read.php');
function load_cvs_header($filename, &$header, &$hash) { $result = ''; $header = ''; $hash = '';
$header .= '-- $' . 'Date$' . "\n"; $header .= '-- $' . 'Revision$' . "\n"; $header .= '-- $' . 'Author$' . "\n"; if (!file_exists($filename)) return; $input = file($filename);
$line = array_shift($input); if (!preg_match('/^--\s+\$Date/', $line)) return; $result .= $line;
$line = array_shift($input); if (!preg_match('/^--\s+\$Revision/', $line)) return; $result .= $line;
$line = array_shift($input); if (!preg_match('/^--\s+\$Author/', $line)) return; $result .= $line;
$line = array_shift($input); if (preg_match('/^--\s+\$Hash: (\S+)/', $line, $m)) $hash = $m[1];
$header = $result; }
function write_if_changed($content, $oldheader, $oldhash, $filename) { $newhash = md5($content); if ($newhash == $oldhash) { // print "skipped $filename (no changes)\n"; return; }
global $auto_header; $content = $oldheader . "-- \$Hash: $newhash \$\n" . $auto_header . $content;
if (!$filehandle = fopen($filename, 'w')) die("could not open $filename with write access\n"); if (!fwrite($filehandle, $content)) die("could not write $filename\n"); fclose($filehandle); print "updated $filename\n"; }
$adsfilename = "$filepath$filestem.ads"; $adbfilename = "$filepath$filestem.adb";
load_cvs_header($adsfilename, $adsheader, $adshash); load_cvs_header($adbfilename, $adbheader, $adbhash);
if ($extends) { $with = "with Ada.Tags; use Ada.Tags;\n" . $with; } $ads .= $with; $ads .= "package $package is\n"; $ads .= "\n"; $ads .= $pre_public; $ads .= " -- Public representation.\n"; if ($extends) { $ads .= " type $object is new $extends with private;\n"; $ads .= "\n"; $ads .= " -- Work-around for GNAT bug.\n"; $ads .= " " . $object . "_Tag : constant String;\n"; } else { $ads .= " type $object is$abstract$tagged limited private;\n"; } $ads .= "\n"; $ads .= " -- Pointer to representation data.\n";
if ($tagged) $ads .= " type $object_access is access all $object'Class;\n"; else $ads .= " type $object_access is access all $object;\n";
// $ads .= "\n"; // $ads .= " -- Value for uninitialized or empty instances.\n"; // $ads .= " Null_$object_access : constant $object_access := null;\n";
$ads .= "\n"; $ads .= $post_public; $ads .= $ads_methods; $ads .= "\n"; $ads .= "private\n"; $ads .= "\n"; $ads .= $pre_private; $ads .= " -- Private representation.\n"; if ($extends) { if ($attributes) { $ads .= " type $object is\n"; $ads .= " new $extends with\n"; $ads .= " record\n"; $ads .= $attributes; $ads .= " end record;\n"; } else { $ads .= " type $object is\n"; $ads .= " new $extends with null record;\n"; } $ads .= "\n"; $ads .= " -- Work-around for GNAT bug.\n"; // $ads .= " " . $object . "_Tag : constant Tag := $object'Tag;\n"; $external_tag = strtolower("$package.$object"); $ads .= " " . $object . "_Tag : constant String := \"$external_tag\";\n"; } else { if ($attributes) { $ads .= " type $object is$abstract$tagged limited record\n"; $ads .= $attributes; $ads .= " end record;\n"; } else { $ads .= " type $object is$abstract$tagged limited null record;\n"; } } $ads .= "\n"; $ads .= "end $package;\n"; write_if_changed($ads, $adsheader, $adshash, $adsfilename);
if (!$adb_methods) exit;
$adb .= $body_with; $adb .= "package body $package is\n"; $adb .= "\n"; $adb .= $adb_methods; $adb .= "\n"; $adb .= "end $package;\n"; write_if_changed($adb, $adbheader, $adbhash, $adbfilename);
?>
|