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 2013/08/05 20:38:00 UTC
[lucy-commits] [03/12] git commit: refs/heads/master - Remove CFCDumpable.
Remove CFCDumpable.
CFCDumpable is obsolete since we are no longer using it to autogenerate
implementations for Dump/Load -- remove it.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/a12fc932
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/a12fc932
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/a12fc932
Branch: refs/heads/master
Commit: a12fc932d081ad8b5efb8a1a408bf257ecb0e576
Parents: 6c64f94
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Thu Jul 25 16:31:13 2013 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Aug 5 11:35:44 2013 -0700
----------------------------------------------------------------------
clownfish/compiler/include/CFC.h | 1 -
clownfish/compiler/perl/lib/Clownfish/CFC.pm | 5 -
clownfish/compiler/perl/lib/Clownfish/CFC.xs | 21 -
.../compiler/perl/lib/Clownfish/CFC/Dumpable.pm | 20 -
clownfish/compiler/perl/t/401-class.t | 3 +-
clownfish/compiler/perl/typemap | 1 -
clownfish/compiler/src/CFCClass.c | 28 --
clownfish/compiler/src/CFCDumpable.c | 405 -------------------
clownfish/compiler/src/CFCDumpable.h | 68 ----
clownfish/compiler/src/CFCTestClass.c | 7 +-
10 files changed, 2 insertions(+), 557 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/include/CFC.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/include/CFC.h b/clownfish/compiler/include/CFC.h
index 080ad61..9a13607 100644
--- a/clownfish/compiler/include/CFC.h
+++ b/clownfish/compiler/include/CFC.h
@@ -18,7 +18,6 @@
#include "CFCCBlock.h"
#include "CFCClass.h"
#include "CFCDocuComment.h"
-#include "CFCDumpable.h"
#include "CFCFile.h"
#include "CFCFileSpec.h"
#include "CFCFunction.h"
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/perl/lib/Clownfish/CFC.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.pm b/clownfish/compiler/perl/lib/Clownfish/CFC.pm
index b891516..c918155 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.pm
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.pm
@@ -167,11 +167,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.01' ) }
}
{
- package Clownfish::CFC::Dumpable;
- BEGIN { push our @ISA, 'Clownfish::CFC::Base' }
-}
-
-{
package Clownfish::CFC::Model::File;
BEGIN { push our @ISA, 'Clownfish::CFC::Base' }
use Clownfish::CFC::Util qw( verify_args );
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC.xs b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
index eda22dc..b4cb0b2 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC.xs
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC.xs
@@ -512,27 +512,6 @@ PPCODE:
END_SET_OR_GET_SWITCH
}
-MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Dumpable
-
-SV*
-new(klass)
- const char *klass;
-CODE:
- if (strcmp(klass, "Clownfish::CFC::Dumpable")) {
- croak("No subclassing allowed");
- }
- CFCDumpable *self = CFCDumpable_new();
- RETVAL = S_cfcbase_to_perlref(self);
- CFCBase_decref((CFCBase*)self);
-OUTPUT: RETVAL
-
-void
-add_dumpables(self, klass)
- CFCDumpable *self;
- CFCClass *klass;
-PPCODE:
- CFCDumpable_add_dumpables(self, klass);
-
MODULE = Clownfish::CFC PACKAGE = Clownfish::CFC::Model::File
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/perl/lib/Clownfish/CFC/Dumpable.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Dumpable.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Dumpable.pm
deleted file mode 100644
index 05a2197..0000000
--- a/clownfish/compiler/perl/lib/Clownfish/CFC/Dumpable.pm
+++ /dev/null
@@ -1,20 +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.
-
-package Clownfish::CFC::Dumpable;
-use Clownfish::CFC;
-
-1;
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/t/401-class.t b/clownfish/compiler/perl/t/401-class.t
index 6cf51a2..c92d545 100644
--- a/clownfish/compiler/perl/t/401-class.t
+++ b/clownfish/compiler/perl/t/401-class.t
@@ -16,7 +16,7 @@
use strict;
use warnings;
-use Test::More tests => 57;
+use Test::More tests => 56;
use Clownfish::CFC::Model::Class;
use Clownfish::CFC::Parser;
@@ -156,7 +156,6 @@ is_deeply( $foo_jr->fresh_member_vars, [], "fresh_member_vars" );
is_deeply( $foo_jr->inert_vars, [], "don't inherit inert vars" );
is_deeply( $final_foo->fresh_methods, [], "fresh_methods" );
-like( $foo_jr->get_autocode, qr/load/i, "autogenerate Dump/Load" );
is_deeply( $foo->tree_to_ladder, [ $foo, $foo_jr, $final_foo ],
'tree_to_ladder' );
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/perl/typemap
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/typemap b/clownfish/compiler/perl/typemap
index 17be341..d744071 100644
--- a/clownfish/compiler/perl/typemap
+++ b/clownfish/compiler/perl/typemap
@@ -18,7 +18,6 @@ CFCBase* CLOWNFISH_TYPE
CFCCBlock* CLOWNFISH_MODEL
CFCClass* CLOWNFISH_MODEL
CFCDocuComment* CLOWNFISH_MODEL
-CFCDumpable* CLOWNFISH_TYPE
CFCFile* CLOWNFISH_MODEL
CFCFileSpec* CLOWNFISH_MODEL
CFCFunction* CLOWNFISH_MODEL
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCClass.c b/clownfish/compiler/src/CFCClass.c
index 79c1ec6..6e9179d 100644
--- a/clownfish/compiler/src/CFCClass.c
+++ b/clownfish/compiler/src/CFCClass.c
@@ -26,7 +26,6 @@
#define CFC_NEED_SYMBOL_STRUCT_DEF
#include "CFCSymbol.h"
#include "CFCClass.h"
-#include "CFCDumpable.h"
#include "CFCFunction.h"
#include "CFCMethod.h"
#include "CFCParcel.h"
@@ -96,15 +95,6 @@ S_establish_ancestry(CFCClass *self);
static void
S_bequeath_member_vars(CFCClass *self);
-// Create auto-generated methods. This must be called after member vars are
-// passed down but before methods are passed down.
-static void
-S_generate_automethods(CFCClass *self);
-
-// Create dumpable functions unless hand coded versions were supplied.
-static void
-S_create_dumpables(CFCClass *self);
-
// Pass down methods to from parent to children.
static void
S_bequeath_methods(CFCClass *self);
@@ -651,15 +641,6 @@ S_family_tree_size(CFCClass *self) {
return count;
}
-static void
-S_create_dumpables(CFCClass *self) {
- if (CFCClass_has_attribute(self, "dumpable")) {
- CFCDumpable *dumpable = CFCDumpable_new();
- CFCDumpable_add_dumpables(dumpable, self);
- CFCBase_decref((CFCBase*)dumpable);
- }
-}
-
void
CFCClass_grow_tree(CFCClass *self) {
if (self->tree_grown) {
@@ -667,19 +648,10 @@ CFCClass_grow_tree(CFCClass *self) {
}
S_establish_ancestry(self);
S_bequeath_member_vars(self);
- S_generate_automethods(self);
S_bequeath_methods(self);
self->tree_grown = 1;
}
-static void
-S_generate_automethods(CFCClass *self) {
- S_create_dumpables(self);
- for (size_t i = 0; i < self->num_kids; i++) {
- S_generate_automethods(self->children[i]);
- }
-}
-
// Return value is valid only so long as object persists (elements are not
// refcounted).
CFCClass**
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/src/CFCDumpable.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCDumpable.c b/clownfish/compiler/src/CFCDumpable.c
deleted file mode 100644
index 269eddd..0000000
--- a/clownfish/compiler/src/CFCDumpable.c
+++ /dev/null
@@ -1,405 +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>
-
-#ifndef true
- #define true 1
- #define false 0
-#endif
-
-#define CFC_NEED_BASE_STRUCT_DEF
-#include "CFCBase.h"
-#include "CFCDumpable.h"
-#include "CFCClass.h"
-#include "CFCFunction.h"
-#include "CFCMethod.h"
-#include "CFCParamList.h"
-#include "CFCParcel.h"
-#include "CFCSymbol.h"
-#include "CFCType.h"
-#include "CFCVariable.h"
-#include "CFCUtil.h"
-
-// Add an autogenerated Dump method to the CFCClass.
-static void
-S_add_dump_method(CFCClass *klass);
-
-// Add an autogenerated Load method to the CFCClass.
-static void
-S_add_load_method(CFCClass *klass);
-
-// Create a Clownfish::CFC::Model::Method object for either Dump() or Load().
-static CFCMethod*
-S_make_method_obj(CFCClass *klass, const char *method_name);
-
-// Generate code for dumping a single member var.
-static void
-S_process_dump_member(CFCClass *klass, CFCVariable *member, char *buf,
- size_t buf_size);
-
-// Generate code for loading a single member var.
-static void
-S_process_load_member(CFCClass *klass, CFCVariable *member, char *buf,
- size_t buf_size);
-
-struct CFCDumpable {
- CFCBase base;
-};
-
-static const CFCMeta CFCDUMPABLE_META = {
- "Clownfish::CFC::Dumpable",
- sizeof(CFCDumpable),
- (CFCBase_destroy_t)CFCDumpable_destroy
-};
-
-CFCDumpable*
-CFCDumpable_new(void) {
- CFCDumpable *self = (CFCDumpable*)CFCBase_allocate(&CFCDUMPABLE_META);
- return CFCDumpable_init(self);
-}
-
-CFCDumpable*
-CFCDumpable_init(CFCDumpable *self) {
- return self;
-}
-
-void
-CFCDumpable_destroy(CFCDumpable *self) {
- CFCBase_destroy((CFCBase*)self);
-}
-
-void
-CFCDumpable_add_dumpables(CFCDumpable *self, CFCClass *klass) {
- (void)self;
-
- if (!CFCClass_has_attribute(klass, "dumpable")) {
- CFCUtil_die("Class %s isn't dumpable", CFCClass_get_class_name(klass));
- }
-
- // Inherit Dump/Load from parent if no fresh member vars.
- CFCClass *parent = CFCClass_get_parent(klass);
- if (parent && CFCClass_has_attribute(parent, "dumpable")) {
- CFCVariable **fresh = CFCClass_fresh_member_vars(klass);
- int needs_autogenerated_dumpables = fresh[0] != NULL ? true : false;
- FREEMEM(fresh);
- if (!needs_autogenerated_dumpables) { return; }
- }
-
- if (!CFCClass_fresh_method(klass, "Dump")) {
- S_add_dump_method(klass);
- }
- if (!CFCClass_fresh_method(klass, "Load")) {
- S_add_load_method(klass);
- }
-}
-
-static CFCMethod*
-S_make_method_obj(CFCClass *klass, const char *method_name) {
- const char *klass_full_struct_sym = CFCClass_full_struct_sym(klass);
- const char *klass_name = CFCClass_get_class_name(klass);
- const char *klass_cnick = CFCClass_get_cnick(klass);
- CFCParcel *klass_parcel = CFCClass_get_parcel(klass);
-
- CFCType *return_type = CFCType_new_object(CFCTYPE_INCREMENTED,
- klass_parcel, "cfish_Obj", 1);
- CFCType *self_type = CFCType_new_object(0, klass_parcel,
- klass_full_struct_sym, 1);
- CFCVariable *self_var = CFCVariable_new(NULL, NULL, NULL, NULL, "self",
- self_type, false);
- CFCParamList *param_list = NULL;
-
- if (strcmp(method_name, "Dump") == 0) {
- param_list = CFCParamList_new(false);
- CFCParamList_add_param(param_list, self_var, NULL);
- }
- else if (strcmp(method_name, "Load") == 0) {
- CFCType *dump_type = CFCType_new_object(0, klass_parcel, "cfish_Obj",
- 1);
- CFCVariable *dump_var = CFCVariable_new(NULL, NULL, NULL, NULL, "dump",
- dump_type, false);
- param_list = CFCParamList_new(false);
- CFCParamList_add_param(param_list, self_var, NULL);
- CFCParamList_add_param(param_list, dump_var, NULL);
- CFCBase_decref((CFCBase*)dump_var);
- CFCBase_decref((CFCBase*)dump_type);
- }
- else {
- CFCUtil_die("Unexpected method_name: '%s'", method_name);
- }
-
- CFCMethod *method = CFCMethod_new(klass_parcel, "public", klass_name,
- klass_cnick, method_name, return_type,
- param_list, NULL, false, false);
-
- CFCBase_decref((CFCBase*)param_list);
- CFCBase_decref((CFCBase*)self_type);
- CFCBase_decref((CFCBase*)self_var);
- CFCBase_decref((CFCBase*)return_type);
-
- return method;
-}
-
-#define BUF_SIZE 400
-
-static void
-S_add_dump_method(CFCClass *klass) {
- CFCMethod *method = S_make_method_obj(klass, "Dump");
- CFCClass_add_method(klass, method);
- CFCBase_decref((CFCBase*)method);
- const char *full_func_sym = CFCMethod_implementing_func_sym(method);
- const char *full_struct = CFCClass_full_struct_sym(klass);
- const char *vtable_var = CFCClass_full_vtable_var(klass);
- const char *prefix = CFCClass_get_prefix(klass);
- const char *class_cnick = CFCClass_get_cnick(klass);
- CFCClass *parent = CFCClass_get_parent(klass);
- char buf[BUF_SIZE];
-
- if (parent && CFCClass_has_attribute(parent, "dumpable")) {
- char *full_typedef = CFCMethod_full_typedef(method, klass);
- char *full_meth = CFCMethod_full_method_sym(method, klass);
-
- const char pattern[] =
- "cfish_Obj*\n"
- "%s(%s *self)\n"
- "{\n"
- " %sIVARS *ivars = %s%s_IVARS(self);\n"
- " %s super_dump = CFISH_SUPER_METHOD_PTR(%s, %s);\n"
- " cfish_Hash *dump = (cfish_Hash*)super_dump(self);\n";
- char *autocode
- = CFCUtil_sprintf(pattern, full_func_sym, full_struct,
- full_struct, prefix, class_cnick,
- full_typedef, vtable_var, full_meth);
- CFCClass_append_autocode(klass, autocode);
- FREEMEM(full_meth);
- FREEMEM(full_typedef);
- FREEMEM(autocode);
-
- CFCVariable **fresh = CFCClass_fresh_member_vars(klass);
- for (size_t i = 0; fresh[i] != NULL; i++) {
- S_process_dump_member(klass, fresh[i], buf, BUF_SIZE);
- }
- FREEMEM(fresh);
- }
- else {
- const char pattern[] =
- "cfish_Obj*\n"
- "%s(%s *self)\n"
- "{\n"
- " %sIVARS *ivars = %s%s_IVARS(self);\n"
- " cfish_Hash *dump = cfish_Hash_new(0);\n"
- " Cfish_Hash_Store_Str(dump, \"_class\", 6,\n"
- " (cfish_Obj*)Cfish_CB_Clone(Cfish_Obj_Get_Class_Name((cfish_Obj*)self)));\n";
- char *autocode
- = CFCUtil_sprintf(pattern, full_func_sym, full_struct,
- full_struct, prefix, class_cnick);
- CFCClass_append_autocode(klass, autocode);
- FREEMEM(autocode);
- CFCVariable **members = CFCClass_member_vars(klass);
- for (size_t i = 0; members[i] != NULL; i++) {
- S_process_dump_member(klass, members[i], buf, BUF_SIZE);
- }
- }
-
- CFCClass_append_autocode(klass, " return (cfish_Obj*)dump;\n}\n\n");
-}
-
-static void
-S_add_load_method(CFCClass *klass) {
- CFCMethod *method = S_make_method_obj(klass, "Load");
- CFCClass_add_method(klass, method);
- CFCBase_decref((CFCBase*)method);
- const char *full_func_sym = CFCMethod_implementing_func_sym(method);
- const char *full_struct = CFCClass_full_struct_sym(klass);
- const char *vtable_var = CFCClass_full_vtable_var(klass);
- CFCClass *parent = CFCClass_get_parent(klass);
- const char *prefix = CFCClass_get_prefix(klass);
- const char *class_cnick = CFCClass_get_cnick(klass);
- char buf[BUF_SIZE];
-
- if (parent && CFCClass_has_attribute(parent, "dumpable")) {
- char *full_typedef = CFCMethod_full_typedef(method, klass);
- char *full_meth = CFCMethod_full_method_sym(method, klass);
-
- const char pattern[] =
- "cfish_Obj*\n"
- "%s(%s *self, cfish_Obj *dump)\n"
- "{\n"
- " cfish_Hash *source = (cfish_Hash*)CFISH_CERTIFY(dump, CFISH_HASH);\n"
- " %s super_load = CFISH_SUPER_METHOD_PTR(%s, %s);\n"
- " %s *loaded = (%s*)super_load(self, dump);\n"
- " %sIVARS *ivars = %s%s_IVARS(loaded);\n";
- char *autocode
- = CFCUtil_sprintf(pattern, full_func_sym, full_struct,
- full_typedef, vtable_var, full_meth, full_struct,
- full_struct, full_struct, prefix, class_cnick);
- CFCClass_append_autocode(klass, autocode);
- FREEMEM(full_meth);
- FREEMEM(full_typedef);
- FREEMEM(autocode);
-
- CFCVariable **fresh = CFCClass_fresh_member_vars(klass);
- for (size_t i = 0; fresh[i] != NULL; i++) {
- S_process_load_member(klass, fresh[i], buf, BUF_SIZE);
- }
- FREEMEM(fresh);
- }
- else {
- const char pattern[] =
- "cfish_Obj*\n"
- "%s(%s *self, cfish_Obj *dump)\n"
- "{\n"
- " cfish_Hash *source = (cfish_Hash*)CFISH_CERTIFY(dump, CFISH_HASH);\n"
- " cfish_CharBuf *class_name = (cfish_CharBuf*)CFISH_CERTIFY(\n"
- " Cfish_Hash_Fetch_Str(source, \"_class\", 6), CFISH_CHARBUF);\n"
- " cfish_VTable *vtable = cfish_VTable_singleton(class_name, NULL);\n"
- " %s *loaded = (%s*)Cfish_VTable_Make_Obj(vtable);\n"
- " %sIVARS *ivars = %s%s_IVARS(loaded);\n"
- " CHY_UNUSED_VAR(self);\n";
- char *autocode
- = CFCUtil_sprintf(pattern, full_func_sym, full_struct, full_struct,
- full_struct,
- full_struct, prefix, class_cnick);
- CFCClass_append_autocode(klass, autocode);
- FREEMEM(autocode);
- CFCVariable **members = CFCClass_member_vars(klass);
- for (size_t i = 0; members[i] != NULL; i++) {
- S_process_load_member(klass, members[i], buf, BUF_SIZE);
- }
- }
-
- CFCClass_append_autocode(klass, " return (cfish_Obj*)loaded;\n}\n\n");
-}
-
-static void
-S_process_dump_member(CFCClass *klass, CFCVariable *member, char *buf,
- size_t buf_size) {
- CFCUTIL_NULL_CHECK(member);
- CFCType *type = CFCVariable_get_type(member);
- const char *name = CFCVariable_micro_sym(member);
- unsigned name_len = (unsigned)strlen(name);
- const char *specifier = CFCType_get_specifier(type);
-
- // Skip the VTable.
- if (strcmp(specifier, "cfish_VTable") == 0) {
- return;
- }
-
- if (CFCType_is_integer(type) || CFCType_is_floating(type)) {
- char int_pattern[] =
- " Cfish_Hash_Store_Str(dump, \"%s\", %u, (cfish_Obj*)cfish_CB_newf(\"%%i64\", (int64_t)ivars->%s));\n";
- char float_pattern[] =
- " Cfish_Hash_Store_Str(dump, \"%s\", %u, (cfish_Obj*)cfish_CB_newf(\"%%f64\", (double)ivars->%s));\n";
- char bool_pattern[] =
- " Cfish_Hash_Store_Str(dump, \"%s\", %u, (cfish_Obj*)cfish_Bool_singleton(ivars->%s));\n";
- const char *pattern;
- if (strcmp(specifier, "bool") == 0) {
- pattern = bool_pattern;
- }
- else if (CFCType_is_integer(type)) {
- pattern = int_pattern;
- }
- else {
- pattern = float_pattern;
- }
- size_t needed = strlen(pattern) + name_len * 2 + 20;
- if (buf_size < needed) {
- CFCUtil_die("Buffer not big enough (%lu < %lu)",
- (unsigned long)buf_size, (unsigned long)needed);
- }
- sprintf(buf, pattern, name, name_len, name);
- }
- else if (CFCType_is_object(type)) {
- char pattern[] =
- " if (ivars->%s) {\n"
- " Cfish_Hash_Store_Str(dump, \"%s\", %u, Cfish_Obj_Dump((cfish_Obj*)ivars->%s));\n"
- " }\n";
-
- size_t needed = strlen(pattern) + name_len * 3 + 20;
- if (buf_size < needed) {
- CFCUtil_die("Buffer not big enough (%lu < %lu)",
- (unsigned long)buf_size, (unsigned long)needed);
- }
- sprintf(buf, pattern, name, name, name_len, name);
- }
- else {
- CFCUtil_die("Don't know how to dump a %s",
- CFCType_get_specifier(type));
- }
-
- CFCClass_append_autocode(klass, buf);
-}
-
-static void
-S_process_load_member(CFCClass *klass, CFCVariable *member, char *buf,
- size_t buf_size) {
- CFCUTIL_NULL_CHECK(member);
- CFCType *type = CFCVariable_get_type(member);
- const char *type_str = CFCType_to_c(type);
- const char *name = CFCVariable_micro_sym(member);
- unsigned name_len = (unsigned)strlen(name);
- char extraction[200];
- const char *specifier = CFCType_get_specifier(type);
-
- // Skip the VTable.
- if (strcmp(specifier, "cfish_VTable") == 0) {
- return;
- }
-
- if (2 * strlen(type_str) + 100 > sizeof(extraction)) { // play it safe
- CFCUtil_die("type_str too long: '%s'", type_str);
- }
- if (CFCType_is_integer(type)) {
- if (strcmp(specifier, "bool") == 0) {
- sprintf(extraction, "Cfish_Obj_To_Bool(var)");
- }
- else {
- sprintf(extraction, "(%s)Cfish_Obj_To_I64(var)", type_str);
- }
- }
- else if (CFCType_is_floating(type)) {
- sprintf(extraction, "(%s)Cfish_Obj_To_F64(var)", type_str);
- }
- else if (CFCType_is_object(type)) {
- const char *vtable_var = CFCType_get_vtable_var(type);
- sprintf(extraction,
- "(%s*)CFISH_CERTIFY(Cfish_Obj_Load(var, var), %s)",
- specifier, vtable_var);
- }
- else {
- CFCUtil_die("Don't know how to load %s", specifier);
- }
-
- const char *pattern =
- " {\n"
- " cfish_Obj *var = Cfish_Hash_Fetch_Str(source, \"%s\", %u);\n"
- " if (var) { ivars->%s = %s; }\n"
- " }\n";
- size_t needed = sizeof(pattern)
- + (name_len * 2)
- + strlen(extraction)
- + 20;
- if (buf_size < needed) {
- CFCUtil_die("Buffer not big enough (%lu < %lu)",
- (unsigned long)buf_size, (unsigned long)needed);
- }
- sprintf(buf, pattern, name, name_len, name, extraction);
-
- CFCClass_append_autocode(klass, buf);
-}
-
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/src/CFCDumpable.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCDumpable.h b/clownfish/compiler/src/CFCDumpable.h
deleted file mode 100644
index c76bd89..0000000
--- a/clownfish/compiler/src/CFCDumpable.h
+++ /dev/null
@@ -1,68 +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::Dumpable - Auto-generate code for "dumpable" classes.
- *
- * If a class declares that it has the attribute "dumpable", but does not
- * declare either Dump or Load(), Clownfish::CFC::Dumpable will attempt to
- * auto-generate those methods if methods inherited from the parent class do
- * not suffice.
- *
- * class Foo::Bar inherits Foo : dumpable {
- * Thing *thing;
- *
- * public inert incremented Bar*
- * new();
- *
- * void
- * Destroy(Bar *self);
- * }
- */
-
-#ifndef H_CFCDUMPABLE
-#define H_CFCDUMPABLE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CFCDumpable CFCDumpable;
-struct CFCClass;
-
-/** Constructor.
- */
-CFCDumpable*
-CFCDumpable_new(void);
-
-CFCDumpable*
-CFCDumpable_init(CFCDumpable *self);
-
-void
-CFCDumpable_destroy(CFCDumpable *self);
-
-
-/** Analyze a class with the attribute "dumpable" and add Dump() or Load()
- * methods as necessary.
- */
-void
-CFCDumpable_add_dumpables(CFCDumpable *self, struct CFCClass *klass);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_CFCDUMPABLE */
-
http://git-wip-us.apache.org/repos/asf/lucy/blob/a12fc932/clownfish/compiler/src/CFCTestClass.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCTestClass.c b/clownfish/compiler/src/CFCTestClass.c
index 2eb4183..f94a71b 100644
--- a/clownfish/compiler/src/CFCTestClass.c
+++ b/clownfish/compiler/src/CFCTestClass.c
@@ -44,7 +44,7 @@ S_has_symbol(CFCSymbol **symbols, const char *micro_sym);
const CFCTestBatch CFCTEST_BATCH_CLASS = {
"Clownfish::CFC::Model::Class",
- 87,
+ 86,
S_run_tests
};
@@ -202,11 +202,6 @@ S_run_tests(CFCTest *test) {
}
{
- const char *autocode = CFCClass_get_autocode(foo_jr);
- OK(test, strstr(autocode, "load") != NULL, "autogenerate Dump/Load");
- }
-
- {
CFCClass **ladder = CFCClass_tree_to_ladder(foo);
OK(test, ladder[0] == foo, "ladder[0]");
OK(test, ladder[1] == foo_jr, "ladder[1]");