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/01/16 00:04:51 UTC
[lucy-commits] svn commit: r1231790 - in /incubator/lucy/trunk: core/Lucy/Document/
core/Lucy/Index/ core/Lucy/Object/ core/Lucy/Search/ core/Lucy/Util/
core/LucyX/Search/ perl/lib/ perl/lib/Lucy/Object/ perl/t/ perl/t/binding/
perl/xs/Lucy/Document/
Author: marvin
Date: Sun Jan 15 23:04:48 2012
New Revision: 1231790
URL: http://svn.apache.org/viewvc?rev=1231790&view=rev
Log:
Don't support NULL as first arg to Deserialize().
For reasons not worth explaining now, the API for Deserialize() has stipulated
that it must be callable with either a blank object or NULL. This patch
forces Deserialize() to be called only on a blank object.
Modified:
incubator/lucy/trunk/core/Lucy/Document/Doc.cfh
incubator/lucy/trunk/core/Lucy/Document/HitDoc.c
incubator/lucy/trunk/core/Lucy/Document/HitDoc.cfh
incubator/lucy/trunk/core/Lucy/Index/DocVector.c
incubator/lucy/trunk/core/Lucy/Index/DocVector.cfh
incubator/lucy/trunk/core/Lucy/Index/HighlightReader.c
incubator/lucy/trunk/core/Lucy/Index/Similarity.c
incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh
incubator/lucy/trunk/core/Lucy/Index/TermVector.c
incubator/lucy/trunk/core/Lucy/Index/TermVector.cfh
incubator/lucy/trunk/core/Lucy/Object/ByteBuf.c
incubator/lucy/trunk/core/Lucy/Object/ByteBuf.cfh
incubator/lucy/trunk/core/Lucy/Object/CharBuf.c
incubator/lucy/trunk/core/Lucy/Object/CharBuf.cfh
incubator/lucy/trunk/core/Lucy/Object/Hash.c
incubator/lucy/trunk/core/Lucy/Object/Hash.cfh
incubator/lucy/trunk/core/Lucy/Object/Num.c
incubator/lucy/trunk/core/Lucy/Object/Num.cfh
incubator/lucy/trunk/core/Lucy/Object/Obj.c
incubator/lucy/trunk/core/Lucy/Object/Obj.cfh
incubator/lucy/trunk/core/Lucy/Object/VArray.c
incubator/lucy/trunk/core/Lucy/Object/VArray.cfh
incubator/lucy/trunk/core/Lucy/Object/VTable.c
incubator/lucy/trunk/core/Lucy/Object/VTable.cfh
incubator/lucy/trunk/core/Lucy/Search/Compiler.c
incubator/lucy/trunk/core/Lucy/Search/Compiler.cfh
incubator/lucy/trunk/core/Lucy/Search/LeafQuery.c
incubator/lucy/trunk/core/Lucy/Search/LeafQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.c
incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/MatchDoc.c
incubator/lucy/trunk/core/Lucy/Search/MatchDoc.cfh
incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.c
incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c
incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c
incubator/lucy/trunk/core/Lucy/Search/PolyQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/Query.c
incubator/lucy/trunk/core/Lucy/Search/Query.cfh
incubator/lucy/trunk/core/Lucy/Search/RangeQuery.c
incubator/lucy/trunk/core/Lucy/Search/RangeQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/SortRule.c
incubator/lucy/trunk/core/Lucy/Search/SortRule.cfh
incubator/lucy/trunk/core/Lucy/Search/SortSpec.c
incubator/lucy/trunk/core/Lucy/Search/SortSpec.cfh
incubator/lucy/trunk/core/Lucy/Search/TermQuery.c
incubator/lucy/trunk/core/Lucy/Search/TermQuery.cfh
incubator/lucy/trunk/core/Lucy/Search/TopDocs.c
incubator/lucy/trunk/core/Lucy/Search/TopDocs.cfh
incubator/lucy/trunk/core/Lucy/Util/Freezer.c
incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.c
incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.cfh
incubator/lucy/trunk/perl/lib/Lucy.pm
incubator/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm
incubator/lucy/trunk/perl/lib/Lucy/Object/CharBuf.pm
incubator/lucy/trunk/perl/lib/Lucy/Object/Hash.pm
incubator/lucy/trunk/perl/lib/Lucy/Object/VArray.pm
incubator/lucy/trunk/perl/lib/Lucy/Object/VTable.pm
incubator/lucy/trunk/perl/t/026-serialization.t
incubator/lucy/trunk/perl/t/binding/016-varray.t
incubator/lucy/trunk/perl/t/binding/017-hash.t
incubator/lucy/trunk/perl/t/binding/029-charbuf.t
incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c
Modified: incubator/lucy/trunk/core/Lucy/Document/Doc.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Document/Doc.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Document/Doc.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Document/Doc.cfh Sun Jan 15 23:04:48 2012
@@ -86,7 +86,7 @@ public class Lucy::Document::Doc inherit
Serialize(Doc *self, OutStream *outstream);
public incremented Doc*
- Deserialize(Doc *self, InStream *instream);
+ Deserialize(decremented Doc *self, InStream *instream);
public incremented Hash*
Dump(Doc *self);
Modified: incubator/lucy/trunk/core/Lucy/Document/HitDoc.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Document/HitDoc.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Document/HitDoc.c (original)
+++ incubator/lucy/trunk/core/Lucy/Document/HitDoc.c Sun Jan 15 23:04:48 2012
@@ -46,14 +46,17 @@ HitDoc_get_score(HitDoc *self) {
void
HitDoc_serialize(HitDoc *self, OutStream *outstream) {
- Doc_serialize((Doc*)self, outstream);
+ HitDoc_serialize_t super_serialize
+ = (HitDoc_serialize_t)SUPER_METHOD(HITDOC, HitDoc, Serialize);
+ super_serialize(self, outstream);
OutStream_Write_F32(outstream, self->score);
}
HitDoc*
HitDoc_deserialize(HitDoc *self, InStream *instream) {
- self = self ? self : (HitDoc*)VTable_Make_Obj(HITDOC);
- Doc_deserialize((Doc*)self, instream);
+ HitDoc_deserialize_t super_deserialize
+ = (HitDoc_deserialize_t)SUPER_METHOD(HITDOC, HitDoc, Deserialize);
+ self = super_deserialize(self, instream);
self->score = InStream_Read_F32(instream);
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Document/HitDoc.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Document/HitDoc.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Document/HitDoc.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Document/HitDoc.cfh Sun Jan 15 23:04:48 2012
@@ -63,7 +63,7 @@ class Lucy::Document::HitDoc inherits Lu
Serialize(HitDoc *self, OutStream *outstream);
public incremented HitDoc*
- Deserialize(HitDoc *self, InStream *instream);
+ Deserialize(decremented HitDoc *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/DocVector.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/DocVector.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/DocVector.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/DocVector.c Sun Jan 15 23:04:48 2012
@@ -53,9 +53,10 @@ DocVec_serialize(DocVector *self, OutStr
DocVector*
DocVec_deserialize(DocVector *self, InStream *instream) {
- self = self ? self : (DocVector*)VTable_Make_Obj(DOCVECTOR);
- self->field_bufs = Hash_deserialize(NULL, instream);
- self->field_vectors = Hash_deserialize(NULL, instream);
+ self->field_bufs
+ = Hash_Deserialize((Hash*)VTable_Make_Obj(HASH), instream);
+ self->field_vectors
+ = Hash_Deserialize((Hash*)VTable_Make_Obj(HASH), instream);
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/DocVector.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/DocVector.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/DocVector.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/DocVector.cfh Sun Jan 15 23:04:48 2012
@@ -51,7 +51,7 @@ class Lucy::Index::DocVector cnick DocVe
Serialize(DocVector *self, OutStream *outstream);
public incremented DocVector*
- Deserialize(DocVector *self, InStream *instream);
+ Deserialize(decremented DocVector *self, InStream *instream);
public void
Destroy(DocVector *self);
Modified: incubator/lucy/trunk/core/Lucy/Index/HighlightReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/HighlightReader.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/HighlightReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/HighlightReader.c Sun Jan 15 23:04:48 2012
@@ -181,16 +181,20 @@ DefHLReader_destroy(DefaultHighlightRead
DocVector*
DefHLReader_fetch_doc_vec(DefaultHighlightReader *self, int32_t doc_id) {
+ InStream *const ix_in = self->ix_in;
+ InStream *const dat_in = self->dat_in;
DocVector *doc_vec = DocVec_new();
- InStream_Seek(self->ix_in, doc_id * 8);
- int64_t file_pos = InStream_Read_I64(self->ix_in);
- InStream_Seek(self->dat_in, file_pos);
+ InStream_Seek(ix_in, doc_id * 8);
+ int64_t file_pos = InStream_Read_I64(ix_in);
+ InStream_Seek(dat_in, file_pos);
- uint32_t num_fields = InStream_Read_C32(self->dat_in);
+ uint32_t num_fields = InStream_Read_C32(dat_in);
while (num_fields--) {
- CharBuf *field = CB_deserialize(NULL, self->dat_in);
- ByteBuf *field_buf = BB_deserialize(NULL, self->dat_in);
+ CharBuf *field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), dat_in);
+ ByteBuf *field_buf
+ = BB_Deserialize((ByteBuf*)VTable_Make_Obj(BYTEBUF), dat_in);
DocVec_Add_Field_Buf(doc_vec, field, field_buf);
DECREF(field_buf);
DECREF(field);
Modified: incubator/lucy/trunk/core/Lucy/Index/Similarity.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Similarity.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Similarity.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Similarity.c Sun Jan 15 23:04:48 2012
@@ -103,17 +103,13 @@ Sim_serialize(Similarity *self, OutStrea
Similarity*
Sim_deserialize(Similarity *self, InStream *instream) {
- CharBuf *class_name = CB_deserialize(NULL, instream);
- if (!self) {
- VTable *vtable = VTable_singleton(class_name, SIMILARITY);
- self = (Similarity*)VTable_Make_Obj(vtable);
- }
- else if (!CB_Equals(class_name, (Obj*)Sim_Get_Class_Name(self))) {
+ CharBuf *class_name
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
+ if (!CB_Equals(class_name, (Obj*)Sim_Get_Class_Name(self))) {
THROW(ERR, "Class name mismatch: '%o' '%o'", Sim_Get_Class_Name(self),
class_name);
}
DECREF(class_name);
-
Sim_init(self);
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh Sun Jan 15 23:04:48 2012
@@ -137,7 +137,7 @@ class Lucy::Index::Similarity cnick Sim
Serialize(Similarity *self, OutStream *outstream);
public incremented Similarity*
- Deserialize(Similarity *self, InStream *instream);
+ Deserialize(decremented Similarity *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/TermVector.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/TermVector.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/TermVector.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/TermVector.c Sun Jan 15 23:04:48 2012
@@ -94,8 +94,10 @@ TV_serialize(TermVector *self, OutStream
TermVector*
TV_deserialize(TermVector *self, InStream *instream) {
- CharBuf *field = (CharBuf*)CB_deserialize(NULL, instream);
- CharBuf *text = (CharBuf*)CB_deserialize(NULL, instream);
+ CharBuf *field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
+ CharBuf *text
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
uint32_t num_pos = InStream_Read_C32(instream);
// Read positional data.
@@ -111,8 +113,7 @@ TV_deserialize(TermVector *self, InStrea
I32Array *start_offsets = I32Arr_new_steal(starts, num_pos);
I32Array *end_offsets = I32Arr_new_steal(ends, num_pos);
- self = self ? self : (TermVector*)VTable_Make_Obj(TERMVECTOR);
- self = TV_init(self, field, text, positions, start_offsets, end_offsets);
+ TV_init(self, field, text, positions, start_offsets, end_offsets);
DECREF(positions);
DECREF(start_offsets);
Modified: incubator/lucy/trunk/core/Lucy/Index/TermVector.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/TermVector.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/TermVector.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/TermVector.cfh Sun Jan 15 23:04:48 2012
@@ -50,7 +50,7 @@ class Lucy::Index::TermVector cnick TV
Get_End_Offsets(TermVector *self);
public incremented TermVector*
- Deserialize(TermVector *self, InStream *instream);
+ Deserialize(decremented TermVector *self, InStream *instream);
public bool_t
Equals(TermVector *self, Obj *other);
Modified: incubator/lucy/trunk/core/Lucy/Object/ByteBuf.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/ByteBuf.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/ByteBuf.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/ByteBuf.c Sun Jan 15 23:04:48 2012
@@ -202,7 +202,6 @@ ByteBuf*
BB_deserialize(ByteBuf *self, InStream *instream) {
const size_t size = InStream_Read_C32(instream);
const size_t capacity = size ? size : sizeof(int64_t);
- self = self ? self : (ByteBuf*)VTable_Make_Obj(BYTEBUF);
if (capacity > self->cap) { S_grow(self, capacity); }
self->size = size;
InStream_Read_Bytes(instream, self->buf, size);
Modified: incubator/lucy/trunk/core/Lucy/Object/ByteBuf.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/ByteBuf.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/ByteBuf.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/ByteBuf.cfh Sun Jan 15 23:04:48 2012
@@ -124,7 +124,7 @@ class Lucy::Object::ByteBuf cnick BB inh
Serialize(ByteBuf *self, OutStream *outstream);
public incremented ByteBuf*
- Deserialize(ByteBuf *self, InStream *instream);
+ Deserialize(decremented ByteBuf *self, InStream *instream);
}
/**
Modified: incubator/lucy/trunk/core/Lucy/Object/CharBuf.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/CharBuf.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/CharBuf.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/CharBuf.c Sun Jan 15 23:04:48 2012
@@ -461,7 +461,6 @@ CB_serialize(CharBuf *self, OutStream *t
CharBuf*
CB_deserialize(CharBuf *self, InStream *instream) {
size_t size = InStream_Read_C32(instream);
- self = self ? self : (CharBuf*)VTable_Make_Obj(CHARBUF);
if (size >= self->cap) { S_grow(self, size); }
InStream_Read_Bytes(instream, self->ptr, size);
self->size = size;
Modified: incubator/lucy/trunk/core/Lucy/Object/CharBuf.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/CharBuf.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/CharBuf.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/CharBuf.cfh Sun Jan 15 23:04:48 2012
@@ -239,7 +239,7 @@ class Lucy::Object::CharBuf cnick CB
Serialize(CharBuf *self, OutStream *outstream);
public incremented CharBuf*
- Deserialize(CharBuf *self, InStream *instream);
+ Deserialize(decremented CharBuf *self, InStream *instream);
/** Remove Unicode whitespace characters from both top and tail.
*/
Modified: incubator/lucy/trunk/core/Lucy/Object/Hash.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Hash.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Hash.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Hash.c Sun Jan 15 23:04:48 2012
@@ -206,8 +206,7 @@ Hash_deserialize(Hash *self, InStream *i
uint32_t num_other = size - num_charbufs;
CharBuf *key = num_charbufs ? CB_new(0) : NULL;
- if (self) { Hash_init(self, size); }
- else { self = Hash_new(size); }
+ Hash_init(self, size);
// Read key-value pairs with CharBuf keys.
while (num_charbufs--) {
Modified: incubator/lucy/trunk/core/Lucy/Object/Hash.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Hash.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Hash.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Hash.cfh Sun Jan 15 23:04:48 2012
@@ -140,7 +140,7 @@ class Lucy::Object::Hash inherits Lucy::
Serialize(Hash *self, OutStream *outstream);
public incremented Hash*
- Deserialize(Hash *self, InStream *instream);
+ Deserialize(decremented Hash *self, InStream *instream);
public void
Destroy(Hash *self);
Modified: incubator/lucy/trunk/core/Lucy/Object/Num.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Num.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Num.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Num.c Sun Jan 15 23:04:48 2012
@@ -151,7 +151,7 @@ Float32_serialize(Float32 *self, OutStre
Float32*
Float32_deserialize(Float32 *self, InStream *instream) {
float value = InStream_Read_F32(instream);
- return self ? Float32_init(self, value) : Float32_new(value);
+ return Float32_init(self, value);
}
/***************************************************************************/
@@ -213,7 +213,7 @@ Float64_serialize(Float64 *self, OutStre
Float64*
Float64_deserialize(Float64 *self, InStream *instream) {
double value = InStream_Read_F64(instream);
- return self ? Float64_init(self, value) : Float64_new(value);
+ return Float64_init(self, value);
}
/***************************************************************************/
@@ -274,7 +274,7 @@ Int32_serialize(Integer32 *self, OutStre
Integer32*
Int32_deserialize(Integer32 *self, InStream *instream) {
int32_t value = (int32_t)InStream_Read_C32(instream);
- return self ? Int32_init(self, value) : Int32_new(value);
+ return Int32_init(self, value);
}
/***************************************************************************/
@@ -353,7 +353,7 @@ Int64_serialize(Integer64 *self, OutStre
Integer64*
Int64_deserialize(Integer64 *self, InStream *instream) {
int64_t value = (int64_t)InStream_Read_C64(instream);
- return self ? Int64_init(self, value) : Int64_new(value);
+ return Int64_init(self, value);
}
/***************************************************************************/
Modified: incubator/lucy/trunk/core/Lucy/Object/Num.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Num.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Num.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Num.cfh Sun Jan 15 23:04:48 2012
@@ -87,7 +87,7 @@ class Lucy::Object::Float32 inherits Luc
Serialize(Float32 *self, OutStream *outstream);
public incremented Float32*
- Deserialize(Float32 *self, InStream *instream);
+ Deserialize(decremented Float32 *self, InStream *instream);
public incremented Float32*
Clone(Float32 *self);
@@ -130,7 +130,7 @@ class Lucy::Object::Float64 inherits Luc
Serialize(Float64 *self, OutStream *outstream);
public incremented Float64*
- Deserialize(Float64 *self, InStream *instream);
+ Deserialize(decremented Float64 *self, InStream *instream);
public incremented Float64*
Clone(Float64 *self);
@@ -174,7 +174,7 @@ class Lucy::Object::Integer32 cnick Int3
Serialize(Integer32 *self, OutStream *outstream);
public incremented Integer32*
- Deserialize(Integer32 *self, InStream *instream);
+ Deserialize(decremented Integer32 *self, InStream *instream);
public incremented Integer32*
Clone(Integer32 *self);
@@ -222,7 +222,7 @@ class Lucy::Object::Integer64 cnick Int6
Serialize(Integer64 *self, OutStream *outstream);
public incremented Integer64*
- Deserialize(Integer64 *self, InStream *instream);
+ Deserialize(decremented Integer64 *self, InStream *instream);
public incremented Integer64*
Clone(Integer64 *self);
@@ -273,7 +273,7 @@ class Lucy::Object::BoolNum cnick Bool i
Serialize(BoolNum *self, OutStream *outstream);
public incremented BoolNum*
- Deserialize(BoolNum *self, InStream *instream);
+ Deserialize(decremented BoolNum *self, InStream *instream);
/* Returns self. */
public incremented BoolNum*
Modified: incubator/lucy/trunk/core/Lucy/Object/Obj.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Obj.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Obj.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Obj.c Sun Jan 15 23:04:48 2012
@@ -76,16 +76,11 @@ Obj_serialize(Obj *self, OutStream *outs
Obj*
Obj_deserialize(Obj *self, InStream *instream) {
- CharBuf *class_name = CB_deserialize(NULL, instream);
- if (!self) {
- VTable *vtable = VTable_singleton(class_name, OBJ);
- self = VTable_Make_Obj(vtable);
- }
- else {
- 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);
- }
+ 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);
Modified: incubator/lucy/trunk/core/Lucy/Object/Obj.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Obj.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Obj.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Obj.cfh Sun Jan 15 23:04:48 2012
@@ -166,7 +166,7 @@ class Lucy::Object::Obj {
* in which case they should create the object from nothing.
*/
public incremented Obj*
- Deserialize(Obj *self, InStream *instream);
+ 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
Modified: incubator/lucy/trunk/core/Lucy/Object/VArray.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/VArray.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/VArray.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/VArray.c Sun Jan 15 23:04:48 2012
@@ -109,12 +109,7 @@ VA_serialize(VArray *self, OutStream *ou
VArray*
VA_deserialize(VArray *self, InStream *instream) {
uint32_t size = InStream_Read_C32(instream);
- if (self) {
- self->size = size;
- self->cap = size + 1;
- self->elems = (Obj**)CALLOCATE(self->cap, sizeof(Obj*));
- }
- else { self = VA_new(size); }
+ VA_Grow(self, size);
for (uint32_t tick = InStream_Read_C32(instream);
tick < size;
tick += InStream_Read_C32(instream)
Modified: incubator/lucy/trunk/core/Lucy/Object/VArray.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/VArray.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/VArray.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/VArray.cfh Sun Jan 15 23:04:48 2012
@@ -162,7 +162,7 @@ class Lucy::Object::VArray cnick VA inhe
Serialize(VArray *self, OutStream *outstream);
public incremented VArray*
- Deserialize(VArray *self, InStream *instream);
+ Deserialize(decremented VArray *self, InStream *instream);
public void
Destroy(VArray *self);
Modified: incubator/lucy/trunk/core/Lucy/Object/VTable.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/VTable.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/VTable.c (original)
+++ incubator/lucy/trunk/core/Lucy/Object/VTable.c Sun Jan 15 23:04:48 2012
@@ -119,20 +119,20 @@ VTable_init_registry() {
}
VTable*
-VTable_singleton(const CharBuf *subclass_name, VTable *parent) {
+VTable_singleton(const CharBuf *class_name, VTable *parent) {
if (VTable_registry == NULL) {
VTable_init_registry();
}
- VTable *singleton = (VTable*)LFReg_Fetch(VTable_registry, (Obj*)subclass_name);
+ VTable *singleton = (VTable*)LFReg_Fetch(VTable_registry, (Obj*)class_name);
if (singleton == NULL) {
VArray *fresh_host_methods;
uint32_t num_fresh;
if (parent == NULL) {
- CharBuf *parent_class = VTable_find_parent_class(subclass_name);
+ CharBuf *parent_class = VTable_find_parent_class(class_name);
if (parent_class == NULL) {
- THROW(ERR, "Class '%o' doesn't descend from %o", subclass_name,
+ THROW(ERR, "Class '%o' doesn't descend from %o", class_name,
OBJ->name);
}
else {
@@ -147,10 +147,10 @@ VTable_singleton(const CharBuf *subclass
// Turn clone into child.
singleton->parent = parent;
DECREF(singleton->name);
- singleton->name = CB_Clone(subclass_name);
+ singleton->name = CB_Clone(class_name);
// Allow host methods to override.
- fresh_host_methods = VTable_fresh_host_methods(subclass_name);
+ fresh_host_methods = VTable_fresh_host_methods(class_name);
num_fresh = VA_Get_Size(fresh_host_methods);
if (num_fresh) {
Hash *meths = Hash_new(num_fresh);
@@ -186,10 +186,10 @@ VTable_singleton(const CharBuf *subclass
}
else {
DECREF(singleton);
- singleton = (VTable*)LFReg_Fetch(VTable_registry, (Obj*)subclass_name);
+ singleton = (VTable*)LFReg_Fetch(VTable_registry, (Obj*)class_name);
if (!singleton) {
THROW(ERR, "Failed to either insert or fetch VTable for '%o'",
- subclass_name);
+ class_name);
}
}
}
Modified: incubator/lucy/trunk/core/Lucy/Object/VTable.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/VTable.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/VTable.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/VTable.cfh Sun Jan 15 23:04:48 2012
@@ -38,15 +38,15 @@ class Lucy::Object::VTable inherits Lucy
inert size_t offset_of_parent;
/** Return a singleton. If a VTable can be found in the registry based on
- * the subclass name, it will be returned. Otherwise, a new VTable will
- * be created using [parent] as a base.
+ * the supplied class name, it will be returned. Otherwise, a new VTable
+ * will be created using [parent] as a base.
*
* If [parent] is NULL, an attempt will be made to find it using
* VTable_find_parent_class(). If the attempt fails, an error will
* result.
*/
inert VTable*
- singleton(const CharBuf *subclass_name, VTable *parent);
+ singleton(const CharBuf *class_name, VTable *parent);
/** Register a vtable, so that it can be retrieved by class name.
*
Modified: incubator/lucy/trunk/core/Lucy/Search/Compiler.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/Compiler.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/Compiler.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/Compiler.c Sun Jan 15 23:04:48 2012
@@ -130,7 +130,6 @@ Compiler_serialize(Compiler *self, OutSt
Compiler*
Compiler_deserialize(Compiler *self, InStream *instream) {
- if (!self) { THROW(ERR, "Compiler_Deserialize is abstract"); }
self->boost = InStream_Read_F32(instream);
self->parent = (Query*)THAW(instream);
self->sim = (Similarity*)THAW(instream);
Modified: incubator/lucy/trunk/core/Lucy/Search/Compiler.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/Compiler.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/Compiler.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/Compiler.cfh Sun Jan 15 23:04:48 2012
@@ -155,7 +155,7 @@ class Lucy::Search::Compiler inherits Lu
Serialize(Compiler *self, OutStream *outstream);
public incremented Compiler*
- Deserialize(Compiler *self, InStream *instream);
+ Deserialize(decremented Compiler *self, InStream *instream);
public bool_t
Equals(Compiler *self, Obj *other);
Modified: incubator/lucy/trunk/core/Lucy/Search/LeafQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/LeafQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/LeafQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/LeafQuery.c Sun Jan 15 23:04:48 2012
@@ -93,11 +93,14 @@ LeafQuery_serialize(LeafQuery *self, Out
LeafQuery*
LeafQuery_deserialize(LeafQuery *self, InStream *instream) {
- self = self ? self : (LeafQuery*)VTable_Make_Obj(LEAFQUERY);
- self->field = InStream_Read_U8(instream)
- ? CB_deserialize(NULL, instream)
- : NULL;
- self->text = CB_deserialize(NULL, instream);
+ if (InStream_Read_U8(instream)) {
+ self->field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
+ }
+ else {
+ self->field = NULL;
+ }
+ self->text = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
self->boost = InStream_Read_F32(instream);
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Search/LeafQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/LeafQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/LeafQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/LeafQuery.cfh Sun Jan 15 23:04:48 2012
@@ -61,7 +61,7 @@ class Lucy::Search::LeafQuery inherits L
Serialize(LeafQuery *self, OutStream *outstream);
public incremented LeafQuery*
- Deserialize(LeafQuery *self, InStream *instream);
+ Deserialize(decremented LeafQuery *self, InStream *instream);
/** Throws an error.
*/
Modified: incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.c Sun Jan 15 23:04:48 2012
@@ -81,14 +81,6 @@ MatchAllCompiler_init(MatchAllCompiler *
searcher, NULL, boost);
}
-MatchAllCompiler*
-MatchAllCompiler_deserialize(MatchAllCompiler *self, InStream *instream) {
- self = self
- ? self
- : (MatchAllCompiler*)VTable_Make_Obj(MATCHALLCOMPILER);
- return (MatchAllCompiler*)Compiler_deserialize((Compiler*)self, instream);
-}
-
Matcher*
MatchAllCompiler_make_matcher(MatchAllCompiler *self, SegReader *reader,
bool_t need_score) {
Modified: incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/MatchAllQuery.cfh Sun Jan 15 23:04:48 2012
@@ -58,9 +58,6 @@ class Lucy::Search::MatchAllCompiler
public incremented nullable Matcher*
Make_Matcher(MatchAllCompiler *self, SegReader *reader,
bool_t need_score);
-
- public incremented MatchAllCompiler*
- Deserialize(MatchAllCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/MatchDoc.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/MatchDoc.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/MatchDoc.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/MatchDoc.c Sun Jan 15 23:04:48 2012
@@ -51,11 +51,11 @@ MatchDoc_serialize(MatchDoc *self, OutSt
MatchDoc*
MatchDoc_deserialize(MatchDoc *self, InStream *instream) {
- self = self ? self : (MatchDoc*)VTable_Make_Obj(MATCHDOC);
self->doc_id = InStream_Read_C32(instream);
self->score = InStream_Read_F32(instream);
if (InStream_Read_U8(instream)) {
- self->values = VA_deserialize(NULL, instream);
+ self->values
+ = VA_Deserialize((VArray*)VTable_Make_Obj(VARRAY), instream);
}
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Search/MatchDoc.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/MatchDoc.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/MatchDoc.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/MatchDoc.cfh Sun Jan 15 23:04:48 2012
@@ -35,7 +35,7 @@ class Lucy::Search::MatchDoc inherits Lu
Serialize(MatchDoc *self, OutStream *outstream);
public incremented MatchDoc*
- Deserialize(MatchDoc *self, InStream *instream);
+ Deserialize(decremented MatchDoc *self, InStream *instream);
int32_t
Get_Doc_ID(MatchDoc *self);
Modified: incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.c Sun Jan 15 23:04:48 2012
@@ -103,7 +103,6 @@ NoMatchQuery_serialize(NoMatchQuery *sel
NoMatchQuery*
NoMatchQuery_deserialize(NoMatchQuery *self, InStream *instream) {
- self = self ? self : (NoMatchQuery*)VTable_Make_Obj(NOMATCHQUERY);
NoMatchQuery_init(self);
self->fails_to_match = !!InStream_Read_I8(instream);
return self;
@@ -126,12 +125,6 @@ NoMatchCompiler_init(NoMatchCompiler *se
searcher, NULL, boost);
}
-NoMatchCompiler*
-NoMatchCompiler_deserialize(NoMatchCompiler *self, InStream *instream) {
- self = self ? self : (NoMatchCompiler*)VTable_Make_Obj(NOMATCHCOMPILER);
- return (NoMatchCompiler*)Compiler_deserialize((Compiler*)self, instream);
-}
-
Matcher*
NoMatchCompiler_make_matcher(NoMatchCompiler *self, SegReader *reader,
bool_t need_score) {
Modified: incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/NoMatchQuery.cfh Sun Jan 15 23:04:48 2012
@@ -52,7 +52,7 @@ class Lucy::Search::NoMatchQuery inherit
Serialize(NoMatchQuery *self, OutStream *outstream);
public incremented NoMatchQuery*
- Deserialize(NoMatchQuery *self, InStream *instream);
+ Deserialize(decremented NoMatchQuery *self, InStream *instream);
public bool_t
Equals(NoMatchQuery *self, Obj *other);
@@ -77,9 +77,6 @@ class Lucy::Search::NoMatchCompiler
public incremented nullable Matcher*
Make_Matcher(NoMatchCompiler *self, SegReader *reader, bool_t need_score);
-
- public incremented NoMatchCompiler*
- Deserialize(NoMatchCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.c Sun Jan 15 23:04:48 2012
@@ -81,10 +81,11 @@ PhraseQuery_serialize(PhraseQuery *self,
PhraseQuery*
PhraseQuery_deserialize(PhraseQuery *self, InStream *instream) {
- float boost = InStream_Read_F32(instream);
- CharBuf *field = CB_deserialize(NULL, instream);
- VArray *terms = VA_deserialize(NULL, instream);
- self = self ? self : (PhraseQuery*)VTable_Make_Obj(PHRASEQUERY);
+ float boost = InStream_Read_F32(instream);
+ CharBuf *field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
+ VArray *terms
+ = VA_Deserialize((VArray*)VTable_Make_Obj(VARRAY), instream);
return S_do_init(self, field, terms, boost);
}
@@ -203,8 +204,11 @@ PhraseCompiler_serialize(PhraseCompiler
PhraseCompiler*
PhraseCompiler_deserialize(PhraseCompiler *self, InStream *instream) {
- self = self ? self : (PhraseCompiler*)VTable_Make_Obj(PHRASECOMPILER);
- Compiler_deserialize((Compiler*)self, instream);
+ PhraseCompiler_deserialize_t super_deserialize
+ = (PhraseCompiler_deserialize_t)SUPER_METHOD(PHRASECOMPILER,
+ PhraseCompiler,
+ Deserialize);
+ self = super_deserialize(self, instream);
self->idf = InStream_Read_F32(instream);
self->raw_weight = InStream_Read_F32(instream);
self->query_norm_factor = InStream_Read_F32(instream);
Modified: incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PhraseQuery.cfh Sun Jan 15 23:04:48 2012
@@ -62,7 +62,7 @@ class Lucy::Search::PhraseQuery inherits
Serialize(PhraseQuery *self, OutStream *outstream);
public incremented PhraseQuery*
- Deserialize(PhraseQuery *self, InStream *instream);
+ Deserialize(decremented PhraseQuery *self, InStream *instream);
public void
Destroy(PhraseQuery *self);
@@ -106,7 +106,7 @@ class Lucy::Search::PhraseCompiler
Serialize(PhraseCompiler *self, OutStream *outstream);
public incremented PhraseCompiler*
- Deserialize(PhraseCompiler *self, InStream *instream);
+ Deserialize(decremented PhraseCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PolyQuery.c Sun Jan 15 23:04:48 2012
@@ -77,16 +77,12 @@ PolyQuery*
PolyQuery_deserialize(PolyQuery *self, InStream *instream) {
float boost = InStream_Read_F32(instream);
uint32_t num_children = InStream_Read_U32(instream);
-
- if (!self) { THROW(ERR, "Abstract class"); }
PolyQuery_init(self, NULL);
PolyQuery_Set_Boost(self, boost);
-
VA_Grow(self->children, num_children);
while (num_children--) {
VA_Push(self->children, THAW(instream));
}
-
return self;
}
@@ -173,19 +169,22 @@ void
PolyCompiler_serialize(PolyCompiler *self, OutStream *outstream) {
CB_Serialize(PolyCompiler_Get_Class_Name(self), outstream);
VA_Serialize(self->children, outstream);
- Compiler_serialize((Compiler*)self, outstream);
+ PolyCompiler_serialize_t super_serialize
+ = (PolyCompiler_serialize_t)SUPER_METHOD(POLYCOMPILER, PolyCompiler,
+ Serialize);
+ super_serialize(self, outstream);
}
PolyCompiler*
PolyCompiler_deserialize(PolyCompiler *self, InStream *instream) {
- CharBuf *class_name = CB_deserialize(NULL, instream);
- if (!self) {
- VTable *vtable = VTable_singleton(class_name, NULL);
- self = (PolyCompiler*)VTable_Make_Obj(vtable);
- }
- DECREF(class_name);
- self->children = VA_deserialize(NULL, instream);
- return (PolyCompiler*)Compiler_deserialize((Compiler*)self, instream);
+ CharBuf *class_name
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
+ DECREF(class_name); // TODO Don't serialize class name.
+ self->children
+ = VA_Deserialize((VArray*)VTable_Make_Obj(VARRAY), instream);
+ PolyCompiler_deserialize_t super_deserialize
+ = (PolyCompiler_deserialize_t)SUPER_METHOD(POLYCOMPILER, PolyCompiler,
+ Deserialize);
+ return super_deserialize(self, instream);
}
-
Modified: incubator/lucy/trunk/core/Lucy/Search/PolyQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/PolyQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/PolyQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/PolyQuery.cfh Sun Jan 15 23:04:48 2012
@@ -52,7 +52,7 @@ abstract class Lucy::Search::PolyQuery
Serialize(PolyQuery *self, OutStream *outstream);
public incremented PolyQuery*
- Deserialize(PolyQuery *self, InStream *instream);
+ Deserialize(decremented PolyQuery *self, InStream *instream);
public bool_t
Equals(PolyQuery *self, Obj *other);
@@ -92,7 +92,7 @@ class Lucy::Search::PolyCompiler inherit
Serialize(PolyCompiler *self, OutStream *outstream);
public incremented PolyCompiler*
- Deserialize(PolyCompiler *self, InStream *instream);
+ Deserialize(decremented PolyCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/Query.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/Query.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/Query.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/Query.c Sun Jan 15 23:04:48 2012
@@ -48,9 +48,6 @@ Query_serialize(Query *self, OutStream *
Query*
Query_deserialize(Query *self, InStream *instream) {
float boost = InStream_Read_F32(instream);
- self = self ? self : (Query*)VTable_Make_Obj(QUERY);
- Query_init(self, boost);
- return self;
+ return Query_init(self, boost);
}
-
Modified: incubator/lucy/trunk/core/Lucy/Search/Query.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/Query.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/Query.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/Query.cfh Sun Jan 15 23:04:48 2012
@@ -75,7 +75,7 @@ class Lucy::Search::Query inherits Lucy:
Serialize(Query *self, OutStream *outstream);
public incremented Query*
- Deserialize(Query *self, InStream *instream);
+ Deserialize(decremented Query *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/RangeQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/RangeQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/RangeQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/RangeQuery.c Sun Jan 15 23:04:48 2012
@@ -137,15 +137,15 @@ RangeQuery_serialize(RangeQuery *self, O
RangeQuery*
RangeQuery_deserialize(RangeQuery *self, InStream *instream) {
// Deserialize components.
- float boost = InStream_Read_F32(instream);
- CharBuf *field = CB_deserialize(NULL, instream);
+ float boost = InStream_Read_F32(instream);
+ CharBuf *field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
Obj *lower_term = InStream_Read_U8(instream) ? THAW(instream) : NULL;
Obj *upper_term = InStream_Read_U8(instream) ? THAW(instream) : NULL;
bool_t include_lower = InStream_Read_U8(instream);
bool_t include_upper = InStream_Read_U8(instream);
// Init object.
- self = self ? self : (RangeQuery*)VTable_Make_Obj(RANGEQUERY);
RangeQuery_init(self, field, lower_term, upper_term, include_lower,
include_upper);
RangeQuery_Set_Boost(self, boost);
@@ -182,12 +182,6 @@ RangeCompiler_init(RangeCompiler *self,
searcher, NULL, boost);
}
-RangeCompiler*
-RangeCompiler_deserialize(RangeCompiler *self, InStream *instream) {
- self = self ? self : (RangeCompiler*)VTable_Make_Obj(RANGECOMPILER);
- return (RangeCompiler*)Compiler_deserialize((Compiler*)self, instream);
-}
-
Matcher*
RangeCompiler_make_matcher(RangeCompiler *self, SegReader *reader,
bool_t need_score) {
Modified: incubator/lucy/trunk/core/Lucy/Search/RangeQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/RangeQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/RangeQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/RangeQuery.cfh Sun Jan 15 23:04:48 2012
@@ -68,7 +68,7 @@ class Lucy::Search::RangeQuery inherits
Serialize(RangeQuery *self, OutStream *outstream);
public incremented RangeQuery*
- Deserialize(RangeQuery *self, InStream *instream);
+ Deserialize(decremented RangeQuery *self, InStream *instream);
public void
Destroy(RangeQuery *self);
@@ -85,9 +85,6 @@ class Lucy::Search::RangeCompiler inheri
public incremented nullable Matcher*
Make_Matcher(RangeCompiler *self, SegReader *reader, bool_t need_score);
-
- public incremented RangeCompiler*
- Deserialize(RangeCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/SortRule.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/SortRule.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/SortRule.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/SortRule.c Sun Jan 15 23:04:48 2012
@@ -59,10 +59,10 @@ SortRule_destroy(SortRule *self) {
SortRule*
SortRule_deserialize(SortRule *self, InStream *instream) {
- self = self ? self : (SortRule*)VTable_Make_Obj(SORTRULE);
self->type = InStream_Read_C32(instream);
if (self->type == SortRule_FIELD) {
- self->field = CB_deserialize(NULL, instream);
+ self->field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
}
self->reverse = InStream_Read_C32(instream);
return self;
Modified: incubator/lucy/trunk/core/Lucy/Search/SortRule.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/SortRule.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/SortRule.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/SortRule.cfh Sun Jan 15 23:04:48 2012
@@ -63,7 +63,7 @@ class Lucy::Search::SortRule inherits Lu
Get_Reverse(SortRule *self);
public incremented SortRule*
- Deserialize(SortRule *self, InStream *instream);
+ Deserialize(decremented SortRule *self, InStream *instream);
public void
Serialize(SortRule *self, OutStream *outstream);
Modified: incubator/lucy/trunk/core/Lucy/Search/SortSpec.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/SortSpec.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/SortSpec.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/SortSpec.c Sun Jan 15 23:04:48 2012
@@ -54,12 +54,10 @@ SortSpec_deserialize(SortSpec *self, InS
uint32_t num_rules = InStream_Read_C32(instream);
VArray *rules = VA_new(num_rules);
- // Create base object.
- self = self ? self : (SortSpec*)VTable_Make_Obj(SORTSPEC);
-
// Add rules.
for (uint32_t i = 0; i < num_rules; i++) {
- VA_Push(rules, (Obj*)SortRule_deserialize(NULL, instream));
+ SortRule *blank = (SortRule*)VTable_Make_Obj(SORTRULE);
+ VA_Push(rules, (Obj*)SortRule_Deserialize(blank, instream));
}
SortSpec_init(self, rules);
DECREF(rules);
Modified: incubator/lucy/trunk/core/Lucy/Search/SortSpec.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/SortSpec.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/SortSpec.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/SortSpec.cfh Sun Jan 15 23:04:48 2012
@@ -42,7 +42,7 @@ class Lucy::Search::SortSpec inherits Lu
init(SortSpec *self, VArray *rules);
public incremented SortSpec*
- Deserialize(SortSpec *self, InStream *instream);
+ Deserialize(decremented SortSpec *self, InStream *instream);
public void
Serialize(SortSpec *self, OutStream *outstream);
Modified: incubator/lucy/trunk/core/Lucy/Search/TermQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/TermQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/TermQuery.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/TermQuery.c Sun Jan 15 23:04:48 2012
@@ -64,8 +64,8 @@ TermQuery_serialize(TermQuery *self, Out
TermQuery*
TermQuery_deserialize(TermQuery *self, InStream *instream) {
- self = self ? self : (TermQuery*)VTable_Make_Obj(TERMQUERY);
- self->field = CB_deserialize(NULL, instream);
+ self->field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
self->term = (Obj*)THAW(instream);
self->boost = InStream_Read_F32(instream);
return self;
@@ -170,7 +170,10 @@ TermCompiler_equals(TermCompiler *self,
void
TermCompiler_serialize(TermCompiler *self, OutStream *outstream) {
- Compiler_serialize((Compiler*)self, outstream);
+ TermCompiler_serialize_t super_serialize
+ = (TermCompiler_serialize_t)SUPER_METHOD(TERMCOMPILER, TermCompiler,
+ Serialize);
+ super_serialize(self, outstream);
OutStream_Write_F32(outstream, self->idf);
OutStream_Write_F32(outstream, self->raw_weight);
OutStream_Write_F32(outstream, self->query_norm_factor);
@@ -179,8 +182,10 @@ TermCompiler_serialize(TermCompiler *sel
TermCompiler*
TermCompiler_deserialize(TermCompiler *self, InStream *instream) {
- self = self ? self : (TermCompiler*)VTable_Make_Obj(TERMCOMPILER);
- Compiler_deserialize((Compiler*)self, instream);
+ TermCompiler_deserialize_t super_deserialize
+ = (TermCompiler_deserialize_t)SUPER_METHOD(TERMCOMPILER, TermCompiler,
+ Deserialize);
+ self = super_deserialize(self, instream);
self->idf = InStream_Read_F32(instream);
self->raw_weight = InStream_Read_F32(instream);
self->query_norm_factor = InStream_Read_F32(instream);
Modified: incubator/lucy/trunk/core/Lucy/Search/TermQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/TermQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/TermQuery.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/TermQuery.cfh Sun Jan 15 23:04:48 2012
@@ -60,7 +60,7 @@ class Lucy::Search::TermQuery inherits L
Serialize(TermQuery *self, OutStream *outstream);
public incremented TermQuery*
- Deserialize(TermQuery *self, InStream *instream);
+ Deserialize(decremented TermQuery *self, InStream *instream);
public bool_t
Equals(TermQuery *self, Obj *other);
@@ -105,7 +105,7 @@ class Lucy::Search::TermCompiler inherit
Serialize(TermCompiler *self, OutStream *outstream);
public incremented TermCompiler*
- Deserialize(TermCompiler *self, InStream *instream);
+ Deserialize(decremented TermCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/core/Lucy/Search/TopDocs.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/TopDocs.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/TopDocs.c (original)
+++ incubator/lucy/trunk/core/Lucy/Search/TopDocs.c Sun Jan 15 23:04:48 2012
@@ -52,8 +52,8 @@ TopDocs_serialize(TopDocs *self, OutStre
TopDocs*
TopDocs_deserialize(TopDocs *self, InStream *instream) {
- self = self ? self : (TopDocs*)VTable_Make_Obj(TOPDOCS);
- self->match_docs = VA_deserialize(NULL, instream);
+ self->match_docs
+ = VA_Deserialize((VArray*)VTable_Make_Obj(VARRAY), instream);
self->total_hits = InStream_Read_C32(instream);
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Search/TopDocs.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Search/TopDocs.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Search/TopDocs.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Search/TopDocs.cfh Sun Jan 15 23:04:48 2012
@@ -56,7 +56,7 @@ class Lucy::Search::TopDocs inherits Luc
Serialize(TopDocs *self, OutStream *outstream);
public incremented TopDocs*
- Deserialize(TopDocs *self, InStream *instream);
+ Deserialize(decremented TopDocs *self, InStream *instream);
public void
Destroy(TopDocs *self);
Modified: incubator/lucy/trunk/core/Lucy/Util/Freezer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Util/Freezer.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Util/Freezer.c (original)
+++ incubator/lucy/trunk/core/Lucy/Util/Freezer.c Sun Jan 15 23:04:48 2012
@@ -29,7 +29,8 @@ Freezer_freeze(Obj *obj, OutStream *outs
Obj*
Freezer_thaw(InStream *instream) {
- CharBuf *class_name = CB_deserialize(NULL, instream);
+ CharBuf *class_name
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
VTable *vtable = VTable_singleton(class_name, NULL);
Obj *blank = VTable_Make_Obj(vtable);
DECREF(class_name);
Modified: incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.c (original)
+++ incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.c Sun Jan 15 23:04:48 2012
@@ -86,11 +86,12 @@ ProximityQuery_serialize(ProximityQuery
ProximityQuery*
ProximityQuery_deserialize(ProximityQuery *self, InStream *instream) {
- float boost = InStream_Read_F32(instream);
- CharBuf *field = CB_deserialize(NULL, instream);
- VArray *terms = VA_deserialize(NULL, instream);
- uint32_t within = InStream_Read_C32(instream);
- self = self ? self : (ProximityQuery*)VTable_Make_Obj(PROXIMITYQUERY);
+ float boost = InStream_Read_F32(instream);
+ CharBuf *field
+ = CB_Deserialize((CharBuf*)VTable_Make_Obj(CHARBUF), instream);
+ VArray *terms
+ = VA_deserialize((VArray*)VTable_Make_Obj(VARRAY), instream);
+ uint32_t within = InStream_Read_C32(instream);
return S_do_init(self, field, terms, boost, within);
}
@@ -210,7 +211,11 @@ ProximityCompiler_init(ProximityCompiler
void
ProximityCompiler_serialize(ProximityCompiler *self, OutStream *outstream) {
- Compiler_serialize((Compiler*)self, outstream);
+ ProximityCompiler_serialize_t super_serialize
+ = (ProximityCompiler_serialize_t)SUPER_METHOD(PROXIMITYCOMPILER,
+ ProximityCompiler,
+ Serialize);
+ super_serialize(self, outstream);
OutStream_Write_F32(outstream, self->idf);
OutStream_Write_F32(outstream, self->raw_weight);
OutStream_Write_F32(outstream, self->query_norm_factor);
@@ -220,8 +225,11 @@ ProximityCompiler_serialize(ProximityCom
ProximityCompiler*
ProximityCompiler_deserialize(ProximityCompiler *self, InStream *instream) {
- self = self ? self : (ProximityCompiler*)VTable_Make_Obj(PROXIMITYCOMPILER);
- Compiler_deserialize((Compiler*)self, instream);
+ ProximityCompiler_deserialize_t super_deserialize
+ = (ProximityCompiler_deserialize_t)SUPER_METHOD(PROXIMITYCOMPILER,
+ ProximityCompiler,
+ Deserialize);
+ self = super_deserialize(self, instream);
self->idf = InStream_Read_F32(instream);
self->raw_weight = InStream_Read_F32(instream);
self->query_norm_factor = InStream_Read_F32(instream);
Modified: incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.cfh?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.cfh (original)
+++ incubator/lucy/trunk/core/LucyX/Search/ProximityQuery.cfh Sun Jan 15 23:04:48 2012
@@ -68,7 +68,7 @@ class LucyX::Search::ProximityQuery inhe
Serialize(ProximityQuery *self, OutStream *outstream);
public incremented ProximityQuery*
- Deserialize(ProximityQuery *self, InStream *instream);
+ Deserialize(decremented ProximityQuery *self, InStream *instream);
public void
Destroy(ProximityQuery *self);
@@ -113,7 +113,7 @@ class LucyX::Search::ProximityCompiler
Serialize(ProximityCompiler *self, OutStream *outstream);
public incremented ProximityCompiler*
- Deserialize(ProximityCompiler *self, InStream *instream);
+ Deserialize(decremented ProximityCompiler *self, InStream *instream);
}
Modified: incubator/lucy/trunk/perl/lib/Lucy.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy.pm?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy.pm Sun Jan 15 23:04:48 2012
@@ -200,6 +200,11 @@ sub error {$Lucy::Object::Err::error}
}
}
+ our %singleton_PARAMS = (
+ class_name => undef,
+ parent => undef,
+ );
+
no warnings 'redefine';
sub DESTROY { } # leak all
}
Modified: incubator/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy/Object/ByteBuf.pm Sun Jan 15 23:04:48 2012
@@ -41,12 +41,12 @@ CODE:
OUTPUT: RETVAL
SV*
-_deserialize(either_sv, instream)
- SV *either_sv;
+_deserialize(self, instream)
+ lucy_ByteBuf *self;
lucy_InStream *instream;
CODE:
- CHY_UNUSED_VAR(either_sv);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_BB_deserialize(NULL, instream));
+ lucy_ByteBuf *thawed = Lucy_BB_Deserialize(self, instream);
+ RETVAL = (SV*)Lucy_BB_To_Host(thawed);
OUTPUT: RETVAL
END_XS_CODE
Modified: incubator/lucy/trunk/perl/lib/Lucy/Object/CharBuf.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy/Object/CharBuf.pm?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy/Object/CharBuf.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy/Object/CharBuf.pm Sun Jan 15 23:04:48 2012
@@ -48,12 +48,12 @@ CODE:
OUTPUT: RETVAL
SV*
-_deserialize(either_sv, instream)
- SV *either_sv;
+_deserialize(self, instream)
+ lucy_CharBuf *self;
lucy_InStream *instream;
CODE:
- CHY_UNUSED_VAR(either_sv);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_CB_deserialize(NULL, instream));
+ lucy_CharBuf *thawed = Lucy_CB_Deserialize(self, instream);
+ RETVAL = (SV*)Lucy_CB_To_Host(thawed);
OUTPUT: RETVAL
SV*
Modified: incubator/lucy/trunk/perl/lib/Lucy/Object/Hash.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy/Object/Hash.pm?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy/Object/Hash.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy/Object/Hash.pm Sun Jan 15 23:04:48 2012
@@ -26,12 +26,12 @@ my $xs_code = <<'END_XS_CODE';
MODULE = Lucy PACKAGE = Lucy::Object::Hash
SV*
-_deserialize(either_sv, instream)
- SV *either_sv;
+_deserialize(self, instream)
+ lucy_Hash *self;
lucy_InStream *instream;
CODE:
- CHY_UNUSED_VAR(either_sv);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_Hash_deserialize(NULL, instream));
+ lucy_Hash *thawed = Lucy_Hash_Deserialize(self, instream);
+ RETVAL = (SV*)Lucy_Hash_To_Host(thawed);
OUTPUT: RETVAL
SV*
Modified: incubator/lucy/trunk/perl/lib/Lucy/Object/VArray.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy/Object/VArray.pm?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy/Object/VArray.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy/Object/VArray.pm Sun Jan 15 23:04:48 2012
@@ -33,12 +33,12 @@ CODE:
OUTPUT: RETVAL
SV*
-_deserialize(either_sv, instream)
- SV *either_sv;
+_deserialize(self, instream)
+ lucy_VArray *self;
lucy_InStream *instream;
CODE:
- CHY_UNUSED_VAR(either_sv);
- RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_VA_deserialize(NULL, instream));
+ lucy_VArray *thawed = Lucy_VA_Deserialize(self, instream);
+ RETVAL = (SV*)Lucy_VA_To_Host(thawed);
OUTPUT: RETVAL
SV*
Modified: incubator/lucy/trunk/perl/lib/Lucy/Object/VTable.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy/Object/VTable.pm?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy/Object/VTable.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy/Object/VTable.pm Sun Jan 15 23:04:48 2012
@@ -33,6 +33,38 @@ CODE:
}
RETVAL = (SV*)Lucy_Obj_To_Host((lucy_Obj*)lucy_VTable_registry);
OUTPUT: RETVAL
+
+SV*
+singleton(unused_sv, ...)
+ SV *unused_sv;
+CODE:
+{
+ CHY_UNUSED_VAR(unused_sv);
+ lucy_CharBuf *class_name = NULL;
+ lucy_VTable *parent = NULL;
+ chy_bool_t args_ok
+ = XSBind_allot_params(&(ST(0)), 1, items,
+ "Lucy::Object::VTable::singleton_PARAMS",
+ ALLOT_OBJ(&class_name, "class_name", 10, true,
+ LUCY_CHARBUF, alloca(cfish_ZCB_size())),
+ ALLOT_OBJ(&parent, "parent", 6, false,
+ LUCY_VTABLE, NULL),
+ NULL);
+ if (!args_ok) {
+ CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error()));
+ }
+ lucy_VTable *singleton = lucy_VTable_singleton(class_name, parent);
+ RETVAL = (SV*)Lucy_VTable_To_Host(singleton);
+}
+OUTPUT: RETVAL
+
+SV*
+make_obj(self)
+ lucy_VTable *self;
+CODE:
+ lucy_Obj *blank = Lucy_VTable_Make_Obj(self);
+ RETVAL = CFISH_OBJ_TO_SV_NOINC(blank);
+OUTPUT: RETVAL
END_XS_CODE
Clownfish::CFC::Binding::Perl::Class->register(
Modified: incubator/lucy/trunk/perl/t/026-serialization.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/t/026-serialization.t?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/t/026-serialization.t (original)
+++ incubator/lucy/trunk/perl/t/026-serialization.t Sun Jan 15 23:04:48 2012
@@ -87,6 +87,7 @@ SKIP: {
sub run_test_cycle {
my ( $orig, $transform ) = @_;
my $class = ref($orig);
+ my $vtable = $orig->get_vtable;
my $frozen = freeze($orig);
my $thawed = thaw($frozen);
@@ -99,7 +100,7 @@ sub run_test_cycle {
$outstream->close;
my $instream = Lucy::Store::InStream->open( file => $ram_file )
or confess Lucy->error;
- my $deserialized = $class->deserialize($instream);
+ my $deserialized = $vtable->make_obj->deserialize($instream);
is( $transform->($deserialized),
$transform->($orig), "$class: call deserialize via class name" );
Modified: incubator/lucy/trunk/perl/t/binding/016-varray.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/t/binding/016-varray.t?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/t/binding/016-varray.t (original)
+++ incubator/lucy/trunk/perl/t/binding/016-varray.t Sun Jan 15 23:04:48 2012
@@ -36,7 +36,9 @@ $varray->serialize($outstream);
$outstream->close;
my $instream = Lucy::Store::InStream->open( file => $ram_file )
or die Lucy->error;
-my $deserialized = $varray->deserialize($instream);
+my $vtable
+ = Lucy::Object::VTable->singleton( class_name => 'Lucy::Object::VArray', );
+my $deserialized = $vtable->make_obj->deserialize($instream);
is_deeply( $varray->to_perl, $deserialized->to_perl,
"serialize/deserialize" );
Modified: incubator/lucy/trunk/perl/t/binding/017-hash.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/t/binding/017-hash.t?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/t/binding/017-hash.t (original)
+++ incubator/lucy/trunk/perl/t/binding/017-hash.t Sun Jan 15 23:04:48 2012
@@ -39,7 +39,9 @@ $hash->serialize($outstream);
$outstream->close;
my $instream = Lucy::Store::InStream->open( file => $ram_file )
or die Lucy->error;
-my $deserialized = $hash->deserialize($instream);
+my $hash_vtable
+ = Lucy::Object::VTable->singleton( class_name => 'Lucy::Object::Hash' );
+my $deserialized = $hash_vtable->make_obj->deserialize($instream);
is_deeply( $hash->to_perl, $deserialized->to_perl, "serialize/deserialize" );
my %hash_with_utf8_keys = ( "\x{263a}" => "foo" );
Modified: incubator/lucy/trunk/perl/t/binding/029-charbuf.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/t/binding/029-charbuf.t?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/t/binding/029-charbuf.t (original)
+++ incubator/lucy/trunk/perl/t/binding/029-charbuf.t Sun Jan 15 23:04:48 2012
@@ -43,7 +43,10 @@ $charbuf->serialize($outstream);
$outstream->close;
my $instream = Lucy::Store::InStream->open( file => $ram_file )
or die Lucy->error;
-my $deserialized = Lucy::Object::CharBuf->deserialize($instream);
+my $charbuf_vtable
+ = Lucy::Object::VTable->singleton( class_name => 'Lucy::Object::CharBuf',
+ );
+my $deserialized = $charbuf_vtable->make_obj->deserialize($instream);
is_deeply( $charbuf->to_perl, $deserialized->to_perl,
"serialize/deserialize" );
Modified: incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c?rev=1231790&r1=1231789&r2=1231790&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c Sun Jan 15 23:04:48 2012
@@ -74,12 +74,9 @@ lucy_Doc_serialize(lucy_Doc *self, lucy_
lucy_Doc*
lucy_Doc_deserialize(lucy_Doc *self, lucy_InStream *instream) {
int32_t doc_id = (int32_t)Lucy_InStream_Read_C32(instream);
-
- self = self ? self : (lucy_Doc*)Lucy_VTable_Make_Obj(LUCY_DOC);
lucy_Doc_init(self, NULL, doc_id);
lucy_Host_callback(self, "deserialize_fields", 1,
CFISH_ARG_OBJ("instream", instream));
-
return self;
}