[fidl][dart] Prepare for 64bits ordinals

FIDL-524 #comment

Change-Id: I7a4f7b41506bff79e093c513a3d2b18ba5df3e2f
diff --git a/bin/fidlgen_dart/backend/ir/ir.go b/bin/fidlgen_dart/backend/ir/ir.go
index 61fe0cf..d99b5e4 100644
--- a/bin/fidlgen_dart/backend/ir/ir.go
+++ b/bin/fidlgen_dart/backend/ir/ir.go
@@ -177,8 +177,10 @@
 
 // Method represents a method declaration within an interface declaration.
 type Method struct {
-	Ordinal            types.Ordinal
+	Ordinal            string
 	OrdinalName        string
+	GenOrdinal         string
+	GenOrdinalName     string
 	Name               string
 	HasRequest         bool
 	Request            []Parameter
@@ -596,7 +598,7 @@
 		if err != nil {
 			panic(fmt.Sprintf("JSON IR contains invalid numeric literal: %s", val.Value))
 		}
-		return fmt.Sprintf("0x%s", strconv.FormatUint(num, 16))
+		return fmt.Sprintf("%#x", num)
 	case types.TrueLiteral:
 		return "true"
 	case types.FalseLiteral:
@@ -964,8 +966,10 @@
 	}
 	_, transitional := val.LookupAttribute("Transitional")
 	return Method{
-		Ordinal:            val.Ordinal,
+		Ordinal:            fmt.Sprintf("%#x", uint64(val.Ordinal)<<32),
 		OrdinalName:        fmt.Sprintf("_k%s_%s_Ordinal", protocol.Name, val.Name),
+		GenOrdinal:         fmt.Sprintf("%#x", uint64(val.GenOrdinal)<<32),
+		GenOrdinalName:     fmt.Sprintf("_k%s_%s_GenOrdinal", protocol.Name, val.Name),
 		Name:               name,
 		HasRequest:         val.HasRequest,
 		Request:            request,
diff --git a/bin/fidlgen_dart/backend/templates/interface.tmpl.go b/bin/fidlgen_dart/backend/templates/interface.tmpl.go
index 776763d..1289e3d 100644
--- a/bin/fidlgen_dart/backend/templates/interface.tmpl.go
+++ b/bin/fidlgen_dart/backend/templates/interface.tmpl.go
@@ -38,6 +38,9 @@
 {{ range .Methods }}
 // {{ .Name }}: {{ if .HasRequest }}({{ template "Params" .Request }}){{ end }}{{ if .HasResponse }} -> ({{ template "Params" .Response.WireParameters }}){{ end }}
 const int {{ .OrdinalName }} = {{ .Ordinal }};
+{{- if ne .Ordinal .GenOrdinal }}
+const int {{ .GenOrdinalName }} = {{ .GenOrdinal }};
+{{ end }}
 const $fidl.MethodType {{ .TypeSymbol }} = {{ .TypeExpr }};
 {{- end }}
 
@@ -62,6 +65,9 @@
 {{- range .Methods }}
 {{- if not .HasRequest }}
   {{- if .HasResponse }}
+      {{- if ne .Ordinal .GenOrdinal }}
+      case {{ .GenOrdinalName }}:
+      {{ end }}
       case {{ .OrdinalName }}:
         final String _name = {{ .TypeSymbol }}.name;
         try {
@@ -113,6 +119,9 @@
 {{- range .Methods }}
   {{- if .HasRequest }}
     {{- if .HasResponse }}
+      {{- if ne .Ordinal .GenOrdinal }}
+      case {{ .GenOrdinalName }}:
+      {{ end }}
       case {{ .OrdinalName }}:
         final String _name = {{ .TypeSymbol }}.name;
         try {
@@ -256,6 +265,9 @@
     switch ($message.ordinal) {
 {{- range .Methods }}
   {{- if .HasRequest }}
+      {{- if ne .Ordinal .GenOrdinal }}
+      case {{ .GenOrdinalName }}:
+      {{ end }}
       case {{ .OrdinalName }}:
         final String _name = {{ .TypeSymbol }}.name;
         try {
@@ -386,6 +398,9 @@
 // {{ .Name }}: {{ if .HasRequest }}({{ template "AsyncParams" .Request }}){{ end -}}
                 {{- if .HasResponse }} -> ({{ template "AsyncParams" .Response.MethodParameters }}){{ end }}
 const int {{ .OrdinalName }} = {{ .Ordinal }};
+{{- if ne .Ordinal .GenOrdinal }}
+const int {{ .GenOrdinalName }} = {{ .GenOrdinal }};
+{{ end }}
 const $fidl.MethodType {{ .TypeSymbol }} = {{ .TypeExpr }};
 {{- end }}
 
@@ -484,6 +499,9 @@
 {{- range .Methods }}
 {{- if not .HasRequest }}
   {{- if .HasResponse }}
+      {{- if ne .Ordinal .GenOrdinal }}
+      case {{ .GenOrdinalName }}:
+      {{ end }}
       case {{ .OrdinalName }}:
         final String _name = {{ .TypeSymbol }}.name;
         try {
@@ -528,6 +546,9 @@
 {{- range .Methods }}
   {{- if .HasRequest }}
     {{- if .HasResponse }}
+      {{- if ne .Ordinal .GenOrdinal }}
+      case {{ .GenOrdinalName }}:
+      {{ end }}
       case {{ .OrdinalName }}:
         final String _name = {{ .TypeSymbol }}.name;
         try {
@@ -657,6 +678,9 @@
     switch ($message.ordinal) {
     {{- range .Methods }}
       {{- if .HasRequest }}
+          {{- if ne .Ordinal .GenOrdinal }}
+          case {{ .GenOrdinalName }}:
+          {{ end }}
           case {{ .OrdinalName }}:
             final String _name = {{ .TypeSymbol }}.name;
             try {
diff --git a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden
index 0099f86..1cd242a 100644
--- a/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/doc_comments.test.fidl.json_async.dart.golden
@@ -194,14 +194,14 @@
 typedef _VoidCallback = void Function();
 
 // method: ()
-const int _kInterface_Method_Ordinal = 1061382220;
+const int _kInterface_Method_Ordinal = 0x3f43684c00000000;
 const $fidl.MethodType _kInterface_Method_Type = $fidl.MethodType(
   request: null,
   response: null,
   name: r"Interface.Method",
 );
 // onEvent:  -> ()
-const int _kInterface_OnEvent_Ordinal = 325918733;
+const int _kInterface_OnEvent_Ordinal = 0x136d200d00000000;
 const $fidl.MethodType _kInterface_OnEvent_Type = $fidl.MethodType(
   request: null,
   response: null,
diff --git a/bin/fidlgen_dart/goldens/ordinal_switch.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/ordinal_switch.test.fidl.json_async.dart.golden
index 4de8ae5..7fb7285 100644
--- a/bin/fidlgen_dart/goldens/ordinal_switch.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/ordinal_switch.test.fidl.json_async.dart.golden
@@ -43,14 +43,14 @@
 typedef _VoidCallback = void Function();
 
 // ordinalFive: ()
-const int _kSwitchingOrdinals_OrdinalFive_Ordinal = 2005164903;
+const int _kSwitchingOrdinals_OrdinalFive_Ordinal = 0x7784636700000000;
 const $fidl.MethodType _kSwitchingOrdinals_OrdinalFive_Type = $fidl.MethodType(
   request: null,
   response: null,
   name: r"SwitchingOrdinals.OrdinalFive",
 );
 // onlyGeneratedOrdinal: ()
-const int _kSwitchingOrdinals_OnlyGeneratedOrdinal_Ordinal = 667506719;
+const int _kSwitchingOrdinals_OnlyGeneratedOrdinal_Ordinal = 0x27c9581f00000000;
 const $fidl.MethodType _kSwitchingOrdinals_OnlyGeneratedOrdinal_Type =
     $fidl.MethodType(
   request: null,
@@ -58,7 +58,7 @@
   name: r"SwitchingOrdinals.OnlyGeneratedOrdinal",
 );
 // eventOrdinalFifteen:  -> ()
-const int _kSwitchingOrdinals_EventOrdinalFifteen_Ordinal = 1467258273;
+const int _kSwitchingOrdinals_EventOrdinalFifteen_Ordinal = 0x577495a100000000;
 const $fidl.MethodType _kSwitchingOrdinals_EventOrdinalFifteen_Type =
     $fidl.MethodType(
   request: null,
@@ -66,7 +66,8 @@
   name: r"SwitchingOrdinals.EventOrdinalFifteen",
 );
 // eventOnlyGeneratedOrdinal:  -> ()
-const int _kSwitchingOrdinals_EventOnlyGeneratedOrdinal_Ordinal = 2146190926;
+const int _kSwitchingOrdinals_EventOnlyGeneratedOrdinal_Ordinal =
+    0x7fec464e00000000;
 const $fidl.MethodType _kSwitchingOrdinals_EventOnlyGeneratedOrdinal_Type =
     $fidl.MethodType(
   request: null,
diff --git a/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden
index 05b7377..97a2ffd 100644
--- a/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/protocol_request.test.fidl.json_async.dart.golden
@@ -119,7 +119,7 @@
 }
 
 // getChild: () -> ($fidl.InterfaceHandle<Child> c)
-const int _kParent_GetChild_Ordinal = 915586153;
+const int _kParent_GetChild_Ordinal = 0x3692bc6900000000;
 const $fidl.MethodType _kParent_GetChild_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -129,7 +129,7 @@
   name: r"Parent.GetChild",
 );
 // getChildRequest: () -> ($fidl.InterfaceRequest<Child> r)
-const int _kParent_GetChildRequest_Ordinal = 1068158078;
+const int _kParent_GetChildRequest_Ordinal = 0x3faacc7e00000000;
 const $fidl.MethodType _kParent_GetChildRequest_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -139,7 +139,7 @@
   name: r"Parent.GetChildRequest",
 );
 // takeChild: ($fidl.InterfaceHandle<Child> c)
-const int _kParent_TakeChild_Ordinal = 1275478777;
+const int _kParent_TakeChild_Ordinal = 0x4c0642f900000000;
 const $fidl.MethodType _kParent_TakeChild_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<$fidl.InterfaceHandle<Child>>(
@@ -149,7 +149,7 @@
   name: r"Parent.TakeChild",
 );
 // takeChildRequest: ($fidl.InterfaceRequest<Child> r)
-const int _kParent_TakeChildRequest_Ordinal = 1589872250;
+const int _kParent_TakeChildRequest_Ordinal = 0x5ec3867a00000000;
 const $fidl.MethodType _kParent_TakeChildRequest_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<$fidl.InterfaceRequest<Child>>(
diff --git a/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden b/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden
index 664f751..1ef608f 100644
--- a/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden
+++ b/bin/fidlgen_dart/goldens/protocols.test.fidl.json_async.dart.golden
@@ -343,7 +343,7 @@
 
 // noRequestNoResponse: ()
 const int _kWithAndWithoutRequestResponse_NoRequestNoResponse_Ordinal =
-    503576693;
+    0x1e03f87500000000;
 const $fidl.MethodType
     _kWithAndWithoutRequestResponse_NoRequestNoResponse_Type = $fidl.MethodType(
   request: null,
@@ -352,7 +352,7 @@
 );
 // noRequestEmptyResponse: () -> ()
 const int _kWithAndWithoutRequestResponse_NoRequestEmptyResponse_Ordinal =
-    1308023765;
+    0x4df6dbd500000000;
 const $fidl.MethodType
     _kWithAndWithoutRequestResponse_NoRequestEmptyResponse_Type =
     $fidl.MethodType(
@@ -362,7 +362,7 @@
 );
 // noRequestWithResponse: () -> (String ret)
 const int _kWithAndWithoutRequestResponse_NoRequestWithResponse_Ordinal =
-    107534328;
+    0x668d7f800000000;
 const $fidl.MethodType
     _kWithAndWithoutRequestResponse_NoRequestWithResponse_Type =
     $fidl.MethodType(
@@ -376,7 +376,7 @@
 );
 // withRequestNoResponse: (String arg)
 const int _kWithAndWithoutRequestResponse_WithRequestNoResponse_Ordinal =
-    432149361;
+    0x19c2137100000000;
 const $fidl.MethodType
     _kWithAndWithoutRequestResponse_WithRequestNoResponse_Type =
     $fidl.MethodType(
@@ -390,7 +390,7 @@
 );
 // withRequestEmptyResponse: (String arg) -> ()
 const int _kWithAndWithoutRequestResponse_WithRequestEmptyResponse_Ordinal =
-    1995585907;
+    0x76f2397300000000;
 const $fidl.MethodType
     _kWithAndWithoutRequestResponse_WithRequestEmptyResponse_Type =
     $fidl.MethodType(
@@ -404,7 +404,7 @@
 );
 // withRequestWithResponse: (String arg) -> (String ret)
 const int _kWithAndWithoutRequestResponse_WithRequestWithResponse_Ordinal =
-    426977568;
+    0x1973292000000000;
 const $fidl.MethodType
     _kWithAndWithoutRequestResponse_WithRequestWithResponse_Type =
     $fidl.MethodType(
@@ -421,7 +421,8 @@
   name: r"WithAndWithoutRequestResponse.WithRequestWithResponse",
 );
 // onEmptyResponse:  -> ()
-const int _kWithAndWithoutRequestResponse_OnEmptyResponse_Ordinal = 1769985842;
+const int _kWithAndWithoutRequestResponse_OnEmptyResponse_Ordinal =
+    0x697fd73200000000;
 const $fidl.MethodType _kWithAndWithoutRequestResponse_OnEmptyResponse_Type =
     $fidl.MethodType(
   request: null,
@@ -429,7 +430,8 @@
   name: r"WithAndWithoutRequestResponse.OnEmptyResponse",
 );
 // onWithResponse:  -> (String ret)
-const int _kWithAndWithoutRequestResponse_OnWithResponse_Ordinal = 2051478023;
+const int _kWithAndWithoutRequestResponse_OnWithResponse_Ordinal =
+    0x7a47120700000000;
 const $fidl.MethodType _kWithAndWithoutRequestResponse_OnWithResponse_Type =
     $fidl.MethodType(
   request: null,
@@ -997,7 +999,7 @@
 }
 
 // errorAsPrimitive: () -> ()
-const int _kWithErrorSyntax_ErrorAsPrimitive_Ordinal = 2069369145;
+const int _kWithErrorSyntax_ErrorAsPrimitive_Ordinal = 0x7b58113900000000;
 const $fidl.MethodType _kWithErrorSyntax_ErrorAsPrimitive_Type =
     $fidl.MethodType(
   request: null,
@@ -1008,7 +1010,7 @@
   name: r"WithErrorSyntax.ErrorAsPrimitive",
 );
 // errorAsEnum: () -> ()
-const int _kWithErrorSyntax_ErrorAsEnum_Ordinal = 1284890143;
+const int _kWithErrorSyntax_ErrorAsEnum_Ordinal = 0x4c95de1f00000000;
 const $fidl.MethodType _kWithErrorSyntax_ErrorAsEnum_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -1261,7 +1263,7 @@
 }
 
 // methodA: (int a, int b)
-const int _kOvernetInternalProtocol_MethodA_Ordinal = 1993818253;
+const int _kOvernetInternalProtocol_MethodA_Ordinal = 0x76d7408d00000000;
 const $fidl.MethodType _kOvernetInternalProtocol_MethodA_Type =
     $fidl.MethodType(
   request: <$fidl.MemberType>[
@@ -1272,7 +1274,7 @@
   name: r"OvernetInternalProtocol.MethodA",
 );
 // eventA:  -> (int a, int b)
-const int _kOvernetInternalProtocol_EventA_Ordinal = 1746007436;
+const int _kOvernetInternalProtocol_EventA_Ordinal = 0x6811f58c00000000;
 const $fidl.MethodType _kOvernetInternalProtocol_EventA_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -1282,7 +1284,7 @@
   name: r"OvernetInternalProtocol.EventA",
 );
 // methodB: (int a, int b) -> (int result)
-const int _kOvernetInternalProtocol_MethodB_Ordinal = 952134976;
+const int _kOvernetInternalProtocol_MethodB_Ordinal = 0x38c06d4000000000;
 const $fidl.MethodType _kOvernetInternalProtocol_MethodB_Type =
     $fidl.MethodType(
   request: <$fidl.MemberType>[
@@ -1295,7 +1297,7 @@
   name: r"OvernetInternalProtocol.MethodB",
 );
 // mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
-const int _kOvernetInternalProtocol_MutateSocket_Ordinal = 1691201382;
+const int _kOvernetInternalProtocol_MutateSocket_Ordinal = 0x64cdaf6600000000;
 const $fidl.MethodType _kOvernetInternalProtocol_MutateSocket_Type =
     $fidl.MethodType(
   request: <$fidl.MemberType>[
@@ -1649,7 +1651,7 @@
 }
 
 // methodA: (int a, int b)
-const int _kSocketControlProtocol_MethodA_Ordinal = 1007842318;
+const int _kSocketControlProtocol_MethodA_Ordinal = 0x3c12740e00000000;
 const $fidl.MethodType _kSocketControlProtocol_MethodA_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<int>(type: $fidl.Int64Type(), offset: 16),
@@ -1659,7 +1661,7 @@
   name: r"SocketControlProtocol.MethodA",
 );
 // eventA:  -> (int a, int b)
-const int _kSocketControlProtocol_EventA_Ordinal = 955483393;
+const int _kSocketControlProtocol_EventA_Ordinal = 0x38f3850100000000;
 const $fidl.MethodType _kSocketControlProtocol_EventA_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -1669,7 +1671,7 @@
   name: r"SocketControlProtocol.EventA",
 );
 // methodB: (int a, int b) -> (int result)
-const int _kSocketControlProtocol_MethodB_Ordinal = 677342235;
+const int _kSocketControlProtocol_MethodB_Ordinal = 0x285f6c1b00000000;
 const $fidl.MethodType _kSocketControlProtocol_MethodB_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<int>(type: $fidl.Int64Type(), offset: 16),
@@ -1681,7 +1683,7 @@
   name: r"SocketControlProtocol.MethodB",
 );
 // mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
-const int _kSocketControlProtocol_MutateSocket_Ordinal = 255772213;
+const int _kSocketControlProtocol_MutateSocket_Ordinal = 0xf3ec63500000000;
 const $fidl.MethodType _kSocketControlProtocol_MutateSocket_Type =
     $fidl.MethodType(
   request: <$fidl.MemberType>[
@@ -2035,7 +2037,7 @@
 }
 
 // methodA: (int a, int b)
-const int _kChannelProtocol_MethodA_Ordinal = 1432785874;
+const int _kChannelProtocol_MethodA_Ordinal = 0x556693d200000000;
 const $fidl.MethodType _kChannelProtocol_MethodA_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<int>(type: $fidl.Int64Type(), offset: 16),
@@ -2045,7 +2047,7 @@
   name: r"ChannelProtocol.MethodA",
 );
 // eventA:  -> (int a, int b)
-const int _kChannelProtocol_EventA_Ordinal = 477676034;
+const int _kChannelProtocol_EventA_Ordinal = 0x1c78c20200000000;
 const $fidl.MethodType _kChannelProtocol_EventA_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -2055,7 +2057,7 @@
   name: r"ChannelProtocol.EventA",
 );
 // methodB: (int a, int b) -> (int result)
-const int _kChannelProtocol_MethodB_Ordinal = 180770075;
+const int _kChannelProtocol_MethodB_Ordinal = 0xac6551b00000000;
 const $fidl.MethodType _kChannelProtocol_MethodB_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<int>(type: $fidl.Int64Type(), offset: 16),
@@ -2067,7 +2069,7 @@
   name: r"ChannelProtocol.MethodB",
 );
 // mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
-const int _kChannelProtocol_MutateSocket_Ordinal = 1258480262;
+const int _kChannelProtocol_MutateSocket_Ordinal = 0x4b02e28600000000;
 const $fidl.MethodType _kChannelProtocol_MutateSocket_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<$zx.Socket>(
@@ -2415,7 +2417,7 @@
 }
 
 // methodA: (int a, int b)
-const int _kKitchenSink_MethodA_Ordinal = 450577456;
+const int _kKitchenSink_MethodA_Ordinal = 0x1adb443000000000;
 const $fidl.MethodType _kKitchenSink_MethodA_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<int>(type: $fidl.Int64Type(), offset: 16),
@@ -2425,7 +2427,7 @@
   name: r"KitchenSink.MethodA",
 );
 // eventA:  -> (int a, int b)
-const int _kKitchenSink_EventA_Ordinal = 1795426833;
+const int _kKitchenSink_EventA_Ordinal = 0x6b040a1100000000;
 const $fidl.MethodType _kKitchenSink_EventA_Type = $fidl.MethodType(
   request: null,
   response: <$fidl.MemberType>[
@@ -2435,7 +2437,7 @@
   name: r"KitchenSink.EventA",
 );
 // methodB: (int a, int b) -> (int result)
-const int _kKitchenSink_MethodB_Ordinal = 1999489700;
+const int _kKitchenSink_MethodB_Ordinal = 0x772dcaa400000000;
 const $fidl.MethodType _kKitchenSink_MethodB_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<int>(type: $fidl.Int64Type(), offset: 16),
@@ -2447,7 +2449,7 @@
   name: r"KitchenSink.MethodB",
 );
 // mutateSocket: ($zx.Socket a) -> ($zx.Socket b)
-const int _kKitchenSink_MutateSocket_Ordinal = 115851270;
+const int _kKitchenSink_MutateSocket_Ordinal = 0x6e7c00600000000;
 const $fidl.MethodType _kKitchenSink_MutateSocket_Type = $fidl.MethodType(
   request: <$fidl.MemberType>[
     $fidl.MemberType<$zx.Socket>(
diff --git a/public/dart/fidl/lib/src/codec.dart b/public/dart/fidl/lib/src/codec.dart
index 1d60e90..068533b 100644
--- a/public/dart/fidl/lib/src/codec.dart
+++ b/public/dart/fidl/lib/src/codec.dart
@@ -73,7 +73,7 @@
 
   void encodeMessageHeader(int ordinal, int txid) {
     alloc(kMessageHeaderSize);
-    encodeUint32(ordinal, kMessageOrdinalOffset);
+    encodeUint64(ordinal, kMessageOrdinalOffset);
     encodeUint32(txid, kMessageTxidOffset);
   }
 
diff --git a/public/dart/fidl/lib/src/message.dart b/public/dart/fidl/lib/src/message.dart
index 3190ec0..2175717 100644
--- a/public/dart/fidl/lib/src/message.dart
+++ b/public/dart/fidl/lib/src/message.dart
@@ -10,7 +10,7 @@
 
 const int kMessageHeaderSize = 16;
 const int kMessageTxidOffset = 0;
-const int kMessageOrdinalOffset = 12;
+const int kMessageOrdinalOffset = 8;
 
 class Message {
   Message(this.data, this.handles, this.dataLength, this.handlesLength);
@@ -30,7 +30,7 @@
   set txid(int value) =>
       data.setUint32(kMessageTxidOffset, value, Endian.little);
 
-  int get ordinal => data.getUint32(kMessageOrdinalOffset, Endian.little);
+  int get ordinal => data.getUint64(kMessageOrdinalOffset, Endian.little);
 
   void hexDump() {
     const int width = 16;