Separate test whether to create method bindings Move the code that checks whether bindings for a method should be generated to a separate 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/7ece5f56 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/7ece5f56 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/7ece5f56 Branch: refs/heads/overridden_exclusions Commit: 7ece5f56607e667c42b795b4b4d60e8985948d9d Parents: dcf237e Author: Nick Wellnhofer <[email protected]> Authored: Thu Jul 31 14:04:20 2014 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Mon Aug 11 16:37:07 2014 +0200 ---------------------------------------------------------------------- compiler/src/CFCPerlClass.c | 14 ++------------ compiler/src/CFCPerlMethod.c | 14 ++++++++++++++ compiler/src/CFCPerlMethod.h | 5 +++++ 3 files changed, 21 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ece5f56/compiler/src/CFCPerlClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c index 1fb2b7c..52eb851 100644 --- a/compiler/src/CFCPerlClass.c +++ b/compiler/src/CFCPerlClass.c @@ -239,18 +239,8 @@ CFCPerlClass_method_bindings(CFCClass *klass) { for (size_t i = 0; fresh_methods[i] != NULL; i++) { CFCMethod *method = fresh_methods[i]; - // Skip private methods. - if (CFCSymbol_private((CFCSymbol*)method)) { continue; } - - // Skip methods which have been explicitly excluded. - if (CFCMethod_excluded_from_host(method)) { - continue; - } - - // Skip methods with types which cannot be mapped automatically. - if (!CFCPerlSub_can_be_bound((CFCFunction*)method)) { - continue; - } + // Skip methods that shouldn't be bound. + if (!CFCPerlMethod_can_be_bound(method)) { continue; } /* Create the binding, add it to the array. * http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ece5f56/compiler/src/CFCPerlMethod.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c index 2aad102..9b412dc 100644 --- a/compiler/src/CFCPerlMethod.c +++ b/compiler/src/CFCPerlMethod.c @@ -23,6 +23,7 @@ #include "CFCPerlMethod.h" #include "CFCUtil.h" #include "CFCClass.h" +#include "CFCFunction.h" #include "CFCMethod.h" #include "CFCSymbol.h" #include "CFCType.h" @@ -134,6 +135,19 @@ CFCPerlMethod_destroy(CFCPerlMethod *self) { CFCPerlSub_destroy((CFCPerlSub*)self); } +int +CFCPerlMethod_can_be_bound(CFCMethod *method) { + /* + * Check for + * - private methods + * - methods which have been explicitly excluded + * - methods with types which cannot be mapped automatically + */ + return !CFCSymbol_private((CFCSymbol*)method) + && !CFCMethod_excluded_from_host(method) + && CFCPerlSub_can_be_bound((CFCFunction*)method); +} + char* CFCPerlMethod_perl_name(CFCMethod *method) { // See if the user wants the method to have a specific alias. http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/7ece5f56/compiler/src/CFCPerlMethod.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCPerlMethod.h b/compiler/src/CFCPerlMethod.h index be441c4..ee85efe 100644 --- a/compiler/src/CFCPerlMethod.h +++ b/compiler/src/CFCPerlMethod.h @@ -46,6 +46,11 @@ CFCPerlMethod_init(CFCPerlMethod *self, struct CFCMethod *method); void CFCPerlMethod_destroy(CFCPerlMethod *self); +/** Test whether bindings should be generated for a method. + */ +int +CFCPerlMethod_can_be_bound(struct CFCMethod *method); + /** * Create the Perl name of the method. */
