You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/05/30 13:27:47 UTC
[08/12] lucy-clownfish git commit: Make XSBind_cfish_to_perl inline
Make XSBind_cfish_to_perl inline
Now XSBind_cfish_to_perl is nothing more than a null-safe wrapper
around Obj_To_Host.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/e5435615
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/e5435615
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/e5435615
Branch: refs/heads/master
Commit: e5435615d8f8a0132608fd9d90935b62a4f2f995
Parents: 4afe9a6
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 29 14:59:43 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Fri May 29 17:53:26 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlTypeMap.c | 6 ++----
runtime/perl/xs/XSBind.c | 12 +-----------
runtime/perl/xs/XSBind.h | 11 +++++------
3 files changed, 8 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e5435615/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlTypeMap.c b/compiler/src/CFCPerlTypeMap.c
index a07928c..795fdde 100644
--- a/compiler/src/CFCPerlTypeMap.c
+++ b/compiler/src/CFCPerlTypeMap.c
@@ -121,10 +121,8 @@ CFCPerlTypeMap_to_perl(CFCType *type, const char *cf_var) {
char *result = NULL;
if (CFCType_is_object(type)) {
- const char pattern[] =
- "(%s == NULL ?"
- " newSV(0) : XSBind_cfish_to_perl(aTHX_ (cfish_Obj*)%s))";
- result = CFCUtil_sprintf(pattern, cf_var, cf_var);
+ const char pattern[] = "XSBind_cfish_to_perl(aTHX_ (cfish_Obj*)%s)";
+ result = CFCUtil_sprintf(pattern, cf_var);
}
else if (CFCType_is_primitive(type)) {
// Convert from a primitive type to a Perl scalar.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e5435615/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.c b/runtime/perl/xs/XSBind.c
index 630febf..20cd377 100644
--- a/runtime/perl/xs/XSBind.c
+++ b/runtime/perl/xs/XSBind.c
@@ -136,16 +136,6 @@ XSBind_maybe_sv_to_cfish_obj(pTHX_ SV *sv, cfish_Class *klass,
return retval;
}
-SV*
-XSBind_cfish_to_perl(pTHX_ cfish_Obj *obj) {
- if (obj == NULL) {
- return newSV(0);
- }
- else {
- return (SV*)CFISH_Obj_To_Host(obj);
- }
-}
-
cfish_Obj*
XSBind_perl_to_cfish(pTHX_ SV *sv) {
cfish_Obj *retval = NULL;
@@ -978,7 +968,7 @@ CFISH_Vec_To_Host_IMP(cfish_Vector *self) {
}
else {
// Recurse for each value.
- SV *const val_sv = XSBind_cfish_to_perl(aTHX_ val);
+ SV *const val_sv = (SV*)CFISH_Obj_To_Host(val);
av_store(perl_array, i, val_sv);
}
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e5435615/runtime/perl/xs/XSBind.h
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.h b/runtime/perl/xs/XSBind.h
index f895854..465574d 100644
--- a/runtime/perl/xs/XSBind.h
+++ b/runtime/perl/xs/XSBind.h
@@ -116,13 +116,12 @@ cfish_XSBind_cfish_obj_to_sv_noinc(pTHX_ cfish_Obj *obj) {
#define CFISH_OBJ_TO_SV_NOINC(_obj) \
cfish_XSBind_cfish_obj_to_sv_noinc(aTHX_ (cfish_Obj*)_obj)
-/** Deep conversion of Clownfish objects to Perl objects -- Strings to UTF-8
- * SVs, Blobs to SVs, ByteBufs to SVs, Vectors to Perl array refs, Hashes to
- * Perl hashrefs, and any other object to a Perl object wrapping the Clownfish
- * Obj.
+/** Null-safe invocation of Obj_To_Host.
*/
-CFISH_VISIBLE SV*
-cfish_XSBind_cfish_to_perl(pTHX_ cfish_Obj *obj);
+static CFISH_INLINE SV*
+cfish_XSBind_cfish_to_perl(pTHX_ cfish_Obj *obj) {
+ return obj ? (SV*)CFISH_Obj_To_Host(obj) : newSV(0);
+}
/** Deep conversion of Perl data structures to Clownfish objects -- Perl hash
* to Hash, Perl array to Vector, Clownfish objects stripped of their