cvs: pecl /PECL_Gen Extension.php

From: Date: Thu, 11 Nov 2004 15:17:58 +0000
Subject: cvs: pecl /PECL_Gen Extension.php
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-2014@lists.php.net to get a copy of this message
hholzgra Thu Nov 11 10:17:58 2004 EDT Modified files: /pecl/PECL_Gen Extension.php Log: - GPL is now available as a license, make sure PECL_Gen does not accept it - moved up "#include <php>", needs to be put above "#ifdef HAVE_..." this is needed for static builds - add_test() now checks class of parameter - --force no longer removes the target directory so CVS dirs will survive - some methods didn't have PHPDoc headers http://cvs.php.net/diff.php/pecl/PECL_Gen/Extension.php?r1=1.7&r2=1.8&ty=u Index: pecl/PECL_Gen/Extension.php diff -u pecl/PECL_Gen/Extension.php:1.7 pecl/PECL_Gen/Extension.php:1.8 --- pecl/PECL_Gen/Extension.php:1.7 Tue Nov 9 14:07:30 2004 +++ pecl/PECL_Gen/Extension.php Thu Nov 11 10:17:56 2004 @@ -16,7 +16,7 @@ // | Authors: Hartmut Holzgraefe <hholzgra@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Extension.php,v 1.7 2004/11/09 19:07:30 hholzgra Exp $ +// $Id: Extension.php,v 1.8 2004/11/11 15:17:56 hholzgra Exp $ // // {{{ includes @@ -49,12 +49,23 @@ * A class that generates PECL extension soure and documenation files * * @access public - * @version $Id: Extension.php,v 1.7 2004/11/09 19:07:30 hholzgra Exp $ + * @version $Id: Extension.php,v 1.8 2004/11/11 15:17:56 hholzgra Exp $ */ class PECL_Gen_Extension extends PEAR { + /** + * Current version number + * + * @access public + * @return string version + */ + static function version() + { + return "0.8.2"; + } + // {{{ member variables /** @@ -260,6 +271,13 @@ // }}} + + /** + * Set extension base name + * + * @access public + * @param string name + */ function set_name($name) { if (! PECL_Gen_Element::is_name($name)) { @@ -270,18 +288,36 @@ return true; } + /** + * Set extension summary text + * + * @access public + * @param string short summary + */ function set_summary($text) { $this->summary = $text; return true; } + /** + * Set extension documentation text + * + * @access public + * @param string long description + */ function set_description($text) { $this->description = $text; return true; } + /** + * Set the programming language to produce code for + * + * @access public + * @param string programming language name + */ function set_language($lang) { switch (strtolower($lang)) { @@ -300,6 +336,12 @@ return $this->raiseError("'$lang' is not a supported implementation language"); } + /** + * Set target platform for generated code + * + * @access public + * @param string platform name + */ function set_platform($type) { $this->platform = new PECL_Gen_Tools_Platform($type); @@ -311,6 +353,14 @@ } + /** + * Add verbatim code snippet to extension + * + * @access public + * @param string which file to put the code to + * @param string where in the file the code should be put + * @param string the actual code + */ function add_code($role, $position, $code) { if (!in_array($role, array("header", "code"))) { @@ -569,8 +619,12 @@ */ function set_license($license) { + if ($license->shortname == "GPL") { + return $this->raiseError("The GPL is no valid choice for PHP extensions due to license incompatibilities"); + } + $this->license = $license; - + return true; } @@ -623,14 +677,8 @@ } // purge and create extension directory - if (file_exists($dirpath)) { - if ($force) { - if (!is_writeable($dirpath) || !@System::rm("-rf $dirpath")) { - return $this->raiseError("can't purge '$dirpath'"); - } - } else { - return $this->raiseError("'$dirpath' already exists, can't create that directory (use '--force' to override)"); - } + if (!$force && file_exists($dirpath)) { + return $this->raiseError("'$dirpath' already exists, can't create that directory (use '--force' to override)"); } if (!@System::mkdir("-p $dirpath")) { return $this->raiseError("can't create '$dirpath'"); @@ -1028,9 +1076,10 @@ #include "config.h" #endif +#include <php.h> + #ifdef HAVE_'.$upname.' -#include <php.h> #include <php_ini.h> #include <SAPI.h> #include <ext/standard/info.h> @@ -1752,7 +1801,6 @@ - /** * Write authors to the CREDITS file * @@ -1882,10 +1930,26 @@ // }}} + /** + * add a custom test case + * + * @access public + * @param object a Test object + */ function add_test($test) { - $this->testcases[] = $test; + if (! is_a($test, "PECL_Gen_Element_Test")) { + return $this->raiseError("Parameter is not a PECL_Gen Test instance"); + } + + $this->testcases[$test->name] = $test; + return true; } + /** + * Write test case files + * + * @access private + */ function write_test_files() { @mkdir("$this->name/tests"); @@ -1894,7 +1958,7 @@ $function->write_test($this); } - // custom test cases + // custom test cases (may overwrite custom function test cases foreach ($this->testcases as $test) { $test->write_test($this); } @@ -2097,17 +2161,6 @@ } - /** - * Current version number - * - * @access public - * @return string version - */ - static function version() - { - return "0.8.2"; - } - }

« previous php.pecl.cvs (#2014) next »