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 2010/10/31 06:23:53 UTC

[lucy-commits] svn commit: r1029248 - in /incubator/lucy/trunk/clownfish/lib/Clownfish/Binding: Core/Class.pm Core/Method.pm Perl.pm

Author: marvin
Date: Sun Oct 31 05:23:52 2010
New Revision: 1029248

URL: http://svn.apache.org/viewvc?rev=1029248&view=rev
Log:
Fix many incorrect uses of parcel prefixes.  These become obviously wrong when
you try to compile an set of classes consisting of more than one parcel, e.g.
by putting Obj within "parcel Clownfish".

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm

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=1029248&r1=1029247&r2=1029248&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Class.pm Sun Oct 31 05:23:52 2010
@@ -64,19 +64,21 @@ sub include_h {
     return join( '/', @components );
 }
 
-sub vtable_var    { uc( shift->{struct_sym} ) }
-sub callbacks_var { shift->vtable_var . '_CALLBACKS' }
-sub name_var      { shift->vtable_var . '_CLASS_NAME' }
+sub vtable_var      { uc( shift->{struct_sym} ) }
+sub full_vtable_var { $_[0]->get_PREFIX . uc( $_[0]->{struct_sym} ) }
+sub callbacks_var   { shift->vtable_var . '_CALLBACKS' }
+sub name_var        { shift->vtable_var . '_CLASS_NAME' }
+sub full_name_var   { shift->full_vtable_var . '_CLASS_NAME' }
 
 sub name_var_definition {
     my $self           = shift;
     my $prefix         = $self->get_prefix;
     my $PREFIX         = $self->get_PREFIX;
-    my $full_var_name  = $PREFIX . $self->name_var;
+    my $full_var_name  = $self->full_name_var;
     my $class_name_len = length( $self->{class_name} );
     return <<END_STUFF;
-${prefix}ZombieCharBuf $full_var_name = {
-    ${PREFIX}ZOMBIECHARBUF,
+kino_ZombieCharBuf $full_var_name = {
+    KINO_ZOMBIECHARBUF,
     {1}, /* ref.count */
     "$self->{class_name}",
     $class_name_len,
@@ -93,8 +95,8 @@ sub vtable_definition {
     my $client     = $self->{client};
     my $parent     = $client->get_parent;
     my @methods    = $client->methods;
-    my $name_var   = $self->name_var;
-    my $vtable_var = $self->vtable_var;
+    my $name_var   = $self->full_name_var;
+    my $vtable_var = $self->full_vtable_var;
     my $vt         = $vtable_var . "_vt";
     my $vt_type    = $self->vtable_type;
     my $cnick      = $self->{cnick};
@@ -104,7 +106,7 @@ sub vtable_definition {
     # Create a pointer to the parent class's vtable.
     my $parent_ref
         = defined $parent
-        ? "$PREFIX" . $parent->vtable_var
+        ? $parent->full_vtable_var
         : "NULL";    # No parent, e.g. Obj or inert classes.
 
     # Spec functions which implement the methods, casting to quiet compiler.
@@ -115,17 +117,17 @@ sub vtable_definition {
 
     return <<END_VTABLE
 
-$PREFIX$vt_type $PREFIX$vt = {
-    ${PREFIX}VTABLE, /* vtable vtable */
+$PREFIX$vt_type $vt = {
+    KINO_VTABLE, /* vtable vtable */
     {1}, /* ref.count */
     $parent_ref, /* parent */
-    (${prefix}CharBuf*)&${PREFIX}$name_var,
+    (kino_CharBuf*)&$name_var,
     0, /* flags */
     NULL, /* "void *x" member reserved for future use */
     sizeof($self->{full_struct_sym}), /* obj_alloc_size */
-    offsetof(${prefix}VTable, methods) 
+    offsetof(kino_VTable, methods) 
         + $num_methods * sizeof(kino_method_t), /* vt_alloc_size */
-    (${prefix}Callback**)&${PREFIX}${vtable_var}_CALLBACKS,  /* callbacks */
+    (kino_Callback**)&${vtable_var}_CALLBACKS,  /* callbacks */
     {
         $method_string
     }
@@ -204,7 +206,7 @@ sub to_c_header {
     my $vt_type       = $PREFIX . $self->vtable_type;
     my $vt            = "extern struct $vt_type $PREFIX${vtable_var}_vt;";
     my $vtable_object = "#define $PREFIX$vtable_var "
-        . "((${prefix}VTable*)&$PREFIX${vtable_var}_vt)";
+        . "((kino_VTable*)&$PREFIX${vtable_var}_vt)";
     my $num_methods = scalar @methods;
 
     # Declare Callback objects.
@@ -286,15 +288,15 @@ $method_typedefs
 $method_defs
 
 typedef struct $vt_type {
-    ${prefix}VTable *vtable;
+    kino_VTable *vtable;
     kino_ref_t ref;
-    ${prefix}VTable *parent;
-    ${prefix}CharBuf *name;
+    kino_VTable *parent;
+    kino_CharBuf *name;
     uint32_t flags;
     void *x;
     size_t obj_alloc_size;
     size_t vt_alloc_size;
-    ${prefix}Callback **callbacks;
+    kino_Callback **callbacks;
     kino_method_t methods[$num_methods];
 } $vt_type;
 $vt
@@ -374,8 +376,8 @@ sub to_c {
     # allow us to initialize a pointer to an anonymous array inside a global
     # struct, we have to give it a real symbol and then store a pointer to
     # that symbol inside the VTable struct.
-    my $callbacks_var = $PREFIX . $self->vtable_var . "_CALLBACKS";
-    $callbacks .= "${prefix}Callback *$callbacks_var" . "[] = {\n    ";
+    my $callbacks_var = $self->full_vtable_var . "_CALLBACKS";
+    $callbacks .= "kino_Callback *$callbacks_var" . "[] = {\n    ";
     $callbacks .= join( ",\n    ", @class_callbacks, "NULL" );
     $callbacks .= "\n};\n";
 

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm?rev=1029248&r1=1029247&r2=1029248&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm Sun Oct 31 05:23:52 2010
@@ -44,7 +44,6 @@ sub _virtual_method_def {
     my $full_method_sym = $method->full_method_sym($cnick);
     my $full_offset_sym = $method->full_offset_sym($cnick);
     my $typedef         = $method->full_typedef;
-    my $prefix          = $method->get_prefix;
     my $arg_names       = $param_list->name_list;
     $arg_names =~ s/\s*\w+/self/;
 
@@ -88,7 +87,6 @@ END_STUFF
 
 sub typedef_dec {
     my ( undef, $method ) = @_;
-    my $prefix      = $method->get_prefix;
     my $params      = $method->get_param_list->to_c;
     my $return_type = $method->get_return_type->to_c;
     my $typedef     = $method->full_typedef;
@@ -191,7 +189,6 @@ sub _invalid_callback_def {
         = $method->full_method_sym( $method->get_class_cnick );
     my $override_sym = $method->full_override_sym;
     my $params       = $method->get_param_list->to_c;
-    my $prefix       = $method->get_prefix;
     my $unused       = '';
     for my $var ( @{ $method->get_param_list->get_variables } ) {
         my $var_name = $var->micro_sym;
@@ -212,12 +209,11 @@ sub _void_callback_def {
     my ( $method, $callback_params ) = @_;
     my $override_sym = $method->full_override_sym;
     my $params       = $method->get_param_list->to_c;
-    my $prefix       = $method->get_prefix;
     return <<END_CALLBACK_DEF;
 void
 $override_sym($params)
 {
-    ${prefix}Host_callback($callback_params);
+    kino_Host_callback($callback_params);
 }
 END_CALLBACK_DEF
 }
@@ -229,11 +225,10 @@ sub _primitive_callback_def {
     my $params          = $method->get_param_list->to_c;
     my $return_type     = $method->get_return_type;
     my $return_type_str = $return_type->to_c;
-    my $prefix          = $method->get_prefix;
     my $nat_func
-        = $return_type->is_floating ? "${prefix}Host_callback_f64"
-        : $return_type->is_integer  ? "${prefix}Host_callback_i64"
-        : $return_type_str eq 'void*' ? "${prefix}Host_callback_host"
+        = $return_type->is_floating ? "kino_Host_callback_f64"
+        : $return_type->is_integer  ? "kino_Host_callback_i64"
+        : $return_type_str eq 'void*' ? "kino_Host_callback_host"
         :   confess("unrecognized type: $return_type_str");
     return <<END_CALLBACK_DEF;
 $return_type_str
@@ -252,12 +247,10 @@ sub _obj_callback_def {
     my $params          = $method->get_param_list->to_c;
     my $return_type     = $method->get_return_type;
     my $return_type_str = $return_type->to_c;
-    my $prefix          = $method->get_prefix;
-    my $PREFIX          = $method->get_PREFIX;
     my $cb_func_name
         = $return_type->is_string_type
-        ? "${prefix}Host_callback_str"
-        : "${prefix}Host_callback_obj";
+        ? "kino_Host_callback_str"
+        : "kino_Host_callback_obj";
 
     my $nullable_check = "";
     if ( !$return_type->nullable ) {
@@ -293,8 +286,6 @@ sub abstract_method_def {
     my $vtable          = uc( $method->self_type->get_specifier );
     my $return_type     = $method->get_return_type;
     my $return_type_str = $return_type->to_c;
-    my $prefix          = $method->get_prefix;
-    my $Prefix          = $method->get_Prefix;
     my $macro_sym       = $method->get_macro_sym;
 
     # Build list of unused params and create an unreachable return statement

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm?rev=1029248&r1=1029247&r2=1029248&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm Sun Oct 31 05:23:52 2010
@@ -339,7 +339,6 @@ sub _write_boot_c {
         my $include_h = $class->include_h;
         $pound_includes .= qq|#include "$include_h"\n|;
         next if $class->inert;
-        my $prefix  = $class->get_prefix;
         my $PREFIX  = $class->get_PREFIX;
         my $vt_type = $PREFIX . $class->vtable_type;
 
@@ -347,7 +346,7 @@ sub _write_boot_c {
         # multiple threads contend for adding these permanent VTables and some
         # fail.
         $registrations
-            .= qq|    ${prefix}VTable_add_to_registry($PREFIX|
+            .= qq|    kino_VTable_add_to_registry($PREFIX|
             . $class->vtable_var
             . qq|);\n|;