lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] svn commit: r1059170 - in /incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl: Constructor.pm Method.pm Subroutine.pm
Date Fri, 14 Jan 2011 21:14:46 GMT
Author: marvin
Date: Fri Jan 14 21:14:46 2011
New Revision: 1059170

URL: http://svn.apache.org/viewvc?rev=1059170&view=rev
Log:
Declare some variables locally (self, retval) rather than relying on the
var_declarations() method.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm?rev=1059170&r1=1059169&r2=1059170&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm Fri Jan 14 21:14:46
2011
@@ -113,7 +113,7 @@ sub xsub_def {
     my $self_var  = $arg_vars->[0];
     my $self_type = $self_var->get_type->to_c;
     push @var_assignments,
-        qq|self = ($self_type)XSBind_new_blank_obj( ST(0) );|;
+        qq|$self_type self = ($self_type)XSBind_new_blank_obj( ST(0) );|;
 
     # Bundle up variable assignment statments and refcount modifications.
     my $var_assignments = join( "\n    ", @var_assignments, @refcount_mods );
@@ -134,7 +134,7 @@ XS($c_name)
     }
     $var_assignments
 
-    retval = $func_sym($name_list);
+    $self_type retval = $func_sym($name_list);
     if (retval) {
         ST(0) = (SV*)Cfish_Obj_To_Host((cfish_Obj*)retval);
         Cfish_Obj_Dec_RefCount((cfish_Obj*)retval);

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm?rev=1059170&r1=1059169&r2=1059170&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm Fri Jan 14 21:14:46
2011
@@ -85,12 +85,13 @@ sub _xsub_body {
     else {
         # Return a value for method invoked in a scalar context.
         my $return_type       = $method->get_return_type;
+        my $type_str          = $return_type->to_c;
         my $retval_assignment = to_perl( $return_type, 'ST(0)', 'retval' );
         my $decrement         = "";
         if ( $return_type->is_object and $return_type->incremented ) {
             $decrement = "LUCY_DECREF(retval);\n";
         }
-        $body .= qq|retval = $full_func_sym($name_list);
+        $body .= qq|$type_str retval = $full_func_sym($name_list);
     $retval_assignment$decrement
     sv_2mortal( ST(0) );
     XSRETURN(1);|
@@ -280,7 +281,7 @@ sub _self_assign_statement {
         = $method_name eq 'deserialize'
         ? 'XSBind_maybe_sv_to_cfish_obj'
         : 'XSBind_sv_to_cfish_obj';
-    return "self = ($type_c)$binding_func(ST(0), $vtable, NULL);";
+    return "$type_c self = ($type_c)$binding_func(ST(0), $vtable, NULL);";
 }
 
 1;

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm?rev=1059170&r1=1059169&r2=1059170&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm Fri Jan 14 21:14:46
2011
@@ -99,13 +99,10 @@ sub params_hash_def {
 }
 
 sub var_declarations {
-    my $self             = shift;
-    my $arg_vars         = $self->{param_list}->get_variables;
-    my @var_declarations = map { $_->local_declaration } @$arg_vars;
-    if ( !$self->{retval_type}->is_void ) {
-        my $return_type = $self->{retval_type}->to_c;
-        push @var_declarations, "$return_type retval;";
-    }
+    my $self     = shift;
+    my $arg_vars = $self->{param_list}->get_variables;
+    my @var_declarations
+        = map { $_->local_declaration } @$arg_vars[ 1 .. $#$arg_vars ];
     if ( $self->{use_labeled_params} ) {
         push @var_declarations,
             map { "SV* " . $_->micro_sym . "_sv = NULL;" }



Mime
View raw message