Add helper identifying Clownfish runtime parcel.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/69b35c3e Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/69b35c3e Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/69b35c3e Branch: refs/heads/master Commit: 69b35c3e7ba1c3b93e47c62ac7a0d51656086b5c Parents: 83881f0 Author: Marvin Humphrey <[email protected]> Authored: Thu May 28 10:55:12 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Thu May 28 10:55:12 2015 -0700 ---------------------------------------------------------------------- compiler/src/CFCBindClass.c | 8 ++++---- compiler/src/CFCBindCore.c | 2 +- compiler/src/CFCParcel.c | 5 +++++ compiler/src/CFCParcel.h | 5 +++++ 4 files changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/69b35c3e/compiler/src/CFCBindClass.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c index a30ea18..527538b 100644 --- a/compiler/src/CFCBindClass.c +++ b/compiler/src/CFCBindClass.c @@ -436,8 +436,8 @@ S_struct_definition(CFCBindClass *self) { const char *struct_sym; char *member_decs = CFCUtil_strdup(""); - const char *prefix = CFCClass_get_prefix(client); - if (strcmp(prefix, "cfish_") == 0) { + CFCParcel *parcel = CFCClass_get_parcel(client); + if (CFCParcel_is_cfish(parcel)) { struct_sym = CFCClass_full_struct_sym(client); member_decs = CFCUtil_cat(member_decs, "\n CFISH_OBJ_HEAD", NULL); } @@ -473,12 +473,12 @@ char* CFCBindClass_spec_def(CFCBindClass *self) { CFCClass *client = self->client; + CFCParcel *parcel = CFCClass_get_parcel(client); CFCClass *parent = CFCClass_get_parent(client); const char *class_name = CFCClass_get_name(client); const char *class_var = CFCClass_full_class_var(client); const char *struct_sym = CFCClass_full_struct_sym(client); const char *ivars_struct = CFCClass_full_ivars_struct(client); - const char *prefix = CFCClass_get_prefix(client); // Create a pointer to the parent Class object. char *parent_ref; @@ -525,7 +525,7 @@ CFCBindClass_spec_def(CFCBindClass *self) { char *ivars_size = NULL; - if (strcmp(prefix, "cfish_") == 0) { + if (CFCParcel_is_cfish(parcel)) { ivars_size = CFCUtil_sprintf("sizeof(%s)", struct_sym); } else { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/69b35c3e/compiler/src/CFCBindCore.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c index 43e25f0..985f00c 100644 --- a/compiler/src/CFCBindCore.c +++ b/compiler/src/CFCBindCore.c @@ -351,7 +351,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) { char *extra_defs; char *extra_includes; - if (strcmp(prefix, "cfish_") == 0) { + if (CFCParcel_is_cfish(parcel)) { extra_defs = CFCUtil_sprintf("%s%s", cfish_defs_1, cfish_defs_2); extra_includes = CFCUtil_strdup(cfish_includes); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/69b35c3e/compiler/src/CFCParcel.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c index f54c81c..15e10da 100644 --- a/compiler/src/CFCParcel.c +++ b/compiler/src/CFCParcel.c @@ -601,6 +601,11 @@ CFCParcel_lookup_struct_sym(CFCParcel *self, const char *struct_sym) { return parcel; } +int +CFCParcel_is_cfish(CFCParcel *self) { + return !strcmp(self->prefix, "cfish_"); +} + /**************************************************************************/ struct CFCPrereq { http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/69b35c3e/compiler/src/CFCParcel.h ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParcel.h b/compiler/src/CFCParcel.h index dff7deb..9ecec9b 100644 --- a/compiler/src/CFCParcel.h +++ b/compiler/src/CFCParcel.h @@ -177,6 +177,11 @@ CFCParcel_add_struct_sym(CFCParcel *self, const char *struct_sym); CFCParcel* CFCParcel_lookup_struct_sym(CFCParcel *self, const char *struct_sym); +/** Indicate whether the parcel is "clownfish", the main Clownfish runtime. + */ +int +CFCParcel_is_cfish(CFCParcel *self); + /**************************************************************************/ CFCPrereq*
