diff options
| author | Hartmut Holzgraefe <hholzgra@php.net> | 2003-02-26 10:06:47 +0000 |
|---|---|---|
| committer | Hartmut Holzgraefe <hholzgra@php.net> | 2003-02-26 10:06:47 +0000 |
| commit | f7490c405b712f77ef11982f5fec054f97ce1dd6 (patch) | |
| tree | fcd453c3b4c561c9fe36415ad520bcf0429b9ed0 /scripts/ext_skel_ng/php_resource.php | |
| parent | 189d29061e0f4f3231fbd1c8884bf0191ecdaa9f (diff) | |
| download | php-git-f7490c405b712f77ef11982f5fec054f97ce1dd6.tar.gz | |
forgot to add these two on my last commit :(
Diffstat (limited to 'scripts/ext_skel_ng/php_resource.php')
| -rw-r--r-- | scripts/ext_skel_ng/php_resource.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/ext_skel_ng/php_resource.php b/scripts/ext_skel_ng/php_resource.php new file mode 100644 index 0000000000..ea99405841 --- /dev/null +++ b/scripts/ext_skel_ng/php_resource.php @@ -0,0 +1,65 @@ +<?php + + class php_resource extends php_element { + function php_resource($name, $payload, $destruct, $description) { + $this->name = $name; + $this->payload = $payload; + $this->destruct = $destruct; + $this->description = $description; + + if (empty($this->destruct) && strstr($this->payload, "*")) { + $this->destruct = " free(resource);\n"; + } + + if(empty($this->payload)) { + $this->payload = "int"; + } + } + + function docbook_xml($base) { + return " + <section id='$base.resources.{$this->name}'> + <title><litera>{$this->name}</literal></title> + <para> + {$this->description} + </para> + </section> +"; + } + + function minit_code() { + return " +le_{$this->name} = zend_register_list_destructors_ex({$this->name}_dtor, + NULL, + \"{$this->name}\", + module_number); + +"; + } + + function c_code() { + return " +int le_{$this->name}; + +void {$this->name}_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) +{ + {$this->payload} resource = ({$this->payload})(rsrc->ptr); + + {$this->destruct} +} +"; + } + + function h_code() { + $upname = strtoupper($this->name); + + return " +#define {$upname}_FETCH(r, z) ZEND_FETCH_RESOURCE(r, {$this->payload}, z, -1, ${$this->name}, le_{$this->name }); \ + if(!r) { RETURN_FALSE; } + +#define {$upname}_REGISTER(r) ZEND_REGISTER_RESOURCE(return_value, r, le_{$this->name }); +"; + } + } + +?>
\ No newline at end of file |
