commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1092630 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr/jnimacros.h os/unix/semaphore.c os/win32/semaphore.c
Date Fri, 15 Apr 2011 08:37:59 GMT
Author: mturk
Date: Fri Apr 15 08:37:59 2011
New Revision: 1092630

URL: http://svn.apache.org/viewvc?rev=1092630&view=rev
Log:
Compact local function usage

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr/jnimacros.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/jnimacros.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/jnimacros.h?rev=1092630&r1=1092629&r2=1092630&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/jnimacros.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/jnimacros.h Fri Apr 15 08:37:59
2011
@@ -38,6 +38,14 @@
             return ACR_ESYMNOTFOUND;                                        \
     } else (void)(0)
 
+#define R_LOAD_METHOD(I, E)    \
+    if (_m##I##n.i == 0) {                                                  \
+        _m##I##n.i = (*env)->GetMethodID(env, _clazzn.i, _m##I##n.n,        \
+                                        _m##I##n.s);                        \
+        if (_m##I##n.i == 0)                                                \
+            return (E);                                                     \
+    } else (void)(0)
+
 #define J_LOPT_METHOD(I)    \
     if (_m##I##n.i == 0) {                                                  \
         _m##I##n.i = (*env)->GetMethodID(env, _clazzn.i, _m##I##n.n,        \

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c?rev=1092630&r1=1092629&r2=1092630&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c Fri Apr 15 08:37:59
2011
@@ -47,26 +47,17 @@ J_DECLARE_M_ID(0000) = {
     "()V"
 };
 
-static int _load_factory(JNI_STDENV)
-{
-    int rv;
-
-    if (_clazzn.u == 1)
-        return 0;
-    if ((rv = AcrLoadClass(env, &_clazzn, 0)) != 0)
-        return rv;
-    J_LOAD_METHOD(0000);
-    _clazzn.u = 1;
-    return 0;
-}
-
 ACR_JNI_EXPORT(jobject, Semaphore, getImplFactory)(JNI_STDARGS)
 {
-    if (_load_factory(env) != 0) {
+    if (_clazzn.u == 1)
+        return (*env)->NewObject(env, _clazzn.i, J4MID(0000));    
+    if (AcrLoadClass(env, &_clazzn, 0) != 0) {
         ACR_THROW_MSG(ACR_EX_EINSTANCE, "PosixSemaphoreImplFactory not initialized");
         return 0;
     }
-    return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
+    R_LOAD_METHOD(0000, 0);
+    _clazzn.u = 1;
+    return (*env)->NewObject(env, _clazzn.i, J4MID(0000));    
 }
 
 ACR_JNI_EXPORT(jboolean, Semaphore, unlink0)(JNI_STDARGS, jstring name)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c?rev=1092630&r1=1092629&r2=1092630&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/semaphore.c Fri Apr 15 08:37:59
2011
@@ -33,24 +33,17 @@ J_DECLARE_M_ID(0000) = {
     "()V"
 };
 
-static int _init_factory(JNI_STDENV)
-{
-    int rv;
-
-    if ((rv = AcrLoadClass(env, &_clazzn, 0)) != 0)
-        return rv;
-    J_LOAD_METHOD(0000);
-    _clazzn.u = 1;
-    return 0;
-}
-
 ACR_JNI_EXPORT(jobject, Semaphore, getImplFactory)(JNI_STDARGS)
 {
-    if (_init_factory(env) != 0) {
+    if (_clazzn.u == 1)
+        return (*env)->NewObject(env, _clazzn.i, J4MID(0000));    
+    if (AcrLoadClass(env, &_clazzn, 0) != 0) {
         ACR_THROW_MSG(ACR_EX_EINSTANCE, "WindowsSemaphoreImplFactory not initialized");
         return 0;
     }
-    return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
+    R_LOAD_METHOD(0000, 0);
+    _clazzn.u = 1;
+    return (*env)->NewObject(env, _clazzn.i, J4MID(0000));    
 }
 
 ACR_JNI_EXPORT(jboolean, Semaphore, unlink0)(JNI_STDARGS, jstring name)



Mime
View raw message