Eliminate Clownfish::Host usage by Lucy.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/54e5918c Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/54e5918c Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/54e5918c Branch: refs/heads/master Commit: 54e5918c946f917c9dcdd6338dadeaa23c470c58 Parents: 04ac681 Author: Marvin Humphrey <[email protected]> Authored: Wed Nov 14 19:11:24 2012 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Fri Nov 16 16:54:16 2012 -0800 ---------------------------------------------------------------------- perl/xs/Lucy/Analysis/RegexTokenizer.c | 30 +++++++++++++++++++++----- perl/xs/Lucy/Store/FSFolder.c | 26 +++++++++++++++++------ 2 files changed, 43 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/54e5918c/perl/xs/Lucy/Analysis/RegexTokenizer.c ---------------------------------------------------------------------- diff --git a/perl/xs/Lucy/Analysis/RegexTokenizer.c b/perl/xs/Lucy/Analysis/RegexTokenizer.c index ea5ef0b..274b347 100644 --- a/perl/xs/Lucy/Analysis/RegexTokenizer.c +++ b/perl/xs/Lucy/Analysis/RegexTokenizer.c @@ -21,10 +21,12 @@ #include "Lucy/Analysis/RegexTokenizer.h" #include "Lucy/Analysis/Token.h" #include "Lucy/Analysis/Inversion.h" -#include "Clownfish/Host.h" #include "Clownfish/Util/Memory.h" #include "Clownfish/Util/StringHelper.h" +static SV* +S_compile_token_re(const cfish_CharBuf *pattern); + static void S_set_token_re_but_not_pattern(lucy_RegexTokenizer *self, void *token_re); @@ -34,8 +36,6 @@ S_set_pattern_from_token_re(lucy_RegexTokenizer *self, void *token_re); lucy_RegexTokenizer* lucy_RegexTokenizer_init(lucy_RegexTokenizer *self, const lucy_CharBuf *pattern) { - SV *token_re_sv; - lucy_Analyzer_init((lucy_Analyzer*)self); #define DEFAULT_PATTERN "\\w+(?:['\\x{2019}]\\w+)*" if (pattern) { @@ -53,15 +53,33 @@ lucy_RegexTokenizer_init(lucy_RegexTokenizer *self, } // 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)); + SV *token_re_sv = S_compile_token_re(self->pattern); S_set_token_re_but_not_pattern(self, SvRV(token_re_sv)); SvREFCNT_dec(token_re_sv); return self; } +static SV* +S_compile_token_re(const cfish_CharBuf *pattern) { + dSP; + ENTER; + SAVETMPS; + EXTEND(SP, 2); + PUSHMARK(SP); + PUSHmortal; + XPUSHs(XSBind_cb_to_sv(pattern)); + PUTBACK; + call_pv("Lucy::Analysis::RegexTokenizer::compile_token_re", G_SCALAR); + SPAGAIN; + SV *token_re_sv = POPs; + SvREFCNT_inc(token_re_sv); + PUTBACK; + FREETMPS; + LEAVE; + return token_re_sv; +} + static void S_set_token_re_but_not_pattern(lucy_RegexTokenizer *self, void *token_re) { #if (PERL_VERSION > 10) http://git-wip-us.apache.org/repos/asf/lucy/blob/54e5918c/perl/xs/Lucy/Store/FSFolder.c ---------------------------------------------------------------------- diff --git a/perl/xs/Lucy/Store/FSFolder.c b/perl/xs/Lucy/Store/FSFolder.c index 42e5b56..433d6b7 100644 --- a/perl/xs/Lucy/Store/FSFolder.c +++ b/perl/xs/Lucy/Store/FSFolder.c @@ -14,14 +14,26 @@ * limitations under the License. */ -#include "Lucy/Util/ToolSet.h" -#include "Clownfish/Host.h" +#include "XSBind.h" #include "Lucy/Store/FSFolder.h" -CharBuf* -FSFolder_absolutify(const CharBuf *path) { - - return Host_callback_str(FSFOLDER, "absolutify", 1, - ARG_STR("path", path)); +cfish_CharBuf* +lucy_FSFolder_absolutify(const cfish_CharBuf *path) { + dSP; + ENTER; + SAVETMPS; + EXTEND(SP, 2); + PUSHMARK(SP); + PUSHmortal; + mPUSHs(XSBind_cb_to_sv(path)); + PUTBACK; + call_pv("Lucy::Store::FSFolder::absolutify", G_SCALAR); + SPAGAIN; + cfish_CharBuf *absolutified + = (cfish_CharBuf*)XSBind_perl_to_cfish(POPs); + PUTBACK; + FREETMPS; + LEAVE; + return absolutified; }
