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 2013/05/30 21:57:28 UTC
[lucy-commits] [1/2] git commit: refs/heads/separate-clownfish-wip1 - Store parcel
names instead of parcel pointers
Updated Branches:
refs/heads/separate-clownfish-wip1 40220b9e9 -> 8a26610bb
Store parcel names instead of parcel pointers
This avoids reference cycles.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/8a26610b
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/8a26610b
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/8a26610b
Branch: refs/heads/separate-clownfish-wip1
Commit: 8a26610bb810152fb05be34946dda1421ff226b2
Parents: 79f08f1
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu May 30 21:42:27 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu May 30 21:54:15 2013 +0200
----------------------------------------------------------------------
clownfish/compiler/src/CFCBindCore.c | 3 +
clownfish/compiler/src/CFCParcel.c | 68 +++++++++++++++++------------
clownfish/compiler/src/CFCParcel.h | 3 +-
3 files changed, 45 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/8a26610b/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index e4553a6..c1f200e 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -265,6 +265,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
extra_includes = CFCUtil_cat(extra_includes, "#include <",
dep_prefix, "parcel.h>\n", NULL);
}
+ FREEMEM(dep_parcels);
}
const char pattern[] =
@@ -386,12 +387,14 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
inh_bootstrap = CFCUtil_cat(inh_bootstrap, " ", inh_prefix,
"bootstrap_inheritance();\n", NULL);
}
+ FREEMEM(inh_parcels);
CFCParcel **dep_parcels = CFCParcel_dependent_parcels(parcel);
for (size_t i = 0; dep_parcels[i]; ++i) {
const char *dep_prefix = CFCParcel_get_prefix(dep_parcels[i]);
dep_bootstrap = CFCUtil_cat(dep_bootstrap, " ", dep_prefix,
"bootstrap_parcel();\n", NULL);
}
+ FREEMEM(dep_parcels);
char pattern[] =
"%s\n"
http://git-wip-us.apache.org/repos/asf/lucy/blob/8a26610b/clownfish/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParcel.c b/clownfish/compiler/src/CFCParcel.c
index cf28607..fe4f27a 100644
--- a/clownfish/compiler/src/CFCParcel.c
+++ b/clownfish/compiler/src/CFCParcel.c
@@ -39,9 +39,9 @@ struct CFCParcel {
char *PREFIX;
char *privacy_sym;
int is_included;
- CFCParcel **dependent_parcels;
+ char **dependent_parcels;
size_t num_dependent_parcels;
- CFCParcel **inherited_parcels;
+ char **inherited_parcels;
size_t num_inherited_parcels;
};
@@ -231,9 +231,9 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *cnick,
self->is_included = is_included;
// Initialize dependencies.
- self->dependent_parcels = (CFCParcel**)CALLOCATE(1, sizeof(CFCParcel*));
+ self->dependent_parcels = (char**)CALLOCATE(1, sizeof(char*));
self->num_dependent_parcels = 0;
- self->inherited_parcels = (CFCParcel**)CALLOCATE(1, sizeof(CFCParcel*));
+ self->inherited_parcels = (char**)CALLOCATE(1, sizeof(char*));
self->num_inherited_parcels = 0;
return self;
@@ -326,11 +326,11 @@ CFCParcel_destroy(CFCParcel *self) {
FREEMEM(self->PREFIX);
FREEMEM(self->privacy_sym);
for (size_t i = 0; self->dependent_parcels[i]; ++i) {
- CFCBase_decref((CFCBase*)self->dependent_parcels[i]);
+ FREEMEM(self->dependent_parcels[i]);
}
FREEMEM(self->dependent_parcels);
for (size_t i = 0; self->inherited_parcels[i]; ++i) {
- CFCBase_decref((CFCBase*)self->inherited_parcels[i]);
+ FREEMEM(self->inherited_parcels[i]);
}
FREEMEM(self->inherited_parcels);
CFCBase_destroy((CFCBase*)self);
@@ -397,46 +397,42 @@ CFCParcel_included(CFCParcel *self) {
void
CFCParcel_add_dependent_parcel(CFCParcel *self, CFCParcel *dependent) {
- const char *prefix = CFCParcel_get_prefix(self);
- const char *dep_prefix = CFCParcel_get_prefix(dependent);
+ const char *name = CFCParcel_get_name(self);
+ const char *dep_name = CFCParcel_get_name(dependent);
- if (strcmp(prefix, dep_prefix) == 0) { return; }
+ if (strcmp(name, dep_name) == 0) { return; }
for (size_t i = 0; self->dependent_parcels[i]; ++i) {
- const char *other_prefix
- = CFCParcel_get_prefix(self->dependent_parcels[i]);
- if (strcmp(other_prefix, dep_prefix) == 0) { return; }
+ const char *other_name = self->dependent_parcels[i];
+ if (strcmp(other_name, dep_name) == 0) { return; }
}
size_t num_parcels = self->num_dependent_parcels;
self->dependent_parcels
- = (CFCParcel**)REALLOCATE(self->dependent_parcels,
- (num_parcels + 2) * sizeof(CFCParcel*));
- self->dependent_parcels[num_parcels]
- = (CFCParcel*)CFCBase_incref((CFCBase*)dependent);
+ = (char**)REALLOCATE(self->dependent_parcels,
+ (num_parcels + 2) * sizeof(char*));
+ self->dependent_parcels[num_parcels] = CFCUtil_strdup(dep_name);
self->dependent_parcels[num_parcels+1] = NULL;
self->num_dependent_parcels = num_parcels + 1;
}
void
CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited) {
- const char *prefix = CFCParcel_get_prefix(self);
- const char *inh_prefix = CFCParcel_get_prefix(inherited);
+ const char *name = CFCParcel_get_name(self);
+ const char *inh_name = CFCParcel_get_name(inherited);
- if (strcmp(prefix, inh_prefix) == 0) { return; }
+ if (strcmp(name, inh_name) == 0) { return; }
for (size_t i = 0; self->inherited_parcels[i]; ++i) {
- const char *other_prefix
- = CFCParcel_get_prefix(self->inherited_parcels[i]);
- if (strcmp(other_prefix, inh_prefix) == 0) { return; }
+ const char *other_name = self->inherited_parcels[i];
+ if (strcmp(other_name, inh_name) == 0) { return; }
}
size_t num_parcels = self->num_inherited_parcels;
self->inherited_parcels
- = (CFCParcel**)REALLOCATE(self->inherited_parcels,
- (num_parcels + 2) * sizeof(CFCParcel*));
- self->inherited_parcels[num_parcels]
- = (CFCParcel*)CFCBase_incref((CFCBase*)inherited);
+ = (char**)REALLOCATE(self->inherited_parcels,
+ (num_parcels + 2) * sizeof(char*));
+ self->inherited_parcels[num_parcels] = CFCUtil_strdup(inh_name);
self->inherited_parcels[num_parcels+1] = NULL;
self->num_inherited_parcels = num_parcels + 1;
@@ -446,12 +442,28 @@ CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited) {
CFCParcel**
CFCParcel_dependent_parcels(CFCParcel *self) {
- return self->dependent_parcels;
+ CFCParcel **parcels
+ = (CFCParcel**)CALLOCATE(self->num_dependent_parcels + 1,
+ sizeof(CFCParcel*));
+
+ for (size_t i = 0; self->dependent_parcels[i]; ++i) {
+ parcels[i] = CFCParcel_fetch(self->dependent_parcels[i]);
+ }
+
+ return parcels;
}
CFCParcel**
CFCParcel_inherited_parcels(CFCParcel *self) {
- return self->inherited_parcels;
+ CFCParcel **parcels
+ = (CFCParcel**)CALLOCATE(self->num_inherited_parcels + 1,
+ sizeof(CFCParcel*));
+
+ for (size_t i = 0; self->inherited_parcels[i]; ++i) {
+ parcels[i] = CFCParcel_fetch(self->inherited_parcels[i]);
+ }
+
+ return parcels;
}
/*****************************************************************************
http://git-wip-us.apache.org/repos/asf/lucy/blob/8a26610b/clownfish/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParcel.h b/clownfish/compiler/src/CFCParcel.h
index efd78a7..d937297 100644
--- a/clownfish/compiler/src/CFCParcel.h
+++ b/clownfish/compiler/src/CFCParcel.h
@@ -132,12 +132,13 @@ void
CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited);
/** Return a NULL-terminated array of all Parcels that the Parcel depends on.
+ * Must be freed by the caller.
*/
CFCParcel**
CFCParcel_dependent_parcels(CFCParcel *self);
/** Return a NULL-terminated array of all Parcels containing superclasses that
- * subclasses in the Parcel extend.
+ * subclasses in the Parcel extend. Must be freed by the caller.
*/
CFCParcel**
CFCParcel_inherited_parcels(CFCParcel *self);
[lucy-commits] [2/2] git commit: refs/heads/separate-clownfish-wip1 -
s/extended/inherited/
Posted by nw...@apache.org.
s/extended/inherited/
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/79f08f1f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/79f08f1f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/79f08f1f
Branch: refs/heads/separate-clownfish-wip1
Commit: 79f08f1f0b91263dc7cdd517bae4cbc82c31dc41
Parents: 40220b9
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu May 30 21:31:13 2013 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu May 30 21:54:15 2013 +0200
----------------------------------------------------------------------
clownfish/compiler/src/CFCBindCore.c | 18 +++++-----
clownfish/compiler/src/CFCClass.c | 2 +-
clownfish/compiler/src/CFCParcel.c | 46 ++++++++++++++--------------
clownfish/compiler/src/CFCParcel.h | 4 +-
4 files changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/79f08f1f/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index 6317e75..e4553a6 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -371,19 +371,19 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
// Bootstrapping code for dependent parcels.
//
// bootstrap_inheritance() first calls bootstrap_inheritance() for all
- // parcels from which classes are extended. Then the VTables of the parcel
+ // parcels from which classes are inherited. Then the VTables of the parcel
// are initialized. It aborts on recursive invocation.
//
// bootstrap_parcel() first calls bootstrap_inheritance() of its own
// parcel. Then it calls bootstrap_parcel() for all dependent parcels.
// Finally, it calls init_parcel(). Recursive invocation is allowed.
- char *ext_bootstrap = CFCUtil_strdup("");
+ char *inh_bootstrap = CFCUtil_strdup("");
char *dep_bootstrap = CFCUtil_strdup("");
- CFCParcel **ext_parcels = CFCParcel_extended_parcels(parcel);
- for (size_t i = 0; ext_parcels[i]; ++i) {
- const char *ext_prefix = CFCParcel_get_prefix(ext_parcels[i]);
- ext_bootstrap = CFCUtil_cat(ext_bootstrap, " ", ext_prefix,
+ CFCParcel **inh_parcels = CFCParcel_inherited_parcels(parcel);
+ for (size_t i = 0; inh_parcels[i]; ++i) {
+ const char *inh_prefix = CFCParcel_get_prefix(inh_parcels[i]);
+ inh_bootstrap = CFCUtil_cat(inh_bootstrap, " ", inh_prefix,
"bootstrap_inheritance();\n", NULL);
}
CFCParcel **dep_parcels = CFCParcel_dependent_parcels(parcel);
@@ -426,7 +426,7 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
" }\n"
" if (bootstrap_state >= 2) { return; }\n"
" bootstrap_state = 1;\n"
- "%s" // Bootstrap extended parcels.
+ "%s" // Bootstrap inherited parcels.
" cfish_VTable_bootstrap(vtable_specs, %d);\n"
" bootstrap_state = 2;\n"
"}\n"
@@ -443,7 +443,7 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
"%s\n";
char *file_content
= CFCUtil_sprintf(pattern, self->header, privacy_syms, prefix,
- includes, c_data, vt_specs, prefix, ext_bootstrap,
+ includes, c_data, vt_specs, prefix, inh_bootstrap,
num_specs, prefix, prefix, dep_bootstrap, prefix,
self->footer);
@@ -459,7 +459,7 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
FREEMEM(includes);
FREEMEM(c_data);
FREEMEM(vt_specs);
- FREEMEM(ext_bootstrap);
+ FREEMEM(inh_bootstrap);
FREEMEM(dep_bootstrap);
FREEMEM(file_content);
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/79f08f1f/clownfish/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.c b/clownfish/compiler/src/CFCClass.c
index e2cb2cc..aafaf35 100644
--- a/clownfish/compiler/src/CFCClass.c
+++ b/clownfish/compiler/src/CFCClass.c
@@ -327,7 +327,7 @@ CFCClass_add_child(CFCClass *self, CFCClass *child) {
// Add parcel dependency.
CFCParcel *parcel = CFCClass_get_parcel(self);
CFCParcel *child_parcel = CFCClass_get_parcel(child);
- CFCParcel_add_extended_parcel(child_parcel, parcel);
+ CFCParcel_add_inherited_parcel(child_parcel, parcel);
}
void
http://git-wip-us.apache.org/repos/asf/lucy/blob/79f08f1f/clownfish/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParcel.c b/clownfish/compiler/src/CFCParcel.c
index 2618162..cf28607 100644
--- a/clownfish/compiler/src/CFCParcel.c
+++ b/clownfish/compiler/src/CFCParcel.c
@@ -41,8 +41,8 @@ struct CFCParcel {
int is_included;
CFCParcel **dependent_parcels;
size_t num_dependent_parcels;
- CFCParcel **extended_parcels;
- size_t num_extended_parcels;
+ CFCParcel **inherited_parcels;
+ size_t num_inherited_parcels;
};
static CFCParcel *default_parcel = NULL;
@@ -233,8 +233,8 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *cnick,
// Initialize dependencies.
self->dependent_parcels = (CFCParcel**)CALLOCATE(1, sizeof(CFCParcel*));
self->num_dependent_parcels = 0;
- self->extended_parcels = (CFCParcel**)CALLOCATE(1, sizeof(CFCParcel*));
- self->num_extended_parcels = 0;
+ self->inherited_parcels = (CFCParcel**)CALLOCATE(1, sizeof(CFCParcel*));
+ self->num_inherited_parcels = 0;
return self;
}
@@ -329,10 +329,10 @@ CFCParcel_destroy(CFCParcel *self) {
CFCBase_decref((CFCBase*)self->dependent_parcels[i]);
}
FREEMEM(self->dependent_parcels);
- for (size_t i = 0; self->extended_parcels[i]; ++i) {
- CFCBase_decref((CFCBase*)self->extended_parcels[i]);
+ for (size_t i = 0; self->inherited_parcels[i]; ++i) {
+ CFCBase_decref((CFCBase*)self->inherited_parcels[i]);
}
- FREEMEM(self->extended_parcels);
+ FREEMEM(self->inherited_parcels);
CFCBase_destroy((CFCBase*)self);
}
@@ -419,29 +419,29 @@ CFCParcel_add_dependent_parcel(CFCParcel *self, CFCParcel *dependent) {
}
void
-CFCParcel_add_extended_parcel(CFCParcel *self, CFCParcel *extended) {
+CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited) {
const char *prefix = CFCParcel_get_prefix(self);
- const char *ext_prefix = CFCParcel_get_prefix(extended);
+ const char *inh_prefix = CFCParcel_get_prefix(inherited);
- if (strcmp(prefix, ext_prefix) == 0) { return; }
+ if (strcmp(prefix, inh_prefix) == 0) { return; }
- for (size_t i = 0; self->extended_parcels[i]; ++i) {
+ for (size_t i = 0; self->inherited_parcels[i]; ++i) {
const char *other_prefix
- = CFCParcel_get_prefix(self->extended_parcels[i]);
- if (strcmp(other_prefix, ext_prefix) == 0) { return; }
+ = CFCParcel_get_prefix(self->inherited_parcels[i]);
+ if (strcmp(other_prefix, inh_prefix) == 0) { return; }
}
- size_t num_parcels = self->num_extended_parcels;
- self->extended_parcels
- = (CFCParcel**)REALLOCATE(self->extended_parcels,
+ size_t num_parcels = self->num_inherited_parcels;
+ self->inherited_parcels
+ = (CFCParcel**)REALLOCATE(self->inherited_parcels,
(num_parcels + 2) * sizeof(CFCParcel*));
- self->extended_parcels[num_parcels]
- = (CFCParcel*)CFCBase_incref((CFCBase*)extended);
- self->extended_parcels[num_parcels+1] = NULL;
- self->num_extended_parcels = num_parcels + 1;
+ self->inherited_parcels[num_parcels]
+ = (CFCParcel*)CFCBase_incref((CFCBase*)inherited);
+ self->inherited_parcels[num_parcels+1] = NULL;
+ self->num_inherited_parcels = num_parcels + 1;
// Add to dependent parcels.
- CFCParcel_add_dependent_parcel(self, extended);
+ CFCParcel_add_dependent_parcel(self, inherited);
}
CFCParcel**
@@ -450,8 +450,8 @@ CFCParcel_dependent_parcels(CFCParcel *self) {
}
CFCParcel**
-CFCParcel_extended_parcels(CFCParcel *self) {
- return self->extended_parcels;
+CFCParcel_inherited_parcels(CFCParcel *self) {
+ return self->inherited_parcels;
}
/*****************************************************************************
http://git-wip-us.apache.org/repos/asf/lucy/blob/79f08f1f/clownfish/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParcel.h b/clownfish/compiler/src/CFCParcel.h
index fe7498a..efd78a7 100644
--- a/clownfish/compiler/src/CFCParcel.h
+++ b/clownfish/compiler/src/CFCParcel.h
@@ -129,7 +129,7 @@ CFCParcel_add_dependent_parcel(CFCParcel *self, CFCParcel *dependent);
* extend. Also adds the other Parcel to the Parcel's dependencies.
*/
void
-CFCParcel_add_extended_parcel(CFCParcel *self, CFCParcel *extended);
+CFCParcel_add_inherited_parcel(CFCParcel *self, CFCParcel *inherited);
/** Return a NULL-terminated array of all Parcels that the Parcel depends on.
*/
@@ -140,7 +140,7 @@ CFCParcel_dependent_parcels(CFCParcel *self);
* subclasses in the Parcel extend.
*/
CFCParcel**
-CFCParcel_extended_parcels(CFCParcel *self);
+CFCParcel_inherited_parcels(CFCParcel *self);
#ifdef __cplusplus
}