You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2016/03/20 06:53:58 UTC
[04/14] lucy-clownfish git commit: Fix some `unused` warnings in the
Perl bindings.
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/338ab9f6
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/338ab9f6
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/338ab9f6
Branch: refs/heads/master
Commit: 338ab9f6c61a4cf71edde1068de88b4cb77f2fe6
Parents: f35c02d
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Wed Mar 16 00:35:55 2016 +0000
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sat Mar 19 21:42:44 2016 -0700
----------------------------------------------------------------------
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/338ab9f6/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/338ab9f6/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 08d32e2..c8281ee 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/338ab9f6/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 ec8ac12..d7f0ec0 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