typedef int intObj; /* T_PTROBJ */
typedef int intRefIv; /* T_REF_IV_PTR */
typedef int intArray; /* T_ARRAY */
+typedef int intTINT; /* T_INT */
+typedef int intTLONG; /* T_LONG */
typedef short shortOPQ; /* T_OPAQUE */
typedef int intOpq; /* T_OPAQUEPTR */
+typedef unsigned intUnsigned; /* T_U_INT */
/* A structure to test T_OPAQUEPTR */
struct t_opaqueptr {
Its behaviour is identical to using an C<int> type in XS with T_IV.
+=cut
+
+intTINT
+T_INT( i )
+ intTINT i
+ CODE:
+ RETVAL = i;
+ OUTPUT:
+ RETVAL
+
=item T_ENUM
An enum value. Used to transfer an enum component
but explicitly casts the variable to type C<unsigned int>.
The default type for C<unsigned int> is T_UV.
+=cut
+
+intUnsigned
+T_U_INT( uint )
+ intUnsigned uint
+ CODE:
+ RETVAL = uint;
+ OUTPUT:
+ RETVAL
+
=item T_SHORT
Short integers. This is equivalent to T_IV but explicitly casts
the return to type C<short>. The default typemap for C<short>
is T_IV.
+=cut
+
+short
+T_SHORT( s )
+ short s
+ CODE:
+ RETVAL = s;
+ OUTPUT:
+ RETVAL
+
=item T_U_SHORT
Unsigned short integers. This is equivalent to T_UV but explicitly
the return to type C<long>. The default typemap for C<long>
is T_IV.
+=cut
+
+intTLONG
+T_LONG( in )
+ intTLONG in
+ CODE:
+ RETVAL = in;
+ OUTPUT:
+ RETVAL
+
=item T_U_LONG
Unsigned long integers. This is equivalent to T_UV but explicitly
}
}
-use Test::More tests => 84;
+use Test::More tests => 102;
use strict;
use warnings;
is( T_UV(5), 5 ); # pass
isnt( T_UV(-4), -4); # fail
-# T_IV - signed integer
-note("T_IV");
-is( T_IV(5), 5);
-is( T_IV(-4), -4);
-is( T_IV(4.1), int(4.1));
-is( T_IV("52"), "52");
-isnt( T_IV(4.5), 4.5); # failure
+# T_U_INT - unsigned integer with (unsigned int) cast
+note("T_U_INT");
+is( T_U_INT(5), 5 ); # pass
+isnt( T_U_INT(-4), -4); # fail
+# T_IV - signed integer
+# T_INT - signed integer with cast
+# T_LONG - signed integer with cast to IV
+# T_SHORT - signed short
+for my $t (['T_IV', \&T_IV],
+ ['T_INT', \&T_INT],
+ ['T_LONG', \&T_LONG],
+ ['T_SHORT', \&T_SHORT])
+{
+ note($t->[0]);
+ is( $t->[1]->(5), 5);
+ is( $t->[1]->(-4), -4);
+ is( $t->[1]->(4.1), int(4.1));
+ is( $t->[1]->("52"), "52");
+ isnt( $t->[1]->(4.5), 4.5); # failure
+}
-# Skip T_INT
+if ($Config{shortsize} == 2) {
+ isnt( T_SHORT(32801), 32801 );
+}
+else {
+ pass(); # e.g. Crays have shortsize 4 (T3X) or 8 (CXX and SVX)
+}
# T_ENUM - enum list
ok( T_ENUM(), 'T_ENUM' ); # just hope for a true value
ok( ! T_BOOL('') );
ok( ! T_BOOL(undef) );
-# Skip T_U_INT
-
-# Skip T_SHORT
-
# T_U_SHORT aka U16
note("T_U_SHORT");
is( T_U_SHORT(32000), 32000);