LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Elizabeth M Smith Date: Sun Jul 27 08:22:55 2008 Subject: Dirty hack for 5.3 and Gobject::register_type
I've been working with php-gtk on 5.3, compiles fine and runs fine
except for one small issue.
In 5.3 a class in a namespace has colons in the full name - gobject's
register type does not allow colons in a name when you register the type
Attached is a small dirty hack to fix that - it copies the class's name,
replaces colons with underscores, and then uses the underscore version
to register the type.
This works fine - only caveat is you can't have a class in namespace
foo::bar::baz AND register a class named foo__bar__baz - I'm fairly
certain that won't be a common problem.
Unless someone has a better idea I'll commit this version.
Thanks,
Elizabeth
Index: phpg_gobject.c
===================================================================
RCS file: /repository/php-gtk/main/phpg_gobject.c,v
retrieving revision 1.68
diff -u -r1.68 phpg_gobject.c
--- phpg_gobject.c 29 Feb 2008 19:05:53 -0000 1.68
+++ phpg_gobject.c 26 Jul 2008 02:08:36 -0000
@@ -1352,7 +1352,7 @@
zend_class_entry *class = gobject_ce;
GType parent_type, new_type;
GTypeQuery query;
- const char *type_name;
+ const char *type_name, *class_name_copy;
zval **prop_decls, **signal_decls;
GTypeInfo type_info = {
@@ -1379,7 +1379,10 @@
return;
}
- type_name = class->name;
+ /* If this is a namespaced class we will have issues, since :: is not allowed, so copy and replace : */
+ class_name_copy = g_strdup(class->name);
+ type_name = g_strdelimit(class_name_copy, ":", '_');
+
if (g_type_from_name(type_name) != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "type '%s' already exists?", type_name);
return;
| Navigate in group php.gtk.dev at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by Zareef Ahmed
Powered By PHP Consultants |