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/07/07 21:45:35 UTC
[lucy-commits] svn commit: r1144002 - in /incubator/lucy/trunk/clownfish: lib/Clownfish.xs
lib/Clownfish/Binding/Core.pm lib/Clownfish/Binding/Core/Class.pm
src/CFCClass.c src/CFCClass.h
Author: marvin
Date: Thu Jul 7 19:45:35 2011
New Revision: 1144002
URL: http://svn.apache.org/viewvc?rev=1144002&view=rev
Log:
Consolidate symbol generation with a member var.
Generate the macro symbol used to indicate that access to a class's inner
workings is needed within CFCClass's constructor, rather than reassembling it
in multiple places throughout the CFC code base.
Modified:
incubator/lucy/trunk/clownfish/lib/Clownfish.xs
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm
incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm
incubator/lucy/trunk/clownfish/src/CFCClass.c
incubator/lucy/trunk/clownfish/src/CFCClass.h
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.xs?rev=1144002&r1=1144001&r2=1144002&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.xs Thu Jul 7 19:45:35 2011
@@ -299,6 +299,7 @@ ALIAS:
tree_to_ladder = 42
novel_methods = 44
novel_member_vars = 46
+ privacy_symbol = 48
PPCODE:
{
START_SET_OR_GET_SWITCH
@@ -413,6 +414,11 @@ PPCODE:
FREEMEM(novel);
break;
}
+ case 48: {
+ const char *value = CFCClass_privacy_symbol(self);
+ retval = value ? newSVpvn(value, strlen(value)) : newSV(0);
+ }
+ break;
END_SET_OR_GET_SWITCH
}
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm?rev=1144002&r1=1144001&r2=1144002&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core.pm Thu Jul 7 19:45:35 2011
@@ -200,7 +200,7 @@ sub _write_parcel_c {
my $bound = Clownfish::Binding::Core::Class->new(
client => $block, );
$content .= $bound->to_c . "\n";
- my $c_file_sym = "C_" . uc( $block->full_struct_sym );
+ my $c_file_sym = $block->privacy_symbol;
$c_file_syms .= "#define $c_file_sym\n";
my $include_h = $block->include_h;
$includes .= qq|#include "$include_h"\n|;
Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm?rev=1144002&r1=1144001&r2=1144002&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm Thu Jul 7 19:45:35 2011
@@ -38,7 +38,7 @@ sub to_c_header {
my $methods = $client->methods;
my $novel_methods = $client->novel_methods;
my $inert_vars = $client->inert_vars;
- my $c_file_sym = "C_" . uc($client->full_struct_sym);
+ my $c_file_sym = $client->privacy_symbol;
my $struct_def = _struct_definition($self);
# If class inherits from something, include the parent class's header.
Modified: incubator/lucy/trunk/clownfish/src/CFCClass.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCClass.c?rev=1144002&r1=1144001&r2=1144002&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCClass.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCClass.c Thu Jul 7 19:45:35 2011
@@ -81,6 +81,7 @@ struct CFCClass {
char *full_vtable_var;
char *full_vtable_hidden;
char *full_vtable_type;
+ char *privacy_symbol;
char *include_h;
};
@@ -166,6 +167,7 @@ CFCClass_do_create(CFCClass *self, struc
self->full_vtable_var = (char*)MALLOCATE(prefix_len + struct_sym_len + 1);
self->full_vtable_hidden = (char*)MALLOCATE(prefix_len + struct_sym_len + 3 + 1);
self->full_vtable_type = (char*)MALLOCATE(prefix_len + struct_sym_len + 3 + 1);
+ self->privacy_symbol = (char*)MALLOCATE(prefix_len + struct_sym_len + 2 + 1);
size_t i;
for (i = 0; i < struct_sym_len; i++) {
self->short_vtable_var[i] = toupper(self->struct_sym[i]);
@@ -178,6 +180,7 @@ CFCClass_do_create(CFCClass *self, struc
self->full_vtable_var[i] = '\0';
sprintf(self->full_vtable_type, "%s_VT", self->full_vtable_var);
sprintf(self->full_vtable_hidden, "%s_vt", self->full_vtable_var);
+ sprintf(self->privacy_symbol, "C_%s", self->full_vtable_var);
// Cache the relative path to the autogenerated C header file.
size_t source_class_len = strlen(self->source_class);
@@ -245,6 +248,7 @@ CFCClass_destroy(CFCClass *self) {
FREEMEM(self->full_vtable_var);
FREEMEM(self->full_vtable_hidden);
FREEMEM(self->full_vtable_type);
+ FREEMEM(self->privacy_symbol);
CFCSymbol_destroy((CFCSymbol*)self);
}
@@ -758,6 +762,11 @@ CFCClass_full_vtable_type(CFCClass *self
}
const char*
+CFCClass_privacy_symbol(CFCClass *self) {
+ return self->privacy_symbol;
+}
+
+const char*
CFCClass_include_h(CFCClass *self) {
return self->include_h;
}
Modified: incubator/lucy/trunk/clownfish/src/CFCClass.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCClass.h?rev=1144002&r1=1144001&r2=1144002&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCClass.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCClass.h Thu Jul 7 19:45:35 2011
@@ -160,6 +160,12 @@ CFCClass_full_vtable_hidden(CFCClass *se
const char*
CFCClass_full_vtable_type(CFCClass *self);
+/** Access the symbol which unlocks the class struct definition and other
+ * private information.
+ */
+const char*
+CFCClass_privacy_symbol(CFCClass *self);
+
const char*
CFCClass_include_h(CFCClass *self);