roxen.lists.pike.general

Subject Author Date
[7.8.316] more Problems with Parser.XML.DOM (w/patch) Reinhard Pfau <Reinhard[dot]Pfau[at]gmx[dot]de> 13-08-2009
Hi,

trying to get my website generator working with Pike 7.8 I discovered
more problems with Parser.XML.DOM... :-(

Some methods of some classes within that module were marked as
"protected" in Pike 7.6.112 (and older versions). Since the modifier
"protected" was just a placeholder there, the methods were public.

Looking closer at these methods it looks like that the modifier
"protected" was meant to work like in C++: it should allow indexing the
method within another instance of the same class (hierarchy).

But in Pike 7.8 "protected" is just an alias/a replacement for
"static"...
All originally "static" modifiers from the DOM module were replaced with
"protected", but the originally "protected" one were kept..
This leads to a number of failures when these methods are looked up by a
different object (of the same class); these lookups now return
UNDEFINED...  and they are looked up this way.... :-(

The following patch resolves that problem by commenting out the
"protected" modifiers of the affected methods.
(I prefer commenting out so that the information is kept (at least for
human readers) that these methods should be protected in some way and
are "not really public".

----vvv-------------------------------------------------
--- lib/modules/Parser.pmod/XML.pmod/DOM.pmod:7.8.316	2008-06-28
18:36:55.000000000 +0200
+++ lib/modules/Parser.pmod/XML.pmod/DOM.pmod	2009-08-12 01:14:33.000000000 +0200
@@ -203,11 +203,11 @@
   protected class NodeNodeList {
     inherit NodeList;
 
-    protected int search(Node n) { return predef::search(nodes, n); }
-    protected void insert_at(int pos, array(Node) ns) {
+    /*protected*/ int search(Node n) { return predef::search(nodes, n); }
+    /*protected*/ void insert_at(int pos, array(Node) ns) {
       nodes = nodes[..pos-1] + ns + nodes[pos..];
     }
-    protected void delete_at(int pos) {
+    /*protected*/ void delete_at(int pos) {
       nodes = nodes[..pos-1]+nodes[pos+1..];
     }
   }
@@ -216,7 +216,7 @@
   protected NodeNodeList child_nodes;
   protected Document owner_document;
 
-  protected int is_readonly() {
+  /*protected*/ int is_readonly() {
     return parent_node && parent_node->is_readonly();
   }
 
@@ -276,7 +276,7 @@
     return 0;
   }
 
-  protected void _set_parent(Node new_parent)
+  /*protected*/ void _set_parent(Node new_parent)
   {
     if(new_parent && parent_node)
 	parent_node->remove_child(this);
@@ -583,9 +583,9 @@
     return new;
   }
 
-  protected void _set_parent(Node new_parent) { }
+  /*protected*/ void _set_parent(Node new_parent) { }
 
-  protected void _bind(Element new_element)
+  /*protected*/ void _bind(Element new_element)
   {
     if(new_element && bound_to)
       throw(DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
@@ -817,7 +817,7 @@
   NamedNodeMap get_entities() { return entities || create_entities(); }
   NamedNodeMap get_notations() { return notations || create_notations(); }
 
-  protected void _set_owner_document(Document d) { owner_document = d; }
+  /*protected*/ void _set_owner_document(Document d) { owner_document = d; }
 
   protected NamedNodeMap create_entities()
   {
@@ -849,7 +849,7 @@
   string get_node_name() { return name; }
   string get_public_id() { return public_id; }
   string get_system_id() { return system_id; }
-  protected int is_readonly() { return 1; }
+  /*protected*/ int is_readonly() { return 1; }
 
   protected void create(Document owner, string _name, string p_id, string s_id)
   {
@@ -871,7 +871,7 @@
   string get_public_id() { return public_id; }
   string get_system_id() { return system_id; }
   string get_notation_name() { return notation_name; }
-  protected int is_readonly() { return name != 0; }
+  /*protected*/ int is_readonly() { return name != 0; }
 
   string cast(string to)
   {
@@ -907,7 +907,7 @@
 
   int get_node_type() { return ENTITY_REFERENCE_NODE; }
   string get_node_name() { return name; }
-  protected int is_readonly() { return 1; }
+  /*protected*/ int is_readonly() { return 1; }
 
   Node clone_node(int|void deep) {
     return owner_document->create_entity_reference(name);
----^^^-------------------------------------------------

After that patch my website generator at least runs without exceptions..
but the output produced is still not correct; even if I use the "-V7.6"
switch for Pike 7.6 compatibility.... :-(
With Pike-7.6.112 everything works fine.

Looks like there are still some more differences left... *sigh*
I'll try to find them, too.

(Hmm.. looks like no really tested the DOM module with 7.8.*. Ok; now,
someone does ;-) )

Greetings,
Reinhard.

-- 
Reinhard Pfau
mailto:<Reinhard.Pfau[at]gmx.de>