subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hwri...@apache.org
Subject svn commit: r964386 - in /subversion/trunk/subversion/bindings/javahl/native: CreateJ.cpp CreateJ.h LogMessageCallback.cpp
Date Thu, 15 Jul 2010 11:16:38 GMT
Author: hwright
Date: Thu Jul 15 11:16:38 2010
New Revision: 964386

URL: http://svn.apache.org/viewvc?rev=964386&view=rev
Log:
JavaHL: Move the creation of the Java ChangedPath object into its own native
code function.

* subversion/bindings/javahl/native/CreateJ.cpp
  (ChangedPath): New.

* subversion/bindings/javahl/native/LogMessageCallback.cpp
  (singleMessage): Remove code to create the ChangedPath, and call the CreateJ
    method instead.

* subversion/bindings/javahl/native/CreateJ.h
  (ChangedPath): New.

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

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp?rev=964386&r1=964385&r2=964386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.cpp Thu Jul 15 11:16:38 2010
@@ -349,6 +349,58 @@ CreateJ::Lock(const svn_lock_t *lock)
 }
 
 jobject
+CreateJ::ChangedPath(const char *path, svn_log_changed_path2_t *log_item)
+{
+  JNIEnv *env = JNIUtil::getEnv();
+
+  // Create a local frame for our references
+  env->PushLocalFrame(LOCAL_FRAME_SIZE);
+  if (JNIUtil::isJavaExceptionThrown())
+    return NULL;
+
+  jclass clazzCP = env->FindClass(JAVA_PACKAGE"/ChangePath");
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN(SVN_NO_ERROR);
+
+  static jmethodID midCP = 0;
+  if (midCP == 0)
+    {
+      midCP = env->GetMethodID(clazzCP,
+                               "<init>",
+                               "(Ljava/lang/String;JLjava/lang/String;C"
+                               "L"JAVA_PACKAGE"/NodeKind;"
+                               "L"JAVA_PACKAGE"/Tristate;"
+                               "L"JAVA_PACKAGE"/Tristate;)V");
+      if (JNIUtil::isJavaExceptionThrown())
+        POP_AND_RETURN(SVN_NO_ERROR);
+    }
+
+  jstring jpath = JNIUtil::makeJString(path);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jstring jcopyFromPath = JNIUtil::makeJString(log_item->copyfrom_path);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jobject jnodeKind = EnumMapper::mapNodeKind(log_item->node_kind);
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  jlong jcopyFromRev = log_item->copyfrom_rev;
+  jchar jaction = log_item->action;
+
+  jobject jcp = env->NewObject(clazzCP, midCP, jpath, jcopyFromRev,
+                      jcopyFromPath, jaction, jnodeKind,
+                      EnumMapper::mapTristate(log_item->text_modified),
+                      EnumMapper::mapTristate(log_item->props_modified));
+  if (JNIUtil::isJavaExceptionThrown())
+    POP_AND_RETURN_NULL;
+
+  return env->PopLocalFrame(jcp);
+}
+
+jobject
 CreateJ::Status(svn_wc_context_t *wc_ctx, const char *local_abspath,
                 const svn_client_status_t *status, apr_pool_t *pool)
 {

Modified: subversion/trunk/subversion/bindings/javahl/native/CreateJ.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CreateJ.h?rev=964386&r1=964385&r2=964386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CreateJ.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CreateJ.h Thu Jul 15 11:16:38 2010
@@ -52,6 +52,9 @@ class CreateJ
   Lock(const svn_lock_t *lock);
 
   static jobject
+  ChangedPath(const char *path, svn_log_changed_path2_t *log_item);
+
+  static jobject
   Status(svn_wc_context_t *wc_ctx, const char *local_abspath,
          const svn_client_status_t *status, apr_pool_t *pool);
 

Modified: subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp?rev=964386&r1=964385&r2=964386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/LogMessageCallback.cpp Thu Jul 15 11:16:38
2010
@@ -91,23 +91,6 @@ LogMessageCallback::singleMessage(svn_lo
         POP_AND_RETURN(SVN_NO_ERROR);
     }
 
-  jclass clazzCP = env->FindClass(JAVA_PACKAGE"/ChangePath");
-  if (JNIUtil::isJavaExceptionThrown())
-    POP_AND_RETURN(SVN_NO_ERROR);
-
-  static jmethodID midCP = 0;
-  if (midCP == 0)
-    {
-      midCP = env->GetMethodID(clazzCP,
-                               "<init>",
-                               "(Ljava/lang/String;JLjava/lang/String;C"
-                               "L"JAVA_PACKAGE"/NodeKind;"
-                               "L"JAVA_PACKAGE"/Tristate;"
-                               "L"JAVA_PACKAGE"/Tristate;)V");
-      if (JNIUtil::isJavaExceptionThrown())
-        POP_AND_RETURN(SVN_NO_ERROR);
-    }
-
   jobject jChangedPaths = NULL;
   if (log_entry->changed_paths)
     {
@@ -122,33 +105,9 @@ LogMessageCallback::singleMessage(svn_lo
           svn_log_changed_path2_t *log_item =
                     (svn_log_changed_path2_t *) svn__apr_hash_index_val(hi);
 
-          jstring jpath = JNIUtil::makeJString(path);
-          if (JNIUtil::isJavaExceptionThrown())
-            POP_AND_RETURN(SVN_NO_ERROR);
-
-          jstring jcopyFromPath = JNIUtil::makeJString(log_item->copyfrom_path);
-          if (JNIUtil::isJavaExceptionThrown())
-            POP_AND_RETURN(SVN_NO_ERROR);
-
-          jobject jnodeKind = EnumMapper::mapNodeKind(log_item->node_kind);
-          if (JNIUtil::isJavaExceptionThrown())
-            POP_AND_RETURN(SVN_NO_ERROR);
-
-          jlong jcopyFromRev = log_item->copyfrom_rev;
-          jchar jaction = log_item->action;
-
-          jobject cp = env->NewObject(clazzCP, midCP, jpath, jcopyFromRev,
-                              jcopyFromPath, jaction, jnodeKind,
-                              EnumMapper::mapTristate(log_item->text_modified),
-                              EnumMapper::mapTristate(log_item->props_modified));
-          if (JNIUtil::isJavaExceptionThrown())
-            POP_AND_RETURN(SVN_NO_ERROR);
+          jobject cp = CreateJ::ChangedPath(path, log_item);
 
           jcps.push_back(cp);
-
-          env->DeleteLocalRef(jnodeKind);
-          env->DeleteLocalRef(jpath);
-          env->DeleteLocalRef(jcopyFromPath);
         }
 
       jChangedPaths = CreateJ::Set(jcps);



Mime
View raw message