예제 #1
0
 /**
  * Code needed ahead of the method table
  *
  * Abstract/Interface methods need to define their argument
  * list ahead of the method table
  *
  * @param   array
  * @returns string
  */
 function argInfoCode($params)
 {
     array_shift($params);
     return parent::argInfoCode($params);
 }
예제 #2
0
 /**
  * ext-skel compatibility mode
  *
  */
 function extSkelCompat()
 {
     $extname = $this->options->value("extname");
     $err = $this->extension->setName($extname);
     if (PEAR::isError($err)) {
         $command->terminate($err->getMessage());
     }
     if ($this->options->have("proto")) {
         $proto_file = $this->options->value("proto");
         if (!file_exists($proto_file) || !is_readable($proto_file)) {
             $command->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));
             if (PEAR::isError($err)) {
                 $command->terminate($err->getMessage());
             }
             $err = $this->extension->addFunction($func);
             if (PEAR::isError($err)) {
                 $command->terminate($err->getMessage());
             }
         }
     }
     if ($this->options->have("stubs")) {
         $stubname = $this->options->value("stubs");
         if (file_exists("{$stubname}") && !$this->options->have("f", "force")) {
             $command->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")) {
             $command->terminate("'{$extname}' already exists, can't create directory (use '--force' to override)");
         }
         $err = System::mkdir($extname);
         if (PEAR::isError($err)) {
             $command->terminate($err->getMessage());
         }
         $this->extension->dirpath = realpath("./{$extname}");
         $err = $this->extension->generateSource("./{$extname}");
         if (PEAR::isError($err)) {
             $command->terminate($err->getMessage());
         }
         if ($this->options->have("xml")) {
             $manpath = "{$extname}/manual/" . str_replace('_', '-', $extname);
             $err = System::mkdir("-p {$manpath}");
             if (PEAR::isError($err)) {
                 $command->terminate($err->getMessage());
             }
             $err = $this->extension->generateDocumentation($manpath);
             if (PEAR::isError($err)) {
                 $command->terminate($err->getMessage());
             }
         }
         $this->extension->writeRreadme("./{$extname}");
         if (!$this->options->have("quiet")) {
             echo $this->extension->successMsg();
         }
     }
 }
예제 #3
0
 /**
  * Add a function to the extension
  *
  * @access public
  * @param  object   a function object
  */
 function addFunction(CodeGen_PECL_Element_Function $function)
 {
     $name = $function->getName();
     $role = $function->getRole();
     switch ($role) {
         case "public":
             if (isset($this->functions[$name])) {
                 return PEAR::raiseError("public function '{$name}' has been defined before");
             }
             $this->functions[$name] = $function;
             return true;
         case "private":
             return PEAR::raiseError("private functions are no longer supported, use <code> sections instead");
         case "internal":
             if (isset($this->internalFunctions[$name])) {
                 return PEAR::raiseError("internal '{$name}' has been defined before");
             }
             $this->internalFunctions[$name] = $function;
             return true;
         default:
             return PEAR::raiseError("unnokwn function role '{$role}'");
     }
 }
예제 #4
0
 /**
  * Create test case for this function
  *
  * @access public
  * @param  object  extension the function is part of
  * @return object  generated test case
  */
 function createTest(CodeGen_PECL_Extension $extension)
 {
     if ($this->isAbstract || $this->isInterface) {
         return null;
     }
     $test = parent::createTest($extension);
     $test->setName($this->getFullName());
     $test->setTitle($this->classname . "::" . $this->name . "() member function");
     return $test;
 }