cvs: php-gtk / NEWS /src php_gtk.h php_gtk_object.c php_gtk_types.c php_gtk_util.c

From: Date: Mon, 05 Mar 2001 04:47:49 +0000
Subject: cvs: php-gtk / NEWS /src php_gtk.h php_gtk_object.c php_gtk_types.c php_gtk_util.c
Groups: php.gtk 
Request: Send a blank email to php-gtk+get-270@lists.php.net to get a copy of this message
andrei Sun Mar 4 20:47:49 2001 EDT Modified files: /php-gtk NEWS /php-gtk/src php_gtk.h php_gtk_object.c php_gtk_types.c php_gtk_util.c Log: * Renamed php_gtk_check_callable() to php_gtk_is_callable(). * Added an extra parameter to php_gtk_is_callable() that is filled in with the name of the callable. Now just need to use it everywhere. * Added php_gtk_parse_args_hash() internal function. Index: php-gtk/NEWS diff -u php-gtk/NEWS:1.5 php-gtk/NEWS:1.6 --- php-gtk/NEWS:1.5 Sat Mar 3 13:13:33 2001 +++ php-gtk/NEWS Sun Mar 4 20:47:49 2001 @@ -1,3 +1,4 @@ + - implemented support for creating menus via GtkItemFactory. - fixed loading of the extension via php.ini. - fixed timeout and idle handler marshaller so that they are called more than once. Index: php-gtk/src/php_gtk.h diff -u php-gtk/src/php_gtk.h:1.18 php-gtk/src/php_gtk.h:1.19 --- php-gtk/src/php_gtk.h:1.18 Fri Mar 2 22:25:22 2001 +++ php-gtk/src/php_gtk.h Sun Mar 4 20:47:49 2001 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: php_gtk.h,v 1.18 2001/03/03 06:25:22 andrei Exp $: */ +/* $Id: php_gtk.h,v 1.19 2001/03/05 04:47:49 andrei Exp $: */ #ifndef _PHP_GTK_H #define _PHP_GTK_H @@ -140,6 +140,7 @@ /* Utility functions. */ int php_gtk_parse_args(int argc, char *format, ...); int php_gtk_parse_args_quiet(int argc, char *format, ...); +int php_gtk_parse_args_hash(zval *hash, char *format, ...); int php_gtk_check_class(zval *wrapper, zend_class_entry *expected_ce); void php_gtk_invalidate(zval *wrapper); zend_bool php_gtk_check_callable(zval *function); Index: php-gtk/src/php_gtk_object.c diff -u php-gtk/src/php_gtk_object.c:1.16 php-gtk/src/php_gtk_object.c:1.17 --- php-gtk/src/php_gtk_object.c:1.16 Sat Mar 3 08:12:11 2001 +++ php-gtk/src/php_gtk_object.c Sun Mar 4 20:47:49 2001 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: php_gtk_object.c,v 1.16 2001/03/03 16:12:11 andrei Exp $ */ +/* $Id: php_gtk_object.c,v 1.17 2001/03/05 04:47:49 andrei Exp $ */ #include "php_gtk.h" @@ -153,7 +153,7 @@ gtk_args = php_gtk_args_as_hash(nargs, args); - if (!php_gtk_check_callable(signal_data)) { + if (!php_gtk_is_callable(signal_data, NULL)) { zend_hash_index_find(Z_ARRVAL_P(signal_data), 0, (void **)&func); zend_hash_index_find(Z_ARRVAL_P(signal_data), 1, (void **)&extra); zend_hash_index_find(Z_ARRVAL_P(signal_data), 2, (void **)&pass_wrapper); @@ -198,7 +198,7 @@ zval *retval = NULL; ELS_FETCH(); - if (!php_gtk_check_callable(handler_data)) { + if (!php_gtk_is_callable(handler_data, NULL)) { zend_hash_index_find(Z_ARRVAL_P(handler_data), 0, (void **)&func); zend_hash_index_find(Z_ARRVAL_P(handler_data), 1, (void **)&extra); handler_args = php_gtk_hash_as_array(*extra); @@ -234,6 +234,8 @@ input_args[1] = &condition; call_user_function_ex(EG(function_table), NULL, func, &retval, 2, input_args, 1, NULL); + zval_ptr_dtor(&source); + zval_ptr_dtor(&condition); if (retval) zval_ptr_dtor(&retval); } Index: php-gtk/src/php_gtk_types.c diff -u php-gtk/src/php_gtk_types.c:1.17 php-gtk/src/php_gtk_types.c:1.18 --- php-gtk/src/php_gtk_types.c:1.17 Thu Mar 1 08:43:33 2001 +++ php-gtk/src/php_gtk_types.c Sun Mar 4 20:47:49 2001 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: php_gtk_types.c,v 1.17 2001/03/01 16:43:33 andrei Exp $ */ +/* $Id: php_gtk_types.c,v 1.18 2001/03/05 04:47:49 andrei Exp $ */ #include "php_gtk.h" @@ -1532,7 +1532,7 @@ } accel_group = gtk_accel_group_new(); - *return_value = *php_gtk_accel_group_new(accel_group); + php_gtk_set_object(this_ptr, accel_group, le_gtk_accel_group); } PHP_FUNCTION(gtk_accel_group_lock) Index: php-gtk/src/php_gtk_util.c diff -u php-gtk/src/php_gtk_util.c:1.8 php-gtk/src/php_gtk_util.c:1.9 --- php-gtk/src/php_gtk_util.c:1.8 Thu Mar 1 08:43:33 2001 +++ php-gtk/src/php_gtk_util.c Sun Mar 4 20:47:49 2001 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: php_gtk_util.c,v 1.8 2001/03/01 16:43:33 andrei Exp $ */ +/* $Id: php_gtk_util.c,v 1.9 2001/03/05 04:47:49 andrei Exp $ */ #include "php_gtk.h" @@ -348,6 +348,21 @@ return retval; } +int php_gtk_parse_args_hash(zval *hash, char *format, ...) +{ + va_list va; + int retval; + zval ***args; + + va_start(va, format); + args = php_gtk_hash_as_array(hash); + retval = parse_va_args(zend_hash_num_elements(Z_ARRVAL_P(hash)), args, format, &va, 0); + efree(args); + va_end(va); + + return retval; +} + int php_gtk_check_class(zval *wrapper, zend_class_entry *expected_ce) { zend_class_entry *ce; @@ -370,19 +385,21 @@ ZVAL_NULL(wrapper); } -zend_bool php_gtk_check_callable(zval *function) +zend_bool php_gtk_is_callable(zval *callable, char **callable_name) { char *lcname; int retval = 0; ELS_FETCH(); - switch (Z_TYPE_P(function)) { + switch (Z_TYPE_P(callable)) { case IS_STRING: - lcname = estrndup(Z_STRVAL_P(function), Z_STRLEN_P(function)); - zend_str_tolower(lcname, Z_STRLEN_P(function)); - if (zend_hash_exists(EG(function_table), lcname, Z_STRLEN_P(function)+1)) + lcname = estrndup(Z_STRVAL_P(callable), Z_STRLEN_P(callable)); + zend_str_tolower(lcname, Z_STRLEN_P(callable)); + if (zend_hash_exists(EG(function_table), lcname, Z_STRLEN_P(callable)+1)) retval = 1; efree(lcname); + if (!retval && callable_name) + *callable_name = g_strndup(Z_STRVAL_P(callable), Z_STRLEN_P(callable)); break; case IS_ARRAY: @@ -391,8 +408,8 @@ zval **obj; zend_class_entry *ce; - if (zend_hash_index_find(Z_ARRVAL_P(function), 0, (void **) &obj) == SUCCESS && - zend_hash_index_find(Z_ARRVAL_P(function), 1, (void **) &method) == SUCCESS && + if (zend_hash_index_find(Z_ARRVAL_P(callable), 0, (void **) &obj) == SUCCESS && + zend_hash_index_find(Z_ARRVAL_P(callable), 1, (void **) &method) == SUCCESS && (Z_TYPE_PP(obj) == IS_OBJECT || Z_TYPE_PP(obj) == IS_STRING) && Z_TYPE_PP(method) == IS_STRING) { if (Z_TYPE_PP(obj) == IS_STRING) { @@ -402,16 +419,22 @@ zend_str_tolower(lcname, Z_STRLEN_PP(obj)); found = zend_hash_find(EG(class_table), lcname, Z_STRLEN_PP(obj) + 1, (void**)&ce); efree(lcname); - if (found == FAILURE) + if (found == FAILURE) { + if (callable_name) + *callable_name = g_strdup_printf("%s::%s", Z_STRVAL_PP(obj), Z_STRVAL_PP(method)); break; + } } else ce = Z_OBJCE_PP(obj); lcname = estrndup(Z_STRVAL_PP(method), Z_STRLEN_PP(method)); zend_str_tolower(lcname, Z_STRLEN_PP(method)); if (zend_hash_exists(&ce->function_table, lcname, Z_STRLEN_PP(method)+1)) retval = 1; + if (!retval && callable_name) + *callable_name = g_strdup_printf("%s::%s", ce->name, Z_STRVAL_PP(method)); efree(lcname); - } + } else if (callable_name) + *callable_name = g_strdup("unknown"); } break;

« previous php.gtk (#270) next »