[prev in list] [next in list] [prev in thread] [next in thread]
List: php-gtk-cvs
Subject: [php-gtk-cvs] com gtk/php-gtk: - Do not register 'gtype' class constants for interfaces. - When crea
From: David Soria Parra <dsp () php ! net>
Date: 2007-03-03 19:23:02
Message-ID: php-mail-c003ca869c8dcab4f3904ba21da7b753771351887 () git ! php ! net
[Download RAW message or body]
Commit: 482a962b034c61f6623fbe06e92f66523f1c5950
Author: Andrei Zmievski <andrei@php.net> Sat, 3 Mar 2007 19:23:02 +0000
Parents: 67ad718cacb2a6c64fc639b7a2c3ef2af7f1026d
Branches: master
Link: http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=482a962b034c61f6623fbe06e92f66523f1c5950
Log:
- Do not register 'gtype' class constants for interfaces.
- When creating classes dynamically, unset the abstract flag from
methods inherited from interfaces and from the class itself.
- Use explicit function entry instead of ZEND_ABSTRACT_ME() to point to
default interface method implementation.
Changed paths:
M generator/generator.php
M generator/templates.php
M main/phpg_support.c
Diff:
482a962b034c61f6623fbe06e92f66523f1c5950
diff --git a/generator/generator.php b/generator/generator.php
index a74d1d7..2a1fced 100644
--- a/generator/generator.php
+++ b/generator/generator.php
@@ -756,7 +756,7 @@ class Generator {
}
} else if ($class->def_type == 'interface') {
foreach ($method_entries as $me) {
- $method_defs[] = vsprintf(Templates::abs_method_entry, $me);
+ $method_defs[] = sprintf(Templates::abs_method_entry, $me[1], \
$me[0], $me[1], $me[2], 'ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT'); }
}
@@ -810,7 +810,11 @@ class Generator {
'ifaces' => join(', ', $iface_entries),
'num_ifaces' => \
count($iface_entries))); }
- $this->gtype_constants .= sprintf(Templates::gtype_constant, $class->ce, \
$class->typecode); + /* Do not register gtype constants for interfaces, since \
interfaces will + never be instantiated anyway. */
+ if ($class->def_type != 'interface') {
+ $this->gtype_constants .= sprintf(Templates::gtype_constant, $class->ce, \
$class->typecode); + }
return array('ce' => $class->ce,
'class' => $class->in_module . $class->name,
@@ -1459,4 +1463,4 @@ $generator->write_source($savefile);
error_reporting($old_error_reporting);
/* vim: set et sts=4: */
-?>
\ No newline at end of file
+?>
diff --git a/generator/templates.php b/generator/templates.php
index 3780e40..0a33131 100644
--- a/generator/templates.php
+++ b/generator/templates.php
@@ -205,7 +205,7 @@ const non_gtk_object_init = "
php_gtk_set_object(this_ptr, wrapped_obj, le_%s);\n";
const method_entry = "\tPHP_ME(%s, %s, %s, %s)\n";
-const abs_method_entry = "\tZEND_ABSTRACT_ME(%s, %s, %s)\n";
+const abs_method_entry = "\tZEND_FENTRY(%s, ZEND_MN(%s_%s), %s, %s)\n";
const function_entry = "#if ZEND_EXTENSION_API_NO > 220051025\n\tPHP_ME_MAPPING(%s, \
%s, NULL, 0)\n#else\n\tPHP_ME_MAPPING(%s, %s, NULL)\n#endif\n"; const alias_entry = \
"\tPHP_MALIAS(%s, %s, %s, %s, %s)\n"; const functions_decl = "
diff --git a/main/phpg_support.c b/main/phpg_support.c
index 6d2f542..5d83aaf 100644
--- a/main/phpg_support.c
+++ b/main/phpg_support.c
@@ -473,6 +473,20 @@ PHP_GTK_API void phpg_register_string_constant(zend_class_entry \
*ce, char *name, /* }}} */
/* {{{ phpg_create_class */
+
+static int unset_abstract_flag(zend_function *func, int num_args, va_list args, \
zend_hash_key *hash_key) +{
+ zend_class_entry *iface_ce = va_arg(args, zend_class_entry *);
+
+ if (func->type == ZEND_INTERNAL_FUNCTION) {
+ if (zend_hash_quick_exists(&iface_ce->function_table, hash_key->arKey, \
hash_key->nKeyLength, hash_key->h)) { + \
((zend_internal_function*)func)->fn_flags &= ~ZEND_ACC_ABSTRACT; + }
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+
PHP_GTK_API zend_class_entry* phpg_create_class(GType gtype)
{
zend_class_entry *parent_ce, *iface_ce, *ce;
@@ -492,6 +506,12 @@ PHP_GTK_API zend_class_entry* phpg_create_class(GType gtype)
for (i = 0; i < n_ifaces; i++) {
iface_ce = phpg_class_from_gtype(ifaces[i]);
zend_class_implements(ce TSRMLS_CC, 1, iface_ce);
+ if (!G_TYPE_IS_INTERFACE(gtype)) {
+ zend_hash_apply_with_arguments(&ce->function_table, \
(apply_func_args_t) unset_abstract_flag, 1, iface_ce TSRMLS_CC); + }
+ }
+ if (!G_TYPE_IS_INTERFACE(gtype)) {
+ ce->ce_flags &= ~ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
}
g_free(ifaces);
}
--
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