You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2012/09/27 00:19:54 UTC
[lucy-commits] svn commit: r1390757 - in /lucy/trunk/clownfish/runtime: core/Clownfish/
perl/buildlib/Clownfish/Build/
Author: marvin
Date: Wed Sep 26 22:19:53 2012
New Revision: 1390757
URL: http://svn.apache.org/viewvc?rev=1390757&view=rev
Log:
Remove serialization capabilities.
Modified:
lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.c
lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.cfh
lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.c
lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.cfh
lucy/trunk/clownfish/runtime/core/Clownfish/Hash.c
lucy/trunk/clownfish/runtime/core/Clownfish/Hash.cfh
lucy/trunk/clownfish/runtime/core/Clownfish/Num.c
lucy/trunk/clownfish/runtime/core/Clownfish/Num.cfh
lucy/trunk/clownfish/runtime/core/Clownfish/Obj.c
lucy/trunk/clownfish/runtime/core/Clownfish/Obj.cfh
lucy/trunk/clownfish/runtime/core/Clownfish/VArray.c
lucy/trunk/clownfish/runtime/core/Clownfish/VArray.cfh
lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.c?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.c Wed Sep 26 22:19:53 2012
@@ -27,8 +27,6 @@
#include "Clownfish/VTable.h"
#include "Clownfish/ByteBuf.h"
#include "Clownfish/Err.h"
-#include "Lucy/Store/InStream.h"
-#include "Lucy/Store/OutStream.h"
#include "Clownfish/Util/Memory.h"
static void
@@ -192,22 +190,6 @@ BB_grow(ByteBuf *self, size_t size) {
return self->buf;
}
-void
-BB_serialize(ByteBuf *self, OutStream *target) {
- OutStream_Write_C32(target, self->size);
- OutStream_Write_Bytes(target, self->buf, self->size);
-}
-
-ByteBuf*
-BB_deserialize(ByteBuf *self, InStream *instream) {
- const size_t size = InStream_Read_C32(instream);
- const size_t capacity = size ? size : sizeof(int64_t);
- if (capacity > self->cap) { S_grow(self, capacity); }
- self->size = size;
- InStream_Read_Bytes(instream, self->buf, size);
- return self;
-}
-
int
BB_compare(const void *va, const void *vb) {
const ByteBuf *a = *(const ByteBuf**)va;
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.cfh?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/ByteBuf.cfh Wed Sep 26 22:19:53 2012
@@ -119,12 +119,6 @@ class Clownfish::ByteBuf cnick BB inheri
public int32_t
Hash_Sum(ByteBuf *self);
-
- public void
- Serialize(ByteBuf *self, OutStream *outstream);
-
- public incremented ByteBuf*
- Deserialize(decremented ByteBuf *self, InStream *instream);
}
/**
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.c?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.c Wed Sep 26 22:19:53 2012
@@ -29,8 +29,6 @@
#include "Clownfish/CharBuf.h"
#include "Clownfish/Err.h"
-#include "Lucy/Store/InStream.h"
-#include "Lucy/Store/OutStream.h"
#include "Clownfish/Util/Memory.h"
#include "Clownfish/Util/StringHelper.h"
@@ -450,25 +448,6 @@ CB_load(CharBuf *self, Obj *dump) {
}
void
-CB_serialize(CharBuf *self, OutStream *target) {
- OutStream_Write_C32(target, self->size);
- OutStream_Write_Bytes(target, self->ptr, self->size);
-}
-
-CharBuf*
-CB_deserialize(CharBuf *self, InStream *instream) {
- size_t size = InStream_Read_C32(instream);
- if (size >= self->cap) { S_grow(self, size); }
- InStream_Read_Bytes(instream, self->ptr, size);
- self->size = size;
- self->ptr[size] = '\0';
- if (!StrHelp_utf8_valid(self->ptr, size)) {
- DIE_INVALID_UTF8(self->ptr, size);
- }
- return self;
-}
-
-void
CB_mimic_str(CharBuf *self, const char* ptr, size_t size) {
if (!StrHelp_utf8_valid(ptr, size)) {
DIE_INVALID_UTF8(ptr, size);
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.cfh?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/CharBuf.cfh Wed Sep 26 22:19:53 2012
@@ -235,12 +235,6 @@ class Clownfish::CharBuf cnick CB
public incremented CharBuf*
Load(CharBuf *self, Obj *dump);
- public void
- Serialize(CharBuf *self, OutStream *outstream);
-
- public incremented CharBuf*
- Deserialize(decremented CharBuf *self, InStream *instream);
-
/** Remove Unicode whitespace characters from both top and tail.
*/
uint32_t
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Hash.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Hash.c?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Hash.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Hash.c Wed Sep 26 22:19:53 2012
@@ -28,9 +28,6 @@
#include "Clownfish/CharBuf.h"
#include "Clownfish/Err.h"
#include "Clownfish/VArray.h"
-#include "Lucy/Store/InStream.h"
-#include "Lucy/Store/OutStream.h"
-#include "Lucy/Util/Freezer.h"
#include "Clownfish/Util/Memory.h"
static HashTombStone *TOMBSTONE;
@@ -169,69 +166,6 @@ Hash_load(Hash *self, Obj *dump) {
}
void
-Hash_serialize(Hash *self, OutStream *outstream) {
- Obj *key;
- Obj *val;
- uint32_t charbuf_count = 0;
- OutStream_Write_C32(outstream, self->size);
-
- // Write CharBuf keys first. CharBuf keys are the common case; grouping
- // them together is a form of run-length-encoding and saves space, since
- // we omit the per-key class name.
- Hash_Iterate(self);
- while (Hash_Next(self, &key, &val)) {
- if (Obj_Is_A(key, CHARBUF)) { charbuf_count++; }
- }
- OutStream_Write_C32(outstream, charbuf_count);
- Hash_Iterate(self);
- while (Hash_Next(self, &key, &val)) {
- if (Obj_Is_A(key, CHARBUF)) {
- Obj_Serialize(key, outstream);
- FREEZE(val, outstream);
- }
- }
-
- // Punt on the classes of the remaining keys.
- Hash_Iterate(self);
- while (Hash_Next(self, &key, &val)) {
- if (!Obj_Is_A(key, CHARBUF)) {
- FREEZE(key, outstream);
- FREEZE(val, outstream);
- }
- }
-}
-
-Hash*
-Hash_deserialize(Hash *self, InStream *instream) {
- uint32_t size = InStream_Read_C32(instream);
- uint32_t num_charbufs = InStream_Read_C32(instream);
- uint32_t num_other = size - num_charbufs;
- CharBuf *key = num_charbufs ? CB_new(0) : NULL;
-
- Hash_init(self, size);
-
- // Read key-value pairs with CharBuf keys.
- while (num_charbufs--) {
- uint32_t len = InStream_Read_C32(instream);
- char *key_buf = CB_Grow(key, len);
- InStream_Read_Bytes(instream, key_buf, len);
- key_buf[len] = '\0';
- CB_Set_Size(key, len);
- Hash_Store(self, (Obj*)key, THAW(instream));
- }
- DECREF(key);
-
- // Read remaining key/value pairs.
- while (num_other--) {
- Obj *k = THAW(instream);
- Hash_Store(self, k, THAW(instream));
- DECREF(k);
- }
-
- return self;
-}
-
-void
Hash_clear(Hash *self) {
HashEntry *entry = (HashEntry*)self->entries;
HashEntry *const limit = entry + self->capacity;
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Hash.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Hash.cfh?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Hash.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Hash.cfh Wed Sep 26 22:19:53 2012
@@ -140,12 +140,6 @@ class Clownfish::Hash inherits Clownfish
Load(Hash *self, Obj *dump);
public void
- Serialize(Hash *self, OutStream *outstream);
-
- public incremented Hash*
- Deserialize(decremented Hash *self, InStream *instream);
-
- public void
Destroy(Hash *self);
}
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Num.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Num.c?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Num.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Num.c Wed Sep 26 22:19:53 2012
@@ -30,8 +30,6 @@
#include "Clownfish/CharBuf.h"
#include "Clownfish/Err.h"
#include "Clownfish/VTable.h"
-#include "Lucy/Store/InStream.h"
-#include "Lucy/Store/OutStream.h"
Num*
Num_init(Num *self) {
@@ -146,17 +144,6 @@ Float32_mimic(Float32 *self, Obj *other)
self->value = twin->value;
}
-void
-Float32_serialize(Float32 *self, OutStream *outstream) {
- OutStream_Write_F32(outstream, self->value);
-}
-
-Float32*
-Float32_deserialize(Float32 *self, InStream *instream) {
- float value = InStream_Read_F32(instream);
- return Float32_init(self, value);
-}
-
/***************************************************************************/
Float64*
@@ -208,17 +195,6 @@ Float64_hash_sum(Float64 *self) {
return ints[0] ^ ints[1];
}
-void
-Float64_serialize(Float64 *self, OutStream *outstream) {
- OutStream_Write_F64(outstream, self->value);
-}
-
-Float64*
-Float64_deserialize(Float64 *self, InStream *instream) {
- double value = InStream_Read_F64(instream);
- return Float64_init(self, value);
-}
-
/***************************************************************************/
Integer32*
@@ -269,17 +245,6 @@ Int32_hash_sum(Integer32 *self) {
return self->value;
}
-void
-Int32_serialize(Integer32 *self, OutStream *outstream) {
- OutStream_Write_C32(outstream, (uint32_t)self->value);
-}
-
-Integer32*
-Int32_deserialize(Integer32 *self, InStream *instream) {
- int32_t value = (int32_t)InStream_Read_C32(instream);
- return Int32_init(self, value);
-}
-
/***************************************************************************/
Integer64*
@@ -348,17 +313,6 @@ Int64_equals(Integer64 *self, Obj *other
return true;
}
-void
-Int64_serialize(Integer64 *self, OutStream *outstream) {
- OutStream_Write_C64(outstream, (uint64_t)self->value);
-}
-
-Integer64*
-Int64_deserialize(Integer64 *self, InStream *instream) {
- int64_t value = (int64_t)InStream_Read_C64(instream);
- return Int64_init(self, value);
-}
-
/***************************************************************************/
@@ -428,22 +382,6 @@ Bool_equals(BoolNum *self, Obj *other) {
return self == (BoolNum*)other;
}
-void
-Bool_serialize(BoolNum *self, OutStream *outstream) {
- OutStream_Write_U8(outstream, (uint8_t)self->value);
-}
-
-BoolNum*
-Bool_deserialize(BoolNum *self, InStream *instream) {
- bool_t value = (bool_t)InStream_Read_U8(instream);
- if (self && self != CFISH_TRUE && self != CFISH_FALSE) {
- Bool_Dec_RefCount_t super_decref
- = SUPER_METHOD_PTR(BOOLNUM, Lucy_Bool_Dec_RefCount);
- super_decref(self);
- }
- return value ? CFISH_TRUE : CFISH_FALSE;
-}
-
BoolNum*
Bool_inc_refcount(BoolNum *self) {
return self;
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Num.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Num.cfh?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Num.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Num.cfh Wed Sep 26 22:19:53 2012
@@ -86,12 +86,6 @@ class Clownfish::Float32 inherits Clownf
public int32_t
Hash_Sum(Float32 *self);
- public void
- Serialize(Float32 *self, OutStream *outstream);
-
- public incremented Float32*
- Deserialize(decremented Float32 *self, InStream *instream);
-
public incremented Float32*
Clone(Float32 *self);
@@ -129,12 +123,6 @@ class Clownfish::Float64 inherits Clownf
public int32_t
Hash_Sum(Float64 *self);
- public void
- Serialize(Float64 *self, OutStream *outstream);
-
- public incremented Float64*
- Deserialize(decremented Float64 *self, InStream *instream);
-
public incremented Float64*
Clone(Float64 *self);
@@ -173,12 +161,6 @@ class Clownfish::Integer32 cnick Int32
public int32_t
Hash_Sum(Integer32 *self);
- public void
- Serialize(Integer32 *self, OutStream *outstream);
-
- public incremented Integer32*
- Deserialize(decremented Integer32 *self, InStream *instream);
-
public incremented Integer32*
Clone(Integer32 *self);
@@ -221,12 +203,6 @@ class Clownfish::Integer64 cnick Int64
public bool_t
Equals(Integer64 *self, Obj *other);
- public void
- Serialize(Integer64 *self, OutStream *outstream);
-
- public incremented Integer64*
- Deserialize(decremented Integer64 *self, InStream *instream);
-
public incremented Integer64*
Clone(Integer64 *self);
@@ -275,12 +251,6 @@ class Clownfish::BoolNum cnick Bool inhe
public int32_t
Hash_Sum(BoolNum *self);
- public void
- Serialize(BoolNum *self, OutStream *outstream);
-
- public incremented BoolNum*
- Deserialize(decremented BoolNum *self, InStream *instream);
-
/* Returns self. */
public incremented BoolNum*
Clone(BoolNum *self);
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Obj.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Obj.c?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Obj.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Obj.c Wed Sep 26 22:19:53 2012
@@ -28,8 +28,6 @@
#include "Clownfish/Err.h"
#include "Clownfish/Hash.h"
#include "Clownfish/VTable.h"
-#include "Lucy/Store/InStream.h"
-#include "Lucy/Store/OutStream.h"
#include "Clownfish/Util/Memory.h"
Obj*
@@ -68,24 +66,6 @@ Obj_equals(Obj *self, Obj *other) {
return (self == other);
}
-void
-Obj_serialize(Obj *self, OutStream *outstream) {
- CharBuf *class_name = Obj_Get_Class_Name(self);
- CB_Serialize(class_name, outstream);
-}
-
-Obj*
-Obj_deserialize(Obj *self, InStream *instream) {
- CharBuf *class_name
- = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
- CharBuf *my_class = VTable_Get_Name(self->vtable);
- if (!CB_Equals(class_name, (Obj*)my_class)) {
- THROW(ERR, "Class mismatch: %o %o", class_name, my_class);
- }
- DECREF(class_name);
- return Obj_init(self);
-}
-
CharBuf*
Obj_to_string(Obj *self) {
#if (SIZEOF_PTR == 4)
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/Obj.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/Obj.cfh?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/Obj.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/Obj.cfh Wed Sep 26 22:19:53 2012
@@ -153,18 +153,6 @@ public class Clownfish::Obj {
public bool_t
To_Bool(Obj *self);
- /** Serialize the object by writing to the supplied OutStream.
- */
- public void
- Serialize(Obj *self, OutStream *outstream);
-
- /** Inflate an object by reading the serialized form from the instream.
- * The assumption is that the object has been allocated, assigned a
- * refcount and a vtable, but that everything else is uninitialized.
- */
- public incremented Obj*
- Deserialize(decremented Obj *self, InStream *instream);
-
/** Return a representation of the object using only scalars, hashes, and
* arrays. Some implementations support JSON serialization via Dump() and
* its companion method, Load(); for others, Dump() is only a debugging
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/VArray.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/VArray.c?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/VArray.c (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/VArray.c Wed Sep 26 22:19:53 2012
@@ -25,10 +25,7 @@
#include "Clownfish/VArray.h"
#include "Clownfish/Err.h"
#include "Clownfish/Util/Memory.h"
-#include "Lucy/Util/Freezer.h"
#include "Clownfish/Util/SortUtils.h"
-#include "Lucy/Store/InStream.h"
-#include "Lucy/Store/OutStream.h"
VArray*
VA_new(uint32_t capacity) {
@@ -90,37 +87,6 @@ VA_load(VArray *self, Obj *dump) {
return loaded;
}
-void
-VA_serialize(VArray *self, OutStream *outstream) {
- uint32_t last_valid_tick = 0;
- OutStream_Write_C32(outstream, self->size);
- for (uint32_t i = 0; i < self->size; i++) {
- Obj *elem = self->elems[i];
- if (elem) {
- OutStream_Write_C32(outstream, i - last_valid_tick);
- FREEZE(elem, outstream);
- last_valid_tick = i;
- }
- }
- // Terminate.
- OutStream_Write_C32(outstream, self->size - last_valid_tick);
-}
-
-VArray*
-VA_deserialize(VArray *self, InStream *instream) {
- uint32_t size = InStream_Read_C32(instream);
- VA_Grow(self, size);
- for (uint32_t tick = InStream_Read_C32(instream);
- tick < size;
- tick += InStream_Read_C32(instream)
- ) {
- Obj *obj = THAW(instream);
- self->elems[tick] = obj;
- }
- self->size = size;
- return self;
-}
-
VArray*
VA_clone(VArray *self) {
VArray *twin = VA_new(self->size);
Modified: lucy/trunk/clownfish/runtime/core/Clownfish/VArray.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/core/Clownfish/VArray.cfh?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/core/Clownfish/VArray.cfh (original)
+++ lucy/trunk/clownfish/runtime/core/Clownfish/VArray.cfh Wed Sep 26 22:19:53 2012
@@ -169,12 +169,6 @@ class Clownfish::VArray cnick VA inherit
Load(VArray *self, Obj *dump);
public void
- Serialize(VArray *self, OutStream *outstream);
-
- public incremented VArray*
- Deserialize(decremented VArray *self, InStream *instream);
-
- public void
Destroy(VArray *self);
}
Modified: lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm?rev=1390757&r1=1390756&r2=1390757&view=diff
==============================================================================
--- lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm (original)
+++ lucy/trunk/clownfish/runtime/perl/buildlib/Clownfish/Build/Binding.pm Wed Sep 26 22:19:53 2012
@@ -52,15 +52,6 @@ CODE:
RETVAL = CFISH_OBJ_TO_SV_NOINC(self);
}
OUTPUT: RETVAL
-
-SV*
-_deserialize(self, instream)
- lucy_ByteBuf *self;
- lucy_InStream *instream;
-CODE:
- lucy_ByteBuf *thawed = Lucy_BB_Deserialize(self, instream);
- RETVAL = (SV*)Lucy_BB_To_Host(thawed);
-OUTPUT: RETVAL
END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
@@ -100,15 +91,6 @@ CODE:
OUTPUT: RETVAL
SV*
-_deserialize(self, instream)
- lucy_CharBuf *self;
- lucy_InStream *instream;
-CODE:
- lucy_CharBuf *thawed = Lucy_CB_Deserialize(self, instream);
- RETVAL = (SV*)Lucy_CB_To_Host(thawed);
-OUTPUT: RETVAL
-
-SV*
to_perl(self)
lucy_CharBuf *self;
CODE:
@@ -200,16 +182,6 @@ sub bind_hash {
my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Clownfish::Hash
-
-SV*
-_deserialize(self, instream)
- lucy_Hash *self;
- lucy_InStream *instream;
-CODE:
- lucy_Hash *thawed = Lucy_Hash_Deserialize(self, instream);
- RETVAL = (SV*)Lucy_Hash_To_Host(thawed);
-OUTPUT: RETVAL
-
SV*
_fetch(self, key)
lucy_Hash *self;
@@ -523,79 +495,6 @@ CODE:
RETVAL = Lucy_Obj_Is_A(self, target);
}
OUTPUT: RETVAL
-
-void
-STORABLE_freeze(self, ...)
- lucy_Obj *self;
-PPCODE:
-{
- CHY_UNUSED_VAR(self);
- if (items < 2 || !SvTRUE(ST(1))) {
- SV *retval;
- lucy_ByteBuf *serialized_bb;
- lucy_RAMFileHandle *file_handle
- = lucy_RAMFH_open(NULL, LUCY_FH_WRITE_ONLY | LUCY_FH_CREATE, NULL);
- lucy_OutStream *target = lucy_OutStream_open((lucy_Obj*)file_handle);
-
- Lucy_Obj_Serialize(self, target);
-
- Lucy_OutStream_Close(target);
- serialized_bb
- = Lucy_RAMFile_Get_Contents(Lucy_RAMFH_Get_File(file_handle));
- retval = XSBind_bb_to_sv(serialized_bb);
- CFISH_DECREF(file_handle);
- CFISH_DECREF(target);
-
- if (SvCUR(retval) == 0) { // Thwart Storable bug
- THROW(LUCY_ERR, "Calling serialize produced an empty string");
- }
- ST(0) = sv_2mortal(retval);
- XSRETURN(1);
- }
-}
-
-=begin comment
-
-Calls deserialize(), and copies the object pointer. Since deserialize is an
-abstract method, it will confess() unless implemented.
-
-=end comment
-
-=cut
-
-void
-STORABLE_thaw(blank_obj, cloning, serialized_sv)
- SV *blank_obj;
- SV *cloning;
- SV *serialized_sv;
-PPCODE:
-{
- char *class_name = HvNAME(SvSTASH(SvRV(blank_obj)));
- lucy_ZombieCharBuf *klass
- = CFISH_ZCB_WRAP_STR(class_name, strlen(class_name));
- lucy_VTable *vtable
- = (lucy_VTable*)lucy_VTable_singleton((lucy_CharBuf*)klass, NULL);
- STRLEN len;
- char *ptr = SvPV(serialized_sv, len);
- lucy_ViewByteBuf *contents = lucy_ViewBB_new(ptr, len);
- lucy_RAMFile *ram_file = lucy_RAMFile_new((lucy_ByteBuf*)contents, true);
- lucy_RAMFileHandle *file_handle
- = lucy_RAMFH_open(NULL, LUCY_FH_READ_ONLY, ram_file);
- lucy_InStream *instream = lucy_InStream_open((lucy_Obj*)file_handle);
- lucy_Obj *self = Lucy_VTable_Foster_Obj(vtable, blank_obj);
- lucy_Obj *deserialized = Lucy_Obj_Deserialize(self, instream);
-
- CHY_UNUSED_VAR(cloning);
- CFISH_DECREF(contents);
- CFISH_DECREF(ram_file);
- CFISH_DECREF(file_handle);
- CFISH_DECREF(instream);
-
- // Catch bad deserialize() override.
- if (deserialized != self) {
- THROW(LUCY_ERR, "Error when deserializing obj of class %o", klass);
- }
-}
END_XS_CODE
my $binding = Clownfish::CFC::Binding::Perl::Class->new(
@@ -631,15 +530,6 @@ CODE:
OUTPUT: RETVAL
SV*
-_deserialize(self, instream)
- lucy_VArray *self;
- lucy_InStream *instream;
-CODE:
- lucy_VArray *thawed = Lucy_VA_Deserialize(self, instream);
- RETVAL = (SV*)Lucy_VA_To_Host(thawed);
-OUTPUT: RETVAL
-
-SV*
_clone(self)
lucy_VArray *self;
CODE: