lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [04/11] git commit: refs/heads/cfish-string-prep1 - Fix Perl typemap for non-const Strings
Date Sat, 28 Sep 2013 17:33:04 GMT
Fix Perl typemap for non-const Strings


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/672419f9
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/672419f9
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/672419f9

Branch: refs/heads/cfish-string-prep1
Commit: 672419f928877c75fcecc3e600364bfc4f4a5e4f
Parents: 3accd4d
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Sat Sep 28 17:08:15 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 28 17:08:15 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCPerlTypeMap.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/672419f9/clownfish/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerlTypeMap.c b/clownfish/compiler/src/CFCPerlTypeMap.c
index 6ce222f..32fbc53 100644
--- a/clownfish/compiler/src/CFCPerlTypeMap.c
+++ b/clownfish/compiler/src/CFCPerlTypeMap.c
@@ -275,10 +275,19 @@ CFCPerlTypeMap_write_xs_typemap(CFCHierarchy *hierarchy) {
 
         start = CFCUtil_cat(start, full_struct_sym, "*\t", vtable_var, "_\n",
                             NULL);
+        const char *allocation;
+        if (strcmp(full_struct_sym, "cfish_String") == 0) {
+            // Share buffers rather than copy between Perl scalars and
+            // Clownfish string types.
+            allocation = "alloca(cfish_SStr_size())";
+        }
+        else {
+            allocation = "NULL";
+        }
         input = CFCUtil_cat(input, vtable_var, "_\n"
                             "    $var = (", full_struct_sym,
                             "*)XSBind_sv_to_cfish_obj($arg, ", vtable_var,
-                            ", NULL);\n\n", NULL);
+                            ", ", allocation, ");\n\n", NULL);
 
         output = CFCUtil_cat(output, vtable_var, "_\n"
                              "    $arg = (SV*)CFISH_Obj_To_Host((cfish_Obj*)$var);\n"


Mime
View raw message