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/24 01:59:23 UTC

[lucy-commits] svn commit: r1139125 - in /incubator/lucy/trunk/clownfish: lib/Clownfish.xs lib/Clownfish/Binding/Core/Class.pm src/CFCBindClass.c src/CFCBindClass.h

Author: marvin
Date: Thu Jun 23 23:59:23 2011
New Revision: 1139125

URL: http://svn.apache.org/viewvc?rev=1139125&view=rev
Log:
Port _name_var_definition() routine from Clownfish::Binding::Core::Class to C.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish.xs
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm
    incubator/lucy/trunk/clownfish/src/CFCBindClass.c
    incubator/lucy/trunk/clownfish/src/CFCBindClass.h

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.xs?rev=1139125&r1=1139124&r2=1139125&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.xs Thu Jun 23 23:59:23 2011
@@ -1807,6 +1807,13 @@ CODE:
 OUTPUT: RETVAL
 
 SV*
+_name_var_definition(self)
+    CFCBindClass *self;
+CODE:
+    RETVAL = S_sv_eat_c_string(CFCBindClass_name_var_definition(self));
+OUTPUT: RETVAL
+
+SV*
 _vtable_definition(self)
     CFCBindClass *self;
 CODE:

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=1139125&r1=1139124&r2=1139125&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm Thu Jun 23 23:59:23 2011
@@ -30,25 +30,6 @@ sub new {
     return _new( $args{client} );
 }
 
-# C code defining the ZombieCharBuf which contains the class name for this
-# class.
-sub _name_var_definition {
-    my $self           = shift;
-    my $full_var_name  = _full_name_var($self);
-    my $class_name     = $self->_get_client->get_class_name;
-    my $class_name_len = length($class_name);
-    return <<END_STUFF;
-cfish_ZombieCharBuf $full_var_name = {
-    CFISH_ZOMBIECHARBUF,
-    {1}, /* ref.count */
-    "$class_name",
-    $class_name_len,
-    0
-};
-
-END_STUFF
-}
-
 sub to_c_header {
     my $self          = shift;
     my $client        = $self->_get_client;

Modified: incubator/lucy/trunk/clownfish/src/CFCBindClass.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindClass.c?rev=1139125&r1=1139124&r2=1139125&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindClass.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindClass.c Thu Jun 23 23:59:23 2011
@@ -98,6 +98,33 @@ CFCBindClass_struct_definition(CFCBindCl
     return struct_def;
 }
 
+/* C code defining the ZombieCharBuf which contains the class name for this
+ * class. */
+char*
+CFCBindClass_name_var_definition(CFCBindClass *self) {
+    const char *class_name  = CFCClass_get_class_name(self->client);
+    unsigned class_name_len = (unsigned)strlen(class_name);
+
+    const char pattern[] = 
+        "cfish_ZombieCharBuf %s = {\n"
+        "    CFISH_ZOMBIECHARBUF,\n"
+        "    {1}, /* ref.count */\n"
+        "    \"%s\",\n"
+        "    %u,\n"
+        "    0\n"
+        "};\n\n";
+    size_t size = sizeof(pattern)
+                  + strlen(self->full_name_var)
+                  + class_name_len
+                  + 15 // class_name_len
+                  + 20;
+    char *name_var_def = (char*)MALLOCATE(size);
+    sprintf(name_var_def, pattern, self->full_name_var, class_name,
+            class_name_len);
+
+    return name_var_def;
+}
+
 // Return C code defining the class's VTable.
 char*
 CFCBindClass_vtable_definition(CFCBindClass *self) {

Modified: incubator/lucy/trunk/clownfish/src/CFCBindClass.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindClass.h?rev=1139125&r1=1139124&r2=1139125&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindClass.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindClass.h Thu Jun 23 23:59:23 2011
@@ -38,6 +38,9 @@ char*
 CFCBindClass_struct_definition(CFCBindClass *self);
 
 char*
+CFCBindClass_name_var_definition(CFCBindClass *self);
+
+char*
 CFCBindClass_vtable_definition(CFCBindClass *self);
 
 struct CFCClass*