THRIFT-3025 Change pure Ints into @enums Client: Haxe Patch: Jens Geyer This closes #391
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/65ee9838 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/65ee9838 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/65ee9838 Branch: refs/heads/master Commit: 65ee9838bcfe1da945647b27f8db98ea573e5def Parents: 8cc78c1 Author: Jens Geyer <[email protected]> Authored: Thu Mar 5 23:11:45 2015 +0100 Committer: Jens Geyer <[email protected]> Committed: Fri Mar 6 01:27:48 2015 +0100 ---------------------------------------------------------------------- .../org/apache/thrift/TApplicationException.hx | 2 + .../org/apache/thrift/TFieldRequirementType.hx | 8 ++-- .../apache/thrift/protocol/TCompactProtocol.hx | 21 +--------- .../org/apache/thrift/protocol/TCompactTypes.hx | 41 ++++++++++++++++++++ .../src/org/apache/thrift/protocol/TMessage.hx | 2 +- .../org/apache/thrift/protocol/TMessageType.hx | 5 ++- .../thrift/protocol/TProtocolException.hx | 2 + .../src/org/apache/thrift/protocol/TType.hx | 5 +-- .../thrift/transport/TTransportException.hx | 2 + 9 files changed, 58 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/TApplicationException.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/TApplicationException.hx b/lib/haxe/src/org/apache/thrift/TApplicationException.hx index 4287a85..4fe571d 100644 --- a/lib/haxe/src/org/apache/thrift/TApplicationException.hx +++ b/lib/haxe/src/org/apache/thrift/TApplicationException.hx @@ -34,6 +34,8 @@ class TApplicationException extends TException { private static var MESSAGE_FIELD = { new TField("message", TType.STRING, 1); }; private static var TYPE_FIELD = { new TField("type", TType.I32, 2); }; + // WARNING: These are subject to be extended in the future, so we can't use enums + // with Haxe 3.1.3 because of https://github.com/HaxeFoundation/haxe/issues/3649 public static inline var UNKNOWN : Int = 0; public static inline var UNKNOWN_METHOD : Int = 1; public static inline var INVALID_MESSAGE_TYPE : Int = 2; http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx b/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx index 7c22030..039a2cf 100644 --- a/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx +++ b/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx @@ -23,9 +23,9 @@ package org.apache.thrift; * Requirement type constants. * */ -class TFieldRequirementType { - public static inline var REQUIRED : Int = 1; +@:enum +abstract TFieldRequirementType(Int) from Int to Int { + public static inline var REQUIRED : Int = 1; public static inline var OPTIONAL : Int = 2; - public static inline var DEFAULT : Int = 3; - + public static inline var DEFAULT : Int = 3; } http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx b/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx index d08a6d0..0781114 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx @@ -35,26 +35,7 @@ import org.apache.thrift.helper.BitConverter; /** - * All of the on-wire type codes. - */ -class TCompactTypes { - public static inline var STOP = 0x00; - public static inline var BOOLEAN_TRUE = 0x01; - public static inline var BOOLEAN_FALSE = 0x02; - public static inline var BYTE = 0x03; - public static inline var I16 = 0x04; - public static inline var I32 = 0x05; - public static inline var I64 = 0x06; - public static inline var DOUBLE = 0x07; - public static inline var BINARY = 0x08; - public static inline var LIST = 0x09; - public static inline var SET = 0x0A; - public static inline var MAP = 0x0B; - public static inline var STRUCT = 0x0C; -} - -/** -* Binary protocol implementation for thrift. +* Compact protocol implementation for thrift. */ class TCompactProtocol implements TProtocol { http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx b/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx new file mode 100644 index 0000000..cdd3d87 --- /dev/null +++ b/lib/haxe/src/org/apache/thrift/protocol/TCompactTypes.hx @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.thrift.protocol; + +/** + * All of the on-wire type codes. + */ +@:enum +abstract TCompactTypes(Int) from Int to Int { + public static inline var STOP = 0x00; + public static inline var BOOLEAN_TRUE = 0x01; + public static inline var BOOLEAN_FALSE = 0x02; + public static inline var BYTE = 0x03; + public static inline var I16 = 0x04; + public static inline var I32 = 0x05; + public static inline var I64 = 0x06; + public static inline var DOUBLE = 0x07; + public static inline var BINARY = 0x08; + public static inline var LIST = 0x09; + public static inline var SET = 0x0A; + public static inline var MAP = 0x0B; + public static inline var STRUCT = 0x0C; +} + http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx index 58d71a9..d99264a 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx @@ -38,4 +38,4 @@ class TMessage { public function equals(other:TMessage) : Bool { return name == other.name && type == other.type && seqid == other.seqid; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx index 7cb38b3..706d329 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx @@ -19,9 +19,10 @@ package org.apache.thrift.protocol; -class TMessageType { +@:enum +abstract TMessageType(Int) from Int to Int { public static inline var CALL : Int = 1; - public static inline var REPLY : Int = 2; + public static inline var REPLY : Int = 2; public static inline var EXCEPTION : Int = 3; public static inline var ONEWAY : Int = 4; } http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx index 6e528cb..2e0f9f5 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx @@ -23,6 +23,8 @@ import org.apache.thrift.TException; class TProtocolException extends TException { + // WARNING: These are subject to be extended in the future, so we can't use enums + // with Haxe 3.1.3 because of https://github.com/HaxeFoundation/haxe/issues/3649 public static inline var UNKNOWN : Int = 0; public static inline var INVALID_DATA : Int = 1; public static inline var NEGATIVE_SIZE : Int = 2; http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/protocol/TType.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/protocol/TType.hx b/lib/haxe/src/org/apache/thrift/protocol/TType.hx index 1e093c2..6abbc96 100644 --- a/lib/haxe/src/org/apache/thrift/protocol/TType.hx +++ b/lib/haxe/src/org/apache/thrift/protocol/TType.hx @@ -19,8 +19,8 @@ package org.apache.thrift.protocol; -class TType { - +@:enum +abstract TType(Int) from Int to Int { public static inline var STOP : Int = 0; public static inline var VOID : Int = 1; public static inline var BOOL : Int = 2; @@ -34,5 +34,4 @@ class TType { public static inline var MAP : Int = 13; public static inline var SET : Int = 14; public static inline var LIST : Int = 15; - } http://git-wip-us.apache.org/repos/asf/thrift/blob/65ee9838/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx ---------------------------------------------------------------------- diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx index f930c52..036b9f5 100644 --- a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx +++ b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx @@ -23,6 +23,8 @@ import org.apache.thrift.TException; class TTransportException extends TException { + // WARNING: These are subject to be extended in the future, so we can't use enums + // with Haxe 3.1.3 because of https://github.com/HaxeFoundation/haxe/issues/3649 public static inline var UNKNOWN : Int = 0; public static inline var NOT_OPEN : Int = 1; public static inline var ALREADY_OPEN : Int = 2;
