You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/03/02 20:05:04 UTC

svn commit: r918154 - in /subversion/trunk/subversion/bindings/javahl/native: BlameCallback.cpp CreateJ.cpp CreateJ.h LogMessageCallback.cpp ProplistCallback.cpp ProplistCallback.h SVNClient.cpp

Author: hwright
Date: Tue Mar  2 19:05:04 2010
New Revision: 918154

URL: http://svn.apache.org/viewvc?rev=918154&view=rev
Log:
JavaHL: Shuffle one of the native functions into a more appropriate home.

[ in subversion/bindings/javahl/ ]
* native/ProplistCallback.h,
  native/ProplistCallback.cpp
  (makeMapFromHash): Remove.

* native/CreateJ.cpp,
  native/CreateJ.h
  (PropertyMap): New, copied from ProplistCallback.

* native/SVNClient.cpp,
  native/BlameCallback.cpp,
  native/LogMessageCallback.cpp:
    Update all references.

Modified:
    subversion/trunk/subversion/bindings/javahl/native/BlameCallback.cpp
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
    subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
    subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp
    subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.cpp
    subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.h
    subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp

Modified: subversion/trunk/subversion/bindings/javahl/native/BlameCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/BlameCallback.cpp?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/BlameCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/BlameCallback.cpp Tue Mar  2 19:05:04 2010
@@ -25,7 +25,7 @@
  */
 
 #include "BlameCallback.h"
-#include "ProplistCallback.h"
+#include "CreateJ.h"
 #include "JNIUtil.h"
 #include "svn_time.h"
 /**
@@ -100,14 +100,14 @@
     }
 
   // convert the parameters to their Java relatives
-  jobject jrevProps = ProplistCallback::makeMapFromHash(revProps, pool);
+  jobject jrevProps = CreateJ::PropertyMap(revProps, pool);
   if (JNIUtil::isJavaExceptionThrown())
     return SVN_NO_ERROR;
 
   jobject jmergedRevProps = NULL;
   if (mergedRevProps != NULL)
     {
-      jmergedRevProps = ProplistCallback::makeMapFromHash(mergedRevProps, pool);
+      jmergedRevProps = CreateJ::PropertyMap(mergedRevProps, pool);
       if (JNIUtil::isJavaExceptionThrown())
         return SVN_NO_ERROR;
     }

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Tue Mar  2 19:05:04 2010
@@ -436,3 +436,70 @@
 
   return set;
 }
+
+jobject CreateJ::PropertyMap(apr_hash_t *prop_hash, apr_pool_t *pool)
+{
+  JNIEnv *env = JNIUtil::getEnv();
+  jclass clazz = env->FindClass("java/util/HashMap");
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  static jmethodID init_mid = 0;
+  if (init_mid == 0)
+    {
+      init_mid = env->GetMethodID(clazz, "<init>", "()V");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  static jmethodID put_mid = 0;
+  if (put_mid == 0)
+    {
+      put_mid = env->GetMethodID(clazz, "put",
+                                 "(Ljava/lang/Object;Ljava/lang/Object;)"
+                                 "Ljava/lang/Object;");
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  jobject map = env->NewObject(clazz, init_mid);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  apr_hash_index_t *hi;
+  int i = 0;
+  for (hi = apr_hash_first(pool, prop_hash); hi; hi = apr_hash_next(hi), ++i)
+    {
+      const char *key;
+      svn_string_t *val;
+
+      apr_hash_this(hi, (const void **)&key, NULL, (void **)&val);
+
+      jstring jpropName = JNIUtil::makeJString(key);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      jbyteArray jpropVal = JNIUtil::makeJByteArray(
+                                    (const signed char *)val->data, val->len);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      env->CallObjectMethod(map, put_mid, jpropName, jpropVal);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      env->DeleteLocalRef(jpropName);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+
+      env->DeleteLocalRef(jpropVal);
+      if (JNIUtil::isJavaExceptionThrown())
+        return NULL;
+    }
+
+  env->DeleteLocalRef(clazz);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  return map;
+}

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.h?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.h Tue Mar  2 19:05:04 2010
@@ -53,6 +53,9 @@
   static jobject
   StringSet(apr_array_header_t *strings);
 
+  static jobject
+  PropertyMap(apr_hash_t *prop_hash, apr_pool_t *pool);
+
  protected:
   static jobject
   ConflictVersion(const svn_wc_conflict_version_t *version);

Modified: subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp Tue Mar  2 19:05:04 2010
@@ -25,7 +25,7 @@
  */
 
 #include "LogMessageCallback.h"
-#include "ProplistCallback.h"
+#include "CreateJ.h"
 #include "EnumMapper.h"
 #include "JNIUtil.h"
 #include "svn_time.h"
@@ -167,7 +167,7 @@
 
   jobject jrevprops = NULL;
   if (log_entry->revprops != NULL && apr_hash_count(log_entry->revprops) > 0)
-    jrevprops = ProplistCallback::makeMapFromHash(log_entry->revprops, pool);
+    jrevprops = CreateJ::PropertyMap(log_entry->revprops, pool);
 
   env->CallVoidMethod(m_callback,
                       sm_mid,

Modified: subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.cpp?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.cpp Tue Mar  2 19:05:04 2010
@@ -26,6 +26,7 @@
 
 #include "ProplistCallback.h"
 #include "JNIUtil.h"
+#include "CreateJ.h"
 #include "svn_time.h"
 
 /**
@@ -95,7 +96,7 @@
     return SVN_NO_ERROR;
 
   jobject jmap = NULL;
-  jmap = makeMapFromHash(prop_hash, pool);
+  jmap = CreateJ::PropertyMap(prop_hash, pool);
   if (JNIUtil::isJavaExceptionThrown())
     return SVN_NO_ERROR;
 
@@ -114,71 +115,3 @@
 
   return SVN_NO_ERROR;
 }
-
-jobject ProplistCallback::makeMapFromHash(apr_hash_t *prop_hash,
-                                          apr_pool_t *pool)
-{
-  JNIEnv *env = JNIUtil::getEnv();
-  jclass clazz = env->FindClass("java/util/HashMap");
-  if (JNIUtil::isJavaExceptionThrown())
-    return NULL;
-
-  static jmethodID init_mid = 0;
-  if (init_mid == 0)
-    {
-      init_mid = env->GetMethodID(clazz, "<init>", "()V");
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    }
-
-  static jmethodID put_mid = 0;
-  if (put_mid == 0)
-    {
-      put_mid = env->GetMethodID(clazz, "put",
-                                 "(Ljava/lang/Object;Ljava/lang/Object;)"
-                                 "Ljava/lang/Object;");
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    }
-
-  jobject map = env->NewObject(clazz, init_mid);
-  if (JNIUtil::isJavaExceptionThrown())
-    return NULL;
-
-  apr_hash_index_t *hi;
-  int i = 0;
-  for (hi = apr_hash_first(pool, prop_hash); hi; hi = apr_hash_next(hi), ++i)
-    {
-      const char *key;
-      svn_string_t *val;
-
-      apr_hash_this(hi, (const void **)&key, NULL, (void **)&val);
-
-      jstring jpropName = JNIUtil::makeJString(key);
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-      jbyteArray jpropVal = JNIUtil::makeJByteArray(
-                                    (const signed char *)val->data, val->len);
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-      env->CallObjectMethod(map, put_mid, jpropName, jpropVal);
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-      env->DeleteLocalRef(jpropName);
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-
-      env->DeleteLocalRef(jpropVal);
-      if (JNIUtil::isJavaExceptionThrown())
-        return NULL;
-    }
-
-  env->DeleteLocalRef(clazz);
-  if (JNIUtil::isJavaExceptionThrown())
-    return NULL;
-
-  return map;
-}

Modified: subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.h?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/ProplistCallback.h Tue Mar  2 19:05:04 2010
@@ -45,8 +45,6 @@
                                apr_hash_t *prop_hash,
                                apr_pool_t *pool);
 
-  static jobject makeMapFromHash(apr_hash_t *prop_hash, apr_pool_t *pool);
-
  protected:
   svn_error_t *singlePath(const char *path,
                           apr_hash_t *prop_hash,

Modified: subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp?rev=918154&r1=918153&r2=918154&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/SVNClient.cpp Tue Mar  2 19:05:04 2010
@@ -1888,7 +1888,7 @@
                                         &set_rev, ctx, requestPool.pool()),
                 NULL);
 
-    return ProplistCallback::makeMapFromHash(props, requestPool.pool());
+    return CreateJ::PropertyMap(props, requestPool.pool());
 }
 
 struct info_baton