lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [02/34] git commit: refs/heads/master - Migrate Lucy's document classes to IVARS.
Date Wed, 17 Jul 2013 14:12:22 GMT
Migrate Lucy's document classes to IVARS.

Change all Lucy's document classes to access instance vars via an IVARS
struct rather than via `self`.


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

Branch: refs/heads/master
Commit: 9645b2e6c42169cdccdc138e01a5e1690666b205
Parents: 6835217
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Thu Jun 27 20:30:14 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jul 16 15:50:06 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Document/Doc.c    |  6 +++---
 core/Lucy/Document/HitDoc.c | 26 ++++++++++++++++----------
 2 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/9645b2e6/core/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Document/Doc.c b/core/Lucy/Document/Doc.c
index 9c6e6e5..6ad9996 100644
--- a/core/Lucy/Document/Doc.c
+++ b/core/Lucy/Document/Doc.c
@@ -27,17 +27,17 @@ Doc_new(void *fields, int32_t doc_id) {
 
 void
 Doc_set_doc_id(Doc *self, int32_t doc_id) {
-    self->doc_id = doc_id;
+    Doc_IVARS(self)->doc_id = doc_id;
 }
 
 int32_t
 Doc_get_doc_id(Doc *self) {
-    return self->doc_id;
+    return Doc_IVARS(self)->doc_id;
 }
 
 void*
 Doc_get_fields(Doc *self) {
-    return self->fields;
+    return Doc_IVARS(self)->fields;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/9645b2e6/core/Lucy/Document/HitDoc.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Document/HitDoc.c b/core/Lucy/Document/HitDoc.c
index edffe16..45c64e5 100644
--- a/core/Lucy/Document/HitDoc.c
+++ b/core/Lucy/Document/HitDoc.c
@@ -30,26 +30,28 @@ HitDoc_new(void *fields, int32_t doc_id, float score) {
 HitDoc*
 HitDoc_init(HitDoc *self, void *fields, int32_t doc_id, float score) {
     Doc_init((Doc*)self, fields, doc_id);
-    self->score = score;
+    HitDocIVARS *const ivars = HitDoc_IVARS(self);
+    ivars->score = score;
     return self;
 }
 
 void
 HitDoc_set_score(HitDoc *self, float score) {
-    self->score = score;
+    HitDoc_IVARS(self)->score = score;
 }
 
 float
 HitDoc_get_score(HitDoc *self) {
-    return self->score;
+    return HitDoc_IVARS(self)->score;
 }
 
 void
 HitDoc_serialize(HitDoc *self, OutStream *outstream) {
+    HitDocIVARS *const ivars = HitDoc_IVARS(self);
     HitDoc_Serialize_t super_serialize
         = SUPER_METHOD_PTR(HITDOC, Lucy_HitDoc_Serialize);
     super_serialize(self, outstream);
-    OutStream_Write_F32(outstream, self->score);
+    OutStream_Write_F32(outstream, ivars->score);
 }
 
 HitDoc*
@@ -57,16 +59,18 @@ HitDoc_deserialize(HitDoc *self, InStream *instream) {
     HitDoc_Deserialize_t super_deserialize
         = SUPER_METHOD_PTR(HITDOC, Lucy_HitDoc_Deserialize);
     self = super_deserialize(self, instream);
-    self->score = InStream_Read_F32(instream);
+    HitDocIVARS *const ivars = HitDoc_IVARS(self);
+    ivars->score = InStream_Read_F32(instream);
     return self;
 }
 
 Hash*
 HitDoc_dump(HitDoc *self) {
+    HitDocIVARS *const ivars = HitDoc_IVARS(self);
     HitDoc_Dump_t super_dump
         = SUPER_METHOD_PTR(HITDOC, Lucy_HitDoc_Dump);
     Hash *dump = super_dump(self);
-    Hash_Store_Str(dump, "score", 5, (Obj*)CB_newf("%f64", self->score));
+    Hash_Store_Str(dump, "score", 5, (Obj*)CB_newf("%f64", ivars->score));
     return dump;
 }
 
@@ -76,18 +80,20 @@ HitDoc_load(HitDoc *self, Obj *dump) {
     HitDoc_Load_t super_load
         = SUPER_METHOD_PTR(HITDOC, Lucy_HitDoc_Load);
     HitDoc *loaded = super_load(self, dump);
+    HitDocIVARS *const loaded_ivars = HitDoc_IVARS(loaded);
     Obj *score = CERTIFY(Hash_Fetch_Str(source, "score", 5), OBJ);
-    loaded->score = (float)Obj_To_F64(score);
+    loaded_ivars->score = (float)Obj_To_F64(score);
     return loaded;
 }
 
 bool
 HitDoc_equals(HitDoc *self, Obj *other) {
-    HitDoc *twin = (HitDoc*)other;
-    if (twin == self)                     { return true;  }
+    if ((HitDoc*)other == self)           { return true;  }
     if (!Obj_Is_A(other, HITDOC))         { return false; }
     if (!Doc_equals((Doc*)self, other))   { return false; }
-    if (self->score != twin->score)       { return false; }
+    HitDocIVARS *const ivars = HitDoc_IVARS(self);
+    HitDocIVARS *const ovars = HitDoc_IVARS((HitDoc*)other);
+    if (ivars->score != ovars->score)     { return false; }
     return true;
 }
 


Mime
View raw message