[kaffe] CVS kaffe (dalibor): Resynced with GNU JAXP

Kaffe CVS cvs-commits at kaffe.org
Sat Jun 5 11:43:02 PDT 2004


PatchSet 4826 
Date: 2004/06/05 18:12:17
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU JAXP

2004-06-05  Dalibor Topic  <robilad at kaffe.org>

        * libraries/clib/libxmlj/xmlj_dom.c,
        libraries/clib/libxmlj/xmlj_io.c,
        libraries/clib/libxmlj/xmlj_node.c,
        libraries/clib/libxmlj/xmlj_sax.c,
        libraries/clib/libxmlj/xmlj_transform.c,
        libraries/clib/libxmlj/xmlj_util.c,
        libraries/clib/libxmlj/xmlj_util.h,
        libraries/clib/libxmlj/xmlj_xpath.c,
        libraries/javalib/gnu/regexp/MessagesBundle_it.properties,
        libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java,
        libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java:
        Resynced with GNU JAXP.

Members: 
	ChangeLog:1.2394->1.2395 
	libraries/clib/libxmlj/xmlj_dom.c:1.2->1.3 
	libraries/clib/libxmlj/xmlj_io.c:1.3->1.4 
	libraries/clib/libxmlj/xmlj_node.c:1.2->1.3 
	libraries/clib/libxmlj/xmlj_sax.c:1.2->1.3 
	libraries/clib/libxmlj/xmlj_transform.c:1.2->1.3 
	libraries/clib/libxmlj/xmlj_util.c:1.1->1.2 
	libraries/clib/libxmlj/xmlj_util.h:1.1->1.2 
	libraries/clib/libxmlj/xmlj_xpath.c:1.1->1.2 
	libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java:1.2->1.3 
	libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2394 kaffe/ChangeLog:1.2395
--- kaffe/ChangeLog:1.2394	Sat Jun  5 17:28:12 2004
+++ kaffe/ChangeLog	Sat Jun  5 18:12:17 2004
@@ -1,5 +1,20 @@
 2004-06-05  Dalibor Topic  <robilad at kaffe.org>
 
+        * libraries/clib/libxmlj/xmlj_dom.c,
+        libraries/clib/libxmlj/xmlj_io.c,
+        libraries/clib/libxmlj/xmlj_node.c,
+        libraries/clib/libxmlj/xmlj_sax.c,
+        libraries/clib/libxmlj/xmlj_transform.c,
+        libraries/clib/libxmlj/xmlj_util.c,
+        libraries/clib/libxmlj/xmlj_util.h,
+        libraries/clib/libxmlj/xmlj_xpath.c,
+        libraries/javalib/gnu/regexp/MessagesBundle_it.properties,
+        libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java,
+        libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java:
+	Resynced with GNU JAXP.
+
+2004-06-05  Dalibor Topic  <robilad at kaffe.org>
+
         * libraries/javalib/gnu/regexp/MessagesBundle_it.properties:
 	New file from GNU Classpath.
 
Index: kaffe/libraries/clib/libxmlj/xmlj_dom.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_dom.c:1.2 kaffe/libraries/clib/libxmlj/xmlj_dom.c:1.3
--- kaffe/libraries/clib/libxmlj/xmlj_dom.c:1.2	Thu Jun  3 18:56:07 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_dom.c	Sat Jun  5 18:12:19 2004
@@ -99,7 +99,7 @@
 {
   xmlDocPtr doc;
 
-  doc = (xmlDocPtr) id;
+  doc = (xmlDocPtr) xmljAsPointer (id);
   xmljFreeDoc (env, doc);
   xmlFree (doc);
 }
@@ -909,6 +909,10 @@
   xmlNodePtr node;
 
   node = xmljGetNodeID (env, self);
+  if (node == NULL)
+    {
+      return NULL;
+    }
   return xmljNewString (env, node->name);
 }
 
@@ -919,7 +923,6 @@
   xmlBufferPtr buf;
   jstring ret;
 
-
   node = xmljGetNodeID (env, self);
 
   /* If not character data, return null */
@@ -1006,21 +1009,6 @@
 
   node = xmljGetNodeID (env, self);
   return xmljGetNodeInstance (env, node->next);
-}
-
-JNIEXPORT jobject JNICALL
-Java_gnu_xml_libxmlj_dom_GnomeNode_getAttributes (JNIEnv * env, jobject self)
-{
-  xmlNodePtr node;
-  jclass cls;
-  jmethodID method;
-
-  node = xmljGetNodeID (env, self);
-
-  /* Construct named node map object */
-  cls = (*env)->FindClass (env, "gnu/xml/libxmlj/dom/GnomeNamedNodeMap");
-  method = (*env)->GetMethodID (env, cls, "<init>", "(J)V");
-  return (*env)->NewObject (env, cls, method, (jlong) node);
 }
 
 JNIEXPORT jobject JNICALL
Index: kaffe/libraries/clib/libxmlj/xmlj_io.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_io.c:1.3 kaffe/libraries/clib/libxmlj/xmlj_io.c:1.4
--- kaffe/libraries/clib/libxmlj/xmlj_io.c:1.3	Thu Jun  3 18:56:07 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_io.c	Sat Jun  5 18:12:19 2004
@@ -437,6 +437,17 @@
   xmlParserCtxtPtr ctx;
   SAXParseContext *saxCtx;
   xmlSAXHandlerPtr sax;
+
+  /*printf ("validate=%d\ncoalesce=%d\nexpandEntities=%d\ncontentHandler=%d\ndtdHandler=%d\nentityResolver=%d\nerrorHandler=%d\ndeclarationHandler=%d\nlexicalHandler=%d\n",
+          validate,
+          coalesce,
+          expandEntities,
+          contentHandler,
+          dtdHandler,
+          entityResolver,
+          errorHandler,
+          declarationHandler,
+          lexicalHandler);*/
   
   ctx = xmljNewParserContext (env, in, detectBuffer, systemId, publicId,
                               validate, coalesce, expandEntities);
@@ -490,8 +501,9 @@
               
   xmljSetThreadContext (saxCtx);
 
-  printf ("ctx=%d loadsubset=%d\n", ctx, ctx->loadsubset);
+  printf ("xmljParseDocument2 loadsubset=%d\n", ctx->loadsubset);
   ret = xmlParseDocument (ctx);
+  printf ("xmlParseDocument done\n");
   doc = ctx->myDoc;
   if (ret)
     {
Index: kaffe/libraries/clib/libxmlj/xmlj_node.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_node.c:1.2 kaffe/libraries/clib/libxmlj/xmlj_node.c:1.3
--- kaffe/libraries/clib/libxmlj/xmlj_node.c:1.2	Thu Jun  3 18:56:07 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_node.c	Sat Jun  5 18:12:19 2004
@@ -37,13 +37,22 @@
 {
   jclass cls;
   jfieldID field;
+  jlong id;
   xmlNodePtr node;
 
   cls = (*env)->GetObjectClass (env, self);
   field = (*env)->GetFieldID (env, cls, "id", "J");
-  node = (xmlNodePtr) (*env)->GetLongField (env, self, field);
+  id = (*env)->GetLongField (env, self, field);
+  if (id == 0LL)
+    {
+      printf ("id is 0LL!\n");
+    }
+  node = (xmlNodePtr) xmljAsPointer (id);
   if (node == NULL)
-    xmljThrowDOMException (env, 8, NULL);	/* NOT_FOUND_ERR */
+    {
+      printf ("node is null!\n");
+      xmljThrowDOMException (env, 8, NULL);	/* NOT_FOUND_ERR */
+    }
   return node;
 }
 
@@ -63,10 +72,11 @@
   cls = (*env)->FindClass (env, "gnu/xml/libxmlj/dom/GnomeNode");
   method = (*env)->GetStaticMethodID (env, cls, "newInstance",
                                       "(JJI)Lgnu/xml/libxmlj/dom/GnomeNode;");
+  
   return (*env)->CallStaticObjectMethod (env, cls, method,
-                                         (jlong) node->doc,
-                                         (jlong) node,
-                                         (jint) node->type);
+                                         xmljAsField (node->doc),
+                                         xmljAsField (node),
+                                         node->type);
 }
 
 void
@@ -78,7 +88,7 @@
   /* Invoke the GnomeNode.freeDocument class method */
   cls = (*env)->FindClass (env, "gnu/xml/libxmlj/dom/GnomeNode");
   method = (*env)->GetStaticMethodID (env, cls, "freeDocument", "(J)V");
-  (*env)->CallStaticVoidMethod (env, cls, method, (jlong) doc);
+  (*env)->CallStaticVoidMethod (env, cls, method, xmljAsField (doc));
 }
 
 int
Index: kaffe/libraries/clib/libxmlj/xmlj_sax.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_sax.c:1.2 kaffe/libraries/clib/libxmlj/xmlj_sax.c:1.3
--- kaffe/libraries/clib/libxmlj/xmlj_sax.c:1.2	Thu Jun  3 18:56:07 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_sax.c	Sat Jun  5 18:12:19 2004
@@ -44,8 +44,8 @@
   xmlSAXLocatorPtr loc;
   SAXParseContext *sax;
 
-  ctx = (xmlParserCtxtPtr) j_ctx;
-  loc = (xmlSAXLocatorPtr) j_loc;
+  ctx = (xmlParserCtxtPtr) xmljAsPointer (j_ctx);
+  loc = (xmlSAXLocatorPtr) xmljAsPointer (j_loc);
   sax = (SAXParseContext *) ctx->_private;
   
   return sax->publicId;
@@ -61,8 +61,8 @@
   xmlSAXLocatorPtr loc;
   SAXParseContext *sax;
 
-  ctx = (xmlParserCtxtPtr) j_ctx;
-  loc = (xmlSAXLocatorPtr) j_loc;
+  ctx = (xmlParserCtxtPtr) xmljAsPointer (j_ctx);
+  loc = (xmlSAXLocatorPtr) xmljAsPointer (j_loc);
   sax = (SAXParseContext *) ctx->_private;
   
   return sax->systemId;
@@ -77,8 +77,8 @@
   xmlParserCtxtPtr ctx;
   xmlSAXLocatorPtr loc;
 
-  ctx = (xmlParserCtxtPtr) j_ctx;
-  loc = (xmlSAXLocatorPtr) j_loc;
+  ctx = (xmlParserCtxtPtr) xmljAsPointer (j_ctx);
+  loc = (xmlSAXLocatorPtr) xmljAsPointer (j_loc);
   if (ctx == NULL || ctx->input == NULL)
     {
       return -1;
@@ -95,8 +95,8 @@
   xmlParserCtxtPtr ctx;
   xmlSAXLocatorPtr loc;
 
-  ctx = (xmlParserCtxtPtr) j_ctx;
-  loc = (xmlSAXLocatorPtr) j_loc;
+  ctx = (xmlParserCtxtPtr) xmljAsPointer (j_ctx);
+  loc = (xmlSAXLocatorPtr) xmljAsPointer (j_loc);
   if (ctx == NULL || ctx->input == NULL)
     {
       return -1;
@@ -733,8 +733,8 @@
   (*env)->CallVoidMethod (env,
                           target,
                           sax->setDocumentLocator,
-                          (jlong) ctx,
-                          (jlong) loc);
+                          xmljAsField (ctx),
+                          xmljAsField (loc));
 }
 
 void
Index: kaffe/libraries/clib/libxmlj/xmlj_transform.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_transform.c:1.2 kaffe/libraries/clib/libxmlj/xmlj_transform.c:1.3
--- kaffe/libraries/clib/libxmlj/xmlj_transform.c:1.2	Thu Jun  3 18:56:07 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_transform.c	Sat Jun  5 18:12:19 2004
@@ -45,6 +45,7 @@
 #include "xmlj_error.h"
 #include "xmlj_node.h"
 #include "xmlj_sax.h"
+#include "xmlj_util.h"
 
 #include <math.h>
 #include <stdarg.h>
@@ -433,7 +434,7 @@
   /*xmljFreeParserContext (ctx);*/
   
   /* Return handle/address casted to Java int value */
-  return (jlong) nativeStylesheetHandle;
+  return xmljAsField (nativeStylesheetHandle);
 }
 
 /*
@@ -452,7 +453,7 @@
 
   xsltStylesheetPtr stylesheet;
  
-  stylesheet = (xsltStylesheetPtr) nativeStylesheetHandle;
+  stylesheet = (xsltStylesheetPtr) xmljAsPointer (nativeStylesheetHandle);
   stylesheet->_private = NULL;
   xmlFreeDoc (stylesheet->doc);
   stylesheet->doc = NULL;
@@ -493,7 +494,7 @@
   xmlDocPtr sourceDoc;
   xmlDocPtr resultDoc;
   
-  stylesheet = ((xsltStylesheetPtr) xsltSource);
+  stylesheet = (xsltStylesheetPtr) xmljAsPointer (xsltSource);
   sourceDoc = (xmlDocPtr) xmljGetNodeID (env, jdocument);
   
   if (!(*env)->ExceptionOccurred (env) && NULL != sourceDoc)
Index: kaffe/libraries/clib/libxmlj/xmlj_util.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_util.c:1.1 kaffe/libraries/clib/libxmlj/xmlj_util.c:1.2
--- kaffe/libraries/clib/libxmlj/xmlj_util.c:1.1	Wed May 19 17:27:46 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_util.c	Sat Jun  5 18:12:19 2004
@@ -138,3 +138,35 @@
     }
   return ret;
 }
+
+void * xmljAsPointer (jlong field)
+{
+  void * ptr;
+
+  ptr = (void *) field;
+
+  if (field != 0LL && ptr == NULL)
+    {
+      printf ("xmljAsPointer: casting killed %lld\n", field);
+    }
+  return ptr;
+}
+
+jlong xmljAsField (void * ptr)
+{
+  jlong field;
+
+  field = (jlong) ptr;
+
+  if (ptr == NULL)
+    {
+      printf ("WARNING: ptr is null\n");
+    }
+
+  if (ptr != NULL && field == 0LL)
+    {
+      printf ("xmljAsField: casting killed %d\n", ptr);
+    }
+  return field;
+}
+
Index: kaffe/libraries/clib/libxmlj/xmlj_util.h
diff -u kaffe/libraries/clib/libxmlj/xmlj_util.h:1.1 kaffe/libraries/clib/libxmlj/xmlj_util.h:1.2
--- kaffe/libraries/clib/libxmlj/xmlj_util.h:1.1	Wed May 19 17:27:46 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_util.h	Sat Jun  5 18:12:19 2004
@@ -44,4 +44,8 @@
                            const char *name,
                            const char *signature);
 
+void * xmljAsPointer (jlong field);
+
+jlong xmljAsField (void * ptr);
+
 #endif /* !defined XMLJ_UTIL_H */
Index: kaffe/libraries/clib/libxmlj/xmlj_xpath.c
diff -u kaffe/libraries/clib/libxmlj/xmlj_xpath.c:1.1 kaffe/libraries/clib/libxmlj/xmlj_xpath.c:1.2
--- kaffe/libraries/clib/libxmlj/xmlj_xpath.c:1.1	Thu Jun  3 18:56:07 2004
+++ kaffe/libraries/clib/libxmlj/xmlj_xpath.c	Sat Jun  5 18:12:19 2004
@@ -38,10 +38,12 @@
 {
   jclass cls;
   jfieldID field;
+  jlong val;
 
   cls = (*env)->GetObjectClass (env, obj);
   field = (*env)->GetFieldID (env, cls, "obj", "J");
-  return (xmlXPathObjectPtr) (*env)->GetLongField (env, obj, field);
+  val = (*env)->GetLongField (env, obj, field);
+  return (xmlXPathObjectPtr) xmljAsPointer (val);
 }
 
 JNIEXPORT jobject JNICALL
@@ -76,7 +78,7 @@
   const xmlChar *str;
 
   str = xmljGetStringChars (env, expression);
-  return (jlong) xmlXPathCompile (str);
+  return xmljAsField (xmlXPathCompile (str));
 }
 
 JNIEXPORT void JNICALL
@@ -86,7 +88,7 @@
 {
   xmlXPathCompExprPtr expr;
 
-  expr = (xmlXPathCompExprPtr) ptr;
+  expr = (xmlXPathCompExprPtr) xmljAsPointer (ptr);
   xmlXPathFreeCompExpr (expr);
 }
 
@@ -104,7 +106,7 @@
   xmlXPathObjectPtr eval;
   jobject ret;
 
-  expr = (xmlXPathCompExprPtr) ptr;
+  expr = (xmlXPathCompExprPtr) xmljAsPointer (ptr);
   node = xmljGetNodeID (env, contextNode);
   ctx = xmljCreateXPathContextPtr (env, node);
   eval = xmlXPathCompiledEval (expr, ctx);
@@ -118,7 +120,7 @@
                                                 jobject self,
                                                 jlong obj)
 {
-  xmlXPathFreeObject ((xmlXPathObjectPtr) obj);
+  xmlXPathFreeObject ((xmlXPathObjectPtr) xmljAsPointer (obj));
 }
 
 JNIEXPORT jshort JNICALL
@@ -145,6 +147,7 @@
     case XPATH_LOCATIONSET:
     case XPATH_USERS:
     case XPATH_XSLT_TREE:
+    default:
       return -1; /* TODO */
     }
 }
Index: kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java
diff -u kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java:1.2 kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java:1.3
--- kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java:1.2	Thu Jun  3 18:56:09 2004
+++ kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeDocumentBuilderFactory.java	Sat Jun  5 18:12:19 2004
@@ -42,7 +42,6 @@
   public GnomeDocumentBuilderFactory ()
     {
       setNamespaceAware (true);
-      setValidating (true);
     }
 
   public Object getAttribute (String name)
Index: kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java
diff -u kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java:1.2 kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java:1.3
--- kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java:1.2	Thu Jun  3 18:56:09 2004
+++ kaffe/libraries/javalib/gnu/xml/libxmlj/dom/GnomeNode.java	Sat Jun  5 18:12:19 2004
@@ -58,8 +58,16 @@
    * @param node the node pointer
    * @param type the node type
    */
-  static GnomeNode newInstance (long doc, long node, int type)
+  static GnomeNode newInstance (final long doc, final long node, final int type)
     {
+      if (doc == 0L)
+        {
+          throw new NullPointerException ("doc");
+        }
+      if (node == 0L)
+        {
+          throw new NullPointerException ("node");
+        }
       if (instances == null)
         {
           instances = new HashMap ();
@@ -129,7 +137,7 @@
    * Frees the specified document.
    * This removes all its nodes from the cache.
    */
-  static void freeDocument (long doc)
+  static void freeDocument (final long doc)
     {
       if (instances == null)
         {
@@ -147,7 +155,7 @@
 
   Map userData;
 
-  GnomeNode (long id)
+  GnomeNode (final long id)
     {
       this.id = id;
     }
@@ -177,7 +185,10 @@
 
   public native Node getNextSibling ();
 
-  public native NamedNodeMap getAttributes ();
+  public NamedNodeMap getAttributes ()
+    {
+      return new GnomeNamedNodeMap (id);
+    }
 
   public native Document getOwnerDocument ();
 




More information about the kaffe mailing list