[4suite-checkins] In 4Suite/Ft/Xml/src, files xmlstring.c, xmlstring.h

Jeremy Kloth jkloth at 4suite.org
Fri Nov 24 13:24:09 MST 2006


Modified Files:
    xmlstring.c xmlstring.h

Log Message:
Added MakeQName as a C API function.

ViewCVS diff:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/xmlstring.c.diff?r1=1.9&r2=1.10
ViewCVS view:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/xmlstring.c?rev=1.10&content-type=text/vnd.viewcvs-markup

Index: xmlstring.c
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/xmlstring.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -U2 -r1.9 -r1.10
--- xmlstring.c	25 Sep 2006 17:33:10 -0000	1.9
+++ xmlstring.c	24 Nov 2006 20:24:09 -0000	1.10
@@ -363,4 +363,33 @@
 }
 
+static PyObject *MakeQName(PyObject *prefix, PyObject *localName)
+{
+  PyObject *nodeName;
+
+  if (PyObject_IsTrue(prefix)) {
+    Py_UNICODE *ustr;
+
+    nodeName = PyUnicode_FromUnicode(NULL,
+                                     PyUnicode_GET_SIZE(prefix) + \
+                                     PyUnicode_GET_SIZE(localName) + 1);
+    if (nodeName == NULL) return NULL;
+
+    ustr = PyUnicode_AS_UNICODE(nodeName);
+    Py_UNICODE_COPY(ustr,
+                    PyUnicode_AS_UNICODE(prefix),
+                    PyUnicode_GET_SIZE(prefix));
+
+    ustr[PyUnicode_GET_SIZE(prefix)] = (Py_UNICODE)':';
+
+    Py_UNICODE_COPY(ustr + PyUnicode_GET_SIZE(prefix) + 1,
+                    PyUnicode_AS_UNICODE(localName),
+                    PyUnicode_GET_SIZE(localName));
+  } else {
+    Py_INCREF(localName);
+    nodeName = localName;
+  }
+  return nodeName;
+}
+
 /** Public Methods ****************************************************/
 
@@ -754,4 +783,5 @@
   IsNCName,
   SplitQName,
+  MakeQName,
   NormalizeSpace,
 };
ViewCVS diff:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/xmlstring.h.diff?r1=1.3&r2=1.4
ViewCVS view:
  http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/xmlstring.h?rev=1.4&content-type=text/vnd.viewcvs-markup

Index: xmlstring.h
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/xmlstring.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -U2 -r1.3 -r1.4
--- xmlstring.h	15 Jan 2006 02:55:04 -0000	1.3
+++ xmlstring.h	24 Nov 2006 20:24:09 -0000	1.4
@@ -18,4 +18,5 @@
     int (*SplitQName)(PyObject *qualifiedName, PyObject **prefix,
                       PyObject **localName);
+    PyObject *(*MakeQName)(PyObject *prefix, PyObject *localName);
     PyObject *(*NormalizeSpace)(PyObject *str);
   } XmlString_APIObject;
@@ -38,4 +39,5 @@
 #define XmlString_IsNCName XmlString_API->IsNCName
 #define XmlString_SplitQName XmlString_API->SplitQName
+#define XmlString_MakeQName XmlString_API->MakeQName
 #define XmlString_NormalizeSpace XmlString_API->NormalizeSpace
 


More information about the 4suite-checkins mailing list