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: r1059138 - in /incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl: Constructor.pm Method.pm Subroutine.pm
Date Fri, 14 Jan 2011 19:38:31 GMT
Author: marvin
Date: Fri Jan 14 19:38:31 2011
New Revision: 1059138

URL: http://svn.apache.org/viewvc?rev=1059138&view=rev
Log:
Remove extra bracketed scope in XS binding wrapper functions, since we no
longer need to adhere to C89 declaration-before-statement rules.

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=1059138&r1=1059137&r2=1059138&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 19:38:31
2011
@@ -67,7 +67,7 @@ sub xsub_def {
     my @var_assignments;
     my @refcount_mods;
     my $allot_params = qq|chy_bool_t args_ok = XSBind_allot_params(\n|
-        . qq|            &(ST(0)), 1, items, "$params_hash_name",\n|;
+        . qq|        &(ST(0)), 1, items, "$params_hash_name",\n|;
 
     # Iterate over args in param list.
     for ( my $i = 1; $i <= $#$arg_vars; $i++ ) {
@@ -79,25 +79,25 @@ sub xsub_def {
         my $len     = length $name;
 
         # Create snippet for extracting sv from stack, if supplied.
-        $allot_params .= qq|            &$sv_name, "$name", $len,\n|;
+        $allot_params .= qq|        &$sv_name, "$name", $len,\n|;
 
         # Create code for determining and validating value.
         my $statement = from_perl( $type, $name, $sv_name );
         if ( defined $val ) {
             my $assignment = qq|if ($sv_name && XSBind_sv_defined($sv_name)) {
-            $statement
-        }
-        else {
-            $name = $val;
-        }|;
+        $statement
+    }
+    else {
+        $name = $val;
+    }|;
             push @var_assignments, $assignment;
         }
         else {
             my $assignment
                 = qq#if ( !$sv_name || !XSBind_sv_defined($sv_name) ) {
-           CFISH_THROW(CFISH_ERR, "Missing required param '$name'");
-        }
-        $statement#;
+       CFISH_THROW(CFISH_ERR, "Missing required param '$name'");
+    }
+    $statement#;
             push @var_assignments, $assignment;
         }
 
@@ -106,7 +106,7 @@ sub xsub_def {
             push @refcount_mods, "if ($name) { LUCY_INCREF($name); }";
         }
     }
-    $allot_params .= "            NULL);";
+    $allot_params .= "        NULL);";
 
     # Last, so that earlier exceptions while fetching params don't trigger bad
     # DESTROY.
@@ -115,9 +115,8 @@ sub xsub_def {
     push @var_assignments,
         qq|self = ($self_type)XSBind_new_blank_obj( ST(0) );|;
 
-    # Bundle up variable assignment statments.
-    my $var_assignments = join( "\n        ", @var_assignments );
-    my $refcount_mods   = join( "\n        ", @refcount_mods );
+    # Bundle up variable assignment statments and refcount modifications.
+    my $var_assignments = join( "\n    ", @var_assignments, @refcount_mods );
 
     return <<END_STUFF;
 XS($c_name);
@@ -128,25 +127,24 @@ XS($c_name)
     CHY_UNUSED_VAR(ax);
     if (items < 1) { CFISH_THROW(CFISH_ERR, "Usage: %s(class_name, ...)",  GvNAME(CvGV(cv)));
}
     SP -= items;
-    {
-        $var_declarations
-        $allot_params
-        if (!args_ok) {
-            CFISH_RETHROW(LUCY_INCREF(cfish_Err_get_error()));
-        }
-        $var_assignments
-        $refcount_mods
-        retval = $func_sym($name_list);
-        if (retval) {
-            ST(0) = (SV*)Cfish_Obj_To_Host((cfish_Obj*)retval);
-            Cfish_Obj_Dec_RefCount((cfish_Obj*)retval);
-        }
-        else {
-            ST(0) = newSV(0);
-        }
-        sv_2mortal( ST(0) );
-        XSRETURN(1);
+
+    $var_declarations
+    $allot_params
+    if (!args_ok) {
+        CFISH_RETHROW(LUCY_INCREF(cfish_Err_get_error()));
+    }
+    $var_assignments
+
+    retval = $func_sym($name_list);
+    if (retval) {
+        ST(0) = (SV*)Cfish_Obj_To_Host((cfish_Obj*)retval);
+        Cfish_Obj_Dec_RefCount((cfish_Obj*)retval);
+    }
+    else {
+        ST(0) = newSV(0);
     }
+    sv_2mortal( ST(0) );
+    XSRETURN(1);
 }
 
 END_STUFF

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=1059138&r1=1059137&r2=1059138&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 19:38:31
2011
@@ -75,12 +75,12 @@ sub _xsub_body {
         next unless $arg_type->is_object;
         next unless $arg_type->decremented;
         my $var_name = $arg_var->micro_sym;
-        $body .= "if ($var_name) (void)LUCY_INCREF($var_name);\n        ";
+        $body .= "if ($var_name) (void)LUCY_INCREF($var_name);\n    ";
     }
 
     if ( $method->void ) {
         # Invoke method in void context.
-        $body .= qq|$full_func_sym($name_list);\n| . qq|        XSRETURN(0);|;
+        $body .= qq|$full_func_sym($name_list);\n| . qq|    XSRETURN(0);|;
     }
     else {
         # Return a value for method invoked in a scalar context.
@@ -91,9 +91,9 @@ sub _xsub_body {
             $decrement = "LUCY_DECREF(retval);\n";
         }
         $body .= qq|retval = $full_func_sym($name_list);
-        $retval_assignment$decrement
-        sv_2mortal( ST(0) );
-        XSRETURN(1);|
+    $retval_assignment$decrement
+    sv_2mortal( ST(0) );
+    XSRETURN(1);|
     }
 
     return $body;
@@ -152,11 +152,11 @@ sub _xsub_def_positional_args {
         if ( defined $val ) {
             $statement
                 = qq|    if ( items >= $i && XSBind_sv_defined(ST($i)) ) {
-            $statement
-        }
-        else { 
-            $var_name = $val;
-        }|;
+        $statement
+    }
+    else { 
+        $var_name = $val;
+    }|;
         }
         push @var_assignments, $statement;
     }
@@ -171,14 +171,13 @@ XS($c_name)
     CHY_UNUSED_VAR(ax);
     SP -= items;
     $num_args_check;
-    {
-        /* Extract vars from Perl stack. */
-        $var_declarations
-        $var_assignments
 
-        /* Execute */
-        $body
-    }
+    /* Extract vars from Perl stack. */
+    $var_declarations
+    $var_assignments
+
+    /* Execute */
+    $body
 }
 END_STUFF
 }
@@ -208,7 +207,7 @@ sub _xsub_def_labeled_params {
         = _self_assign_statement( $self_type, $self->{method}->micro_sym );
     my @var_assignments;
     my $allot_params = qq|chy_bool_t args_ok = XSBind_allot_params(\n|
-        . qq|            &(ST(0)), 1, items, "$params_hash_name",\n|;
+        . qq|        &(ST(0)), 1, items, "$params_hash_name",\n|;
 
     # Iterate over args in param list.
     for ( my $i = 1; $i <= $#$arg_vars; $i++ ) {
@@ -220,31 +219,31 @@ sub _xsub_def_labeled_params {
         my $len     = length $name;
 
         # Code for extracting sv from stack, if supplied.
-        $allot_params .= qq|            &$sv_name, "$name", $len,\n|;
+        $allot_params .= qq|        &$sv_name, "$name", $len,\n|;
 
         # Code for determining and validating value.
         my $statement = from_perl( $type, $name, $sv_name );
         if ( defined $val ) {
             my $assignment
-                = qq|if ( $sv_name && XSBind_sv_defined($sv_name) ) {
-            $statement;
-        }
-        else {
-            $name = $val;
-        }|;
+            = qq|if ( $sv_name && XSBind_sv_defined($sv_name) ) {
+        $statement;
+    }
+    else {
+        $name = $val;
+    }|;
             push @var_assignments, $assignment;
         }
         else {
             my $assignment
                 = qq#if ( !$sv_name || !XSBind_sv_defined($sv_name) ) { #
                 . qq#CFISH_THROW(CFISH_ERR, "Missing required param '$name'"); }\n#
-                . qq#         $statement;#;
+                . qq#     $statement;#;
             push @var_assignments, $assignment;
         }
     }
-    $allot_params .= "            NULL);";
+    $allot_params .= "        NULL);";
     my $var_assignments
-        = join( "\n        ", $self_assignment, @var_assignments, );
+        = join( "\n    ", $self_assignment, @var_assignments, );
 
     return <<END_STUFF;
 XS($c_name);
@@ -255,18 +254,17 @@ XS($c_name)
     CHY_UNUSED_VAR(ax);
     $num_args_check;
     SP -= items;
-    {
-        /* Extract vars from Perl stack. */
-        $var_declarations
-        $allot_params
-        if (!args_ok) {
-            CFISH_RETHROW(LUCY_INCREF(cfish_Err_get_error()));
-        }
-        $var_assignments
 
-        /* Execute */
-        $body
+    /* Extract vars from Perl stack. */
+    $var_declarations
+    $allot_params
+    if (!args_ok) {
+        CFISH_RETHROW(LUCY_INCREF(cfish_Err_get_error()));
     }
+    $var_assignments
+
+    /* Execute */
+    $body
 }
 END_STUFF
 }

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=1059138&r1=1059137&r2=1059138&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 19:38:31
2011
@@ -111,7 +111,7 @@ sub var_declarations {
             map { "SV* " . $_->micro_sym . "_sv = NULL;" }
             @$arg_vars[ 1 .. $#$arg_vars ];
     }
-    return join( "\n        ", @var_declarations );
+    return join( "\n    ", @var_declarations );
 }
 
 sub xsub_def { confess "Abstract method" }



Mime
View raw message