lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [17/54] [abbrv] Remove bundled Clownfish.
Date Sat, 26 Apr 2014 23:11:47 GMT
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
deleted file mode 100644
index 5ae8ac6..0000000
--- a/clownfish/compiler/src/CFCBindCore.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "charmony.h"
-
-#include <string.h>
-#include <stdio.h>
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCBindCore.h"
-#include "CFCBindClass.h"
-#include "CFCBindFile.h"
-#include "CFCClass.h"
-#include "CFCFile.h"
-#include "CFCHierarchy.h"
-#include "CFCParcel.h"
-#include "CFCUtil.h"
-
-#define STRING(s)  #s
-#define XSTRING(s) STRING(s)
-
-struct CFCBindCore {
-    CFCBase base;
-    CFCHierarchy *hierarchy;
-    char         *header;
-    char         *footer;
-};
-
-/* Write the "parcel.h" header file, which contains common symbols needed by
- * all classes, plus typedefs for all class structs.
- */
-static void
-S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel);
-
-/* Write the "parcel.c" file containing autogenerated implementation code.
- */
-static void
-S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel);
-
-/* Write the "cfish_platform.h" header file, which contains platform-specific
- * definitions.
- */
-static void
-S_write_platform_h(CFCBindCore *self);
-
-static char*
-S_charmony_feature_defines();
-
-static char*
-S_charmony_string_defines();
-
-static char*
-S_charmony_stdbool_defines();
-
-static char*
-S_charmony_stdint_defines();
-
-static char*
-S_charmony_alloca_defines();
-
-static const CFCMeta CFCBINDCORE_META = {
-    "Clownfish::CFC::Binding::Core",
-    sizeof(CFCBindCore),
-    (CFCBase_destroy_t)CFCBindCore_destroy
-};
-
-CFCBindCore*
-CFCBindCore_new(CFCHierarchy *hierarchy, const char *header,
-                const char *footer) {
-    CFCBindCore *self = (CFCBindCore*)CFCBase_allocate(&CFCBINDCORE_META);
-    return CFCBindCore_init(self, hierarchy, header, footer);
-}
-
-CFCBindCore*
-CFCBindCore_init(CFCBindCore *self, CFCHierarchy *hierarchy,
-                 const char *header, const char *footer) {
-    CFCUTIL_NULL_CHECK(hierarchy);
-    CFCUTIL_NULL_CHECK(header);
-    CFCUTIL_NULL_CHECK(footer);
-    self->hierarchy = (CFCHierarchy*)CFCBase_incref((CFCBase*)hierarchy);
-    self->header    = CFCUtil_strdup(header);
-    self->footer    = CFCUtil_strdup(footer);
-    return self;
-}
-
-void
-CFCBindCore_destroy(CFCBindCore *self) {
-    CFCBase_decref((CFCBase*)self->hierarchy);
-    FREEMEM(self->header);
-    FREEMEM(self->footer);
-    CFCBase_destroy((CFCBase*)self);
-}
-
-int
-CFCBindCore_write_all_modified(CFCBindCore *self, int modified) {
-    CFCHierarchy *hierarchy = self->hierarchy;
-    const char   *header    = self->header;
-    const char   *footer    = self->footer;
-
-    // Discover whether files need to be regenerated.
-    modified = CFCHierarchy_propagate_modified(hierarchy, modified);
-
-    // Iterate over all File objects, writing out those which don't have
-    // up-to-date auto-generated files.
-    const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
-    CFCFile **files = CFCHierarchy_files(hierarchy);
-    for (int i = 0; files[i] != NULL; i++) {
-        if (CFCFile_get_modified(files[i])) {
-            CFCBindFile_write_h(files[i], inc_dest, header, footer);
-        }
-    }
-
-    // If any class definition has changed, rewrite the parcel.h and parcel.c
-    // files.
-    if (modified) {
-        S_write_platform_h(self);
-
-        CFCParcel **parcels = CFCParcel_all_parcels();
-        for (size_t i = 0; parcels[i]; ++i) {
-            CFCParcel *parcel = parcels[i];
-            // TODO: Skip parcels the source parcels don't depend on.
-            S_write_parcel_h(self, parcel);
-            if (!CFCParcel_included(parcel)) {
-                S_write_parcel_c(self, parcel);
-            }
-        }
-        FREEMEM(parcels);
-    }
-
-    return modified;
-}
-
-/* Write the "parcel.h" header file, which contains common symbols needed by
- * all classes, plus typedefs for all class structs.
- */
-static void
-S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
-    CFCHierarchy *hierarchy   = self->hierarchy;
-    const char   *prefix      = CFCParcel_get_prefix(parcel);
-    const char   *PREFIX      = CFCParcel_get_PREFIX(parcel);
-    const char   *privacy_sym = CFCParcel_get_privacy_sym(parcel);
-
-    // Declare object structs for all instantiable classes.
-    char *typedefs = CFCUtil_strdup("");
-    CFCClass **ordered = CFCHierarchy_ordered_classes(hierarchy);
-    for (int i = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-        const char *class_prefix = CFCClass_get_prefix(klass);
-        if (strcmp(class_prefix, prefix) != 0) { continue; }
-
-        if (!CFCClass_inert(klass)) {
-            const char *full_struct = CFCClass_full_struct_sym(klass);
-            typedefs = CFCUtil_cat(typedefs, "typedef struct ", full_struct,
-                                   " ", full_struct, ";\n", NULL);
-        }
-    }
-    FREEMEM(ordered);
-
-    // Special includes and macros for Clownfish parcel.
-    const char *cfish_includes =
-        "#include <stdarg.h>\n"
-        "#include <stddef.h>\n"
-        "\n"
-        "#include \"cfish_platform.h\"\n"
-        "#include \"cfish_hostdefs.h\"\n";
-
-    // Special definitions for Clownfish parcel.
-    const char *cfish_defs =
-        "#define CFISH_UNUSED_VAR(var) ((void)var)\n"
-        "#define CFISH_UNREACHABLE_RETURN(type) return (type)0\n"
-        "\n"
-        "/* Generic method pointer.\n"
-        " */\n"
-        "typedef void\n"
-        "(*cfish_method_t)(const void *vself);\n"
-        "\n"
-        "/* Access the function pointer for a given method from the vtable.\n"
-        " */\n"
-        "#define CFISH_METHOD_PTR(_vtable, _full_meth) \\\n"
-        "     ((_full_meth ## _t)cfish_method(_vtable, _full_meth ## _OFFSET))\n"
-        "\n"
-        "static CFISH_INLINE cfish_method_t\n"
-        "cfish_method(const void *vtable, size_t offset) {\n"
-        "    union { char *cptr; cfish_method_t *fptr; } ptr;\n"
-        "    ptr.cptr = (char*)vtable + offset;\n"
-        "    return ptr.fptr[0];\n"
-        "}\n"
-        "\n"
-        "typedef struct cfish_Dummy {\n"
-        "   CFISH_OBJ_HEAD\n"
-        "   void *vtable;\n"
-        "} cfish_Dummy;\n"
-        "\n"
-        "/* Access the function pointer for a given method from the object.\n"
-        " */\n"
-        "static CFISH_INLINE cfish_method_t\n"
-        "cfish_obj_method(const void *object, size_t offset) {\n"
-        "    cfish_Dummy *dummy = (cfish_Dummy*)object;\n"
-        "    return cfish_method(dummy->vtable, offset);\n"
-        "}\n"
-        "\n"
-        "/* Access the function pointer for the given method in the superclass's\n"
-        " * vtable. */\n"
-        "#define CFISH_SUPER_METHOD_PTR(_vtable, _full_meth) \\\n"
-        "     ((_full_meth ## _t)cfish_super_method(_vtable, \\\n"
-        "                                           _full_meth ## _OFFSET))\n"
-        "\n"
-        "extern CFISH_VISIBLE size_t cfish_VTable_offset_of_parent;\n"
-        "static CFISH_INLINE cfish_method_t\n"
-        "cfish_super_method(const void *vtable, size_t offset) {\n"
-        "    char *vt_as_char = (char*)vtable;\n"
-        "    cfish_VTable **parent_ptr\n"
-        "        = (cfish_VTable**)(vt_as_char + cfish_VTable_offset_of_parent);\n"
-        "    return cfish_method(*parent_ptr, offset);\n"
-        "}\n"
-        "\n"
-        "/* Structs for VTable initialization.\n"
-        " */\n"
-        "\n"
-        "typedef struct cfish_NovelMethSpec {\n"
-        "    size_t         *offset;\n"
-        "    const char     *name;\n"
-        "    cfish_method_t  func;\n"
-        "    cfish_method_t  callback_func;\n"
-        "} cfish_NovelMethSpec;\n"
-        "\n"
-        "typedef struct cfish_OverriddenMethSpec {\n"
-        "    size_t         *offset;\n"
-        "    size_t         *parent_offset;\n"
-        "    cfish_method_t  func;\n"
-        "} cfish_OverriddenMethSpec;\n"
-        "\n"
-        "typedef struct cfish_InheritedMethSpec {\n"
-        "    size_t *offset;\n"
-        "    size_t *parent_offset;\n"
-        "} cfish_InheritedMethSpec;\n"
-        "\n"
-        "typedef struct cfish_VTableSpec {\n"
-        "    cfish_VTable **vtable;\n"
-        "    cfish_VTable **parent;\n"
-        "    const char    *name;\n"
-        "    size_t         ivars_size;\n"
-        "    size_t        *ivars_offset_ptr;\n"
-        "    uint32_t       num_novel_meths;\n"
-        "    uint32_t       num_overridden_meths;\n"
-        "    uint32_t       num_inherited_meths;\n"
-        "    const cfish_NovelMethSpec      *novel_meth_specs;\n"
-        "    const cfish_OverriddenMethSpec *overridden_meth_specs;\n"
-        "    const cfish_InheritedMethSpec  *inherited_meth_specs;\n"
-        "} cfish_VTableSpec;\n"
-        "\n"
-        "#ifdef CFISH_USE_SHORT_NAMES\n"
-        "  #define METHOD_PTR               CFISH_METHOD_PTR\n"
-        "  #define SUPER_METHOD_PTR         CFISH_SUPER_METHOD_PTR\n"
-        "  #define NovelMethSpec            cfish_NovelMethSpec\n"
-        "  #define OverriddenMethSpec       cfish_OverriddenMethSpec\n"
-        "  #define InheritedMethSpec        cfish_InheritedMethSpec\n"
-        "  #define VTableSpec               cfish_VTableSpec\n"
-        "#endif\n"
-        "\n";
-
-    const char *extra_defs;
-    char *extra_includes;
-    if (strcmp(prefix, "cfish_") == 0) {
-        extra_defs = cfish_defs;
-        extra_includes = CFCUtil_strdup(cfish_includes);
-    }
-    else {
-        extra_defs = "";
-        extra_includes = CFCUtil_strdup("");
-
-        // Include parcel.h of dependent 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]);
-            extra_includes = CFCUtil_cat(extra_includes, "#include <",
-                                         dep_prefix, "parcel.h>\n", NULL);
-        }
-        FREEMEM(dep_parcels);
-    }
-
-    const char pattern[] =
-        "%s\n"
-        "#ifndef CFISH_%sPARCEL_H\n"
-        "#define CFISH_%sPARCEL_H 1\n"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "extern \"C\" {\n"
-        "#endif\n"
-        "\n"
-        "%s" // Extra includes.
-        "\n"
-        "#ifdef %s\n"
-        "  #define %sVISIBLE CFISH_EXPORT\n"
-        "#else\n"
-        "  #define %sVISIBLE CFISH_IMPORT\n"
-        "#endif\n"
-        "\n"
-        "%s" // Typedefs.
-        "\n"
-        "%s" // Extra definitions.
-        "%sVISIBLE void\n"
-        "%sbootstrap_inheritance();\n"
-        "\n"
-        "%sVISIBLE void\n"
-        "%sbootstrap_parcel();\n"
-        "\n"
-        "void\n"
-        "%sinit_parcel();\n"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "}\n"
-        "#endif\n"
-        "\n"
-        "#endif /* CFISH_%sPARCEL_H */\n"
-        "\n"
-        "%s\n"
-        "\n";
-    char *file_content
-        = CFCUtil_sprintf(pattern, self->header, PREFIX, PREFIX,
-                          extra_includes, privacy_sym, PREFIX, PREFIX,
-                          typedefs, extra_defs, PREFIX, prefix, PREFIX, prefix,
-                          prefix, PREFIX, self->footer);
-
-    // Unlink then write file.
-    const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "%sparcel.h", inc_dest,
-                                     prefix);
-    remove(filepath);
-    CFCUtil_write_file(filepath, file_content, strlen(file_content));
-    FREEMEM(filepath);
-
-    FREEMEM(typedefs);
-    FREEMEM(extra_includes);
-    FREEMEM(file_content);
-}
-
-static void
-S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
-    CFCHierarchy *hierarchy = self->hierarchy;
-    const char   *prefix    = CFCParcel_get_prefix(parcel);
-
-    // Aggregate C code for the parcel.
-    char *privacy_syms = CFCUtil_strdup("");
-    char *includes     = CFCUtil_strdup("");
-    char *c_data       = CFCUtil_strdup("");
-    char *vt_specs = CFCUtil_strdup(
-        "static const cfish_VTableSpec vtable_specs[] = {\n");
-    int num_specs = 0;
-    CFCClass **ordered  = CFCHierarchy_ordered_classes(hierarchy);
-    for (int i = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-        const char *class_prefix = CFCClass_get_prefix(klass);
-        if (strcmp(class_prefix, prefix) != 0) { continue; }
-
-        const char *include_h = CFCClass_include_h(klass);
-        includes = CFCUtil_cat(includes, "#include \"", include_h,
-                               "\"\n", NULL);
-
-        CFCBindClass *class_binding = CFCBindClass_new(klass);
-        char *class_c_data = CFCBindClass_to_c_data(class_binding);
-        c_data = CFCUtil_cat(c_data, class_c_data, "\n", NULL);
-        FREEMEM(class_c_data);
-        if (!CFCClass_inert(klass)) {
-            if (num_specs != 0) {
-                vt_specs = CFCUtil_cat(vt_specs, ",\n", NULL);
-            }
-            char *vt_spec = CFCBindClass_spec_def(class_binding);
-            vt_specs = CFCUtil_cat(vt_specs, vt_spec, NULL);
-            FREEMEM(vt_spec);
-            ++num_specs;
-        }
-        CFCBase_decref((CFCBase*)class_binding);
-        const char *privacy_sym = CFCClass_privacy_symbol(klass);
-        privacy_syms = CFCUtil_cat(privacy_syms, "#define ",
-                                   privacy_sym, "\n", NULL);
-    }
-    vt_specs = CFCUtil_cat(vt_specs, "\n};\n", NULL);
-    FREEMEM(ordered);
-
-    // Bootstrapping code for dependent parcels.
-    //
-    // bootstrap_inheritance() first calls bootstrap_inheritance() for all
-    // 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 *inh_bootstrap = CFCUtil_strdup("");
-    char *dep_bootstrap = CFCUtil_strdup("");
-    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);
-    }
-    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"
-        "\n"
-        "#define C_CFISH_VTABLE\n"          // Needed for abstract methods.
-        "#include <stdio.h>\n"
-        "#include <stdlib.h>\n"
-        "%s\n"
-        "#include \"%sparcel.h\"\n"
-        "#include \"callbacks.h\"\n"
-        "#include \"Clownfish/String.h\"\n"  // Needed for dump/load.
-        "#include \"Clownfish/Err.h\"\n"     // Needed for dump/load.
-        "#include \"Clownfish/Num.h\"\n"     // Needed for dump/load.
-        "#include \"Clownfish/VArray.h\"\n"  // Needed for dump/load.
-        "#include \"Clownfish/VTable.h\"\n"  // Needed for bootstrap.
-        "%s\n"
-        "\n"
-        "%s\n"
-        "\n"
-        "/* VTableSpec structs for initialization.\n"
-        " */\n"
-        "%s\n"
-        "\n"
-        "static int bootstrap_state = 0;\n"
-        "\n"
-        "void\n"
-        "%sbootstrap_inheritance() {\n"
-        "    if (bootstrap_state == 1) {\n"
-        "        fprintf(stderr, \"Cycle in class inheritance between\"\n"
-        "                        \" parcels detected.\\n\");\n"
-        "        abort();\n"
-        "    }\n"
-        "    if (bootstrap_state >= 2) { return; }\n"
-        "    bootstrap_state = 1;\n"
-        "%s" // Bootstrap inherited parcels.
-        "    cfish_VTable_bootstrap(vtable_specs, %d);\n"
-        "    bootstrap_state = 2;\n"
-        "}\n"
-        "\n"
-        "void\n"
-        "%sbootstrap_parcel() {\n"
-        "    if (bootstrap_state >= 3) { return; }\n"
-        "    %sbootstrap_inheritance();\n"
-        "    bootstrap_state = 3;\n"
-        "%s" // Finish bootstrapping of all dependent parcels.
-        "    %sinit_parcel();\n"
-        "}\n"
-        "\n"
-        "%s\n";
-    char *file_content
-        = CFCUtil_sprintf(pattern, self->header, privacy_syms, prefix,
-                          includes, c_data, vt_specs, prefix, inh_bootstrap,
-                          num_specs, prefix, prefix, dep_bootstrap, prefix,
-                          self->footer);
-
-    // Unlink then open file.
-    const char *src_dest = CFCHierarchy_get_source_dest(hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "%sparcel.c", src_dest,
-                                     prefix);
-    remove(filepath);
-    CFCUtil_write_file(filepath, file_content, strlen(file_content));
-    FREEMEM(filepath);
-
-    FREEMEM(privacy_syms);
-    FREEMEM(includes);
-    FREEMEM(c_data);
-    FREEMEM(vt_specs);
-    FREEMEM(inh_bootstrap);
-    FREEMEM(dep_bootstrap);
-    FREEMEM(file_content);
-}
-
-/* Write the "callbacks.h" header file, which contains declarations of host
- * callbacks.
- */
-void
-CFCBindCore_write_callbacks_h(CFCBindCore *self) {
-    CFCHierarchy  *hierarchy   = self->hierarchy;
-    CFCClass     **ordered     = CFCHierarchy_ordered_classes(hierarchy);
-    char          *includes    = CFCUtil_strdup("");
-    char          *all_cb_decs = CFCUtil_strdup("");
-
-    for (int i = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-
-        const char *include_h = CFCClass_include_h(klass);
-        includes = CFCUtil_cat(includes, "#include \"", include_h, "\"\n",
-                               NULL);
-
-        if (!CFCClass_included(klass)) {
-            CFCBindClass *class_binding = CFCBindClass_new(klass);
-            char *cb_decs = CFCBindClass_callback_decs(class_binding);
-            all_cb_decs = CFCUtil_cat(all_cb_decs, cb_decs, NULL);
-            FREEMEM(cb_decs);
-            CFCBase_decref((CFCBase*)class_binding);
-        }
-    }
-
-    FREEMEM(ordered);
-
-    const char pattern[] =
-        "%s\n"
-        "#ifndef CFCCALLBACKS_H\n"
-        "#define CFCCALLBACKS_H 1\n"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "extern \"C\" {\n"
-        "#endif\n"
-        "\n"
-        "%s"
-        "\n"
-        "%s"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "}\n"
-        "#endif\n"
-        "\n"
-        "#endif /* CFCCALLBACKS_H */\n"
-        "\n"
-        "%s\n"
-        "\n";
-    char *file_content
-        = CFCUtil_sprintf(pattern, self->header, includes, all_cb_decs,
-                          self->footer);
-
-    // Unlink then write file.
-    const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "callbacks.h", inc_dest);
-    remove(filepath);
-    CFCUtil_write_file(filepath, file_content, strlen(file_content));
-    FREEMEM(filepath);
-
-    FREEMEM(includes);
-    FREEMEM(all_cb_decs);
-    FREEMEM(file_content);
-}
-
-/* Write the "cfish_platform.h" header file, which contains platform-specific
- * definitions.
- */
-static void
-S_write_platform_h(CFCBindCore *self) {
-    char *feature_defs = S_charmony_feature_defines();
-    char *string_defs  = S_charmony_string_defines();
-    char *stdbool_defs = S_charmony_stdbool_defines();
-    char *stdint_defs  = S_charmony_stdint_defines();
-    char *alloca_defs  = S_charmony_alloca_defines();
-
-    const char pattern[] =
-        "%s"
-        "\n"
-        "#ifndef CFISH_PLATFORM_H\n"
-        "#define CFISH_PLATFORM_H 1\n"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "extern \"C\" {\n"
-        "#endif\n"
-        "\n"
-        "%s"
-        "%s"
-        "\n"
-        "%s"
-        "%s"
-        "\n"
-        "%s"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "}\n"
-        "#endif\n"
-        "\n"
-        "#endif /* CFISH_PLATFORM_H */\n"
-        "\n"
-        "%s"
-        "\n";
-    char *file_content
-        = CFCUtil_sprintf(pattern, self->header, feature_defs, string_defs,
-                          stdbool_defs, stdint_defs, alloca_defs,
-                          self->footer);
-
-    // Unlink then write file.
-    const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_platform.h",
-                                     inc_dest);
-    remove(filepath);
-    CFCUtil_write_file(filepath, file_content, strlen(file_content));
-    FREEMEM(filepath);
-
-    FREEMEM(feature_defs);
-    FREEMEM(string_defs);
-    FREEMEM(stdbool_defs);
-    FREEMEM(stdint_defs);
-    FREEMEM(alloca_defs);
-    FREEMEM(file_content);
-}
-
-static char*
-S_charmony_feature_defines() {
-    char *defines = CFCUtil_strdup("");
-
-#ifdef CHY_HAS_WINDOWS_H
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_WINDOWS_H\n", NULL);
-#endif
-#ifdef CHY_HAS_SYS_ATOMIC_H
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_SYS_ATOMIC_H\n", NULL);
-#endif
-#ifdef CHY_HAS_PTHREAD_H
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_PTHREAD_H\n", NULL);
-#endif
-#ifdef CHY_LITTLE_END
-    defines = CFCUtil_cat(defines, "#define CFISH_LITTLE_END\n", NULL);
-#endif
-#ifdef CHY_BIG_END
-    defines = CFCUtil_cat(defines, "#define CFISH_BIG_END\n", NULL);
-#endif
-#ifdef CHY_HAS_FUNC_MACRO
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_FUNC_MACRO\n", NULL);
-#endif
-#ifdef CHY_HAS_VARIADIC_MACROS
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_VARIADIC_MACROS\n",
-                          NULL);
-#endif
-#ifdef CHY_HAS_ISO_VARIADIC_MACROS
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_ISO_VARIADIC_MACROS\n",
-                          NULL);
-#endif
-#ifdef CHY_HAS_GNUC_VARIADIC_MACROS
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_GNUC_VARIADIC_MACROS\n",
-                          NULL);
-#endif
-#ifdef CHY_HAS_OSATOMIC_CAS_PTR
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_OSATOMIC_CAS_PTR\n",
-                          NULL);
-#endif
-
-    return defines;
-}
-
-static char*
-S_charmony_string_defines() {
-    const char *pattern =
-        "#define CFISH_INLINE %s\n"
-        "#define CFISH_EXPORT %s\n"
-        "#define CFISH_IMPORT %s\n"
-        "#define CFISH_SIZEOF_CHAR %s\n"
-        "#define CFISH_SIZEOF_SHORT %s\n"
-        "#define CFISH_SIZEOF_INT %s\n"
-        "#define CFISH_SIZEOF_LONG %s\n"
-        "#define CFISH_SIZEOF_SIZE_T %s\n"
-        "#define CFISH_FUNC_MACRO %s\n"
-        "#define CFISH_U64_TO_DOUBLE(x) %s\n";
-    char *defines
-        = CFCUtil_sprintf(pattern,
-                          XSTRING(CHY_INLINE),
-                          XSTRING(CHY_EXPORT),
-                          XSTRING(CHY_IMPORT),
-                          XSTRING(CHY_SIZEOF_CHAR),
-                          XSTRING(CHY_SIZEOF_SHORT),
-                          XSTRING(CHY_SIZEOF_INT),
-                          XSTRING(CHY_SIZEOF_LONG),
-                          XSTRING(CHY_SIZEOF_SIZE_T),
-                          XSTRING(CHY_FUNC_MACRO),
-                          XSTRING(CHY_U64_TO_DOUBLE(x)));
-
-    return defines;
-}
-
-static char*
-S_charmony_stdbool_defines() {
-#ifdef CHY_HAS_STDBOOL_H
-    const char *defines = "#include <stdbool.h>\n";
-#else
-    const char *defines =
-        "#if (!defined(__cplusplus) && !defined(CFISH_HAS_STDBOOL))\n"
-        "  typedef int bool;\n"
-        "  #ifndef true\n"
-        "    #define true 1\n"
-        "  #endif\n"
-        "  #ifndef false\n"
-        "    #define false 0\n"
-        "  #endif\n"
-        "#endif\n";
-#endif
-
-    return CFCUtil_strdup(defines);
-}
-
-static char*
-S_charmony_stdint_defines() {
-#ifdef CHY_HAS_STDINT_H
-    return CFCUtil_strdup("#include <stdint.h>\n");
-#else
-    const char *pattern =
-        "#ifndef CFISH_HAS_STDINT\n"
-        "  typedef %s int8_t;\n"
-        "  typedef %s uint8_t;\n"
-        "  typedef %s int16_t;\n"
-        "  typedef %s uint16_t;\n"
-        "  typedef %s int32_t;\n"
-        "  typedef %s uint32_t;\n"
-        "  typedef %s int64_t;\n"
-        "  typedef %s uint64_t;\n"
-        "#endif\n";
-    return CFCUtil_sprintf(pattern,
-                           XSTRING(CHY_INT8_T),  XSTRING(CHY_UINT8_T),
-                           XSTRING(CHY_INT16_T), XSTRING(CHY_UINT16_T),
-                           XSTRING(CHY_INT32_T), XSTRING(CHY_UINT32_T),
-                           XSTRING(CHY_INT64_T), XSTRING(CHY_UINT64_T));
-#endif
-}
-
-static char*
-S_charmony_alloca_defines() {
-    char *defines = CFCUtil_strdup("");
-
-#if defined(CHY_HAS_ALLOCA_H)
-    defines = CFCUtil_cat(defines, "#include <alloca.h>\n", NULL);
-#elif defined(CHY_HAS_MALLOC_H)
-    defines = CFCUtil_cat(defines, "#include <malloc.h>\n", NULL);
-#elif defined(CHY_ALLOCA_IN_STDLIB_H)
-    defines = CFCUtil_cat(defines, "#include <stdlib.h>\n", NULL);
-#endif
-
-    defines = CFCUtil_cat(defines, "#define cfish_alloca ",
-                          XSTRING(chy_alloca), "\n", NULL);
-
-    return defines;
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindCore.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.h b/clownfish/compiler/src/CFCBindCore.h
deleted file mode 100644
index 33fdd82..0000000
--- a/clownfish/compiler/src/CFCBindCore.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Clownfish::CFC::Binding::Core - Generate core C code for a
- * Clownfish::CFC::Model::Hierarchy.
- *
- * A Clownfish::CFC::Model::Hierarchy describes an abstract specifiction for a
- * class hierarchy; Clownfish::CFC::Binding::Core is responsible for
- * auto-generating C code which implements that specification.
- */
-#ifndef H_CFCBINDCORE
-#define H_CFCBINDCORE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCBindCore CFCBindCore;
-struct CFCHierarchy;
-
-
-/**
- * @param hierarchy A L<Clownfish::CFC::Model::Hierarchy>.
- * @param header Text which will be prepended to each generated C file --
- * typically, an "autogenerated file" warning.
- * @param footer Text to be appended to the end of each generated C file --
- * typically copyright information.
- */
-CFCBindCore*
-CFCBindCore_new(struct CFCHierarchy *hierarchy, const char *header,
-                const char *footer);
-
-CFCBindCore*
-CFCBindCore_init(CFCBindCore *self, struct CFCHierarchy *hierarchy,
-                 const char *header, const char *footer);
-
-void
-CFCBindCore_destroy(CFCBindCore *self);
-
-/** Call <code>CFCHierarchy_propagate_modified</code>to establish which
- * classes do not have up-to-date generated .c and .h files, then traverse the
- * hierarchy writing all necessary files.
- */
-int
-CFCBindCore_write_all_modified(CFCBindCore *self, int modified);
-
-/** Write the "callbacks.h" header file, which contains declarations of host
- * callbacks.
- */
-void
-CFCBindCore_write_callbacks_h(CFCBindCore *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCBINDCORE */
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindFile.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindFile.c b/clownfish/compiler/src/CFCBindFile.c
deleted file mode 100644
index 928254d..0000000
--- a/clownfish/compiler/src/CFCBindFile.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "charmony.h"
-
-#include <stdio.h>
-#include <string.h>
-#include "CFCBindFile.h"
-#include "CFCBindClass.h"
-#include "CFCBase.h"
-#include "CFCFile.h"
-#include "CFCClass.h"
-#include "CFCCBlock.h"
-#include "CFCParcel.h"
-#include "CFCUtil.h"
-
-void
-CFCBindFile_write_h(CFCFile *file, const char *dest, const char *header,
-                    const char *footer) {
-    CFCUTIL_NULL_CHECK(file);
-    CFCUTIL_NULL_CHECK(dest);
-    CFCUTIL_NULL_CHECK(header);
-    CFCUTIL_NULL_CHECK(footer);
-
-    // Make directories.
-    char *h_path = CFCFile_h_path(file, dest);
-    char *h_dir  = CFCUtil_strdup(h_path);
-    for (size_t len = strlen(h_dir); len--;) {
-        if (h_dir[len] == CHY_DIR_SEP_CHAR) {
-            h_dir[len] = 0;
-            break;
-        }
-    }
-    if (!CFCUtil_is_dir(h_dir)) {
-        CFCUtil_make_path(h_dir);
-        if (!CFCUtil_is_dir(h_dir)) {
-            CFCUtil_die("Can't make path %s", h_dir);
-        }
-    }
-    FREEMEM(h_dir);
-
-    // Create the include-guard strings.
-    const char *include_guard_start = CFCFile_guard_start(file);
-    const char *include_guard_close = CFCFile_guard_close(file);
-
-    // Aggregate block content.
-    char *content = CFCUtil_strdup("");
-    CFCBase **blocks = CFCFile_blocks(file);
-    for (int i = 0; blocks[i] != NULL; i++) {
-        const char *cfc_class = CFCBase_get_cfc_class(blocks[i]);
-
-        if (strcmp(cfc_class, "Clownfish::CFC::Model::Parcel") == 0) {
-            CFCParcel *parcel = (CFCParcel*)blocks[i];
-            const char *prefix = CFCParcel_get_prefix(parcel);
-            content = CFCUtil_cat(content, "#include \"", prefix,
-                                  "parcel.h\"\n\n", NULL);
-        }
-        else if (strcmp(cfc_class, "Clownfish::CFC::Model::Class") == 0) {
-            CFCBindClass *class_binding
-                = CFCBindClass_new((CFCClass*)blocks[i]);
-            char *c_header = CFCBindClass_to_c_header(class_binding);
-            content = CFCUtil_cat(content, c_header, "\n", NULL);
-            FREEMEM(c_header);
-            CFCBase_decref((CFCBase*)class_binding);
-        }
-        else if (strcmp(cfc_class, "Clownfish::CFC::Model::CBlock") == 0) {
-            const char *block_contents 
-                = CFCCBlock_get_contents((CFCCBlock*)blocks[i]);
-            content = CFCUtil_cat(content, block_contents, "\n", NULL);
-        }
-        else {
-            CFCUtil_die("Unexpected class: %s", cfc_class);
-        }
-    }
-
-    char pattern[] =
-        "%s\n"
-        "\n"
-        "%s\n"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "extern \"C\" {\n"
-        "#endif\n"
-        "\n"
-        "%s\n"
-        "\n"
-        "#ifdef __cplusplus\n"
-        "}\n"
-        "#endif\n"
-        "\n"
-        "%s\n"
-        "\n"
-        "%s\n"
-        "\n";
-    char *file_content
-        = CFCUtil_sprintf(pattern, header, include_guard_start, content,
-                          include_guard_close, footer);
-
-    // Unlink then write file.
-    remove(h_path);
-    CFCUtil_write_file(h_path, file_content, strlen(file_content));
-
-    FREEMEM(content);
-    FREEMEM(file_content);
-    FREEMEM(h_path);
-}
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindFile.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindFile.h b/clownfish/compiler/src/CFCBindFile.h
deleted file mode 100644
index 4b24923..0000000
--- a/clownfish/compiler/src/CFCBindFile.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef H_CFCBINDFILE
-#define H_CFCBINDFILE
-
-/** Clownfish::CFC::Binding::Core::File - Generate core C code for a Clownfish file.
- *
- * This module is the companion to Clownfish::CFC::Model::File, generating the
- * C code needed to implement the file's specification.
- *
- * There is a one-to-one mapping between Clownfish header files and
- * autogenerated .h and .c files.  If Foo.cfh includes both Foo and
- * Foo::FooJr, then it is necessary to pound-include "Foo.h" in order to get
- * FooJr's interface -- not "Foo/FooJr.h", which won't exist.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct CFCFile;
-
-/** Generate a C header file containing all class declarations and literal C
- * blocks.
- *
- * @param file A Clownfish::CFC::Model::File.
- * @param dest The directory under which autogenerated files are being
- * written.
- * @param header Text which will be prepended to each generated C file --
- * typically, an "autogenerated file" warning.
- * @param footer Text to be appended to the end of each generated C file --
- * typically copyright information.
- */
-void
-CFCBindFile_write_h(struct CFCFile *file, const char *dest,
-                    const char *header, const char *footer);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCBINDFILE */
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindFunction.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindFunction.c b/clownfish/compiler/src/CFCBindFunction.c
deleted file mode 100644
index ae71d84..0000000
--- a/clownfish/compiler/src/CFCBindFunction.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "CFCBindFunction.h"
-#include "CFCUtil.h"
-#include "CFCFunction.h"
-#include "CFCParamList.h"
-#include "CFCType.h"
-
-char*
-CFCBindFunc_func_declaration(CFCFunction *func) {
-    CFCType      *return_type    = CFCFunction_get_return_type(func);
-    CFCParamList *param_list     = CFCFunction_get_param_list(func);
-    const char   *ret_type_str   = CFCType_to_c(return_type);
-    const char   *full_func_sym  = CFCFunction_full_func_sym(func);
-    const char   *param_list_str = CFCParamList_to_c(param_list);
-    const char   *inline_prop    = CFCFunction_inline(func)
-                                   ? "static CFISH_INLINE "
-                                   : "";
-    char *buf = CFCUtil_sprintf("%s%s\n%s(%s);", inline_prop, ret_type_str,
-                                full_func_sym, param_list_str);
-    return buf;
-}
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindFunction.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindFunction.h b/clownfish/compiler/src/CFCBindFunction.h
deleted file mode 100644
index 5297b01..0000000
--- a/clownfish/compiler/src/CFCBindFunction.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Clownfish::CFC::Binding::Core::Function - Generate core C code for a function.
- */
-
-#ifndef H_CFCBINDFUNCTION
-#define H_CFCBINDFUNCTION
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct CFCFunction;
-
-/** Return C code declaring the function's C implementation.
- */
-char*
-CFCBindFunc_func_declaration(struct CFCFunction *func);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCBINDFUNCTION */
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindMethod.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindMethod.c b/clownfish/compiler/src/CFCBindMethod.c
deleted file mode 100644
index 3448e44..0000000
--- a/clownfish/compiler/src/CFCBindMethod.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include "CFCBindMethod.h"
-#include "CFCUtil.h"
-#include "CFCMethod.h"
-#include "CFCFunction.h"
-#include "CFCParamList.h"
-#include "CFCType.h"
-#include "CFCVariable.h"
-#include "CFCSymbol.h"
-#include "CFCClass.h"
-
-/* Create a macro definition that aliases to a function name directly, since
- * this method may not be overridden. */
-static char*
-S_final_method_def(CFCMethod *method, CFCClass *klass);
-
-static char*
-S_virtual_method_def(CFCMethod *method, CFCClass *klass);
-
-/* Take a NULL-terminated list of CFCVariables and build up a string of
- * directives like:
- *
- *     UNUSED_VAR(var1);
- *     UNUSED_VAR(var2);
- */
-static char*
-S_build_unused_vars(CFCVariable **vars);
-
-/* Create an unreachable return statement if necessary, in order to thwart
- * compiler warnings. */
-static char*
-S_maybe_unreachable(CFCType *return_type);
-
-char*
-CFCBindMeth_method_def(CFCMethod *method, CFCClass *klass) {
-    if (CFCMethod_final(method)) {
-        return S_final_method_def(method, klass);
-    }
-    else {
-        return S_virtual_method_def(method, klass);
-    }
-}
-
-/* Create a macro definition that aliases to a function name directly, since
- * this method may not be overridden. */
-static char*
-S_final_method_def(CFCMethod *method, CFCClass *klass) {
-    const char *self_type = CFCType_to_c(CFCMethod_self_type(method));
-    const char *full_func_sym = CFCMethod_imp_func(method);
-    const char *arg_names 
-        = CFCParamList_name_list(CFCMethod_get_param_list(method));
-
-    char *full_meth_sym   = CFCMethod_full_method_sym(method, klass);
-    char *full_offset_sym = CFCMethod_full_offset_sym(method, klass);
-
-    const char pattern[] =
-        "extern size_t %s;\n"
-        "#define %s(%s) \\\n"
-        "    %s((%s)%s)\n";
-    char *method_def
-        = CFCUtil_sprintf(pattern, full_offset_sym, full_meth_sym, arg_names,
-                          full_func_sym, self_type, arg_names);
-
-    FREEMEM(full_offset_sym);
-    FREEMEM(full_meth_sym);
-    return method_def;
-}
-
-static char*
-S_virtual_method_def(CFCMethod *method, CFCClass *klass) {
-    CFCParamList *param_list = CFCMethod_get_param_list(method);
-    const char *PREFIX         = CFCClass_get_PREFIX(klass);
-    const char *invoker_struct = CFCClass_full_struct_sym(klass);
-
-    char *full_meth_sym   = CFCMethod_full_method_sym(method, klass);
-    char *full_offset_sym = CFCMethod_full_offset_sym(method, klass);
-    char *full_typedef    = CFCMethod_full_typedef(method, klass);
-
-    // Prepare parameter lists, minus invoker.  The invoker gets forced to
-    // "self" later.
-    if (CFCParamList_variadic(param_list)) {
-        CFCUtil_die("Variadic methods not supported");
-    }
-    const char *arg_names_minus_invoker = CFCParamList_name_list(param_list);
-    const char *params_minus_invoker    = CFCParamList_to_c(param_list);
-    while (*arg_names_minus_invoker && *arg_names_minus_invoker != ',') {
-        arg_names_minus_invoker++;
-    }
-    while (*params_minus_invoker && *params_minus_invoker != ',') {
-        params_minus_invoker++;
-    }
-
-    // Prepare a return statement... or not.
-    CFCType *return_type = CFCMethod_get_return_type(method);
-    const char *ret_type_str = CFCType_to_c(return_type);
-    const char *maybe_return = CFCType_is_void(return_type) ? "" : "return ";
-
-    const char pattern[] =
-        "extern %sVISIBLE size_t %s;\n"
-        "static CFISH_INLINE %s\n"
-        "%s(%s *self%s) {\n"
-        "    const %s method = (%s)cfish_obj_method(self, %s);\n"
-        "    %smethod(self%s);\n"
-        "}\n";
-    char *method_def
-        = CFCUtil_sprintf(pattern, PREFIX, full_offset_sym, ret_type_str,
-                          full_meth_sym, invoker_struct, params_minus_invoker,
-                          full_typedef, full_typedef, full_offset_sym,
-                          maybe_return, arg_names_minus_invoker);
-
-    FREEMEM(full_offset_sym);
-    FREEMEM(full_meth_sym);
-    FREEMEM(full_typedef);
-    return method_def;
-}
-
-char*
-CFCBindMeth_typedef_dec(struct CFCMethod *method, CFCClass *klass) {
-    const char *params_minus_invoker
-        = CFCParamList_to_c(CFCMethod_get_param_list(method));
-    while (*params_minus_invoker && *params_minus_invoker != ',') {
-        params_minus_invoker++;
-    }
-    const char *self_struct = CFCClass_full_struct_sym(klass);
-    const char *ret_type = CFCType_to_c(CFCMethod_get_return_type(method));
-    char *full_typedef = CFCMethod_full_typedef(method, klass);
-    char *buf = CFCUtil_sprintf("typedef %s\n(*%s)(%s *self%s);\n", ret_type,
-                                full_typedef, self_struct,
-                                params_minus_invoker);
-    FREEMEM(full_typedef);
-    return buf;
-}
-
-char*
-CFCBindMeth_novel_spec_def(CFCMethod *method) {
-    const char *macro_sym = CFCMethod_get_macro_sym(method);
-    const char *imp_func  = CFCMethod_imp_func(method);
-
-    const char *full_override_sym = "NULL";
-    if (!CFCMethod_final(method)) {
-        full_override_sym = CFCMethod_full_override_sym(method);
-    }
-
-    char *full_offset_sym = CFCMethod_full_offset_sym(method, NULL);
-
-    char pattern[] =
-        "    {\n"
-        "        &%s, /* offset */\n"
-        "        \"%s\", /* name */\n"
-        "        (cfish_method_t)%s, /* func */\n"
-        "        (cfish_method_t)%s /* callback_func */\n"
-        "    }";
-    char *def
-        = CFCUtil_sprintf(pattern, full_offset_sym, macro_sym, imp_func,
-                          full_override_sym);
-
-    FREEMEM(full_offset_sym);
-    return def;
-}
-
-char*
-CFCBindMeth_overridden_spec_def(CFCMethod *method, CFCClass *klass) {
-    const char *imp_func  = CFCMethod_imp_func(method);
-
-    char *full_offset_sym = CFCMethod_full_offset_sym(method, NULL);
-
-    CFCClass *parent = CFCClass_get_parent(klass);
-    char *parent_offset_sym = CFCMethod_full_offset_sym(method, parent);
-
-    char pattern[] =
-        "    {\n"
-        "        &%s, /* offset */\n"
-        "        &%s, /* parent_offset */\n"
-        "        (cfish_method_t)%s /* func */\n"
-        "    }";
-    char *def
-        = CFCUtil_sprintf(pattern, full_offset_sym, parent_offset_sym,
-                          imp_func);
-
-    FREEMEM(full_offset_sym);
-    FREEMEM(parent_offset_sym);
-    return def;
-}
-
-char*
-CFCBindMeth_inherited_spec_def(CFCMethod *method, CFCClass *klass) {
-    char *full_offset_sym = CFCMethod_full_offset_sym(method, klass);
-
-    CFCClass *parent = CFCClass_get_parent(klass);
-    char *parent_offset_sym = CFCMethod_full_offset_sym(method, parent);
-
-    char pattern[] =
-        "    {\n"
-        "        &%s, /* offset */\n"
-        "        &%s /* parent_offset */\n"
-        "    }";
-    char *def = CFCUtil_sprintf(pattern, full_offset_sym, parent_offset_sym);
-
-    FREEMEM(full_offset_sym);
-    FREEMEM(parent_offset_sym);
-    return def;
-}
-
-static char*
-S_build_unused_vars(CFCVariable **vars) {
-    char *unused = CFCUtil_strdup("");
-
-    for (int i = 0; vars[i] != NULL; i++) {
-        const char *var_name = CFCVariable_micro_sym(vars[i]);
-        size_t size = strlen(unused) + strlen(var_name) + 80;
-        unused = (char*)REALLOCATE(unused, size);
-        strcat(unused, "\n    CFISH_UNUSED_VAR(");
-        strcat(unused, var_name);
-        strcat(unused, ");");
-    }
-
-    return unused;
-}
-
-static char*
-S_maybe_unreachable(CFCType *return_type) {
-    char *return_statement;
-    if (CFCType_is_void(return_type)) {
-        return_statement = CFCUtil_strdup("");
-    }
-    else {
-        const char *ret_type_str = CFCType_to_c(return_type);
-        char pattern[] = "\n    CFISH_UNREACHABLE_RETURN(%s);";
-        return_statement = CFCUtil_sprintf(pattern, ret_type_str);
-    }
-    return return_statement;
-}
-
-char*
-CFCBindMeth_abstract_method_def(CFCMethod *method) {
-    CFCParamList *param_list = CFCMethod_get_param_list(method);
-    const char *params = CFCParamList_to_c(param_list);
-    const char *full_func_sym = CFCMethod_imp_func(method);
-    const char *vtable_var
-        = CFCType_get_vtable_var(CFCMethod_self_type(method));
-    CFCType    *return_type  = CFCMethod_get_return_type(method);
-    const char *ret_type_str = CFCType_to_c(return_type);
-    const char *macro_sym    = CFCMethod_get_macro_sym(method);
-
-    // Thwart compiler warnings.
-    CFCVariable **param_vars = CFCParamList_get_variables(param_list);
-    char *unused = S_build_unused_vars(param_vars + 1);
-    char *return_statement = S_maybe_unreachable(return_type);
-
-    char pattern[] =
-        "%s\n"
-        "%s(%s) {\n"
-        "    cfish_String *klass = self ? CFISH_Obj_Get_Class_Name((cfish_Obj*)self) : %s->name;%s\n"
-        "    CFISH_THROW(CFISH_ERR, \"Abstract method '%s' not defined by %%o\", klass);%s\n"
-        "}\n";
-    char *abstract_def
-        = CFCUtil_sprintf(pattern, ret_type_str, full_func_sym, params,
-                          vtable_var, unused, macro_sym, return_statement);
-
-    FREEMEM(unused);
-    FREEMEM(return_statement);
-    return abstract_def;
-}
-
-char*
-CFCBindMeth_callback_dec(CFCMethod *method) {
-    CFCType *return_type = CFCMethod_get_return_type(method);
-    const char *ret_type_str = CFCType_to_c(return_type);
-    const char *override_sym = CFCMethod_full_override_sym(method);
-    const char *params = CFCParamList_to_c(CFCMethod_get_param_list(method));
-
-    char pattern[] =
-        "%s\n"
-        "%s(%s);\n";
-    char *callback_dec
-        = CFCUtil_sprintf(pattern, ret_type_str, override_sym, params);
-
-    return callback_dec;
-}
-
-char*
-CFCBindMeth_imp_declaration(CFCMethod *method) {
-    CFCType      *return_type    = CFCMethod_get_return_type(method);
-    CFCParamList *param_list     = CFCMethod_get_param_list(method);
-    const char   *ret_type_str   = CFCType_to_c(return_type);
-    const char   *full_imp_sym   = CFCMethod_imp_func(method);
-    const char   *param_list_str = CFCParamList_to_c(param_list);
-    char *buf = CFCUtil_sprintf("%s\n%s(%s);", ret_type_str,
-                                full_imp_sym, param_list_str);
-    return buf;
-}
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCBindMethod.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindMethod.h b/clownfish/compiler/src/CFCBindMethod.h
deleted file mode 100644
index 45bbb31..0000000
--- a/clownfish/compiler/src/CFCBindMethod.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Clownfish::CFC::Binding::Core::Method - Generate core C code for a method.
- *
- * Clownfish::CFC::Model::Method is an abstract specification; this class
- * generates C code which implements the specification.
- */
-
-#ifndef H_CFCBINDMETHOD
-#define H_CFCBINDMETHOD
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct CFCMethod;
-struct CFCClass;
-
-/** Return C code for the static inline vtable method invocation function.
- * @param method A L<Clownfish::CFC::Model::Method>.
- * @param class The L<Clownfish::CFC::Model::Class> which will be invoking the
- * method.  (LobsterClaw needs its own method invocation function even if the
- * method was defined in Claw.)
- */
-char*
-CFCBindMeth_method_def(struct CFCMethod *method, struct CFCClass *klass);
-
-/** Return C code expressing a typedef declaration for the method.
- */
-char*
-CFCBindMeth_typedef_dec(struct CFCMethod *method, struct CFCClass *klass);
-
-/** Return C code defining the MethSpec object for a novel method, which
- * is used during VTable initialization.
- */
-char*
-CFCBindMeth_novel_spec_def(struct CFCMethod *method);
-
-/** Return C code defining the MethSpec object for an overridden method,
- * which is used during VTable initialization.
- */
-char*
-CFCBindMeth_overridden_spec_def(struct CFCMethod *method,
-                                struct CFCClass *klass);
-
-/** Return C code defining the MethSpec object for an inherited method,
- * which is used during VTable initialization.
- */
-char*
-CFCBindMeth_inherited_spec_def(struct CFCMethod *method,
-                               struct CFCClass *klass);
-
-/** Return C code implementing a version of the method which throws an
- * "abstract method" error at runtime, for methods which are declared as
- * "abstract" in a Clownfish header file.
- */
-char*
-CFCBindMeth_abstract_method_def(struct CFCMethod *method);
-
-/** Return C code declaring a callback to the Host for this method.
- */
-char*
-CFCBindMeth_callback_dec(struct CFCMethod *method);
-
-/** Return C code declaring the function which implements a method.
- */
-char*
-CFCBindMeth_imp_declaration(struct CFCMethod *method);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCBINDMETHOD */
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCC.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCC.c b/clownfish/compiler/src/CFCC.c
deleted file mode 100644
index 3f21a0d..0000000
--- a/clownfish/compiler/src/CFCC.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "charmony.h"
-
-#include <stdio.h>
-#include <string.h>
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCC.h"
-#include "CFCCClass.h"
-#include "CFCClass.h"
-#include "CFCHierarchy.h"
-#include "CFCUtil.h"
-
-struct CFCC {
-    CFCBase base;
-    CFCHierarchy *hierarchy;
-    char         *header;
-    char         *footer;
-};
-
-static const CFCMeta CFCC_META = {
-    "Clownfish::CFC::Binding::C",
-    sizeof(CFCC),
-    (CFCBase_destroy_t)CFCC_destroy
-};
-
-CFCC*
-CFCC_new(CFCHierarchy *hierarchy, const char *header, const char *footer) {
-    CFCC *self = (CFCC*)CFCBase_allocate(&CFCC_META);
-    return CFCC_init(self, hierarchy, header, footer);
-}
-
-CFCC*
-CFCC_init(CFCC *self, CFCHierarchy *hierarchy, const char *header,
-          const char *footer) {
-    CFCUTIL_NULL_CHECK(hierarchy);
-    CFCUTIL_NULL_CHECK(header);
-    CFCUTIL_NULL_CHECK(footer);
-    self->hierarchy = (CFCHierarchy*)CFCBase_incref((CFCBase*)hierarchy);
-    self->header    = CFCUtil_strdup(header);
-    self->footer    = CFCUtil_strdup(footer);
-    return self;
-}
-
-void
-CFCC_destroy(CFCC *self) {
-    CFCBase_decref((CFCBase*)self->hierarchy);
-    FREEMEM(self->header);
-    FREEMEM(self->footer);
-    CFCBase_destroy((CFCBase*)self);
-}
-
-/* Write "callbacks.h" with NULL callbacks.
- */
-void
-CFCC_write_callbacks(CFCC *self) {
-    CFCHierarchy  *hierarchy   = self->hierarchy;
-    CFCClass     **ordered     = CFCHierarchy_ordered_classes(hierarchy);
-    char          *all_cb_decs = CFCUtil_strdup("");
-
-    for (int i = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-
-        if (!CFCClass_included(klass)) {
-            char *cb_decs = CFCCClass_callback_decs(klass);
-            all_cb_decs = CFCUtil_cat(all_cb_decs, cb_decs, NULL);
-            FREEMEM(cb_decs);
-        }
-    }
-
-    FREEMEM(ordered);
-
-    const char pattern[] =
-        "%s\n"
-        "#ifndef CFCCALLBACKS_H\n"
-        "#define CFCCALLBACKS_H 1\n"
-        "\n"
-        "#include <stddef.h>\n"
-        "\n"
-        "%s"
-        "\n"
-        "#endif /* CFCCALLBACKS_H */\n"
-        "\n"
-        "%s\n"
-        "\n";
-    char *file_content = CFCUtil_sprintf(pattern, self->header, all_cb_decs,
-                                         self->footer);
-
-    // Unlink then write file.
-    const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "callbacks.h", inc_dest);
-    remove(filepath);
-    CFCUtil_write_file(filepath, file_content, strlen(file_content));
-    FREEMEM(filepath);
-
-    FREEMEM(all_cb_decs);
-    FREEMEM(file_content);
-}
-
-void
-CFCC_write_man_pages(CFCC *self) {
-    CFCHierarchy  *hierarchy = self->hierarchy;
-    CFCClass     **ordered   = CFCHierarchy_ordered_classes(hierarchy);
-
-    size_t num_classes = 0;
-    for (size_t i = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-        if (!CFCClass_included(klass)) { ++num_classes; }
-    }
-    char **man_pages = (char**)CALLOCATE(num_classes, sizeof(char*));
-
-    // Generate man pages, but don't write.  That way, if there's an error
-    // while generating the pages, we leak memory but don't clutter up the file 
-    // system.
-    for (size_t i = 0, j = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-        if (CFCClass_included(klass)) { continue; }
-
-        char *man_page = CFCCClass_create_man_page(klass);
-        man_pages[j++] = man_page;
-    }
-
-    const char *dest = CFCHierarchy_get_dest(hierarchy);
-    char *man3_path
-        = CFCUtil_sprintf("%s" CHY_DIR_SEP "man" CHY_DIR_SEP "man3", dest);
-    if (!CFCUtil_is_dir(man3_path)) {
-        CFCUtil_make_path(man3_path);
-        if (!CFCUtil_is_dir(man3_path)) {
-            CFCUtil_die("Can't make path %s", man3_path);
-        }
-    }
-
-    // Write out any man pages that have changed.
-    for (size_t i = 0, j = 0; ordered[i] != NULL; i++) {
-        CFCClass *klass = ordered[i];
-        if (CFCClass_included(klass)) { continue; }
-
-        char *man_page = man_pages[j++];
-        if (!man_page) { continue; }
-
-        const char *full_struct_sym = CFCClass_full_struct_sym(klass);
-        char *filename = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s.3", man3_path,
-                                         full_struct_sym);
-        CFCUtil_write_if_changed(filename, man_page, strlen(man_page));
-        FREEMEM(filename);
-        FREEMEM(man_page);
-    }
-
-    FREEMEM(man3_path);
-    FREEMEM(man_pages);
-    FREEMEM(ordered);
-}
-
-void
-CFCC_write_hostdefs(CFCC *self) {
-    const char pattern[] =
-        "%s\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);
-
-    // Unlink then write file.
-    const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
-    char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_hostdefs.h",
-                                     inc_dest);
-    remove(filepath);
-    CFCUtil_write_file(filepath, content, strlen(content));
-    FREEMEM(filepath);
-
-    FREEMEM(content);
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCC.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCC.h b/clownfish/compiler/src/CFCC.h
deleted file mode 100644
index 6f665ed..0000000
--- a/clownfish/compiler/src/CFCC.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Clownfish::CFC::Binding::C - Generate code for C bindings.
- */
-#ifndef H_CFCC
-#define H_CFCC
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCC CFCC;
-struct CFCHierarchy;
-
-/**
- * @param hierarchy A L<Clownfish::CFC::Model::Hierarchy>.
- * @param header Text which will be prepended to each generated C file --
- * typically, an "autogenerated file" warning.
- * @param footer Text to be appended to the end of each generated C file --
- * typically copyright information.
- */
-CFCC*
-CFCC_new(struct CFCHierarchy *hierarchy, const char *header,
-         const char *footer);
-
-CFCC*
-CFCC_init(CFCC *self, struct CFCHierarchy *hierarchy, const char *header,
-          const char *footer);
-
-void
-CFCC_destroy(CFCC *self);
-
-/** Write the "callbacks.h" header file with dummy callbacks.
- */
-void
-CFCC_write_callbacks(CFCC *self);
-
-/** Write the "cfish_hostdefs.h" header file.
- */
-void
-CFCC_write_hostdefs(CFCC *self);
-
-/** Write all man pages.
- */
-void
-CFCC_write_man_pages(CFCC *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCC */
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCCBlock.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCCBlock.c b/clownfish/compiler/src/CFCCBlock.c
deleted file mode 100644
index 0231877..0000000
--- a/clownfish/compiler/src/CFCCBlock.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCCBlock.h"
-#include "CFCUtil.h"
-
-struct CFCCBlock {
-    CFCBase base;
-    char *contents;
-};
-
-static const CFCMeta CFCCBLOCK_META = {
-    "Clownfish::CFC::Model::CBlock",
-    sizeof(CFCCBlock),
-    (CFCBase_destroy_t)CFCCBlock_destroy
-};
-
-CFCCBlock*
-CFCCBlock_new(const char *contents) {
-    CFCCBlock *self = (CFCCBlock*)CFCBase_allocate(&CFCCBLOCK_META);
-    return CFCCBlock_init(self, contents);
-}
-
-CFCCBlock*
-CFCCBlock_init(CFCCBlock *self, const char *contents) {
-    CFCUTIL_NULL_CHECK(contents);
-    self->contents = CFCUtil_strdup(contents);
-    return self;
-}
-
-void
-CFCCBlock_destroy(CFCCBlock *self) {
-    FREEMEM(self->contents);
-    CFCBase_destroy((CFCBase*)self);
-}
-
-const char*
-CFCCBlock_get_contents(CFCCBlock *self) {
-    return self->contents;
-}
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCCBlock.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCCBlock.h b/clownfish/compiler/src/CFCCBlock.h
deleted file mode 100644
index 98ac4d9..0000000
--- a/clownfish/compiler/src/CFCCBlock.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/** Clownfish::CFC::Model::CBlock - A block of embedded C code.
- *
- * CBlock exists to support embedding literal C code within Clownfish header
- * files:
- *
- *     class Crustacean::Lobster {
- *         ...
- *
- *         inert inline void
- *         say_hello(Lobster *self);
- *     }
- *
- *     __C__
- *     #include <stdio.h>
- *     static CFISH_INLINE void
- *     crust_Lobster_say_hello(crust_Lobster *self)
- *     {
- *         printf("Prepare to die, human scum.\n");
- *     }
- *     __END_C__
- */
-
-#ifndef H_CFCCBLOCK
-#define H_CFCCBLOCK
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCCBlock CFCCBlock;
-
-/** CBlock Constructor.
- *
- * @param contents The contents of the CBlock, not including delimiters.
- */
-CFCCBlock*
-CFCCBlock_new(const char *contents);
-
-CFCCBlock*
-CFCCBlock_init(CFCCBlock *self, const char *contents);
-
-void
-CFCCBlock_destroy(CFCCBlock *self);
-
-/** Accessor.
- */
-const char*
-CFCCBlock_get_contents(CFCCBlock *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCCBLOCK */
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCCClass.c b/clownfish/compiler/src/CFCCClass.c
deleted file mode 100644
index b6def3b..0000000
--- a/clownfish/compiler/src/CFCCClass.c
+++ /dev/null
@@ -1,552 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string.h>
-
-#include "charmony.h"
-#include "CFCCClass.h"
-#include "CFCClass.h"
-#include "CFCDocuComment.h"
-#include "CFCFunction.h"
-#include "CFCMethod.h"
-#include "CFCParamList.h"
-#include "CFCSymbol.h"
-#include "CFCType.h"
-#include "CFCUtil.h"
-#include "CFCVariable.h"
-
-#ifndef true
-    #define true 1
-    #define false 0
-#endif
-
-typedef struct CFCPodLink {
-    size_t      total_size;
-    const char *text;
-    size_t      text_size;
-} CFCPodLink;
-
-static char*
-S_man_create_name(CFCClass *klass);
-
-static char*
-S_man_create_synopsis(CFCClass *klass);
-
-static char*
-S_man_create_description(CFCClass *klass);
-
-static char*
-S_man_create_functions(CFCClass *klass);
-
-static char*
-S_man_create_methods(CFCClass *klass);
-
-static char*
-S_man_create_inherited_methods(CFCClass *klass);
-
-static char*
-S_man_create_func(CFCClass *klass, CFCFunction *func, const char *short_sym,
-                  const char *full_sym);
-
-static char*
-S_man_create_param_list(CFCFunction *func, const char *full_sym);
-
-static char*
-S_man_create_inheritance(CFCClass *klass);
-
-static char*
-S_man_escape_content(const char *content);
-
-static void
-S_parse_pod_link(const char *content, CFCPodLink *pod_link);
-
-// Declare dummy host callbacks.
-char*
-CFCCClass_callback_decs(CFCClass *klass) {
-    CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
-    char       *cb_decs       = CFCUtil_strdup("");
-
-    for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
-        CFCMethod *method = fresh_methods[meth_num];
-
-        // Define callback to NULL.
-        if (CFCMethod_novel(method) && !CFCMethod_final(method)) {
-            const char *override_sym = CFCMethod_full_override_sym(method);
-            cb_decs = CFCUtil_cat(cb_decs, "#define ", override_sym, " NULL\n",
-                                  NULL);
-        }
-    }
-
-    FREEMEM(fresh_methods);
-
-    return cb_decs;
-}
-
-char*
-CFCCClass_create_man_page(CFCClass *klass) {
-    if (!CFCSymbol_public((CFCSymbol*)klass)) { return NULL; }
-
-    const char *class_name = CFCClass_get_class_name(klass);
-
-    // Create NAME.
-    char *name = S_man_create_name(klass);
-
-    // Create SYNOPSIS.
-    char *synopsis = S_man_create_synopsis(klass);
-
-    // Create DESCRIPTION.
-    char *description = S_man_create_description(klass);
-
-    // Create CONSTRUCTORS.
-    char *functions_man = S_man_create_functions(klass);
-
-    // Create METHODS, possibly including an ABSTRACT METHODS section.
-    char *methods_man = S_man_create_methods(klass);
-
-    // Build an INHERITANCE section describing class ancestry.
-    char *inheritance = S_man_create_inheritance(klass);
-
-    // Put it all together.
-    const char pattern[] =
-    ".\\\" Licensed to the Apache Software Foundation (ASF) under one or more\n"
-    ".\\\" contributor license agreements.  See the NOTICE file distributed with\n"
-    ".\\\" this work for additional information regarding copyright ownership.\n"
-    ".\\\" The ASF licenses this file to You under the Apache License, Version 2.0\n"
-    ".\\\" (the \"License\"); you may not use this file except in compliance with\n"
-    ".\\\" the License.  You may obtain a copy of the License at\n"
-    ".\\\"\n"
-    ".\\\"     http://www.apache.org/licenses/LICENSE-2.0\n"
-    ".\\\"\n"
-    ".\\\" Unless required by applicable law or agreed to in writing, software\n"
-    ".\\\" distributed under the License is distributed on an \"AS IS\" BASIS,\n"
-    ".\\\" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
-    ".\\\" See the License for the specific language governing permissions and\n"
-    ".\\\" limitations under the License.\n"
-    ".TH %s 3\n"
-    "%s"
-    "%s"
-    "%s"
-    "%s"
-    "%s"
-    "%s";
-    char *man_page
-        = CFCUtil_sprintf(pattern, class_name, name, synopsis, description,
-                          functions_man, methods_man, inheritance);
-
-    FREEMEM(name);
-    FREEMEM(synopsis);
-    FREEMEM(description);
-    FREEMEM(functions_man);
-    FREEMEM(methods_man);
-    FREEMEM(inheritance);
-
-    return man_page;
-}
-
-static char*
-S_man_create_name(CFCClass *klass) {
-    char *result = CFCUtil_strdup(".SH NAME\n");
-    result = CFCUtil_cat(result, CFCClass_get_class_name(klass), NULL);
-
-    CFCDocuComment *docucom = CFCClass_get_docucomment(klass);
-    if (docucom) {
-        const char *raw_brief = CFCDocuComment_get_brief(docucom);
-        if (raw_brief && raw_brief[0] != '\0') {
-            char *brief = S_man_escape_content(raw_brief);
-            result = CFCUtil_cat(result, " \\- ", brief, NULL);
-            FREEMEM(brief);
-        }
-    }
-
-    result = CFCUtil_cat(result, "\n", NULL);
-
-    return result;
-}
-
-static char*
-S_man_create_synopsis(CFCClass *klass) {
-    CHY_UNUSED_VAR(klass);
-    return CFCUtil_strdup("");
-}
-
-static char*
-S_man_create_description(CFCClass *klass) {
-    char *result  = CFCUtil_strdup("");
-
-    CFCDocuComment *docucom = CFCClass_get_docucomment(klass);
-    if (!docucom) { return result; }
-
-    const char *raw_description = CFCDocuComment_get_long(docucom);
-    if (!raw_description || raw_description[0] == '\0') { return result; }
-
-    char *description = S_man_escape_content(raw_description);
-    result = CFCUtil_cat(result, ".SH DESCRIPTION\n", description, "\n", NULL);
-    FREEMEM(description);
-
-    return result;
-}
-
-static char*
-S_man_create_functions(CFCClass *klass) {
-    CFCFunction **functions = CFCClass_functions(klass);
-    char         *result    = CFCUtil_strdup("");
-
-    for (int func_num = 0; functions[func_num] != NULL; func_num++) {
-        CFCFunction *func = functions[func_num];
-        if (!CFCFunction_public(func)) { continue; }
-
-        if (result[0] == '\0') {
-            result = CFCUtil_cat(result, ".SH FUNCTIONS\n", NULL);
-        }
-
-        const char *micro_sym     = CFCFunction_micro_sym(func);
-        const char *full_func_sym = CFCFunction_full_func_sym(func);
-
-        char *redman = S_man_create_func(klass, func, micro_sym,
-                                         full_func_sym);
-        result = CFCUtil_cat(result, redman, NULL);
-        FREEMEM(redman);
-    }
-
-    return result;
-}
-
-static char*
-S_man_create_methods(CFCClass *klass) {
-    CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
-    char       *methods_man   = CFCUtil_strdup("");
-    char       *novel_man     = CFCUtil_strdup("");
-    char       *result;
-
-    for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
-        CFCMethod *method = fresh_methods[meth_num];
-        if (!CFCMethod_public(method) || !CFCMethod_novel(method)) {
-            continue;
-        }
-
-        const char *macro_sym = CFCMethod_get_macro_sym(method);
-        char *full_method_sym = CFCMethod_full_method_sym(method, NULL);
-        char *method_man = S_man_create_func(klass, (CFCFunction*)method,
-                                             macro_sym, full_method_sym);
-
-        if (CFCMethod_abstract(method)) {
-            if (methods_man[0] == '\0') {
-                methods_man = CFCUtil_cat(methods_man,
-                                          ".SS Abstract methods\n", NULL);
-            }
-            methods_man = CFCUtil_cat(methods_man, method_man, NULL);
-        }
-        else {
-            if (novel_man[0] == '\0') {
-                novel_man = CFCUtil_cat(novel_man,
-                                        ".SS Novel methods\n", NULL);
-            }
-            novel_man = CFCUtil_cat(novel_man, method_man, NULL);
-        }
-
-        FREEMEM(method_man);
-        FREEMEM(full_method_sym);
-    }
-
-    methods_man = CFCUtil_cat(methods_man, novel_man, NULL);
-
-    // Add methods from parent classes excluding Clownfish::Obj
-    CFCClass *parent = CFCClass_get_parent(klass);
-    while (parent) {
-        if (strcmp(CFCClass_get_class_name(parent), "Clownfish::Obj") == 0) {
-            break;
-        }
-        char *inherited_man = S_man_create_inherited_methods(parent);
-        methods_man = CFCUtil_cat(methods_man, inherited_man, NULL);
-        FREEMEM(inherited_man);
-        parent = CFCClass_get_parent(parent);
-    }
-
-    if (methods_man[0] == '\0') {
-        result = CFCUtil_strdup("");
-    }
-    else {
-        result = CFCUtil_sprintf(".SH METHODS\n%s", methods_man);
-    }
-
-    FREEMEM(methods_man);
-    FREEMEM(novel_man);
-    FREEMEM(fresh_methods);
-    return result;
-}
-
-static char*
-S_man_create_inherited_methods(CFCClass *klass) {
-    CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
-    char       *result        = CFCUtil_strdup("");
-
-    for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
-        CFCMethod *method = fresh_methods[meth_num];
-        if (!CFCMethod_public(method) || !CFCMethod_novel(method)) {
-            continue;
-        }
-
-        if (result[0] == '\0') {
-            result = CFCUtil_cat(result, ".SS Methods inherited from ",
-                                 CFCClass_get_class_name(klass), "\n", NULL);
-        }
-
-        const char *macro_sym = CFCMethod_get_macro_sym(method);
-        char *full_method_sym = CFCMethod_full_method_sym(method, NULL);
-        char *method_man = S_man_create_func(klass, (CFCFunction*)method,
-                                             macro_sym, full_method_sym);
-        result = CFCUtil_cat(result, method_man, NULL);
-
-        FREEMEM(method_man);
-        FREEMEM(full_method_sym);
-    }
-
-    FREEMEM(fresh_methods);
-    return result;
-}
-
-static char*
-S_man_create_func(CFCClass *klass, CFCFunction *func, const char *short_sym,
-                  const char *full_sym) {
-    CFCType    *return_type   = CFCFunction_get_return_type(func);
-    const char *return_type_c = CFCType_to_c(return_type);
-    const char *incremented   = "";
-
-    if (CFCType_incremented(return_type)) {
-        incremented = " // incremented";
-    }
-
-    char *param_list = S_man_create_param_list(func, full_sym);
-
-    const char *pattern =
-        ".TP\n"
-        ".B %s\n"
-        ".na\n"
-        "%s%s\n"
-        ".br\n"
-        "%s"
-        ".ad\n";
-    char *result = CFCUtil_sprintf(pattern, short_sym, return_type_c,
-                                   incremented, param_list);
-
-    FREEMEM(param_list);
-
-    // Get documentation, which may be inherited.
-    CFCDocuComment *docucomment = CFCFunction_get_docucomment(func);
-    if (!docucomment) {
-        const char *micro_sym = CFCFunction_micro_sym(func);
-        CFCClass *parent = klass;
-        while (NULL != (parent = CFCClass_get_parent(parent))) {
-            CFCFunction *parent_func
-                = (CFCFunction*)CFCClass_method(parent, micro_sym);
-            if (!parent_func) { break; }
-            docucomment = CFCFunction_get_docucomment(parent_func);
-            if (docucomment) { break; }
-        }
-    }
-
-    if (docucomment) {
-        // Description
-        const char *raw_desc = CFCDocuComment_get_description(docucomment);
-        char *desc = S_man_escape_content(raw_desc);
-        result = CFCUtil_cat(result, ".IP\n", desc, "\n", NULL);
-        FREEMEM(desc);
-
-        // Params
-        const char **param_names
-            = CFCDocuComment_get_param_names(docucomment);
-        const char **param_docs
-            = CFCDocuComment_get_param_docs(docucomment);
-        if (param_names[0]) {
-            result = CFCUtil_cat(result, ".RS\n", NULL);
-            for (size_t i = 0; param_names[i] != NULL; i++) {
-                char *doc = S_man_escape_content(param_docs[i]);
-                result = CFCUtil_cat(result, ".TP\n.I ", param_names[i],
-                                     "\n", doc, "\n", NULL);
-                FREEMEM(doc);
-            }
-            result = CFCUtil_cat(result, ".RE\n", NULL);
-        }
-
-        // Return value
-        const char *retval_doc = CFCDocuComment_get_retval(docucomment);
-        if (retval_doc && strlen(retval_doc)) {
-            char *doc = S_man_escape_content(retval_doc);
-            result = CFCUtil_cat(result, ".IP\n.B Returns:\n", doc, "\n",
-                                 NULL);
-            FREEMEM(doc);
-        }
-    }
-
-    return result;
-}
-
-static char*
-S_man_create_param_list(CFCFunction *func, const char *full_sym) {
-    CFCParamList  *param_list = CFCFunction_get_param_list(func);
-    CFCVariable  **variables  = CFCParamList_get_variables(param_list);
-
-    if (!variables[0]) {
-        return CFCUtil_sprintf(".BR %s (void);\n", full_sym);
-    }
-
-    char *result = CFCUtil_sprintf(".BR %s (", full_sym);
-
-    for (int i = 0; variables[i]; ++i) {
-        CFCVariable *variable = variables[i];
-        CFCType     *type     = CFCVariable_get_type(variable);
-        const char  *type_c   = CFCType_to_c(type);
-        const char  *name     = CFCVariable_micro_sym(variable);
-
-        result = CFCUtil_cat(result, "\n.br\n.RB \"    ", type_c, " \" ", name,
-                             NULL);
-
-        if (variables[i+1] || CFCType_decremented(type)) {
-            result = CFCUtil_cat(result, " \"", NULL);
-            if (variables[i+1]) {
-                result = CFCUtil_cat(result, ",", NULL);
-            }
-            else {
-                result = CFCUtil_cat(result, " // decremented", NULL);
-            }
-            result = CFCUtil_cat(result, "\"", NULL);
-        }
-    }
-
-    result = CFCUtil_cat(result, "\n.br\n);\n.br\n", NULL);
-
-    return result;
-}
-
-static char*
-S_man_create_inheritance(CFCClass *klass) {
-    CFCClass *ancestor = CFCClass_get_parent(klass);
-    char     *result   = CFCUtil_strdup("");
-
-    if (!ancestor) { return result; }
-
-    const char *class_name = CFCClass_get_class_name(klass);
-    result = CFCUtil_cat(result, ".SH INHERITANCE\n", class_name, NULL);
-    while (ancestor) {
-        const char *ancestor_name = CFCClass_get_class_name(ancestor);
-        result = CFCUtil_cat(result, " is a ", ancestor_name, NULL);
-        ancestor = CFCClass_get_parent(ancestor);
-    }
-    result = CFCUtil_cat(result, ".\n", NULL);
-
-    return result;
-}
-
-static char*
-S_man_escape_content(const char *content) {
-    size_t  result_len = 0;
-    size_t  result_cap = strlen(content) + 256;
-    char   *result     = (char*)MALLOCATE(result_cap + 1);
-
-    for (size_t i = 0; content[i]; i++) {
-        const char *subst      = content + i;
-        size_t      subst_size = 1;
-
-        switch (content[i]) {
-            case '\\':
-                // Escape backslash.
-                subst      = "\\e";
-                subst_size = 2;
-                break;
-            case '-':
-                // Escape hyphen.
-                subst      = "\\-";
-                subst_size = 2;
-                break;
-            case '\n':
-                // Escape dot after newline.
-                if (content[i+1] == '.') {
-                    subst      = "\n\\";
-                    subst_size = 2;
-                }
-                break;
-            case '<':
-                // <code> markup.
-                if (strncmp(content + i + 1, "code>", 5) == 0) {
-                    subst      = "\\fI";
-                    subst_size = 3;
-                    i += 5;
-                }
-                else if (strncmp(content + i + 1, "/code>", 6) == 0) {
-                    subst      = "\\fP";
-                    subst_size = 3;
-                    i += 6;
-                }
-                break;
-            case 'L':
-                if (content[i+1] == '<') {
-                    // POD-style link.
-                    struct CFCPodLink pod_link;
-                    S_parse_pod_link(content + i + 2, &pod_link);
-                    if (pod_link.total_size) {
-                        subst      = pod_link.text;
-                        subst_size = pod_link.text_size;
-                        i += pod_link.total_size + 1;
-                    }
-                }
-                break;
-            default:
-                break;
-        }
-
-        if (result_len + subst_size > result_cap) {
-            result_cap += 256;
-            result = (char*)REALLOCATE(result, result_cap + 1);
-        }
-
-        memcpy(result + result_len, subst, subst_size);
-        result_len += subst_size;
-    }
-
-    result[result_len] = '\0';
-
-    return result;
-}
-
-// Quick and dirty parsing of POD links. The syntax isn't fully supported
-// and the result isn't man-escaped. But it should be good enough for now
-// since at some point we'll switch to another format anyway.
-static void
-S_parse_pod_link(const char *content, CFCPodLink *pod_link) {
-    int in_text = true;
-
-    for (size_t i = 0; i < 256 && content[i]; ++i) {
-        if (content[i] == '|') {
-            if (in_text) {
-                pod_link->text_size = i;
-                in_text = false;
-            }
-        }
-        else if (content[i] == '>') {
-            pod_link->total_size = i + 1;
-            pod_link->text       = content;
-            if (in_text) {
-                pod_link->text_size = i;
-            }
-            return;
-        }
-    }
-
-    pod_link->total_size = 0;
-    pod_link->text       = NULL;
-    pod_link->text_size  = 0;
-}
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCCClass.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCCClass.h b/clownfish/compiler/src/CFCCClass.h
deleted file mode 100644
index b319596..0000000
--- a/clownfish/compiler/src/CFCCClass.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef H_CFCCCLASS
-#define H_CFCCCLASS
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct CFCClass;
-
-/* Return dummy host callbacks defined to NULL.
- */
-char*
-CFCCClass_callback_decs(struct CFCClass *klass);
-
-/** Return the man page for the class.
- */
-char*
-CFCCClass_create_man_page(struct CFCClass *klass);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCCCLASS */
-


Mime
View raw message