2003-02-19 10:07:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class php_constant extends php_element {
|
|
|
|
function php_constant($name, $value, $type="string", $desc="") {
|
|
|
|
$this->name = $name;
|
|
|
|
$this->value= $value;
|
|
|
|
$this->type = $type;
|
|
|
|
$this->desc = $desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
function c_code() {
|
|
|
|
switch($this->type) {
|
|
|
|
case "integer":
|
|
|
|
return "REGISTER_LONG_CONSTANT(\"{$this->name}\", {$this->value}, 0);\n";
|
|
|
|
|
|
|
|
case "float":
|
|
|
|
return "REGISTER_DOUBLE_CONSTANT(\"{$this->name}\", {$this->value}, 0);\n";
|
|
|
|
|
|
|
|
case "string":
|
|
|
|
return "REGISTER_STRING_CONSTANT(\"{$this->name}\", \"$value\", ".strlen($this->value).", 0);\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function docbook_xml() {
|
|
|
|
return trim("
|
|
|
|
<row>
|
|
|
|
<entry>
|
2003-03-15 22:37:03 +00:00
|
|
|
<constant id='constant".strtolower(str_replace("_","-",$this->name))."'>{$this->name}</constant>
|
2003-02-19 10:07:22 +00:00
|
|
|
(<link linkend='language.types.integer'>integer</link>)
|
|
|
|
</entry>
|
|
|
|
<entry>{$this->value}</entry>
|
|
|
|
<entry>{$this->desc}</entry>
|
|
|
|
</row>
|
|
|
|
")."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-15 22:37:03 +00:00
|
|
|
?>
|