lucy-commits mailing list archives

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

Change all Lucy's plan 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/c2adaf55
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/c2adaf55
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/c2adaf55

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

----------------------------------------------------------------------
 core/Lucy/Plan/BlobType.c     | 28 +++++++----
 core/Lucy/Plan/FieldType.c    | 44 +++++++++--------
 core/Lucy/Plan/FullTextType.c | 62 ++++++++++++------------
 core/Lucy/Plan/NumericType.c  | 20 ++++----
 core/Lucy/Plan/Schema.c       | 98 ++++++++++++++++++++++----------------
 core/Lucy/Plan/StringType.c   | 34 ++++++-------
 core/Lucy/Plan/TextType.c     | 33 ++++++++-----
 7 files changed, 177 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/BlobType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/BlobType.c b/core/Lucy/Plan/BlobType.c
index e8492c9..1892d5a 100644
--- a/core/Lucy/Plan/BlobType.c
+++ b/core/Lucy/Plan/BlobType.c
@@ -28,7 +28,8 @@ BlobType_new(bool stored) {
 BlobType*
 BlobType_init(BlobType *self, bool stored) {
     FType_init((FieldType*)self);
-    self->stored = stored;
+    BlobTypeIVARS *const ivars = BlobType_IVARS(self);
+    ivars->stored = stored;
     return self;
 }
 
@@ -58,26 +59,26 @@ BlobType_primitive_id(BlobType *self) {
 
 bool
 BlobType_equals(BlobType *self, Obj *other) {
-    BlobType *twin = (BlobType*)other;
-    if (twin == self)               { return true; }
+    if ((BlobType*)other == self)   { return true; }
     if (!Obj_Is_A(other, BLOBTYPE)) { return false; }
     return FType_equals((FieldType*)self, other);
 }
 
 Hash*
 BlobType_dump_for_schema(BlobType *self) {
+    BlobTypeIVARS *const ivars = BlobType_IVARS(self);
     Hash *dump = Hash_new(0);
     Hash_Store_Str(dump, "type", 4, (Obj*)CB_newf("blob"));
 
     // Store attributes that override the defaults -- even if they're
     // meaningless.
-    if (self->boost != 1.0) {
-        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", self->boost));
+    if (ivars->boost != 1.0) {
+        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", ivars->boost));
     }
-    if (self->indexed) {
+    if (ivars->indexed) {
         Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_TRUE);
     }
-    if (self->stored) {
+    if (ivars->stored) {
         Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_TRUE);
     }
 
@@ -108,9 +109,16 @@ BlobType_load(BlobType *self, Obj *dump) {
     UNUSED_VAR(self);
 
     BlobType_init(loaded, false);
-    if (boost_dump)   { loaded->boost   = (float)Obj_To_F64(boost_dump);    }
-    if (indexed_dump) { loaded->indexed = Obj_To_Bool(indexed_dump); }
-    if (stored_dump)  { loaded->stored  = Obj_To_Bool(stored_dump);  }
+    BlobTypeIVARS *const loaded_ivars = BlobType_IVARS(loaded);
+    if (boost_dump) {
+        loaded_ivars->boost = (float)Obj_To_F64(boost_dump);
+    }
+    if (indexed_dump) {
+        loaded_ivars->indexed = Obj_To_Bool(indexed_dump);
+    }
+    if (stored_dump){
+        loaded_ivars->stored = Obj_To_Bool(stored_dump);
+    }
 
     return loaded;
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/FieldType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/FieldType.c b/core/Lucy/Plan/FieldType.c
index 00139ae..089f7c1 100644
--- a/core/Lucy/Plan/FieldType.c
+++ b/core/Lucy/Plan/FieldType.c
@@ -30,52 +30,53 @@ FType_init(FieldType *self) {
 FieldType*
 FType_init2(FieldType *self, float boost, bool indexed, bool stored,
             bool sortable) {
-    self->boost              = boost;
-    self->indexed            = indexed;
-    self->stored             = stored;
-    self->sortable           = sortable;
+    FieldTypeIVARS *const ivars = FType_IVARS(self);
+    ivars->boost             = boost;
+    ivars->indexed           = indexed;
+    ivars->stored            = stored;
+    ivars->sortable          = sortable;
     ABSTRACT_CLASS_CHECK(self, FIELDTYPE);
     return self;
 }
 
 void
 FType_set_boost(FieldType *self, float boost) {
-    self->boost = boost;
+    FType_IVARS(self)->boost = boost;
 }
 
 void
 FType_set_indexed(FieldType *self, bool indexed) {
-    self->indexed = !!indexed;
+    FType_IVARS(self)->indexed = !!indexed;
 }
 
 void
 FType_set_stored(FieldType *self, bool stored) {
-    self->stored = !!stored;
+    FType_IVARS(self)->stored = !!stored;
 }
 
 void
 FType_set_sortable(FieldType *self, bool sortable) {
-    self->sortable = !!sortable;
+    FType_IVARS(self)->sortable = !!sortable;
 }
 
 float
 FType_get_boost(FieldType *self) {
-    return self->boost;
+    return FType_IVARS(self)->boost;
 }
 
 bool
 FType_indexed(FieldType *self) {
-    return self->indexed;
+    return FType_IVARS(self)->indexed;
 }
 
 bool
 FType_stored(FieldType *self) {
-    return self->stored;
+    return FType_IVARS(self)->stored;
 }
 
 bool
 FType_sortable(FieldType *self) {
-    return self->sortable;
+    return FType_IVARS(self)->sortable;
 }
 
 bool
@@ -98,14 +99,17 @@ FType_compare_values(FieldType *self, Obj *a, Obj *b) {
 
 bool
 FType_equals(FieldType *self, Obj *other) {
-    FieldType *twin = (FieldType*)other;
-    if (twin == self)                                     { return true; }
-    if (FType_Get_VTable(self) != FType_Get_VTable(twin)) { return false; }
-    if (self->boost != twin->boost)                       { return false; }
-    if (!!self->indexed    != !!twin->indexed)            { return false; }
-    if (!!self->stored     != !!twin->stored)             { return false; }
-    if (!!self->sortable   != !!twin->sortable)           { return false; }
-    if (!!FType_Binary(self) != !!FType_Binary(twin))     { return false; }
+    if ((FieldType*)other == self)                       { return true; }
+    if (FType_Get_VTable(self) != Obj_Get_VTable(other)) { return false; }
+    FieldTypeIVARS *const ivars = FType_IVARS(self);
+    FieldTypeIVARS *const ovars = FType_IVARS((FieldType*)other);
+    if (ivars->boost != ovars->boost)                    { return false; }
+    if (!!ivars->indexed    != !!ovars->indexed)         { return false; }
+    if (!!ivars->stored     != !!ovars->stored)          { return false; }
+    if (!!ivars->sortable   != !!ovars->sortable)        { return false; }
+    if (!!FType_Binary(self) != !!FType_Binary((FieldType*)other)) {
+        return false;
+    }
     return true;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/FullTextType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/FullTextType.c b/core/Lucy/Plan/FullTextType.c
index 4c30b2b..ac379eb 100644
--- a/core/Lucy/Plan/FullTextType.c
+++ b/core/Lucy/Plan/FullTextType.c
@@ -38,33 +38,36 @@ FullTextType_init2(FullTextType *self, Analyzer *analyzer, float boost,
                    bool indexed, bool stored, bool sortable,
                    bool highlightable) {
     FType_init((FieldType*)self);
+    FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
 
     /* Assign */
-    self->boost         = boost;
-    self->indexed       = indexed;
-    self->stored        = stored;
-    self->sortable      = sortable;
-    self->highlightable = highlightable;
-    self->analyzer      = (Analyzer*)INCREF(analyzer);
+    ivars->boost         = boost;
+    ivars->indexed       = indexed;
+    ivars->stored        = stored;
+    ivars->sortable      = sortable;
+    ivars->highlightable = highlightable;
+    ivars->analyzer      = (Analyzer*)INCREF(analyzer);
 
     return self;
 }
 
 void
 FullTextType_destroy(FullTextType *self) {
-    DECREF(self->analyzer);
+    FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
+    DECREF(ivars->analyzer);
     SUPER_DESTROY(self, FULLTEXTTYPE);
 }
 
 bool
 FullTextType_equals(FullTextType *self, Obj *other) {
-    FullTextType *twin = (FullTextType*)other;
-    if (twin == self)                                   { return true; }
-    if (!Obj_Is_A(other, FULLTEXTTYPE))                 { return false; }
-    if (!FType_equals((FieldType*)self, other))         { return false; }
-    if (!!self->sortable != !!twin->sortable)           { return false; }
-    if (!!self->highlightable != !!twin->highlightable) { return false; }
-    if (!Analyzer_Equals(self->analyzer, (Obj*)twin->analyzer)) {
+    if ((FullTextType*)other == self)                     { return true; }
+    if (!Obj_Is_A(other, FULLTEXTTYPE))                   { return false; }
+    FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
+    FullTextTypeIVARS *const ovars = FullTextType_IVARS((FullTextType*)other);
+    if (!FType_equals((FieldType*)self, other))           { return false; }
+    if (!!ivars->sortable      != !!ovars->sortable)      { return false; }
+    if (!!ivars->highlightable != !!ovars->highlightable) { return false; }
+    if (!Analyzer_Equals(ivars->analyzer, (Obj*)ovars->analyzer)) {
         return false;
     }
     return true;
@@ -72,23 +75,24 @@ FullTextType_equals(FullTextType *self, Obj *other) {
 
 Hash*
 FullTextType_dump_for_schema(FullTextType *self) {
+    FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
     Hash *dump = Hash_new(0);
     Hash_Store_Str(dump, "type", 4, (Obj*)CB_newf("fulltext"));
 
     // Store attributes that override the defaults.
-    if (self->boost != 1.0) {
-        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", self->boost));
+    if (ivars->boost != 1.0) {
+        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", ivars->boost));
     }
-    if (!self->indexed) {
+    if (!ivars->indexed) {
         Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_FALSE);
     }
-    if (!self->stored) {
+    if (!ivars->stored) {
         Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_FALSE);
     }
-    if (self->sortable) {
+    if (ivars->sortable) {
         Hash_Store_Str(dump, "sortable", 8, (Obj*)CFISH_TRUE);
     }
-    if (self->highlightable) {
+    if (ivars->highlightable) {
         Hash_Store_Str(dump, "highlightable", 13, (Obj*)CFISH_TRUE);
     }
 
@@ -97,11 +101,12 @@ FullTextType_dump_for_schema(FullTextType *self) {
 
 Hash*
 FullTextType_dump(FullTextType *self) {
+    FullTextTypeIVARS *const ivars = FullTextType_IVARS(self);
     Hash *dump = FullTextType_Dump_For_Schema(self);
     Hash_Store_Str(dump, "_class", 6,
                    (Obj*)CB_Clone(FullTextType_Get_Class_Name(self)));
     Hash_Store_Str(dump, "analyzer", 8,
-                   (Obj*)Analyzer_Dump(self->analyzer));
+                   (Obj*)Analyzer_Dump(ivars->analyzer));
     DECREF(Hash_Delete_Str(dump, "type", 4));
 
     return dump;
@@ -146,30 +151,25 @@ FullTextType_load(FullTextType *self, Obj *dump) {
     }
     CERTIFY(analyzer, ANALYZER);
 
-    FullTextType_init(loaded, analyzer);
+    FullTextType_init2(loaded, analyzer, boost, indexed, stored,
+                       sortable, hl);
     DECREF(analyzer);
-    if (boost_dump)   { loaded->boost         = boost;    }
-    if (indexed_dump) { loaded->indexed       = indexed;  }
-    if (stored_dump)  { loaded->stored        = stored;   }
-    if (sort_dump)    { loaded->sortable      = sortable; }
-    if (hl_dump)      { loaded->highlightable = hl;       }
-
     return loaded;
 }
 
 void
 FullTextType_set_highlightable(FullTextType *self, bool highlightable) {
-    self->highlightable = highlightable;
+    FullTextType_IVARS(self)->highlightable = highlightable;
 }
 
 Analyzer*
 FullTextType_get_analyzer(FullTextType *self) {
-    return self->analyzer;
+    return FullTextType_IVARS(self)->analyzer;
 }
 
 bool
 FullTextType_highlightable(FullTextType *self) {
-    return self->highlightable;
+    return FullTextType_IVARS(self)->highlightable;
 }
 
 Similarity*

http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/NumericType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/NumericType.c b/core/Lucy/Plan/NumericType.c
index a71602a..2d73119 100644
--- a/core/Lucy/Plan/NumericType.c
+++ b/core/Lucy/Plan/NumericType.c
@@ -28,10 +28,11 @@ NumericType*
 NumType_init2(NumericType *self, float boost, bool indexed, bool stored,
               bool sortable) {
     FType_init((FieldType*)self);
-    self->boost      = boost;
-    self->indexed    = indexed;
-    self->stored     = stored;
-    self->sortable   = sortable;
+    NumericTypeIVARS *const ivars = NumType_IVARS(self);
+    ivars->boost      = boost;
+    ivars->indexed    = indexed;
+    ivars->stored     = stored;
+    ivars->sortable   = sortable;
     return self;
 }
 
@@ -43,20 +44,21 @@ NumType_binary(NumericType *self) {
 
 Hash*
 NumType_dump_for_schema(NumericType *self) {
+    NumericTypeIVARS *const ivars = NumType_IVARS(self);
     Hash *dump = Hash_new(0);
     Hash_Store_Str(dump, "type", 4, (Obj*)NumType_Specifier(self));
 
     // Store attributes that override the defaults.
-    if (self->boost != 1.0) {
-        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", self->boost));
+    if (ivars->boost != 1.0) {
+        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", ivars->boost));
     }
-    if (!self->indexed) {
+    if (!ivars->indexed) {
         Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_FALSE);
     }
-    if (!self->stored) {
+    if (!ivars->stored) {
         Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_FALSE);
     }
-    if (self->sortable) {
+    if (ivars->sortable) {
         Hash_Store_Str(dump, "sortable", 8, (Obj*)CFISH_TRUE);
     }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/Schema.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/Schema.c b/core/Lucy/Plan/Schema.c
index ba6de0b..64f9281 100644
--- a/core/Lucy/Plan/Schema.c
+++ b/core/Lucy/Plan/Schema.c
@@ -53,28 +53,30 @@ Schema_new() {
 
 Schema*
 Schema_init(Schema *self) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     // Init.
-    self->analyzers      = Hash_new(0);
-    self->types          = Hash_new(0);
-    self->sims           = Hash_new(0);
-    self->uniq_analyzers = VA_new(2);
-    VA_Resize(self->uniq_analyzers, 1);
+    ivars->analyzers      = Hash_new(0);
+    ivars->types          = Hash_new(0);
+    ivars->sims           = Hash_new(0);
+    ivars->uniq_analyzers = VA_new(2);
+    VA_Resize(ivars->uniq_analyzers, 1);
 
     // Assign.
-    self->arch = Schema_Architecture(self);
-    self->sim  = Arch_Make_Similarity(self->arch);
+    ivars->arch = Schema_Architecture(self);
+    ivars->sim  = Arch_Make_Similarity(ivars->arch);
 
     return self;
 }
 
 void
 Schema_destroy(Schema *self) {
-    DECREF(self->arch);
-    DECREF(self->analyzers);
-    DECREF(self->uniq_analyzers);
-    DECREF(self->types);
-    DECREF(self->sims);
-    DECREF(self->sim);
+    SchemaIVARS *const ivars = Schema_IVARS(self);
+    DECREF(ivars->arch);
+    DECREF(ivars->analyzers);
+    DECREF(ivars->uniq_analyzers);
+    DECREF(ivars->types);
+    DECREF(ivars->sims);
+    DECREF(ivars->sim);
     SUPER_DESTROY(self, SCHEMA);
 }
 
@@ -94,12 +96,13 @@ S_add_unique(VArray *array, Obj *elem) {
 
 bool
 Schema_equals(Schema *self, Obj *other) {
-    Schema *twin = (Schema*)other;
-    if (twin == self)                                 { return true; }
-    if (!Obj_Is_A(other, SCHEMA))                     { return false; }
-    if (!Arch_Equals(self->arch, (Obj*)twin->arch))   { return false; }
-    if (!Sim_Equals(self->sim, (Obj*)twin->sim))      { return false; }
-    if (!Hash_Equals(self->types, (Obj*)twin->types)) { return false; }
+    if ((Schema*)other == self)                         { return true; }
+    if (!Obj_Is_A(other, SCHEMA))                       { return false; }
+    SchemaIVARS *const ivars = Schema_IVARS(self);
+    SchemaIVARS *const ovars = Schema_IVARS((Schema*)other);
+    if (!Arch_Equals(ivars->arch, (Obj*)ovars->arch))   { return false; }
+    if (!Sim_Equals(ivars->sim, (Obj*)ovars->sim))      { return false; }
+    if (!Hash_Equals(ivars->types, (Obj*)ovars->types)) { return false; }
     return true;
 }
 
@@ -138,82 +141,90 @@ Schema_spec_field(Schema *self, const CharBuf *field, FieldType *type)
{
 
 static void
 S_add_text_field(Schema *self, const CharBuf *field, FieldType *type) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     FullTextType *fttype    = (FullTextType*)CERTIFY(type, FULLTEXTTYPE);
     Similarity   *sim       = FullTextType_Make_Similarity(fttype);
     Analyzer     *analyzer  = FullTextType_Get_Analyzer(fttype);
 
     // Cache helpers.
-    Hash_Store(self->sims, (Obj*)field, (Obj*)sim);
-    Hash_Store(self->analyzers, (Obj*)field, INCREF(analyzer));
-    S_add_unique(self->uniq_analyzers, (Obj*)analyzer);
+    Hash_Store(ivars->sims, (Obj*)field, (Obj*)sim);
+    Hash_Store(ivars->analyzers, (Obj*)field, INCREF(analyzer));
+    S_add_unique(ivars->uniq_analyzers, (Obj*)analyzer);
 
     // Store FieldType.
-    Hash_Store(self->types, (Obj*)field, INCREF(type));
+    Hash_Store(ivars->types, (Obj*)field, INCREF(type));
 }
 
 static void
 S_add_string_field(Schema *self, const CharBuf *field, FieldType *type) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     StringType *string_type = (StringType*)CERTIFY(type, STRINGTYPE);
     Similarity *sim         = StringType_Make_Similarity(string_type);
 
     // Cache helpers.
-    Hash_Store(self->sims, (Obj*)field, (Obj*)sim);
+    Hash_Store(ivars->sims, (Obj*)field, (Obj*)sim);
 
     // Store FieldType.
-    Hash_Store(self->types, (Obj*)field, INCREF(type));
+    Hash_Store(ivars->types, (Obj*)field, INCREF(type));
 }
 
 static void
 S_add_blob_field(Schema *self, const CharBuf *field, FieldType *type) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     BlobType *blob_type = (BlobType*)CERTIFY(type, BLOBTYPE);
-    Hash_Store(self->types, (Obj*)field, INCREF(blob_type));
+    Hash_Store(ivars->types, (Obj*)field, INCREF(blob_type));
 }
 
 static void
 S_add_numeric_field(Schema *self, const CharBuf *field, FieldType *type) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     NumericType *num_type = (NumericType*)CERTIFY(type, NUMERICTYPE);
-    Hash_Store(self->types, (Obj*)field, INCREF(num_type));
+    Hash_Store(ivars->types, (Obj*)field, INCREF(num_type));
 }
 
 FieldType*
 Schema_fetch_type(Schema *self, const CharBuf *field) {
-    return (FieldType*)Hash_Fetch(self->types, (Obj*)field);
+    SchemaIVARS *const ivars = Schema_IVARS(self);
+    return (FieldType*)Hash_Fetch(ivars->types, (Obj*)field);
 }
 
 Analyzer*
 Schema_fetch_analyzer(Schema *self, const CharBuf *field) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     return field
-           ? (Analyzer*)Hash_Fetch(self->analyzers, (Obj*)field)
+           ? (Analyzer*)Hash_Fetch(ivars->analyzers, (Obj*)field)
            : NULL;
 }
 
 Similarity*
 Schema_fetch_sim(Schema *self, const CharBuf *field) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     Similarity *sim = NULL;
     if (field != NULL) {
-        sim = (Similarity*)Hash_Fetch(self->sims, (Obj*)field);
+        sim = (Similarity*)Hash_Fetch(ivars->sims, (Obj*)field);
     }
     return sim;
 }
 
 uint32_t
 Schema_num_fields(Schema *self) {
-    return Hash_Get_Size(self->types);
+    SchemaIVARS *const ivars = Schema_IVARS(self);
+    return Hash_Get_Size(ivars->types);
 }
 
 Architecture*
 Schema_get_architecture(Schema *self) {
-    return self->arch;
+    return Schema_IVARS(self)->arch;
 }
 
 Similarity*
 Schema_get_similarity(Schema *self) {
-    return self->sim;
+    return Schema_IVARS(self)->sim;
 }
 
 VArray*
 Schema_all_fields(Schema *self) {
-    return Hash_Keys(self->types);
+    return Hash_Keys(Schema_IVARS(self)->types);
 }
 
 uint32_t
@@ -237,20 +248,21 @@ S_find_in_array(VArray *array, Obj *obj) {
 
 Hash*
 Schema_dump(Schema *self) {
+    SchemaIVARS *const ivars = Schema_IVARS(self);
     Hash *dump = Hash_new(0);
-    Hash *type_dumps = Hash_new(Hash_Get_Size(self->types));
+    Hash *type_dumps = Hash_new(Hash_Get_Size(ivars->types));
     CharBuf *field;
     FieldType *type;
 
     // Record class name, store dumps of unique Analyzers.
     Hash_Store_Str(dump, "_class", 6,
                    (Obj*)CB_Clone(Schema_Get_Class_Name(self)));
-    Hash_Store_Str(dump, "analyzers", 9, (Obj*)VA_Dump(self->uniq_analyzers));
+    Hash_Store_Str(dump, "analyzers", 9, (Obj*)VA_Dump(ivars->uniq_analyzers));
 
     // Dump FieldTypes.
     Hash_Store_Str(dump, "fields", 6, (Obj*)type_dumps);
-    Hash_Iterate(self->types);
-    while (Hash_Next(self->types, (Obj**)&field, (Obj**)&type)) {
+    Hash_Iterate(ivars->types);
+    while (Hash_Next(ivars->types, (Obj**)&field, (Obj**)&type)) {
         VTable *type_vtable = FType_Get_VTable(type);
 
         // Dump known types to simplified format.
@@ -259,7 +271,7 @@ Schema_dump(Schema *self) {
             Hash *type_dump = FullTextType_Dump_For_Schema(fttype);
             Analyzer *analyzer = FullTextType_Get_Analyzer(fttype);
             uint32_t tick
-                = S_find_in_array(self->uniq_analyzers, (Obj*)analyzer);
+                = S_find_in_array(ivars->uniq_analyzers, (Obj*)analyzer);
 
             // Store the tick which references a unique analyzer.
             Hash_Store_Str(type_dump, "analyzer", 8,
@@ -299,7 +311,8 @@ Schema_load(Schema *self, Obj *dump) {
 
     // Start with a blank Schema.
     Schema_init(loaded);
-    VA_Grow(loaded->uniq_analyzers, VA_Get_Size(analyzers));
+    SchemaIVARS *const loaded_ivars = Schema_IVARS(loaded);
+    VA_Grow(loaded_ivars->uniq_analyzers, VA_Get_Size(analyzers));
 
     Hash_Iterate(type_dumps);
     while (Hash_Next(type_dumps, (Obj**)&field, (Obj**)&type_dump)) {
@@ -390,8 +403,9 @@ Schema_eat(Schema *self, Schema *other) {
 
     CharBuf *field;
     FieldType *type;
-    Hash_Iterate(other->types);
-    while (Hash_Next(other->types, (Obj**)&field, (Obj**)&type)) {
+    SchemaIVARS *const ovars = Schema_IVARS(other);
+    Hash_Iterate(ovars->types);
+    while (Hash_Next(ovars->types, (Obj**)&field, (Obj**)&type)) {
         Schema_Spec_Field(self, field, type);
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/StringType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/StringType.c b/core/Lucy/Plan/StringType.c
index d27cd37..2965121 100644
--- a/core/Lucy/Plan/StringType.c
+++ b/core/Lucy/Plan/StringType.c
@@ -36,37 +36,38 @@ StringType*
 StringType_init2(StringType *self, float boost, bool indexed,
                  bool stored, bool sortable) {
     FType_init((FieldType*)self);
-    self->boost      = boost;
-    self->indexed    = indexed;
-    self->stored     = stored;
-    self->sortable   = sortable;
+    StringTypeIVARS *const ivars = StringType_IVARS(self);
+    ivars->boost      = boost;
+    ivars->indexed    = indexed;
+    ivars->stored     = stored;
+    ivars->sortable   = sortable;
     return self;
 }
 
 bool
 StringType_equals(StringType *self, Obj *other) {
-    StringType *twin = (StringType*)other;
-    if (twin == self)                           { return true; }
+    if ((StringType*)other == self)             { return true; }
     if (!FType_equals((FieldType*)self, other)) { return false; }
     return true;
 }
 
 Hash*
 StringType_dump_for_schema(StringType *self) {
+    StringTypeIVARS *const ivars = StringType_IVARS(self);
     Hash *dump = Hash_new(0);
     Hash_Store_Str(dump, "type", 4, (Obj*)CB_newf("string"));
 
     // Store attributes that override the defaults.
-    if (self->boost != 1.0) {
-        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", self->boost));
+    if (ivars->boost != 1.0) {
+        Hash_Store_Str(dump, "boost", 5, (Obj*)CB_newf("%f64", ivars->boost));
     }
-    if (!self->indexed) {
+    if (!ivars->indexed) {
         Hash_Store_Str(dump, "indexed", 7, (Obj*)CFISH_FALSE);
     }
-    if (!self->stored) {
+    if (!ivars->stored) {
         Hash_Store_Str(dump, "stored", 6, (Obj*)CFISH_FALSE);
     }
-    if (self->sortable) {
+    if (ivars->sortable) {
         Hash_Store_Str(dump, "sortable", 8, (Obj*)CFISH_TRUE);
     }
 
@@ -97,13 +98,12 @@ StringType_load(StringType *self, Obj *dump) {
     Obj *sortable_dump   = Hash_Fetch_Str(source, "sortable", 8);
     UNUSED_VAR(self);
 
-    StringType_init(loaded);
-    if (boost_dump)    { loaded->boost    = (float)Obj_To_F64(boost_dump); }
-    if (indexed_dump)  { loaded->indexed  = Obj_To_Bool(indexed_dump); }
-    if (stored_dump)   { loaded->stored   = Obj_To_Bool(stored_dump); }
-    if (sortable_dump) { loaded->sortable = Obj_To_Bool(sortable_dump); }
+    float boost    = boost_dump    ? (float)Obj_To_F64(boost_dump) : 1.0f;
+    bool  indexed  = indexed_dump  ? Obj_To_Bool(indexed_dump)     : true;
+    bool  stored   = stored_dump   ? Obj_To_Bool(stored_dump)      : true;
+    bool  sortable = sortable_dump ? Obj_To_Bool(sortable_dump)    : false;
 
-    return loaded;
+    return StringType_init2(loaded, boost, indexed, stored, sortable);
 }
 
 Similarity*

http://git-wip-us.apache.org/repos/asf/lucy/blob/c2adaf55/core/Lucy/Plan/TextType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/TextType.c b/core/Lucy/Plan/TextType.c
index 44a290d..25ee102 100644
--- a/core/Lucy/Plan/TextType.c
+++ b/core/Lucy/Plan/TextType.c
@@ -53,37 +53,42 @@ TextTermStepper_new() {
 TextTermStepper*
 TextTermStepper_init(TextTermStepper *self) {
     TermStepper_init((TermStepper*)self);
-    self->value = (Obj*)CB_new(0);
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
+    ivars->value = (Obj*)CB_new(0);
     return self;
 }
 
 void
 TextTermStepper_set_value(TextTermStepper *self, Obj *value) {
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
     CERTIFY(value, CHARBUF);
-    DECREF(self->value);
-    self->value = INCREF(value);
+    DECREF(ivars->value);
+    ivars->value = INCREF(value);
 }
 
 void
 TextTermStepper_reset(TextTermStepper *self) {
-    CB_Set_Size((CharBuf*)self->value, 0);
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
+    CB_Set_Size((CharBuf*)ivars->value, 0);
 }
 
 void
 TextTermStepper_write_key_frame(TextTermStepper *self, OutStream *outstream,
                                 Obj *value) {
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
     uint8_t *buf  = CB_Get_Ptr8((CharBuf*)value);
     size_t   size = CB_Get_Size((CharBuf*)value);
     OutStream_Write_C32(outstream, size);
     OutStream_Write_Bytes(outstream, buf, size);
-    Obj_Mimic(self->value, value);
+    Obj_Mimic(ivars->value, value);
 }
 
 void
 TextTermStepper_write_delta(TextTermStepper *self, OutStream *outstream,
                             Obj *value) {
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
     CharBuf *new_value  = (CharBuf*)CERTIFY(value, CHARBUF);
-    CharBuf *last_value = (CharBuf*)self->value;
+    CharBuf *last_value = (CharBuf*)ivars->value;
     char    *new_text  = (char*)CB_Get_Ptr8(new_value);
     size_t   new_size  = CB_Get_Size(new_value);
     char    *last_text = (char*)CB_Get_Ptr8(last_value);
@@ -100,18 +105,19 @@ TextTermStepper_write_delta(TextTermStepper *self, OutStream *outstream,
     OutStream_Write_String(outstream, diff_start_str, diff_len);
 
     // Update value.
-    CB_Mimic((CharBuf*)self->value, value);
+    CB_Mimic((CharBuf*)ivars->value, value);
 }
 
 void
 TextTermStepper_read_key_frame(TextTermStepper *self, InStream *instream) {
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
     const uint32_t text_len = InStream_Read_C32(instream);
 
     // Allocate space.
-    if (self->value == NULL) {
-        self->value = (Obj*)CB_new(text_len);
+    if (ivars->value == NULL) {
+        ivars->value = (Obj*)CB_new(text_len);
     }
-    CharBuf *value = (CharBuf*)self->value;
+    CharBuf *value = (CharBuf*)ivars->value;
     char *ptr      = CB_Grow(value, text_len);
 
     // Set the value text.
@@ -129,15 +135,16 @@ TextTermStepper_read_key_frame(TextTermStepper *self, InStream *instream)
{
 
 void
 TextTermStepper_read_delta(TextTermStepper *self, InStream *instream) {
+    TextTermStepperIVARS *const ivars = TextTermStepper_IVARS(self);
     const uint32_t text_overlap     = InStream_Read_C32(instream);
     const uint32_t finish_chars_len = InStream_Read_C32(instream);
     const uint32_t total_text_len   = text_overlap + finish_chars_len;
 
     // Allocate space.
-    if (self->value == NULL) {
-        self->value = (Obj*)CB_new(total_text_len);
+    if (ivars->value == NULL) {
+        ivars->value = (Obj*)CB_new(total_text_len);
     }
-    CharBuf *value = (CharBuf*)self->value;
+    CharBuf *value = (CharBuf*)ivars->value;
     char *ptr      = CB_Grow(value, total_text_len);
 
     // Set the value text.


Mime
View raw message