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/10 16:08:32 UTC
svn commit: r921386 - in /subversion/trunk/subversion/bindings/javahl:
native/CopySources.cpp native/CopySources.h
native/org_apache_subversion_javahl_SVNClient.cpp
src/org/apache/subversion/javahl/SVNClient.java
Author: hwright
Date: Wed Mar 10 15:08:31 2010
New Revision: 921386
URL: http://svn.apache.org/viewvc?rev=921386&view=rev
Log:
JavaHL: Update the last bit of collection-handling code to go directly to
the native interface.
[ in subversion/bindings/javahl/ ]
* native/CopySources.cpp,
native/CopySources.h:
(CopySources): Initialize the reference.
(~CopySources): Update comment.
(array): Update the way to create the array to use the Array object vector.
* native/org_apache_subversion_javahl_SVNClient.cpp
(Java_org_apache_subversion_javahl_SVNClient_copy): Unpack the collection
using Array.
* src/org/apache/subversion/javahl/SVNClient.java
(copy): Make native, and remove the public wrapper.
Modified:
subversion/trunk/subversion/bindings/javahl/native/CopySources.cpp
subversion/trunk/subversion/bindings/javahl/native/CopySources.h
subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Modified: subversion/trunk/subversion/bindings/javahl/native/CopySources.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CopySources.cpp?rev=921386&r1=921385&r2=921386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CopySources.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CopySources.cpp Wed Mar 10 15:08:31 2010
@@ -33,16 +33,13 @@
#include "Revision.h"
#include "CopySources.h"
-CopySources::CopySources(jobjectArray jcopySources)
+CopySources::CopySources(Array ©Sources)
+ : m_copySources(copySources)
{
- m_copySources = jcopySources;
}
CopySources::~CopySources()
{
- // m_copySources does not need to be destroyed, because it is a
- // parameter to the Java SVNClient.copy() method, and thus not
- // explicitly managed.
}
jobject
@@ -92,107 +89,93 @@ apr_array_header_t *
CopySources::array(SVN::Pool &pool)
{
apr_pool_t *p = pool.pool();
- if (m_copySources == NULL)
- return apr_array_make(p, 0, sizeof(svn_client_copy_source_t *));
JNIEnv *env = JNIUtil::getEnv();
- jint nbrSources = env->GetArrayLength(m_copySources);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
jclass clazz = env->FindClass(JAVA_PACKAGE "/CopySource");
if (JNIUtil::isJavaExceptionThrown())
return NULL;
+ std::vector<jobject> sources = m_copySources.vector();
+
apr_array_header_t *copySources =
- apr_array_make(p, nbrSources, sizeof(svn_client_copy_source_t *));
- for (int i = 0; i < nbrSources; ++i)
+ apr_array_make(p, sources.size(), sizeof(svn_client_copy_source_t *));
+ for (std::vector<jobject>::const_iterator it = sources.begin();
+ it < sources.end(); ++it)
{
- jobject copySource = env->GetObjectArrayElement(m_copySources, i);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ svn_client_copy_source_t *src =
+ (svn_client_copy_source_t *) apr_palloc(p, sizeof(*src));
- if (env->IsInstanceOf(copySource, clazz))
+ // Extract the path or URL from the copy source.
+ static jmethodID getPath = 0;
+ if (getPath == 0)
{
- svn_client_copy_source_t *src =
- (svn_client_copy_source_t *) apr_palloc(p, sizeof(*src));
-
- // Extract the path or URL from the copy source.
- static jmethodID getPath = 0;
- if (getPath == 0)
- {
- getPath = env->GetMethodID(clazz, "getPath",
- "()Ljava/lang/String;");
- if (JNIUtil::isJavaExceptionThrown() || getPath == 0)
- return NULL;
- }
- jstring jpath = (jstring)
- env->CallObjectMethod(copySource, getPath);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
-
- JNIStringHolder path(jpath);
- if (JNIUtil::isJavaExceptionThrown())
+ getPath = env->GetMethodID(clazz, "getPath",
+ "()Ljava/lang/String;");
+ if (JNIUtil::isJavaExceptionThrown() || getPath == 0)
return NULL;
+ }
+ jstring jpath = (jstring)
+ env->CallObjectMethod(*it, getPath);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
- src->path = apr_pstrdup(p, (const char *) path);
- SVN_JNI_ERR(JNIUtil::preprocessPath(src->path, pool.pool()),
- NULL);
- env->DeleteLocalRef(jpath);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ JNIStringHolder path(jpath);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
- // Extract source revision from the copy source.
- static jmethodID getRevision = 0;
- if (getRevision == 0)
- {
- getRevision = env->GetMethodID(clazz, "getRevision",
- "()L"JAVA_PACKAGE"/Revision;");
- if (JNIUtil::isJavaExceptionThrown() || getRevision == 0)
- return NULL;
- }
- jobject jrev = env->CallObjectMethod(copySource, getRevision);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ src->path = apr_pstrdup(p, (const char *) path);
+ SVN_JNI_ERR(JNIUtil::preprocessPath(src->path, pool.pool()),
+ NULL);
+ env->DeleteLocalRef(jpath);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
- // TODO: Default this to svn_opt_revision_undefined (or HEAD)
- Revision rev(jrev);
- src->revision = (const svn_opt_revision_t *)
- apr_palloc(p, sizeof(*src->revision));
- memcpy((void *) src->revision, rev.revision(),
- sizeof(*src->revision));
- env->DeleteLocalRef(jrev);
- if (JNIUtil::isJavaExceptionThrown())
+ // Extract source revision from the copy source.
+ static jmethodID getRevision = 0;
+ if (getRevision == 0)
+ {
+ getRevision = env->GetMethodID(clazz, "getRevision",
+ "()L"JAVA_PACKAGE"/Revision;");
+ if (JNIUtil::isJavaExceptionThrown() || getRevision == 0)
return NULL;
+ }
+ jobject jrev = env->CallObjectMethod(*it, getRevision);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
- // Extract pegRevision from the copy source.
- static jmethodID getPegRevision = 0;
- if (getPegRevision == 0)
- {
- getPegRevision = env->GetMethodID(clazz, "getPegRevision",
- "()L"JAVA_PACKAGE"/Revision;");
- if (JNIUtil::isJavaExceptionThrown() || getPegRevision == 0)
- return NULL;
- }
- jobject jPegRev = env->CallObjectMethod(copySource,
- getPegRevision);
- if (JNIUtil::isJavaExceptionThrown())
- return NULL;
+ // TODO: Default this to svn_opt_revision_undefined (or HEAD)
+ Revision rev(jrev);
+ src->revision = (const svn_opt_revision_t *)
+ apr_palloc(p, sizeof(*src->revision));
+ memcpy((void *) src->revision, rev.revision(),
+ sizeof(*src->revision));
+ env->DeleteLocalRef(jrev);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
- Revision pegRev(jPegRev, true);
- src->peg_revision = (const svn_opt_revision_t *)
- apr_palloc(p, sizeof(*src->peg_revision));
- memcpy((void *) src->peg_revision, pegRev.revision(),
- sizeof(*src->peg_revision));
- env->DeleteLocalRef(jPegRev);
- if (JNIUtil::isJavaExceptionThrown())
+ // Extract pegRevision from the copy source.
+ static jmethodID getPegRevision = 0;
+ if (getPegRevision == 0)
+ {
+ getPegRevision = env->GetMethodID(clazz, "getPegRevision",
+ "()L"JAVA_PACKAGE"/Revision;");
+ if (JNIUtil::isJavaExceptionThrown() || getPegRevision == 0)
return NULL;
-
- APR_ARRAY_PUSH(copySources, svn_client_copy_source_t *) = src;
}
- env->DeleteLocalRef(copySource);
+ jobject jPegRev = env->CallObjectMethod(*it, getPegRevision);
if (JNIUtil::isJavaExceptionThrown())
return NULL;
+
+ Revision pegRev(jPegRev, true);
+ src->peg_revision = (const svn_opt_revision_t *)
+ apr_palloc(p, sizeof(*src->peg_revision));
+ memcpy((void *) src->peg_revision, pegRev.revision(),
+ sizeof(*src->peg_revision));
+ env->DeleteLocalRef(jPegRev);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
+
+ APR_ARRAY_PUSH(copySources, svn_client_copy_source_t *) = src;
}
env->DeleteLocalRef(clazz);
Modified: subversion/trunk/subversion/bindings/javahl/native/CopySources.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/CopySources.h?rev=921386&r1=921385&r2=921386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/CopySources.h (original)
+++ subversion/trunk/subversion/bindings/javahl/native/CopySources.h Wed Mar 10 15:08:31 2010
@@ -31,6 +31,7 @@
#include <apr_tables.h>
#include "Pool.h"
+#include "Array.h"
/**
* A container for our copy sources, which can convert them into an
@@ -43,7 +44,7 @@ class CopySources
* Create a CopySources object.
* @param jobjectArray An array of CopySource Java objects.
*/
- CopySources(jobjectArray copySources);
+ CopySources(Array ©Sources);
/**
* Destroy a CopySources object
@@ -69,7 +70,7 @@ class CopySources
/**
* A local reference to the Java CopySources peer.
*/
- jobjectArray m_copySources;
+ Array &m_copySources;
};
#endif /* COPY_SOURCES_H */
Modified: subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp?rev=921386&r1=921385&r2=921386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp (original)
+++ subversion/trunk/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp Wed Mar 10 15:08:31 2010
@@ -570,7 +570,7 @@ Java_org_apache_subversion_javahl_SVNCli
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_copy
-(JNIEnv *env, jobject jthis, jobjectArray jcopySources, jstring jdestPath,
+(JNIEnv *env, jobject jthis, jobject jcopySources, jstring jdestPath,
jstring jmessage, jboolean jcopyAsChild, jboolean jmakeParents,
jboolean jignoreExternals, jobject jrevpropTable)
{
@@ -582,13 +582,19 @@ Java_org_apache_subversion_javahl_SVNCli
JNIUtil::throwError(_("bad C++ this"));
return;
}
- CopySources copySources(jcopySources);
+ Array copySrcArray(jcopySources);
if (JNIUtil::isExceptionThrown())
return;
+
+ CopySources copySources(copySrcArray);
+ if (JNIUtil::isExceptionThrown())
+ return;
+
JNIStringHolder destPath(jdestPath);
if (JNIUtil::isExceptionThrown())
return;
- JNIStringHolder message(jmessage);
+
+JNIStringHolder message(jmessage);
if (JNIUtil::isExceptionThrown())
return;
Modified: subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java?rev=921386&r1=921385&r2=921386&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java (original)
+++ subversion/trunk/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java Wed Mar 10 15:08:31 2010
@@ -240,21 +240,10 @@ public class SVNClient implements ISVNCl
/**
* @since 1.7
*/
- public void copy(List<CopySource> sources, String destPath,
- String message, boolean copyAsChild,
- boolean makeParents, boolean ignoreExternals,
- Map<String, String> revpropTable)
- throws ClientException
- {
- this.copy(sources.toArray(new CopySource[sources.size()]),
- destPath, message, copyAsChild, makeParents,
- ignoreExternals, revpropTable);
- }
-
- private native void copy(CopySource[] sources, String destPath,
- String message, boolean copyAsChild,
- boolean makeParents, boolean ignoreExternals,
- Map<String, String> revpropTable)
+ public native void copy(List<CopySource> sources, String destPath,
+ String message, boolean copyAsChild,
+ boolean makeParents, boolean ignoreExternals,
+ Map<String, String> revpropTable)
throws ClientException;
/**