[gxml/newattr: 4/13] Document.vala: add the ability to lookup attributes, since we'll map xmlAttr to GXmlAttr for caching



commit 82e3b40740369eb8fc6f0869b94b66cee64407a8
Author: Richard Schwarting <aquarichy gmail com>
Date:   Tue Oct 22 02:41:15 2013 -0400

    Document.vala: add the ability to lookup attributes, since we'll map xmlAttr to GXmlAttr for caching in 
our Document now

 gxml/Document.vala |   30 +++++++++++++-----------------
 1 files changed, 13 insertions(+), 17 deletions(-)
---
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 62ddcbd..b10fb63 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -108,6 +108,11 @@ namespace GXml {
                internal Xml.Doc *xmldoc;
 
                /* *** Private methods *** */
+               internal unowned Attr? lookup_attr (Xml.Attr *xmlattr) {
+                       // Xml.Attr and Xml.Node are intentionally compatible
+                       return (Attr)this.lookup_node ((Xml.Node*)xmlattr);
+               }
+
                internal unowned Node? lookup_node (Xml.Node *xmlnode) {
                        unowned Node domnode;
 
@@ -119,7 +124,8 @@ namespace GXml {
                        if (domnode == null) {
                                // If we don't have a cached the appropriate Node for a given Xml.Node* yet, 
create it (type matters)
                                // TODO: see if we can attach logic to the enum {} to handle this
-                               switch ((NodeType)xmlnode->type) {
+                               NodeType nodetype = (NodeType)xmlnode->type;
+                               switch (nodetype) {
                                case NodeType.ELEMENT:
                                        new Element (xmlnode, this);
                                        break;
@@ -135,27 +141,17 @@ namespace GXml {
                                case NodeType.DOCUMENT_FRAGMENT:
                                        new DocumentFragment (xmlnode, this);
                                        break;
-                                       /* TODO: These are not yet implemented */
-                               case NodeType.ENTITY_REFERENCE:
-                                       // new EntityReference (xmlnode, this);
+                               case NodeType.ATTRIBUTE:
+                                       new Attr ((Xml.Attr*)xmlnode, this);
                                        break;
+                                       /* TODO: These are not yet implemented (but we won't support Document 
*/
+                               case NodeType.ENTITY_REFERENCE:
                                case NodeType.ENTITY:
-                                       // new Entity (xmlnode, this);
-                                       break;
                                case NodeType.PROCESSING_INSTRUCTION:
-                                       // new ProcessingInstruction (xmlnode, this);
-                                       break;
                                case NodeType.DOCUMENT_TYPE:
-                                       // new DocumentType (xmlnode, this);
-                                       break;
                                case NodeType.NOTATION:
-                                       // new Notation (xmlnode, this);
-                                       break;
-                               case NodeType.ATTRIBUTE:
-                                       // TODO: error
-                                       break;
-                               case NodeType.DOCUMENT:
-                                       // TODO: error
+                               case NodeType.DOCUMENT: 
+                                       GLib.warning ("Looking up %s from an xmlNode* is not supported", 
nodetype.to_string ());
                                        break;
                                }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]