[Kde-bindings] port of pyjamas to pykde / khtml - issues and observations with pykde
Richard Dale
rdale at foton.es
Tue Oct 14 10:59:38 UTC 2008
On Monday 13 October 2008 21:43:17 Luke Kenneth Casson Leighton wrote:
> > also, crucially - absolutely, absolutely crucially: you can't do a
> > "compare" against nodes. the objects are potentially different. and
>
> folks, hi,
>
> this is a show-stopper, and needs to be fixed. i tried creating a
> workaround wrapper class, by extending pykhtml's dom.py, with a view
> to making it the "central" location - choke-point - through which the
> creation of all Node and Node-derived objects go, but there doesn't
> exist a function in the underlying DOM model to uniquely identify the
> c++ objects. not the wrappers _around_ the c++ objects, the c++
> objects themselves.
The best place for this sort of thing is to post to the kde-bindings at kde.org
list, and talk with Simon Edwards the PyKDE maintainer.
However, you are right in this case that the problem is that there isn't
sufficient RTTI information in the C++ api to identify what class an instance
is. Here is a snippet of code from the Ruby bindings that attempts to identify
DOM::Node classes. But there are many other classes which can't be identified.
} else if (strcmp(smoke->classes[classId].className, "DOM::Node") == 0) {
DOM::Node * node = (DOM::Node *) smoke->cast(ptr, classId, smoke-
>idClass("DOM::Node"));
switch (node->nodeType()) {
case DOM::Node::ELEMENT_NODE:
if (((DOM::Element*)node)->isHTMLElement()) {
return "DOM::HTMLElement";
} else {
return "DOM::Element";
}
case DOM::Node::ATTRIBUTE_NODE:
return "DOM::Attr";
case DOM::Node::TEXT_NODE:
return "DOM::Text";
case DOM::Node::CDATA_SECTION_NODE:
return "DOM::CDATASection";
case DOM::Node::ENTITY_REFERENCE_NODE:
return "DOM::EntityReference";
case DOM::Node::ENTITY_NODE:
return "DOM::Entity";
case DOM::Node::PROCESSING_INSTRUCTION_NODE:
return "DOM::ProcessingInstruction";
case DOM::Node::COMMENT_NODE:
return "DOM::Comment";
case DOM::Node::DOCUMENT_NODE:
return "DOM::Document";
case DOM::Node::DOCUMENT_TYPE_NODE:
return "DOM::DocumentType";
case DOM::Node::DOCUMENT_FRAGMENT_NODE:
return "DOM::DocumentFragment";
case DOM::Node::NOTATION_NODE:
return "DOM::Notation";
}
}
Maybe the code has changed since I looked at it and KDE3, I haven't had a
really careful look at it for a while. The KHTML guys might be able to help
best.
-- Richard
More information about the Kde-bindings
mailing list