Re: using resources... for GtkHTMLStream
| From: | Markus Fischer | Date: | Mon, 08 Oct 2001 02:19:54 +0000 |
| Subject: | Re: using resources... for GtkHTMLStream | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-87@lists.php.net to get a copy of this message | ||
Sorry I completely ignored this one in the first place as I was
to busy. I'm not a Zend guru myself.
parse_args returns a zval* to your resource; not the resource
directly:
Try the following:
zval *resource;
int resource_type;
if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "rsi", &resource, &buffer, &size))
return;
gs = zend_list_find(Z_RESVAL_P(resource), &resource_type);
if (!gs || resource_type != le_gtkhtmlstream) {
php_error(...
return;
}
On Sat, Oct 06, 2001 at 05:15:33PM -0000, Alan Knowles wrote :
> The two functions below illustrate the issue - gtk_html_begin
> returns a struct, GtkHTMLStream gtk_html_write uses this as one
> of it's inputs to determine where to send the data..
>
> I have attempted to wrap the return value into a PHP Resource
> and defined a simple struct to wrap the real one..
>
> however I dont seem to be able to get the address back out of
> the struct.. (or am even sure that I am setting it
> correctly)...
>
> suggestions, other good (simple) examples of code doing
> something similar would be helpfull..
>
> regards
>
> alan
>
> typedef struct {
> GtkHTMLStream *htmlstream;
> long id;
> } php_gtkhtmlstream;
>
> static int le_gtkhtmlstream;
>
> PHP_FUNCTION(gtk_html_begin)
> {
> zval **res_value;
> php_gtkhtmlstream *gs;
>
> NOT_STATIC_METHOD();
>
> if (!php_gtk_parse_args(ZEND_NUM_ARGS(), ""))
> return;
> gs = (php_gtkhtmlstream *)emalloc(sizeof(php_gtkhtmlstream));
> gs->htmlstream = gtk_html_begin(GTK_HTML(PHP_GTK_GET(this_ptr)));
> gs->id=1;
> res_value = zend_list_insert(gs, le_gtkhtmlstream);
>
> RETURN_RESOURCE(res_value);
>
>
> }
>
>
>
> PHP_FUNCTION(gtk_html_write)
> {
> php_gtkhtmlstream *gs;
> char *buffer;
> long size;
>
> NOT_STATIC_METHOD();
>
> if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "rsi", &gs, &buffer, &size))
> return;
> gtk_html_write(GTK_HTML(PHP_GTK_GET(this_ptr)),
> (GtkHTMLStream *)gs->htmlstream, buffer, (size_t) size);
>
> RETURN_NULL();
> }
--
Markus Fischer, http://guru.josefine.at/~mfischer/
EMail: mfischer@guru.josefine.at
PGP Public Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
PGP Fingerprint: D3B0 DD4F E12B F911 3CE1 C2B5 D674 B445 C227 2BD0
-All your scripts are belong to Zend-