[Webkit-unassigned] [Bug 16401] [GTK] GObject/C DOM binding
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Feb 11 06:32:50 PST 2009
https://bugs.webkit.org/show_bug.cgi?id=16401
------- Comment #141 from lkcl at lkcl.net 2009-02-11 06:32 PDT -------
> When are properties actually useful? They are unconfortable to use even in
> Python. For widgets, software such as Glade benefits from them, but they don�t
> seem to be so useful in the DOM. I wouldn't regret it if they dissapeared.
i mentioned this earlier, but will repeat it here so that it is clearer,
martin. automated property detection in higher-level abstract classes.
when providing an abstraction layer on top of python-pygobject bindings,
for example, which is what pyjamas-desktop is (it's a port of GWT to python
_and_ webkit).
all that is needed, to replace javascript code:
if (node.offsetWidth > 20)
{
Window.alert("width > 20");
}
is this:
if node.offsetWidth > 20:
ui.Window.alert("width > 20")
that's it. done. finished.
underneath, that node.offsetWidth does something like this:
def __getattr__(self, property_name):
return gdom_node_get_property(property_name)
that's all. nothing to it. dead. simple.
if you REMOVE property-getting/setting, it gets xxxxing AWFUL:
def __getattr__(self, property_name):
s = "gdom_node_get_%s" % property_name
return eval(s)
that's the best "simple" case i can think of, and it's pretty bad.
here's the much much worse-case scenario:
def __getattr__(self, property_name):
t = gdom_node_get_type(self, "type") # argh! can't even get the node type!
if t == "element":
if property_name == 'width':
return gdom_element_get_width()
elif property_name == 'height':
return gdom_element_get_height()
...
...
elif t == '....'
...
....
...
...
...
...
this will be about a _thousand_ lines long, and require a _nightmare_
maintenance task as the DOM model is expanded.
and that's just "get". what about "set"?
yes, you could auto-generate this... but from what? from the original
IDL file??
you can't auto-generate it from the .defs file because the information
has been lost by that point as to which bits were properties and which
bits were truly functions.
apologies for spelling it out like this but i hope it's clearer as to
why it is so damn important that properties be available as properties.
if you're doing a "simple language thing" - great, good luck, go for it,
you will have no need for and no purpose for which getter/setter properties
are useful.
if however you're providing an abstraction layer on top of language
bindings on top of the glib/gobject bindings, then having exactly the
same access to properties in exactly the same way that javascript has
access to properties is utterly essential.
l.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list