Author: jkeenan
Date: Mon Feb 12 20:28:30 2007
New Revision: 16963

Modified:
   branches/buildtools/lib/Parrot/Ops2c/Utils.pm
   branches/buildtools/tools/build/ops2c.pl

Log:
1.  Deleted much commented-out code.
2.  Converted _print_preamble_header() to a method.


Modified: branches/buildtools/lib/Parrot/Ops2c/Utils.pm
==============================================================================
--- branches/buildtools/lib/Parrot/Ops2c/Utils.pm       (original)
+++ branches/buildtools/lib/Parrot/Ops2c/Utils.pm       Mon Feb 12 20:28:30 2007
@@ -185,13 +185,7 @@
     open my $HEADER, '>', $self->{header}
         or die "ops2c.pl: Cannot open header file '$self->{header}' for 
writing: $!!\n";
 
-    _print_preamble_header( {
-        fh          => $HEADER,
-        preamble    => $self->{preamble},
-        flag        => $self->{flag},
-        sym_export  => $self->{sym_export},
-        init_func   => $self->{init_func},
-    } );
+    $self->_print_preamble_header($HEADER);
 
     _print_run_core_func_decl_header( {
         trans   => $self->{trans},
@@ -208,18 +202,17 @@
 }
 
 sub _print_preamble_header {
-    my $argsref = shift;
-    my $fh = $argsref->{fh};
+    my ($self, $fh) = @_;
 
-    print $fh $argsref->{preamble};
-    if ($argsref->{flag}->{dynamic}) {
+    print $fh $self->{preamble};
+    if ($self->{flag}->{dynamic}) {
         print $fh "#define PARROT_IN_EXTENSION\n";
     }
     print $fh <<END_C;
 #include "parrot/parrot.h"
 #include "parrot/oplib.h"
 
-$argsref->{sym_export} extern op_lib_t *$argsref->{init_func}(long init);
+$self->{sym_export} extern op_lib_t *$self->{init_func}(long init);
 
 END_C
 }

Modified: branches/buildtools/tools/build/ops2c.pl
==============================================================================
--- branches/buildtools/tools/build/ops2c.pl    (original)
+++ branches/buildtools/tools/build/ops2c.pl    Mon Feb 12 20:28:30 2007
@@ -11,11 +11,7 @@
 use Parrot::Ops2c::Auxiliary qw( Usage getoptions );
 use Parrot::Ops2c::Utils;
 
-#
-# Look at the command line options
-#
 my $flagref = getoptions();
-
 if (
         (not defined $flagref) or 
         $flagref->{help} or
@@ -25,15 +21,6 @@
         exit 1;
 }
 
-#my $class_name = shift @ARGV;
-#print STDERR Dumper ([EMAIL PROTECTED], $class_name);
-#my %is_allowed = map { $_ => 1 } qw(C CGoto CGP CSwitch CPrederef);
-#unless ($is_allowed{$class_name}) {
-#    Usage();
-#    exit 1;
-#}
-
-#########################
 my $self = Parrot::Ops2c::Utils->new( {
     argv    => [ @ARGV ],
     flag    => $flagref,
@@ -44,73 +31,6 @@
     exit 1;
 }
 #########################
-#my $trans_class = "Parrot::OpTrans::" . $class_name;
-#eval "require $trans_class";
-#my $trans           = $trans_class->new();
-#my $suffix          = $trans->suffix();     # Invoked (sometimes) as ${suffix}
-
-#my $file = $flagref->{core} ? 'core.ops' : shift @ARGV;
-#my $base = $file;   # Invoked (sometimes) as ${base}
-#$base =~ s/\.ops$//;
-#my $base_ops_stub = $base . q{_ops} . $suffix;
-#my $base_ops_h    = $base_ops_stub . q{.h};
-#
-#my $incdir  = "include/parrot/oplib";
-#my $include = "parrot/oplib/$base_ops_h";
-#my $header  = "include/$include";
-#
-## SOURCE is closed and reread, which confuses make -j
-## create a temp file and rename it
-#my $source = "src/ops/$base_ops_stub.c.temp";
-#
-#if ( $base =~ m!^src/dynoplibs/! || $flagref->{dynamic} ) {
-#    $source             =~ s!src/ops/!!;
-#    $header             = $base_ops_h;
-#    $base               =~ s!^.*[/\\]!!;
-#    $include            = $base_ops_h;
-#    $flagref->{dynamic} = 1;
-#}
-#
-#my $sym_export = $flagref->{dynamic} ? 'PARROT_DYNEXT_EXPORT' : 'PARROT_API';
-
-# Read the input files:
-#my $ops;
-#if ($flagref->{core}) {
-#    $ops = _prepare_core( {
-#        file        => $file,
-#        flag        => $flagref,
-#    } );
-#}
-#else {
-#    $ops = _prepare_non_core( {
-#        file        => $file,
-#        argv        => [ @ARGV ],
-#        flag        => $flagref,
-#    } );
-#}
-#
-#my %versions = (
-#    major => $ops->major_version,
-#    minor => $ops->minor_version,
-#    patch => $ops->patch_version,
-#);
-#my $num_ops       = scalar $ops->ops;
-#my $num_entries   = $num_ops + 1;          # For trailing NULL
-
-#if ( !$flagref->{dynamic} && !-d $incdir ) {
-#    mkdir( $incdir, 0755 ) or die "ops2c.pl: Could not mkdir $incdir $!!\n";
-#}
-#
-#my $preamble = _compose_preamble($file, $0);
-#
-#my $init_func = join q{_}, (
-#    q{Parrot},
-#    q{DynOp},
-#    $base . $suffix,
-#    @versions{ qw(major minor patch) },
-#);
-
-#########################
 local @ARGV = @{$self->{argv}};
 my $trans = $self->{trans};
 my $suffix = $self->{suffix};
@@ -131,29 +51,7 @@
 my $preamble = $self->{preamble};
 my $init_func = $self->{init_func};
 
-#########################
-
-# Open the C-header (.h) file
-#open my $HEADER, '>', $header
-#    or die "ops2c.pl: Cannot open header file '$header' for writing: $!!\n";
-#
-#_print_preamble_header( {
-#    fh          => $HEADER,
-#    preamble    => $preamble,
-#    flag        => $flagref,
-#    sym_export  => $sym_export,
-#    init_func   => $init_func,
-#} );
-#
-#_print_run_core_func_decl_header( {
-#    trans   => $trans,
-#    fh      => $HEADER,
-#    base    => $base,
-#} );
-#
-#_print_coda($HEADER);
-#
-#close $HEADER or die "Unable to close handle to $header: $!";
+##### BEGIN printing to $HEADER #####
 $self->print_c_header_file();
 ##### END printing to $HEADER #####
 
@@ -226,6 +124,7 @@
     trans       => $trans,
     base        => $base,
 } );
+#######
 
 # reset #line in the SOURCE file.
 $SOURCE = _reset_line_number( {
@@ -308,71 +207,6 @@
 
 #################### SUBROUTINES ####################
 
-#sub _prepare_core {
-#    my $argsref = shift;
-#    my $ops = Parrot::OpsFile->new(
-#        [ qq|src/ops/$argsref->{file}| ],
-#        $argsref->{flag}->{nolines},
-#    );
-#    $ops->{OPS}      = $Parrot::OpLib::core::ops;
-#    $ops->{PREAMBLE} = $Parrot::OpLib::core::preamble;
-#    return $ops;
-#}
-#
-#sub _prepare_non_core {
-#    my $argsref = shift;
-#    my %opsfiles;
-#    my @opsfiles;
-#
-#    foreach my $f ( $argsref->{file}, @{$argsref->{argv}} ) {
-#        if ( $opsfiles{$f} ) {
-#            print STDERR "$0: Ops file '$f' mentioned more than once!\n";
-#            next;
-#        }
-#
-#        $opsfiles{$f} = 1;
-#        push @opsfiles, $f;
-#
-#        die "$0: Could not read ops file '$f'!\n" unless -r $f;
-#    }
-#
-#    my $ops = Parrot::OpsFile->new( [EMAIL PROTECTED], 
$argsref->{flag}->{nolines} );
-#
-#    my $cur_code = 0;
-#    for my $el ( @{ $ops->{OPS} } ) {
-#        $el->{CODE} = $cur_code++;
-#    }
-#    return $ops;
-#}
-
-#sub _print_preamble_header {
-#    my $argsref = shift;
-#    my $fh = $argsref->{fh};
-#
-#    print $fh $argsref->{preamble};
-#    if ($argsref->{flag}->{dynamic}) {
-#        print $fh "#define PARROT_IN_EXTENSION\n";
-#    }
-#    print $fh <<END_C;
-##include "parrot/parrot.h"
-##include "parrot/oplib.h"
-#
-#$argsref->{sym_export} extern op_lib_t *$argsref->{init_func}(long init);
-#
-#END_C
-#}
-#
-#sub _print_run_core_func_decl_header {
-#    my $argsref = shift;
-#    if ( $argsref->{trans}->can("run_core_func_decl") ) {
-#        my $run_core_func = $trans->run_core_func_decl($argsref->{base});
-#        my $fh = $argsref->{fh};
-#        print $fh "$run_core_func;\n";
-#    } else {
-#        return;
-#    }
-#}
-
 sub _print_coda {
     my $fh = shift;
     print $fh <<END_C;

Reply via email to