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/09 19:50:05 UTC
[08/11] lucy-clownfish git commit: Implement CFCMethod_is_fresh
Implement CFCMethod_is_fresh
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/587d26b2
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/587d26b2
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/587d26b2
Branch: refs/heads/master
Commit: 587d26b2a4c96052a8bea114df057f8c36bc3b11
Parents: ee9fda0
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Apr 21 10:19:55 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu May 7 21:19:37 2015 +0200
----------------------------------------------------------------------
compiler/src/CFCBindClass.c | 7 ++-----
compiler/src/CFCCHtml.c | 4 +---
compiler/src/CFCCMan.c | 4 +---
compiler/src/CFCMethod.c | 6 ++++++
compiler/src/CFCMethod.h | 5 +++++
compiler/src/CFCPerlClass.c | 4 ++--
6 files changed, 17 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/587d26b2/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c
index 2f2b563..a69679f 100644
--- a/compiler/src/CFCBindClass.c
+++ b/compiler/src/CFCBindClass.c
@@ -268,7 +268,6 @@ S_to_c_header_dynamic(CFCBindClass *self) {
char*
CFCBindClass_to_c_data(CFCBindClass *self) {
CFCClass *client = self->client;
- const char *class_name = CFCClass_get_name(client);
if (CFCClass_inert(client)) {
return CFCUtil_strdup("");
@@ -295,8 +294,7 @@ CFCBindClass_to_c_data(CFCBindClass *self) {
NULL);
FREEMEM(full_offset_sym);
- const char *meth_class_name = CFCMethod_get_class_name(method);
- int is_fresh = strcmp(class_name, meth_class_name) == 0;
+ int is_fresh = CFCMethod_is_fresh(method, client);
// Create a default implementation for abstract methods.
if (is_fresh && CFCMethod_abstract(method)) {
@@ -498,9 +496,8 @@ CFCBindClass_spec_def(CFCBindClass *self) {
for (int meth_num = 0; methods[meth_num] != NULL; meth_num++) {
CFCMethod *method = methods[meth_num];
- const char *meth_class_name = CFCMethod_get_class_name(method);
- if (strcmp(class_name, meth_class_name) == 0) {
+ if (CFCMethod_is_fresh(method, client)) {
if (CFCMethod_novel(method)) {
++num_novel;
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/587d26b2/compiler/src/CFCCHtml.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c
index 571a0ae..0409a7b 100644
--- a/compiler/src/CFCCHtml.c
+++ b/compiler/src/CFCCHtml.c
@@ -564,7 +564,6 @@ static char*
S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) {
CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
const char *prefix = CFCClass_get_prefix(klass);
- const char *ancestor_name = CFCClass_get_name(ancestor);
char *result = CFCUtil_strdup("");
for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
@@ -573,8 +572,7 @@ S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) {
continue;
}
- const char *class_name = CFCMethod_get_class_name(method);
- if (strcmp(class_name, ancestor_name) != 0) {
+ if (!CFCMethod_is_fresh(method, ancestor)) {
// The method is implementated in a subclass and already
// documented.
continue;
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/587d26b2/compiler/src/CFCCMan.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCCMan.c b/compiler/src/CFCCMan.c
index 9ebd086..354d91f 100644
--- a/compiler/src/CFCCMan.c
+++ b/compiler/src/CFCCMan.c
@@ -235,7 +235,6 @@ S_man_create_methods(CFCClass *klass) {
static char*
S_man_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) {
CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
- const char *ancestor_name = CFCClass_get_name(ancestor);
char *result = CFCUtil_strdup("");
for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
@@ -244,8 +243,7 @@ S_man_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) {
continue;
}
- const char *class_name = CFCMethod_get_class_name(method);
- if (strcmp(class_name, ancestor_name) != 0) {
+ if (!CFCMethod_is_fresh(method, ancestor)) {
// The method is implementated in a subclass and already
// documented.
continue;
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/587d26b2/compiler/src/CFCMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCMethod.c b/compiler/src/CFCMethod.c
index 78180b4..be17981 100644
--- a/compiler/src/CFCMethod.c
+++ b/compiler/src/CFCMethod.c
@@ -385,6 +385,12 @@ CFCMethod_get_class_name(CFCMethod *self) {
}
int
+CFCMethod_is_fresh(CFCMethod *self, CFCClass *klass) {
+ const char *class_name = CFCClass_get_name(klass);
+ return strcmp(CFCMethod_get_class_name(self), class_name) == 0;
+}
+
+int
CFCMethod_public(CFCMethod *self) {
return CFCSymbol_public((CFCSymbol*)self);
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/587d26b2/compiler/src/CFCMethod.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCMethod.h b/compiler/src/CFCMethod.h
index 3f64c12..fa4df9e 100644
--- a/compiler/src/CFCMethod.h
+++ b/compiler/src/CFCMethod.h
@@ -208,6 +208,11 @@ CFCMethod_get_exposure(CFCMethod *self);
const char*
CFCMethod_get_class_name(CFCMethod *self);
+/** Return true if the method is fresh in `klass`.
+ */
+int
+CFCMethod_is_fresh(CFCMethod *self, struct CFCClass *klass);
+
int
CFCMethod_public(CFCMethod *self);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/587d26b2/compiler/src/CFCPerlClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlClass.c b/compiler/src/CFCPerlClass.c
index dad5f72..6484c78 100644
--- a/compiler/src/CFCPerlClass.c
+++ b/compiler/src/CFCPerlClass.c
@@ -181,7 +181,7 @@ CFCPerlClass_bind_method(CFCPerlClass *self, const char *alias,
CFCUtil_die("Can't bind_method %s -- can't find method %s in %s",
alias, meth_name, self->class_name);
}
- if (strcmp(CFCMethod_get_class_name(method), self->class_name) != 0) {
+ if (!CFCMethod_is_fresh(method, self->client)) {
CFCUtil_die("Can't bind_method %s -- method %s not fresh in %s",
alias, meth_name, self->class_name);
}
@@ -199,7 +199,7 @@ CFCPerlClass_exclude_method(CFCPerlClass *self, const char *meth_name) {
CFCUtil_die("Can't exclude_method %s -- method not found in %s",
meth_name, self->class_name);
}
- if (strcmp(CFCMethod_get_class_name(method), self->class_name) != 0) {
+ if (!CFCMethod_is_fresh(method, self->client)) {
CFCUtil_die("Can't exclude_method %s -- method not fresh in %s",
meth_name, self->class_name);
}