cvs: php-gtk /generator arg_types.php generator.php

From: Date: Mon, 05 Mar 2001 21:25:38 +0000
Subject: cvs: php-gtk /generator arg_types.php generator.php
Groups: php.gtk 
Request: Send a blank email to php-gtk+get-332@lists.php.net to get a copy of this message
fmk Mon Mar 5 13:25:38 2001 EDT Modified files: /php-gtk/generator arg_types.php generator.php Log: Fixing the return value of parameters passed by ref. Thsi has effect on clist_get_text() and other functions using gchar** types as argument.

Index: php-gtk/generator/arg_types.php diff -u php-gtk/generator/arg_types.php:1.16 php-gtk/generator/arg_types.php:1.17 --- php-gtk/generator/arg_types.php:1.16 Sat Mar 3 10:42:16 2001 +++ php-gtk/generator/arg_types.php Mon Mar 5 13:25:37 2001 @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: arg_types.php,v 1.16 2001/03/03 18:42:16 fmk Exp $ */ +/* $Id: arg_types.php,v 1.17 2001/03/05 21:25:37 fmk Exp $ */ /*======================================================================*\ Function: convert_typename @@ -77,7 +77,7 @@ \*======================================================================*/ class Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { trigger_error("This is an abstract class", E_USER_ERROR); @@ -99,7 +99,7 @@ class String_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) { @@ -139,14 +139,16 @@ class StringRef_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { $var_list->add('zval', '*php_' . $name . ' = NULL'); + $var_list->add('gchar', '*gtk_' . $name . ' = NULL'); $parse_list[] = '&php_' . $name; $parse_type[] = "F"; - $arg_list[] = "($type)&Z_STRVAL_P(php_$name)"; + $arg_list[] = "&gtk_$name"; $extra_code[] = " convert_to_string(php_$name);\n"; + $after_code[] = "ZVAL_STRING(php_$name, gtk_$name, 1);\n"; return 'V'; } @@ -157,7 +159,7 @@ class Char_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) @@ -175,13 +177,14 @@ $var_list->add('gchar', 'ret[2]'); return " ret[0] = %s;\n" . " ret[1] = '\\0';\n" . + " %s\n" . " RETURN_STRINGL(ret, 1, 1);"; } } class Int_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) @@ -196,13 +199,16 @@ function write_return($type, &$var_list) { - return ' RETURN_LONG(%s);'; + $var_list->add('long', 'php_retval'); + return " php_retval = %s;\n" . + " %s\n" . + " RETURN_LONG(php_retval);"; } } class IntRef_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { $var_list->add('zval', '*php_' . $name . ' = NULL'); @@ -220,7 +226,7 @@ class Bool_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) @@ -235,13 +241,16 @@ function write_return($type, &$var_list) { - return ' RETURN_BOOL(%s);'; + $var_list->add('gboolean', 'php_retval'); + return " php_retval = %s;\n" . + " %s\n" . + " RETURN_BOOL(php_retval);"; } } class Double_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) @@ -256,7 +265,10 @@ function write_return($type, &$var_list) { - return ' RETURN_DOUBLE(%s);'; + $var_list->add('double', 'php_retval'); + return " php_retval = %s;\n" . + " %s\n" . + " RETURN_DOUBLE(php_retval);"; } } @@ -275,7 +287,7 @@ } function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) @@ -293,7 +305,10 @@ function write_return($type, &$var_list) { - return ' RETURN_LONG(%s);'; + $var_list->add('long', 'php_retval'); + return " php_retval = %s;\n" . + " %s\n" . + " RETURN_LONG(php_retval);"; } } @@ -312,7 +327,7 @@ } function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if (isset($default)) @@ -330,7 +345,10 @@ function write_return($type, &$var_list) { - return ' RETURN_LONG(%s);'; + $var_list->add('long', 'php_retval'); + return " php_retval = %s;\n" . + " %s\n" . + " RETURN_LONG(php_retval);"; } } @@ -345,7 +363,7 @@ } function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { if ($null_ok) { @@ -394,6 +412,7 @@ { $var_list->add('zval', '*ret'); return " ret = php_gtk_new((GtkObject *)%s);\n" . + " %s\n" . " SEPARATE_ZVAL(&ret);\n" . " *return_value = *ret;\n" . " return;"; @@ -402,7 +421,7 @@ class Rect_Arg extends Arg_Type { function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$parse_type, + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$parse_type, $in_constructor) { $var_list->add(substr($type, 0, -1), $name); @@ -428,7 +447,7 @@ } function write_param($type, $name, $default, $null_ok, &$var_list, - &$parse_list, &$arg_list, &$extra_code, &$array_code) + &$parse_list, &$arg_list, &$extra_code, &$after_code, &$array_code) { $var_list->add('zval', '*' . $name); $parse_list[] = '&' . $name; @@ -441,6 +460,7 @@ { $var_list->add(substr($type, 0, -1), '*ret'); return " ret = %s;\n" . + " %s\n" . " *return_value = *php_" . $this->php_type . "_new(ret);\n" . " return;"; } @@ -450,6 +470,7 @@ function write_return($type, &$var_list) { return " *return_value = *php_gdk_atom_new(%s);\n" . + " %s\n" . " return;"; } } Index: php-gtk/generator/generator.php diff -u php-gtk/generator/generator.php:1.11 php-gtk/generator/generator.php:1.12 --- php-gtk/generator/generator.php:1.11 Sun Mar 4 16:21:42 2001 +++ php-gtk/generator/generator.php Mon Mar 5 13:25:37 2001 @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: generator.php,v 1.11 2001/03/05 00:21:42 andrei Exp $ */ +/* $Id: generator.php,v 1.12 2001/03/05 21:25:37 fmk Exp $ */ /* * Significant portions of this generator are based on the pygtk code generator @@ -105,6 +105,7 @@ $parse_list = array(''); $arg_list = array(''); $extra_code = array(); + $after_code = array(); $parse_type = array(); if ($method->varargs) @@ -129,6 +130,7 @@ $parse_list, $arg_list, $extra_code, + $after_code, $parse_type, false); } @@ -136,6 +138,7 @@ $arg_list = implode(', ', $arg_list); $parse_list = implode(', ', $parse_list); $extra_code = implode('', $extra_code); + $after_code = implode('', $after_code); $method_call = sprintf($method_call_tpl, $method->c_name, @@ -148,7 +151,8 @@ } $return_tpl = $ret_handler->write_return($method->return_type, $var_list); $return_code = sprintf($return_tpl, - $method_call); + $method_call, + $after_code); $method_code = sprintf($method_tpl, strtolower($method->c_name), @@ -173,6 +177,7 @@ $parse_list = array(''); $arg_list = array(); $extra_code = array(); + $after_code = array(); $parse_type = array(); foreach ($constructor->params as $params_array) { @@ -194,6 +199,7 @@ $parse_list, $arg_list, $extra_code, + $after_code, $parse_type, true); } @@ -201,6 +207,7 @@ $arg_list = implode(', ', $arg_list); $parse_list = implode(', ', $parse_list); $extra_code = implode('', $extra_code); + $after_code = implode('', $after_code); $var_list->add('GtkObject', '*wrapped_obj'); @@ -230,6 +237,7 @@ $parse_list = array(''); $arg_list = array(); $extra_code = array(); + $after_code = array(); $parse_type = array(); if ($function->varargs) @@ -254,6 +262,7 @@ $parse_list, $arg_list, $extra_code, + $after_code, $parse_type, false); } @@ -261,6 +270,7 @@ $arg_list = implode(', ', $arg_list); $parse_list = implode(', ', $parse_list); $extra_code = implode('', $extra_code); + $after_code = implode('', $after_code); $function_call = sprintf($function_call_tpl, $function->c_name, @@ -272,7 +282,8 @@ } $return_tpl = $ret_handler->write_return($function->return_type, $var_list); $return_code = sprintf($return_tpl, - $function_call); + $function_call, + $after_code); $function_code = sprintf($function_tpl, strtolower($function->c_name), @@ -308,7 +319,7 @@ $prop_tpl = $handler->write_return($field_type, $var_list); $prop_code = sprintf($prop_tpl, - $obj_cast . '(PHP_GTK_GET(object))->' . $field_name); + $obj_cast . '(PHP_GTK_GET(object))->' . $field_name, ""); $prop_code = str_replace("\n", "\n\t", $prop_code); $var_list_code = $var_list->to_string();
« previous php.gtk (#332) next »