[webkit-dev] getting back to sub-classes of gobjects

Luke Kenneth Casson Leighton lkcl at lkcl.net
Wed Aug 27 14:52:31 PDT 2008


it's almost there! i've started on pyjamas-desktop/pywebkitgtk now,
as a test case of the DOM bindings, and, given that the code-coverage will
be extensive [i'd already abandoned porting pyjamas to pygtk2),
it's a pretty good test-case.

i have quite an important question - related to my previous one which
was kindly answered with a simple "why don't you do what we do in pygtk
which is to just type-cast down to the base class, with e.g. GTK_BUTTON(obj)"?

that turned out to be the _correct_ - very simple - question :)

now, of course, i have the reverse problem: i need to get _back_ to the
sub-class gobject instance.

the issue is that you can have "child nodes" - in the DOM model - and of
course, each "child node" is mapped to a gobject.  HOWEVER, unfortunately,
all the "getter" functions return gobjects of type "Node".  e.g. from the
function gdom_document_get_element_by_id() which maps onto
DOM.getElementById of course.

e.g. i don't _want_ my c++ object e.g. "HTMLButton" to be mapped to a damn
gobject of type GDOM_TYPE_NODE, i want my damn GDOM_TYPE_HTML_BUTTON thank
you very much :)

so i'm suffering the glib equivalent of c++ typecasting, and i don't know
the voodoo magic to get back to the right type!

any pointers greatly appreciated.  it's _nearly_ there.


More information about the webkit-dev mailing list