Repository: lucy Updated Branches: refs/heads/master dc3a17e88 -> 0d4f3465b
Adjust for changes to labeled param handling Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/0d4f3465 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/0d4f3465 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/0d4f3465 Branch: refs/heads/master Commit: 0d4f3465b424212ee1b029e29c86a1ed771b59d0 Parents: dc3a17e Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Thu Nov 26 14:51:15 2015 +0100 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Thu Nov 26 19:21:12 2015 +0100 ---------------------------------------------------------------------- perl/buildlib/Lucy/Build/Binding/Analysis.pm | 59 +++++++++++------------ perl/buildlib/Lucy/Build/Binding/Document.pm | 43 +++++++++-------- perl/buildlib/Lucy/Build/Binding/Index.pm | 39 +++++++-------- perl/buildlib/Lucy/Build/Binding/Object.pm | 16 +++--- perl/buildlib/Lucy/Build/Binding/Search.pm | 18 +++---- 5 files changed, 87 insertions(+), 88 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/0d4f3465/perl/buildlib/Lucy/Build/Binding/Analysis.pm ---------------------------------------------------------------------- diff --git a/perl/buildlib/Lucy/Build/Binding/Analysis.pm b/perl/buildlib/Lucy/Build/Binding/Analysis.pm index 22f101f..c73ff77 100644 --- a/perl/buildlib/Lucy/Build/Binding/Analysis.pm +++ b/perl/buildlib/Lucy/Build/Binding/Analysis.pm @@ -127,22 +127,20 @@ SV* new(...) CODE: { + static const XSBind_ParamSpec param_specs[1] = { + XSBIND_PARAM("text", false) + }; + int32_t locations[1]; + SV *text_sv = NULL; lucy_Token *starter_token = NULL; - // parse params, only if there's more than one arg - if (items > 1) { - SV *text_sv = NULL; - bool args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&text_sv, "text", 4, false), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } - if (XSBind_sv_defined(aTHX_ text_sv)) { - STRLEN len; - char *text = SvPVutf8(text_sv, len); - starter_token = lucy_Token_new(text, len, 0, len, 1.0, 1); - } + + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 1); + + text_sv = locations[0] < items ? ST(locations[0]) : NULL; + if (XSBind_sv_defined(aTHX_ text_sv)) { + STRLEN len; + char *text = SvPVutf8(text_sv, len); + starter_token = lucy_Token_new(text, len, 0, len, 1.0, 1); } RETVAL = CFISH_OBJ_TO_SV_NOINC(lucy_Inversion_new(starter_token)); @@ -419,7 +417,14 @@ new(either_sv, ...) SV *either_sv; CODE: { - SV *text_sv = NULL; + static const XSBind_ParamSpec param_specs[5] = { + XSBIND_PARAM("text", true), + XSBIND_PARAM("start_offset", true), + XSBIND_PARAM("end_offset", true), + XSBIND_PARAM("pos_inc", false), + XSBIND_PARAM("boost", false) + }; + int32_t locations[5]; uint32_t start_off = 0; uint32_t end_off = 0; int32_t pos_inc = 1; @@ -427,21 +432,15 @@ CODE: STRLEN len = 0; char *text = NULL; lucy_Token *self = NULL; - bool args_ok; - - args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&text_sv, "text", 4, true), - ALLOT_U32(&start_off, "start_offset", 12, true), - ALLOT_U32(&end_off, "end_offset", 10, true), - ALLOT_I32(&pos_inc, "pos_inc", 7, false), - ALLOT_F32(&boost, "boost", 5, false), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } - text = SvPVutf8(text_sv, len); + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 5); + + text = SvPVutf8(ST(locations[0]), len); + start_off = (uint32_t)SvUV(ST(locations[1])); + end_off = (uint32_t)SvUV(ST(locations[2])); + pos_inc = locations[3] < items ? (int32_t)SvIV(ST(locations[3])) : 1; + boost = locations[4] < items ? (float)SvNV(ST(locations[4])) : 1.0f; + self = (lucy_Token*)XSBind_new_blank_obj(aTHX_ either_sv); lucy_Token_init(self, text, len, start_off, end_off, boost, pos_inc); http://git-wip-us.apache.org/repos/asf/lucy/blob/0d4f3465/perl/buildlib/Lucy/Build/Binding/Document.pm ---------------------------------------------------------------------- diff --git a/perl/buildlib/Lucy/Build/Binding/Document.pm b/perl/buildlib/Lucy/Build/Binding/Document.pm index c4d559c..605a1e9 100644 --- a/perl/buildlib/Lucy/Build/Binding/Document.pm +++ b/perl/buildlib/Lucy/Build/Binding/Document.pm @@ -82,20 +82,20 @@ new(either_sv, ...) SV *either_sv; CODE: { + static const XSBind_ParamSpec param_specs[2] = { + XSBIND_PARAM("fields", false), + XSBIND_PARAM("doc_id", false) + }; + int32_t locations[2]; SV* fields_sv = NULL; HV *fields = NULL; int32_t doc_id = 0; lucy_Doc *self = NULL; - bool args_ok; - - args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&fields_sv, "fields", 6, false), - ALLOT_I32(&doc_id, "doc_id", 6, false), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } + + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 2); + + fields_sv = locations[0] < items ? ST(locations[0]) : NULL; + doc_id = locations[1] < items ? (int32_t)SvIV(ST(locations[1])) : 0; if (fields_sv && XSBind_sv_defined(aTHX_ fields_sv)) { if (SvROK(fields_sv)) { @@ -172,22 +172,23 @@ new(either_sv, ...) SV *either_sv; CODE: { + static const XSBind_ParamSpec param_specs[3] = { + XSBIND_PARAM("fields", false), + XSBIND_PARAM("doc_id", false), + XSBIND_PARAM("score", false) + }; + int32_t locations[3]; SV *fields_sv = NULL; HV *fields = NULL; int32_t doc_id = 0; float score = 0.0f; lucy_HitDoc *self = NULL; - bool args_ok; - - args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&fields_sv, "fields", 6, false), - ALLOT_I32(&doc_id, "doc_id", 6, false), - ALLOT_F32(&score, "score", 5, false), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } + + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 3); + + fields_sv = locations[0] < items ? ST(locations[0]) : NULL; + doc_id = locations[1] < items ? (int32_t)SvIV(ST(locations[1])) : 0; + score = locations[2] < items ? (float)SvNV(ST(locations[2])) : 0.0f; if (fields_sv && XSBind_sv_defined(aTHX_ fields_sv)) { if (SvROK(fields_sv)) { http://git-wip-us.apache.org/repos/asf/lucy/blob/0d4f3465/perl/buildlib/Lucy/Build/Binding/Index.pm ---------------------------------------------------------------------- diff --git a/perl/buildlib/Lucy/Build/Binding/Index.pm b/perl/buildlib/Lucy/Build/Binding/Index.pm index 9d27fef..e644a95 100644 --- a/perl/buildlib/Lucy/Build/Binding/Index.pm +++ b/perl/buildlib/Lucy/Build/Binding/Index.pm @@ -394,18 +394,17 @@ PPCODE: if (items == 2) { doc_sv = ST(1); } - else if (items > 2) { - bool args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&doc_sv, "doc", 3, true), - ALLOT_F32(&boost, "boost", 5, false), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } - } - else if (items == 1) { - CFISH_THROW(CFISH_ERR, "Missing required argument 'doc'"); + else { + static const XSBind_ParamSpec param_specs[2] = { + XSBIND_PARAM("doc", true), + XSBIND_PARAM("boost", false) + }; + int32_t locations[2]; + + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 2); + + doc_sv = ST(locations[0]); + if (locations[1] < items) { boost = (float)SvNV(ST(locations[1])); } } // Either get a Doc or use the stock doc. @@ -778,14 +777,16 @@ value(self, ...) lucy_SortCache *self; CODE: { + static const XSBind_ParamSpec param_specs[1] = { + XSBIND_PARAM("ord", false) + }; + int32_t locations[1]; int32_t ord = 0; - bool args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_I32(&ord, "ord", 3, false), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } + + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 1); + + ord = locations[0] < items ? (int32_t)SvIV(ST(locations[0])) : 0; + { cfish_Obj *value = LUCY_SortCache_Value(self, ord); RETVAL = XSBind_cfish_to_perl(aTHX_ value); http://git-wip-us.apache.org/repos/asf/lucy/blob/0d4f3465/perl/buildlib/Lucy/Build/Binding/Object.pm ---------------------------------------------------------------------- diff --git a/perl/buildlib/Lucy/Build/Binding/Object.pm b/perl/buildlib/Lucy/Build/Binding/Object.pm index b29eef9..5ac4db1 100644 --- a/perl/buildlib/Lucy/Build/Binding/Object.pm +++ b/perl/buildlib/Lucy/Build/Binding/Object.pm @@ -63,19 +63,17 @@ new(either_sv, ...) SV *either_sv; CODE: { + static const XSBind_ParamSpec param_specs[1] = { + XSBIND_PARAM("ints", true) + }; + int32_t locations[1]; SV *ints_sv = NULL; AV *ints_av = NULL; lucy_I32Array *self = NULL; - bool args_ok; - - args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&ints_sv, "ints", 4, true), - NULL); - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 1); + + ints_sv = ST(locations[0]); if (SvROK(ints_sv)) { ints_av = (AV*)SvRV(ints_sv); } http://git-wip-us.apache.org/repos/asf/lucy/blob/0d4f3465/perl/buildlib/Lucy/Build/Binding/Search.pm ---------------------------------------------------------------------- diff --git a/perl/buildlib/Lucy/Build/Binding/Search.pm b/perl/buildlib/Lucy/Build/Binding/Search.pm index e886872..46beef5 100644 --- a/perl/buildlib/Lucy/Build/Binding/Search.pm +++ b/perl/buildlib/Lucy/Build/Binding/Search.pm @@ -370,23 +370,23 @@ new(either_sv, ...) SV *either_sv; CODE: { + static const XSBind_ParamSpec param_specs[2] = { + XSBIND_PARAM("type", true), + XSBIND_PARAM("value", false) + }; + int32_t locations[2]; SV *type_sv = NULL; SV *value_sv = NULL; const char *type_str = NULL; cfish_Obj *value = NULL; uint32_t type = 0; lucy_ParserElem *self = NULL; - bool args_ok; - args_ok - = XSBind_allot_params(aTHX_ &(ST(0)), 1, items, - ALLOT_SV(&type_sv, "type", 4, true), - ALLOT_SV(&value_sv, "value", 5, false), - NULL); + XSBind_locate_args(aTHX_ &ST(0), 1, items, param_specs, locations, 2); + + type_sv = ST(locations[0]); + value_sv = locations[1] < items ? ST(locations[1]) : NULL; - if (!args_ok) { - CFISH_RETHROW(CFISH_INCREF(cfish_Err_get_error())); - } type_str = SvPVutf8_nolen(type_sv); if (strcmp(type_str, "OPEN_PAREN") == 0) {