[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r24008 - trunk/subversion/bindings/java/javahl/native

From: Hyrum K. Wright <hyrum_wright_at_mail.utexas.edu>
Date: 2007-03-23 21:30:29 CET

Daniel Rall wrote:
> On Thu, 22 Mar 2007, hwright@tigris.org wrote:
>
>> Author: hwright
>> Date: Thu Mar 22 09:14:05 2007
>> New Revision: 24008
>>
>> Log:
>> JavaHL: Introduce a macro similiar to SVN_ERR() to check for error return values
>> in the C++ layer and handle the error appropriately.
>>
>> * subversion/bindings/java/javahl/native/JNIUtil.h
>> (SVN_JNI_ERR): New macro, styled after SVN_ERR(), which checks to see if its
>> arguments are in error, and then calls JNIUtil::handleSVNError() if so.
>>
>> * subversion/bindings/java/javahl/native/SVNClient.cpp,
>> subversion/bindings/java/javahl/native/SVNAdmin.cpp:
>> Use the new macro to handle errors.
> ...
>
> Thank you thank you thank you!

No problem. It was nice to cut the number of lines in the SVNClient.cpp
down by ~15%. :)

I'm trying to do something similar with the following construct:

    someMethodCallHere();
    if (JNIUtil::isJavaExceptionThrown())
    {
        return NULL;
    }

I thought of doing something similar to SVN_JNI_ERR(), but have a couple
of concerns. Because it's wrapped in a 'do { ... } while(0);' block,
things like

    SVN_JNI_CHECK_EX(obj o = someMethod(), NULL);

wouldn't work, because then o would only have scope in the 'do { ... }
while(0);' block.

That can be solved by declaring the variable outside the
SVN_JNI_CHECK_EX() macro like so:

    obj o;
    SVN_JNI_CHECK_EX(o = someMethod(), NULL);

But that has its own problems, in that instead of just calling the copy
constructor, we then call the default constructor, and then the
assignment operator, which is kind of wasteful.

Any suggestions?

-Hyrum

Received on Fri Mar 23 21:30:40 2007

This is an archived mail posted to the Subversion Dev mailing list.