commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r886763 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_private.h os/unix/finfo.c
Date Thu, 03 Dec 2009 12:43:35 GMT
Author: mturk
Date: Thu Dec  3 12:43:35 2009
New Revision: 886763

URL: http://svn.apache.org/viewvc?rev=886763&view=rev
Log:
Use different method macros that are easier to read inside source. Handy for complex structs

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/finfo.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=886763&r1=886762&r2=886763&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Thu Dec  3 12:43:35
2009
@@ -320,10 +320,13 @@
 #define J_DECLARE_F_ID(I) static JAVA_F_ID _f##I##n
 #define J_DECLARE_M_ID(I) static JAVA_M_ID _m##I##n
 
-#define J_DECLARE_FIELD(N, S) static JAVA_F_ID _f##N##n = { NULL, #N, #S }
-#define J_DECLARE_M_SET(N, S) static JAVA_M_ID _m##N##n = { NULL, "set" #N, "(" #S ")V" }
-#define J_DECLARE_M_GET(N, S) static JAVA_M_ID _m##N##n = { NULL, "get" #N, "()" #S     }
-#define J_DECLARE_M_INI(N, S) static JAVA_M_ID _m##N##n = { NULL, "<init>", "(" #S
")V" }
+#define J_DECLARE_CLASS(N, P)    static JAVA_C_ID _clazzn  = { NULL, NULL, #P #N }
+
+#define J_DECLARE_FIELD(N, S)    static JAVA_F_ID _f##N##n = { NULL, #N, #S }
+#define J_DECLARE_M_SET(N, S)    static JAVA_M_ID _m##N##n = { NULL, "set" #N, "(" #S ")V"
}
+#define J_DECLARE_M_GET(N, S)    static JAVA_M_ID _m##N##n = { NULL, "get" #N, "()" #S  
  }
+#define J_DECLARE_M_INI(N, S)    static JAVA_M_ID _m##N##n = { NULL, "<init>", "("
#S ")V" }
+#define J_DECLARE_MCALL(N, P, R) static JAVA_M_ID _m##N##n = { NULL, #N, "(" #P ")" #R  }
 
 #define J4MID(I)          _m##I##n.i
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/finfo.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/finfo.c?rev=886763&r1=886762&r2=886763&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/finfo.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/finfo.c Thu Dec  3 12:43:35 2009
@@ -33,107 +33,29 @@
 extern mode_t acr_default_umask;
 extern mode_t acr_default_perms;
 
-J_DECLARE_CLAZZ = {
-    NULL,
-    NULL,
-    ACR_IO_CLASS_PATH "FileInfo"
-};
-
-J_DECLARE_F_ID(0000) = {
-    NULL,
-    "Protection",
-    "I"
-};
-
-J_DECLARE_F_ID(0001) = {
-    NULL,
-    "User",
-    "L" ACR_CLASS_PATH "User;"
-};
-
-J_DECLARE_F_ID(0002) = {
-    NULL,
-    "Group",
-    "L" ACR_CLASS_PATH "Group;"
-};
-
-J_DECLARE_F_ID(0003) = {
-    NULL,
-    "NumLinks",
-    "I"
-};
-
-J_DECLARE_F_ID(0004) = {
-    NULL,
-    "Size",
-    "J"
-};
-
-J_DECLARE_F_ID(0005) = {
-    NULL,
-    "StorageSize",
-    "J"
-};
-
-J_DECLARE_F_ID(0006) = {
-    NULL,
-    "LastAccessTime",
-    "J"
-};
-
-J_DECLARE_F_ID(0007) = {
-    NULL,
-    "ModifiedTime",
-    "J"
-};
-
-J_DECLARE_F_ID(0008) = {
-    NULL,
-    "CreatedTime",
-    "J"
-};
-
-J_DECLARE_F_ID(0009) = {
-    NULL,
-    "Path",
-    "Ljava/lang/String;"
-};
-
-J_DECLARE_F_ID(0010) = {
-    NULL,
-    "Name",
-    "Ljava/lang/String;"
-};
-
-J_DECLARE_F_ID(0011) = {
-    NULL,
-    "InodeId",
-    "J"
-};
-
-J_DECLARE_F_ID(0012) = {
-    NULL,
-    "DeviceId",
-    "J"
-};
-
-J_DECLARE_M_ID(0000) = {
-    NULL,
-    "<init>",
-    "(I)V"
-};
-
-J_DECLARE_M_ID(0001) = {
-    NULL,
-    "<init>",
-    "(Ljava/lang/String;)V"
-};
-
-J_DECLARE_M_ID(0002) = {
-    NULL,
-    "setType",
-    "(I)V"
-};
+/**
+ * org.apache.common.runtime.io.FileInfo
+ */
+J_DECLARE_CLASS(FileInfo, ACR_IO_CLASS_PATH);
+
+J_DECLARE_FIELD(Protection,     I);
+J_DECLARE_FIELD(User,           "L" ACR_CLASS_PATH "User;");
+J_DECLARE_FIELD(Group,          "L" ACR_CLASS_PATH "Group;");
+J_DECLARE_FIELD(NumLinks,       I);
+J_DECLARE_FIELD(Size,           J);
+J_DECLARE_FIELD(StorageSize,    J);
+J_DECLARE_FIELD(LastAccessTime, J);
+
+J_DECLARE_FIELD(ModifiedTime,   J);
+J_DECLARE_FIELD(CreatedTime,    J);
+J_DECLARE_FIELD(Path,           "Ljava/lang/String;");
+J_DECLARE_FIELD(Name,           "Ljava/lang/String;");
+J_DECLARE_FIELD(InodeId,        J);
+J_DECLARE_FIELD(DeviceId,       J);
+
+J_DECLARE_M_INI(0000,           I);
+J_DECLARE_M_INI(0001,           "Ljava/lang/String;");
+J_DECLARE_M_SET(Type,           I);
 
 ACR_CLASS_LDEF(io_FileInfo)
 {
@@ -141,22 +63,23 @@
 
     if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
         return rv;
-    J_LOAD_IFIELD(0000);
-    J_LOAD_IFIELD(0001);
-    J_LOAD_IFIELD(0002);
-    J_LOAD_IFIELD(0003);
-    J_LOAD_IFIELD(0004);
-    J_LOAD_IFIELD(0005);
-    J_LOAD_IFIELD(0006);
-    J_LOAD_IFIELD(0007);
-    J_LOAD_IFIELD(0008);
-    J_LOAD_IFIELD(0009);
-    J_LOAD_IFIELD(0010);
-    J_LOAD_IFIELD(0011);
-    J_LOAD_IFIELD(0012);
+    J_LOAD_IFIELD(Protection);
+    J_LOAD_IFIELD(User);
+    J_LOAD_IFIELD(Group);
+    J_LOAD_IFIELD(NumLinks);
+    J_LOAD_IFIELD(Size);
+    J_LOAD_IFIELD(StorageSize);
+    J_LOAD_IFIELD(LastAccessTime);
+    J_LOAD_IFIELD(ModifiedTime);
+    J_LOAD_IFIELD(CreatedTime);
+    J_LOAD_IFIELD(Path);
+    J_LOAD_IFIELD(Name);
+    J_LOAD_IFIELD(InodeId);
+    J_LOAD_IFIELD(DeviceId);
+
     J_LOAD_METHOD(0000);
     J_LOAD_METHOD(0001);
-    J_LOAD_METHOD(0002);
+    J_LOAD_METHOD(Type);
 
     return ACR_SUCCESS;
 }
@@ -186,25 +109,25 @@
 
 static void _fill0(ACR_JNISTDARGS, struct_stat_t *info, jboolean full)
 {
-    SET_IFIELD_I(0000, _O, ACR_UnixModeToPerms(info->st_mode));
+    SET_IFIELD_I(Protection, _O, ACR_UnixModeToPerms(info->st_mode));
     if (full) {
-        SET_IFIELD_O(0001, _O, ACR_UserObjectCreateFromId(_E,  info->st_uid));
-        SET_IFIELD_O(0002, _O, ACR_GroupObjectCreateFromId(_E, info->st_gid));
+        SET_IFIELD_O(User,  _O, ACR_UserObjectCreateFromId(_E,  info->st_uid));
+        SET_IFIELD_O(Group, _O, ACR_GroupObjectCreateFromId(_E, info->st_gid));
     }
-    SET_IFIELD_I(0003, _O, info->st_nlink);
-    SET_IFIELD_J(0004, _O, info->st_size);
+    SET_IFIELD_I(NumLinks,  _O, info->st_nlink);
+    SET_IFIELD_J(Size,      _O, info->st_size);
     /* TODO: Some platforms lack the st_blocks member
      */
 #ifdef DEV_BSIZE
-    SET_IFIELD_J(0005, _O, (info->st_blocks * (jlong)DEV_BSIZE));
+    SET_IFIELD_J(StorageSize, _O, (info->st_blocks * (jlong)DEV_BSIZE));
 #else
-    SET_IFIELD_J(0005, _O, (info->st_blocks * (jlong)512));
+    SET_IFIELD_J(StorageSize, _O, (info->st_blocks * (jlong)512));
 #endif
-    SET_IFIELD_J(0006, _O, info->st_atime);
-    SET_IFIELD_J(0007, _O, info->st_mtime);
-    SET_IFIELD_J(0008, _O, info->st_ctime);
-    SET_IFIELD_J(0011, _O, info->st_ino);
-    SET_IFIELD_J(0012, _O, info->st_dev);
+    SET_IFIELD_J(LastAccessTime, _O, info->st_atime);
+    SET_IFIELD_J(ModifiedTime,   _O, info->st_mtime);
+    SET_IFIELD_J(CreatedTime,    _O, info->st_ctime);
+    SET_IFIELD_J(InodeId,        _O, info->st_ino);
+    SET_IFIELD_J(DeviceId,       _O, info->st_dev);
 }
 
 static int _ftype0(struct_stat_t *info)
@@ -280,9 +203,9 @@
             char *name;
 
             name = dirname_r(canon, path, PATH_MAX);
-            SET_IFIELD_S(0009, fi, name);
+            SET_IFIELD_S(Path, fi, name);
             name = basename_r(canon, path, PATH_MAX);
-            SET_IFIELD_S(0010, fi, name);
+            SET_IFIELD_S(Name, fi, name);
         }
         x_free(canon);
     }
@@ -322,9 +245,9 @@
         char *name;
 
         name = dirname_r(f->name, path, PATH_MAX);
-        SET_IFIELD_S(0009, fi, name);
+        SET_IFIELD_S(Path, fi, name);
         name = basename_r(f->name, path, PATH_MAX);
-        SET_IFIELD_S(0010, fi, name);
+        SET_IFIELD_S(Name, fi, name);
     }
     _fill0(_E, fi, &info, full);
 
@@ -341,7 +264,7 @@
     if (rc < 0)
         return ACR_GET_OS_ERROR();
     type = _ftype0(&info);
-    CALL_VMETHOD1(0002, _O, type);
+    CALL_VMETHOD1(Type, _O, type);
     _fill0(_E, _O, &info, JNI_TRUE);
 
     return 0;



Mime
View raw message