Repository: lucy-clownfish Updated Branches: refs/heads/master ac2de384e -> d8ecb8d38
Write Go-specific hostdefs rather than reuse C. Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/c123bbf1 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/c123bbf1 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/c123bbf1 Branch: refs/heads/master Commit: c123bbf177b0d3c3d139605ce893d71cb36cda88 Parents: b2cc905 Author: Marvin Humphrey <[email protected]> Authored: Mon Mar 16 21:15:33 2015 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Mon Apr 6 09:08:19 2015 -0700 ---------------------------------------------------------------------- compiler/src/CFCGo.c | 31 ++++++++++++++++++++++++++++++- runtime/go/build.go | 2 -- 2 files changed, 30 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c123bbf1/compiler/src/CFCGo.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCGo.c b/compiler/src/CFCGo.c index 8625664..2e2b0f3 100644 --- a/compiler/src/CFCGo.c +++ b/compiler/src/CFCGo.c @@ -89,10 +89,39 @@ CFCGo_set_footer(CFCGo *self, const char *footer) { self->c_footer = CFCUtil_make_c_comment(footer); } +static void +S_write_hostdefs(CFCGo *self) { + const char pattern[] = + "/*\n" + " * %s\n" + " */\n" + "\n" + "#ifndef H_CFISH_HOSTDEFS\n" + "#define H_CFISH_HOSTDEFS 1\n" + "\n" + "#define CFISH_OBJ_HEAD \\\n" + " size_t refcount;\n" + "\n" + "#endif /* H_CFISH_HOSTDEFS */\n" + "\n" + "%s\n"; + char *content + = CFCUtil_sprintf(pattern, self->header, self->footer); + + // Write if the content has changed. + const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy); + char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_hostdefs.h", + inc_dest); + CFCUtil_write_if_changed(filepath, content, strlen(content)); + + FREEMEM(filepath); + FREEMEM(content); +} + void CFCGo_write_bindings(CFCGo *self, CFCParcel *parcel, const char *dest) { - CHY_UNUSED_VAR(self); CHY_UNUSED_VAR(parcel); CHY_UNUSED_VAR(dest); + S_write_hostdefs(self); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c123bbf1/runtime/go/build.go ---------------------------------------------------------------------- diff --git a/runtime/go/build.go b/runtime/go/build.go index c746537..3ef57fb 100644 --- a/runtime/go/build.go +++ b/runtime/go/build.go @@ -121,8 +121,6 @@ func runCFC() { coreBinding := cfc.NewBindCore(hierarchy, autogenHeader, "") modified := coreBinding.WriteAllModified(false) if modified { - cBinding := cfc.NewBindC(hierarchy, autogenHeader, "") - cBinding.WriteHostDefs() goBinding := cfc.NewBindGo(hierarchy) goBinding.SetHeader(autogenHeader) parcel := cfc.FetchParcel("Clownfish")
