예제 #1
0
 function tagend_class_description($attr, $data)
 {
     return $this->helper->setDescription(CodeGen_Tools_IndentC::linetrim($data));
 }
예제 #2
0
    /**
     * Write config.m4 file for autoconf 
     *
     * @access private
     * @param  string  directory to write to
     */
    function writeConfigM4()
    {
        $upname = strtoupper($this->name);
        $this->addPackageFile("conf", "config.m4");
        $file = new CodeGen_Tools_Outbuf($this->dirpath . "/config.m4", CodeGen_Tools_Outbuf::OB_TABIFY);
        echo 'dnl
dnl $ Id: $
dnl
';
        if (isset($this->with[$this->name])) {
            $with = $this->with[$this->name];
            echo "\n" . $with->m4Line() . "\n";
        } else {
            echo "\nPHP_ARG_ENABLE({$this->name}, whether to enable {$this->name} functions,\n[  --enable-{$this->name}         Enable {$this->name} support])\n";
        }
        echo "\n";
        echo "if test \"\$PHP_{$upname}\" != \"no\"; then\n";
        foreach ($this->configfragments['top'] as $fragment) {
            echo "{$fragment}\n";
        }
        foreach ($this->with as $with) {
            echo $with->configm4($this);
        }
        $pathes = array();
        foreach ($this->headers as $header) {
            $pathes[$header->getPath()] = true;
            // TODO WTF???
        }
        foreach (array_keys($pathes) as $path) {
            echo "  PHP_ADD_INCLUDE(\$PHP_{$upname}_DIR/{$path})\n";
        }
        if ($this->language === "cpp") {
            echo "  PHP_REQUIRE_CXX\n";
            echo "  AC_LANG_CPLUSPLUS\n";
            echo "  PHP_ADD_LIBRARY(stdc++,,{$upname}_SHARED_LIBADD)\n";
        }
        echo "  export OLD_CPPFLAGS=\"\$CPPFLAGS\"\n";
        echo "  export CPPFLAGS=\"\$CPPFLAGS \$INCLUDES -DHAVE_" . strtoupper($this->name) . "\"\n";
        if (count($this->headers)) {
            if (!isset($this->with[$this->name])) {
                $this->terminate("global headers not bound to a --with option found and no --with option by the default name");
            }
            foreach ($this->headers as $header) {
                echo $header->configm4($this->name, $this->name);
            }
        }
        foreach ($this->resources as $resource) {
            echo $resource->configm4($this->name);
        }
        echo "  export CPPFLAGS=\"\$OLD_CPPFLAGS\"\n";
        if (count($this->libs)) {
            if (!isset($this->with[$this->name])) {
                $this->terminate("global libs not bound to a --with option found and no --with option by the default name");
            }
            foreach ($this->libs as $lib) {
                echo $lib->configm4($this->name, $this->name);
            }
        }
        echo "\n";
        echo "\n  PHP_SUBST({$upname}_SHARED_LIBADD)\n  AC_DEFINE(HAVE_{$upname}, 1, [ ])\n  PHP_NEW_EXTENSION({$this->name}, " . join(" ", array_keys($this->packageFiles['code'])) . " , \$ext_shared)\n";
        if (count($this->makefragments)) {
            echo "  PHP_ADD_MAKEFILE_FRAGMENT\n";
            $frag = new CodeGen_Tools_FileReplacer($this->dirpath . "/Makefile.frag");
            foreach ($this->makefragments as $block) {
                $frag->puts(CodeGen_Tools_IndentC::tabify("\n{$block}\n"));
            }
            $frag->close();
        }
        foreach ($this->configfragments['bottom'] as $fragment) {
            echo "{$fragment}\n";
        }
        echo "\nfi\n\n";
        return $file->write();
    }
예제 #3
0
 /**
  * Generate indented codeblock with variable declarations
  *
  * @param  string   code
  * @param  int      indent level
  * @return string   formated code block
  */
 function varblock($code, $indent = 1)
 {
     if ($this->language == 'c') {
         $head = CodeGen_Tools_IndentC::indent($indent * $this->indentSteps, "do {\n");
         $foot = CodeGen_Tools_IndentC::indent($indent * $this->indentSteps, "} while (0);\n");
         $indent++;
     } else {
         $head = $foot = "";
     }
     $code = CodeGen_Tools_IndentC::indent($indent * $this->indentSteps, $code);
     return $head . $code . $foot;
 }