[prev in list] [next in list] [prev in thread] [next in thread]
List: php-gtk-cvs
Subject: [php-gtk-cvs] com gtk/php-gtk: Break out type name retrieval into a separate function.: =?UTF-8?Q?ma
From: David Soria Parra <dsp () php ! net>
Date: 2001-05-10 19:21:19
Message-ID: php-mail-83285de5aa542a7954802ebda573ed0666222435 () git ! php ! net
[Download RAW message or body]
Commit: b0daf29b99999fd6e5df1e8082a1c0aa840b9bd1
Author: Andrei Zmievski <andrei@php.net> Thu, 10 May 2001 19:21:19 +0000
Parents: c838301f43be7a7ceeba320a9b66a961bbfe6255
Branches: GTK2 PHP_GTK_1 ZE2_PORT devel master
Link: http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=b0daf29b99999fd6e5df1e8082a1c0aa840b9bd1
Log:
Break out type name retrieval into a separate function.
Changed paths:
M main/php_gtk_util.c
Diff:
b0daf29b99999fd6e5df1e8082a1c0aa840b9bd1
diff --git a/main/php_gtk_util.c b/main/php_gtk_util.c
index 548c53e..e5f958f 100644
--- a/main/php_gtk_util.c
+++ b/main/php_gtk_util.c
@@ -190,59 +190,52 @@ static char *parse_arg_impl(zval **arg, va_list *va, char **spec, char *buf)
return NULL;
}
-static int parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet)
+static char *php_gtk_zval_type_name(zval *arg)
{
- char *expected_type;
- char *actual_type;
- char buf[1024];
- char errorbuf[1024];
- char objtype[1024];
+ switch (Z_TYPE_P(arg)) {
+ case IS_NULL:
+ return "null";
- expected_type = parse_arg_impl(arg, va, spec, errorbuf);
- if (expected_type) {
- switch (Z_TYPE_PP(arg)) {
- case IS_NULL:
- actual_type = "NULL";
- break;
+ case IS_LONG:
+ return "integer";
- case IS_LONG:
- actual_type = "integer";
- break;
-
- case IS_DOUBLE:
- actual_type = "double";
- break;
+ case IS_DOUBLE:
+ return "double";
- case IS_STRING:
- actual_type = "string";
- break;
+ case IS_STRING:
+ return "string";
- case IS_ARRAY:
- actual_type = "array";
- break;
+ case IS_ARRAY:
+ return "array";
- case IS_OBJECT:
- sprintf(objtype, "object <%s>", Z_OBJCE_PP(arg)->name);
- actual_type = objtype;
- break;
+ case IS_OBJECT:
+ return Z_OBJCE_P(arg)->name;
- case IS_BOOL:
- actual_type = "boolean";
- break;
+ case IS_BOOL:
+ return "boolean";
- case IS_RESOURCE:
- actual_type = "resource";
- break;
+ case IS_RESOURCE:
+ return "resource";
- default:
- actual_type = "unknown";
- break;
+ default:
+ return "unknown";
+ }
+}
- }
+static int parse_arg(int arg_num, zval **arg, va_list *va, char **spec, int quiet)
+{
+ char *expected_type;
+ char *actual_type;
+ char buf[1024];
+ char errorbuf[1024];
+ char objtype[1024];
+ expected_type = parse_arg_impl(arg, va, spec, errorbuf);
+ if (expected_type) {
if (!quiet) {
sprintf(buf, "%s() expects argument %d to be %s, %s given",
- get_active_function_name(), arg_num, expected_type, actual_type);
+ get_active_function_name(), arg_num, expected_type,
+ php_gtk_zval_type_name(*arg));
php_error(E_WARNING, buf);
}
return 0;
--
PHP-GTK CVS Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic