|
View:
New views
12 Messages
—
Rating Filter:
Alert me
|
|
|
Reflection woesHello,
I've been using the Reflection API to automatically build a PHP skeleton file of all PHP-GTK elements, in order to enable code completion for PHP-GTK in Eclipse PDT, and probably any other PHP IDE since it would look like just any ordinary PHP file. However, in doing so, I've encountered what seem to be a few anomalies: (a) PHP-GTK classes return empty results on the getExtension()/getExtensionName() methods, unlike those in other extensions (b) some methods bear names which are reserved PHP words, and cannot therefore be declared as such. These reserved words are - "foreach" - PhpGtkCustomTreeModel - GtkListStore - GtkTextTagTable - GtkTreeModelFilter - GtkTreeModelSort - GtkTreeStore - GtkSourceTagTableand - "unset" - GtkPrintSettings These do not cause errors or even warnings on runtime, and indeed discussion on #php suggests it may be legit for an extension to define methods bearing the names of reserved words of the language, but it is unadvised. However, it prevents extending these classes in PHP by inheriting and redefining these methods, since defining such extensions results in a compile error. Since these methods are not marked with the "final" modifier, they should be inheritable, so this seems to be a bug indeed. (c) none of the methods supports the getPrototype() method, which causes an exception upon invokation. I'm not sure of the status of this methods, since it is listed in the PHP classbrowser: http://www.php.net/~helly/classbrowser/class.php?class=ReflectionMethod&extension=Reflection but not on the normal Reflection page: http://www.php.net/manual/en/language.oop5.reflection.php#language.oop5.reflection.reflectionmethod Frederic G. MARAND http://php-gtk.eu/ -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woes-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Frédéric G. MARAND wrote: > These do not cause errors or even warnings on runtime, and indeed > discussion on #php suggests it may be legit for an extension to define > methods bearing the names of reserved words of the language, but it is > unadvised. > > However, it prevents extending these classes in PHP by inheriting and > redefining these methods, since defining such extensions results in a > compile error. Since these methods are not marked with the "final" > modifier, they should be inheritable, so this seems to be a bug indeed. I suggest GtkPrintSettings be made an alias (for compatibility) but the real function be named in a way that makes it overwriteable (although at this stage I wonder what one would wan't to overwrite it for). Regarding the foreach() ones, I think this is just an unlucky naming, but should be easily changeable since these functions are only for internal use (aren't they?) and not part of the normal GTK API. Best Regards, Florian -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIJjwUmmrYql7RDyIRAgFYAKCooiDjSFij23r3RY24/LC7jP9kBACaA7hG HWCnebkquSwSUOxXOyKF5XM= =H/QO -----END PGP SIGNATURE----- -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woes-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Florian Breit wrote: > I suggest GtkPrintSettings be made an alias [...] GtkPrintSettings->unset() I meant. Sorry for that ;) - -- Florian -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIJjzhmmrYql7RDyIRAvdRAKCNjESAE8XMEbqz+wf7VR2ZDM/nCwCeJeYr 40JU1jYtzpFHC62N+7GaqzE= =zDcq -----END PGP SIGNATURE----- -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
|
|
|
Re: Reflection woes-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Frédéric G. MARAND wrote: > Florian, > > Not sure why you say they are not part of the "normal" Gtk API. They > appear to be listed just like any other method: > > http://library.gnome.org/devel/gtk/2.12/GtkPrintSettings.html#gtk-print-settings-foreach Indeed you are right for GtkTextTagTable and GtkPrintSettings. Different it is for GtkListStore and GtkTreeModelFilter which I cannot find any foreach-method defined for, though. GtkSourceTagTable is inheriting it from GtkTextTagTable. Didn't check them all when I read your message, sorry. However, I suggest the same apply to them than as for the unset-one, though I think perhaps it would be better we'd set up a general rule on how to approach such conflicts now and in future? Kind regards, Florian -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIJuEcmmrYql7RDyIRAojrAJ45g0moKxLUGDb4UkToYHDmu5ozKACghM2h iqYMqspx1HkTgPYa+1I7AXk= =Jl+T -----END PGP SIGNATURE----- -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woesFrédéric G. MARAND wrote:
> Hello, > > I've been using the Reflection API to automatically build a PHP skeleton > file of all PHP-GTK elements, in order to enable code completion for > PHP-GTK in Eclipse PDT, and probably any other PHP IDE since it would > look like just any ordinary PHP file. Sounds good. > However, in doing so, I've encountered what seem to be a few anomalies: > (a) PHP-GTK classes return empty results on the > getExtension()/getExtensionName() methods, unlike those in other extensions Yeah, this needs to be fixed. > (b) some methods bear names which are reserved PHP words, and cannot > therefore be declared as such. These reserved words are > - "foreach" > - PhpGtkCustomTreeModel > - GtkListStore > - GtkTextTagTable > - GtkTreeModelFilter > - GtkTreeModelSort > - GtkTreeStore > - GtkSourceTagTableand > - "unset" > - GtkPrintSettings > > These do not cause errors or even warnings on runtime, and indeed > discussion on #php suggests it may be legit for an extension to define > methods bearing the names of reserved words of the language, but it is > unadvised. > > However, it prevents extending these classes in PHP by inheriting and > redefining these methods, since defining such extensions results in a > compile error. Since these methods are not marked with the "final" > modifier, they should be inheritable, so this seems to be a bug indeed. It's not a bug, but more of a mismatch between languages. Trying to redefine "foreach" methods is kind of useless right now, because they will not be called by anything, but with the upcoming virtual method support, they will be. So we probably should think about migrating these to a new name, possibly "for_each". > (c) none of the methods supports the getPrototype() method, which causes > an exception upon invokation. I'm not sure of the status of this > methods, since it is listed in the PHP classbrowser: > http://www.php.net/~helly/classbrowser/class.php?class=ReflectionMethod&extension=Reflection > > but not on the normal Reflection page: > http://www.php.net/manual/en/language.oop5.reflection.php#language.oop5.reflection.reflectionmethod Hmm, I thought Christian put in a bunch of prototype descriptors in.. I'll take a look. -Andrei -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woesSo I did some digging around ran into a catch-22. The problem is that we're
registering all the classes in RINIT hook of PHP-GTK, and EG(current_module), which is used to associate the class with an extension on registration is empty in RINIT. We could move registration to MINIT hook, but then we don't have access to argc/argv which are used by gtk_init() function, since those are made available only in RINIT. Any ideas? The reason gtk_init() needs argc/argv is to parse out options like --display, etc. If we are willing to remove support for those options, then we can call gtk_init() with argc=0, argv=NULL and have it in MINIT. -Andrei Andrei Zmievski wrote: >> However, in doing so, I've encountered what seem to be a few anomalies: >> (a) PHP-GTK classes return empty results on the >> getExtension()/getExtensionName() methods, unlike those in other >> extensions > > Yeah, this needs to be fixed. -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woesHiya Andrei,
> Any ideas? The reason gtk_init() needs argc/argv is to parse out options > like --display, etc. If we are willing to remove support for those > options, then we can call gtk_init() with argc=0, argv=NULL and have it in > MINIT. Could you please clarify where '--display, etc' are used? As in, which scenarios? Thanks, - Steph -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woesThe list seems to be:
* --gtk-module * --g-fatal-warnings * --gtk-debug * --gtk-no-debug * --gdk-debug * --gdk-no-debug * --display * --sync * --no-xshm * --name * --class Here are Gtk+ source snippets related to this: static GOptionEntry gtk_args[] = { { "gtk-module", 0, 0, G_OPTION_ARG_CALLBACK, gtk_arg_module_cb, /* Description of --gtk-module=MODULES in --help output */ N_("Load additional GTK+ modules"), /* Placeholder in --gtk-module=MODULES in --help output */ N_("MODULES") }, { "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, /* Description of --g-fatal-warnings in --help output */ N_("Make all warnings fatal"), NULL }, #ifdef G_ENABLE_DEBUG { "gtk-debug", 0, 0, G_OPTION_ARG_CALLBACK, gtk_arg_debug_cb, /* Description of --gtk-debug=FLAGS in --help output */ N_("GTK+ debugging flags to set"), /* Placeholder in --gtk-debug=FLAGS in --help output */ N_("FLAGS") }, { "gtk-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, gtk_arg_no_debug_cb, /* Description of --gtk-no-debug=FLAGS in --help output */ N_("GTK+ debugging flags to unset"), /* Placeholder in --gtk-no-debug=FLAGS in --help output */ N_("FLAGS") }, #endif { NULL } }; static GOptionEntry gdk_args[] = { { "class", 0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_class_cb, /* Description of --class=CLASS in --help output */ N_("Program class as used by the window manager"), /* Placeholder in --class=CLASS in --help output */ N_("CLASS") }, { "name", 0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_name_cb, /* Description of --name=NAME in --help output */ N_("Program name as used by the window manager"), /* Placeholder in --name=NAME in --help output */ N_("NAME") }, { "display", 0, G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &_gdk_display_name, /* Description of --display=DISPLAY in --help output */ N_("X display to use"), /* Placeholder in --display=DISPLAY in --help output */ N_("DISPLAY") }, { "screen", 0, 0, G_OPTION_ARG_INT, &_gdk_screen_number, /* Description of --screen=SCREEN in --help output */ N_("X screen to use"), /* Placeholder in --screen=SCREEN in --help output */ N_("SCREEN") }, #ifdef G_ENABLE_DEBUG { "gdk-debug", 0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_debug_cb, /* Description of --gdk-debug=FLAGS in --help output */ N_("Gdk debugging flags to set"), /* Placeholder in --gdk-debug=FLAGS in --help output */ N_("FLAGS") }, { "gdk-no-debug", 0, 0, G_OPTION_ARG_CALLBACK, gdk_arg_no_debug_cb, /* Description of --gdk-no-debug=FLAGS in --help output */ N_("Gdk debugging flags to unset"), /* Placeholder in --gdk-no-debug=FLAGS in --help output */ N_("FLAGS") }, #endif { NULL } }; Steph Fox wrote: > Hiya Andrei, > >> Any ideas? The reason gtk_init() needs argc/argv is to parse out >> options like --display, etc. If we are willing to remove support for >> those options, then we can call gtk_init() with argc=0, argv=NULL and >> have it in MINIT. > > Could you please clarify where '--display, etc' are used? As in, which > scenarios? > > Thanks, > > - Steph -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
|
|
|
Re: Reflection woesMy reflection-based script seems to be working now, and it also put into
light a three other symbol clashes in the PHP-GTK constants: Gdk::XOR Gdk::AND Gdk::OR These are also reserved PHP words. The problem with Traversable not being implementable in a script is really a PHP issue, not one with PHP-GTK. Andrei Zmievski a écrit : [...}> It's not a bug, but more of a mismatch between languages. Trying to > redefine "foreach" methods is kind of useless right now, because they > will not be called by anything, but with the upcoming virtual method > support, they will be. So we probably should think about migrating these > to a new name, possibly "for_each". [...] -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Reflection woesI'd like to make sure that we cannot turn it off.. Because otherwise I
don't see a way around it. -Andrei Steph Fox wrote: > Hi Frédéric, > > I had a vague memory of that - that's why I asked. It's come up on the > mailing list a few times in the past. > > Andrei: there's a use case for it in PHP-GTK, we can't just turn it off :( > > - Steph > > ----- Original Message ----- From: ""Frédéric G. MARAND"" <fgm@...> > To: "Steph Fox" <steph@...> > Sent: Sunday, May 11, 2008 11:57 PM > Subject: Re: [PHP-GTK-DEV] Reflection woes > > > These are the default X.11 arguments: --display, for instance, allows > the application to display a remote display, different from the one it > was started on. > > Sample case: from a putty session, without a X display, open a PHP-GTK > app to the attached X server. > > Steph Fox a écrit : >> Hiya Andrei, >> >>> Any ideas? The reason gtk_init() needs argc/argv is to parse out >>> options like --display, etc. If we are willing to remove support for >>> those options, then we can call gtk_init() with argc=0, argv=NULL and >>> have it in MINIT. >> >> Could you please clarify where '--display, etc' are used? As in, which >> scenarios? >> >> Thanks, >> >> - Steph >> > -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
| Free Forum Powered by Nabble | Forum Help |