Esempio n. 1
0
 /**
  * Set parameter and return value information from PHP style prototype
  *
  * @access public
  * @param  string  PHP style prototype
  * @return bool    Success status
  */
 function setProto($proto, $extension)
 {
     $err = parent::setProto($proto, $extension);
     if (PEAR::isError($err)) {
         return $err;
     }
     if ($this->name != "__construct") {
         $param = array();
         $param['name'] = "_this_zval";
         $param['type'] = "object";
         $param['subtype'] = $this->classname;
         $param['byRef'] = true;
         array_unshift($this->params, $param);
     }
 }
Esempio n. 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();
         }
     }
 }