lib/fiddle/pack.rb in fiddle-1.1.1 vs lib/fiddle/pack.rb in fiddle-1.1.2
- old
+ new
@@ -13,10 +13,11 @@
TYPE_DOUBLE => ALIGN_DOUBLE,
TYPE_UCHAR => ALIGN_CHAR,
TYPE_USHORT => ALIGN_SHORT,
TYPE_UINT => ALIGN_INT,
TYPE_ULONG => ALIGN_LONG,
+ TYPE_BOOL => ALIGN_BOOL,
}
PACK_MAP = {
TYPE_VOIDP => "L!",
TYPE_CHAR => "c",
@@ -28,10 +29,20 @@
TYPE_UCHAR => "C",
TYPE_USHORT => "S!",
TYPE_UINT => "I!",
TYPE_ULONG => "L!",
}
+ case SIZEOF_BOOL
+ when SIZEOF_CHAR
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_UCHAR]
+ when SIZEOF_SHORT
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_USHORT]
+ when SIZEOF_INT
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_UINT]
+ when SIZEOF_LONG
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_ULONG]
+ end
SIZE_MAP = {
TYPE_VOIDP => SIZEOF_VOIDP,
TYPE_CHAR => SIZEOF_CHAR,
TYPE_SHORT => SIZEOF_SHORT,
@@ -41,9 +52,10 @@
TYPE_DOUBLE => SIZEOF_DOUBLE,
TYPE_UCHAR => SIZEOF_CHAR,
TYPE_USHORT => SIZEOF_SHORT,
TYPE_UINT => SIZEOF_INT,
TYPE_ULONG => SIZEOF_LONG,
+ TYPE_BOOL => SIZEOF_BOOL,
}
if defined?(TYPE_LONG_LONG)
ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_MAP[TYPE_ULONG_LONG] = ALIGN_LONG_LONG
PACK_MAP[TYPE_LONG_LONG] = "q"
PACK_MAP[TYPE_ULONG_LONG] = "Q"