You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2014/04/12 08:49:51 UTC
[lucy-commits] [16/27] Remove bundled Clownfish.
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.c b/clownfish/compiler/src/CFCClass.c
deleted file mode 100644
index c2d5a2b..0000000
--- a/clownfish/compiler/src/CFCClass.c
+++ /dev/null
@@ -1,833 +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 <ctype.h>
-
-#ifndef true
- #define true 1
- #define false 0
-#endif
-
-#define CFC_NEED_SYMBOL_STRUCT_DEF
-#include "CFCSymbol.h"
-#include "CFCClass.h"
-#include "CFCFunction.h"
-#include "CFCMethod.h"
-#include "CFCParcel.h"
-#include "CFCDocuComment.h"
-#include "CFCUtil.h"
-#include "CFCVariable.h"
-#include "CFCFileSpec.h"
-
-typedef struct CFCClassRegEntry {
- char *key;
- struct CFCClass *klass;
-} CFCClassRegEntry;
-
-static CFCClassRegEntry *registry = NULL;
-static size_t registry_size = 0;
-static size_t registry_cap = 0;
-
-// Store a new CFCClass in a registry.
-static void
-S_register(CFCClass *self);
-
-struct CFCClass {
- CFCSymbol symbol;
- int tree_grown;
- CFCDocuComment *docucomment;
- struct CFCClass *parent;
- struct CFCClass **children;
- size_t num_kids;
- CFCFunction **functions;
- size_t num_functions;
- CFCMethod **methods;
- size_t num_methods;
- CFCVariable **member_vars;
- size_t num_member_vars;
- CFCVariable **inert_vars;
- size_t num_inert_vars;
- CFCFileSpec *file_spec;
- char *parent_class_name;
- int is_final;
- int is_inert;
- char *struct_sym;
- char *full_struct_sym;
- char *ivars_struct;
- char *full_ivars_struct;
- char *ivars_func;
- char *full_ivars_func;
- char *full_ivars_offset;
- char *short_vtable_var;
- char *full_vtable_var;
- char *privacy_symbol;
- char *include_h;
-};
-
-// Link up parents and kids.
-static void
-S_establish_ancestry(CFCClass *self);
-
-// Pass down member vars to from parent to children.
-static void
-S_bequeath_member_vars(CFCClass *self);
-
-// Pass down methods to from parent to children.
-static void
-S_bequeath_methods(CFCClass *self);
-
-static const CFCMeta CFCCLASS_META = {
- "Clownfish::CFC::Model::Class",
- sizeof(CFCClass),
- (CFCBase_destroy_t)CFCClass_destroy
-};
-
-CFCClass*
-CFCClass_create(struct CFCParcel *parcel, const char *exposure,
- const char *class_name, const char *cnick,
- const char *micro_sym, CFCDocuComment *docucomment,
- CFCFileSpec *file_spec, const char *parent_class_name,
- int is_final, int is_inert) {
- CFCClass *self = (CFCClass*)CFCBase_allocate(&CFCCLASS_META);
- return CFCClass_do_create(self, parcel, exposure, class_name, cnick,
- micro_sym, docucomment, file_spec,
- parent_class_name, is_final, is_inert);
-}
-
-CFCClass*
-CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel,
- const char *exposure, const char *class_name,
- const char *cnick, const char *micro_sym,
- CFCDocuComment *docucomment, CFCFileSpec *file_spec,
- const char *parent_class_name, int is_final, int is_inert) {
- CFCUTIL_NULL_CHECK(class_name);
- exposure = exposure ? exposure : "parcel";
- micro_sym = micro_sym ? micro_sym : "class";
- parcel = parcel ? parcel : CFCParcel_default_parcel();
- CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name, cnick,
- micro_sym);
- if (!is_inert
- && !parent_class_name
- && strcmp(class_name, "Clownfish::Obj") != 0
- ) {
- parent_class_name = "Clownfish::Obj";
- }
- self->parent = NULL;
- self->tree_grown = false;
- self->children = (CFCClass**)CALLOCATE(1, sizeof(CFCClass*));
- self->num_kids = 0;
- self->functions = (CFCFunction**)CALLOCATE(1, sizeof(CFCFunction*));
- self->num_functions = 0;
- self->methods = (CFCMethod**)CALLOCATE(1, sizeof(CFCMethod*));
- self->num_methods = 0;
- self->member_vars = (CFCVariable**)CALLOCATE(1, sizeof(CFCVariable*));
- self->num_member_vars = 0;
- self->inert_vars = (CFCVariable**)CALLOCATE(1, sizeof(CFCVariable*));
- self->num_inert_vars = 0;
- self->parent_class_name = CFCUtil_strdup(parent_class_name);
- self->docucomment
- = (CFCDocuComment*)CFCBase_incref((CFCBase*)docucomment);
- self->file_spec = (CFCFileSpec*)CFCBase_incref((CFCBase*)file_spec);
-
- // Cache several derived symbols.
- const char *last_colon = strrchr(class_name, ':');
- self->struct_sym = last_colon
- ? CFCUtil_strdup(last_colon + 1)
- : CFCUtil_strdup(class_name);
- const char *prefix = CFCClass_get_prefix(self);
- size_t struct_sym_len = strlen(self->struct_sym);
- self->short_vtable_var = (char*)MALLOCATE(struct_sym_len + 1);
- size_t i;
- for (i = 0; i < struct_sym_len; i++) {
- self->short_vtable_var[i] = toupper(self->struct_sym[i]);
- }
- self->short_vtable_var[struct_sym_len] = '\0';
- self->full_struct_sym = CFCUtil_sprintf("%s%s", prefix, self->struct_sym);
- self->ivars_struct = CFCUtil_sprintf("%sIVARS", self->struct_sym);
- self->full_ivars_struct = CFCUtil_sprintf("%sIVARS", self->full_struct_sym);
- self->ivars_func = CFCUtil_sprintf("%s_IVARS", CFCClass_get_cnick(self));
- self->full_ivars_func = CFCUtil_sprintf("%s%s_IVARS", prefix,
- CFCClass_get_cnick(self));
- self->full_ivars_offset = CFCUtil_sprintf("%s_OFFSET", self->full_ivars_func);
- size_t full_struct_sym_len = strlen(self->full_struct_sym);
- self->full_vtable_var = (char*)MALLOCATE(full_struct_sym_len + 1);
- for (i = 0; self->full_struct_sym[i] != '\0'; i++) {
- self->full_vtable_var[i] = toupper(self->full_struct_sym[i]);
- }
- self->full_vtable_var[i] = '\0';
- self->privacy_symbol = CFCUtil_sprintf("C_%s", self->full_vtable_var);
-
- // Build the relative path to the autogenerated C header file.
- if (file_spec) {
- const char *path_part = CFCFileSpec_get_path_part(self->file_spec);
- self->include_h = CFCUtil_sprintf("%s.h", path_part);
- }
- else {
- self->include_h = CFCUtil_strdup("class.h");
- }
-
- self->is_final = !!is_final;
- self->is_inert = !!is_inert;
-
- if (file_spec && CFCFileSpec_included(file_spec)) {
- if (!CFCParcel_included(parcel)) {
- CFCUtil_die("Class %s from include dir found in parcel %s from"
- " source dir",
- class_name, CFCParcel_get_name(parcel));
- }
- }
- else {
- if (CFCParcel_included(parcel)) {
- CFCUtil_die("Class %s from source dir found in parcel %s from"
- " include dir",
- class_name, CFCParcel_get_name(parcel));
- }
- }
-
- // Store in registry.
- S_register(self);
-
- return self;
-}
-
-void
-CFCClass_destroy(CFCClass *self) {
- CFCBase_decref((CFCBase*)self->docucomment);
- CFCBase_decref((CFCBase*)self->parent);
- for (size_t i = 0; self->children[i] != NULL; i++) {
- CFCBase_decref((CFCBase*)self->children[i]);
- }
- for (size_t i = 0; self->functions[i] != NULL; i++) {
- CFCBase_decref((CFCBase*)self->functions[i]);
- }
- for (size_t i = 0; self->methods[i] != NULL; i++) {
- CFCBase_decref((CFCBase*)self->methods[i]);
- }
- for (size_t i = 0; self->member_vars[i] != NULL; i++) {
- CFCBase_decref((CFCBase*)self->member_vars[i]);
- }
- for (size_t i = 0; self->inert_vars[i] != NULL; i++) {
- CFCBase_decref((CFCBase*)self->inert_vars[i]);
- }
- CFCBase_decref((CFCBase*)self->file_spec);
- FREEMEM(self->children);
- FREEMEM(self->functions);
- FREEMEM(self->methods);
- FREEMEM(self->member_vars);
- FREEMEM(self->inert_vars);
- FREEMEM(self->parent_class_name);
- FREEMEM(self->struct_sym);
- FREEMEM(self->ivars_struct);
- FREEMEM(self->full_ivars_struct);
- FREEMEM(self->ivars_func);
- FREEMEM(self->full_ivars_func);
- FREEMEM(self->full_ivars_offset);
- FREEMEM(self->short_vtable_var);
- FREEMEM(self->full_struct_sym);
- FREEMEM(self->full_vtable_var);
- FREEMEM(self->privacy_symbol);
- FREEMEM(self->include_h);
- CFCSymbol_destroy((CFCSymbol*)self);
-}
-
-static void
-S_register(CFCClass *self) {
- if (registry_size == registry_cap) {
- size_t new_cap = registry_cap + 10;
- registry = (CFCClassRegEntry*)REALLOCATE(
- registry,
- (new_cap + 1) * sizeof(CFCClassRegEntry));
- for (size_t i = registry_cap; i <= new_cap; i++) {
- registry[i].key = NULL;
- registry[i].klass = NULL;
- }
- registry_cap = new_cap;
- }
-
- CFCParcel *parcel = CFCClass_get_parcel(self);
- const char *prefix = CFCParcel_get_prefix(parcel);
- const char *class_name = CFCClass_get_class_name(self);
- const char *cnick = CFCClass_get_cnick(self);
- const char *key = self->full_struct_sym;
-
- for (size_t i = 0; i < registry_size; i++) {
- CFCClass *other = registry[i].klass;
- CFCParcel *other_parcel = CFCClass_get_parcel(other);
- const char *other_prefix = CFCParcel_get_prefix(other_parcel);
- const char *other_class_name = CFCClass_get_class_name(other);
- const char *other_cnick = CFCClass_get_cnick(other);
-
- if (strcmp(class_name, other_class_name) == 0) {
- CFCUtil_die("Two classes with name %s", class_name);
- }
- if (strcmp(registry[i].key, key) == 0) {
- CFCUtil_die("Class name conflict between %s and %s",
- class_name, other_class_name);
- }
- if (strcmp(prefix, other_prefix) == 0
- && strcmp(cnick, other_cnick) == 0
- ) {
- CFCUtil_die("Class nickname conflict between %s and %s",
- class_name, other_class_name);
- }
- }
-
- registry[registry_size].key = CFCUtil_strdup(key);
- registry[registry_size].klass = (CFCClass*)CFCBase_incref((CFCBase*)self);
- registry_size++;
-}
-
-#define MAX_SINGLETON_LEN 256
-
-CFCClass*
-CFCClass_fetch_singleton(CFCParcel *parcel, const char *class_name) {
- CFCUTIL_NULL_CHECK(class_name);
-
- // Build up the key.
- const char *last_colon = strrchr(class_name, ':');
- const char *struct_sym = last_colon
- ? last_colon + 1
- : class_name;
- const char *prefix = parcel ? CFCParcel_get_prefix(parcel) : "";
- size_t prefix_len = strlen(prefix);
- size_t struct_sym_len = strlen(struct_sym);
- if (prefix_len + struct_sym_len > MAX_SINGLETON_LEN) {
- CFCUtil_die("names too long: '%s', '%s'", prefix, struct_sym);
- }
- char key[MAX_SINGLETON_LEN + 1];
- sprintf(key, "%s%s", prefix, struct_sym);
- for (size_t i = 0; i < registry_size; i++) {
- if (strcmp(registry[i].key, key) == 0) {
- return registry[i].klass;
- }
- }
- return NULL;
-}
-
-void
-CFCClass_clear_registry(void) {
- for (size_t i = 0; i < registry_size; i++) {
- CFCClass *klass = registry[i].klass;
- if (klass->parent) {
- // Break circular ref.
- CFCBase_decref((CFCBase*)klass->parent);
- klass->parent = NULL;
- }
- CFCBase_decref((CFCBase*)klass);
- FREEMEM(registry[i].key);
- }
- FREEMEM(registry);
- registry_size = 0;
- registry_cap = 0;
- registry = NULL;
-}
-
-void
-CFCClass_add_child(CFCClass *self, CFCClass *child) {
- CFCUTIL_NULL_CHECK(child);
- if (self->tree_grown) {
- CFCUtil_die("Can't call add_child after grow_tree");
- }
- if (self->is_inert) {
- CFCUtil_die("Can't inherit from inert class %s",
- CFCClass_get_class_name(self));
- }
- if (child->is_inert) {
- CFCUtil_die("Inert class %s can't inherit",
- CFCClass_get_class_name(child));
- }
- self->num_kids++;
- size_t size = (self->num_kids + 1) * sizeof(CFCClass*);
- self->children = (CFCClass**)REALLOCATE(self->children, size);
- self->children[self->num_kids - 1]
- = (CFCClass*)CFCBase_incref((CFCBase*)child);
- self->children[self->num_kids] = NULL;
-
- // Add parcel dependency.
- CFCParcel *parcel = CFCClass_get_parcel(self);
- CFCParcel *child_parcel = CFCClass_get_parcel(child);
- CFCParcel_add_inherited_parcel(child_parcel, parcel);
-}
-
-void
-CFCClass_add_function(CFCClass *self, CFCFunction *func) {
- CFCUTIL_NULL_CHECK(func);
- if (self->tree_grown) {
- CFCUtil_die("Can't call add_function after grow_tree");
- }
- self->num_functions++;
- size_t size = (self->num_functions + 1) * sizeof(CFCFunction*);
- self->functions = (CFCFunction**)REALLOCATE(self->functions, size);
- self->functions[self->num_functions - 1]
- = (CFCFunction*)CFCBase_incref((CFCBase*)func);
- self->functions[self->num_functions] = NULL;
-}
-
-void
-CFCClass_add_method(CFCClass *self, CFCMethod *method) {
- CFCUTIL_NULL_CHECK(method);
- if (self->tree_grown) {
- CFCUtil_die("Can't call add_method after grow_tree");
- }
- if (self->is_inert) {
- CFCUtil_die("Can't add_method to an inert class");
- }
- self->num_methods++;
- size_t size = (self->num_methods + 1) * sizeof(CFCMethod*);
- self->methods = (CFCMethod**)REALLOCATE(self->methods, size);
- self->methods[self->num_methods - 1]
- = (CFCMethod*)CFCBase_incref((CFCBase*)method);
- self->methods[self->num_methods] = NULL;
-}
-
-void
-CFCClass_add_member_var(CFCClass *self, CFCVariable *var) {
- CFCUTIL_NULL_CHECK(var);
- if (self->tree_grown) {
- CFCUtil_die("Can't call add_member_var after grow_tree");
- }
- self->num_member_vars++;
- size_t size = (self->num_member_vars + 1) * sizeof(CFCVariable*);
- self->member_vars = (CFCVariable**)REALLOCATE(self->member_vars, size);
- self->member_vars[self->num_member_vars - 1]
- = (CFCVariable*)CFCBase_incref((CFCBase*)var);
- self->member_vars[self->num_member_vars] = NULL;
-}
-
-void
-CFCClass_add_inert_var(CFCClass *self, CFCVariable *var) {
- CFCUTIL_NULL_CHECK(var);
- if (self->tree_grown) {
- CFCUtil_die("Can't call add_inert_var after grow_tree");
- }
- self->num_inert_vars++;
- size_t size = (self->num_inert_vars + 1) * sizeof(CFCVariable*);
- self->inert_vars = (CFCVariable**)REALLOCATE(self->inert_vars, size);
- self->inert_vars[self->num_inert_vars - 1]
- = (CFCVariable*)CFCBase_incref((CFCBase*)var);
- self->inert_vars[self->num_inert_vars] = NULL;
-}
-
-#define MAX_FUNC_LEN 128
-
-static CFCFunction*
-S_find_func(CFCFunction **funcs, const char *sym) {
- if (!sym) {
- return NULL;
- }
-
- char lcsym[MAX_FUNC_LEN + 1];
- size_t sym_len = strlen(sym);
- if (sym_len > MAX_FUNC_LEN) { CFCUtil_die("sym too long: '%s'", sym); }
- for (size_t i = 0; i <= sym_len; i++) {
- lcsym[i] = tolower(sym[i]);
- }
- for (size_t i = 0; funcs[i] != NULL; i++) {
- CFCFunction *func = funcs[i];
- if (strcmp(lcsym, CFCFunction_micro_sym(func)) == 0) {
- return func;
- }
- }
- return NULL;
-}
-
-CFCFunction*
-CFCClass_function(CFCClass *self, const char *sym) {
- return S_find_func(self->functions, sym);
-}
-
-CFCMethod*
-CFCClass_method(CFCClass *self, const char *sym) {
- return (CFCMethod*)S_find_func((CFCFunction**)self->methods, sym);
-}
-
-CFCMethod*
-CFCClass_fresh_method(CFCClass *self, const char *sym) {
- CFCMethod *method = CFCClass_method(self, sym);
- if (method) {
- const char *class_name = CFCClass_get_class_name(self);
- const char *meth_class_name = CFCMethod_get_class_name(method);
- if (strcmp(class_name, meth_class_name) == 0) {
- return method;
- }
- }
- return NULL;
-}
-
-void
-CFCClass_resolve_types(CFCClass *self, CFCClass **classes) {
- for (size_t i = 0; self->functions[i] != NULL; i++) {
- CFCFunction_resolve_types(self->functions[i], classes);
- }
- for (size_t i = 0; self->methods[i] != NULL; i++) {
- CFCMethod_resolve_types(self->methods[i], classes);
- }
- for (size_t i = 0; self->member_vars[i] != NULL; i++) {
- CFCVariable_resolve_type(self->member_vars[i], classes);
- }
- for (size_t i = 0; self->inert_vars[i] != NULL; i++) {
- CFCVariable_resolve_type(self->inert_vars[i], classes);
- }
-}
-
-// Pass down member vars to from parent to children.
-static void
-S_bequeath_member_vars(CFCClass *self) {
- for (size_t i = 0; self->children[i] != NULL; i++) {
- CFCClass *child = self->children[i];
- size_t num_vars = self->num_member_vars + child->num_member_vars;
- size_t size = (num_vars + 1) * sizeof(CFCVariable*);
- child->member_vars
- = (CFCVariable**)REALLOCATE(child->member_vars, size);
- memmove(child->member_vars + self->num_member_vars,
- child->member_vars,
- child->num_member_vars * sizeof(CFCVariable*));
- memcpy(child->member_vars, self->member_vars,
- self->num_member_vars * sizeof(CFCVariable*));
- for (size_t j = 0; self->member_vars[j] != NULL; j++) {
- CFCBase_incref((CFCBase*)child->member_vars[j]);
- }
- child->num_member_vars = num_vars;
- child->member_vars[num_vars] = NULL;
- S_bequeath_member_vars(child);
- }
-}
-
-static void
-S_bequeath_methods(CFCClass *self) {
- for (size_t child_num = 0; self->children[child_num] != NULL; child_num++) {
- CFCClass *child = self->children[child_num];
-
- // Create array of methods, preserving exact order so vtables match up.
- size_t num_methods = 0;
- size_t max_methods = self->num_methods + child->num_methods;
- CFCMethod **methods = (CFCMethod**)MALLOCATE(
- (max_methods + 1) * sizeof(CFCMethod*));
-
- // Gather methods which child inherits or overrides.
- for (size_t i = 0; i < self->num_methods; i++) {
- CFCMethod *method = self->methods[i];
- const char *macro_sym = CFCMethod_get_macro_sym(method);
- CFCMethod *child_method = CFCClass_method(child, macro_sym);
- if (child_method) {
- CFCMethod_override(child_method, method);
- methods[num_methods++] = child_method;
- }
- else {
- methods[num_methods++] = method;
- }
- }
-
- // Append novel child methods to array. Child methods which were just
- // marked via CFCMethod_override() a moment ago are skipped.
- for (size_t i = 0; i < child->num_methods; i++) {
- CFCMethod *method = child->methods[i];
- if (CFCMethod_novel(method)) {
- methods[num_methods++] = method;
- }
- }
- methods[num_methods] = NULL;
-
- // Manage refcounts and assign new array. Transform to final methods
- // if child class is a final class.
- if (child->is_final) {
- for (size_t i = 0; i < num_methods; i++) {
- if (CFCMethod_final(methods[i])) {
- CFCBase_incref((CFCBase*)methods[i]);
- }
- else {
- methods[i] = CFCMethod_finalize(methods[i]);
- }
- }
- }
- else {
- for (size_t i = 0; i < num_methods; i++) {
- CFCBase_incref((CFCBase*)methods[i]);
- }
- }
- for (size_t i = 0; i < child->num_methods; i++) {
- CFCBase_decref((CFCBase*)child->methods[i]);
- }
- FREEMEM(child->methods);
- child->methods = methods;
- child->num_methods = num_methods;
-
- // Pass it all down to the next generation.
- S_bequeath_methods(child);
- child->tree_grown = true;
- }
-}
-
-// Let the children know who their parent class is.
-static void
-S_establish_ancestry(CFCClass *self) {
- for (size_t i = 0; i < self->num_kids; i++) {
- CFCClass *child = self->children[i];
- // This is a circular reference and thus a memory leak, but we don't
- // care, because we have to have everything in memory at once anyway.
- CFCClass_set_parent(child, self);
- S_establish_ancestry(child);
- }
-}
-
-static size_t
-S_family_tree_size(CFCClass *self) {
- size_t count = 1; // self
- for (size_t i = 0; i < self->num_kids; i++) {
- count += S_family_tree_size(self->children[i]);
- }
- return count;
-}
-
-void
-CFCClass_grow_tree(CFCClass *self) {
- if (self->tree_grown) {
- CFCUtil_die("Can't call grow_tree more than once");
- }
- S_establish_ancestry(self);
- S_bequeath_member_vars(self);
- S_bequeath_methods(self);
- self->tree_grown = 1;
-}
-
-// Return value is valid only so long as object persists (elements are not
-// refcounted).
-CFCClass**
-CFCClass_tree_to_ladder(CFCClass *self) {
- size_t ladder_len = S_family_tree_size(self);
- CFCClass **ladder = (CFCClass**)MALLOCATE((ladder_len + 1) * sizeof(CFCClass*));
- ladder[ladder_len] = NULL;
- size_t step = 0;
- ladder[step++] = self;
- for (size_t i = 0; i < self->num_kids; i++) {
- CFCClass *child = self->children[i];
- CFCClass **child_ladder = CFCClass_tree_to_ladder(child);
- for (size_t j = 0; child_ladder[j] != NULL; j++) {
- ladder[step++] = child_ladder[j];
- }
- FREEMEM(child_ladder);
- }
- return ladder;
-}
-
-static CFCSymbol**
-S_fresh_syms(CFCClass *self, CFCSymbol **syms) {
- const char *class_name = CFCClass_get_class_name(self);
- size_t count = 0;
- while (syms[count] != NULL) { count++; }
- size_t amount = (count + 1) * sizeof(CFCSymbol*);
- CFCSymbol **fresh = (CFCSymbol**)MALLOCATE(amount);
- size_t num_fresh = 0;
- for (size_t i = 0; i < count; i++) {
- CFCSymbol *sym = syms[i];
- const char *sym_class_name = CFCSymbol_get_class_name(sym);
- if (strcmp(sym_class_name, class_name) == 0) {
- fresh[num_fresh++] = sym;
- }
- }
- fresh[num_fresh] = NULL;
- return fresh;
-}
-
-CFCMethod**
-CFCClass_fresh_methods(CFCClass *self) {
- return (CFCMethod**)S_fresh_syms(self, (CFCSymbol**)self->methods);
-}
-
-CFCVariable**
-CFCClass_fresh_member_vars(CFCClass *self) {
- return (CFCVariable**)S_fresh_syms(self, (CFCSymbol**)self->member_vars);
-}
-
-CFCMethod*
-CFCClass_find_novel_method(CFCClass *self, const char *sym) {
- if (!self->tree_grown) {
- CFCUtil_die("Can't call original_method before grow_tree");
- }
- CFCClass *ancestor = self;
- do {
- CFCMethod *method = CFCClass_method(ancestor, sym);
- if (method && CFCMethod_novel(method)) {
- return method;
- }
- } while (NULL != (ancestor = CFCClass_get_parent(ancestor)));
- return NULL;
-}
-
-CFCClass**
-CFCClass_children(CFCClass *self) {
- return self->children;
-}
-
-CFCFunction**
-CFCClass_functions(CFCClass *self) {
- return self->functions;
-}
-
-CFCMethod**
-CFCClass_methods(CFCClass *self) {
- return self->methods;
-}
-
-size_t
-CFCClass_num_methods(CFCClass *self) {
- return self->num_methods;
-}
-
-CFCVariable**
-CFCClass_member_vars(CFCClass *self) {
- return self->member_vars;
-}
-
-size_t
-CFCClass_num_member_vars(CFCClass *self) {
- return self->num_member_vars;
-}
-
-CFCVariable**
-CFCClass_inert_vars(CFCClass *self) {
- return self->inert_vars;
-}
-
-const char*
-CFCClass_get_cnick(CFCClass *self) {
- return CFCSymbol_get_class_cnick((CFCSymbol*)self);
-}
-
-void
-CFCClass_set_parent(CFCClass *self, CFCClass *parent) {
- CFCClass *old_parent = self->parent;
- self->parent = (CFCClass*)CFCBase_incref((CFCBase*)parent);
- CFCBase_decref((CFCBase*)old_parent);
-}
-
-CFCClass*
-CFCClass_get_parent(CFCClass *self) {
- return self->parent;
-}
-
-const char*
-CFCClass_get_path_part(CFCClass *self) {
- return self->file_spec ? CFCFileSpec_get_path_part(self->file_spec) : NULL;
-}
-
-int
-CFCClass_included(CFCClass *self) {
- return self->file_spec ? CFCFileSpec_included(self->file_spec) : 0;
-}
-
-const char*
-CFCClass_get_parent_class_name(CFCClass *self) {
- return self->parent_class_name;
-}
-
-int
-CFCClass_final(CFCClass *self) {
- return self->is_final;
-}
-
-int
-CFCClass_inert(CFCClass *self) {
- return self->is_inert;
-}
-
-const char*
-CFCClass_get_struct_sym(CFCClass *self) {
- return self->struct_sym;
-}
-
-const char*
-CFCClass_full_struct_sym(CFCClass *self) {
- return self->full_struct_sym;
-}
-
-const char*
-CFCClass_short_ivars_struct(CFCClass *self) {
- return self->ivars_struct;
-}
-
-const char*
-CFCClass_full_ivars_struct(CFCClass *self) {
- return self->full_ivars_struct;
-}
-
-const char*
-CFCClass_short_ivars_func(CFCClass *self) {
- return self->ivars_func;
-}
-
-const char*
-CFCClass_full_ivars_func(CFCClass *self) {
- return self->full_ivars_func;
-}
-
-const char*
-CFCClass_full_ivars_offset(CFCClass *self) {
- return self->full_ivars_offset;
-}
-
-const char*
-CFCClass_short_vtable_var(CFCClass *self) {
- return self->short_vtable_var;
-}
-
-const char*
-CFCClass_full_vtable_var(CFCClass *self) {
- return self->full_vtable_var;
-}
-
-const char*
-CFCClass_privacy_symbol(CFCClass *self) {
- return self->privacy_symbol;
-}
-
-const char*
-CFCClass_include_h(CFCClass *self) {
- return self->include_h;
-}
-
-struct CFCDocuComment*
-CFCClass_get_docucomment(CFCClass *self) {
- return self->docucomment;
-}
-
-const char*
-CFCClass_get_prefix(CFCClass *self) {
- return CFCSymbol_get_prefix((CFCSymbol*)self);
-}
-
-const char*
-CFCClass_get_Prefix(CFCClass *self) {
- return CFCSymbol_get_Prefix((CFCSymbol*)self);
-}
-
-const char*
-CFCClass_get_PREFIX(CFCClass *self) {
- return CFCSymbol_get_PREFIX((CFCSymbol*)self);
-}
-
-const char*
-CFCClass_get_class_name(CFCClass *self) {
- return CFCSymbol_get_class_name((CFCSymbol*)self);
-}
-
-CFCParcel*
-CFCClass_get_parcel(CFCClass *self) {
- return CFCSymbol_get_parcel((CFCSymbol*)self);
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCClass.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.h b/clownfish/compiler/src/CFCClass.h
deleted file mode 100644
index 5c52728..0000000
--- a/clownfish/compiler/src/CFCClass.h
+++ /dev/null
@@ -1,305 +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::Class - An object representing a single class
- * definition.
- *
- * Clownfish::CFC::Model::Class objects are stored as quasi-singletons, one
- * for each unique parcel/class_name combination.
- */
-
-#ifndef H_CFCCLASS
-#define H_CFCCLASS
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-
-typedef struct CFCClass CFCClass;
-struct CFCParcel;
-struct CFCDocuComment;
-struct CFCFunction;
-struct CFCMethod;
-struct CFCVariable;
-struct CFCFileSpec;
-
-/** Create and register a quasi-singleton. May only be called once for each
- * unique parcel/class_name combination.
- *
- * @param parcel See Clownfish::CFC::Model::Symbol.
- * @param exposure See Clownfish::CFC::Model::Symbol.
- * @param class_name See Clownfish::CFC::Model::Symbol.
- * @param cnick See Clownfish::CFC::Model::Symbol.
- * @param micro_sym Defaults to "class".
- * @param docucomment An optional Clownfish::CFC::Model::DocuComment attached
- * to this class.
- * @param file_spec - Clownfish::CFC::Model::FileSpec of the file in which
- * this class was declared
- * @param docucomment A Clownfish::CFC::Model::DocuComment describing this
- * Class.
- * @param is_inert Should be true if the class is inert, i.e. cannot be
- * instantiated.
- * @param is_final Should be true if the class is final.
- */
-CFCClass*
-CFCClass_create(struct CFCParcel *parcel, const char *exposure,
- const char *class_name, const char *cnick,
- const char *micro_sym, struct CFCDocuComment *docucomment,
- struct CFCFileSpec *file_spec, const char *parent_class_name,
- int is_final, int is_inert);
-
-CFCClass*
-CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel,
- const char *exposure, const char *class_name,
- const char *cnick, const char *micro_sym,
- struct CFCDocuComment *docucomment,
- struct CFCFileSpec *file_spec, const char *parent_class_name,
- int is_final, int is_inert);
-
-void
-CFCClass_destroy(CFCClass *self);
-
-/** Retrieve a Class, if one has already been created.
- *
- * @param A Clownfish::CFC::Model::Parcel.
- * @param class_name The name of the Class.
- */
-CFCClass*
-CFCClass_fetch_singleton(struct CFCParcel *parcel, const char *class_name);
-
-/** Empty out the registry, decrementing the refcount of all Class singleton
- * objects.
- */
-void
-CFCClass_clear_registry(void);
-
-/** Add a child class.
- */
-void
-CFCClass_add_child(CFCClass *self, CFCClass *child);
-
-/** Add a Function to the class. Valid only before CFCClass_grow_tree() is
- * called.
- */
-void
-CFCClass_add_function(CFCClass *self, struct CFCFunction *func);
-
-/** Add a Method to the class. Valid only before CFCClass_grow_tree() is
- * called.
- */
-void
-CFCClass_add_method(CFCClass *self, struct CFCMethod *method);
-
-/** Add a member variable to the class. Valid only before
- * CFCClass_grow_tree() is called.
- */
-void
-CFCClass_add_member_var(CFCClass *self, struct CFCVariable *var);
-
-/** Add an inert (class) variable to the class. Valid only before
- * CFCClass_grow_tree() is called.
- */
-void
-CFCClass_add_inert_var(CFCClass *self, struct CFCVariable *var);
-
-/* Return the inert Function object for the supplied sym, if any.
- */
-struct CFCFunction*
-CFCClass_function(CFCClass *self, const char *sym);
-
-/* Return the Method object for the supplied micro/macro sym, if any.
- */
-struct CFCMethod*
-CFCClass_method(CFCClass *self, const char *sym);
-
-/** Return a Method object if the Method corresponding to the supplied sym is
- * implemented in this class.
- */
-struct CFCMethod*
-CFCClass_fresh_method(CFCClass *self, const char *sym);
-
-/** Traverse all ancestors to find the first class which declared the method
- * and return it. Cannot be called before grow_tree().
- */
-struct CFCMethod*
-CFCClass_find_novel_method(CFCClass *self, const char *sym);
-
-/** Find the actual class of all object variables without prefix.
- */
-void
-CFCClass_resolve_types(CFCClass *self, CFCClass **classes);
-
-/** Bequeath all inherited methods and members to children.
- */
-void
-CFCClass_grow_tree(CFCClass *self);
-
-/** Return this class and all its child classes as an array, where all
- * children appear after their parent nodes.
- */
-CFCClass**
-CFCClass_tree_to_ladder(CFCClass *self);
-
-/** Return an array of all methods implemented in this class.
- */
-struct CFCMethod**
-CFCClass_fresh_methods(CFCClass *self);
-
-/** Return an array of all member variables declared in this class.
- */
-struct CFCVariable**
-CFCClass_fresh_member_vars(CFCClass *self);
-
-/** Return an array of all child classes.
- */
-CFCClass**
-CFCClass_children(CFCClass *self);
-
-/** Return an array of all (inert) functions.
- */
-struct CFCFunction**
-CFCClass_functions(CFCClass *self);
-
-/** Return an array of all methods.
- */
-struct CFCMethod**
-CFCClass_methods(CFCClass *self);
-
-size_t
-CFCClass_num_methods(CFCClass *self);
-
-/** Return an array of all member variables.
- */
-struct CFCVariable**
-CFCClass_member_vars(CFCClass *self);
-
-size_t
-CFCClass_num_member_vars(CFCClass *self);
-
-/** Return an array of all inert (shared, class) variables.
- */
-struct CFCVariable**
-CFCClass_inert_vars(CFCClass *self);
-
-const char*
-CFCClass_get_cnick(CFCClass *self);
-
-/** Set the parent Class. (Not class name, Class.)
- */
-void
-CFCClass_set_parent(CFCClass *self, CFCClass *parent);
-
-CFCClass*
-CFCClass_get_parent(CFCClass *self);
-
-const char*
-CFCClass_get_path_part(CFCClass *self);
-
-int
-CFCClass_included(CFCClass *self);
-
-const char*
-CFCClass_get_parent_class_name(CFCClass *self);
-
-int
-CFCClass_final(CFCClass *self);
-
-int
-CFCClass_inert(CFCClass *self);
-
-const char*
-CFCClass_get_struct_sym(CFCClass *self);
-
-/** Fully qualified struct symbol, including the parcel prefix.
- */
-const char*
-CFCClass_full_struct_sym(CFCClass *self);
-
-/** IVARS struct name, not including parcel prefix.
- */
-const char*
-CFCClass_short_ivars_struct(CFCClass *self);
-
-/** Fully qualified IVARS struct name including parcel prefix.
- */
-const char*
-CFCClass_full_ivars_struct(CFCClass *self);
-
-/** Name of the function used to access IVARS, not including parcel prefix.
- */
-const char*
-CFCClass_short_ivars_func(CFCClass *self);
-
-/** Fully qualified name of the function used to access IVARS including parcel
- * prefix.
- */
-const char*
-CFCClass_full_ivars_func(CFCClass *self);
-
-/** Fully qualified name of the offset variable at which the IVARS may be
- * found, including parcel prefix.
- */
-const char*
-CFCClass_full_ivars_offset(CFCClass *self);
-
-/** The short name of the global VTable object for this class.
- */
-const char*
-CFCClass_short_vtable_var(CFCClass *self);
-
-/** Fully qualified vtable variable name, including the parcel prefix.
- */
-const char*
-CFCClass_full_vtable_var(CFCClass *self);
-
-/** Access the symbol which unlocks the class struct definition and other
- * private information.
- */
-const char*
-CFCClass_privacy_symbol(CFCClass *self);
-
-/** Return a relative path to a C header file, appropriately formatted for a
- * pound-include directive.
- */
-const char*
-CFCClass_include_h(CFCClass *self);
-
-struct CFCDocuComment*
-CFCClass_get_docucomment(CFCClass *self);
-
-const char*
-CFCClass_get_prefix(CFCClass *self);
-
-const char*
-CFCClass_get_Prefix(CFCClass *self);
-
-const char*
-CFCClass_get_PREFIX(CFCClass *self);
-
-const char*
-CFCClass_get_class_name(CFCClass *self);
-
-struct CFCParcel*
-CFCClass_get_parcel(CFCClass *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCCLASS */
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCDocuComment.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCDocuComment.c b/clownfish/compiler/src/CFCDocuComment.c
deleted file mode 100644
index 4a28cf2..0000000
--- a/clownfish/compiler/src/CFCDocuComment.c
+++ /dev/null
@@ -1,265 +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 <ctype.h>
-#include <string.h>
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCDocuComment.h"
-#include "CFCUtil.h"
-
-struct CFCDocuComment {
- CFCBase base;
- char *description;
- char *brief;
- char *long_des;
- char **param_names;
- char **param_docs;
- char *retval;
-};
-
-/** Remove comment open, close, and left border from raw comment text.
- */
-static void
-S_strip(char *comment) {
- size_t len = strlen(comment);
- char *scratch = (char*)MALLOCATE(len + 1);
-
- // Establish that comment text begins with "/**" and ends with "*/".
- if (strstr(comment, "/**") != comment
- || strstr(comment, "*/") != (comment + len - 2)
- ) {
- CFCUtil_die("Malformed comment");
- }
-
- // Capture text minus beginning "/**", ending "*/", and left border.
- size_t i = 3;
- size_t max = len - 2;
- while ((isspace(comment[i]) || comment[i] == '*') && i < max) {
- i++;
- }
- size_t j = 0;
- for (; i < max; i++) {
- while (comment[i] == '\n' && i < max) {
- scratch[j++] = comment[i];
- i++;
- while (isspace(comment[i]) && comment[i] != '\n' && i < max) {
- i++;
- }
- if (comment[i] == '*') { i++; }
- if (comment[i] == ' ') { i++; }
- }
- if (i < max) {
- scratch[j++] = comment[i];
- }
- }
-
- // Modify original string in place.
- for (i = 0; i < j; i++) {
- comment[i] = scratch[i];
- }
- comment[j] = '\0';
-
- // Clean up.
- FREEMEM(scratch);
-}
-
-static const CFCMeta CFCDOCUCOMMENT_META = {
- "Clownfish::CFC::Model::DocuComment",
- sizeof(CFCDocuComment),
- (CFCBase_destroy_t)CFCDocuComment_destroy
-};
-
-CFCDocuComment*
-CFCDocuComment_parse(const char *raw_text) {
- char *text = CFCUtil_strdup(raw_text);
- CFCDocuComment *self
- = (CFCDocuComment*)CFCBase_allocate(&CFCDOCUCOMMENT_META);
-
- // Strip whitespace, comment open, close, and left border.
- CFCUtil_trim_whitespace(text);
- S_strip(text);
-
- // Extract the brief description.
- char *ptr = text;
- size_t len = strlen(text);
- char *limit = strchr(ptr, '@');
- if (!limit) {
- limit = text + len;
- }
- while (ptr < limit) {
- if (*ptr == '.'
- && ((ptr == limit - 1) || isspace(*(ptr + 1)))
- ) {
- ptr++;
- size_t brief_len = ptr - text;
- self->brief = CFCUtil_strdup(text);
- self->brief[brief_len] = '\0';
- break;
- }
- ptr++;
- }
-
- if (!self->brief) {
- self->brief = CFCUtil_strdup("");
- }
-
- // Extract @param directives.
- size_t num_params = 0;
- self->param_names = (char**)CALLOCATE(num_params + 1, sizeof(char*));
- self->param_docs = (char**)CALLOCATE(num_params + 1, sizeof(char*));
-
- char *candidate = strstr(text, "@param");
- size_t text_len = strlen(text);
- char *text_limit = text + text_len;
- while (candidate) {
- // Extract param name.
- char *ptr = candidate + sizeof("@param") - 1;
- if (!isspace(*ptr) || ptr > text_limit) {
- CFCUtil_die("Malformed @param directive in '%s'", raw_text);
- }
- while (isspace(*ptr) && ptr < text_limit) { ptr++; }
- char *param_name = ptr;
- while ((isalnum(*ptr) || *ptr == '_') && ptr < text_limit) { ptr++; }
- size_t param_name_len = ptr - param_name;
- if (!param_name_len) {
- CFCUtil_die("Malformed @param directive in '%s'", raw_text);
- }
-
- // Extract param description.
- while (isspace(*ptr) && ptr < text_limit) { ptr++; }
- char *param_doc = ptr;
- while (ptr < text_limit) {
- if (*ptr == '@') { break; }
- else if (*ptr == '\n' && ptr < text_limit) {
- ptr++;
- while (ptr < text_limit && *ptr != '\n' && isspace(*ptr)) {
- ptr++;
- }
- if (*ptr == '\n' || *ptr == '@') { break; }
- }
- else {
- ptr++;
- }
- }
- size_t param_doc_len = ptr - param_doc;
-
- num_params++;
- size_t size = (num_params + 1) * sizeof(char*);
- self->param_names = (char**)REALLOCATE(self->param_names, size);
- self->param_docs = (char**)REALLOCATE(self->param_docs, size);
- self->param_names[num_params - 1]
- = CFCUtil_strndup(param_name, param_name_len);
- self->param_docs[num_params - 1]
- = CFCUtil_strndup(param_doc, param_doc_len);
- CFCUtil_trim_whitespace(self->param_names[num_params - 1]);
- CFCUtil_trim_whitespace(self->param_docs[num_params - 1]);
- self->param_names[num_params] = NULL;
- self->param_docs[num_params] = NULL;
-
- if (ptr == text_limit) {
- break;
- }
- else if (ptr > text_limit) {
- CFCUtil_die("Overran end of string while parsing '%s'", raw_text);
- }
- candidate = strstr(ptr, "@param");
- }
-
- // Extract full description.
- self->description = CFCUtil_strdup(text);
-
- char *terminus = strstr(self->description, "@param");
- if (!terminus) {
- terminus = strstr(self->description, "@return");
- }
- if (terminus) {
- *terminus = '\0';
- }
-
- CFCUtil_trim_whitespace(self->description);
-
- // Extract long description.
- self->long_des = CFCUtil_strdup(self->description + strlen(self->brief));
- CFCUtil_trim_whitespace(self->long_des);
-
- // Extract @return directive.
- char *maybe_retval = strstr(text, "@return ");
- if (maybe_retval) {
- self->retval = CFCUtil_strdup(maybe_retval + sizeof("@return ") - 1);
- char *terminus = strchr(self->retval, '@');
- if (terminus) {
- *terminus = '\0';
- }
- CFCUtil_trim_whitespace(self->retval);
- }
-
- FREEMEM(text);
- return self;
-}
-
-void
-CFCDocuComment_destroy(CFCDocuComment *self) {
- if (self->param_names) {
- for (size_t i = 0; self->param_names[i] != NULL; i++) {
- FREEMEM(self->param_names[i]);
- }
- FREEMEM(self->param_names);
- }
- if (self->param_docs) {
- for (size_t i = 0; self->param_docs[i] != NULL; i++) {
- FREEMEM(self->param_docs[i]);
- }
- FREEMEM(self->param_docs);
- }
- FREEMEM(self->description);
- FREEMEM(self->brief);
- FREEMEM(self->long_des);
- FREEMEM(self->retval);
- CFCBase_destroy((CFCBase*)self);
-}
-
-const char*
-CFCDocuComment_get_description(CFCDocuComment *self) {
- return self->description;
-}
-
-const char*
-CFCDocuComment_get_brief(CFCDocuComment *self) {
- return self->brief;
-}
-
-const char*
-CFCDocuComment_get_long(CFCDocuComment *self) {
- return self->long_des;
-}
-
-const char**
-CFCDocuComment_get_param_names(CFCDocuComment *self) {
- return (const char**)self->param_names;
-}
-
-const char**
-CFCDocuComment_get_param_docs(CFCDocuComment *self) {
- return (const char**)self->param_docs;
-}
-
-const char*
-CFCDocuComment_get_retval(CFCDocuComment *self) {
- return self->retval;
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCDocuComment.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCDocuComment.h b/clownfish/compiler/src/CFCDocuComment.h
deleted file mode 100644
index 910f191..0000000
--- a/clownfish/compiler/src/CFCDocuComment.h
+++ /dev/null
@@ -1,61 +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::DocuComment - Formatted comment a la Doxygen.
- */
-
-#ifndef H_CFCDOCUCOMMENT
-#define H_CFCDOCUCOMMENT
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCDocuComment CFCDocuComment;
-
-/** Parse comment text.
- */
-CFCDocuComment*
-CFCDocuComment_parse(const char *raw_text);
-
-void
-CFCDocuComment_destroy(CFCDocuComment *self);
-
-const char*
-CFCDocuComment_get_description(CFCDocuComment *self);
-
-const char*
-CFCDocuComment_get_brief(CFCDocuComment *self);
-
-const char*
-CFCDocuComment_get_long(CFCDocuComment *self);
-
-const char**
-CFCDocuComment_get_param_names(CFCDocuComment *self);
-
-const char**
-CFCDocuComment_get_param_docs(CFCDocuComment *self);
-
-// May be NULL.
-const char*
-CFCDocuComment_get_retval(CFCDocuComment *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCDOCUCOMMENT */
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCFile.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFile.c b/clownfish/compiler/src/CFCFile.c
deleted file mode 100644
index 84065b1..0000000
--- a/clownfish/compiler/src/CFCFile.c
+++ /dev/null
@@ -1,232 +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>
-#include <ctype.h>
-
-#ifndef true
- #define true 1
- #define false 0
-#endif
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCFile.h"
-#include "CFCFileSpec.h"
-#include "CFCUtil.h"
-#include "CFCClass.h"
-
-struct CFCFile {
- CFCBase base;
- CFCBase **blocks;
- CFCClass **classes;
- CFCFileSpec *spec;
- int modified;
- char *guard_name;
- char *guard_start;
- char *guard_close;
-};
-
-static const CFCMeta CFCFILE_META = {
- "Clownfish::CFC::Model::File",
- sizeof(CFCFile),
- (CFCBase_destroy_t)CFCFile_destroy
-};
-
-CFCFile*
-CFCFile_new(CFCFileSpec *spec) {
-
- CFCFile *self = (CFCFile*)CFCBase_allocate(&CFCFILE_META);
- return CFCFile_init(self, spec);
-}
-
-CFCFile*
-CFCFile_init(CFCFile *self, CFCFileSpec *spec) {
- CFCUTIL_NULL_CHECK(spec);
- self->modified = false;
- self->spec = (CFCFileSpec*)CFCBase_incref((CFCBase*)spec);
- self->blocks = (CFCBase**)CALLOCATE(1, sizeof(CFCBase*));
- self->classes = (CFCClass**)CALLOCATE(1, sizeof(CFCBase*));
-
- // Derive include guard name, plus C code for opening and closing the
- // guard.
- const char *path_part = CFCFileSpec_get_path_part(self->spec);
- size_t len = strlen(path_part);
- self->guard_name = (char*)MALLOCATE(len + sizeof("H_") + 1);
- memcpy(self->guard_name, "H_", 2);
- size_t i, j;
- for (i = 0, j = 2; i < len; i++) {
- char c = path_part[i];
- if (c == CHY_DIR_SEP_CHAR) {
- self->guard_name[j++] = '_';
- }
- else if (isalnum(c)) {
- self->guard_name[j++] = toupper(c);
- }
- }
- self->guard_name[j] = '\0';
- self->guard_start = CFCUtil_sprintf("#ifndef %s\n#define %s 1\n",
- self->guard_name, self->guard_name);
- self->guard_close = CFCUtil_sprintf("#endif /* %s */\n", self->guard_name);
-
- return self;
-}
-
-void
-CFCFile_destroy(CFCFile *self) {
- for (size_t i = 0; self->blocks[i] != NULL; i++) {
- CFCBase_decref(self->blocks[i]);
- }
- FREEMEM(self->blocks);
- for (size_t i = 0; self->classes[i] != NULL; i++) {
- CFCBase_decref((CFCBase*)self->classes[i]);
- }
- FREEMEM(self->classes);
- FREEMEM(self->guard_name);
- FREEMEM(self->guard_start);
- FREEMEM(self->guard_close);
- CFCBase_decref((CFCBase*)self->spec);
- CFCBase_destroy((CFCBase*)self);
-}
-
-void
-CFCFile_add_block(CFCFile *self, CFCBase *block) {
- CFCUTIL_NULL_CHECK(block);
- const char *cfc_class = CFCBase_get_cfc_class(block);
-
- // Add to classes array if the block is a CFCClass.
- if (strcmp(cfc_class, "Clownfish::CFC::Model::Class") == 0) {
- size_t num_class_blocks = 0;
- while (self->classes[num_class_blocks] != NULL) {
- num_class_blocks++;
- }
- num_class_blocks++;
- size_t size = (num_class_blocks + 1) * sizeof(CFCClass*);
- self->classes = (CFCClass**)REALLOCATE(self->classes, size);
- self->classes[num_class_blocks - 1]
- = (CFCClass*)CFCBase_incref(block);
- self->classes[num_class_blocks] = NULL;
- }
-
- // Add to blocks array.
- if (strcmp(cfc_class, "Clownfish::CFC::Model::Class") == 0
- || strcmp(cfc_class, "Clownfish::CFC::Model::Parcel") == 0
- || strcmp(cfc_class, "Clownfish::CFC::Model::CBlock") == 0
- ) {
- size_t num_blocks = 0;
- while (self->blocks[num_blocks] != NULL) {
- num_blocks++;
- }
- num_blocks++;
- size_t size = (num_blocks + 1) * sizeof(CFCBase*);
- self->blocks = (CFCBase**)REALLOCATE(self->blocks, size);
- self->blocks[num_blocks - 1] = CFCBase_incref(block);
- self->blocks[num_blocks] = NULL;
- }
- else {
- CFCUtil_die("Wrong kind of object: '%s'", cfc_class);
- }
-}
-
-static char*
-S_some_path(CFCFile *self, const char *base_dir, const char *ext) {
- const char *path_part = CFCFileSpec_get_path_part(self->spec);
- char *buf;
- if (base_dir) {
- buf = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s%s", base_dir,
- path_part, ext);
- }
- else {
- buf = CFCUtil_sprintf("%s%s", path_part, ext);
- }
- for (size_t i = 0; buf[i] != '\0'; i++) {
- #ifdef _WIN32
- if (buf[i] == '/') { buf[i] = '\\'; }
- #else
- if (buf[i] == '\\') { buf[i] = '/'; }
- #endif
- }
- return buf;
-}
-
-char*
-CFCFile_c_path(CFCFile *self, const char *base_dir) {
- return S_some_path(self, base_dir, ".c");
-}
-
-char*
-CFCFile_h_path(CFCFile *self, const char *base_dir) {
- return S_some_path(self, base_dir, ".h");
-}
-
-char*
-CFCFile_cfh_path(CFCFile *self, const char *base_dir) {
- return S_some_path(self, base_dir, ".cfh");
-}
-
-CFCBase**
-CFCFile_blocks(CFCFile *self) {
- return self->blocks;
-}
-
-CFCClass**
-CFCFile_classes(CFCFile *self) {
- return self->classes;
-}
-
-void
-CFCFile_set_modified(CFCFile *self, int modified) {
- self->modified = !!modified;
-}
-
-int
-CFCFile_get_modified(CFCFile *self) {
- return self->modified;
-}
-
-const char*
-CFCFile_get_source_dir(CFCFile *self) {
- return CFCFileSpec_get_source_dir(self->spec);
-}
-
-const char*
-CFCFile_get_path_part(CFCFile *self) {
- return CFCFileSpec_get_path_part(self->spec);
-}
-
-int
-CFCFile_included(CFCFile *self) {
- return CFCFileSpec_included(self->spec);
-}
-
-const char*
-CFCFile_guard_name(CFCFile *self) {
- return self->guard_name;
-}
-
-const char*
-CFCFile_guard_start(CFCFile *self) {
- return self->guard_start;
-}
-
-const char*
-CFCFile_guard_close(CFCFile *self) {
- return self->guard_close;
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCFile.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFile.h b/clownfish/compiler/src/CFCFile.h
deleted file mode 100644
index e360605..0000000
--- a/clownfish/compiler/src/CFCFile.h
+++ /dev/null
@@ -1,119 +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::File - Structured representation of the contents of
- * a Clownfish source file.
- *
- * An abstraction representing a file which contains Clownfish code.
- */
-#ifndef H_CFCFILE
-#define H_CFCFILE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCFile CFCFile;
-struct CFCBase;
-struct CFCClass;
-struct CFCFileSpec;
-
-/**
- * @param spec - A CFCFileSpec object describing the file
-*/
-CFCFile*
-CFCFile_new(struct CFCFileSpec *spec);
-
-CFCFile*
-CFCFile_init(CFCFile *self, struct CFCFileSpec *spec);
-
-void
-CFCFile_destroy(CFCFile *self);
-
-/** Add an element to the blocks array. The block must be either a
- * Clownfish::CFC::Model::Class, a Clownfish::CFC::Model::Parcel, or a
- * Clownfish::CFC::Model::CBlock.
- */
-void
-CFCFile_add_block(CFCFile *self, CFCBase *block);
-
-/** Given a base directory, return a path name derived from the File's
- * path_part with a ".c" extension.
- */
-char*
-CFCFile_c_path(CFCFile *self, const char *base_dir);
-
-/** As c_path, but with a ".h" extension.
- */
-char*
-CFCFile_h_path(CFCFile *self, const char *base_dir);
-
-/** As c_path, but with a ".cfh" extension.
- */
-char*
-CFCFile_cfh_path(CFCFile *self, const char *base_dir);
-
-/** Return all blocks as an array.
- */
-struct CFCBase**
-CFCFile_blocks(CFCFile *self);
-
-/** Return all Clownfish::CFC::Model::Class blocks from the file as an array.
- */
-struct CFCClass**
-CFCFile_classes(CFCFile *self);
-
-/** Setter for the file's "modified" property, which is initially false.
- */
-void
-CFCFile_set_modified(CFCFile *self, int modified);
-
-int
-CFCFile_get_modified(CFCFile *self);
-
-const char*
-CFCFile_get_source_dir(CFCFile *self);
-
-const char*
-CFCFile_get_path_part(CFCFile *self);
-
-int
-CFCFile_included(CFCFile *self);
-
-/** Return a string used for an include guard in a C header (e.g.
- * "H_CRUSTACEAN_LOBSTER"), unique per file.
- */
-const char*
-CFCFile_guard_name(CFCFile *self);
-
-/** Return a string opening the include guard.
- */
-const char*
-CFCFile_guard_start(CFCFile *self);
-
-/** Return a string closing the include guard. Other classes count on being
- * able to match this string.
- */
-const char*
-CFCFile_guard_close(CFCFile *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCFILE */
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCFileSpec.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFileSpec.c b/clownfish/compiler/src/CFCFileSpec.c
deleted file mode 100644
index 41e3ba4..0000000
--- a/clownfish/compiler/src/CFCFileSpec.c
+++ /dev/null
@@ -1,86 +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 <stdio.h>
-#include <ctype.h>
-
-#ifndef true
- #define true 1
- #define false 0
-#endif
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCFileSpec.h"
-#include "CFCUtil.h"
-#include "CFCClass.h"
-
-struct CFCFileSpec {
- CFCBase base;
- char *source_dir;
- char *path_part;
- int is_included;
-};
-
-static const CFCMeta CFCFILESPEC_META = {
- "Clownfish::CFC::Model::FileSpec",
- sizeof(CFCFileSpec),
- (CFCBase_destroy_t)CFCFileSpec_destroy
-};
-
-CFCFileSpec*
-CFCFileSpec_new(const char *source_dir, const char *path_part,
- int is_included) {
- CFCFileSpec *self = (CFCFileSpec*)CFCBase_allocate(&CFCFILESPEC_META);
- return CFCFileSpec_init(self, source_dir, path_part, is_included);
-}
-
-CFCFileSpec*
-CFCFileSpec_init(CFCFileSpec *self, const char *source_dir,
- const char *path_part, int is_included) {
- CFCUTIL_NULL_CHECK(source_dir);
- CFCUTIL_NULL_CHECK(path_part);
-
- self->source_dir = CFCUtil_strdup(source_dir);
- self->path_part = CFCUtil_strdup(path_part);
- self->is_included = !!is_included;
-
- return self;
-}
-
-void
-CFCFileSpec_destroy(CFCFileSpec *self) {
- FREEMEM(self->source_dir);
- FREEMEM(self->path_part);
- CFCBase_destroy((CFCBase*)self);
-}
-
-const char*
-CFCFileSpec_get_source_dir(CFCFileSpec *self) {
- return self->source_dir;
-}
-
-const char*
-CFCFileSpec_get_path_part(CFCFileSpec *self) {
- return self->path_part;
-}
-
-int
-CFCFileSpec_included(CFCFileSpec *self) {
- return self->is_included;
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCFileSpec.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFileSpec.h b/clownfish/compiler/src/CFCFileSpec.h
deleted file mode 100644
index 830a618..0000000
--- a/clownfish/compiler/src/CFCFileSpec.h
+++ /dev/null
@@ -1,69 +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::FileSpec - Specification of an input file
- *
- * This class contains data related to input files that is known before
- * parsing and can be referenced from classes created during parsing like
- * CFCFile or CFCClass.
- */
-#ifndef H_CFCFILESPEC
-#define H_CFCFILESPEC
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCFileSpec CFCFileSpec;
-struct CFCBase;
-struct CFCClass;
-
-/**
- * @param path_part - The path of the file, relative to the source directory
- * and excluding the .cfh extension. Should be "Foo/Bar" if the source file
- * is found at 'Foo/Bar.cfh' within the source directory. That implies that
- * the output C header file should be 'Foo/Bar.h' within the target include
- * directory.
- * @param source_dir The source directory in which the file was found.
- * @param is_included Should be true if the file is from an include dir.
-*/
-CFCFileSpec*
-CFCFileSpec_new(const char *source_dir, const char *path_part,
- int is_included);
-
-CFCFileSpec*
-CFCFileSpec_init(CFCFileSpec *self, const char *source_dir,
- const char *path_part, int is_included);
-
-void
-CFCFileSpec_destroy(CFCFileSpec *self);
-
-const char*
-CFCFileSpec_get_source_dir(CFCFileSpec *self);
-
-const char*
-CFCFileSpec_get_path_part(CFCFileSpec *self);
-
-int
-CFCFileSpec_included(CFCFileSpec *self);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCFILESPEC */
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCFunction.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFunction.c b/clownfish/compiler/src/CFCFunction.c
deleted file mode 100644
index 6f781f4..0000000
--- a/clownfish/compiler/src/CFCFunction.c
+++ /dev/null
@@ -1,144 +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 <ctype.h>
-
-#ifndef true
- #define true 1
- #define false 0
-#endif
-
-#define CFC_NEED_FUNCTION_STRUCT_DEF
-#include "CFCFunction.h"
-#include "CFCParcel.h"
-#include "CFCType.h"
-#include "CFCParamList.h"
-#include "CFCDocuComment.h"
-#include "CFCUtil.h"
-
-static const CFCMeta CFCFUNCTION_META = {
- "Clownfish::CFC::Model::Function",
- sizeof(CFCFunction),
- (CFCBase_destroy_t)CFCFunction_destroy
-};
-
-CFCFunction*
-CFCFunction_new(CFCParcel *parcel, const char *exposure,
- const char *class_name, const char *class_cnick,
- const char *micro_sym, CFCType *return_type,
- CFCParamList *param_list, CFCDocuComment *docucomment,
- int is_inline) {
- CFCFunction *self = (CFCFunction*)CFCBase_allocate(&CFCFUNCTION_META);
- return CFCFunction_init(self, parcel, exposure, class_name, class_cnick,
- micro_sym, return_type, param_list, docucomment,
- is_inline);
-}
-
-static int
-S_validate_micro_sym(const char *micro_sym) {
- size_t len = strlen(micro_sym);
- if (!len) { return false; }
- for (size_t i = 0; i < len; i++) {
- char c = micro_sym[i];
- if (!islower(c) && !isdigit(c) && c != '_') { return false; }
- }
- return true;
-}
-
-CFCFunction*
-CFCFunction_init(CFCFunction *self, CFCParcel *parcel, const char *exposure,
- const char *class_name, const char *class_cnick,
- const char *micro_sym, CFCType *return_type,
- CFCParamList *param_list, CFCDocuComment *docucomment,
- int is_inline) {
-
- exposure = exposure ? exposure : "parcel";
- CFCUTIL_NULL_CHECK(class_name);
- CFCUTIL_NULL_CHECK(return_type);
- CFCUTIL_NULL_CHECK(param_list);
- if (!S_validate_micro_sym(micro_sym)) {
- CFCBase_decref((CFCBase*)self);
- CFCUtil_die("Invalid micro_sym: '%s'", micro_sym);
- }
- CFCSymbol_init((CFCSymbol*)self, parcel, exposure, class_name,
- class_cnick, micro_sym);
- self->return_type = (CFCType*)CFCBase_incref((CFCBase*)return_type);
- self->param_list = (CFCParamList*)CFCBase_incref((CFCBase*)param_list);
- self->docucomment = (CFCDocuComment*)CFCBase_incref((CFCBase*)docucomment);
- self->is_inline = is_inline;
- return self;
-}
-
-void
-CFCFunction_resolve_types(CFCFunction *self, struct CFCClass **classes) {
- CFCType_resolve(self->return_type, classes);
- CFCParamList_resolve_types(self->param_list, classes);
-}
-
-void
-CFCFunction_destroy(CFCFunction *self) {
- CFCBase_decref((CFCBase*)self->return_type);
- CFCBase_decref((CFCBase*)self->param_list);
- CFCBase_decref((CFCBase*)self->docucomment);
- CFCSymbol_destroy((CFCSymbol*)self);
-}
-
-CFCType*
-CFCFunction_get_return_type(CFCFunction *self) {
- return self->return_type;
-}
-
-CFCParamList*
-CFCFunction_get_param_list(CFCFunction *self) {
- return self->param_list;
-}
-
-CFCDocuComment*
-CFCFunction_get_docucomment(CFCFunction *self) {
- return self->docucomment;
-}
-
-int
-CFCFunction_inline(CFCFunction *self) {
- return self->is_inline;
-}
-
-int
-CFCFunction_void(CFCFunction *self) {
- return CFCType_is_void(self->return_type);
-}
-
-const char*
-CFCFunction_full_func_sym(CFCFunction *self) {
- return CFCSymbol_full_sym((CFCSymbol*)self);
-}
-
-const char*
-CFCFunction_short_func_sym(CFCFunction *self) {
- return CFCSymbol_short_sym((CFCSymbol*)self);
-}
-
-const char*
-CFCFunction_micro_sym(CFCFunction *self) {
- return CFCSymbol_micro_sym((CFCSymbol*)self);
-}
-
-int
-CFCFunction_public(CFCFunction *self) {
- return CFCSymbol_public((CFCSymbol*)self);
-}
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/1704c275/clownfish/compiler/src/CFCFunction.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFunction.h b/clownfish/compiler/src/CFCFunction.h
deleted file mode 100644
index baab2c7..0000000
--- a/clownfish/compiler/src/CFCFunction.h
+++ /dev/null
@@ -1,124 +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::Function - Metadata describing a function.
- */
-
-#ifndef H_CFCFUNCTION
-#define H_CFCFUNCTION
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCFunction CFCFunction;
-struct CFCParcel;
-struct CFCType;
-struct CFCDocuComment;
-struct CFCParamList;
-struct CFCClass;
-
-#ifdef CFC_NEED_FUNCTION_STRUCT_DEF
-#define CFC_NEED_SYMBOL_STRUCT_DEF
-#include "CFCSymbol.h"
-struct CFCFunction {
- CFCSymbol symbol;
- struct CFCType *return_type;
- struct CFCParamList *param_list;
- struct CFCDocuComment *docucomment;
- int is_inline;
-};
-#endif
-
-/**
- * @param parcel A Clownfish::CFC::Model::Parcel.
- * @param exposure The function's exposure (see
- * L<Clownfish::CFC::Model::Symbol>).
- * @param class_name The full name of the class in whose namespace the
- * function resides.
- * @param class_cnick The C nickname for the class.
- * @param micro_sym The lower case name of the function, without any
- * namespacing prefixes.
- * @param return_type A Clownfish::CFC::Model::Type representing the
- * function's return type.
- * @param param_list A Clownfish::CFC::Model::ParamList representing the
- * function's argument list.
- * @param docucomment A Clownfish::CFC::Model::DocuComment describing the
- * function.
- * @param is_inline Should be true if the function should be inlined by the
- * compiler.
- */
-CFCFunction*
-CFCFunction_new(struct CFCParcel *parcel, const char *exposure,
- const char *class_name, const char *class_cnick,
- const char *micro_sym, struct CFCType *return_type,
- struct CFCParamList *param_list,
- struct CFCDocuComment *docucomment, int is_inline);
-
-CFCFunction*
-CFCFunction_init(CFCFunction *self, struct CFCParcel *parcel,
- const char *exposure, const char *class_name,
- const char *class_cnick, const char *micro_sym,
- struct CFCType *return_type, struct CFCParamList *param_list,
- struct CFCDocuComment *docucomment, int is_inline);
-
-void
-CFCFunction_destroy(CFCFunction *self);
-
-struct CFCType*
-CFCFunction_get_return_type(CFCFunction *self);
-
-struct CFCParamList*
-CFCFunction_get_param_list(CFCFunction *self);
-
-struct CFCDocuComment*
-CFCFunction_get_docucomment(CFCFunction *self);
-
-int
-CFCFunction_inline(CFCFunction *self);
-
-/** Returns true if the function has a void return type, false otherwise.
- */
-int
-CFCFunction_void(CFCFunction *self);
-
-/** A synonym for full_sym().
- */
-const char*
-CFCFunction_full_func_sym(CFCFunction *self);
-
-/** A synonym for short_sym().
- */
-const char*
-CFCFunction_short_func_sym(CFCFunction *self);
-
-const char*
-CFCFunction_micro_sym(CFCFunction *self);
-
-int
-CFCFunction_public(CFCFunction *self);
-
-/** Find the actual class of all object variables without prefix.
- */
-void
-CFCFunction_resolve_types(CFCFunction *self, struct CFCClass **classes);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCFUNCTION */
-