function tagend_constants_constant($attr, $data)
 {
     $const = new CodeGen_PECL_Element_Constant();
     if (isset($attr["name"])) {
         $err = $const->setName($attr["name"]);
         if (PEAR::isError($err)) {
             return $err;
         }
     } else {
         return PEAR::raiseError("name attribut for constant missing");
     }
     if (isset($attr["type"])) {
         $err = $const->setType($attr["type"]);
     } else {
         $err = $const->setType("int");
         // default
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     if (isset($attr["value"])) {
         $err = $const->setValue($attr["value"]);
     } else {
         $const->setDefine(false);
         $err = $const->setValue($attr["name"]);
         // default -> mimic a C #define or enum value
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     if (isset($attr["define"])) {
         $err = $const->setDefine($attr["define"]);
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     $const->setDesc(CodeGen_Tools_IndentC::linetrim($data));
     return $this->extension->addConstant($const);
 }
Esempio n. 2
0
 function tagend_extension_constant($attr, $data)
 {
     $const = new CodeGen_PECL_Element_Constant();
     if (isset($attr["name"])) {
         $err = $const->setName($attr["name"]);
         if (PEAR::isError($err)) {
             return $err;
         }
     } else {
         return PEAR::raiseError("name attribut for constant missing");
     }
     if (isset($attr["type"])) {
         $err = $const->setType($attr["type"]);
     } else {
         $err = $const->setType("int");
         // default
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     if (isset($attr["value"])) {
         $err = $const->setValue($attr["value"]);
     } else {
         $const->setDefine(false);
         $err = $const->setValue($attr["name"]);
         // default -> mimic a C #define or enum value
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     if (isset($attr["define"])) {
         $err = $const->setDefine($attr["define"]);
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     if (isset($attr["group"])) {
         $err = $const->setGroup($attr["group"]);
     } else {
         if (is_array($this->helper) && isset($this->helper["group"])) {
             $err = $const->setGroup($this->helper["group"]);
         }
     }
     if (PEAR::isError($err)) {
         return $err;
     }
     if (isset($attr["if"])) {
         $condition = $attr["if"] == "yes" ? $attr["name"] : $attr["if"];
         $const->setIfCondition($condition);
     } else {
         if (is_array($this->helper) && isset($this->helper["if"])) {
             $const->setIfCondition($this->helper["if"]);
         }
     }
     $groupIfs = $this->getGroupAttributeStack("if");
     if (is_array($groupIfs)) {
         foreach ($groupIfs as $if) {
             $const->addIfCondition($if);
         }
     }
     $const->setDesc(CodeGen_Tools_IndentC::linetrim($data));
     return $this->extension->addConstant($const);
 }