Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert "This project is no longer maintained within PEAR CVS,"

This reverts commit 3579cec.
  • Loading branch information...
commit d1498dac431edfb234af2629cc563bc3d353de46 1 parent 3579cec
Daniel O'Connor CloCkWeRX authored

Showing 78 changed files with 22,292 additions and 4 deletions. Show diff stats Hide diff stats

  1. +68 0 LICENSE
  2. +265 0 PECL/Command.php
  3. +267 0 PECL/Dependency/Extension.php
  4. +73 0 PECL/Dependency/Header.php
  5. +123 0 PECL/Dependency/Lib.php
  6. +84 0 PECL/Dependency/Platform.php
  7. +425 0 PECL/Dependency/With.php
  8. +158 0 PECL/Element.php
  9. +669 0 PECL/Element/Class.php
  10. +244 0 PECL/Element/ClassConstant.php
  11. +353 0 PECL/Element/Constant.php
  12. +1,660 0 PECL/Element/Function.php
  13. +294 0 PECL/Element/Global.php
  14. +451 0 PECL/Element/Ini.php
  15. +307 0 PECL/Element/Interface.php
  16. +261 0 PECL/Element/Logo.php
  17. +466 0 PECL/Element/Method.php
  18. +9 0 PECL/Element/ObjectInterface.php
  19. +232 0 PECL/Element/Property.php
  20. +356 0 PECL/Element/Resource.php
  21. +241 0 PECL/Element/Stream.php
  22. +464 0 PECL/Element/Test.php
  23. +2,566 0 PECL/Extension.php
  24. +1,369 0 PECL/ExtensionParser.php
  25. +125 0 PECL/Maintainer.php
  26. +127 0 PECL/Release.php
  27. +279 0 PECL/Tools/ProtoLexer.php
  28. +139 0 PECL/Tools/ProtoLexer.plex
  29. +1,292 0 PECL/Tools/ProtoParser.php
  30. +105 0 PECL/Tools/ProtoParser.y
  31. +8 4 README
  32. +90 0 TODO
  33. +8 0 docs/Makefile
  34. +44 0 docs/RFC_proto.txt
  35. +4 0 docs/examples/Makefile
  36. +73 0 docs/examples/README
  37. +45 0 docs/examples/api_functions.xml
  38. +275 0 docs/examples/cairo.xml
  39. +24 0 docs/examples/class_abstract.xml
  40. +25 0 docs/examples/class_constant.xml
  41. +18 0 docs/examples/class_extends.xml
  42. +80 0 docs/examples/class_methods.xml
  43. +69 0 docs/examples/class_methods_abstract.xml
  44. +26 0 docs/examples/class_methods_final.xml
  45. +9 0 docs/examples/class_minimal.xml
  46. +77 0 docs/examples/class_payload.xml
  47. +232 0 docs/examples/class_properties.xml
  48. +47 0 docs/examples/class_type_hints.xml
  49. +9 0 docs/examples/code_pi.xml
  50. +21 0 docs/examples/constants.xml
  51. +11 0 docs/examples/crossext.xml
  52. +70 0 docs/examples/function_by_ref.xml
  53. +41 0 docs/examples/function_type_hints.xml
  54. +31 0 docs/examples/globals.xml
  55. +82 0 docs/examples/interface.xml
  56. +53 0 docs/examples/interface_simple.xml
  57. +5 0 docs/examples/license.xml
  58. +3 0  docs/examples/minimal.xml
  59. +20 0 docs/examples/parsing.xml
  60. +1 0  docs/examples/parsing_1.inc
  61. +3 0  docs/examples/parsing_2.inc
  62. +17 0 docs/examples/phpini.xml
  63. +57 0 docs/examples/release.xml
  64. +56 0 docs/examples/resource.xml
  65. +48 0 docs/examples/resource_cpp.xml
  66. +56 0 docs/examples/resource_old.xml
  67. +3 0  docs/examples/snippet.c
  68. +3 0  docs/examples/snippet1.c
  69. +3 0  docs/examples/snippet2.c
  70. +29 0 docs/examples/test.sh
  71. +37 0 docs/examples/testcase.xml
  72. +8 0 docs/examples/with_1.xml
  73. +194 0 docs/extension.dtd
  74. +4,331 0 docs/manual.html
  75. BIN  docs/manual.pdf
  76. +1,922 0 docs/manual.xml
  77. +504 0 package2.xml
  78. +48 0 pecl-gen
68 LICENSE
... ... @@ -0,0 +1,68 @@
  1 +--------------------------------------------------------------------
  2 + The PHP License, Version 3.0
  3 +Copyright (c) 1999 - 2003 The PHP Group. All rights reserved.
  4 +--------------------------------------------------------------------
  5 +
  6 +Redistribution and use in source and binary forms, with or without
  7 +modification, is permitted provided that the following conditions
  8 +are met:
  9 +
  10 + 1. Redistributions of source code must retain the above copyright
  11 + notice, this list of conditions and the following disclaimer.
  12 +
  13 + 2. Redistributions in binary form must reproduce the above copyright
  14 + notice, this list of conditions and the following disclaimer in
  15 + the documentation and/or other materials provided with the
  16 + distribution.
  17 +
  18 + 3. The name "PHP" must not be used to endorse or promote products
  19 + derived from this software without prior written permission. For
  20 + written permission, please contact group@php.net.
  21 +
  22 + 4. Products derived from this software may not be called "PHP", nor
  23 + may "PHP" appear in their name, without prior written permission
  24 + from group@php.net. You may indicate that your software works in
  25 + conjunction with PHP by saying "Foo for PHP" instead of calling
  26 + it "PHP Foo" or "phpfoo"
  27 +
  28 + 5. The PHP Group may publish revised and/or new versions of the
  29 + license from time to time. Each version will be given a
  30 + distinguishing version number.
  31 + Once covered code has been published under a particular version
  32 + of the license, you may always continue to use it under the terms
  33 + of that version. You may also choose to use such covered code
  34 + under the terms of any subsequent version of the license
  35 + published by the PHP Group. No one other than the PHP Group has
  36 + the right to modify the terms applicable to covered code created
  37 + under this License.
  38 +
  39 + 6. Redistributions of any form whatsoever must retain the following
  40 + acknowledgment:
  41 + "This product includes PHP, freely available from
  42 + <http://www.php.net/>".
  43 +
  44 +THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
  45 +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  46 +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  47 +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
  48 +DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  49 +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  50 +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  51 +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  52 +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  53 +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  54 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  55 +OF THE POSSIBILITY OF SUCH DAMAGE.
  56 +
  57 +--------------------------------------------------------------------
  58 +
  59 +This software consists of voluntary contributions made by many
  60 +individuals on behalf of the PHP Group.
  61 +
  62 +The PHP Group can be contacted via Email at group@php.net.
  63 +
  64 +For more information on the PHP Group and the PHP project,
  65 +please see <http://www.php.net>.
  66 +
  67 +This product includes the Zend Engine, freely available at
  68 +<http://www.zend.com>.
265 PECL/Command.php
... ... @@ -0,0 +1,265 @@
  1 +<?php
  2 +/**
  3 + * Command wrapper class
  4 + *
  5 + * PHP versions 5
  6 + *
  7 + * LICENSE: This source file is subject to version 3.0 of the PHP license
  8 + * that is available through the world-wide-web at the following URI:
  9 + * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10 + * the PHP License and are unable to obtain it through the web, please
  11 + * send a note to license@php.net so we can mail you a copy immediately.
  12 + *
  13 + * @category Tools and Utilities
  14 + * @package CodeGen
  15 + * @author Hartmut Holzgraefe <hartmut@php.net>
  16 + * @copyright 2005, 2006 Hartmut Holzgraefe
  17 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  18 + * @version CVS: $Id$
  19 + * @link http://pear.php.net/package/CodeGen
  20 + */
  21 +
  22 +/**
  23 + * includes
  24 + */
  25 +require_once "CodeGen/Command.php";
  26 +
  27 +require_once "CodeGen/PECL/Extension.php";
  28 +require_once "CodeGen/PECL/ExtensionParser.php";
  29 +
  30 +
  31 +/**
  32 + * Command wrapper class
  33 + *
  34 + * This class wraps up the functionality needed for the
  35 + * command line script.
  36 + *
  37 + * @category Tools and Utilities
  38 + * @package CodeGen
  39 + * @author Hartmut Holzgraefe <hartmut@php.net>
  40 + * @copyright 2005, 2006 Hartmut Holzgraefe
  41 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  42 + * @version Release: @package_version@
  43 + * @link http://pear.php.net/package/CodeGen
  44 + */
  45 +class CodeGen_PECL_Command
  46 + extends CodeGen_Command
  47 +{
  48 + /**
  49 + * Command constructor
  50 + *
  51 + * @param object Extension to work on
  52 + */
  53 + function __construct(CodeGen_Extension $extension)
  54 + {
  55 + parent::__construct($extension);
  56 +
  57 + if ($this->options->have("linespecs")) {
  58 + $this->extension->setLinespecs(true);
  59 + }
  60 + }
  61 +
  62 + /**
  63 + * Add pecl-gen specific command line options
  64 + *
  65 + * @return array extended options
  66 + */
  67 + function commandOptions()
  68 + {
  69 + list($shortOptions, $longOptions) = parent::commandOptions();
  70 +
  71 + $longOptions= array_merge($longOptions, array("extname=",
  72 + "full-xml",
  73 + "function=",
  74 + "linespecs",
  75 + "no-help",
  76 + "proto=",
  77 + "skel=",
  78 + "stubs=",
  79 + "xml=="));
  80 +
  81 + return array($shortOptions, $longOptions);
  82 + }
  83 +
  84 + /**
  85 + * Show usage/help information
  86 + *
  87 + * @param string otpional additional message
  88 + */
  89 + function showUsage($message = false)
  90 + {
  91 + $fp = fopen("php://stderr", "w");
  92 +
  93 + if ($message) fputs($fp, "$message\n\n");
  94 +
  95 + fputs($fp, "Usage:
  96 +
  97 +pecl-gen [-h] [--force] [--experimental] [--version]
  98 + [--extname=name] [--proto=file] [--skel=dir] [--stubs=file]
  99 + [--no-help] [--xml[=file]] [--full-xml] [--function=proto] [specfile.xml]
  100 +
  101 + -h|--help this message
  102 + -f|--force overwrite existing directories
  103 + -d|--dir output directory (defaults to extension name)
  104 + -l|--lint check syntax only, don't create output
  105 + --linespecs generate #line specs
  106 + -x|--experimental deprecated
  107 + --function create a function skeleton from a proto right away
  108 + --version show version info
  109 +
  110 + the following options are inherited from ext_skel:
  111 + --extname=module module is the name of your extension
  112 + --proto=file file contains prototypes of functions to create
  113 + --xml generate xml documentation to be added to phpdoc-cvs
  114 +
  115 + these wait for functionality to be implemented and are ignored for now ...
  116 + --stubs=file generate only function stubs in file
  117 + --no-help don't try to be nice and create comments in the code
  118 + and helper functions to test if the module compiled
  119 +
  120 + these are accepted for backwards compatibility reasons but not used ...
  121 + --full-xml generate xml documentation for a self-contained extension
  122 + (this was also a no-op in ext_skel)
  123 + --skel=dir path to the skeleton directory
  124 + (skeleton stuff is now self-contained)
  125 +");
  126 +
  127 + fclose($fp);
  128 + }
  129 +
  130 +
  131 + /**
  132 + * Generate just a single function stub file
  133 + *
  134 + */
  135 + function singleFunction()
  136 + {
  137 + $func = new CodeGen_PECL_Element_Function;
  138 +
  139 + $func->setRole("public");
  140 +
  141 + $err = $func->setProto(trim($this->options->value("function")), $this->extension);
  142 + if (PEAR::isError($err)) {
  143 + $this->terminate($err->getMessage());
  144 + }
  145 +
  146 + $err = $this->extension->addFunction($func);
  147 + if (PEAR::isError($err)) {
  148 + $this->terminate($err->getMessage());
  149 + }
  150 +
  151 + echo $this->extension->publicFunctionsC();
  152 +
  153 + echo "\n\n/*----------------------------------------------------------------------*/\n\n";
  154 +
  155 + foreach ($this->extension->getFunctions() as $name => $function) {
  156 + echo sprintf("\tPHP_FE(%-20s, NULL)\n", $name);
  157 + }
  158 +
  159 + echo "\n\n/*----------------------------------------------------------------------*/\n\n";
  160 +
  161 + foreach ($this->extension->getFunctions() as $name => $function) {
  162 + echo "PHP_FUNCTION($name);\n";
  163 + }
  164 + }
  165 +
  166 + /**
  167 + * ext-skel compatibility mode
  168 + *
  169 + */
  170 + function extSkelCompat()
  171 + {
  172 + $extname = $this->options->value("extname");
  173 +
  174 + $err = $this->extension->setName($extname);
  175 + if (PEAR::isError($err)) {
  176 + $this->terminate($err->getMessage());
  177 + }
  178 +
  179 + if ($this->options->have("proto")) {
  180 + $proto_file = $this->options->value("proto");
  181 +
  182 + if (!file_exists($proto_file) || !is_readable($proto_file)) {
  183 + $this->terminate("cannot open proto file");
  184 + }
  185 +
  186 + foreach (file($proto_file) as $line) {
  187 + $func = new CodeGen_PECL_Element_Function;
  188 + $func->setRole("public");
  189 + $err = $func->setProto(trim($line));
  190 + if (PEAR::isError($err)) {
  191 + $this->terminate($err->getMessage());
  192 + }
  193 +
  194 + $err = $this->extension->addFunction($func);
  195 + if (PEAR::isError($err)) {
  196 + $this->terminate($err->getMessage());
  197 + }
  198 + }
  199 + }
  200 +
  201 + if ($this->options->have("stubs")) {
  202 + $stubname = $this->options->value("stubs");
  203 +
  204 + if (file_exists("$stubname") && !$this->options->have("f", "force")) {
  205 + $this->terminate("'$stubname' already exists (use '--force' to overwrite)");
  206 + }
  207 +
  208 + $fp = fopen($stubname, "w");
  209 + fputs($fp, $this->extension->publicFunctionsC());
  210 +
  211 + fputs($fp, "\n\n/*----------------------------------------------------------------------*/\n\n");
  212 +
  213 + foreach ($this->extension->functions as $name => $function) {
  214 + fputs($fp, sprintf("\tPHP_FE(%-20s, NULL)\n", $name));
  215 + }
  216 +
  217 + fputs($fp, "\n\n/*----------------------------------------------------------------------*/\n\n");
  218 +
  219 + foreach ($this->extension->functions as $name => $function) {
  220 + fputs($fp, "PHP_FUNCTION($name);\n");
  221 + }
  222 +
  223 + fclose($fp);
  224 +
  225 + echo "$stubname successfully written\n";
  226 + } else {
  227 + if (file_exists("./$extname") && !$this->options->have("f", "force")) {
  228 + $this->terminate("'$extname' already exists, can't create directory (use '--force' to override)");
  229 + }
  230 +
  231 + $err = System::mkdir($extname);
  232 + if (PEAR::isError($err)) {
  233 + $this->terminate($err->getMessage());
  234 + }
  235 +
  236 + $this->extension->dirpath = realpath("./$extname");
  237 +
  238 + $err = $this->extension->generateSource("./$extname");
  239 + if (PEAR::isError($err)) {
  240 + $this->terminate($err->getMessage());
  241 + }
  242 +
  243 + if ($this->options->have("xml")) {
  244 + $manpath = "$extname/manual/". str_replace('_', '-', $extname);
  245 +
  246 + $err = System::mkdir("-p $manpath");
  247 + if (PEAR::isError($err)) {
  248 + $this->terminate($err->getMessage());
  249 + }
  250 +
  251 + $err = $this->extension->generateDocumentation($manpath);
  252 + if (PEAR::isError($err)) {
  253 + $this->terminate($err->getMessage());
  254 + }
  255 + }
  256 +
  257 + $this->extension->writeReadme("./$extname");
  258 +
  259 + if (!$this->options->have("quiet")) {
  260 + echo $this->extension->successMsg();
  261 + }
  262 + }
  263 +
  264 + }
  265 +}
267 PECL/Dependency/Extension.php
... ... @@ -0,0 +1,267 @@
  1 +<?php
  2 +/**
  3 + * Class representing a cross-extension dependency
  4 + *
  5 + * PHP versions 5
  6 + *
  7 + * LICENSE: This source file is subject to version 3.0 of the PHP license
  8 + * that is available through the world-wide-web at the following URI:
  9 + * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10 + * the PHP License and are unable to obtain it through the web, please
  11 + * send a note to license@php.net so we can mail you a copy immediately.
  12 + *
  13 + * @category Tools and Utilities
  14 + * @package CodeGen
  15 + * @author Hartmut Holzgraefe <hartmut@php.net>
  16 + * @copyright 2005, 2006 Hartmut Holzgraefe
  17 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  18 + * @version CVS: $Id$
  19 + * @link http://pear.php.net/package/CodeGen
  20 + */
  21 +
  22 +/**
  23 + * include
  24 + */
  25 +require_once "CodeGen/PECL/Element.php";
  26 +
  27 +/**
  28 + * Class representing a cross-extension dependency
  29 + *
  30 + * @category Tools and Utilities
  31 + * @package CodeGen
  32 + * @author Hartmut Holzgraefe <hartmut@php.net>
  33 + * @copyright 2005, 2006 Hartmut Holzgraefe
  34 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  35 + * @version Release: @package_version@
  36 + * @link http://pear.php.net/package/CodeGen
  37 + */
  38 +class CodeGen_PECL_Dependency_Extension
  39 + extends CodeGen_Element
  40 +{
  41 + /**
  42 + * Extension name
  43 + *
  44 + * @var string
  45 + */
  46 + protected $name;
  47 +
  48 + /**
  49 + * name getter
  50 + *
  51 + * @return string
  52 + */
  53 + function getName()
  54 + {
  55 + return $this->name;
  56 + }
  57 +
  58 + /**
  59 + * name setter
  60 + *
  61 + * @param string
  62 + */
  63 + function setName($name)
  64 + {
  65 + if (!$this->isName($name)) {
  66 + PEAR::raiseError("'$name' is not a valid extension name ");
  67 + }
  68 +
  69 + $this->name = $name;
  70 + }
  71 +
  72 +
  73 + /**
  74 + * Extension version relation
  75 + *
  76 + * @var array
  77 + */
  78 + protected $version = array();
  79 +
  80 + /**
  81 + * version setter
  82 + *
  83 + * @param string
  84 + */
  85 + function setVersion($version, $relation = "ge")
  86 + {
  87 + switch ($relation) {
  88 + case "ge":
  89 + case "le":
  90 + case "gt":
  91 + case "lt":
  92 + case "eq":
  93 + break;
  94 +
  95 + case ">=":
  96 + $relation = "ge";
  97 + break;
  98 +
  99 + case ">":
  100 + $relation = "gt";
  101 + break;
  102 +
  103 + case "<=":
  104 + $relation = "le";
  105 + break;
  106 +
  107 + case "<":
  108 + $relation = "lt";
  109 + break;
  110 +
  111 + case "=":
  112 + case "==":
  113 + $relation = "eq";
  114 + break;
  115 +
  116 + default:
  117 + return PEAR::raiseError("'$relation' is not a valid version relation ");
  118 + }
  119 +
  120 + // TODO check version string
  121 +
  122 + $this->version = array("version" => $version, "relation" => $relation);
  123 + }
  124 +
  125 +
  126 + /**
  127 + * Extension name
  128 + *
  129 + * @var string
  130 + */
  131 + protected $type = "REQUIRED";
  132 +
  133 + /**
  134 + * type setter
  135 + *
  136 + * @param string
  137 + */
  138 + function setType($type)
  139 + {
  140 + $type = strtoupper($type);
  141 +
  142 + switch ($type) {
  143 + case "REQUIRED":
  144 + case "OPTIONAL":
  145 + case "CONFLICTS":
  146 + $this->type = $type;
  147 + break;
  148 + default:
  149 + return PEAR::raiseError("'$type' is not a valid dependency type ");
  150 + }
  151 + }
  152 +
  153 + /**
  154 + * Generate extension C code snippet
  155 + *
  156 + * @param object extension
  157 + * @return string code snippet
  158 + */
  159 + function cCode($extension)
  160 + {
  161 + if (!empty($this->version)) {
  162 + return sprintf(' ZEND_MOD_%s_EX("%s", "%s", "%s")', $this->type, $this->name, $this->version["relation"], $this->version["version"])."\n";
  163 + } else {
  164 + return sprintf(' ZEND_MOD_%s("%s")', $this->type, $this->name)."\n";
  165 + }
  166 + }
  167 +
  168 + /**
  169 + * Generate extension C code header
  170 + *
  171 + * @param object extension
  172 + * @return string code snippet
  173 + */
  174 + static function cCodeHeader($extension)
  175 + {
  176 + return "/* {{{ cross-extension dependencies */\n
  177 +#if ZEND_EXTENSION_API_NO >= 220050617
  178 +static zend_module_dep ".$extension->getName()."_deps[] = {
  179 +";
  180 + }
  181 +
  182 + /**
  183 + * Generate extension C code footer
  184 + *
  185 + * @param object extension
  186 + * @return string code snippet
  187 + */
  188 + static function cCodeFooter($extension)
  189 + {
  190 + return " {NULL, NULL, NULL, 0}
  191 +};
  192 +#endif
  193 +/* }}} */
  194 +";
  195 + }
  196 +
  197 +
  198 + /**
  199 + * package.xml dependencie entry
  200 + *
  201 + * @return string XML snippet
  202 + */
  203 + function packageXML()
  204 + {
  205 + $xml = ' <dep type="ext"';
  206 + if (!empty($this->version)) {
  207 + $xml.= sprintf(' rel="%s" version="%s"', $this->version["relation"], $this->version["version"]);
  208 + }
  209 + $xml.= ">{$this->name}</dep>\n";
  210 +
  211 + return $xml;
  212 + }
  213 +
  214 +
  215 +
  216 + /**
  217 + * package.xml 2.0 dependencie entry
  218 + *
  219 + * @param mixed requested type(s), either string or array
  220 + * @return string XML snippet
  221 + */
  222 + function packageXML2($types = false)
  223 + {
  224 + $xml = " <extension><name>{$this->name}</name>";
  225 +
  226 + if (!empty($types)) {
  227 + $types = (array)$types;
  228 + if (!in_array($this->type, $types)) {
  229 + return "";
  230 + }
  231 + }
  232 +
  233 + switch ($this->type ) {
  234 + case 'REQUIRED':
  235 + case 'OPTIONAL':
  236 + if (!empty($this->version)) {
  237 + $version = $this->version["version"];
  238 + switch ($this->version["relation"]) {
  239 + case 'gt':
  240 + $xml.= "<exclude>$version</exclude>";
  241 + /* fallthru */
  242 + case 'ge':
  243 + $xml.= "<min>$version</min>";
  244 + break;
  245 + case 'lt':
  246 + $xml.= "<exclude>$version</exclude>";
  247 + /* fallthru */
  248 + case 'le':
  249 + $xml.= "<max>$version</max>";
  250 + break;
  251 + case 'eq':
  252 + $xml.= "<min>$version</min>";
  253 + $xml.= "<max>$version</max>";
  254 + break;
  255 + }
  256 + }
  257 + break;
  258 +
  259 + case 'CONFLICTS':
  260 + $xml.= "<conflicts/>";
  261 + break;
  262 + }
  263 + $xml.= "<extension>\n";
  264 +
  265 + return $xml;
  266 + }
  267 +}
73 PECL/Dependency/Header.php
... ... @@ -0,0 +1,73 @@
  1 +<?php
  2 +/**
  3 + * Class representing a header file dependency
  4 + *
  5 + * PHP versions 5
  6 + *
  7 + * LICENSE: This source file is subject to version 3.0 of the PHP license
  8 + * that is available through the world-wide-web at the following URI:
  9 + * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10 + * the PHP License and are unable to obtain it through the web, please
  11 + * send a note to license@php.net so we can mail you a copy immediately.
  12 + *
  13 + * @category Tools and Utilities
  14 + * @package CodeGen_PECL
  15 + * @author Hartmut Holzgraefe <hartmut@php.net>
  16 + * @copyright 2005, 2006 Hartmut Holzgraefe
  17 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  18 + * @version CVS: $Id$
  19 + * @link http://pear.php.net/package/CodeGen_PECL
  20 + */
  21 +
  22 +/**
  23 + * include
  24 + */
  25 +require_once "CodeGen/Dependency/Header.php";
  26 +
  27 +/**
  28 + * Class representing a header file dependency
  29 + *
  30 + * @category Tools and Utilities
  31 + * @package CodeGen_PECL
  32 + * @author Hartmut Holzgraefe <hartmut@php.net>
  33 + * @copyright 2005, 2006 Hartmut Holzgraefe
  34 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  35 + * @version Release: @package_version@
  36 + * @link http://pear.php.net/package/CodeGen
  37 + */
  38 +class CodeGen_PECL_Dependency_Header
  39 + extends CodeGen_Dependency_Header
  40 +{
  41 + /**
  42 + * return config.m4 code snippet for unix builds
  43 + *
  44 + * @param string Extension name
  45 + * @param string --with option name
  46 + * @return string
  47 + */
  48 + function configm4($extname, $withname)
  49 + {
  50 + $upname = strtoupper($extname);
  51 + $withUpname = strtoupper($withname);
  52 + return " AC_CHECK_HEADER([{$this->name}], [], AC_MSG_ERROR('{$this->name}' header not found))\n";
  53 + }
  54 +
  55 + /**
  56 + * return config.w32 code snippet for windows builds
  57 + *
  58 + * @param string Extension name
  59 + * @param string --with option name
  60 + * @return string
  61 + */
  62 + function configw32($extname, $withname)
  63 + {
  64 + $upname = strtoupper($extname);
  65 + echo "
  66 + if (!CHECK_HEADER_ADD_INCLUDE(\"{$this->name}\", \"CFLAGS_$upname\")) {
  67 + ERROR(\"{$extname}: header '{$this->name}' not found\");
  68 + }
  69 +";
  70 + }
  71 +}
  72 +
  73 +?>
123 PECL/Dependency/Lib.php
... ... @@ -0,0 +1,123 @@
  1 +<?php
  2 +/**
  3 + * Class representing a library dependency
  4 + *
  5 + * PHP versions 5
  6 + *
  7 + * LICENSE: This source file is subject to version 3.0 of the PHP license
  8 + * that is available through the world-wide-web at the following URI:
  9 + * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10 + * the PHP License and are unable to obtain it through the web, please
  11 + * send a note to license@php.net so we can mail you a copy immediately.
  12 + *
  13 + * @category Tools and Utilities
  14 + * @package CodeGen_PECL
  15 + * @author Hartmut Holzgraefe <hartmut@php.net>
  16 + * @copyright 2005, 2006 Hartmut Holzgraefe
  17 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  18 + * @version CVS: $Id$
  19 + * @link http://pear.php.net/package/CodeGen
  20 + */
  21 +
  22 +/**
  23 + * include
  24 + */
  25 +require_once "CodeGen/Dependency/Lib.php";
  26 +require_once "CodeGen/PECL/Dependency/Platform.php";
  27 +
  28 +/**
  29 + * Class representing a library dependencyp
  30 + *
  31 + * @category Tools and Utilities
  32 + * @package CodeGen_PECL
  33 + * @author Hartmut Holzgraefe <hartmut@php.net>
  34 + * @copyright 2005, 2006 Hartmut Holzgraefe
  35 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  36 + * @version Release: @package_version@
  37 + * @link http://pear.php.net/package/CodeGen
  38 + */
  39 +class CodeGen_PECL_Dependency_Lib
  40 + extends CodeGen_Dependency_Lib
  41 +{
  42 + /**
  43 + * Constructor
  44 + *
  45 + * @param string library basename
  46 + * @param string platform name
  47 + */
  48 + function __construct($name, $platform = "all")
  49 + {
  50 + // TODO check name
  51 + $this->name = $name;
  52 +
  53 + $this->platform = new CodeGen_PECL_Dependency_Platform($platform);
  54 + }
  55 +
  56 + /**
  57 + * write config.m4 code snippet for unix builds
  58 + *
  59 + * @param string Extension name
  60 + * @param string --with option name
  61 + * @return string code snippet
  62 + */
  63 + function configm4($extName, $withName)
  64 + {
  65 + static $first = true;
  66 +
  67 + $extUpname = strtoupper($extName);
  68 + $withUpname = str_replace("-", "_", strtoupper($withName));
  69 +
  70 + if (!$this->platform->test("unix")) {
  71 + return "";
  72 + }
  73 +
  74 + $ret = "";
  75 +
  76 + if ($first) {
  77 + $ret.= " PHP_SUBST({$extUpname}_SHARED_LIBADD)\n\n";
  78 + $first = false;
  79 + }
  80 +
  81 + if ($this->function) {
  82 + $ret.= "
  83 + PHP_CHECK_LIBRARY({$this->name}, {$this->function},
  84 + [
  85 + PHP_ADD_LIBRARY_WITH_PATH({$this->name}, \$PHP_{$withUpname}_DIR/{$this->path}, {$extUpname}_SHARED_LIBADD)
  86 + ],[
  87 + AC_MSG_ERROR([wrong {$this->name} lib version or lib not found])
  88 + ],[
  89 + -L\$PHP_{$withUpname}_DIR/{$this->path}
  90 + ])
  91 +";
  92 + } else {
  93 + $ret.= " PHP_ADD_LIBRARY_WITH_PATH({$this->name}, \$PHP_{$withUpname}_DIR/{$this->path}, {$extUpname}_SHARED_LIBADD)\n";
  94 +
  95 + }
  96 +
  97 + return $ret;
  98 + }
  99 +
  100 + /**
  101 + * write config.w32 code snippet for windows builds
  102 + *
  103 + * @param string Extension name
  104 + * @param string --with option name
  105 + * @return string code snippet
  106 + */
  107 + function configw32($extName, $withName)
  108 + {
  109 + if (!$this->platform->test("windows")) {
  110 + return "";
  111 + }
  112 +
  113 + $extUpname = strtoupper($extName);
  114 +
  115 + return "
  116 + if (!CHECK_LIB(\"{$this->name}.lib\", \"{$extName}\", PHP_$extUpname)) {
  117 + ERROR(\"{$extName}: library '{$this->name}' not found\");
  118 + }
  119 +";
  120 + }
  121 +}
  122 +
  123 +?>
84 PECL/Dependency/Platform.php
... ... @@ -0,0 +1,84 @@
  1 +<?php
  2 +/**
  3 + * Class representing a platform dependency
  4 + *
  5 + * PHP versions 5
  6 + *
  7 + * LICENSE: This source file is subject to version 3.0 of the PHP license
  8 + * that is available through the world-wide-web at the following URI:
  9 + * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10 + * the PHP License and are unable to obtain it through the web, please
  11 + * send a note to license@php.net so we can mail you a copy immediately.
  12 + *
  13 + * @category Tools and Utilities
  14 + * @package CodeGen_PECL
  15 + * @author Hartmut Holzgraefe <hartmut@php.net>
  16 + * @copyright 2005, 2006 Hartmut Holzgraefe
  17 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  18 + * @version CVS: $Id$
  19 + * @link http://pear.php.net/package/CodeGen_PECL
  20 + */
  21 +
  22 +/**
  23 + * include
  24 + */
  25 +require_once "CodeGen/Tools/Platform.php";
  26 +
  27 +/**
  28 + * Class representing a platform dependency
  29 + *
  30 + * @category Tools and Utilities
  31 + * @package CodeGen_PECL
  32 + * @author Hartmut Holzgraefe <hartmut@php.net>
  33 + * @copyright 2005, 2006 Hartmut Holzgraefe
  34 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  35 + * @version Release: @package_version@
  36 + * @link http://pear.php.net/package/CodeGen_PECL
  37 + */
  38 +class CodeGen_PECL_Dependency_Platform
  39 + extends CodeGen_Tools_Platform
  40 +{
  41 + /**
  42 + * package.xml dependencie entry
  43 + *
  44 + * @return string XML snippet
  45 + */
  46 + function packageXML()
  47 + {
  48 + if ($this->test("all")) return "";
  49 +
  50 + $xml = "";
  51 +
  52 + if ($this->test("windows")) {
  53 + $xml.= " <dep type='os' rel='has' name='windows'/>\n";
  54 + }
  55 +
  56 + if ($this->test("unix")) {
  57 + $xml.= " <dep type='os' rel='has' name='unix'/>\n";
  58 + }
  59 +
  60 + return $xml;
  61 + }
  62 +
  63 + /**
  64 + * package.xml 2.0 dependencie entry
  65 + *
  66 + * @return string XML snippet
  67 + */
  68 + function packageXML2()
  69 + {
  70 + if ($this->test("all")) return "";
  71 +
  72 + $xml = "";
  73 +
  74 + if ($this->test("windows")) {
  75 + $xml.= " <os><name>windows</name></os>\n";
  76 + }
  77 +
  78 + if ($this->test("unix")) {
  79 + $xml.= " <os><name>unix</name></os>\n";
  80 + }
  81 +
  82 + return $xml;
  83 + }
  84 +}
425 PECL/Dependency/With.php
... ... @@ -0,0 +1,425 @@
  1 +<?php
  2 +/**
  3 + * Class representing a --with configure option
  4 + *
  5 + * PHP versions 5
  6 + *
  7 + * LICENSE: This source file is subject to version 3.0 of the PHP license
  8 + * that is available through the world-wide-web at the following URI:
  9 + * http://www.php.net/license/3_0.txt. If you did not receive a copy of
  10 + * the PHP License and are unable to obtain it through the web, please
  11 + * send a note to license@php.net so we can mail you a copy immediately.
  12 + *
  13 + * @category Tools and Utilities
  14 + * @package CodeGen
  15 + * @author Hartmut Holzgraefe <hartmut@php.net>
  16 + * @copyright 2005, 2006 Hartmut Holzgraefe
  17 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  18 + * @version CVS: $Id$
  19 + * @link http://pear.php.net/package/CodeGen
  20 + */
  21 +
  22 +/**
  23 + * include
  24 + */
  25 +require_once "CodeGen/PECL/Element.php";
  26 +
  27 +/**
  28 + * Class representing a --with configure option
  29 + *
  30 + * @category Tools and Utilities
  31 + * @package CodeGen
  32 + * @author Hartmut Holzgraefe <hartmut@php.net>
  33 + * @copyright 2005, 2006 Hartmut Holzgraefe
  34 + * @license http://www.php.net/license/3_0.txt PHP License 3.0
  35 + * @version Release: @package_version@
  36 + * @link http://pear.php.net/package/CodeGen
  37 + */
  38 +class CodeGen_PECL_Dependency_With
  39 + extends CodeGen_Element
  40 +{
  41 + /**
  42 + * Set option name
  43 + *
  44 + * @var name
  45 + * @access private
  46 + */
  47 + protected $name = false;
  48 +
  49 + /**
  50 + * Short Summary
  51 + *
  52 + * @var string
  53 + * @access private
  54 + */
  55 + protected $summary = "";
  56 +
  57 + /**
  58 + * Long Description
  59 + *
  60 + * @var string
  61 + * @access private
  62 + */
  63 + protected $description = "";
  64 +
  65 + /**
  66 + * A file to test for to check a given argument path
  67 + *
  68 + * @var string
  69 + * @access private
  70 + */
  71 + protected $testfile = false;
  72 +
  73 + /**
  74 + * Default search path
  75 + *
  76 + * @var string
  77 + * @access private
  78 + */
  79 + protected $defaults = "/usr:/usr/local";
  80 +
  81 + /**
  82 + * dependant libraries
  83 + *
  84 + * @var string
  85 + * @access private
  86 + */
  87 + protected $libs = array();
  88 +
  89 +
  90 + /**
  91 + * dependant header files
  92 + *
  93 + * @var string
  94 + * @access private
  95 + */
  96 + protected $headers = array();
  97 +
  98 + /**
  99 + * operation mode
  100 + *
  101 + * @var string
  102 + */
  103 + protected $mode = "default";
  104 +
  105 + /**
  106 + * required version
  107 + *
  108 + * @var string
  109 + */
  110 + protected $version = "";
  111 +
  112 + /**
  113 + * name getter
  114 + *
  115 + * @param string
  116 + */
  117 + function getName()
  118 + {
  119 + return $this->name;
  120 + }
  121 +
  122 +
  123 + /**
  124 + * name setter
  125 + *
  126 + * @param string
  127 + */
  128 + function setName($name)
  129 + {
  130 + if (!preg_match('|^[a-z][a-z0-9_-]*$|i', $name)) {
  131 + return PEAR::raiseError("'$name' is not a valid --with option name");
  132 + }
  133 +
  134 + $this->name = $name;
  135 +
  136 + return true;
  137 + }
  138 +
  139 + /**
  140 + * summary setter
  141 + *
  142 + * @param string
  143 + */
  144 + function setSummary($text)
  145 + {
  146 + $this->summary = trim($text);
  147 +
  148 + return true;
  149 + }
  150 +
  151 + /**
  152 + * summary getter
  153 + *
  154 + * @return string
  155 + */
  156 + function getSummary()
  157 + {
  158 + return $this->summary ? $this->summary : "whether {$this->name} is available";
  159 + }
  160 +
  161 + /**
  162 + * description setter
  163 + *
  164 + * @param string
  165 + */
  166 + function setDescription($text)
  167 + {
  168 + $this->description = $text;
  169 +
  170 + return true;
  171 + }
  172 +
  173 + /**
  174 + * testfile setter
  175 + *
  176 + * @param string
  177 + */
  178 + function setTestfile($path)
  179 + {
  180 + $this->testfile = $path;
  181 + }
  182 +
  183 + /**
  184 + * testfile getter
  185 + *
  186 + * @return string
  187 + */
  188 + function getTestfile()
  189 + {
  190 + return $this->testfile;
  191 + }
  192 +
  193 + /**
  194 + * default searchpath setter
  195 + *
  196 + * @param string
  197 + */
  198 + function setDefaults($defaults)
  199 + {
  200 + $this->defaults = $defaults;
  201 + }
  202 +
  203 + /**
  204 + * default searchpath getter
  205 + *
  206 + * @return string
  207 + */
  208 + function getDefaults()
  209 + {
  210 + return $this->defaults;
  211 + }
  212 +
  213 + /**
  214 + * mode setter
  215 + *
  216 + * @param string
  217 + */
  218 + function setMode($mode)
  219 + {
  220 + switch ($mode) {
  221 + case "default":
  222 + case "pkg-config":
  223 + $this->mode = $mode;
  224 + return true;
  225 +
  226 + default:
  227 + return PEAR::raiseError("'$mode' is not a valid <with> mode");
  228 + }
  229 + }
  230 +
  231 + /**
  232 + * version setter
  233 + *
  234 + * @param string
  235 + */
  236 + function setVersion($version)
  237 + {
  238 + $this->version = $version;
  239 + }
  240 +
  241 + /**
  242 + * add library dependency
  243 + *
  244 + * @param object
  245 + */
  246 + function addLib(CodeGen_PECL_Dependency_Lib $lib)
  247 + {
  248 + $name = $lib->getName();
  249 +
  250 + if (isset($this->libs[$name])) {
  251 + return PEAR::raiseError("library '$name' specified twice");
  252 + }
  253 +
  254 + $this->libs[$name] = $lib;
  255 +
  256 + return true;
  257 + }
  258 +
  259 + /**
  260 + * libraries getter
  261 + *
  262 + * @return array
  263 + */
  264 + function getLibs()
  265 + {
  266 + return $this->libs;
  267 + }
  268 +
  269 + /**
  270 + * add header dependency
&