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 2011/05/02 01:50:38 UTC
[lucy-commits] svn commit: r1098445 [23/23] - in /incubator/lucy/trunk: charmonizer/
charmonizer/src/Charmonizer/ charmonizer/src/Charmonizer/Core/
charmonizer/src/Charmonizer/Probe/ charmonizer/src/Charmonizer/Test/
clownfish/lib/ clownfish/lib/Clownfish/Binding/ cl...
Modified: incubator/lucy/trunk/perl/xs/Lucy/Analysis/RegexTokenizer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Analysis/RegexTokenizer.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Analysis/RegexTokenizer.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Analysis/RegexTokenizer.c Sun May 1 23:50:24 2011
@@ -33,29 +33,29 @@ S_set_pattern_from_token_re(lucy_RegexTo
lucy_RegexTokenizer*
lucy_RegexTokenizer_init(lucy_RegexTokenizer *self,
- const lucy_CharBuf *pattern)
-{
- SV *token_re_sv;
+ const lucy_CharBuf *pattern) {
+ SV *token_re_sv;
lucy_Analyzer_init((lucy_Analyzer*)self);
#define DEFAULT_PATTERN "\\w+(?:['\\x{2019}]\\w+)*"
if (pattern) {
- if ( Lucy_CB_Find_Str(pattern, "\\p", 2) != -1
+ if (Lucy_CB_Find_Str(pattern, "\\p", 2) != -1
|| Lucy_CB_Find_Str(pattern, "\\P", 2) != -1
- ) {
+ ) {
LUCY_DECREF(self);
THROW(LUCY_ERR, "\\p and \\P constructs forbidden");
}
self->pattern = Lucy_CB_Clone(pattern);
}
else {
- self->pattern = lucy_CB_new_from_trusted_utf8(DEFAULT_PATTERN,
- sizeof(DEFAULT_PATTERN) - 1);
+ self->pattern = lucy_CB_new_from_trusted_utf8(
+ DEFAULT_PATTERN, sizeof(DEFAULT_PATTERN) - 1);
}
// Acquire a compiled regex engine for matching one token.
- token_re_sv = (SV*)lucy_Host_callback_host(LUCY_REGEXTOKENIZER,
- "compile_token_re", 1, CFISH_ARG_STR("pattern", self->pattern));
+ token_re_sv = (SV*)lucy_Host_callback_host(
+ LUCY_REGEXTOKENIZER, "compile_token_re", 1,
+ CFISH_ARG_STR("pattern", self->pattern));
S_set_token_re_but_not_pattern(self, SvRV(token_re_sv));
SvREFCNT_dec(token_re_sv);
@@ -63,15 +63,14 @@ lucy_RegexTokenizer_init(lucy_RegexToken
}
static void
-S_set_token_re_but_not_pattern(lucy_RegexTokenizer *self, void *token_re)
-{
+S_set_token_re_but_not_pattern(lucy_RegexTokenizer *self, void *token_re) {
MAGIC *magic = NULL;
REGEXP *rx;
#if (PERL_VERSION > 10)
rx = SvRX((SV*)token_re);
#else
if (SvMAGICAL((SV*)token_re)) {
- magic = mg_find((SV*)token_re, PERL_MAGIC_qr);
+ magic = mg_find((SV*)token_re, PERL_MAGIC_qr);
}
if (!magic) {
THROW(LUCY_ERR, "token_re is not a qr// entity");
@@ -79,8 +78,8 @@ S_set_token_re_but_not_pattern(lucy_Rege
rx = (REGEXP*)magic->mg_obj;
#endif
if (rx == NULL) {
- THROW(LUCY_ERR, "Failed to extract REGEXP from token_re '%s'",
- SvPV_nolen((SV*)token_re));
+ THROW(LUCY_ERR, "Failed to extract REGEXP from token_re '%s'",
+ SvPV_nolen((SV*)token_re));
}
if (self->token_re) ReREFCNT_dec(((REGEXP*)self->token_re));
self->token_re = rx;
@@ -88,8 +87,7 @@ S_set_token_re_but_not_pattern(lucy_Rege
}
static void
-S_set_pattern_from_token_re(lucy_RegexTokenizer *self, void *token_re)
-{
+S_set_pattern_from_token_re(lucy_RegexTokenizer *self, void *token_re) {
SV *rv = newRV((SV*)token_re);
STRLEN len = 0;
char *ptr = SvPVutf8((SV*)rv, len);
@@ -98,16 +96,14 @@ S_set_pattern_from_token_re(lucy_RegexTo
}
void
-lucy_RegexTokenizer_set_token_re(lucy_RegexTokenizer *self, void *token_re)
-{
+lucy_RegexTokenizer_set_token_re(lucy_RegexTokenizer *self, void *token_re) {
S_set_token_re_but_not_pattern(self, token_re);
// Set pattern as a side effect.
S_set_pattern_from_token_re(self, token_re);
}
void
-lucy_RegexTokenizer_destroy(lucy_RegexTokenizer *self)
-{
+lucy_RegexTokenizer_destroy(lucy_RegexTokenizer *self) {
LUCY_DECREF(self->pattern);
ReREFCNT_dec(((REGEXP*)self->token_re));
LUCY_SUPER_DESTROY(self, LUCY_REGEXTOKENIZER);
@@ -115,15 +111,14 @@ lucy_RegexTokenizer_destroy(lucy_RegexTo
void
lucy_RegexTokenizer_tokenize_str(lucy_RegexTokenizer *self,
- const char *string, size_t string_len,
- lucy_Inversion *inversion)
-{
+ const char *string, size_t string_len,
+ lucy_Inversion *inversion) {
uint32_t num_code_points = 0;
SV *wrapper = sv_newmortal();
#if (PERL_VERSION > 10)
REGEXP *rx = (REGEXP*)self->token_re;
regexp *rx_struct = (regexp*)SvANY(rx);
-#else
+#else
REGEXP *rx = (REGEXP*)self->token_re;
regexp *rx_struct = rx;
#endif
@@ -143,27 +138,25 @@ lucy_RegexTokenizer_tokenize_str(lucy_Re
SvCUR_set(wrapper, string_len);
SvPOK_on(wrapper);
- while (
- pregexec(rx, string_arg, string_end, string_arg, 1, wrapper, 1)
- ) {
+ while (pregexec(rx, string_arg, string_end, string_arg, 1, wrapper, 1)) {
#if ((PERL_VERSION >= 10) || (PERL_VERSION == 9 && PERL_SUBVERSION >= 5))
char *const start_ptr = string_arg + rx_struct->offs[0].start;
char *const end_ptr = string_arg + rx_struct->offs[0].end;
-#else
+#else
char *const start_ptr = string_arg + rx_struct->startp[0];
char *const end_ptr = string_arg + rx_struct->endp[0];
#endif
uint32_t start, end;
// Get start and end offsets in Unicode code points.
- for( ; string_arg < start_ptr; num_code_points++) {
+ for (; string_arg < start_ptr; num_code_points++) {
string_arg += lucy_StrHelp_UTF8_COUNT[(uint8_t)*string_arg];
if (string_arg > string_end) {
THROW(LUCY_ERR, "scanned past end of '%s'", string_beg);
}
}
start = num_code_points;
- for( ; string_arg < end_ptr; num_code_points++) {
+ for (; string_arg < end_ptr; num_code_points++) {
string_arg += lucy_StrHelp_UTF8_COUNT[(uint8_t)*string_arg];
if (string_arg > string_end) {
THROW(LUCY_ERR, "scanned past end of '%s'", string_beg);
@@ -173,15 +166,15 @@ lucy_RegexTokenizer_tokenize_str(lucy_Re
// Add a token to the new inversion.
Lucy_Inversion_Append(inversion,
- lucy_Token_new(
- start_ptr,
- (end_ptr - start_ptr),
- start,
- end,
- 1.0f, // boost always 1 for now
- 1 // position increment
- )
- );
+ lucy_Token_new(
+ start_ptr,
+ (end_ptr - start_ptr),
+ start,
+ end,
+ 1.0f, // boost always 1 for now
+ 1 // position increment
+ )
+ );
}
}
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=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Document/Doc.c Sun May 1 23:50:24 2011
@@ -23,8 +23,7 @@
#include "Lucy/Util/Memory.h"
lucy_Doc*
-lucy_Doc_init(lucy_Doc *self, void *fields, int32_t doc_id)
-{
+lucy_Doc_init(lucy_Doc *self, void *fields, int32_t doc_id) {
// Assign.
if (fields) {
if (SvTYPE((SV*)fields) != SVt_PVHV) THROW(LUCY_ERR, "Not a hash");
@@ -39,29 +38,26 @@ lucy_Doc_init(lucy_Doc *self, void *fiel
}
void
-lucy_Doc_set_fields(lucy_Doc *self, void *fields)
-{
+lucy_Doc_set_fields(lucy_Doc *self, void *fields) {
if (self->fields) SvREFCNT_dec((SV*)self->fields);
self->fields = SvREFCNT_inc((SV*)fields);
}
uint32_t
-lucy_Doc_get_size(lucy_Doc *self)
-{
+lucy_Doc_get_size(lucy_Doc *self) {
return self->fields ? HvKEYS((HV*)self->fields) : 0;
}
void
-lucy_Doc_store(lucy_Doc *self, const lucy_CharBuf *field, lucy_Obj *value)
-{
+lucy_Doc_store(lucy_Doc *self, const lucy_CharBuf *field, lucy_Obj *value) {
char *key = (char*)Lucy_CB_Get_Ptr8(field);
size_t key_size = Lucy_CB_Get_Size(field);
- SV *key_sv = newSVpvn(key, key_size);
+ SV *key_sv = newSVpvn(key, key_size);
SV *val_sv = value == NULL
- ? newSV(0)
- : Lucy_Obj_Is_A(value, LUCY_CHARBUF)
- ? XSBind_cb_to_sv((lucy_CharBuf*)value)
- : (SV*)Lucy_Obj_To_Host(value);
+ ? newSV(0)
+ : Lucy_Obj_Is_A(value, LUCY_CHARBUF)
+ ? XSBind_cb_to_sv((lucy_CharBuf*)value)
+ : (SV*)Lucy_Obj_To_Host(value);
SvUTF8_on(key_sv);
(void)hv_store_ent((HV*)self->fields, key_sv, val_sv, 0);
// TODO: make this a thread-local instead of creating it every time?
@@ -69,38 +65,35 @@ lucy_Doc_store(lucy_Doc *self, const luc
}
void
-lucy_Doc_serialize(lucy_Doc *self, lucy_OutStream *outstream)
-{
+lucy_Doc_serialize(lucy_Doc *self, lucy_OutStream *outstream) {
Lucy_OutStream_Write_C32(outstream, self->doc_id);
- lucy_Host_callback(self, "serialize_fields", 1,
- CFISH_ARG_OBJ("outstream", outstream));
+ lucy_Host_callback(self, "serialize_fields", 1,
+ CFISH_ARG_OBJ("outstream", outstream));
}
lucy_Doc*
-lucy_Doc_deserialize(lucy_Doc *self, lucy_InStream *instream)
-{
+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));
-
+ lucy_Host_callback(self, "deserialize_fields", 1,
+ CFISH_ARG_OBJ("instream", instream));
+
return self;
}
lucy_Obj*
-lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field,
- lucy_ViewCharBuf *target)
-{
+lucy_Doc_extract(lucy_Doc *self, lucy_CharBuf *field,
+ lucy_ViewCharBuf *target) {
lucy_Obj *retval = NULL;
- SV **sv_ptr = hv_fetch((HV*)self->fields, (char*)Lucy_CB_Get_Ptr8(field),
- Lucy_CB_Get_Size(field), 0);
+ SV **sv_ptr = hv_fetch((HV*)self->fields, (char*)Lucy_CB_Get_Ptr8(field),
+ Lucy_CB_Get_Size(field), 0);
if (sv_ptr && XSBind_sv_defined(*sv_ptr)) {
SV *const sv = *sv_ptr;
if (sv_isobject(sv) && sv_derived_from(sv, "Lucy::Object::Obj")) {
- IV tmp = SvIV( SvRV(sv) );
+ IV tmp = SvIV(SvRV(sv));
retval = INT2PTR(lucy_Obj*, tmp);
}
else {
@@ -113,11 +106,10 @@ lucy_Doc_extract(lucy_Doc *self, lucy_Ch
return retval;
}
-
+
void*
-lucy_Doc_to_host(lucy_Doc *self)
-{
- lucy_Doc_to_host_t super_to_host
+lucy_Doc_to_host(lucy_Doc *self) {
+ lucy_Doc_to_host_t super_to_host
= (lucy_Doc_to_host_t)LUCY_SUPER_METHOD(LUCY_DOC, Doc, To_Host);
SV *perl_obj = (SV*)super_to_host(self);
XSBind_enable_overload(perl_obj);
@@ -125,30 +117,31 @@ lucy_Doc_to_host(lucy_Doc *self)
}
lucy_Hash*
-lucy_Doc_dump(lucy_Doc *self)
-{
+lucy_Doc_dump(lucy_Doc *self) {
lucy_Hash *dump = lucy_Hash_new(0);
- Lucy_Hash_Store_Str(dump, "_class", 6,
- (lucy_Obj*)Lucy_CB_Clone(Lucy_Doc_Get_Class_Name(self)));
- Lucy_Hash_Store_Str(dump, "doc_id", 7,
- (lucy_Obj*)lucy_CB_newf("%i32", self->doc_id));
- Lucy_Hash_Store_Str(dump, "fields", 6,
- XSBind_perl_to_cfish((SV*)self->fields));
+ Lucy_Hash_Store_Str(dump, "_class", 6,
+ (lucy_Obj*)Lucy_CB_Clone(Lucy_Doc_Get_Class_Name(self)));
+ Lucy_Hash_Store_Str(dump, "doc_id", 7,
+ (lucy_Obj*)lucy_CB_newf("%i32", self->doc_id));
+ Lucy_Hash_Store_Str(dump, "fields", 6,
+ XSBind_perl_to_cfish((SV*)self->fields));
return dump;
}
lucy_Doc*
-lucy_Doc_load(lucy_Doc *self, lucy_Obj *dump)
-{
+lucy_Doc_load(lucy_Doc *self, lucy_Obj *dump) {
lucy_Hash *source = (lucy_Hash*)CFISH_CERTIFY(dump, LUCY_HASH);
lucy_CharBuf *class_name = (lucy_CharBuf*)CFISH_CERTIFY(
- Lucy_Hash_Fetch_Str(source, "_class", 6), LUCY_CHARBUF);
+ Lucy_Hash_Fetch_Str(source, "_class", 6),
+ LUCY_CHARBUF);
lucy_VTable *vtable = lucy_VTable_singleton(class_name, NULL);
lucy_Doc *loaded = (lucy_Doc*)Lucy_VTable_Make_Obj(vtable);
lucy_Obj *doc_id = CFISH_CERTIFY(
- Lucy_Hash_Fetch_Str(source, "doc_id", 7), LUCY_OBJ);
+ Lucy_Hash_Fetch_Str(source, "doc_id", 7),
+ LUCY_OBJ);
lucy_Hash *fields = (lucy_Hash*)CFISH_CERTIFY(
- Lucy_Hash_Fetch_Str(source, "fields", 6), LUCY_HASH);
+ Lucy_Hash_Fetch_Str(source, "fields", 6),
+ LUCY_HASH);
SV *fields_sv = XSBind_cfish_to_perl((lucy_Obj*)fields);
CHY_UNUSED_VAR(self);
@@ -160,15 +153,14 @@ lucy_Doc_load(lucy_Doc *self, lucy_Obj *
}
chy_bool_t
-lucy_Doc_equals(lucy_Doc *self, lucy_Obj *other)
-{
+lucy_Doc_equals(lucy_Doc *self, lucy_Obj *other) {
lucy_Doc *twin = (lucy_Doc*)other;
HV *my_fields;
HV *other_fields;
I32 num_fields;
if (twin == self) { return true; }
- if (!Lucy_Obj_Is_A(other, LUCY_DOC)) { return false; }
+ if (!Lucy_Obj_Is_A(other, LUCY_DOC)) { return false; }
if (!self->doc_id == twin->doc_id) { return false; }
if (!!self->fields ^ !!twin->fields) { return false; }
@@ -177,7 +169,7 @@ lucy_Doc_equals(lucy_Doc *self, lucy_Obj
other_fields = (HV*)twin->fields;
if (HvKEYS(my_fields) != HvKEYS(other_fields)) { return false; }
num_fields = hv_iterinit(my_fields);
- while(num_fields--) {
+ while (num_fields--) {
HE *my_entry = hv_iternext(my_fields);
SV *my_val_sv = HeVAL(my_entry);
STRLEN key_len = HeKLEN(my_entry);
@@ -191,8 +183,7 @@ lucy_Doc_equals(lucy_Doc *self, lucy_Obj
}
void
-lucy_Doc_destroy(lucy_Doc *self)
-{
+lucy_Doc_destroy(lucy_Doc *self) {
if (self->fields) SvREFCNT_dec((SV*)self->fields);
LUCY_SUPER_DESTROY(self, LUCY_DOC);
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Index/DocReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Index/DocReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Index/DocReader.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Index/DocReader.c Sun May 1 23:50:24 2011
@@ -30,8 +30,7 @@
#include "Lucy/Store/InStream.h"
lucy_HitDoc*
-lucy_DefDocReader_fetch_doc(lucy_DefaultDocReader *self, int32_t doc_id)
-{
+lucy_DefDocReader_fetch_doc(lucy_DefaultDocReader *self, int32_t doc_id) {
lucy_Schema *const schema = self->schema;
lucy_InStream *const dat_in = self->dat_in;
lucy_InStream *const ix_in = self->ix_in;
@@ -63,32 +62,32 @@ lucy_DefDocReader_fetch_doc(lucy_Default
*SvEND(field_name_sv) = '\0';
// Find the Field's FieldType.
- lucy_ZombieCharBuf *field_name_zcb
+ lucy_ZombieCharBuf *field_name_zcb
= CFISH_ZCB_WRAP_STR(field_name_ptr, field_name_len);
Lucy_ZCB_Assign_Str(field_name_zcb, field_name_ptr, field_name_len);
type = Lucy_Schema_Fetch_Type(schema, (lucy_CharBuf*)field_name_zcb);
// Read the field value.
- switch(Lucy_FType_Primitive_ID(type) & lucy_FType_PRIMITIVE_ID_MASK) {
+ switch (Lucy_FType_Primitive_ID(type) & lucy_FType_PRIMITIVE_ID_MASK) {
case lucy_FType_TEXT: {
- STRLEN value_len = Lucy_InStream_Read_C32(dat_in);
- value_sv = newSV((value_len ? value_len : 1));
- Lucy_InStream_Read_Bytes(dat_in, SvPVX(value_sv), value_len);
- SvCUR_set(value_sv, value_len);
- *SvEND(value_sv) = '\0';
- SvPOK_on(value_sv);
- SvUTF8_on(value_sv);
- break;
- }
+ STRLEN value_len = Lucy_InStream_Read_C32(dat_in);
+ value_sv = newSV((value_len ? value_len : 1));
+ Lucy_InStream_Read_Bytes(dat_in, SvPVX(value_sv), value_len);
+ SvCUR_set(value_sv, value_len);
+ *SvEND(value_sv) = '\0';
+ SvPOK_on(value_sv);
+ SvUTF8_on(value_sv);
+ break;
+ }
case lucy_FType_BLOB: {
- STRLEN value_len = Lucy_InStream_Read_C32(dat_in);
- value_sv = newSV((value_len ? value_len : 1));
- Lucy_InStream_Read_Bytes(dat_in, SvPVX(value_sv), value_len);
- SvCUR_set(value_sv, value_len);
- *SvEND(value_sv) = '\0';
- SvPOK_on(value_sv);
- break;
- }
+ STRLEN value_len = Lucy_InStream_Read_C32(dat_in);
+ value_sv = newSV((value_len ? value_len : 1));
+ Lucy_InStream_Read_Bytes(dat_in, SvPVX(value_sv), value_len);
+ SvCUR_set(value_sv, value_len);
+ *SvEND(value_sv) = '\0';
+ SvPOK_on(value_sv);
+ break;
+ }
case lucy_FType_FLOAT32:
value_sv = newSVnv(Lucy_InStream_Read_F32(dat_in));
break;
@@ -109,7 +108,7 @@ lucy_DefDocReader_fetch_doc(lucy_Default
}
break;
default:
- value_sv = NULL;
+ value_sv = NULL;
CFISH_THROW(LUCY_ERR, "Unrecognized type: %o", type);
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Index/Inverter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Index/Inverter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Index/Inverter.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Index/Inverter.c Sun May 1 23:50:24 2011
@@ -30,8 +30,7 @@
#include "Lucy/Util/StringHelper.h"
static lucy_InverterEntry*
-S_fetch_entry(lucy_Inverter *self, HE *hash_entry)
-{
+S_fetch_entry(lucy_Inverter *self, HE *hash_entry) {
lucy_Schema *const schema = self->schema;
char *key;
STRLEN key_len;
@@ -52,7 +51,7 @@ S_fetch_entry(lucy_Inverter *self, HE *h
}
lucy_ZombieCharBuf *field = CFISH_ZCB_WRAP_STR(key, key_len);
- int32_t field_num
+ int32_t field_num
= Lucy_Seg_Field_Num(self->segment, (lucy_CharBuf*)field);
if (!field_num) {
// This field seems not to be in the segment yet. Try to find it in
@@ -60,7 +59,7 @@ S_fetch_entry(lucy_Inverter *self, HE *h
if (Lucy_Schema_Fetch_Type(schema, (lucy_CharBuf*)field)) {
// The field is in the Schema. Get a field num from the Segment.
field_num = Lucy_Seg_Add_Field(self->segment,
- (lucy_CharBuf*)field);
+ (lucy_CharBuf*)field);
}
else {
// We've truly failed to find the field. The user must
@@ -70,11 +69,11 @@ S_fetch_entry(lucy_Inverter *self, HE *h
}
{
- lucy_InverterEntry *entry
+ lucy_InverterEntry *entry
= (lucy_InverterEntry*)Lucy_VA_Fetch(self->entry_pool, field_num);
if (!entry) {
- entry
- = lucy_InvEntry_new(schema, (lucy_CharBuf*)field, field_num);
+ entry = lucy_InvEntry_new(schema, (lucy_CharBuf*)field,
+ field_num);
Lucy_VA_Store(self->entry_pool, field_num, (lucy_Obj*)entry);
}
return entry;
@@ -82,8 +81,7 @@ S_fetch_entry(lucy_Inverter *self, HE *h
}
void
-lucy_Inverter_invert_doc(lucy_Inverter *self, lucy_Doc *doc)
-{
+lucy_Inverter_invert_doc(lucy_Inverter *self, lucy_Doc *doc) {
HV *const fields = (HV*)Lucy_Doc_Get_Fields(doc);
I32 num_keys = hv_iterinit(fields);
@@ -98,46 +96,46 @@ lucy_Inverter_invert_doc(lucy_Inverter *
lucy_FieldType *type = inv_entry->type;
// Get the field value, forcing text fields to UTF-8.
- switch (
- Lucy_FType_Primitive_ID(type) & lucy_FType_PRIMITIVE_ID_MASK
- ) {
+ switch (Lucy_FType_Primitive_ID(type) & lucy_FType_PRIMITIVE_ID_MASK) {
case lucy_FType_TEXT: {
- STRLEN val_len;
- char *val_ptr = SvPVutf8(value_sv, val_len);
- lucy_ViewCharBuf *value = (lucy_ViewCharBuf*)inv_entry->value;
- Lucy_ViewCB_Assign_Str(value, val_ptr, val_len);
- break;
- }
+ STRLEN val_len;
+ char *val_ptr = SvPVutf8(value_sv, val_len);
+ lucy_ViewCharBuf *value
+ = (lucy_ViewCharBuf*)inv_entry->value;
+ Lucy_ViewCB_Assign_Str(value, val_ptr, val_len);
+ break;
+ }
case lucy_FType_BLOB: {
- STRLEN val_len;
- char *val_ptr = SvPV(value_sv, val_len);
- lucy_ViewByteBuf *value = (lucy_ViewByteBuf*)inv_entry->value;
- Lucy_ViewBB_Assign_Bytes(value, val_ptr, val_len);
- break;
- }
+ STRLEN val_len;
+ char *val_ptr = SvPV(value_sv, val_len);
+ lucy_ViewByteBuf *value
+ = (lucy_ViewByteBuf*)inv_entry->value;
+ Lucy_ViewBB_Assign_Bytes(value, val_ptr, val_len);
+ break;
+ }
case lucy_FType_INT32: {
- lucy_Integer32* value = (lucy_Integer32*)inv_entry->value;
- Lucy_Int32_Set_Value(value, SvIV(value_sv));
- break;
- }
+ lucy_Integer32* value = (lucy_Integer32*)inv_entry->value;
+ Lucy_Int32_Set_Value(value, SvIV(value_sv));
+ break;
+ }
case lucy_FType_INT64: {
- lucy_Integer64* value = (lucy_Integer64*)inv_entry->value;
- int64_t val = sizeof(IV) == 8
- ? SvIV(value_sv)
- : (int64_t)SvNV(value_sv); // lossy
- Lucy_Int64_Set_Value(value, val);
- break;
- }
+ lucy_Integer64* value = (lucy_Integer64*)inv_entry->value;
+ int64_t val = sizeof(IV) == 8
+ ? SvIV(value_sv)
+ : (int64_t)SvNV(value_sv); // lossy
+ Lucy_Int64_Set_Value(value, val);
+ break;
+ }
case lucy_FType_FLOAT32: {
- lucy_Float32* value = (lucy_Float32*)inv_entry->value;
- Lucy_Float32_Set_Value(value, (float)SvNV(value_sv));
- break;
- }
+ lucy_Float32* value = (lucy_Float32*)inv_entry->value;
+ Lucy_Float32_Set_Value(value, (float)SvNV(value_sv));
+ break;
+ }
case lucy_FType_FLOAT64: {
- lucy_Float64* value = (lucy_Float64*)inv_entry->value;
- Lucy_Float64_Set_Value(value, SvNV(value_sv));
- break;
- }
+ lucy_Float64* value = (lucy_Float64*)inv_entry->value;
+ Lucy_Float64_Set_Value(value, SvNV(value_sv));
+ break;
+ }
default:
THROW(LUCY_ERR, "Unrecognized type: %o", type);
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Index/PolyReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Index/PolyReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Index/PolyReader.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Index/PolyReader.c Sun May 1 23:50:24 2011
@@ -22,19 +22,18 @@
#include "Lucy/Store/Folder.h"
Obj*
-PolyReader_try_open_segreaders(PolyReader *self, VArray *segments)
-{
- return Host_callback_obj(self, "try_open_segreaders", 1,
- ARG_OBJ("segments", segments));
+PolyReader_try_open_segreaders(PolyReader *self, VArray *segments) {
+ return Host_callback_obj(self, "try_open_segreaders", 1,
+ ARG_OBJ("segments", segments));
}
CharBuf*
-PolyReader_try_read_snapshot(Snapshot *snapshot, Folder *folder,
- const CharBuf *path)
-{
+PolyReader_try_read_snapshot(Snapshot *snapshot, Folder *folder,
+ const CharBuf *path) {
return (CharBuf*)Host_callback_obj(POLYREADER, "try_read_snapshot", 3,
- ARG_OBJ("snapshot", snapshot), ARG_OBJ("folder", folder),
- ARG_STR("path", path));
+ ARG_OBJ("snapshot", snapshot),
+ ARG_OBJ("folder", folder),
+ ARG_STR("path", path));
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Index/SegReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Index/SegReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Index/SegReader.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Index/SegReader.c Sun May 1 23:50:24 2011
@@ -20,8 +20,7 @@
#include "Lucy/Object/Host.h"
CharBuf*
-SegReader_try_init_components(SegReader *self)
-{
+SegReader_try_init_components(SegReader *self) {
return (CharBuf*)Host_callback_obj(self, "try_init_components", 0);
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Object/Err.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Object/Err.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Object/Err.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Object/Err.c Sun May 1 23:50:24 2011
@@ -18,32 +18,29 @@
#include "Lucy/Object/Host.h"
lucy_Err*
-lucy_Err_get_error()
-{
- lucy_Err *error
+lucy_Err_get_error() {
+ lucy_Err *error
= (lucy_Err*)lucy_Host_callback_obj(LUCY_ERR, "get_error", 0);
LUCY_DECREF(error); // Cancel out incref from callback.
return error;
}
void
-lucy_Err_set_error(lucy_Err *error)
-{
- lucy_Host_callback(LUCY_ERR, "set_error", 1,
- CFISH_ARG_OBJ("error", error));
+lucy_Err_set_error(lucy_Err *error) {
+ lucy_Host_callback(LUCY_ERR, "set_error", 1,
+ CFISH_ARG_OBJ("error", error));
LUCY_DECREF(error);
}
void
-lucy_Err_do_throw(lucy_Err *err)
-{
+lucy_Err_do_throw(lucy_Err *err) {
dSP;
SV *error_sv = (SV*)Lucy_Err_To_Host(err);
LUCY_DECREF(err);
ENTER;
SAVETMPS;
PUSHMARK(SP);
- XPUSHs( sv_2mortal(error_sv) );
+ XPUSHs(sv_2mortal(error_sv));
PUTBACK;
call_pv("Lucy::Object::Err::do_throw", G_DISCARD);
FREETMPS;
@@ -51,9 +48,8 @@ lucy_Err_do_throw(lucy_Err *err)
}
void*
-lucy_Err_to_host(lucy_Err *self)
-{
- lucy_Err_to_host_t super_to_host
+lucy_Err_to_host(lucy_Err *self) {
+ lucy_Err_to_host_t super_to_host
= (lucy_Err_to_host_t)LUCY_SUPER_METHOD(LUCY_ERR, Err, To_Host);
SV *perl_obj = (SV*)super_to_host(self);
XSBind_enable_overload(perl_obj);
@@ -61,10 +57,9 @@ lucy_Err_to_host(lucy_Err *self)
}
void
-lucy_Err_throw_mess(lucy_VTable *vtable, lucy_CharBuf *message)
-{
+lucy_Err_throw_mess(lucy_VTable *vtable, lucy_CharBuf *message) {
lucy_Err_make_t make = (lucy_Err_make_t)LUCY_METHOD(
- CFISH_CERTIFY(vtable, LUCY_VTABLE), Err, Make);
+ CFISH_CERTIFY(vtable, LUCY_VTABLE), Err, Make);
lucy_Err *err = (lucy_Err*)CFISH_CERTIFY(make(NULL), LUCY_ERR);
Lucy_Err_Cat_Mess(err, message);
LUCY_DECREF(message);
@@ -72,8 +67,7 @@ lucy_Err_throw_mess(lucy_VTable *vtable,
}
void
-lucy_Err_warn_mess(lucy_CharBuf *message)
-{
+lucy_Err_warn_mess(lucy_CharBuf *message) {
SV *error_sv = XSBind_cb_to_sv(message);
LUCY_DECREF(message);
warn("%s", SvPV_nolen(error_sv));
Modified: incubator/lucy/trunk/perl/xs/Lucy/Object/Host.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Object/Host.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Object/Host.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Object/Host.c Sun May 1 23:50:24 2011
@@ -29,18 +29,17 @@ S_do_callback_sv(void *vobj, char *metho
// Convert all arguments to Perl and place them on the Perl stack.
static CHY_INLINE void
-SI_push_args(void *vobj, va_list args, uint32_t num_args)
-{
+SI_push_args(void *vobj, va_list args, uint32_t num_args) {
lucy_Obj *obj = (lucy_Obj*)vobj;
SV *invoker;
uint32_t i;
dSP;
uint32_t stack_slots_needed = num_args < 2
- ? num_args + 1
- : (num_args * 2) + 1;
+ ? num_args + 1
+ : (num_args * 2) + 1;
EXTEND(SP, stack_slots_needed);
-
+
if (Lucy_Obj_Is_A(obj, LUCY_VTABLE)) {
lucy_VTable *vtable = (lucy_VTable*)obj;
// TODO: Creating a new class name SV every time is wasteful.
@@ -53,53 +52,54 @@ SI_push_args(void *vobj, va_list args, u
ENTER;
SAVETMPS;
PUSHMARK(SP);
- PUSHs( sv_2mortal(invoker) );
+ PUSHs(sv_2mortal(invoker));
for (i = 0; i < num_args; i++) {
uint32_t arg_type = va_arg(args, uint32_t);
char *label = va_arg(args, char*);
if (num_args > 1) {
- PUSHs( sv_2mortal( newSVpvn(label, strlen(label)) ) );
+ PUSHs(sv_2mortal(newSVpvn(label, strlen(label))));
}
switch (arg_type & CFISH_HOST_ARGTYPE_MASK) {
- case CFISH_HOST_ARGTYPE_I32: {
- int32_t value = va_arg(args, int32_t);
- PUSHs( sv_2mortal( newSViv(value) ) );
- }
- break;
- case CFISH_HOST_ARGTYPE_I64: {
- int64_t value = va_arg(args, int64_t);
- if (sizeof(IV) == 8) {
- PUSHs( sv_2mortal( newSViv((IV)value) ) );
+ case CFISH_HOST_ARGTYPE_I32: {
+ int32_t value = va_arg(args, int32_t);
+ PUSHs(sv_2mortal(newSViv(value)));
+ }
+ break;
+ case CFISH_HOST_ARGTYPE_I64: {
+ int64_t value = va_arg(args, int64_t);
+ if (sizeof(IV) == 8) {
+ PUSHs(sv_2mortal(newSViv((IV)value)));
+ }
+ else {
+ // lossy
+ PUSHs(sv_2mortal(newSVnv((double)value)));
+ }
+ }
+ break;
+ case CFISH_HOST_ARGTYPE_F32:
+ case CFISH_HOST_ARGTYPE_F64: {
+ // Floats are promoted to doubles by variadic calling.
+ double value = va_arg(args, double);
+ PUSHs(sv_2mortal(newSVnv(value)));
}
- else {
- // lossy
- PUSHs( sv_2mortal( newSVnv((double)value) ) );
+ break;
+ case CFISH_HOST_ARGTYPE_STR: {
+ lucy_CharBuf *string = va_arg(args, lucy_CharBuf*);
+ PUSHs(sv_2mortal(XSBind_cb_to_sv(string)));
}
- }
- break;
- case CFISH_HOST_ARGTYPE_F32:
- case CFISH_HOST_ARGTYPE_F64: {
- // Floats are promoted to doubles by variadic calling.
- double value = va_arg(args, double);
- PUSHs( sv_2mortal( newSVnv(value) ) );
- }
- break;
- case CFISH_HOST_ARGTYPE_STR: {
- lucy_CharBuf *string = va_arg(args, lucy_CharBuf*);
- PUSHs( sv_2mortal( XSBind_cb_to_sv(string) ) );
- }
- break;
- case CFISH_HOST_ARGTYPE_OBJ: {
- lucy_Obj* anObj = va_arg(args, lucy_Obj*);
- SV *arg_sv = anObj == NULL
- ? newSV(0)
- : XSBind_cfish_to_perl(anObj);
- PUSHs( sv_2mortal(arg_sv) );
- }
- break;
- default:
- CFISH_THROW(LUCY_ERR, "Unrecognized arg type: %u32", arg_type);
+ break;
+ case CFISH_HOST_ARGTYPE_OBJ: {
+ lucy_Obj* anObj = va_arg(args, lucy_Obj*);
+ SV *arg_sv = anObj == NULL
+ ? newSV(0)
+ : XSBind_cfish_to_perl(anObj);
+ PUSHs(sv_2mortal(arg_sv));
+ }
+ break;
+ default:
+ CFISH_THROW(LUCY_ERR, "Unrecognized arg type: %u32",
+ arg_type);
}
}
@@ -107,19 +107,18 @@ SI_push_args(void *vobj, va_list args, u
}
void
-lucy_Host_callback(void *vobj, char *method, uint32_t num_args, ...)
-{
+lucy_Host_callback(void *vobj, char *method, uint32_t num_args, ...) {
va_list args;
-
+
va_start(args, num_args);
SI_push_args(vobj, args, num_args);
va_end(args);
-
+
{
- int count = call_method(method, G_VOID|G_DISCARD);
+ int count = call_method(method, G_VOID | G_DISCARD);
if (count != 0) {
- CFISH_THROW(LUCY_ERR, "callback '%s' returned too many values: %i32",
- method, (int32_t)count);
+ CFISH_THROW(LUCY_ERR, "callback '%s' returned too many values: %i32",
+ method, (int32_t)count);
}
FREETMPS;
LEAVE;
@@ -127,8 +126,7 @@ lucy_Host_callback(void *vobj, char *met
}
int64_t
-lucy_Host_callback_i64(void *vobj, char *method, uint32_t num_args, ...)
-{
+lucy_Host_callback_i64(void *vobj, char *method, uint32_t num_args, ...) {
va_list args;
SV *return_sv;
int64_t retval;
@@ -158,8 +156,7 @@ lucy_Host_callback_i64(void *vobj, char
}
double
-lucy_Host_callback_f64(void *vobj, char *method, uint32_t num_args, ...)
-{
+lucy_Host_callback_f64(void *vobj, char *method, uint32_t num_args, ...) {
va_list args;
SV *return_sv;
double retval;
@@ -176,9 +173,7 @@ lucy_Host_callback_f64(void *vobj, char
}
lucy_Obj*
-lucy_Host_callback_obj(void *vobj, char *method,
- uint32_t num_args, ...)
-{
+lucy_Host_callback_obj(void *vobj, char *method, uint32_t num_args, ...) {
va_list args;
SV *temp_retval;
lucy_Obj *retval = NULL;
@@ -196,8 +191,7 @@ lucy_Host_callback_obj(void *vobj, char
}
lucy_CharBuf*
-lucy_Host_callback_str(void *vobj, char *method, uint32_t num_args, ...)
-{
+lucy_Host_callback_str(void *vobj, char *method, uint32_t num_args, ...) {
va_list args;
SV *temp_retval;
lucy_CharBuf *retval = NULL;
@@ -220,8 +214,7 @@ lucy_Host_callback_str(void *vobj, char
}
void*
-lucy_Host_callback_host(void *vobj, char *method, uint32_t num_args, ...)
-{
+lucy_Host_callback_host(void *vobj, char *method, uint32_t num_args, ...) {
va_list args;
SV *retval;
@@ -237,16 +230,15 @@ lucy_Host_callback_host(void *vobj, char
}
static SV*
-S_do_callback_sv(void *vobj, char *method, uint32_t num_args, va_list args)
-{
+S_do_callback_sv(void *vobj, char *method, uint32_t num_args, va_list args) {
SV *return_val;
SI_push_args(vobj, args, num_args);
{
int num_returned = call_method(method, G_SCALAR);
dSP;
if (num_returned != 1) {
- CFISH_THROW(LUCY_ERR, "Bad number of return vals from %s: %i32", method,
- (int32_t)num_returned);
+ CFISH_THROW(LUCY_ERR, "Bad number of return vals from %s: %i32",
+ method, (int32_t)num_returned);
}
return_val = POPs;
PUTBACK;
Modified: incubator/lucy/trunk/perl/xs/Lucy/Object/LockFreeRegistry.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Object/LockFreeRegistry.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Object/LockFreeRegistry.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Object/LockFreeRegistry.c Sun May 1 23:50:24 2011
@@ -22,11 +22,10 @@
#include "Lucy/Object/Host.h"
void*
-lucy_LFReg_to_host(lucy_LockFreeRegistry *self)
-{
+lucy_LFReg_to_host(lucy_LockFreeRegistry *self) {
chy_bool_t first_time = self->ref.count < 4 ? true : false;
- lucy_LFReg_to_host_t to_host = (lucy_LFReg_to_host_t)
- LUCY_SUPER_METHOD(LUCY_LOCKFREEREGISTRY, LFReg, To_Host);
+ lucy_LFReg_to_host_t to_host = (lucy_LFReg_to_host_t)LUCY_SUPER_METHOD(
+ LUCY_LOCKFREEREGISTRY, LFReg, To_Host);
SV *host_obj = (SV*)to_host(self);
if (first_time) {
SvSHARE((SV*)self->ref.host_obj);
Modified: incubator/lucy/trunk/perl/xs/Lucy/Object/Obj.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Object/Obj.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Object/Obj.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Object/Obj.c Sun May 1 23:50:24 2011
@@ -28,8 +28,7 @@
#include "Lucy/Util/Memory.h"
static void
-S_lazy_init_host_obj(lucy_Obj *self)
-{
+S_lazy_init_host_obj(lucy_Obj *self) {
SV *inner_obj = newSV(0);
SvOBJECT_on(inner_obj);
PL_sv_objcount++;
@@ -39,7 +38,7 @@ S_lazy_init_host_obj(lucy_Obj *self)
// Connect class association.
lucy_CharBuf *class_name = Lucy_VTable_Get_Name(self->vtable);
HV *stash = gv_stashpvn((char*)Lucy_CB_Get_Ptr8(class_name),
- Lucy_CB_Get_Size(class_name), TRUE);
+ Lucy_CB_Get_Size(class_name), TRUE);
SvSTASH_set(inner_obj, (HV*)SvREFCNT_inc(stash));
/* Up till now we've been keeping track of the refcount in
@@ -56,16 +55,14 @@ S_lazy_init_host_obj(lucy_Obj *self)
}
uint32_t
-lucy_Obj_get_refcount(lucy_Obj *self)
-{
- return self->ref.count < 4
- ? self->ref.count
- : SvREFCNT((SV*)self->ref.host_obj);
+lucy_Obj_get_refcount(lucy_Obj *self) {
+ return self->ref.count < 4
+ ? self->ref.count
+ : SvREFCNT((SV*)self->ref.host_obj);
}
lucy_Obj*
-lucy_Obj_inc_refcount(lucy_Obj *self)
-{
+lucy_Obj_inc_refcount(lucy_Obj *self) {
switch (self->ref.count) {
case 0:
CFISH_THROW(LUCY_ERR, "Illegal refcount of 0");
@@ -84,8 +81,7 @@ lucy_Obj_inc_refcount(lucy_Obj *self)
}
uint32_t
-lucy_Obj_dec_refcount(lucy_Obj *self)
-{
+lucy_Obj_dec_refcount(lucy_Obj *self) {
uint32_t modified_refcount = I32_MAX;
switch (self->ref.count) {
case 0:
@@ -109,8 +105,7 @@ lucy_Obj_dec_refcount(lucy_Obj *self)
}
void*
-lucy_Obj_to_host(lucy_Obj *self)
-{
+lucy_Obj_to_host(lucy_Obj *self) {
if (self->ref.count < 4) { S_lazy_init_host_obj(self); }
return newRV_inc((SV*)self->ref.host_obj);
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Object/VTable.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Object/VTable.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Object/VTable.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Object/VTable.c Sun May 1 23:50:24 2011
@@ -23,9 +23,8 @@
#include "Lucy/Util/Memory.h"
lucy_Obj*
-lucy_VTable_foster_obj(lucy_VTable *self, void *host_obj)
-{
- lucy_Obj *obj
+lucy_VTable_foster_obj(lucy_VTable *self, void *host_obj) {
+ lucy_Obj *obj
= (lucy_Obj*)lucy_Memory_wrapped_calloc(self->obj_alloc_size, 1);
SV *inner_obj = SvRV((SV*)host_obj);
obj->vtable = self;
@@ -35,33 +34,32 @@ lucy_VTable_foster_obj(lucy_VTable *self
}
void
-lucy_VTable_register_with_host(lucy_VTable *singleton, lucy_VTable *parent)
-{
+lucy_VTable_register_with_host(lucy_VTable *singleton, lucy_VTable *parent) {
// Register class with host.
- lucy_Host_callback(LUCY_VTABLE, "_register", 2,
- CFISH_ARG_OBJ("singleton", singleton), CFISH_ARG_OBJ("parent", parent));
+ lucy_Host_callback(LUCY_VTABLE, "_register", 2,
+ CFISH_ARG_OBJ("singleton", singleton),
+ CFISH_ARG_OBJ("parent", parent));
}
lucy_VArray*
-lucy_VTable_novel_host_methods(const lucy_CharBuf *class_name)
-{
- return (lucy_VArray*)lucy_Host_callback_obj(LUCY_VTABLE,
- "novel_host_methods", 1, CFISH_ARG_STR("class_name", class_name));
+lucy_VTable_novel_host_methods(const lucy_CharBuf *class_name) {
+ return (lucy_VArray*)lucy_Host_callback_obj(
+ LUCY_VTABLE,
+ "novel_host_methods", 1,
+ CFISH_ARG_STR("class_name", class_name));
}
lucy_CharBuf*
-lucy_VTable_find_parent_class(const lucy_CharBuf *class_name)
-{
- return lucy_Host_callback_str(LUCY_VTABLE, "find_parent_class", 1,
- CFISH_ARG_STR("class_name", class_name));
+lucy_VTable_find_parent_class(const lucy_CharBuf *class_name) {
+ return lucy_Host_callback_str(LUCY_VTABLE, "find_parent_class", 1,
+ CFISH_ARG_STR("class_name", class_name));
}
void*
-lucy_VTable_to_host(lucy_VTable *self)
-{
+lucy_VTable_to_host(lucy_VTable *self) {
chy_bool_t first_time = self->ref.count < 4 ? true : false;
- lucy_VTable_to_host_t to_host = (lucy_VTable_to_host_t)
- LUCY_SUPER_METHOD(LUCY_VTABLE, VTable, To_Host);
+ lucy_VTable_to_host_t to_host = (lucy_VTable_to_host_t)LUCY_SUPER_METHOD(
+ LUCY_VTABLE, VTable, To_Host);
SV *host_obj = (SV*)to_host(self);
if (first_time) {
SvSHARE((SV*)self->ref.host_obj);
Modified: incubator/lucy/trunk/perl/xs/Lucy/Store/FSFolder.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Store/FSFolder.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Store/FSFolder.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Store/FSFolder.c Sun May 1 23:50:24 2011
@@ -19,10 +19,9 @@
#include "Lucy/Store/FSFolder.h"
CharBuf*
-FSFolder_absolutify(const CharBuf *path)
-{
-
- return Host_callback_str(FSFOLDER, "absolutify", 1,
- ARG_STR("path", path));
+FSFolder_absolutify(const CharBuf *path) {
+
+ return Host_callback_str(FSFOLDER, "absolutify", 1,
+ ARG_STR("path", path));
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Util/Json.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Util/Json.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Util/Json.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Util/Json.c Sun May 1 23:50:24 2011
@@ -21,42 +21,39 @@
#include "Lucy/Store/Folder.h"
bool_t
-Json_spew_json(Obj *dump, Folder *folder, const CharBuf *path)
-{
- bool_t result = (bool_t)Host_callback_i64(JSON, "spew_json", 3,
- ARG_OBJ("dump", dump), ARG_OBJ("folder", folder),
- ARG_STR("path", path));
+Json_spew_json(Obj *dump, Folder *folder, const CharBuf *path) {
+ bool_t result = (bool_t)Host_callback_i64(JSON, "spew_json", 3,
+ ARG_OBJ("dump", dump),
+ ARG_OBJ("folder", folder),
+ ARG_STR("path", path));
if (!result) { ERR_ADD_FRAME(Err_get_error()); }
return result;
}
Obj*
-Json_slurp_json(Folder *folder, const CharBuf *path)
-{
- Obj *dump = Host_callback_obj(JSON, "slurp_json", 2,
- ARG_OBJ("folder", folder), ARG_STR("path", path));
+Json_slurp_json(Folder *folder, const CharBuf *path) {
+ Obj *dump = Host_callback_obj(JSON, "slurp_json", 2,
+ ARG_OBJ("folder", folder),
+ ARG_STR("path", path));
if (!dump) { ERR_ADD_FRAME(Err_get_error()); }
return dump;
}
CharBuf*
-Json_to_json(Obj *dump)
-{
+Json_to_json(Obj *dump) {
return Host_callback_str(JSON, "to_json", 1,
- ARG_OBJ("dump", dump));
+ ARG_OBJ("dump", dump));
}
Obj*
-Json_from_json(CharBuf *json)
-{
- return Host_callback_obj(JSON, "from_json", 1,
- ARG_STR("json", json));
+Json_from_json(CharBuf *json) {
+ return Host_callback_obj(JSON, "from_json", 1,
+ ARG_STR("json", json));
}
void
-Json_set_tolerant(bool_t tolerant)
-{
+Json_set_tolerant(bool_t tolerant) {
Host_callback(JSON, "set_tolerant", 1,
- ARG_I32("tolerant", tolerant));
+ ARG_I32("tolerant", tolerant));
}
Modified: incubator/lucy/trunk/perl/xs/Lucy/Util/StringHelper.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/Lucy/Util/StringHelper.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/Lucy/Util/StringHelper.c (original)
+++ incubator/lucy/trunk/perl/xs/Lucy/Util/StringHelper.c Sun May 1 23:50:24 2011
@@ -19,8 +19,7 @@
// TODO: replace with code from ICU in common/ucnv_u8.c.
chy_bool_t
-lucy_StrHelp_utf8_valid(const char *ptr, size_t size)
-{
+lucy_StrHelp_utf8_valid(const char *ptr, size_t size) {
const U8 *uptr = (const U8*)ptr;
return size == 0 ? true : !!is_utf8_string(uptr, size);
}
Modified: incubator/lucy/trunk/perl/xs/XSBind.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/XSBind.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/XSBind.c (original)
+++ incubator/lucy/trunk/perl/xs/XSBind.c Sun May 1 23:50:24 2011
@@ -39,14 +39,13 @@ static SV*
S_cfish_hash_to_perl_hash(cfish_Hash *hash);
cfish_Obj*
-XSBind_new_blank_obj(SV *either_sv)
-{
+XSBind_new_blank_obj(SV *either_sv) {
cfish_VTable *vtable;
// Get a VTable.
- if ( sv_isobject(either_sv)
+ if (sv_isobject(either_sv)
&& sv_derived_from(either_sv, "Lucy::Object::Obj")
- ) {
+ ) {
// Use the supplied object's VTable.
IV iv_ptr = SvIV(SvRV(either_sv));
cfish_Obj *self = INT2PTR(cfish_Obj*, iv_ptr);
@@ -65,8 +64,7 @@ XSBind_new_blank_obj(SV *either_sv)
}
cfish_Obj*
-XSBind_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation)
-{
+XSBind_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation) {
cfish_Obj *retval = XSBind_maybe_sv_to_cfish_obj(sv, vtable, allocation);
if (!retval) {
THROW(CFISH_ERR, "Not a %o", Cfish_VTable_Get_Name(vtable));
@@ -75,24 +73,22 @@ XSBind_sv_to_cfish_obj(SV *sv, cfish_VTa
}
cfish_Obj*
-XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation)
-{
+XSBind_maybe_sv_to_cfish_obj(SV *sv, cfish_VTable *vtable, void *allocation) {
cfish_Obj *retval = NULL;
if (XSBind_sv_defined(sv)) {
- if ( sv_isobject(sv)
- && sv_derived_from(sv,
- (char*)Cfish_CB_Get_Ptr8(Cfish_VTable_Get_Name(vtable)))
- ) {
+ if (sv_isobject(sv)
+ && sv_derived_from(sv, (char*)Cfish_CB_Get_Ptr8(Cfish_VTable_Get_Name(vtable)))
+ ) {
// Unwrap a real Clownfish object.
- IV tmp = SvIV( SvRV(sv) );
+ IV tmp = SvIV(SvRV(sv));
retval = INT2PTR(cfish_Obj*, tmp);
}
- else if ( allocation &&
- ( vtable == CFISH_ZOMBIECHARBUF
- || vtable == CFISH_VIEWCHARBUF
- || vtable == CFISH_CHARBUF
- || vtable == CFISH_OBJ)
- ) {
+ else if (allocation &&
+ (vtable == CFISH_ZOMBIECHARBUF
+ || vtable == CFISH_VIEWCHARBUF
+ || vtable == CFISH_CHARBUF
+ || vtable == CFISH_OBJ)
+ ) {
// Wrap the string from an ordinary Perl scalar inside a
// ZombieCharBuf.
STRLEN size;
@@ -110,7 +106,7 @@ XSBind_maybe_sv_to_cfish_obj(SV *sv, cfi
retval = (cfish_Obj*)S_perl_hash_to_cfish_hash((HV*)inner);
}
- if(retval) {
+ if (retval) {
// Mortalize the converted object -- which is somewhat
// dangerous, but is the only way to avoid requiring that the
// caller take responsibility for a refcount.
@@ -125,8 +121,7 @@ XSBind_maybe_sv_to_cfish_obj(SV *sv, cfi
}
SV*
-XSBind_cfish_to_perl(cfish_Obj *obj)
-{
+XSBind_cfish_to_perl(cfish_Obj *obj) {
if (obj == NULL) {
return newSV(0);
}
@@ -163,8 +158,7 @@ XSBind_cfish_to_perl(cfish_Obj *obj)
}
cfish_Obj*
-XSBind_perl_to_cfish(SV *sv)
-{
+XSBind_perl_to_cfish(SV *sv) {
cfish_Obj *retval = NULL;
if (XSBind_sv_defined(sv)) {
@@ -177,9 +171,9 @@ XSBind_perl_to_cfish(SV *sv)
else if (SvTYPE(inner) == SVt_PVHV) {
retval = (cfish_Obj*)S_perl_hash_to_cfish_hash((HV*)inner);
}
- else if ( sv_isobject(sv)
+ else if (sv_isobject(sv)
&& sv_derived_from(sv, "Lucy::Object::Obj")
- ) {
+ ) {
IV tmp = SvIV(inner);
retval = INT2PTR(cfish_Obj*, tmp);
(void)LUCY_INCREF(retval);
@@ -208,17 +202,15 @@ XSBind_perl_to_cfish(SV *sv)
}
SV*
-XSBind_bb_to_sv(const cfish_ByteBuf *bb)
-{
- return bb
- ? newSVpvn(Cfish_BB_Get_Buf(bb), Cfish_BB_Get_Size(bb))
- : newSV(0);
+XSBind_bb_to_sv(const cfish_ByteBuf *bb) {
+ return bb
+ ? newSVpvn(Cfish_BB_Get_Buf(bb), Cfish_BB_Get_Size(bb))
+ : newSV(0);
}
SV*
-XSBind_cb_to_sv(const cfish_CharBuf *cb)
-{
- if (!cb) {
+XSBind_cb_to_sv(const cfish_CharBuf *cb) {
+ if (!cb) {
return newSV(0);
}
else {
@@ -229,8 +221,7 @@ XSBind_cb_to_sv(const cfish_CharBuf *cb)
}
static cfish_Hash*
-S_perl_hash_to_cfish_hash(HV *phash)
-{
+S_perl_hash_to_cfish_hash(HV *phash) {
uint32_t num_keys = hv_iterinit(phash);
cfish_Hash *retval = cfish_Hash_new(num_keys);
cfish_ZombieCharBuf *key = CFISH_ZCB_WRAP_STR("", 0);
@@ -277,8 +268,7 @@ S_perl_hash_to_cfish_hash(HV *phash)
}
static cfish_VArray*
-S_perl_array_to_cfish_array(AV *parray)
-{
+S_perl_array_to_cfish_array(AV *parray) {
const uint32_t size = av_len(parray) + 1;
cfish_VArray *retval = cfish_VA_new(size);
uint32_t i;
@@ -297,8 +287,7 @@ S_perl_array_to_cfish_array(AV *parray)
}
static SV*
-S_cfish_array_to_perl_array(cfish_VArray *varray)
-{
+S_cfish_array_to_perl_array(cfish_VArray *varray) {
AV *perl_array = newAV();
uint32_t num_elems = Cfish_VA_Get_Size(varray);
@@ -323,8 +312,7 @@ S_cfish_array_to_perl_array(cfish_VArray
}
static SV*
-S_cfish_hash_to_perl_hash(cfish_Hash *hash)
-{
+S_cfish_hash_to_perl_hash(cfish_Hash *hash) {
HV *perl_hash = newHV();
SV *key_sv = newSV(1);
cfish_CharBuf *key;
@@ -340,13 +328,13 @@ S_cfish_hash_to_perl_hash(cfish_Hash *ha
// Recurse for each value.
SV *val_sv = XSBind_cfish_to_perl(val);
if (!Cfish_Obj_Is_A((cfish_Obj*)key, CFISH_CHARBUF)) {
- CFISH_THROW(CFISH_ERR,
- "Can't convert a key of class %o to a Perl hash key",
- Cfish_Obj_Get_Class_Name((cfish_Obj*)key));
+ CFISH_THROW(CFISH_ERR,
+ "Can't convert a key of class %o to a Perl hash key",
+ Cfish_Obj_Get_Class_Name((cfish_Obj*)key));
}
else {
STRLEN key_size = Cfish_CB_Get_Size(key);
- char *key_sv_ptr = SvGROW(key_sv, key_size + 1);
+ char *key_sv_ptr = SvGROW(key_sv, key_size + 1);
memcpy(key_sv_ptr, Cfish_CB_Get_Ptr8(key), key_size);
SvCUR_set(key_sv, key_size);
*SvEND(key_sv) = '\0';
@@ -359,8 +347,7 @@ S_cfish_hash_to_perl_hash(cfish_Hash *ha
}
void
-XSBind_enable_overload(void *pobj)
-{
+XSBind_enable_overload(void *pobj) {
SV *perl_obj = (SV*)pobj;
HV *stash = SvSTASH(SvRV(perl_obj));
#if (PERL_VERSION > 10)
@@ -373,9 +360,8 @@ XSBind_enable_overload(void *pobj)
static chy_bool_t
S_extract_from_sv(SV *value, void *target, const char *label,
- chy_bool_t required, int type, cfish_VTable *vtable,
- void *allocation)
-{
+ chy_bool_t required, int type, cfish_VTable *vtable,
+ void *allocation) {
chy_bool_t valid_assignment = false;
if (XSBind_sv_defined(value)) {
@@ -437,16 +423,18 @@ S_extract_from_sv(SV *value, void *targe
valid_assignment = true;
break;
case XSBIND_WANT_OBJ: {
- cfish_Obj *object = XSBind_maybe_sv_to_cfish_obj(value,
- vtable, allocation);
+ cfish_Obj *object
+ = XSBind_maybe_sv_to_cfish_obj(value, vtable,
+ allocation);
if (object) {
*((cfish_Obj**)target) = object;
valid_assignment = true;
}
else {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Invalid value for '%s' - not a %o", label,
- Cfish_VTable_Get_Name(vtable));
+ cfish_CharBuf *mess
+ = CFISH_MAKE_MESS(
+ "Invalid value for '%s' - not a %o",
+ label, Cfish_VTable_Get_Name(vtable));
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
@@ -455,11 +443,11 @@ S_extract_from_sv(SV *value, void *targe
case XSBIND_WANT_SV:
*((SV**)target) = value;
valid_assignment = true;
- break;
+ break;
default: {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Unrecognized type: %i32 for param '%s'",
- (int32_t)type, label);
+ cfish_CharBuf *mess
+ = CFISH_MAKE_MESS("Unrecognized type: %i32 for param '%s'",
+ (int32_t)type, label);
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
@@ -469,8 +457,8 @@ S_extract_from_sv(SV *value, void *targe
// Enforce that required params cannot be undef and must present valid
// values.
if (required && !valid_assignment) {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Missing required param %s", label);
+ cfish_CharBuf *mess = CFISH_MAKE_MESS("Missing required param %s",
+ label);
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
@@ -479,17 +467,16 @@ S_extract_from_sv(SV *value, void *targe
}
chy_bool_t
-XSBind_allot_params(SV** stack, int32_t start, int32_t num_stack_elems,
- char* params_hash_name, ...)
-{
+XSBind_allot_params(SV** stack, int32_t start, int32_t num_stack_elems,
+ char* params_hash_name, ...) {
va_list args;
HV *params_hash = get_hv(params_hash_name, 0);
int32_t args_left = (num_stack_elems - start) / 2;
// Retrieve the params hash, which must be a package global.
if (params_hash == NULL) {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Can't find hash named %s", params_hash_name);
+ cfish_CharBuf *mess = CFISH_MAKE_MESS("Can't find hash named %s",
+ params_hash_name);
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
@@ -498,8 +485,9 @@ XSBind_allot_params(SV** stack, int32_t
// args.
if (num_stack_elems == start) { return true; }
if ((num_stack_elems - start) % 2 != 0) {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Expecting hash-style params, got odd number of args");
+ cfish_CharBuf *mess
+ = CFISH_MAKE_MESS(
+ "Expecting hash-style params, got odd number of args");
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
@@ -510,15 +498,15 @@ XSBind_allot_params(SV** stack, int32_t
STRLEN key_len;
const char *key = SvPV(key_sv, key_len); // assume ASCII labels
if (!hv_exists(params_hash, key, key_len)) {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Invalid parameter: '%s'", key);
+ cfish_CharBuf *mess
+ = CFISH_MAKE_MESS("Invalid parameter: '%s'", key);
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
}
void *target;
- va_start(args, params_hash_name);
+ va_start(args, params_hash_name);
while (args_left && NULL != (target = va_arg(args, void*))) {
char *label = va_arg(args, char*);
int label_len = va_arg(args, int);
@@ -536,8 +524,9 @@ XSBind_allot_params(SV** stack, int32_t
if (SvCUR(key_sv) == (STRLEN)label_len) {
if (memcmp(SvPVX(key_sv), label, label_len) == 0) {
SV *value = stack[tick + 1];
- got_arg = S_extract_from_sv(value, target, label,
- required, type, vtable, allocation);
+ got_arg = S_extract_from_sv(value, target, label,
+ required, type, vtable,
+ allocation);
if (!got_arg) {
CFISH_ERR_ADD_FRAME(cfish_Err_get_error());
return false;
@@ -550,8 +539,8 @@ XSBind_allot_params(SV** stack, int32_t
// Enforce required params.
if (required && !got_arg) {
- cfish_CharBuf *mess = CFISH_MAKE_MESS(
- "Missing required parameter: '%s'", label);
+ cfish_CharBuf *mess
+ = CFISH_MAKE_MESS("Missing required parameter: '%s'", label);
cfish_Err_set_error(cfish_Err_new(mess));
return false;
}
Modified: incubator/lucy/trunk/perl/xs/XSBind.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/xs/XSBind.h?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/xs/XSBind.h (original)
+++ incubator/lucy/trunk/perl/xs/XSBind.h Sun May 1 23:50:24 2011
@@ -51,8 +51,7 @@ cfish_XSBind_new_blank_obj(SV *either_sv
* own.
*/
static CHY_INLINE chy_bool_t
-cfish_XSBind_sv_defined(SV *sv)
-{
+cfish_XSBind_sv_defined(SV *sv) {
if (!sv || !SvANY(sv)) { return false; }
if (SvGMAGICAL(sv)) { mg_get(sv); }
return SvOK(sv);
@@ -83,8 +82,7 @@ cfish_XSBind_maybe_sv_to_cfish_obj(SV *s
* responsibility.
*/
static CHY_INLINE SV*
-cfish_XSBind_cfish_obj_to_sv(cfish_Obj *obj)
-{
+cfish_XSBind_cfish_obj_to_sv(cfish_Obj *obj) {
return obj ? (SV*)Cfish_Obj_To_Host(obj) : newSV(0);
}
@@ -97,8 +95,7 @@ cfish_XSBind_cfish_obj_to_sv(cfish_Obj *
* refcount, e.g. a call to a constructor.
*/
static CHY_INLINE SV*
-cfish_XSBind_cfish_obj_to_sv_noinc(cfish_Obj *obj)
-{
+cfish_XSBind_cfish_obj_to_sv_noinc(cfish_Obj *obj) {
SV *retval;
if (obj) {
retval = (SV*)Cfish_Obj_To_Host(obj);
@@ -205,8 +202,8 @@ cfish_XSBind_enable_overload(void *pobj)
* @return true on success, false on failure (sets Err_error).
*/
chy_bool_t
-cfish_XSBind_allot_params(SV** stack, int32_t start,
- int32_t num_stack_elems,
+cfish_XSBind_allot_params(SV** stack, int32_t start,
+ int32_t num_stack_elems,
char* params_hash_name, ...);
#define XSBIND_WANT_I8 0x1
@@ -220,8 +217,8 @@ cfish_XSBind_allot_params(SV** stack, in
#define XSBIND_WANT_BOOL 0x9
#define XSBIND_WANT_F32 0xA
#define XSBIND_WANT_F64 0xB
-#define XSBIND_WANT_OBJ 0xC
-#define XSBIND_WANT_SV 0xD
+#define XSBIND_WANT_OBJ 0xC
+#define XSBIND_WANT_SV 0xD
#if (CHY_SIZEOF_CHAR == 1)
#define XSBIND_WANT_CHAR XSBIND_WANT_I8
@@ -310,11 +307,11 @@ cfish_XSBind_allot_params(SV** stack, in
#define XSBind_allot_params cfish_XSBind_allot_params
#define ALLOT_I8 XSBIND_ALLOT_I8
#define ALLOT_I16 XSBIND_ALLOT_I16
-#define ALLOT_I32 XSBIND_ALLOT_I32
+#define ALLOT_I32 XSBIND_ALLOT_I32
#define ALLOT_I64 XSBIND_ALLOT_I64
#define ALLOT_U8 XSBIND_ALLOT_U8
#define ALLOT_U16 XSBIND_ALLOT_U16
-#define ALLOT_U32 XSBIND_ALLOT_U32
+#define ALLOT_U32 XSBIND_ALLOT_U32
#define ALLOT_U64 XSBIND_ALLOT_U64
#define ALLOT_BOOL XSBIND_ALLOT_BOOL
#define ALLOT_CHAR XSBIND_ALLOT_CHAR
@@ -322,7 +319,7 @@ cfish_XSBind_allot_params(SV** stack, in
#define ALLOT_INT XSBIND_ALLOT_INT
#define ALLOT_LONG XSBIND_ALLOT_LONG
#define ALLOT_SIZE_T XSBIND_ALLOT_SIZE_T
-#define ALLOT_F32 XSBIND_ALLOT_F32
+#define ALLOT_F32 XSBIND_ALLOT_F32
#define ALLOT_F64 XSBIND_ALLOT_F64
#define ALLOT_OBJ XSBIND_ALLOT_OBJ
#define ALLOT_SV XSBIND_ALLOT_SV