Exemplo n.º 1
0
 /**
  * Write the complete C code file
  *
  * @access private
  * @param  string  directory to write to
  */
 function writeCodeFile()
 {
     $filename = "{$this->name}.{$this->language}";
     // todo extension logic
     $upname = strtoupper($this->name);
     $this->addPackageFile('code', $filename);
     $file = new CodeGen_Tools_Outbuf($this->dirpath . '/' . $filename, CodeGen_Tools_Outbuf::OB_TABIFY);
     echo $this->getLicense();
     echo "#include \"php_{$this->name}.h\"\n\n";
     echo "#if HAVE_{$upname}\n\n";
     if (isset($this->code["code"]["top"])) {
         foreach ($this->code["code"]["top"] as $code) {
             echo $this->codegen->block($code, 0);
         }
     }
     if (!empty($this->logos)) {
         echo CodeGen_PECL_Element_Logo::cCodeHeader($this->name);
         foreach ($this->logos as $logo) {
             echo $logo->cCode($this->name);
         }
         echo CodeGen_PECL_Element_Logo::cCodeFooter($this->name);
     }
     if (!empty($this->resources)) {
         echo CodeGen_PECL_Element_Resource::cCodeHeader($this->name);
         foreach ($this->resources as $resource) {
             echo $resource->cCode($this);
         }
         echo CodeGen_PECL_Element_Resource::cCodeFooter($this->name);
     }
     echo $this->generateInterfaceRegistrations();
     echo $this->generateClassRegistrations();
     echo $this->generateFunctionRegistrations();
     echo $this->generateExtensionEntry();
     echo $this->generateGlobalsC();
     echo $this->internalFunctionsC();
     echo $this->publicFunctionsC();
     if (isset($this->code["code"]["bottom"])) {
         foreach ($this->code["code"]["bottom"] as $code) {
             echo $this->codegen->block($code, 0);
         }
     }
     echo "#endif /* HAVE_{$upname} */\n\n";
     echo $this->cCodeEditorSettings();
     return $file->write();
 }
Exemplo n.º 2
0
 function tagend_extension_logo($attr, $data)
 {
     // TODO checks
     if (!isset($attr["name"])) {
         $attr["name"] = $this->extension->getName();
     }
     $logo = new CodeGen_PECL_Element_Logo($attr["name"]);
     if (!isset($attr["mimetype"])) {
         $attr["mimetype"] = false;
     }
     if (isset($attr["src"])) {
         $err = $logo->loadFile($attr["src"], $attr["mimetype"]);
         if (PEAR::isError($err)) {
             return $err;
         }
     } else {
         // we support base64 encoded embedded data only
         $decoded = base64_decode($data);
         if (!is_string($decoded)) {
             return PEAR::raiseError("only base64 encoded image data is supported for embedded data");
         }
         $err = $logo->setData($decoded, $attr["mimetype"]);
         if (PEAR::isError($err)) {
             return $err;
         }
     }
     return $this->extension->addLogo($logo);
 }