Permalink
Browse files

Merge pull request #2 from nickl-/master

Maintenance fixes
  • Loading branch information...
CloCkWeRX committed Jan 13, 2013
2 parents a0f4545 + 2cfa862 commit 8ae131c9ff230fb841e051afdceede7c1219cf64
View
17 CodeGen/PECL/Cli.php 100755 → 100644
@@ -14,31 +14,28 @@
$command = new CodeGen_PECL_Command($extension, "pecl-gen");
if ($command->options->have("experimental", "x")) {
- echo "the --experimental (-x) option has been deprecated
+ echo "the --experimental (-x) option has been deprecated
please use the 'version' attribute of the <extension> tag
to select version-specific features
";
exit(3);
}
-
-
+
if ($command->options->have("function"))
{
- $command->singleFunction();
- exit(0);
+ $command->singleFunction();
+ exit(0);
}
// ext_skel compatibility?
if ($command->options->have("extname")) {
- $command->extSkelCompat();
- exit(0);
-}
-
+ $command->extSkelCompat();
+ exit(0);
+}
$parser = new CodeGen_PECL_ExtensionParser($extension);
$command->execute($parser);
-?>
View
@@ -1,6 +1,6 @@
<?php
/**
- * Command wrapper class
+ * Command wrapper class
*
* PHP versions 5
*
@@ -27,12 +27,11 @@
require_once "CodeGen/PECL/Extension.php";
require_once "CodeGen/PECL/ExtensionParser.php";
-
/**
* Command wrapper class
*
- * This class wraps up the functionality needed for the
- * command line script.
+ * This class wraps up the functionality needed for the
+ * command line script.
*
* @category Tools and Utilities
* @package CodeGen
@@ -53,7 +52,7 @@ class CodeGen_PECL_Command
function __construct(CodeGen_Extension $extension)
{
parent::__construct($extension);
-
+
if ($this->options->have("linespecs")) {
$this->extension->setLinespecs(true);
}
@@ -68,15 +67,15 @@ function commandOptions()
{
list($shortOptions, $longOptions) = parent::commandOptions();
- $longOptions= array_merge($longOptions, array("extname=",
- "full-xml",
+ $longOptions= array_merge($longOptions, array("extname=",
+ "full-xml",
"function=",
"linespecs",
"no-help",
"proto=",
- "skel=",
- "stubs=",
- "xml=="));
+ "skel=",
+ "stubs=",
+ "xml=="));
return array($shortOptions, $longOptions);
}
@@ -89,13 +88,13 @@ function commandOptions()
function showUsage($message = false)
{
$fp = fopen("php://stderr", "w");
-
+
if ($message) fputs($fp, "$message\n\n");
-
+
fputs($fp, "Usage:
pecl-gen [-h] [--force] [--experimental] [--version]
- [--extname=name] [--proto=file] [--skel=dir] [--stubs=file]
+ [--extname=name] [--proto=file] [--skel=dir] [--stubs=file]
[--no-help] [--xml[=file]] [--full-xml] [--function=proto] [specfile.xml]
-h|--help this message
@@ -108,7 +107,7 @@ function showUsage($message = false)
--version show version info
the following options are inherited from ext_skel:
- --extname=module module is the name of your extension
+ --extname=module module is the name of your extension
--proto=file file contains prototypes of functions to create
--xml generate xml documentation to be added to phpdoc-cvs
@@ -119,20 +118,19 @@ function showUsage($message = false)
these are accepted for backwards compatibility reasons but not used ...
--full-xml generate xml documentation for a self-contained extension
- (this was also a no-op in ext_skel)
+ (this was also a no-op in ext_skel)
--skel=dir path to the skeleton directory
(skeleton stuff is now self-contained)
");
fclose($fp);
}
-
/**
* Generate just a single function stub file
*
*/
- function singleFunction()
+ function singleFunction()
{
$func = new CodeGen_PECL_Element_Function;
@@ -141,23 +139,23 @@ function singleFunction()
$err = $func->setProto(trim($this->options->value("function")), $this->extension);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
- }
-
+ }
+
$err = $this->extension->addFunction($func);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
-
+
echo $this->extension->publicFunctionsC();
-
+
echo "\n\n/*----------------------------------------------------------------------*/\n\n";
-
+
foreach ($this->extension->getFunctions() as $name => $function) {
echo sprintf("\tPHP_FE(%-20s, NULL)\n", $name);
}
-
+
echo "\n\n/*----------------------------------------------------------------------*/\n\n";
-
+
foreach ($this->extension->getFunctions() as $name => $function) {
echo "PHP_FUNCTION($name);\n";
}
@@ -170,96 +168,97 @@ function singleFunction()
function extSkelCompat()
{
$extname = $this->options->value("extname");
-
+
$err = $this->extension->setName($extname);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
-
+
if ($this->options->have("proto")) {
$proto_file = $this->options->value("proto");
-
+
if (!file_exists($proto_file) || !is_readable($proto_file)) {
- $this->terminate("cannot open proto file");
+ $this->terminate("cannot open proto file");
}
-
+
foreach (file($proto_file) as $line) {
$func = new CodeGen_PECL_Element_Function;
$func->setRole("public");
- $err = $func->setProto(trim($line));
+ $err = $func->setProto(trim($line), $this->extension);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
- }
-
+ }
+
$err = $this->extension->addFunction($func);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
}
}
-
+
if ($this->options->have("stubs")) {
$stubname = $this->options->value("stubs");
-
+
if (file_exists("$stubname") && !$this->options->have("f", "force")) {
- $this->terminate("'$stubname' already exists (use '--force' to overwrite)");
+ $this->terminate("'$stubname' already exists (use '--force' to overwrite)");
}
-
+
$fp = fopen($stubname, "w");
fputs($fp, $this->extension->publicFunctionsC());
-
+
fputs($fp, "\n\n/*----------------------------------------------------------------------*/\n\n");
-
+
foreach ($this->extension->functions as $name => $function) {
fputs($fp, sprintf("\tPHP_FE(%-20s, NULL)\n", $name));
}
-
+
fputs($fp, "\n\n/*----------------------------------------------------------------------*/\n\n");
-
+
foreach ($this->extension->functions as $name => $function) {
fputs($fp, "PHP_FUNCTION($name);\n");
}
-
+
fclose($fp);
-
+
echo "$stubname successfully written\n";
} else {
if (file_exists("./$extname") && !$this->options->have("f", "force")) {
- $this->terminate("'$extname' already exists, can't create directory (use '--force' to override)");
+ $this->terminate("'$extname' already exists, can't create directory (use '--force' to override)");
}
-
+
$err = System::mkdir($extname);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
-
+
$this->extension->dirpath = realpath("./$extname");
-
+
$err = $this->extension->generateSource("./$extname");
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
-
+
if ($this->options->have("xml")) {
$manpath = "$extname/manual/". str_replace('_', '-', $extname);
-
+
$err = System::mkdir("-p $manpath");
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
-
+
$err = $this->extension->generateDocumentation($manpath);
if (PEAR::isError($err)) {
$this->terminate($err->getMessage());
}
}
-
+
$this->extension->writeReadme("./$extname");
-
+
if (!$this->options->have("quiet")) {
echo $this->extension->successMsg();
}
}
}
}
+
Oops, something went wrong.

0 comments on commit 8ae131c

Please sign in to comment.