Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:ruby-amqp/amq-protocol
- Loading branch information
Showing
12 changed files
with
107 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# encoding: utf-8 | ||
|
||
source :rubygems | ||
source "https://rubygems.org" | ||
|
||
group :development do | ||
# excludes Windows, Rubinius and JRuby | ||
gem "perftools.rb", :platform => :mri_18 | ||
end | ||
|
||
group :test do | ||
gem "rspec", ">= 2.6.0" | ||
gem "rspec", ">= 2.13.0" | ||
gem "effin_utf8" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module AMQ | ||
module Endianness | ||
BIG_ENDIAN = ([1].pack("s") == "\x00\x01") | ||
|
||
def big_endian? | ||
BIG_ENDIAN | ||
end | ||
|
||
def little_endian? | ||
!BIG_ENDIAN | ||
end | ||
|
||
extend self | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,53 @@ | ||
# encoding: binary | ||
|
||
require 'amq/endianness' | ||
|
||
# Ruby doesn't support pack to/unpack from | ||
# 64bit string in network byte order. | ||
module AMQ | ||
module Hacks | ||
BIG_ENDIAN = ([1].pack("s") == "\x00\x01") | ||
Q = "Q".freeze | ||
UINT64 = "Q".freeze | ||
INT16 = "c".freeze | ||
|
||
if Endianness.big_endian? | ||
def self.pack_uint64_big_endian(long_long) | ||
[long_long].pack(UINT64) | ||
end | ||
|
||
if BIG_ENDIAN | ||
def self.pack_64_big_endian(long_long) | ||
[long_long].pack(Q) | ||
def self.unpack_uint64_big_endian(data) | ||
data.unpack(UINT64) | ||
end | ||
|
||
def self.unpack_64_big_endian(data) | ||
data.unpack(Q) | ||
def self.pack_int16_big_endian(short) | ||
[long_long].pack(INT16) | ||
end | ||
|
||
def self.unpack_int16_big_endian(data) | ||
data.unpack(INT16) | ||
end | ||
else | ||
def self.pack_64_big_endian(long_long) | ||
result = [long_long].pack(Q) | ||
def self.pack_uint64_big_endian(long_long) | ||
result = [long_long].pack(UINT64) | ||
result.bytes.to_a.reverse.map(&:chr).join | ||
end | ||
|
||
def self.unpack_uint64_big_endian(data) | ||
data = data.bytes.to_a.reverse.map(&:chr).join | ||
data.unpack(UINT64) | ||
end | ||
|
||
def self.pack_int16_big_endian(short) | ||
result = [long_long].pack(INT16) | ||
result.bytes.to_a.reverse.map(&:chr).join | ||
end | ||
|
||
def self.unpack_64_big_endian(data) | ||
def self.unpack_int16_big_endian(data) | ||
data = data.bytes.to_a.reverse.map(&:chr).join | ||
data.unpack(Q) | ||
data.unpack(INT16) | ||
end | ||
end | ||
end | ||
end | ||
|
||
# AMQ::Hacks.pack_64_big_endian(17) | ||
# AMQ::Hacks.unpack_64_big_endian("\x00\x00\x00\x00\x00\x00\x00\x11") | ||
# AMQ::Hacks.pack_uint64_big_endian(17) | ||
# AMQ::Hacks.unpack_uint64_big_endian("\x00\x00\x00\x00\x00\x00\x00\x11") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module AMQ | ||
module Protocol | ||
VERSION = "1.3.0.pre1" | ||
VERSION = "1.4.0.pre1" | ||
end # Protocol | ||
end # AMQ |
Oops, something went wrong.