Modifying code generator to support pass by reference values
| From: | Markus Fischer | Date: | Wed, 12 Dec 2001 14:32:30 +0000 |
| Subject: | Modifying code generator to support pass by reference values | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-259@lists.php.net to get a copy of this message | ||
We have gtk function
gtk_foo_bar_get(GtkSomeObject *obj, gdouble *x, gdouble *y);
While working on gtkextra I found quite a lot of them. They
just return the values to x and y, e.g in gtk_foo_bar_get():
void gtk_foo_bar_get(GtkSomeObject *obj, gdouble *x, gdouble *y)
{
*x = obj->blabla.x;
*y = obj->blabla.y;
}
First I wanted to create an extra Retval_Arg handler. Alan
suggested using another flag to the parameters 'return-value'
(method get_position
(of-object Plot (Gtk))
(c-name gtk_plot_get_position)
(return-type none)
(parameter (type-and-name gdouble* x) (return-value))
(parameter (type-and-name gdouble* y) (return-value))
)
Assuming the the function has NO return value the,
the return code would look like:
gtk_foo_bar_get(GTK_FOO_BAR(PHP_GTK_GET(this_ptr)), &x, &y);
array_init(return_value);
add_next_index_double(x);
add_next_index_double(y);
I've played around and it works fine. But before I put
more energy into this I wanted to know if everyone agrees
witht his solution. It requires changes to the code generator
in several places.
Alan, Andrei, anyone?
- Markus
--
Please always Cc to me when replying to me on the lists.