Fix thrift_binary_protocol to be hipe-compatible
authorDavid Reiss <dreiss@apache.org>
Wed, 11 Jun 2008 01:12:45 +0000 (01:12 +0000)
committerDavid Reiss <dreiss@apache.org>
Wed, 11 Jun 2008 01:12:45 +0000 (01:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666468 13f79535-47bb-0310-9956-ffa450edef68

lib/alterl/src/thrift_binary_protocol.erl

index 4bb5880..fce6c42 100644 (file)
@@ -152,7 +152,7 @@ write(This, Data) ->
 %%
 
 read(This, message_begin) ->
-    case read(This, i32) of
+    case read(This, ui32) of
         {ok, Sz} when Sz band ?VERSION_MASK =:= ?VERSION_1 ->
             %% we're at version 1
             {ok, Name}  = read(This, string),
@@ -253,6 +253,15 @@ read(This, i32) ->
         Else -> Else
     end;
 
+%% unsigned ints aren't used by thrift itself, but it's used for the parsing
+%% of the packet version header. Without this special function BEAM works fine
+%% but hipe thinks it received a bad version header.
+read(This, ui32) ->
+    case read(This, 4) of
+        {ok, <<Val:32/integer-unsigned-big, _/binary>>} -> {ok, Val};
+        Else -> Else
+    end;
+
 read(This, i64) ->
     case read(This, 8) of
         {ok, <<Val:64/integer-signed-big, _/binary>>} -> {ok, Val};