Repository: lucy-clownfish
Updated Branches:
  refs/heads/0.5 33651d757 -> 788087e7e


Fix some `unused` warnings in the Perl bindings.

Have the code generator emit some temp variables only if they are
needed.  Deploy one UNUSED_VAR macro.


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

Branch: refs/heads/0.5
Commit: 7ecc951e8575544ba070581f3754548d80b2d3df
Parents: 33651d7
Author: Marvin Humphrey <mar...@rectangular.com>
Authored: Wed Mar 16 00:35:55 2016 +0000
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Fri Mar 25 09:58:33 2016 +0100

----------------------------------------------------------------------
 compiler/src/CFCPerlConstructor.c               |  4 ++--
 compiler/src/CFCPerlMethod.c                    | 23 +++++++++++++++-----
 .../perl/buildlib/Clownfish/Build/Binding.pm    |  1 +
 3 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ecc951e/compiler/src/CFCPerlConstructor.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlConstructor.c 
b/compiler/src/CFCPerlConstructor.c
index c0c3a89..380cb08 100644
--- a/compiler/src/CFCPerlConstructor.c
+++ b/compiler/src/CFCPerlConstructor.c
@@ -118,7 +118,8 @@ CFCPerlConstructor_xsub_def(CFCPerlConstructor *self, 
CFCClass *klass) {
         unsigned num_params = num_vars - 1;
         items_check = "items < 1";
         param_specs = CFCPerlSub_build_param_specs((CFCPerlSub*)self, 1);
-        locs_decl   = CFCUtil_sprintf("    int32_t locations[%u];\n",
+        locs_decl   = CFCUtil_sprintf("    int32_t locations[%u];\n"
+                                      "    SV *sv;\n",
                                       num_params);
 
         const char *pattern =
@@ -146,7 +147,6 @@ CFCPerlConstructor_xsub_def(CFCPerlConstructor *self, 
CFCClass *klass) {
         "    dXSARGS;\n"
         "%s" // param_specs
         "%s" // locs_decl
-        "    SV *sv;\n"
         "%s" // arg_decls
         "    %s retval;\n"
         "\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ecc951e/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 911d51d..9e36d77 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -258,13 +258,18 @@ S_xsub_def_labeled_params(CFCPerlMethod *self, CFCClass 
*klass) {
         retval_decl = CFCUtil_sprintf("    %s retval;\n", return_type_c);
     }
 
+    const char *locations_sv = "";
+    if (num_vars > 1) {
+        locations_sv = "    SV *sv;\n";
+    }
+
     char pattern[] =
         "XS(%s);\n"
         "XS(%s) {\n"
         "    dXSARGS;\n"
         "%s"        // param_specs
         "    int32_t locations[%d];\n"
-        "    SV *sv;\n"
+        "%s" // locations_sv
         "%s"        // arg_decls
         "    %s method;\n"
         "%s"
@@ -286,8 +291,9 @@ S_xsub_def_labeled_params(CFCPerlMethod *self, CFCClass 
*klass) {
         "}\n";
     char *xsub_def
         = CFCUtil_sprintf(pattern, c_name, c_name, param_specs, num_vars - 1,
-                          arg_decls, meth_type_c, retval_decl, self_name,
-                          num_vars - 1, self_assign, arg_assigns, body);
+                          locations_sv, arg_decls, meth_type_c, retval_decl,
+                          self_name, num_vars - 1, self_assign, arg_assigns,
+                          body);
 
     FREEMEM(param_specs);
     FREEMEM(arg_decls);
@@ -342,6 +348,10 @@ S_xsub_def_positional_args(CFCPerlMethod *self, CFCClass 
*klass) {
                                        NULL);
         }
     }
+    const char *working_sv = "";
+    if (num_vars > 1) {
+        working_sv = "    SV *sv;\n";
+    }
 
     char *retval_decl;
     if (CFCType_is_void(return_type)) {
@@ -356,7 +366,7 @@ S_xsub_def_positional_args(CFCPerlMethod *self, CFCClass 
*klass) {
         "XS(%s);\n"
         "XS(%s) {\n"
         "    dXSARGS;\n"
-        "    SV *sv;\n"
+        "%s" // working_sv
         "%s" // arg_decls
         "    %s method;\n"
         "%s"
@@ -376,8 +386,9 @@ S_xsub_def_positional_args(CFCPerlMethod *self, CFCClass 
*klass) {
         "}\n";
     char *xsub
         = CFCUtil_sprintf(pattern, self->sub.c_name, self->sub.c_name,
-                          arg_decls, meth_type_c, retval_decl, num_args_cond,
-                          xs_name_list, self_assign, arg_assigns, body);
+                          working_sv, arg_decls, meth_type_c, retval_decl,
+                          num_args_cond, xs_name_list, self_assign,
+                          arg_assigns, body);
 
     FREEMEM(arg_assigns);
     FREEMEM(arg_decls);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ecc951e/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm 
b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index 6d9e87e..32581e1 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -200,6 +200,7 @@ singleton(either_sv, value)
     bool     value;
 CODE:
 {
+    CFISH_UNUSED_VAR(either_sv);
     RETVAL = CFISH_OBJ_TO_SV_INC(cfish_Bool_singleton(value));
 }
 OUTPUT: RETVAL

Reply via email to