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/02/07 03:38:30 UTC

[lucy-commits] svn commit: r1067848 - in /incubator/lucy/trunk: clownfish/lib/Clownfish/Binding/Core/Method.pm clownfish/lib/Clownfish/Type/Integer.pm core/Lucy/Object/Host.cfh

Author: marvin
Date: Mon Feb  7 02:38:30 2011
New Revision: 1067848

URL: http://svn.apache.org/viewvc?rev=1067848&view=rev
Log:
Make Clownfish autogenerated C code platform independent, by using C sizeof()
directives rather than sizeof values from Perl's Config module.

Modified:
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm
    incubator/lucy/trunk/clownfish/lib/Clownfish/Type/Integer.pm
    incubator/lucy/trunk/core/Lucy/Object/Host.cfh

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=1067848&r1=1067847&r2=1067848&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm Mon Feb  7 02:38:30 2011
@@ -163,10 +163,19 @@ sub _callback_params {
             $param = qq|CFISH_ARG_OBJ("$name", $name)|;
         }
         elsif ( $type->is_integer ) {
-            $param
-                = $type->sizeof > 4
-                ? qq|CFISH_ARG_I64("$name", $name)|
-                : qq|CFISH_ARG_I32("$name", $name)|;
+            my $sizeof = $type->sizeof;
+            if ( defined($sizeof) ) {
+                if ($sizeof <= 4) {
+                    $param = qq|CFISH_ARG_I32("$name", $name)|;
+                }
+                else {
+                    $param = qq|CFISH_ARG_I64("$name", $name)|;
+                }
+            }
+            else {
+                my $c_type = $type->to_c;
+                $param = qq|CFISH_ARG_I($c_type, "$name", $name)|;
+            }
         }
         elsif ( $type->is_floating ) {
             $param = qq|CFISH_ARG_F64("$name", $name)|;

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Type/Integer.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Type/Integer.pm?rev=1067848&r1=1067847&r2=1067848&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Type/Integer.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Type/Integer.pm Mon Feb  7 02:38:30 2011
@@ -20,7 +20,6 @@ package Clownfish::Type::Integer;
 use base qw( Clownfish::Type );
 use Clownfish::Util qw( verify_args );
 use Carp;
-use Config;
 
 # Inside-out member vars.
 our %sizeof;
@@ -31,7 +30,7 @@ our %new_PARAMS = (
 );
 
 our %specifiers = (
-    bool_t   => $Config{intsize},
+    bool_t   => undef,
     int8_t   => 1,
     int16_t  => 2,
     int32_t  => 4,
@@ -41,17 +40,17 @@ our %specifiers = (
     uint32_t => 4,
     uint64_t => 8,
     char     => 1,
-    int      => $Config{intsize},
-    short    => $Config{shortsize},
-    long     => $Config{longsize},
-    size_t   => $Config{sizesize},
+    int      => undef,
+    short    => undef,
+    long     => undef,
+    size_t   => undef,
 );
 
 sub new {
     my ( $either, %args ) = @_;
     verify_args( \%new_PARAMS, %args ) or confess $@;
-    my $sizeof = $specifiers{ $args{specifier} }
-        or confess("Unknown specifier: '$args{specifier}'");
+    confess("Unknown specifier: '$args{specifier}'")
+        unless exists $specifiers{ $args{specifier} };
 
     # Cache the C representation of this type.
     my $c_string = $args{const} ? 'const ' : '';
@@ -66,7 +65,7 @@ sub new {
         integer   => 1,
         primitive => 1,
     );
-    $sizeof{$self} = $sizeof;
+    $sizeof{$self} = $specifiers{ $args{specifier} };
     return $self;
 }
 

Modified: incubator/lucy/trunk/core/Lucy/Object/Host.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Object/Host.cfh?rev=1067848&r1=1067847&r2=1067848&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Object/Host.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Object/Host.cfh Mon Feb  7 02:38:30 2011
@@ -29,6 +29,9 @@ __C__
     CFISH_HOST_ARGTYPE_I32, (_label), ((int32_t)_value)
 #define CFISH_ARG_I64(_label, _value) \
     CFISH_HOST_ARGTYPE_I64, (_label), ((int64_t)_value)
+#define CFISH_ARG_I(_type, _label, _value) \
+    (sizeof(_type) <= 4 ? CFISH_HOST_ARGTYPE_I32 : CFISH_HOST_ARGTYPE_I64), \
+    (_label), (sizeof(_type) <= 4 ? (int32_t)_value : (int64_t)_value)
 #define CFISH_ARG_F32(_label, _value) \
     CFISH_HOST_ARGTYPE_F32, (_label), ((double)_value)
 #define CFISH_ARG_F64(_label, _value) \