Convert calls to Obj_To_* to Json helpers

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

Branch: refs/heads/master
Commit: b5c9cf9c5fea59fc25c35540fd4ca241c35087d6
Parents: 8b4f060
Author: Nick Wellnhofer <[email protected]>
Authored: Sat May 23 15:24:43 2015 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Sat May 23 17:09:12 2015 +0200

----------------------------------------------------------------------
 core/Lucy/Analysis/Normalizer.c               |  5 +++--
 core/Lucy/Document/HitDoc.c                   |  3 ++-
 core/Lucy/Index/DeletionsReader.c             |  3 ++-
 core/Lucy/Index/DeletionsWriter.c             |  3 ++-
 core/Lucy/Index/DocReader.c                   |  3 ++-
 core/Lucy/Index/FilePurger.c                  |  3 ++-
 core/Lucy/Index/HighlightReader.c             |  5 +++--
 core/Lucy/Index/Indexer.c                     |  4 ++--
 core/Lucy/Index/PostingListReader.c           |  5 +++--
 core/Lucy/Index/SegLexicon.c                  |  7 ++++---
 core/Lucy/Index/Segment.c                     |  2 +-
 core/Lucy/Index/Snapshot.c                    |  4 ++--
 core/Lucy/Index/SortReader.c                  |  9 +++++----
 core/Lucy/Plan/BlobType.c                     |  7 ++++---
 core/Lucy/Plan/FullTextType.c                 | 11 ++++++-----
 core/Lucy/Plan/NumericType.c                  |  9 +++++----
 core/Lucy/Plan/Schema.c                       |  2 +-
 core/Lucy/Plan/StringType.c                   |  9 +++++----
 core/Lucy/Search/NoMatchQuery.c               |  3 ++-
 core/Lucy/Search/Query.c                      |  3 ++-
 core/Lucy/Search/RangeQuery.c                 |  5 +++--
 core/Lucy/Store/CompoundFileReader.c          |  8 ++++----
 core/Lucy/Test/Store/TestCompoundFileWriter.c |  2 +-
 core/LucyX/Search/ProximityQuery.c            |  3 ++-
 perl/xs/Lucy/Document/Doc.c                   |  3 ++-
 25 files changed, 70 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Analysis/Normalizer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/Normalizer.c b/core/Lucy/Analysis/Normalizer.c
index 8ea50ba..7f2382e 100644
--- a/core/Lucy/Analysis/Normalizer.c
+++ b/core/Lucy/Analysis/Normalizer.c
@@ -22,6 +22,7 @@
 #include "Lucy/Analysis/Normalizer.h"
 #include "Lucy/Analysis/Token.h"
 #include "Lucy/Analysis/Inversion.h"
+#include "Lucy/Util/Json.h"
 
 #include "utf8proc.h"
 
@@ -154,9 +155,9 @@ Normalizer_Load_IMP(Normalizer *self, Obj *dump) {
     Obj *obj = Hash_Fetch_Utf8(source, "normalization_form", 18);
     String *form = (String*)CERTIFY(obj, STRING);
     obj = Hash_Fetch_Utf8(source, "case_fold", 9);
-    bool case_fold = Obj_To_Bool(CERTIFY(obj, OBJ));
+    bool case_fold = Json_obj_to_bool(CERTIFY(obj, OBJ));
     obj = Hash_Fetch_Utf8(source, "strip_accents", 13);
-    bool strip_accents = Obj_To_Bool(CERTIFY(obj, OBJ));
+    bool strip_accents = Json_obj_to_bool(CERTIFY(obj, OBJ));
 
     return Normalizer_init(loaded, form, case_fold, strip_accents);
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Document/HitDoc.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Document/HitDoc.c b/core/Lucy/Document/HitDoc.c
index 391b931..98d3123 100644
--- a/core/Lucy/Document/HitDoc.c
+++ b/core/Lucy/Document/HitDoc.c
@@ -20,6 +20,7 @@
 #include "Lucy/Document/HitDoc.h"
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
+#include "Lucy/Util/Json.h"
 
 HitDoc*
 HitDoc_new(void *fields, int32_t doc_id, float score) {
@@ -82,7 +83,7 @@ HitDoc_Load_IMP(HitDoc *self, Obj *dump) {
     HitDoc *loaded = super_load(self, dump);
     HitDocIVARS *const loaded_ivars = HitDoc_IVARS(loaded);
     Obj *score = CERTIFY(Hash_Fetch_Utf8(source, "score", 5), OBJ);
-    loaded_ivars->score = (float)Obj_To_F64(score);
+    loaded_ivars->score = (float)Json_obj_to_f64(score);
     return loaded;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/DeletionsReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsReader.c 
b/core/Lucy/Index/DeletionsReader.c
index 5c1ed67..c7118c5 100644
--- a/core/Lucy/Index/DeletionsReader.c
+++ b/core/Lucy/Index/DeletionsReader.c
@@ -30,6 +30,7 @@
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Util/IndexFileNames.h"
+#include "Lucy/Util/Json.h"
 
 DeletionsReader*
 DelReader_init(DeletionsReader *self, Schema *schema, Folder *folder,
@@ -177,7 +178,7 @@ DefDelReader_Read_Deletions_IMP(DefaultDeletionsReader 
*self) {
                 Obj *count = (Obj*)CERTIFY(
                                  Hash_Fetch_Utf8(seg_files_data, "count", 5),
                                  OBJ);
-                del_count = (int32_t)Obj_To_I64(count);
+                del_count = (int32_t)Json_obj_to_i64(count);
                 del_file  = (String*)CERTIFY(
                                 Hash_Fetch_Utf8(seg_files_data, "filename", 8),
                                 STRING);

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/DeletionsWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsWriter.c 
b/core/Lucy/Index/DeletionsWriter.c
index 2d93bab..b626188 100644
--- a/core/Lucy/Index/DeletionsWriter.c
+++ b/core/Lucy/Index/DeletionsWriter.c
@@ -38,6 +38,7 @@
 #include "Lucy/Search/Query.h"
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/OutStream.h"
+#include "Lucy/Util/Json.h"
 
 DeletionsWriter*
 DelWriter_init(DeletionsWriter *self, Schema *schema, Snapshot *snapshot,
@@ -371,7 +372,7 @@ DefDelWriter_Merge_Segment_IMP(DefaultDeletionsWriter *self,
                          * merge away the most recent deletions file
                          * pointing at this target segment -- so force a
                          * new file to be written out. */
-                        int32_t count = 
(int32_t)Obj_To_I64(Hash_Fetch_Utf8(mini_meta, "count", 5));
+                        int32_t count = 
(int32_t)Json_obj_to_i64(Hash_Fetch_Utf8(mini_meta, "count", 5));
                         DeletionsReader *del_reader
                             = (DeletionsReader*)SegReader_Obtain(
                                   candidate, Class_Get_Name(DELETIONSREADER));

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocReader.c b/core/Lucy/Index/DocReader.c
index 0df3798..8759074 100644
--- a/core/Lucy/Index/DocReader.c
+++ b/core/Lucy/Index/DocReader.c
@@ -28,6 +28,7 @@
 #include "Lucy/Plan/Schema.h"
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/InStream.h"
+#include "Lucy/Util/Json.h"
 
 DocReader*
 DocReader_init(DocReader *self, Schema *schema, Folder *folder,
@@ -150,7 +151,7 @@ DefDocReader_init(DefaultDocReader *self, Schema *schema, 
Folder *folder,
         // Check format.
         if (!format) { THROW(ERR, "Missing 'format' var"); }
         else {
-            int64_t format_val = Obj_To_I64(format);
+            int64_t format_val = Json_obj_to_i64(format);
             if (format_val < DocWriter_current_file_format) {
                 THROW(ERR, "Obsolete doc storage format %i64; "
                       "Index regeneration is required", format_val);

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/FilePurger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/FilePurger.c b/core/Lucy/Index/FilePurger.c
index 3e3bc28..a128961 100644
--- a/core/Lucy/Index/FilePurger.c
+++ b/core/Lucy/Index/FilePurger.c
@@ -26,6 +26,7 @@
 #include "Lucy/Store/DirHandle.h"
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/Lock.h"
+#include "Lucy/Util/Json.h"
 
 // Place unused files into purgables array and obsolete Snapshots into
 // snapshots array.
@@ -153,7 +154,7 @@ S_zap_dead_merge(FilePurger *self, Hash *candidates) {
                        : NULL;
 
         if (cutoff) {
-            String *cutoff_seg = Seg_num_to_name(Obj_To_I64(cutoff));
+            String *cutoff_seg = Seg_num_to_name(Json_obj_to_i64(cutoff));
             if (Folder_Exists(ivars->folder, cutoff_seg)) {
                 String *merge_json = SSTR_WRAP_UTF8("merge.json", 10);
                 DirHandle *dh = Folder_Open_Dir(ivars->folder, cutoff_seg);

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/HighlightReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightReader.c 
b/core/Lucy/Index/HighlightReader.c
index eff0e32..0d443c3 100644
--- a/core/Lucy/Index/HighlightReader.c
+++ b/core/Lucy/Index/HighlightReader.c
@@ -31,6 +31,7 @@
 #include "Lucy/Store/OutStream.h"
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Util/Freezer.h"
+#include "Lucy/Util/Json.h"
 
 HighlightReader*
 HLReader_init(HighlightReader *self, Schema *schema, Folder *folder,
@@ -130,9 +131,9 @@ DefHLReader_init(DefaultHighlightReader *self, Schema 
*schema,
         Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
         if (!format) { THROW(ERR, "Missing 'format' var"); }
         else {
-            if (Obj_To_I64(format) != HLWriter_current_file_format) {
+            if (Json_obj_to_i64(format) != HLWriter_current_file_format) {
                 THROW(ERR, "Unsupported highlight data format: %i64",
-                      Obj_To_I64(format));
+                      Json_obj_to_i64(format));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/Indexer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Indexer.c b/core/Lucy/Index/Indexer.c
index efaec72..2226b84 100644
--- a/core/Lucy/Index/Indexer.c
+++ b/core/Lucy/Index/Indexer.c
@@ -184,7 +184,7 @@ Indexer_init(Indexer *self, Schema *schema, Obj *index,
             THROW(ERR, "Background merge detected, but can't read merge data");
         }
         else {
-            int64_t cutoff = Obj_To_I64(cutoff_obj);
+            int64_t cutoff = Json_obj_to_i64(cutoff_obj);
             if (cutoff >= new_seg_num) {
                 new_seg_num = cutoff + 1;
             }
@@ -414,7 +414,7 @@ S_maybe_merge(Indexer *self, Vector *seg_readers) {
         if (merge_data) {
             Obj *cutoff_obj = Hash_Fetch_Utf8(merge_data, "cutoff", 6);
             if (cutoff_obj) {
-                cutoff = Obj_To_I64(cutoff_obj);
+                cutoff = Json_obj_to_i64(cutoff_obj);
             }
             else {
                 cutoff = INT64_MAX;

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/PostingListReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingListReader.c 
b/core/Lucy/Index/PostingListReader.c
index dbaa171..b2b08e1 100644
--- a/core/Lucy/Index/PostingListReader.c
+++ b/core/Lucy/Index/PostingListReader.c
@@ -29,6 +29,7 @@
 #include "Lucy/Plan/FieldType.h"
 #include "Lucy/Plan/Schema.h"
 #include "Lucy/Store/Folder.h"
+#include "Lucy/Util/Json.h"
 
 PostingListReader*
 PListReader_init(PostingListReader *self, Schema *schema, Folder *folder,
@@ -80,9 +81,9 @@ DefPListReader_init(DefaultPostingListReader *self, Schema 
*schema,
         Obj *format = Hash_Fetch_Utf8(my_meta, "format", 6);
         if (!format) { THROW(ERR, "Missing 'format' var"); }
         else {
-            if (Obj_To_I64(format) != PListWriter_current_file_format) {
+            if (Json_obj_to_i64(format) != PListWriter_current_file_format) {
                 THROW(ERR, "Unsupported postings format: %i64",
-                      Obj_To_I64(format));
+                      Json_obj_to_i64(format));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/SegLexicon.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegLexicon.c b/core/Lucy/Index/SegLexicon.c
index c30bf06..5a56920 100644
--- a/core/Lucy/Index/SegLexicon.c
+++ b/core/Lucy/Index/SegLexicon.c
@@ -31,6 +31,7 @@
 #include "Lucy/Plan/Schema.h"
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/InStream.h"
+#include "Lucy/Util/Json.h"
 
 // Iterate until the state is greater than or equal to the target.
 static void
@@ -63,9 +64,9 @@ SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
     // Check format.
     if (!format) { THROW(ERR, "Missing 'format'"); }
     else {
-        if (Obj_To_I64(format) > LexWriter_current_file_format) {
+        if (Json_obj_to_i64(format) > LexWriter_current_file_format) {
             THROW(ERR, "Unsupported lexicon format: %i64",
-                  Obj_To_I64(format));
+                  Json_obj_to_i64(format));
         }
     }
 
@@ -73,7 +74,7 @@ SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
     if (!counts) { THROW(ERR, "Failed to extract 'counts'"); }
     else {
         Obj *count = CERTIFY(Hash_Fetch(counts, field), OBJ);
-        ivars->size = (int32_t)Obj_To_I64(count);
+        ivars->size = (int32_t)Json_obj_to_i64(count);
     }
 
     // Assign.

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/Segment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c
index 0e96acb..fdf46fc 100644
--- a/core/Lucy/Index/Segment.c
+++ b/core/Lucy/Index/Segment.c
@@ -113,7 +113,7 @@ Seg_Read_File_IMP(Segment *self, Folder *folder) {
     Obj *count = Hash_Fetch_Utf8(my_metadata, "count", 5);
     if (!count) { count = Hash_Fetch_Utf8(my_metadata, "doc_count", 9); }
     if (!count) { THROW(ERR, "Missing 'count'"); }
-    else { ivars->count = Obj_To_I64(count); }
+    else { ivars->count = Json_obj_to_i64(count); }
 
     // Get list of field nums.
     Vector *source_by_num = (Vector*)Hash_Fetch_Utf8(my_metadata,

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/Snapshot.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Snapshot.c b/core/Lucy/Index/Snapshot.c
index 9d710df..90a91c7 100644
--- a/core/Lucy/Index/Snapshot.c
+++ b/core/Lucy/Index/Snapshot.c
@@ -115,10 +115,10 @@ Snapshot_Read_File_IMP(Snapshot *self, Folder *folder, 
String *path) {
             = (Hash*)CERTIFY(Json_slurp_json(folder, ivars->path), HASH);
         Obj *format_obj
             = CERTIFY(Hash_Fetch_Utf8(snap_data, "format", 6), OBJ);
-        int32_t format = (int32_t)Obj_To_I64(format_obj);
+        int32_t format = (int32_t)Json_obj_to_i64(format_obj);
         Obj *subformat_obj = Hash_Fetch_Utf8(snap_data, "subformat", 9);
         int32_t subformat = subformat_obj
-                            ? (int32_t)Obj_To_I64(subformat_obj)
+                            ? (int32_t)Json_obj_to_i64(subformat_obj)
                             : 0;
 
         // Verify that we can read the index properly.

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Index/SortReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortReader.c b/core/Lucy/Index/SortReader.c
index b8359bf..2d39125 100644
--- a/core/Lucy/Index/SortReader.c
+++ b/core/Lucy/Index/SortReader.c
@@ -28,6 +28,7 @@
 #include "Lucy/Plan/Schema.h"
 #include "Lucy/Store/Folder.h"
 #include "Lucy/Store/InStream.h"
+#include "Lucy/Util/Json.h"
 
 SortReader*
 SortReader_init(SortReader *self, Schema *schema, Folder *folder,
@@ -71,7 +72,7 @@ DefSortReader_init(DefaultSortReader *self, Schema *schema, 
Folder *folder,
         Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
         if (!format) { THROW(ERR, "Missing 'format' var"); }
         else {
-            ivars->format = (int32_t)Obj_To_I64(format);
+            ivars->format = (int32_t)Json_obj_to_i64(format);
             if (ivars->format < 2 || ivars->format > 3) {
                 THROW(ERR, "Unsupported sort cache format: %i32",
                       ivars->format);
@@ -160,7 +161,7 @@ S_lazy_init_sort_cache(DefaultSortReader *self, String 
*field) {
 
     // See if we have any values.
     Obj *count_obj = Hash_Fetch(ivars->counts, field);
-    int32_t count = count_obj ? (int32_t)Obj_To_I64(count_obj) : 0;
+    int32_t count = count_obj ? (int32_t)Json_obj_to_i64(count_obj) : 0;
     if (!count) { return NULL; }
 
     // Get a FieldType and sanity check that the field is sortable.
@@ -205,10 +206,10 @@ S_lazy_init_sort_cache(DefaultSortReader *self, String 
*field) {
     }
 
     Obj     *null_ord_obj = Hash_Fetch(ivars->null_ords, field);
-    int32_t  null_ord = null_ord_obj ? (int32_t)Obj_To_I64(null_ord_obj) : -1;
+    int32_t  null_ord = null_ord_obj ? (int32_t)Json_obj_to_i64(null_ord_obj) 
: -1;
     Obj     *ord_width_obj = Hash_Fetch(ivars->ord_widths, field);
     int32_t  ord_width = ord_width_obj
-                         ? (int32_t)Obj_To_I64(ord_width_obj)
+                         ? (int32_t)Json_obj_to_i64(ord_width_obj)
                          : S_calc_ord_width(count);
     int32_t  doc_max = (int32_t)Seg_Get_Count(segment);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Plan/BlobType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/BlobType.c b/core/Lucy/Plan/BlobType.c
index a9a2192..ab0048c 100644
--- a/core/Lucy/Plan/BlobType.c
+++ b/core/Lucy/Plan/BlobType.c
@@ -18,6 +18,7 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Plan/BlobType.h"
+#include "Lucy/Util/Json.h"
 
 BlobType*
 BlobType_new(bool stored) {
@@ -107,13 +108,13 @@ BlobType_Load_IMP(BlobType *self, Obj *dump) {
     BlobType_init(loaded, false);
     BlobTypeIVARS *const loaded_ivars = BlobType_IVARS(loaded);
     if (boost_dump) {
-        loaded_ivars->boost = (float)Obj_To_F64(boost_dump);
+        loaded_ivars->boost = (float)Json_obj_to_f64(boost_dump);
     }
     if (indexed_dump) {
-        loaded_ivars->indexed = Obj_To_Bool(indexed_dump);
+        loaded_ivars->indexed = Json_obj_to_bool(indexed_dump);
     }
     if (stored_dump){
-        loaded_ivars->stored = Obj_To_Bool(stored_dump);
+        loaded_ivars->stored = Json_obj_to_bool(stored_dump);
     }
 
     return loaded;

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Plan/FullTextType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/FullTextType.c b/core/Lucy/Plan/FullTextType.c
index 893b1b6..00cc578 100644
--- a/core/Lucy/Plan/FullTextType.c
+++ b/core/Lucy/Plan/FullTextType.c
@@ -22,6 +22,7 @@
 #include "Lucy/Index/Posting/ScorePosting.h"
 #include "Lucy/Index/Similarity.h"
 #include "Lucy/Util/Freezer.h"
+#include "Lucy/Util/Json.h"
 
 FullTextType*
 FullTextType_new(Analyzer *analyzer) {
@@ -129,17 +130,17 @@ FullTextType_Load_IMP(FullTextType *self, Obj *dump) {
 
     // Extract boost.
     Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5);
-    float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f;
+    float boost = boost_dump ? (float)Json_obj_to_f64(boost_dump) : 1.0f;
 
     // Find boolean properties.
     Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7);
     Obj *stored_dump  = Hash_Fetch_Utf8(source, "stored", 6);
     Obj *sort_dump    = Hash_Fetch_Utf8(source, "sortable", 8);
     Obj *hl_dump      = Hash_Fetch_Utf8(source, "highlightable", 13);
-    bool indexed  = indexed_dump ? Obj_To_Bool(indexed_dump) : true;
-    bool stored   = stored_dump  ? Obj_To_Bool(stored_dump)  : true;
-    bool sortable = sort_dump    ? Obj_To_Bool(sort_dump)    : false;
-    bool hl       = hl_dump      ? Obj_To_Bool(hl_dump)      : false;
+    bool indexed  = indexed_dump ? Json_obj_to_bool(indexed_dump) : true;
+    bool stored   = stored_dump  ? Json_obj_to_bool(stored_dump)  : true;
+    bool sortable = sort_dump    ? Json_obj_to_bool(sort_dump)    : false;
+    bool hl       = hl_dump      ? Json_obj_to_bool(hl_dump)      : false;
 
     // Extract an Analyzer.
     Obj *analyzer_dump = Hash_Fetch_Utf8(source, "analyzer", 8);

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Plan/NumericType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/NumericType.c b/core/Lucy/Plan/NumericType.c
index a802d32..217ea49 100644
--- a/core/Lucy/Plan/NumericType.c
+++ b/core/Lucy/Plan/NumericType.c
@@ -18,6 +18,7 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Plan/NumericType.h"
+#include "Lucy/Util/Json.h"
 
 NumericType*
 NumType_init(NumericType *self) {
@@ -108,15 +109,15 @@ NumType_Load_IMP(NumericType *self, Obj *dump) {
 
     // Extract boost.
     Obj *boost_dump = Hash_Fetch_Utf8(source, "boost", 5);
-    float boost = boost_dump ? (float)Obj_To_F64(boost_dump) : 1.0f;
+    float boost = boost_dump ? (float)Json_obj_to_f64(boost_dump) : 1.0f;
 
     // Find boolean properties.
     Obj *indexed_dump = Hash_Fetch_Utf8(source, "indexed", 7);
     Obj *stored_dump  = Hash_Fetch_Utf8(source, "stored", 6);
     Obj *sort_dump    = Hash_Fetch_Utf8(source, "sortable", 8);
-    bool indexed  = indexed_dump ? Obj_To_Bool(indexed_dump) : true;
-    bool stored   = stored_dump  ? Obj_To_Bool(stored_dump)  : true;
-    bool sortable = sort_dump    ? Obj_To_Bool(sort_dump)    : false;
+    bool indexed  = indexed_dump ? Json_obj_to_bool(indexed_dump) : true;
+    bool stored   = stored_dump  ? Json_obj_to_bool(stored_dump)  : true;
+    bool sortable = sort_dump    ? Json_obj_to_bool(sort_dump)    : false;
 
     return NumType_init2(loaded, boost, indexed, stored, sortable);
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Plan/Schema.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/Schema.c b/core/Lucy/Plan/Schema.c
index db3a838..77d9680 100644
--- a/core/Lucy/Plan/Schema.c
+++ b/core/Lucy/Plan/Schema.c
@@ -336,7 +336,7 @@ Schema_Load_IMP(Schema *self, Obj *dump) {
                     = CERTIFY(Hash_Fetch_Utf8(type_dump, "analyzer", 8), OBJ);
                 Analyzer *analyzer
                     = (Analyzer*)Vec_Fetch(analyzers,
-                                          (uint32_t)Obj_To_I64(tick));
+                                          (uint32_t)Json_obj_to_i64(tick));
                 if (!analyzer) {
                     THROW(ERR, "Can't find analyzer for '%o'", field);
                 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Plan/StringType.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Plan/StringType.c b/core/Lucy/Plan/StringType.c
index e7f6f95..d6262a3 100644
--- a/core/Lucy/Plan/StringType.c
+++ b/core/Lucy/Plan/StringType.c
@@ -20,6 +20,7 @@
 #include "Lucy/Plan/StringType.h"
 #include "Lucy/Index/Posting/ScorePosting.h"
 #include "Lucy/Index/Similarity.h"
+#include "Lucy/Util/Json.h"
 
 StringType*
 StringType_new() {
@@ -101,10 +102,10 @@ StringType_Load_IMP(StringType *self, Obj *dump) {
     Obj *sortable_dump   = Hash_Fetch_Utf8(source, "sortable", 8);
     UNUSED_VAR(self);
 
-    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;
+    float boost    = boost_dump    ? (float)Json_obj_to_f64(boost_dump) : 1.0f;
+    bool  indexed  = indexed_dump  ? Json_obj_to_bool(indexed_dump)     : true;
+    bool  stored   = stored_dump   ? Json_obj_to_bool(stored_dump)      : true;
+    bool  sortable = sortable_dump ? Json_obj_to_bool(sortable_dump)    : 
false;
 
     return StringType_init2(loaded, boost, indexed, stored, sortable);
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Search/NoMatchQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/NoMatchQuery.c b/core/Lucy/Search/NoMatchQuery.c
index 55fb008..408358d 100644
--- a/core/Lucy/Search/NoMatchQuery.c
+++ b/core/Lucy/Search/NoMatchQuery.c
@@ -26,6 +26,7 @@
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
 #include "Lucy/Util/Freezer.h"
+#include "Lucy/Util/Json.h"
 
 NoMatchQuery*
 NoMatchQuery_new() {
@@ -96,7 +97,7 @@ NoMatchQuery_Load_IMP(NoMatchQuery *self, Obj *dump) {
     NoMatchQuery *loaded = super_load(self, dump);
     Obj *fails = CFISH_Hash_Fetch_Utf8(source, "fails_to_match", 14);
     NoMatchQuery_IVARS(loaded)->fails_to_match
-        = fails ? Obj_To_Bool(fails) : true;
+        = fails ? Json_obj_to_bool(fails) : true;
     return loaded;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Search/Query.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/Query.c b/core/Lucy/Search/Query.c
index 49b41cb..b82776e 100644
--- a/core/Lucy/Search/Query.c
+++ b/core/Lucy/Search/Query.c
@@ -22,6 +22,7 @@
 #include "Lucy/Search/Searcher.h"
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
+#include "Lucy/Util/Json.h"
 
 Query*
 Query_init(Query *self, float boost) {
@@ -71,7 +72,7 @@ Query_Load_IMP(Query *self, Obj *dump) {
     Class *klass  = Class_singleton(class_name, NULL);
     Query *loaded = (Query*)Class_Make_Obj(klass);
     Obj *boost = CERTIFY(Hash_Fetch_Utf8(source, "boost", 5), OBJ);
-    Query_IVARS(loaded)->boost = (float)Obj_To_F64(boost);
+    Query_IVARS(loaded)->boost = (float)Json_obj_to_f64(boost);
     return (Obj*)loaded;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Search/RangeQuery.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/RangeQuery.c b/core/Lucy/Search/RangeQuery.c
index a2c3699..63cc997 100644
--- a/core/Lucy/Search/RangeQuery.c
+++ b/core/Lucy/Search/RangeQuery.c
@@ -31,6 +31,7 @@
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
 #include "Lucy/Util/Freezer.h"
+#include "Lucy/Util/Json.h"
 
 // Determine the lowest ordinal that should match.
 static int32_t
@@ -203,10 +204,10 @@ RangeQuery_Load_IMP(RangeQuery *self, Obj *dump) {
     }
     Obj *include_lower
         = CERTIFY(Hash_Fetch_Utf8(source, "include_lower", 13), OBJ);
-    loaded_ivars->include_lower = Obj_To_Bool(include_lower);
+    loaded_ivars->include_lower = Json_obj_to_bool(include_lower);
     Obj *include_upper
         = CERTIFY(Hash_Fetch_Utf8(source, "include_upper", 13), OBJ);
-    loaded_ivars->include_upper = Obj_To_Bool(include_upper);
+    loaded_ivars->include_upper = Json_obj_to_bool(include_upper);
     return (Obj*)loaded;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Store/CompoundFileReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Store/CompoundFileReader.c 
b/core/Lucy/Store/CompoundFileReader.c
index 2add656..396eabe 100644
--- a/core/Lucy/Store/CompoundFileReader.c
+++ b/core/Lucy/Store/CompoundFileReader.c
@@ -51,7 +51,7 @@ CFReader_do_open(CompoundFileReader *self, Folder *folder) {
     }
     else {
         Obj *format = Hash_Fetch_Utf8(metadata, "format", 6);
-        ivars->format = format ? (int32_t)Obj_To_I64(format) : 0;
+        ivars->format = format ? (int32_t)Json_obj_to_i64(format) : 0;
         ivars->records = (Hash*)INCREF(Hash_Fetch_Utf8(metadata, "files", 5));
         if (ivars->format < 1) {
             error = Err_new(Str_newf("Corrupt %o file: Missing or invalid 
'format'",
@@ -206,13 +206,13 @@ CFReader_Local_Open_In_IMP(CompoundFileReader *self, 
String *name) {
         else if (Str_Get_Size(ivars->path)) {
             String *fullpath = Str_newf("%o/%o", ivars->path, name);
             InStream *instream = InStream_Reopen(ivars->instream, fullpath,
-                                                 Obj_To_I64(offset), 
Obj_To_I64(len));
+                                                 Json_obj_to_i64(offset), 
Json_obj_to_i64(len));
             DECREF(fullpath);
             return instream;
         }
         else {
-            return InStream_Reopen(ivars->instream, name, Obj_To_I64(offset),
-                                   Obj_To_I64(len));
+            return InStream_Reopen(ivars->instream, name, 
Json_obj_to_i64(offset),
+                                   Json_obj_to_i64(len));
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/Lucy/Test/Store/TestCompoundFileWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Store/TestCompoundFileWriter.c 
b/core/Lucy/Test/Store/TestCompoundFileWriter.c
index c633a83..28b551b 100644
--- a/core/Lucy/Test/Store/TestCompoundFileWriter.c
+++ b/core/Lucy/Test/Store/TestCompoundFileWriter.c
@@ -128,7 +128,7 @@ test_offsets(TestBatchRunner *runner) {
         String *file   = HashIter_Get_Key(iter);
         Hash   *stats  = (Hash*)CERTIFY(HashIter_Get_Value(iter), HASH);
         Obj    *offset = CERTIFY(Hash_Fetch_Utf8(stats, "offset", 6), OBJ);
-        int64_t offs   = Obj_To_I64(offset);
+        int64_t offs   = Json_obj_to_i64(offset);
         if (offs % 8 != 0) {
             offsets_ok = false;
             FAIL(runner, "Offset %" PRId64 " for %s not a multiple of 8",

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/core/LucyX/Search/ProximityQuery.c
----------------------------------------------------------------------
diff --git a/core/LucyX/Search/ProximityQuery.c 
b/core/LucyX/Search/ProximityQuery.c
index 027d106..6173acc 100644
--- a/core/LucyX/Search/ProximityQuery.c
+++ b/core/LucyX/Search/ProximityQuery.c
@@ -39,6 +39,7 @@
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
 #include "Lucy/Util/Freezer.h"
+#include "Lucy/Util/Json.h"
 
 // Shared initialization routine which assumes that it's ok to assume control
 // over [field] and [terms], eating their refcounts.
@@ -123,7 +124,7 @@ ProximityQuery_Load_IMP(ProximityQuery *self, Obj *dump) {
     Obj *terms = CERTIFY(Hash_Fetch_Utf8(source, "terms", 5), OBJ);
     loaded_ivars->terms = (Vector*)CERTIFY(Freezer_load(terms), VECTOR);
     Obj *within = CERTIFY(Hash_Fetch_Utf8(source, "within", 6), OBJ);
-    loaded_ivars->within = (uint32_t)Obj_To_I64(within);
+    loaded_ivars->within = (uint32_t)Json_obj_to_i64(within);
     return (Obj*)loaded;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/b5c9cf9c/perl/xs/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Document/Doc.c b/perl/xs/Lucy/Document/Doc.c
index 97ab055..651e140 100644
--- a/perl/xs/Lucy/Document/Doc.c
+++ b/perl/xs/Lucy/Document/Doc.c
@@ -19,6 +19,7 @@
 #include "Lucy/Document/Doc.h"
 #include "Lucy/Store/InStream.h"
 #include "Lucy/Store/OutStream.h"
+#include "Lucy/Util/Json.h"
 #include "Clownfish/Util/Memory.h"
 
 lucy_Doc*
@@ -191,7 +192,7 @@ LUCY_Doc_Load_IMP(lucy_Doc *self, cfish_Obj *dump) {
     CFISH_UNUSED_VAR(self);
 
     lucy_DocIVARS *const loaded_ivars = lucy_Doc_IVARS(loaded);
-    loaded_ivars->doc_id = (int32_t)CFISH_Obj_To_I64(doc_id);
+    loaded_ivars->doc_id = (int32_t)lucy_Json_obj_to_i64(doc_id);
     loaded_ivars->fields  = SvREFCNT_inc(SvRV(fields_sv));
     SvREFCNT_dec(fields_sv);
 

Reply via email to