lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [15/34] git commit: refs/heads/master - Access FileWindow member vars via getters.
Date Wed, 17 Jul 2013 14:12:35 GMT
Access FileWindow member vars via getters.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/4f7440f8
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4f7440f8
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4f7440f8

Branch: refs/heads/master
Commit: 4f7440f81617a182a53d1e7bc363023f4d6c9375
Parents: d04580a
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Sat Jun 29 15:07:37 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jul 16 16:08:42 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Store/FSFileHandle.c |  5 +++--
 core/Lucy/Store/FileWindow.c   | 14 ++++++++++++++
 core/Lucy/Store/FileWindow.cfh |  9 +++++++++
 core/Lucy/Store/InStream.c     | 25 +++++++++++++++----------
 4 files changed, 41 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4f7440f8/core/Lucy/Store/FSFileHandle.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FSFileHandle.c b/core/Lucy/Store/FSFileHandle.c
index 4074a75..ac523fa 100644
--- a/core/Lucy/Store/FSFileHandle.c
+++ b/core/Lucy/Store/FSFileHandle.c
@@ -15,7 +15,6 @@
  */
 
 #define C_LUCY_FSFILEHANDLE
-#define C_LUCY_FILEWINDOW
 #include "Lucy/Util/ToolSet.h"
 
 #include <errno.h>
@@ -313,7 +312,9 @@ SI_window(FSFileHandle *self, FSFileHandleIVARS *ivars, FileWindow *window,
 
 bool
 FSFH_release_window(FSFileHandle *self, FileWindow *window) {
-    if (!SI_unmap(self, window->buf, window->len)) { return false; }
+    char *buf = FileWindow_Get_Buf(window);
+    int64_t len = FileWindow_Get_Len(window);
+    if (!SI_unmap(self, buf, len)) { return false; }
     FileWindow_Set_Window(window, NULL, 0, 0);
     return true;
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/4f7440f8/core/Lucy/Store/FileWindow.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FileWindow.c b/core/Lucy/Store/FileWindow.c
index 067c6a8..a410931 100644
--- a/core/Lucy/Store/FileWindow.c
+++ b/core/Lucy/Store/FileWindow.c
@@ -51,4 +51,18 @@ FileWindow_set_window(FileWindow *self, char *buf, int64_t offset,
     ivars->len    = len;
 }
 
+char*
+FileWindow_get_buf(FileWindow *self) {
+    return FileWindow_IVARS(self)->buf;
+}
+
+int64_t
+FileWindow_get_offset(FileWindow *self) {
+    return FileWindow_IVARS(self)->offset;
+}
+
+int64_t
+FileWindow_get_len(FileWindow *self) {
+    return FileWindow_IVARS(self)->len;
+}
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4f7440f8/core/Lucy/Store/FileWindow.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/FileWindow.cfh b/core/Lucy/Store/FileWindow.cfh
index dc1d17c..9b8a359 100644
--- a/core/Lucy/Store/FileWindow.cfh
+++ b/core/Lucy/Store/FileWindow.cfh
@@ -35,6 +35,15 @@ class Lucy::Store::FileWindow inherits Clownfish::Obj {
 
     void
     Set_Window(FileWindow *self, char *buf, int64_t offset, int64_t len);
+
+    char*
+    Get_Buf(FileWindow *self);
+
+    int64_t
+    Get_Offset(FileWindow *self);
+
+    int64_t
+    Get_Len(FileWindow *self);
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4f7440f8/core/Lucy/Store/InStream.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/InStream.c b/core/Lucy/Store/InStream.c
index 7727a11..caf286e 100644
--- a/core/Lucy/Store/InStream.c
+++ b/core/Lucy/Store/InStream.c
@@ -15,7 +15,6 @@
  */
 
 #define C_LUCY_INSTREAM
-#define C_LUCY_FILEWINDOW
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Store/InStream.h"
@@ -203,9 +202,12 @@ S_fill(InStream *self, int64_t amount) {
 
     // Make the request.
     if (FH_Window(ivars->file_handle, window, real_file_pos, amount)) {
-        char *const window_limit = window->buf + window->len;
-        ivars->buf = window->buf
-                     - window->offset     // theoretical start of real file
+        char    *fw_buf    = FileWindow_Get_Buf(window);
+        int64_t  fw_offset = FileWindow_Get_Offset(window);
+        int64_t  fw_len    = FileWindow_Get_Len(window);
+        char *const window_limit = fw_buf + fw_len;
+        ivars->buf = fw_buf
+                     - fw_offset          // theoretical start of real file
                      + ivars->offset      // top of virtual file
                      + virtual_file_pos;  // position within virtual file
         ivars->limit = window_limit - ivars->buf > remaining
@@ -228,8 +230,11 @@ void
 InStream_seek(InStream *self, int64_t target) {
     InStreamIVARS *const ivars = InStream_IVARS(self);
     FileWindow *const window = ivars->window;
-    int64_t virtual_window_top = window->offset - ivars->offset;
-    int64_t virtual_window_end = virtual_window_top + window->len;
+    char    *fw_buf    = FileWindow_Get_Buf(window);
+    int64_t  fw_offset = FileWindow_Get_Offset(window);
+    int64_t  fw_len    = FileWindow_Get_Len(window);
+    int64_t  virtual_window_top = fw_offset - ivars->offset;
+    int64_t  virtual_window_end = virtual_window_top + fw_len;
 
     if (target < 0) {
         THROW(ERR, "Can't Seek '%o' to negative target %i64", ivars->filename,
@@ -239,7 +244,7 @@ InStream_seek(InStream *self, int64_t target) {
     else if (target >= virtual_window_top
              && target <= virtual_window_end
             ) {
-        ivars->buf = window->buf - window->offset + ivars->offset + target;
+        ivars->buf = fw_buf - fw_offset + ivars->offset + target;
     }
     else if (target > ivars->len) {
         THROW(ERR, "Can't Seek '%o' past EOF (%i64 > %i64)", ivars->filename,
@@ -259,9 +264,9 @@ InStream_seek(InStream *self, int64_t target) {
 static INLINE int64_t
 SI_tell(InStream *self) {
     InStreamIVARS *const ivars = InStream_IVARS(self);
-    FileWindow *const window = ivars->window;
-    int64_t pos_in_buf = PTR_TO_I64(ivars->buf) - PTR_TO_I64(window->buf);
-    return pos_in_buf + window->offset - ivars->offset;
+    char *fw_buf = FileWindow_Get_Buf(ivars->window);
+    int64_t pos_in_buf = PTR_TO_I64(ivars->buf) - PTR_TO_I64(fw_buf);
+    return pos_in_buf + FileWindow_Get_Offset(ivars->window) - ivars->offset;
 }
 
 int64_t


Mime
View raw message