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 2011/06/20 23:09:06 UTC
[lucy-commits] svn commit: r1137786 - in /incubator/lucy/trunk/clownfish/src: CFCDumpable.c
CFCType.c CFCType.h
Author: marvin
Date: Mon Jun 20 21:09:05 2011
New Revision: 1137786
URL: http://svn.apache.org/viewvc?rev=1137786&view=rev
Log:
Cache name of VTable var inside of object-type CFCTType objects.
Modified:
incubator/lucy/trunk/clownfish/src/CFCDumpable.c
incubator/lucy/trunk/clownfish/src/CFCType.c
incubator/lucy/trunk/clownfish/src/CFCType.h
Modified: incubator/lucy/trunk/clownfish/src/CFCDumpable.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCDumpable.c?rev=1137786&r1=1137785&r2=1137786&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCDumpable.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCDumpable.c Mon Jun 20 21:09:05 2011
@@ -365,7 +365,7 @@ S_process_load_member(CFCClass *klass, C
return;
}
- if (strlen(type_str) + 100 > sizeof(extraction)) { // play it safe
+ if (2 * strlen(type_str) + 100 > sizeof(extraction)) { // play it safe
croak("type_str too long: '%s'", type_str);
}
if (CFCType_is_integer(type)) {
@@ -377,14 +377,7 @@ S_process_load_member(CFCClass *klass, C
if (check < 0) { croak("sprintf failed"); }
}
else if (CFCType_is_object(type)) {
- char vtable_var[50];
- if (specifier_len > sizeof(vtable_var) - 2) {
- croak("specifier too long: '%s'", specifier);
- }
- size_t i;
- for (i = 0; i <= specifier_len; i++) {
- vtable_var[i] = toupper(specifier[i]);
- }
+ const char *vtable_var = CFCType_get_vtable_var(type);
int check = sprintf(extraction,
"(%s*)CFISH_CERTIFY(Cfish_Obj_Load(var, var), %s)",
specifier, vtable_var);
Modified: incubator/lucy/trunk/clownfish/src/CFCType.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCType.c?rev=1137786&r1=1137785&r2=1137786&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCType.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCType.c Mon Jun 20 21:09:05 2011
@@ -37,6 +37,7 @@ struct CFCType {
CFCBase base;
int flags;
char *specifier;
+ char *vtable_var;
int indirection;
struct CFCParcel *parcel;
char *c_string;
@@ -65,6 +66,16 @@ CFCType_init(CFCType *self, int flags, s
self->width = 0;
self->array = NULL;
self->child = NULL;
+ if (flags & CFCTYPE_OBJECT) {
+ int i;
+ self->vtable_var = CFCUtil_strdup(specifier);
+ for (i = 0; self->vtable_var[i] != 0; i++) {
+ self->vtable_var[i] = toupper(self->vtable_var[i]);
+ }
+ }
+ else {
+ self->vtable_var = NULL;
+ }
return self;
}
@@ -366,6 +377,11 @@ CFCType_get_specifier(CFCType *self) {
return self->specifier;
}
+const char*
+CFCType_get_vtable_var(CFCType *self) {
+ return self->vtable_var;
+}
+
int
CFCType_get_indirection(CFCType *self) {
return self->indirection;
Modified: incubator/lucy/trunk/clownfish/src/CFCType.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCType.h?rev=1137786&r1=1137785&r2=1137786&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCType.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCType.h Mon Jun 20 21:09:05 2011
@@ -84,6 +84,12 @@ CFCType_set_specifier(CFCType *self, con
const char*
CFCType_get_specifier(CFCType *self);
+/** Return the name of the VTable variable which corresponds to the object
+ * type. Returns NULL for non-object types.
+ */
+const char*
+CFCType_get_vtable_var(CFCType *self);
+
int
CFCType_get_indirection(CFCType *self);