lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [10/15] git commit: refs/heads/cfish-string-prep1 - Rework string constructors
Date Sat, 14 Sep 2013 19:29:42 GMT
Rework string constructors

* Add 'origin' instance variable to String to distinguish normal
  strings, substrings, and wrapped strings.
* Add Str_new_wrap_* constructors to replace ViewCharBuf.
* Rename Str_new_steal_* constructors.
* Remove SStr_new constructor


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

Branch: refs/heads/cfish-string-prep1
Commit: 0008a9980b3d6604f90f0654e0631597c5c7a766
Parents: fc363f0
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 14 20:16:38 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 14 20:16:38 2013 +0200

----------------------------------------------------------------------
 c/src/Lucy/Index/DocReader.c                    |   3 +-
 clownfish/runtime/core/Clownfish/CharBuf.c      |   2 +-
 clownfish/runtime/core/Clownfish/Num.c          |   1 -
 clownfish/runtime/core/Clownfish/String.c       | 144 +++++++++----------
 clownfish/runtime/core/Clownfish/String.cfh     |  53 +++----
 .../perl/buildlib/Clownfish/Build/Binding.pm    |  17 ---
 clownfish/runtime/perl/lib/Clownfish.pm         |   8 --
 clownfish/runtime/perl/xs/XSBind.c              |   1 -
 core/Lucy/Analysis/SnowballStopFilter.c         |   2 +-
 core/Lucy/Index/SortCache/TextSortCache.c       |   2 +-
 core/Lucy/Util/Freezer.c                        |   4 +-
 core/Lucy/Util/Json.c                           |   2 +-
 example-lang/src/Lucy/Document/Doc.c            |   3 +-
 perl/xs/Lucy/Document/Doc.c                     |   2 +-
 perl/xs/Lucy/Index/Inverter.c                   |   2 +-
 ruby/src/Lucy/Document/Doc.c                    |   3 +-
 16 files changed, 110 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/c/src/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Index/DocReader.c b/c/src/Lucy/Index/DocReader.c
index 7904c45..31a1077 100644
--- a/c/src/Lucy/Index/DocReader.c
+++ b/c/src/Lucy/Index/DocReader.c
@@ -77,8 +77,7 @@ DefDocReader_Fetch_Doc_IMP(DefaultDocReader *self, int32_t doc_id) {
                     char *buf = (char*)MALLOCATE(value_len + 1);
                     InStream_Read_Bytes(dat_in, buf, value_len);
                     buf[value_len] = '\0'; 
-                    value
-                        = (Obj*)Str_new_steal_from_trusted_str(buf, value_len);
+                    value = (Obj*)Str_new_steal_utf8(buf, value_len);
                     break;
                 }
             case FType_BLOB: {

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/CharBuf.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/CharBuf.c b/clownfish/runtime/core/Clownfish/CharBuf.c
index 7b407ad..bfbae45 100644
--- a/clownfish/runtime/core/Clownfish/CharBuf.c
+++ b/clownfish/runtime/core/Clownfish/CharBuf.c
@@ -304,7 +304,7 @@ CB_To_String_IMP(CharBuf *self) {
 String*
 CB_Yield_String_IMP(CharBuf *self) {
     String *retval
-        = Str_new_steal_from_trusted_str(self->ptr, self->size);
+        = Str_new_steal_trusted_utf8(self->ptr, self->size);
     self->ptr  = NULL;
     self->size = 0;
     self->cap  = 0;

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Num.c b/clownfish/runtime/core/Clownfish/Num.c
index 728c618..f18bf76 100644
--- a/clownfish/runtime/core/Clownfish/Num.c
+++ b/clownfish/runtime/core/Clownfish/Num.c
@@ -22,7 +22,6 @@
 #define C_CFISH_FLOAT32
 #define C_CFISH_FLOAT64
 #define C_CFISH_BOOLNUM
-#define C_CFISH_VIEWCHARBUF
 #define CFISH_USE_SHORT_NAMES
 #define CHY_USE_SHORT_NAMES
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/String.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.c b/clownfish/runtime/core/Clownfish/String.c
index 96cf22f..c917a79 100644
--- a/clownfish/runtime/core/Clownfish/String.c
+++ b/clownfish/runtime/core/Clownfish/String.c
@@ -15,7 +15,6 @@
  */
 
 #define C_CFISH_STRING
-#define C_CFISH_VIEWCHARBUF
 #define C_CFISH_STACKSTRING
 #define C_CFISH_STRINGITERATOR
 #define C_CFISH_STACKSTRINGITERATOR
@@ -53,18 +52,18 @@ S_die_invalid_utf8(const char *text, size_t size, const char *file, int
line,
                    const char *func);
 
 String*
-Str_new_from_utf8(const char *ptr, size_t size) {
-    if (!StrHelp_utf8_valid(ptr, size)) {
-        DIE_INVALID_UTF8(ptr, size);
+Str_new_from_utf8(const char *utf8, size_t size) {
+    if (!StrHelp_utf8_valid(utf8, size)) {
+        DIE_INVALID_UTF8(utf8, size);
     }
     String *self = (String*)VTable_Make_Obj(STRING);
-    return Str_init_from_trusted_utf8(self, ptr, size);
+    return Str_init_from_trusted_utf8(self, utf8, size);
 }
 
 String*
-Str_new_from_trusted_utf8(const char *ptr, size_t size) {
+Str_new_from_trusted_utf8(const char *utf8, size_t size) {
     String *self = (String*)VTable_Make_Obj(STRING);
-    return Str_init_from_trusted_utf8(self, ptr, size);
+    return Str_init_from_trusted_utf8(self, utf8, size);
 }
 
 String*
@@ -77,31 +76,57 @@ Str_init_from_trusted_utf8(String *self, const char *utf8, size_t size)
{
     ptr[size] = '\0'; // Null terminate.
 
     // Assign.
-    self->ptr  = ptr;
-    self->size = size;
+    self->ptr    = ptr;
+    self->size   = size;
+    self->origin = self;
 
     return self;
 }
 
 String*
-Str_new_steal_from_trusted_str(const char *ptr, size_t size) {
+Str_new_steal_utf8(const char *utf8, size_t size) {
+    if (!StrHelp_utf8_valid(utf8, size)) {
+        DIE_INVALID_UTF8(utf8, size);
+    }
+    String *self = (String*)VTable_Make_Obj(STRING);
+    return Str_init_steal_trusted_utf8(self, utf8, size);
+}
+
+String*
+Str_new_steal_trusted_utf8(const char *utf8, size_t size) {
     String *self = (String*)VTable_Make_Obj(STRING);
-    return Str_init_steal_trusted_str(self, ptr, size);
+    return Str_init_steal_trusted_utf8(self, utf8, size);
 }
 
 String*
-Str_init_steal_trusted_str(String *self, const char *ptr, size_t size) {
-    self->ptr  = ptr;
-    self->size = size;
+Str_init_steal_trusted_utf8(String *self, const char *utf8, size_t size) {
+    self->ptr    = utf8;
+    self->size   = size;
+    self->origin = self;
     return self;
 }
 
 String*
-Str_new_steal_str(const char *ptr, size_t size) {
-    if (!StrHelp_utf8_valid(ptr, size)) {
-        DIE_INVALID_UTF8(ptr, size);
+Str_new_wrap_utf8(const char *utf8, size_t size) {
+    if (!StrHelp_utf8_valid(utf8, size)) {
+        DIE_INVALID_UTF8(utf8, size);
     }
-    return Str_new_steal_from_trusted_str(ptr, size);
+    String *self = (String*)VTable_Make_Obj(STRING);
+    return Str_init_wrap_trusted_utf8(self, utf8, size);
+}
+
+String*
+Str_new_wrap_trusted_utf8(const char *utf8, size_t size) {
+    String *self = (String*)VTable_Make_Obj(STRING);
+    return Str_init_wrap_trusted_utf8(self, utf8, size);
+}
+
+String*
+Str_init_wrap_trusted_utf8(String *self, const char *ptr, size_t size) {
+    self->ptr    = ptr;
+    self->size   = size;
+    self->origin = NULL;
+    return self;
 }
 
 String*
@@ -112,8 +137,9 @@ Str_new_from_char(uint32_t code_point) {
     ptr[size] = '\0';
 
     String *self = (String*)VTable_Make_Obj(STRING);
-    self->ptr  = ptr;
-    self->size = size;
+    self->ptr    = ptr;
+    self->size   = size;
+    self->origin = self;
     return self;
 }
 
@@ -129,9 +155,23 @@ Str_newf(const char *pattern, ...) {
     return self;
 }
 
+static String*
+S_new_substring(String *origin, size_t byte_offset, size_t size) {
+    String *self = (String*)VTable_Make_Obj(STRING);
+    self->ptr    = origin->ptr + byte_offset;
+    self->size   = size;
+    self->origin = (String*)INCREF(origin);
+    return self;
+}
+
 void
 Str_Destroy_IMP(String *self) {
-    FREEMEM((char*)self->ptr);
+    if (self->origin == self) {
+        FREEMEM((char*)self->ptr);
+    }
+    else {
+        DECREF(self->origin);
+    }
     SUPER_DESTROY(self, STRING);
 }
 
@@ -275,7 +315,7 @@ Str_Cat_Trusted_Utf8_IMP(String *self, const char* ptr, size_t size) {
     memcpy(result_ptr + self->size, ptr, size);
     result_ptr[result_size] = '\0';
     String *result = (String*)VTable_Make_Obj(STRING);
-    return Str_init_steal_trusted_str(result, result_ptr, result_size);
+    return Str_init_steal_trusted_utf8(result, result_ptr, result_size);
 }
 
 bool
@@ -411,13 +451,12 @@ Str_SubString_IMP(String *self, size_t offset, size_t len) {
     StackStringIterator *iter = STR_STACKTOP(self);
 
     SStrIter_Advance(iter, offset);
-    int start_offset = iter->byte_offset;
-    const char *sub_start = self->ptr + start_offset;
+    size_t start_offset = iter->byte_offset;
 
     SStrIter_Advance(iter, len);
-    size_t byte_len = iter->byte_offset - start_offset;
+    size_t size = iter->byte_offset - start_offset;
 
-    return Str_new_from_trusted_utf8(sub_start, byte_len);
+    return S_new_substring(self, start_offset, size);
 }
 
 int
@@ -480,46 +519,6 @@ Str_StackTail_IMP(String *self, void *allocation) {
 
 /*****************************************************************/
 
-ViewCharBuf*
-ViewCB_new_from_utf8(const char *utf8, size_t size) {
-    if (!StrHelp_utf8_valid(utf8, size)) {
-        DIE_INVALID_UTF8(utf8, size);
-    }
-    return ViewCB_new_from_trusted_utf8(utf8, size);
-}
-
-ViewCharBuf*
-ViewCB_new_from_trusted_utf8(const char *utf8, size_t size) {
-    ViewCharBuf *self = (ViewCharBuf*)VTable_Make_Obj(VIEWCHARBUF);
-    return ViewCB_init(self, utf8, size);
-}
-
-ViewCharBuf*
-ViewCB_init(ViewCharBuf *self, const char *utf8, size_t size) {
-    self->ptr  = utf8;
-    self->size = size;
-    return self;
-}
-
-void
-ViewCB_Destroy_IMP(ViewCharBuf *self) {
-    // Note that we do not free self->ptr, and that we invoke the
-    // SUPER_DESTROY with STRING instead of VIEWCHARBUF.
-    SUPER_DESTROY(self, STRING);
-}
-
-/*****************************************************************/
-
-StackString*
-SStr_new(void *allocation) {
-    static char empty_string[] = "";
-    StackString *self
-        = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
-    self->size = 0;
-    self->ptr  = empty_string;
-    return self;
-}
-
 StackString*
 SStr_new_from_str(void *allocation, size_t alloc_size, String *string) {
     size_t  size = string->size;
@@ -533,8 +532,9 @@ SStr_new_from_str(void *allocation, size_t alloc_size, String *string)
{
     ptr[size] = '\0';
 
     StackString *self = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
-    self->ptr  = ptr;
-    self->size = size;
+    self->ptr    = ptr;
+    self->size   = size;
+    self->origin = NULL;
     return self;
 }
 
@@ -542,8 +542,9 @@ StackString*
 SStr_wrap_str(void *allocation, const char *ptr, size_t size) {
     StackString *self
         = (StackString*)VTable_Init_Obj(STACKSTRING, allocation);
-    self->size = size;
-    self->ptr  = ptr;
+    self->size   = size;
+    self->ptr    = ptr;
+    self->origin = NULL;
     return self;
 }
 
@@ -607,8 +608,7 @@ StrIter_substring(StringIterator *top, StringIterator *tail) {
         }
     }
 
-    return Str_new_from_trusted_utf8(string->ptr + top_offset,
-                                     tail_offset - top_offset);
+    return S_new_substring(string, top_offset, tail_offset - top_offset);
 }
 
 StringIterator*

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/core/Clownfish/String.cfh
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/String.cfh b/clownfish/runtime/core/Clownfish/String.cfh
index f64b73a..a1a0378 100644
--- a/clownfish/runtime/core/Clownfish/String.cfh
+++ b/clownfish/runtime/core/Clownfish/String.cfh
@@ -25,6 +25,7 @@ class Clownfish::String cnick Str
 
     const char *ptr;
     size_t      size;
+    String     *origin;
 
     /** Return a new String which holds a copy of the passed-in string.
      * Check for UTF-8 validity.
@@ -48,19 +49,39 @@ class Clownfish::String cnick Str
      * passed-in string.  Check validity of supplied UTF-8.
      */
     inert incremented String*
-    new_steal_str(const char *ptr, size_t size);
+    new_steal_utf8(const char *utf8, size_t size);
 
     /** Return a pointer to a new String which assumes ownership of the
      * passed-in string.  Do not check validity of supplied UTF-8.
      */
     inert incremented String*
-    new_steal_from_trusted_str(const char *ptr, size_t size);
+    new_steal_trusted_utf8(const char *utf8, size_t size);
 
     /** Initialize the String using the passed-in string.  Do not check
      * validity of supplied UTF-8.
      */
     public inert String*
-    init_steal_trusted_str(String *self, const char *ptr, size_t size);
+    init_steal_trusted_utf8(String *self, const char *utf8, size_t size);
+
+    /** Return a pointer to a new String which wraps an external buffer
+     * containing UTF-8.  The buffer must stay unchanged for the lifetime
+     * of the String.  Check validity of supplied UTF-8.
+     */
+    inert incremented String*
+    new_wrap_utf8(const char *utf8, size_t size);
+
+    /** Return a pointer to a new String which wraps an external buffer
+     * containing UTF-8.  The buffer must stay unchanged for the lifetime
+     * of the String.  Do not check validity of supplied UTF-8.
+     */
+    inert incremented String*
+    new_wrap_trusted_utf8(const char *utf8, size_t size);
+
+    /** Initialize the String which wraps an external buffer containing
+     * UTF-8.  Do not check validity of supplied UTF-8.
+     */
+    public inert String*
+    init_wrap_trusted_utf8(String *self, const char *utf8, size_t size);
 
     /** Return a String which holds a single character.
      */
@@ -256,29 +277,8 @@ class Clownfish::String cnick Str
     StackTail(String *self, void *allocation);
 }
 
-class Clownfish::ViewCharBuf cnick ViewCB
-    inherits Clownfish::String {
-
-    inert incremented ViewCharBuf*
-    new_from_utf8(const char *utf8, size_t size);
-
-    inert incremented ViewCharBuf*
-    new_from_trusted_utf8(const char *utf8, size_t size);
-
-    inert ViewCharBuf*
-    init(ViewCharBuf *self, const char *utf8, size_t size);
-
-    public void
-    Destroy(ViewCharBuf *self);
-}
-
 class Clownfish::StackString cnick SStr
-    inherits Clownfish::ViewCharBuf {
-
-    /** Return a StackString with a blank string.
-     */
-    inert incremented StackString*
-    new(void *allocation);
+    inherits Clownfish::String {
 
     /**
      * @param allocation A single block of memory which will be used for both
@@ -424,7 +424,8 @@ class Clownfish::StackStringIterator cnick SStrIter
 
 __C__
 
-#define CFISH_SSTR_BLANK() cfish_SStr_new(cfish_alloca(cfish_SStr_size()))
+#define CFISH_SSTR_BLANK() \
+   cfish_SStr_wrap_str(cfish_alloca(cfish_SStr_size()), "", 0)
 
 #define CFISH_SSTR_WRAP(source) \
     cfish_SStr_wrap(cfish_alloca(cfish_SStr_size()), source)

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 2d7ef0e..7743525 100644
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -176,23 +176,6 @@ to_perl(self)
 CODE:
     RETVAL = XSBind_str_to_sv(self);
 OUTPUT: RETVAL
-
-MODULE = Clownfish     PACKAGE = Clownfish::ViewCharBuf
-
-SV*
-_new(unused, sv)
-    SV *unused;
-    SV *sv;
-CODE:
-{
-    STRLEN size;
-    char *ptr = SvPVutf8(sv, size);
-    cfish_ViewCharBuf *self
-        = cfish_ViewCB_new_from_trusted_utf8(ptr, size);
-    CFISH_UNUSED_VAR(unused);
-    RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
-}
-OUTPUT: RETVAL
 END_XS_CODE
 
     my $binding = Clownfish::CFC::Binding::Perl::Class->new(

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/perl/lib/Clownfish.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/lib/Clownfish.pm b/clownfish/runtime/perl/lib/Clownfish.pm
index 7a4f961..d683245 100644
--- a/clownfish/runtime/perl/lib/Clownfish.pm
+++ b/clownfish/runtime/perl/lib/Clownfish.pm
@@ -162,14 +162,6 @@ sub error {$Clownfish::Err::error}
 }
 
 {
-    package Clownfish::ViewCharBuf;
-    our $VERSION = '0.003000';
-    $VERSION = eval $VERSION;
-    use Carp;
-    sub new { confess "ViewCharBuf has no public constructor." }
-}
-
-{
     package Clownfish::StackString;
     our $VERSION = '0.003000';
     $VERSION = eval $VERSION;

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/clownfish/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/xs/XSBind.c b/clownfish/runtime/perl/xs/XSBind.c
index ea7700d..755667a 100644
--- a/clownfish/runtime/perl/xs/XSBind.c
+++ b/clownfish/runtime/perl/xs/XSBind.c
@@ -96,7 +96,6 @@ XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation)
{
         }
         else if (allocation &&
                  (vtable == CFISH_STACKSTRING
-                  || vtable == CFISH_VIEWCHARBUF
                   || vtable == CFISH_STRING
                   || vtable == CFISH_OBJ)
                 ) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Analysis/SnowballStopFilter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Analysis/SnowballStopFilter.c b/core/Lucy/Analysis/SnowballStopFilter.c
index 4aa9d16..f4c995e 100644
--- a/core/Lucy/Analysis/SnowballStopFilter.c
+++ b/core/Lucy/Analysis/SnowballStopFilter.c
@@ -144,7 +144,7 @@ SnowStop_gen_stoplist(const String *language) {
     NoCloneHash *stoplist = NoCloneHash_new(num_stopwords);
     for (uint32_t i = 0; words[i] != NULL; i++) {
         char *word = (char*)words[i];
-        ViewCharBuf *stop = ViewCB_new_from_trusted_utf8(word, strlen(word));
+        String *stop = Str_new_wrap_trusted_utf8(word, strlen(word));
         NoCloneHash_Store(stoplist, (Obj*)stop, (Obj*)Str_newf(""));
         DECREF(stop);
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Index/SortCache/TextSortCache.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortCache/TextSortCache.c b/core/Lucy/Index/SortCache/TextSortCache.c
index afd5b50..ad533a4 100644
--- a/core/Lucy/Index/SortCache/TextSortCache.c
+++ b/core/Lucy/Index/SortCache/TextSortCache.c
@@ -115,7 +115,7 @@ TextSortCache_Value_IMP(TextSortCache *self, int32_t ord) {
         InStream_Seek(ivars->dat_in, offset);
         InStream_Read_Bytes(ivars->dat_in, ptr, len);
         ptr[len] = '\0';
-        return (Obj*)Str_new_steal_str(ptr, len);
+        return (Obj*)Str_new_steal_utf8(ptr, len);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Util/Freezer.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c
index 5452728..ea22431 100644
--- a/core/Lucy/Util/Freezer.c
+++ b/core/Lucy/Util/Freezer.c
@@ -222,7 +222,7 @@ Freezer_deserialize_string(String *string, InStream *instream) {
     if (!StrHelp_utf8_valid(buf, size)) {
         THROW(ERR, "Attempt to deserialize invalid UTF-8");
     }
-    return Str_init_steal_trusted_str(string, buf, size);
+    return Str_init_steal_trusted_utf8(string, buf, size);
 }
 
 String*
@@ -338,7 +338,7 @@ Freezer_deserialize_hash(Hash *hash, InStream *instream) {
         char *key_buf = (char*)MALLOCATE(len + 1);
         InStream_Read_Bytes(instream, key_buf, len);
         key_buf[len] = '\0';
-        String *key = Str_new_steal_from_trusted_str(key_buf, len);
+        String *key = Str_new_steal_utf8(key_buf, len);
         Hash_Store(hash, (Obj*)key, THAW(instream));
         DECREF(key);
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/core/Lucy/Util/Json.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c
index 5fedf1e..c877b74 100644
--- a/core/Lucy/Util/Json.c
+++ b/core/Lucy/Util/Json.c
@@ -654,7 +654,7 @@ S_unescape_text(const char *top, const char *end) {
         Err_set_error(Err_new(mess));
         return NULL;
     }
-    return Str_new_steal_from_trusted_str(target_buf, target_size);
+    return Str_new_steal_trusted_utf8(target_buf, target_size);
 }
 
 static CFISH_INLINE bool

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/example-lang/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/example-lang/src/Lucy/Document/Doc.c b/example-lang/src/Lucy/Document/Doc.c
index db1d8f7..1ec532d 100644
--- a/example-lang/src/Lucy/Document/Doc.c
+++ b/example-lang/src/Lucy/Document/Doc.c
@@ -55,8 +55,7 @@ lucy_Doc_deserialize(lucy_Doc *self, lucy_InStream *instream) {
 }
 
 lucy_Obj*
-lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field,
-                 lucy_ViewCharBuf *target) {
+lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field) {
     THROW(LUCY_ERR, "TODO");
     UNREACHABLE_RETURN(lucy_Obj*);
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/perl/xs/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Document/Doc.c b/perl/xs/Lucy/Document/Doc.c
index f31eca3..f74ed22 100644
--- a/perl/xs/Lucy/Document/Doc.c
+++ b/perl/xs/Lucy/Document/Doc.c
@@ -158,7 +158,7 @@ LUCY_Doc_Extract_IMP(lucy_Doc *self, cfish_String *field) {
         else {
             STRLEN size;
             char *ptr = SvPVutf8(sv, size);
-            retval = (cfish_Obj*)cfish_ViewCB_new_from_trusted_utf8(ptr, size);
+            retval = (cfish_Obj*)cfish_Str_new_wrap_trusted_utf8(ptr, size);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/perl/xs/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/perl/xs/Lucy/Index/Inverter.c b/perl/xs/Lucy/Index/Inverter.c
index 1d120b1..23eb9ab 100644
--- a/perl/xs/Lucy/Index/Inverter.c
+++ b/perl/xs/Lucy/Index/Inverter.c
@@ -101,7 +101,7 @@ LUCY_Inverter_Invert_Doc_IMP(lucy_Inverter *self, lucy_Doc *doc) {
                     char *val_ptr = SvPVutf8(value_sv, val_len);
                     CFISH_DECREF(entry_ivars->value);
                     entry_ivars->value
-                        = (cfish_Obj*)cfish_ViewCB_new_from_trusted_utf8(
+                        = (cfish_Obj*)cfish_Str_new_wrap_trusted_utf8(
                                 val_ptr, val_len);
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/0008a998/ruby/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/ruby/src/Lucy/Document/Doc.c b/ruby/src/Lucy/Document/Doc.c
index db1d8f7..1ec532d 100644
--- a/ruby/src/Lucy/Document/Doc.c
+++ b/ruby/src/Lucy/Document/Doc.c
@@ -55,8 +55,7 @@ lucy_Doc_deserialize(lucy_Doc *self, lucy_InStream *instream) {
 }
 
 lucy_Obj*
-lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field,
-                 lucy_ViewCharBuf *target) {
+lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field) {
     THROW(LUCY_ERR, "TODO");
     UNREACHABLE_RETURN(lucy_Obj*);
 }


Mime
View raw message