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/06 17:32:14 UTC
[1/5] lucy-clownfish git commit: Use Perl method name in invalid
callback error
Repository: lucy-clownfish
Updated Branches:
refs/heads/master 3e654d21b -> c911cd66b
Use Perl method name in invalid callback error
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/299483d8
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/299483d8
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/299483d8
Branch: refs/heads/master
Commit: 299483d817fcc689d1c4ffc95cb7051f5e5c5f66
Parents: 3e654d2
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Apr 24 16:47:50 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 6 17:25:12 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlMethod.c | 8 +++++---
runtime/perl/t/binding/019-obj.t | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/299483d8/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 547f948..7ab9ed5 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -586,7 +586,6 @@ S_callback_refcount_mods(CFCMethod *method) {
static char*
S_invalid_callback_def(CFCMethod *method) {
const char *override_sym = CFCMethod_full_override_sym(method);
- char *full_method_sym = CFCMethod_full_method_sym(method, NULL);
CFCType *return_type = CFCMethod_get_return_type(method);
CFCParamList *param_list = CFCMethod_get_param_list(method);
const char *ret_type_str = CFCType_to_c(return_type);
@@ -595,6 +594,9 @@ S_invalid_callback_def(CFCMethod *method) {
= CFCType_is_void(return_type)
? CFCUtil_sprintf("")
: CFCUtil_sprintf("CFISH_UNREACHABLE_RETURN(%s);\n", ret_type_str);
+
+ char *perl_name = CFCPerlMethod_perl_name(method);
+
char pattern[] =
"%s\n"
"%s(%s) {\n"
@@ -604,8 +606,8 @@ S_invalid_callback_def(CFCMethod *method) {
"}\n"
;
char *callback_def = CFCUtil_sprintf(pattern, ret_type_str, override_sym,
- params, full_method_sym, maybe_ret);
- FREEMEM(full_method_sym);
+ params, perl_name, maybe_ret);
+ FREEMEM(perl_name);
FREEMEM(maybe_ret);
return callback_def;
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/299483d8/runtime/perl/t/binding/019-obj.t
----------------------------------------------------------------------
diff --git a/runtime/perl/t/binding/019-obj.t b/runtime/perl/t/binding/019-obj.t
index 0b4e80d..f2c0e10 100644
--- a/runtime/perl/t/binding/019-obj.t
+++ b/runtime/perl/t/binding/019-obj.t
@@ -131,7 +131,7 @@ SKIP: {
"Don't allow methods without nullable return values to return NULL" );
eval { InvalidCallbackTestObj->new; };
- like( $@, qr/Can't override CFISH_Obj_To_Host via binding/ );
+ like( $@, qr/Can't override to_host via binding/ );
}
my $alias_test = Clownfish::Test::AliasTestObj->new;
[2/5] lucy-clownfish git commit: Remove unused function
Posted by nw...@apache.org.
Remove unused function
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/d2a16305
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/d2a16305
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/d2a16305
Branch: refs/heads/master
Commit: d2a16305eefb512ccffcb0f3abac3849b14daad8
Parents: 299483d
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Apr 24 17:01:39 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 6 17:25:21 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlMethod.c | 15 ---------------
compiler/src/CFCPerlMethod.h | 5 -----
2 files changed, 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d2a16305/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 7ab9ed5..e549f91 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -418,21 +418,6 @@ S_xsub_def_positional_args(CFCPerlMethod *self) {
}
char*
-CFCPerlMethod_callback_dec(CFCMethod *method) {
- const char *override_sym = CFCMethod_full_override_sym(method);
- CFCType *return_type = CFCMethod_get_return_type(method);
- CFCParamList *param_list = CFCMethod_get_param_list(method);
- const char *ret_type_str = CFCType_to_c(return_type);
- const char *params = CFCParamList_to_c(param_list);
- char pattern[] =
- "%s\n"
- "%s(%s);\n";
- char *callback_dec
- = CFCUtil_sprintf(pattern, ret_type_str, override_sym, params);
- return callback_dec;
-}
-
-char*
CFCPerlMethod_callback_def(CFCMethod *method) {
// Return a callback wrapper that throws an error if there are no
// bindings for a method.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d2a16305/compiler/src/CFCPerlMethod.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.h b/compiler/src/CFCPerlMethod.h
index cf5bc5e..be441c4 100644
--- a/compiler/src/CFCPerlMethod.h
+++ b/compiler/src/CFCPerlMethod.h
@@ -57,11 +57,6 @@ CFCPerlMethod_perl_name(struct CFCMethod *method);
char*
CFCPerlMethod_xsub_def(CFCPerlMethod *self);
-/** Return C code declaring a callback to the Host for this method.
- */
-char*
-CFCPerlMethod_callback_dec(struct CFCMethod *method);
-
/** Return C code implementing a callback to Perl for this method. This code
* is run when a Perl subclass has overridden a method in a Clownfish base
* class.
[3/5] lucy-clownfish git commit: Refactor callback generation
Posted by nw...@apache.org.
Refactor callback generation
Move some common code into CFCPerlMethod_callback_def.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/43ba845d
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/43ba845d
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/43ba845d
Branch: refs/heads/master
Commit: 43ba845d41188fdaaf69e81958fc2b17fde58451
Parents: d2a1630
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Apr 24 16:42:36 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 6 17:25:35 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlMethod.c | 169 +++++++++++++++++++-------------------
1 file changed, 84 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/43ba845d/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index e549f91..d1b17ac 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -69,23 +69,23 @@ S_callback_refcount_mods(CFCMethod *method);
* compile-time.
*/
static char*
-S_invalid_callback_def(CFCMethod *method);
+S_invalid_callback_body(CFCMethod *method);
// Create a callback for a method which operates in a void context.
static char*
-S_void_callback_def(CFCMethod *method, const char *callback_start,
- const char *refcount_mods);
+S_void_callback_body(CFCMethod *method, const char *callback_start,
+ const char *refcount_mods);
// Create a callback which returns a primitive type.
static char*
-S_primitive_callback_def(CFCMethod *method, const char *callback_start,
- const char *refcount_mods);
+S_primitive_callback_body(CFCMethod *method, const char *callback_start,
+ const char *refcount_mods);
/* Create a callback which returns an object type -- either a generic object or
* a string. */
static char*
-S_obj_callback_def(CFCMethod *method, const char *callback_start,
- const char *refcount_mods);
+S_obj_callback_body(CFCMethod *method, const char *callback_start,
+ const char *refcount_mods);
static const CFCMeta CFCPERLMETHOD_META = {
"Clownfish::CFC::Binding::Perl::Method",
@@ -419,35 +419,56 @@ S_xsub_def_positional_args(CFCPerlMethod *self) {
char*
CFCPerlMethod_callback_def(CFCMethod *method) {
+ CFCType *return_type = CFCMethod_get_return_type(method);
+ char *callback_body = NULL;
+
// Return a callback wrapper that throws an error if there are no
// bindings for a method.
if (!CFCMethod_can_be_bound(method)) {
- return S_invalid_callback_def(method);
+ callback_body = S_invalid_callback_body(method);
}
+ else {
+ char *start = S_callback_start(method);
+ char *refcount_mods = S_callback_refcount_mods(method);
- CFCType *return_type = CFCMethod_get_return_type(method);
- char *start = S_callback_start(method);
- char *callback_def = NULL;
- char *refcount_mods = S_callback_refcount_mods(method);
+ if (CFCType_is_void(return_type)) {
+ callback_body = S_void_callback_body(method, start, refcount_mods);
+ }
+ else if (CFCType_is_object(return_type)) {
+ callback_body = S_obj_callback_body(method, start, refcount_mods);
+ }
+ else if (CFCType_is_integer(return_type)
+ || CFCType_is_floating(return_type)
+ ) {
+ callback_body = S_primitive_callback_body(method, start,
+ refcount_mods);
+ }
+ else {
+ // Can't map return type.
+ callback_body = S_invalid_callback_body(method);
+ }
- if (CFCType_is_void(return_type)) {
- callback_def = S_void_callback_def(method, start, refcount_mods);
- }
- else if (CFCType_is_object(return_type)) {
- callback_def = S_obj_callback_def(method, start, refcount_mods);
- }
- else if (CFCType_is_integer(return_type)
- || CFCType_is_floating(return_type)
- ) {
- callback_def = S_primitive_callback_def(method, start, refcount_mods);
- }
- else {
- // Can't map return type.
- callback_def = S_invalid_callback_def(method);
+ FREEMEM(start);
+ FREEMEM(refcount_mods);
}
- FREEMEM(start);
- FREEMEM(refcount_mods);
+ const char *override_sym = CFCMethod_full_override_sym(method);
+
+ CFCParamList *param_list = CFCMethod_get_param_list(method);
+ const char *params = CFCParamList_to_c(param_list);
+
+ const char *ret_type_str = CFCType_to_c(return_type);
+
+ char pattern[] =
+ "%s\n"
+ "%s(%s) {\n"
+ "%s"
+ "}\n";
+ char *callback_def
+ = CFCUtil_sprintf(pattern, ret_type_str, override_sym, params,
+ callback_body);
+
+ FREEMEM(callback_body);
return callback_def;
}
@@ -543,7 +564,7 @@ S_callback_refcount_mods(CFCMethod *method) {
// refcount. (No function can return a decremented object.)
if (CFCType_is_object(return_type) && !CFCType_incremented(return_type)) {
refcount_mods = CFCUtil_cat(refcount_mods,
- "\n CFISH_DECREF(retval);", NULL);
+ " CFISH_DECREF(retval);\n", NULL);
}
// Adjust refcounts of arguments per method signature, so that Perl code
@@ -556,12 +577,12 @@ S_callback_refcount_mods(CFCMethod *method) {
continue;
}
else if (CFCType_incremented(type)) {
- refcount_mods = CFCUtil_cat(refcount_mods, "\n CFISH_INCREF(",
- name, ");", NULL);
+ refcount_mods = CFCUtil_cat(refcount_mods, " CFISH_INCREF(",
+ name, ");\n", NULL);
}
else if (CFCType_decremented(type)) {
- refcount_mods = CFCUtil_cat(refcount_mods, "\n CFISH_DECREF(",
- name, ");", NULL);
+ refcount_mods = CFCUtil_cat(refcount_mods, " CFISH_DECREF(",
+ name, ");\n", NULL);
}
}
@@ -569,12 +590,9 @@ S_callback_refcount_mods(CFCMethod *method) {
}
static char*
-S_invalid_callback_def(CFCMethod *method) {
- const char *override_sym = CFCMethod_full_override_sym(method);
- CFCType *return_type = CFCMethod_get_return_type(method);
- CFCParamList *param_list = CFCMethod_get_param_list(method);
- const char *ret_type_str = CFCType_to_c(return_type);
- const char *params = CFCParamList_to_c(param_list);
+S_invalid_callback_body(CFCMethod *method) {
+ CFCType *return_type = CFCMethod_get_return_type(method);
+ const char *ret_type_str = CFCType_to_c(return_type);
char *maybe_ret
= CFCType_is_void(return_type)
? CFCUtil_sprintf("")
@@ -583,45 +601,34 @@ S_invalid_callback_def(CFCMethod *method) {
char *perl_name = CFCPerlMethod_perl_name(method);
char pattern[] =
- "%s\n"
- "%s(%s) {\n"
" CFISH_UNUSED_VAR(self);\n"
" cfish_Err_invalid_callback(\"%s\");\n"
- "%s"
- "}\n"
- ;
- char *callback_def = CFCUtil_sprintf(pattern, ret_type_str, override_sym,
- params, perl_name, maybe_ret);
+ "%s";
+ char *callback_body = CFCUtil_sprintf(pattern, perl_name, maybe_ret);
+
FREEMEM(perl_name);
FREEMEM(maybe_ret);
- return callback_def;
+ return callback_body;
}
static char*
-S_void_callback_def(CFCMethod *method, const char *callback_start,
- const char *refcount_mods) {
- const char *override_sym = CFCMethod_full_override_sym(method);
- const char *params = CFCParamList_to_c(CFCMethod_get_param_list(method));
+S_void_callback_body(CFCMethod *method, const char *callback_start,
+ const char *refcount_mods) {
char *perl_name = CFCPerlMethod_perl_name(method);
const char pattern[] =
- "void\n"
- "%s(%s) {\n"
"%s"
- " S_finish_callback_void(aTHX_ \"%s\");%s\n"
- "}\n";
- char *callback_def
- = CFCUtil_sprintf(pattern, override_sym, params, callback_start,
- perl_name, refcount_mods);
+ " S_finish_callback_void(aTHX_ \"%s\");\n"
+ "%s";
+ char *callback_body
+ = CFCUtil_sprintf(pattern, callback_start, perl_name, refcount_mods);
FREEMEM(perl_name);
- return callback_def;
+ return callback_body;
}
static char*
-S_primitive_callback_def(CFCMethod *method, const char *callback_start,
- const char *refcount_mods) {
- const char *override_sym = CFCMethod_full_override_sym(method);
- const char *params = CFCParamList_to_c(CFCMethod_get_param_list(method));
+S_primitive_callback_body(CFCMethod *method, const char *callback_start,
+ const char *refcount_mods) {
CFCType *return_type = CFCMethod_get_return_type(method);
const char *ret_type_str = CFCType_to_c(return_type);
char callback_func[50];
@@ -644,26 +651,21 @@ S_primitive_callback_def(CFCMethod *method, const char *callback_start,
char *perl_name = CFCPerlMethod_perl_name(method);
char pattern[] =
- "%s\n"
- "%s(%s) {\n"
"%s"
- " %s retval = (%s)%s(aTHX_ \"%s\");%s\n"
- " return retval;\n"
- "}\n";
- char *callback_def
- = CFCUtil_sprintf(pattern, ret_type_str, override_sym, params,
- callback_start, ret_type_str, ret_type_str,
+ " %s retval = (%s)%s(aTHX_ \"%s\");\n"
+ "%s"
+ " return retval;\n";
+ char *callback_body
+ = CFCUtil_sprintf(pattern, callback_start, ret_type_str, ret_type_str,
callback_func, perl_name, refcount_mods);
FREEMEM(perl_name);
- return callback_def;
+ return callback_body;
}
static char*
-S_obj_callback_def(CFCMethod *method, const char *callback_start,
- const char *refcount_mods) {
- const char *override_sym = CFCMethod_full_override_sym(method);
- const char *params = CFCParamList_to_c(CFCMethod_get_param_list(method));
+S_obj_callback_body(CFCMethod *method, const char *callback_start,
+ const char *refcount_mods) {
CFCType *return_type = CFCMethod_get_return_type(method);
const char *ret_type_str = CFCType_to_c(return_type);
const char *nullable = CFCType_nullable(return_type) ? "true" : "false";
@@ -671,18 +673,15 @@ S_obj_callback_def(CFCMethod *method, const char *callback_start,
char *perl_name = CFCPerlMethod_perl_name(method);
char pattern[] =
- "%s\n"
- "%s(%s) {\n"
"%s"
- " %s retval = (%s)S_finish_callback_obj(aTHX_ self, \"%s\", %s);%s\n"
- " return retval;\n"
- "}\n";
- char *callback_def
- = CFCUtil_sprintf(pattern, ret_type_str, override_sym, params,
- callback_start, ret_type_str, ret_type_str,
+ " %s retval = (%s)S_finish_callback_obj(aTHX_ self, \"%s\", %s);\n"
+ "%s"
+ " return retval;\n";
+ char *callback_body
+ = CFCUtil_sprintf(pattern, callback_start, ret_type_str, ret_type_str,
perl_name, nullable, refcount_mods);
FREEMEM(perl_name);
- return callback_def;
+ return callback_body;
}
[5/5] lucy-clownfish git commit: Readd UNUSED_VAR macros for all
invalid callback args
Posted by nw...@apache.org.
Readd UNUSED_VAR macros for all invalid callback args
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/c911cd66
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/c911cd66
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/c911cd66
Branch: refs/heads/master
Commit: c911cd66bca80a9263ee41990f077d54b6772f38
Parents: 91e680e
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed May 6 17:23:49 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 6 17:30:00 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlMethod.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c911cd66/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index 4ff0c2f..637be28 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -591,6 +591,15 @@ S_callback_refcount_mods(CFCMethod *method) {
static char*
S_invalid_callback_body(CFCMethod *method) {
+ CFCParamList *param_list = CFCMethod_get_param_list(method);
+ CFCVariable **param_vars = CFCParamList_get_variables(param_list);
+ char *unused = CFCUtil_strdup("");
+ for (int i = 0; param_vars[i] != NULL; i++) {
+ const char *name = CFCVariable_micro_sym(param_vars[i]);
+ unused = CFCUtil_cat(unused, " CFISH_UNUSED_VAR(", name, ");\n",
+ NULL);
+ }
+
CFCType *return_type = CFCMethod_get_return_type(method);
const char *ret_type_str = CFCType_to_c(return_type);
char *maybe_ret
@@ -602,12 +611,14 @@ S_invalid_callback_body(CFCMethod *method) {
char *perl_name = CFCPerlMethod_perl_name(method);
char pattern[] =
- " CFISH_UNUSED_VAR(self);\n"
+ "%s"
" cfish_Err_invalid_callback(\"%s\");\n"
"%s";
- char *callback_body = CFCUtil_sprintf(pattern, perl_name, maybe_ret);
+ char *callback_body
+ = CFCUtil_sprintf(pattern, unused, perl_name, maybe_ret);
FREEMEM(perl_name);
+ FREEMEM(unused);
FREEMEM(maybe_ret);
return callback_body;
}
[4/5] lucy-clownfish git commit: Fix whitespace in generated callbacks
Posted by nw...@apache.org.
Fix whitespace in generated callbacks
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/91e680eb
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/91e680eb
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/91e680eb
Branch: refs/heads/master
Commit: 91e680eba63b03728b93d70d928c8c5d9798236f
Parents: 43ba845
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Apr 24 16:51:42 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 6 17:25:43 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCPerlMethod.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91e680eb/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index d1b17ac..4ff0c2f 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -596,7 +596,8 @@ S_invalid_callback_body(CFCMethod *method) {
char *maybe_ret
= CFCType_is_void(return_type)
? CFCUtil_sprintf("")
- : CFCUtil_sprintf("CFISH_UNREACHABLE_RETURN(%s);\n", ret_type_str);
+ : CFCUtil_sprintf(" CFISH_UNREACHABLE_RETURN(%s);\n",
+ ret_type_str);
char *perl_name = CFCPerlMethod_perl_name(method);