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/07/10 06:15:04 UTC

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

Author: marvin
Date: Sun Jul 10 04:15:04 2011
New Revision: 1144776

URL: http://svn.apache.org/viewvc?rev=1144776&view=rev
Log:
Convert to inside-out object model.

Convert to inside-out object pattern in anticipation of step-by-step
migration to C.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm
    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.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm?rev=1144776&r1=1144775&r2=1144776&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl.pm Sun Jul 10 04:15:04 2011
@@ -42,44 +42,97 @@ our %new_PARAMS = (
     footer     => undef,
 );
 
+our %parcel;
+our %hierarchy;
+our %lib_dir;
+our %boot_class;
+our %header;
+our %footer;
+our %xs_path;
+our %pm_path;
+our %boot_h_file;
+our %boot_c_file;
+our %boot_h_path;
+our %boot_c_path;
+our %boot_func;
+
 sub new {
-    my $either = shift;
-    verify_args( \%new_PARAMS, @_ ) or confess $@;
-    my $self = bless { %new_PARAMS, @_, }, ref($either) || $either;
-    if ( !a_isa_b( $self->{parcel}, 'Clownfish::Parcel' ) ) {
-        $self->{parcel}
-            = Clownfish::Parcel->singleton( name => $self->{parcel} );
+    my ( $either, %args ) = @_;
+    verify_args( \%new_PARAMS, %args ) or confess $@;
+    if ( !a_isa_b( $args{parcel}, 'Clownfish::Parcel' ) ) {
+        $args{parcel} = Clownfish::Parcel->singleton( name => $args{parcel} );
     }
-    my $parcel = $self->{parcel};
     for ( keys %new_PARAMS ) {
-        confess("$_ is mandatory") unless defined $self->{$_};
+        confess("$_ is mandatory") unless defined $args{$_};
     }
 
+    # Create object.
+    my $empty = "";
+    my $self = bless \$empty, ref($either) || $either;
+    $parcel{$self}     = $args{parcel};
+    $hierarchy{$self}  = $args{hierarchy};
+    $lib_dir{$self}    = $args{lib_dir};
+    $boot_class{$self} = $args{boot_class};
+    $header{$self}     = $args{header};
+    $footer{$self}     = $args{footer};
+
     # Derive filenames.
-    my $lib                = $self->{lib_dir};
-    my $dest_dir           = $self->{hierarchy}->get_dest;
-    my @file_components    = split( '::', $self->{boot_class} );
+    my $parcel             = $self->_get_parcel;
+    my $lib                = $self->_get_lib_dir;
+    my $dest_dir           = $self->_get_hierarchy->get_dest;
+    my @file_components    = split( '::', $self->_get_boot_class );
     my @xs_file_components = @file_components;
     $xs_file_components[-1] .= '.xs';
-    $self->{xs_path} = catfile( $lib, @xs_file_components );
+    $xs_path{$self} = catfile( $lib, @xs_file_components );
 
-    $self->{pm_path} = catfile( $lib, @file_components, 'Autobinding.pm' );
-    $self->{boot_h_file} = $parcel->get_prefix . "boot.h";
-    $self->{boot_c_file} = $parcel->get_prefix . "boot.c";
-    $self->{boot_h_path} = catfile( $dest_dir, $self->{boot_h_file} );
-    $self->{boot_c_path} = catfile( $dest_dir, $self->{boot_c_file} );
+    $pm_path{$self} = catfile( $lib, @file_components, 'Autobinding.pm' );
+    $boot_h_file{$self} = $parcel->get_prefix . "boot.h";
+    $boot_c_file{$self} = $parcel->get_prefix . "boot.c";
+    $boot_h_path{$self} = catfile( $dest_dir, $self->_get_boot_h_file );
+    $boot_c_path{$self} = catfile( $dest_dir, $self->_get_boot_c_file );
 
     # Derive the name of the bootstrap function.
-    $self->{boot_func}
-        = $parcel->get_prefix . $self->{boot_class} . '_bootstrap';
-    $self->{boot_func} =~ s/\W/_/g;
+    $boot_func{$self}
+        = $parcel->get_prefix . $self->_get_boot_class . '_bootstrap';
+    $boot_func{$self} =~ s/\W/_/g;
 
     return $self;
 }
 
+sub DESTROY {
+    my $self = shift;
+    delete $parcel{$self};
+    delete $hierarchy{$self};
+    delete $lib_dir{$self};
+    delete $boot_class{$self};
+    delete $header{$self};
+    delete $footer{$self};
+    delete $xs_path{$self};
+    delete $pm_path{$self};
+    delete $boot_h_file{$self};
+    delete $boot_c_file{$self};
+    delete $boot_h_path{$self};
+    delete $boot_c_path{$self};
+    delete $boot_func{$self};
+}
+
+sub _get_parcel      { $parcel{ +shift } }
+sub _get_hierarchy   { $hierarchy{ +shift } }
+sub _get_lib_dir     { $lib_dir{ +shift } }
+sub _get_boot_class  { $boot_class{ +shift } }
+sub _get_header      { $header{ +shift } }
+sub _get_footer      { $footer{ +shift } }
+sub _get_xs_path     { $xs_path{ +shift } }
+sub _get_pm_path     { $pm_path{ +shift } }
+sub _get_boot_h_file { $boot_h_file{ +shift } }
+sub _get_boot_c_file { $boot_c_file{ +shift } }
+sub _get_boot_h_path { $boot_h_path{ +shift } }
+sub _get_boot_c_path { $boot_c_path{ +shift } }
+sub _get_boot_func   { $boot_func{ +shift } }
+
 sub write_bindings {
     my $self           = shift;
-    my $ordered        = $self->{hierarchy}->ordered_classes;
+    my $ordered        = $self->_get_hierarchy->ordered_classes;
     my $registry       = Clownfish::Binding::Perl::Class->registry;
     my $hand_rolled_xs = "";
     my $generated_xs   = "";
@@ -167,12 +220,13 @@ sub write_bindings {
     my $xs_file_contents = $self->_xs_file_contents( $generated_xs, $xs_init,
         $hand_rolled_xs );
     my $pm_file_contents = $self->_pm_file_contents($params_hash_defs);
-    write_if_changed( $self->{xs_path}, $xs_file_contents );
-    write_if_changed( $self->{pm_path}, $pm_file_contents );
+    write_if_changed( $self->_get_xs_path, $xs_file_contents );
+    write_if_changed( $self->_get_pm_path, $pm_file_contents );
 }
 
 sub _xs_file_contents {
     my ( $self, $generated_xs, $xs_init, $hand_rolled_xs ) = @_;
+    my $boot_h_file = $self->_get_boot_h_file;
     return <<END_STUFF;
 /* DO NOT EDIT!!!! This is an auto-generated file. */
 
@@ -194,7 +248,7 @@ sub _xs_file_contents {
 
 #include "XSBind.h"
 #include "parcel.h"
-#include "$self->{boot_h_file}"
+#include "$boot_h_file"
 
 #include "Lucy/Object/Host.h"
 #include "Lucy/Util/Memory.h"
@@ -254,8 +308,8 @@ END_STUFF
 
 sub prepare_pod {
     my $self    = shift;
-    my $lib_dir = $self->{lib_dir};
-    my $ordered = $self->{hierarchy}->ordered_classes;
+    my $lib_dir = $self->_get_lib_dir;
+    my $ordered = $self->_get_hierarchy->ordered_classes;
     my @files_written;
     my %has_pod;
     my %modified;
@@ -298,26 +352,29 @@ sub write_boot {
 
 sub _write_boot_h {
     my $self      = shift;
-    my $hierarchy = $self->{hierarchy};
-    my $filepath  = catfile( $hierarchy->get_dest, $self->{boot_h_file} );
-    my $guard     = uc("$self->{boot_class}_BOOT");
+    my $hierarchy = $self->_get_hierarchy;
+    my $filepath  = catfile( $hierarchy->get_dest, $self->_get_boot_h_file );
+    my $guard     = uc( $self->_get_boot_class . "_BOOT" );
     $guard =~ s/\W+/_/g;
+    my $header = $self->_get_header;
+    my $footer = $self->_get_footer;
+    my $boot_func = $self->_get_boot_func;
 
     unlink $filepath;
     sysopen( my $fh, $filepath, O_CREAT | O_EXCL | O_WRONLY )
         or confess("Can't open '$filepath': $!");
     print $fh <<END_STUFF;
-$self->{header}
+$header
 
 #ifndef $guard
 #define $guard 1
 
 void
-$self->{boot_func}();
+$boot_func();
 
 #endif /* $guard */
 
-$self->{footer}
+$footer
 END_STUFF
 }
 
@@ -348,7 +405,11 @@ my %ks_compat = (
 
 sub _write_boot_c {
     my $self           = shift;
-    my $hierarchy      = $self->{hierarchy};
+    my $hierarchy      = $self->_get_hierarchy;
+    my $header         = $self->_get_header;
+    my $footer         = $self->_get_footer;
+    my $boot_func      = $self->_get_boot_func;
+    my $boot_h_file    = $self->_get_boot_h_file;
     my $ordered        = $hierarchy->ordered_classes;
     my $num_classes    = scalar @$ordered;
     my $pound_includes = "";
@@ -389,29 +450,29 @@ sub _write_boot_c {
         $isa_pushes .= qq|    isa = get_av("$class_name\::ISA", 1);\n|;
         $isa_pushes .= qq|    av_push(isa, newSVpv("$parent_class", 0));\n|;
     }
-    my $filepath = catfile( $hierarchy->get_dest, $self->{boot_c_file} );
+    my $filepath = catfile( $hierarchy->get_dest, $self->_get_boot_c_file );
     unlink $filepath;
     sysopen( my $fh, $filepath, O_CREAT | O_EXCL | O_WRONLY )
         or confess("Can't open '$filepath': $!");
     print $fh <<END_STUFF;
-$self->{header}
+$header
 
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"
-#include "$self->{boot_h_file}"
+#include "$boot_h_file"
 #include "parcel.h"
 $pound_includes
 
 void
-$self->{boot_func}() {
+$boot_func() {
     AV *isa;
     cfish_ZombieCharBuf *alias = CFISH_ZCB_WRAP_STR("", 0);
 $registrations
 $isa_pushes
 }
 
-$self->{footer}
+$footer
 
 END_STUFF
 }
@@ -419,7 +480,7 @@ END_STUFF
 sub write_xs_typemap {
     my $self = shift;
     Clownfish::Binding::Perl::TypeMap->write_xs_typemap(
-        hierarchy => $self->{hierarchy}, );
+        hierarchy => $self->_get_hierarchy, );
 }
 
 1;

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm?rev=1144776&r1=1144775&r2=1144776&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Class.pm Sun Jul 10 04:15:04 2011
@@ -33,58 +33,89 @@ our %register_PARAMS = (
     client            => undef,
 );
 
+our %parcel;
+our %class_name;
+our %bind_methods;
+our %bind_constructors;
+our %make_pod;
+our %xs_code;
+our %client;
+
 sub register {
-    my $either = shift;
-    verify_args( \%register_PARAMS, @_ ) or confess $@;
-    my $self = bless { %register_PARAMS, @_, }, ref($either) || $either;
+    my ( $either, %args ) = @_;
+    verify_args( \%register_PARAMS, %args ) or confess $@;
 
     # Validate.
     confess("Missing required param 'class_name'")
-        unless $self->{class_name};
-    confess("$self->{class_name} already registered")
-        if exists $registry{ $self->{class_name} };
+        unless $args{class_name};
+    confess("$args{class_name} already registered")
+        if exists $registry{ $args{class_name} };
 
     # Retrieve Clownfish::Class client, if it will be needed.
-    if (   $self->{bind_methods}
-        || $self->{bind_constructors}
-        || $self->{make_pod} )
+    my $client;
+    if (   $args{bind_methods}
+        || $args{bind_constructors}
+        || $args{make_pod} )
     {
-        $self->{client} = Clownfish::Class->fetch_singleton(
-            parcel     => $self->{parcel},
-            class_name => $self->{class_name},
+        $args{client} = Clownfish::Class->fetch_singleton(
+            parcel     => $args{parcel},
+            class_name => $args{class_name},
         );
-        confess("Can't fetch singleton for $self->{class_name}")
-            unless $self->{client};
+        confess("Can't fetch singleton for $args{class_name}")
+            unless $args{client};
     }
 
+    # Create object.
+    my $empty = "";
+    my $self = bless \$empty, ref($either) || $either;
+    $parcel{$self}            = $args{parcel};
+    $class_name{$self}        = $args{class_name};
+    $bind_methods{$self}      = $args{bind_methods};
+    $bind_constructors{$self} = $args{bind_constructors};
+    $make_pod{$self}          = $args{make_pod};
+    $xs_code{$self}           = $args{xs_code};
+    $client{$self}            = $args{client};
+
     # Add to registry.
-    $registry{ $self->{class_name} } = $self;
+    $registry{ $args{class_name} } = $self;
 
     return $self;
 }
 
-sub get_class_name        { shift->{class_name} }
-sub get_bind_methods      { shift->{bind_methods} }
-sub get_bind_constructors { shift->{bind_constructors} }
-sub get_make_pod          { shift->{make_pod} }
-sub get_client            { shift->{client} }
-sub get_xs_code           { shift->{xs_code} }
+sub DESTROY {
+    my $self = shift;
+    delete $parcel{$self};
+    delete $class_name{$self};
+    delete $bind_methods{$self};
+    delete $bind_constructors{$self};
+    delete $make_pod{$self};
+    delete $xs_code{$self};
+    delete $client{$self};
+}
+
+sub get_class_name        { $class_name{ +shift } }
+sub get_bind_methods      { $bind_methods{ +shift } }
+sub get_bind_constructors { $bind_constructors{ +shift } }
+sub get_make_pod          { $make_pod{ +shift } }
+sub get_client            { $client{ +shift } }
+sub get_xs_code           { $xs_code{ +shift } }
 
 sub constructor_bindings {
     my $self  = shift;
     my @bound = map {
         my $xsub = Clownfish::Binding::Perl::Constructor->new(
-            class => $self->{client},
+            class => $self->get_client,
             alias => $_,
         );
-    } @{ $self->{bind_constructors} };
+    } @{ $self->get_bind_constructors };
     return @bound;
 }
 
 sub method_bindings {
-    my $self      = shift;
-    my $client    = $self->{client};
-    my $meth_list = $self->{bind_methods};
+    my $self       = shift;
+    my $client     = $self->get_client;
+    my $meth_list  = $self->get_bind_methods;
+    my $class_name = $self->get_class_name;
     my @bound;
 
     # Assemble a list of methods to be bound for this class.
@@ -107,12 +138,12 @@ sub method_bindings {
         # Safety checks against excess binding code or private methods.
         if ( !$method->novel ) {
             confess(  "Binding spec'd for method '$meth_name' in class "
-                    . "$self->{class_name}, but it's overridden and "
+                    . "$class_name, but it's overridden and "
                     . "should be bound via the parent class" );
         }
         elsif ( $method->private ) {
             confess(  "Binding spec'd for method '$meth_name' in class "
-                    . "$self->{class_name}, but it's private" );
+                    . "$class_name, but it's private" );
         }
 
         # Create an XSub binding for each override.  Each of these directly
@@ -134,7 +165,7 @@ sub method_bindings {
 
     # Verify that we processed all methods.
     my @leftover_meths = keys %meth_to_bind;
-    confess("Leftover for $self->{class_name}: '@leftover_meths'")
+    confess("Leftover for $class_name: '@leftover_meths'")
         if @leftover_meths;
 
     return @bound;
@@ -207,10 +238,10 @@ sub _gen_subroutine_pod {
 }
 
 sub create_pod {
-    my $self     = shift;
-    my $pod_args = $self->{make_pod} or return;
-    my $class    = $self->{client} or die "No client for $self->{class_name}";
-    my $class_name = $class->get_class_name;
+    my $self       = shift;
+    my $pod_args   = $self->get_make_pod or return;
+    my $class_name = $self->get_class_name;
+    my $class      = $self->get_client or die "No client for $class_name";
     my $docucom    = $class->get_docucomment;
     confess("No DocuComment for '$class_name'") unless $docucom;
     my $brief = $docucom->get_brief;

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=1144776&r1=1144775&r2=1144776&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Constructor.pm Sun Jul 10 04:15:04 2011
@@ -21,6 +21,8 @@ use base qw( Clownfish::Binding::Perl::S
 use Carp;
 use Clownfish::ParamList;
 
+our %init_func;
+
 sub new {
     my ( $either, %args ) = @_;
     my $class          = delete $args{class};
@@ -46,18 +48,26 @@ sub new {
         alias              => $alias,
         %args
     );
-    $self->{init_func} = $func;
+    $init_func{$self} = $func;
     return $self;
 }
 
+sub DESTROY {
+    my $self = shift;
+    delete $init_func{$self};
+    $self->SUPER::DESTROY;
+}
+
+sub _get_init_func { $init_func{ +shift } }
+
 sub xsub_def {
     my $self         = shift;
     my $c_name       = $self->c_name;
-    my $param_list   = $self->{param_list};
+    my $param_list   = $self->get_param_list;
     my $name_list    = $param_list->name_list;
     my $arg_inits    = $param_list->get_initial_values;
     my $arg_vars     = $param_list->get_variables;
-    my $func_sym     = $self->{init_func}->full_func_sym;
+    my $func_sym     = $self->_get_init_func->full_func_sym;
     my $allot_params = $self->build_allot_params;
 
     # Compensate for swallowed refcounts.

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=1144776&r1=1144775&r2=1144776&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Method.pm Sun Jul 10 04:15:04 2011
@@ -27,6 +27,8 @@ our %new_PARAMS = (
     alias  => undef,
 );
 
+our %method;
+
 sub new {
     my ( $either, %args ) = @_;
     confess $@ unless verify_args( \%new_PARAMS, %args );
@@ -44,14 +46,22 @@ sub new {
             : 0;
     }
     my $self = $either->SUPER::new(%args);
-    $self->{method} = $method;
+    $method{$self} = $method;
 
     return $self;
 }
 
+sub DESTROY {
+    my $self = shift;
+    delete $method{$self};
+    $self->SUPER::DESTROY;
+}
+
+sub _get_method { $method{ +shift } }
+
 sub xsub_def {
     my $self = shift;
-    if ( $self->{use_labeled_params} ) {
+    if ( $self->use_labeled_params ) {
         return $self->_xsub_def_labeled_params;
     }
     else {
@@ -62,7 +72,7 @@ sub xsub_def {
 # Build XSUB function body.
 sub _xsub_body {
     my $self          = shift;
-    my $method        = $self->{method};
+    my $method        = $self->_get_method;
     my $full_func_sym = $method->full_func_sym;
     my $param_list    = $method->get_param_list;
     my $arg_vars      = $param_list->get_variables;
@@ -103,7 +113,7 @@ sub _xsub_body {
 
 sub _xsub_def_positional_args {
     my $self       = shift;
-    my $method     = $self->{method};
+    my $method     = $self->_get_method;
     my $param_list = $method->get_param_list;
     my $arg_vars   = $param_list->get_variables;
     my $arg_inits  = $param_list->get_initial_values;
@@ -185,12 +195,12 @@ END_STUFF
 sub _xsub_def_labeled_params {
     my $self        = shift;
     my $c_name      = $self->c_name;
-    my $param_list  = $self->{param_list};
+    my $param_list  = $self->get_param_list;
     my $arg_inits   = $param_list->get_initial_values;
     my $arg_vars    = $param_list->get_variables;
     my $self_var    = $arg_vars->[0];
     my $self_assign = _self_assign_statement( $self_var->get_type,
-        $self->{method}->micro_sym );
+        $self->_get_method->micro_sym );
     my $allot_params = $self->build_allot_params;
     my $body         = $self->_xsub_body;
 

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=1144776&r1=1144775&r2=1144776&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Perl/Subroutine.pm Sun Jul 10 04:15:04 2011
@@ -34,24 +34,45 @@ our %new_PARAMS = (
     use_labeled_params => undef,
 );
 
+our %param_list;
+our %class_name;
+our %alias;
+our %retval_type;
+our %use_labeled_params;
+our %perl_name;
+
 sub new {
-    my $either = shift;
-    verify_args( \%new_PARAMS, @_ ) or confess $@;
-    my $self = bless { %new_PARAMS, @_, }, ref($either) || $either;
+    my ( $either, %args ) = @_;
+    verify_args( \%new_PARAMS, %args ) or confess $@;
     for (qw( param_list class_name alias retval_type )) {
-        confess("$_ is required") unless defined $self->{$_};
+        confess("$_ is required") unless defined $args{$_};
     }
+    my $empty = "";
+    my $self = bless \$empty, ref($either) || $either;
+    $param_list{$self}         = $args{param_list};
+    $alias{$self}              = $args{alias};
+    $class_name{$self}         = $args{class_name};
+    $retval_type{$self}        = $args{retval_type};
+    $use_labeled_params{$self} = $args{use_labeled_params};
+    $perl_name{$self}          = "$args{class_name}::$args{alias}";
     return $self;
 }
 
-sub get_class_name     { shift->{class_name} }
-sub use_labeled_params { shift->{use_labeled_params} }
-
-sub perl_name {
+sub DESTROY {
     my $self = shift;
-    return "$self->{class_name}::$self->{alias}";
+    delete $param_list{$self};
+    delete $class_name{$self};
+    delete $alias{$self};
+    delete $retval_type{$self};
+    delete $use_labeled_params{$self};
+    delete $perl_name{$self};
 }
 
+sub get_class_name     { $class_name{ +shift } }
+sub use_labeled_params { $use_labeled_params{ +shift } }
+sub perl_name          { $perl_name{ +shift } }
+sub get_param_list     { $param_list{ +shift } }
+
 sub c_name {
     my $self   = shift;
     my $c_name = "XS_" . $self->perl_name;
@@ -61,7 +82,7 @@ sub c_name {
 
 sub c_name_list {
     my $self = shift;
-    return $self->{param_list}->name_list;
+    return $self->get_param_list->name_list;
 }
 
 my %params_hash_vals_map = (
@@ -72,11 +93,11 @@ my %params_hash_vals_map = (
 
 sub params_hash_def {
     my $self = shift;
-    return unless $self->{use_labeled_params};
+    return unless $self->use_labeled_params;
 
     my $params_hash_name = $self->perl_name . "_PARAMS";
-    my $arg_vars         = $self->{param_list}->get_variables;
-    my $vals             = $self->{param_list}->get_initial_values;
+    my $arg_vars         = $self->get_param_list->get_variables;
+    my $vals             = $self->get_param_list->get_initial_values;
     my @pairs;
     for ( my $i = 1; $i < @$arg_vars; $i++ ) {
         my $var = $arg_vars->[$i];
@@ -149,7 +170,7 @@ sub _allot_params_arg {
 
 sub build_allot_params {
     my $self         = shift;
-    my $param_list   = $self->{param_list};
+    my $param_list   = $self->get_param_list;
     my $arg_inits    = $param_list->get_initial_values;
     my $arg_vars     = $param_list->get_variables;
     my $params_hash  = $self->perl_name . "_PARAMS";