lib/fiddle/value.rb in fiddle-1.0.0 vs lib/fiddle/value.rb in fiddle-1.0.1

- old
+ new

@@ -11,14 +11,17 @@ [val].pack("s!").unpack("S!")[0] when TYPE_INT [val].pack("i!").unpack("I!")[0] when TYPE_LONG [val].pack("l!").unpack("L!")[0] - when TYPE_LONG_LONG - [val].pack("q").unpack("Q")[0] else - val + if defined?(TYPE_LONG_LONG) and + ty.abs == TYPE_LONG_LONG + [val].pack("q").unpack("Q")[0] + else + val + end end end def signed_value(val, ty) case ty.abs @@ -28,14 +31,17 @@ [val].pack("S!").unpack("s!")[0] when TYPE_INT [val].pack("I!").unpack("i!")[0] when TYPE_LONG [val].pack("L!").unpack("l!")[0] - when TYPE_LONG_LONG - [val].pack("Q").unpack("q")[0] else - val + if defined?(TYPE_LONG_LONG) and + ty.abs == TYPE_LONG_LONG + [val].pack("Q").unpack("q")[0] + else + val + end end end def wrap_args(args, tys, funcs, &block) result = [] @@ -73,13 +79,16 @@ return arg.unpack('C*') else case SIZEOF_VOIDP when SIZEOF_LONG return [arg].pack("p").unpack("l!")[0] - when SIZEOF_LONG_LONG - return [arg].pack("p").unpack("q")[0] else - raise(RuntimeError, "sizeof(void*)?") + if defined?(SIZEOF_LONG_LONG) and + SIZEOF_VOIDP == SIZEOF_LONG_LONG + return [arg].pack("p").unpack("q")[0] + else + raise(RuntimeError, "sizeof(void*)?") + end end end when Float, Integer return arg when Array