Updated Branches: refs/heads/kill_clownfish_host [created] 973ef6901
Remove Clownfish::Host. Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/973ef690 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/973ef690 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/973ef690 Branch: refs/heads/kill_clownfish_host Commit: 973ef6901ba75ace150b212f01e4d1b9cd96d5f8 Parents: 5be4007 Author: Marvin Humphrey <[email protected]> Authored: Wed Nov 14 20:02:25 2012 -0800 Committer: Marvin Humphrey <[email protected]> Committed: Wed Nov 14 20:14:55 2012 -0800 ---------------------------------------------------------------------- clownfish/compiler/src/CFCBindAliases.c | 7 - clownfish/compiler/src/CFCPerl.c | 1 - core/Clownfish/Host.cfh | 108 ----------- core/Lucy/Util/Json.c | 1 - perl/lib/Clownfish/Host.pm | 25 --- perl/lib/Lucy.pm | 11 -- perl/xs/Clownfish/Host.c | 246 -------------------------- perl/xs/Lucy/Index/DocReader.c | 1 - 8 files changed, 0 insertions(+), 400 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/clownfish/compiler/src/CFCBindAliases.c ---------------------------------------------------------------------- diff --git a/clownfish/compiler/src/CFCBindAliases.c b/clownfish/compiler/src/CFCBindAliases.c index a24baf5..9a4fde6 100644 --- a/clownfish/compiler/src/CFCBindAliases.c +++ b/clownfish/compiler/src/CFCBindAliases.c @@ -111,13 +111,6 @@ struct alias aliases[] = { {"Cfish_VTable_Get_Name", "Lucy_VTable_Get_Name"}, {"Cfish_VTable_Make_Obj", "Lucy_VTable_Make_Obj"}, - {"cfish_Host_callback", "lucy_Host_callback"}, - {"cfish_Host_callback_f64", "lucy_Host_callback_f64"}, - {"cfish_Host_callback_host", "lucy_Host_callback_host"}, - {"cfish_Host_callback_i64", "lucy_Host_callback_i64"}, - {"cfish_Host_callback_obj", "lucy_Host_callback_obj"}, - {"cfish_Host_callback_str", "lucy_Host_callback_str"}, - {"CFISH_USE_SHORT_NAMES", "LUCY_USE_SHORT_NAMES"}, {NULL, NULL} http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/clownfish/compiler/src/CFCPerl.c ---------------------------------------------------------------------- diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c index 5f664e3..814dbec 100644 --- a/clownfish/compiler/src/CFCPerl.c +++ b/clownfish/compiler/src/CFCPerl.c @@ -374,7 +374,6 @@ S_xs_file_contents(CFCPerl *self, const char *generated_xs, "#include \"parcel.h\"\n" "#include \"%s\"\n" "\n" - "#include \"Clownfish/Host.h\"\n" "#include \"Clownfish/Util/Memory.h\"\n" "#include \"Clownfish/Util/StringHelper.h\"\n" "\n" http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/core/Clownfish/Host.cfh ---------------------------------------------------------------------- diff --git a/core/Clownfish/Host.cfh b/core/Clownfish/Host.cfh deleted file mode 100644 index 203c6bb..0000000 --- a/core/Clownfish/Host.cfh +++ /dev/null @@ -1,108 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel Lucy; - -__C__ -#define CFISH_HOST_ARGTYPE_I32 (int32_t)0x00000001 -#define CFISH_HOST_ARGTYPE_I64 (int32_t)0x00000002 -#define CFISH_HOST_ARGTYPE_F32 (int32_t)0x00000003 -#define CFISH_HOST_ARGTYPE_F64 (int32_t)0x00000004 -#define CFISH_HOST_ARGTYPE_STR (int32_t)0x00000006 -#define CFISH_HOST_ARGTYPE_OBJ (int32_t)0x00000007 -#define CFISH_HOST_ARGTYPE_MASK 0x00000007 - -#define CFISH_ARG_I32(_label, _value) \ - CFISH_HOST_ARGTYPE_I32, (_label), ((int32_t)_value) -#define CFISH_ARG_I64(_label, _value) \ - CFISH_HOST_ARGTYPE_I64, (_label), ((int64_t)_value) -#define CFISH_ARG_I(_type, _label, _value) \ - (sizeof(_type) <= 4 ? CFISH_HOST_ARGTYPE_I32 : CFISH_HOST_ARGTYPE_I64), \ - (_label), (sizeof(_type) <= 4 ? (int32_t)_value : (int64_t)_value) -#define CFISH_ARG_F32(_label, _value) \ - CFISH_HOST_ARGTYPE_F32, (_label), ((double)_value) -#define CFISH_ARG_F64(_label, _value) \ - CFISH_HOST_ARGTYPE_F64, (_label), ((double)_value) -#define CFISH_ARG_STR(_label, _value) \ - CFISH_HOST_ARGTYPE_STR, (_label), ((lucy_CharBuf*)_value) -#define CFISH_ARG_OBJ(_label, _value) \ - CFISH_HOST_ARGTYPE_OBJ, (_label), ((lucy_Obj*)_value) - -#ifdef LUCY_USE_SHORT_NAMES - #define ARG_I32 CFISH_ARG_I32 - #define ARG_I64 CFISH_ARG_I64 - #define ARG_F32 CFISH_ARG_F32 - #define ARG_F64 CFISH_ARG_F64 - #define ARG_STR CFISH_ARG_STR - #define ARG_OBJ CFISH_ARG_OBJ -#endif - -__END_C__ - -/** Callbacks to the host environment. - * - * All the callback functions are variadic, and all are designed to take a - * series of arguments using the ARG_XXX macros. - * - * int32_t area = (int32_t)Host_callback_i64(self, "calc_area", 2, - * ARG_I32("length", len), ARG_I32("width", width)); - * - * The first argument is void* to avoid the need for tiresome casting to Obj*, - * but must always be a Clownfish object. - * - * If the invoker is a VTable, it will be used to make a class - * callback rather than an object callback. - */ -inert class Clownfish::Host { - - /** Invoke an object method in a void context. - */ - inert void - callback(void *self, const char *method, uint32_t num_args, ...); - - /** Invoke an object method, expecting an integer. - */ - inert int64_t - callback_i64(void *self, const char *method, uint32_t num_args, ...); - - /** Invoke an object method, expecting a 64-bit floating point return - * value. - */ - inert double - callback_f64(void *self, const char *method, uint32_t num_args, ...); - - /** Invoke an object method, expecting a Obj-derived object back, or - * possibly NULL. In order to ensure that the host environment doesn't - * reclaim the return value, it's refcount is increased by one, which the - * caller will have to deal with. - */ - inert incremented nullable Obj* - callback_obj(void *self, const char *method, uint32_t num_args, ...); - - /** Invoke an object method, expecting a host string of some kind back, - * which will be converted into a newly allocated CharBuf. - */ - inert incremented nullable CharBuf* - callback_str(void *self, const char *method, uint32_t num_args, ...); - - /** Invoke an object method, expecting a host data structure back. It's - * up to the caller to know how to process it. - */ - inert nullable void* - callback_host(void *self, const char *method, uint32_t num_args, ...); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/core/Lucy/Util/Json.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Util/Json.c b/core/Lucy/Util/Json.c index b06fe86..55c9482 100644 --- a/core/Lucy/Util/Json.c +++ b/core/Lucy/Util/Json.c @@ -20,7 +20,6 @@ #include "Lucy/Util/ToolSet.h" #include "Lucy/Util/Json.h" -#include "Clownfish/Host.h" #include "Lucy/Store/Folder.h" #include "Lucy/Store/InStream.h" #include "Lucy/Store/OutStream.h" http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/perl/lib/Clownfish/Host.pm ---------------------------------------------------------------------- diff --git a/perl/lib/Clownfish/Host.pm b/perl/lib/Clownfish/Host.pm deleted file mode 100644 index 2a76ba8..0000000 --- a/perl/lib/Clownfish/Host.pm +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -package Clownfish::Host; -use Lucy; -our $VERSION = '0.003000'; -$VERSION = eval $VERSION; - -1; - -__END__ - - http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/perl/lib/Lucy.pm ---------------------------------------------------------------------- diff --git a/perl/lib/Lucy.pm b/perl/lib/Lucy.pm index bb6b6ba..a35e8f0 100644 --- a/perl/lib/Lucy.pm +++ b/perl/lib/Lucy.pm @@ -470,17 +470,6 @@ sub error {$Clownfish::Err::error} } } -{ - package Clownfish::Host; - our $VERSION = '0.003000'; - $VERSION = eval $VERSION; - BEGIN { - if ( !__PACKAGE__->isa('Clownfish::Obj') ) { - push our @ISA, 'Clownfish::Obj'; - } - } -} - 1; __END__ http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/perl/xs/Clownfish/Host.c ---------------------------------------------------------------------- diff --git a/perl/xs/Clownfish/Host.c b/perl/xs/Clownfish/Host.c deleted file mode 100644 index 8616557..0000000 --- a/perl/xs/Clownfish/Host.c +++ /dev/null @@ -1,246 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "XSBind.h" - -#include "Clownfish/VTable.h" - -#include "Clownfish/Obj.h" -#include "Clownfish/Host.h" -#include "Clownfish/CharBuf.h" -#include "Clownfish/Err.h" -#include "Clownfish/Util/Memory.h" - -static SV* -S_do_callback_sv(void *vobj, const char *method, uint32_t num_args, - va_list args); - -// 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) { - lucy_Obj *obj = (lucy_Obj*)vobj; - SV *invoker; - dSP; - - uint32_t stack_slots_needed = num_args < 2 - ? 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. - invoker = XSBind_cb_to_sv(Lucy_VTable_Get_Name(vtable)); - } - else { - invoker = (SV*)Lucy_Obj_To_Host(obj); - } - - ENTER; - SAVETMPS; - PUSHMARK(SP); - PUSHs(sv_2mortal(invoker)); - - for (uint32_t 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)))); - } - 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))); - } - 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))); - } - 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); - } - } - - PUTBACK; -} - -void -lucy_Host_callback(void *vobj, const 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); - if (count != 0) { - CFISH_THROW(LUCY_ERR, "callback '%s' returned too many values: %i32", - method, (int32_t)count); - } - FREETMPS; - LEAVE; -} - -int64_t -lucy_Host_callback_i64(void *vobj, const char *method, uint32_t num_args, ...) { - va_list args; - SV *return_sv; - int64_t retval; - - va_start(args, num_args); - return_sv = S_do_callback_sv(vobj, method, num_args, args); - va_end(args); - if (sizeof(IV) == 8) { - retval = (int64_t)SvIV(return_sv); - } - else { - if (SvIOK(return_sv)) { - // It's already no more than 32 bits, so don't convert. - retval = SvIV(return_sv); - } - else { - // Maybe lossy. - double temp = SvNV(return_sv); - retval = (int64_t)temp; - } - } - - FREETMPS; - LEAVE; - - return retval; -} - -double -lucy_Host_callback_f64(void *vobj, const char *method, uint32_t num_args, ...) { - va_list args; - SV *return_sv; - double retval; - - va_start(args, num_args); - return_sv = S_do_callback_sv(vobj, method, num_args, args); - va_end(args); - retval = SvNV(return_sv); - - FREETMPS; - LEAVE; - - return retval; -} - -lucy_Obj* -lucy_Host_callback_obj(void *vobj, const char *method, uint32_t num_args, ...) { - va_list args; - SV *temp_retval; - lucy_Obj *retval = NULL; - - va_start(args, num_args); - temp_retval = S_do_callback_sv(vobj, method, num_args, args); - va_end(args); - - retval = XSBind_perl_to_cfish(temp_retval); - - FREETMPS; - LEAVE; - - return retval; -} - -lucy_CharBuf* -lucy_Host_callback_str(void *vobj, const char *method, uint32_t num_args, ...) { - va_list args; - SV *temp_retval; - lucy_CharBuf *retval = NULL; - - va_start(args, num_args); - temp_retval = S_do_callback_sv(vobj, method, num_args, args); - va_end(args); - - // Make a stringified copy. - if (temp_retval && XSBind_sv_defined(temp_retval)) { - STRLEN len; - char *ptr = SvPVutf8(temp_retval, len); - retval = lucy_CB_new_from_trusted_utf8(ptr, len); - } - - FREETMPS; - LEAVE; - - return retval; -} - -void* -lucy_Host_callback_host(void *vobj, const char *method, uint32_t num_args, ...) { - va_list args; - SV *retval; - - va_start(args, num_args); - retval = S_do_callback_sv(vobj, method, num_args, args); - va_end(args); - SvREFCNT_inc(retval); - - FREETMPS; - LEAVE; - - return retval; -} - -static SV* -S_do_callback_sv(void *vobj, const 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); - } - return_val = POPs; - PUTBACK; - return return_val; -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/973ef690/perl/xs/Lucy/Index/DocReader.c ---------------------------------------------------------------------- diff --git a/perl/xs/Lucy/Index/DocReader.c b/perl/xs/Lucy/Index/DocReader.c index 2be971a..6230e77 100644 --- a/perl/xs/Lucy/Index/DocReader.c +++ b/perl/xs/Lucy/Index/DocReader.c @@ -25,7 +25,6 @@ #include "Lucy/Plan/Schema.h" #include "Lucy/Plan/TextType.h" #include "Lucy/Plan/NumericType.h" -#include "Clownfish/Host.h" #include "Lucy/Store/InStream.h" lucy_HitDoc*
