diff options
author | Jens Geyer <jensg@apache.org> | 2015-03-05 23:11:45 +0100 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2015-03-06 01:27:48 +0100 |
commit | 65ee9838bcfe1da945647b27f8db98ea573e5def (patch) | |
tree | ee732e3422b493463405f223d23d0066b55a96d9 /lib/haxe/src | |
parent | 8cc78c101a86e9d200a09996e75f3cabec18bad4 (diff) | |
download | thrift-65ee9838bcfe1da945647b27f8db98ea573e5def.tar.gz |
THRIFT-3025 Change pure Ints into @enums
Client: Haxe
Patch: Jens Geyer
This closes #391
Diffstat (limited to 'lib/haxe/src')
9 files changed, 58 insertions, 30 deletions
diff --git a/lib/haxe/src/org/apache/thrift/TApplicationException.hx b/lib/haxe/src/org/apache/thrift/TApplicationException.hx index 4287a85e0..4fe571d41 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; diff --git a/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx b/lib/haxe/src/org/apache/thrift/TFieldRequirementType.hx index 7c2203009..039a2cf3a 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; } diff --git a/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx b/lib/haxe/src/org/apache/thrift/protocol/TCompactProtocol.hx index d08a6d0bc..07811148d 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 { 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 000000000..cdd3d874f --- /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; +} + diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx index 58d71a994..d99264a56 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 +} diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx index 7cb38b373..706d3298b 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; } diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx index 6e528cbe7..2e0f9f53d 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; diff --git a/lib/haxe/src/org/apache/thrift/protocol/TType.hx b/lib/haxe/src/org/apache/thrift/protocol/TType.hx index 1e093c206..6abbc9685 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; - } diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx index f930c52c9..036b9f5c6 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; |