You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2012/05/11 04:23:01 UTC
svn commit: r1337007 - in /thrift/trunk: compiler/cpp/src/generate/ lib/as3/
lib/as3/src/org/apache/thrift/ lib/as3/src/org/apache/thrift/protocol/
lib/as3/src/org/apache/thrift/transport/
Author: jfarrell
Date: Fri May 11 02:23:00 2012
New Revision: 1337007
URL: http://svn.apache.org/viewvc?rev=1337007&view=rev
Log:
Thrift-1079:Support i64 in AS3
Client: as3
Patch: Reverting
Reverting patch due to usage of non public library which breaks ability to export as3 client to maven central during a release.
Removed:
thrift/trunk/lib/as3/src/org/apache/thrift/TDeserializer.as
thrift/trunk/lib/as3/src/org/apache/thrift/TSerializer.as
thrift/trunk/lib/as3/src/org/apache/thrift/transport/TMemoryBuffer.as
Modified:
thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc
thrift/trunk/lib/as3/build.xml
thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as
thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TProtocol.as
Modified: thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc?rev=1337007&r1=1337006&r2=1337007&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_as3_generator.cc Fri May 11 02:23:00 2012
@@ -193,8 +193,7 @@ class t_as3_generator : public t_oop_gen
ttype->is_container() ||
ttype->is_struct() ||
ttype->is_xception() ||
- ttype->is_string() ||
- (ttype->is_base_type() && ((t_base_type*)ttype)->get_base() == t_base_type::TYPE_I64);//for using the new BigInteger library
+ ttype->is_string();
}
std::string constant_name(std::string name);
@@ -262,8 +261,7 @@ string t_as3_generator::as3_type_imports
string() +
"import org.apache.thrift.Set;\n" +
"import flash.utils.ByteArray;\n" +
- "import flash.utils.Dictionary;\n" +
- "import com.hurlant.math.BigInteger;\n\n";
+ "import flash.utils.Dictionary;\n\n";
}
/**
@@ -486,13 +484,7 @@ void t_as3_generator::print_const_value(
vector<t_field*>::const_iterator f_iter;
const map<t_const_value*, t_const_value*>& val = value->get_map();
map<t_const_value*, t_const_value*>::const_iterator v_iter;
-
- out << name;
- if(!defval){
- out << ":" << type_name(type);
- }
- out << " = new " << type_name(type, false, true) << "();" << endl;
-
+ out << name << ":" << type_name(type) << " = new " << type_name(type, false, true) << "();" << endl;
if (!in_static) {
indent(out) << "{" << endl;
indent_up();
@@ -599,20 +591,20 @@ string t_as3_generator::render_const_val
render << ((value->get_integer() > 0) ? "true" : "false");
break;
case t_base_type::TYPE_BYTE:
- render << "int(" << value->get_integer() << ")";
+ render << "(byte)" << value->get_integer();
break;
case t_base_type::TYPE_I16:
- render << "int(" << value->get_integer() << ")";
+ render << "(short)" << value->get_integer();
break;
case t_base_type::TYPE_I32:
render << value->get_integer();
break;
case t_base_type::TYPE_I64:
- render << "new BigInteger(\"" << hex << value->get_integer() << dec << "\")";
+ render << value->get_integer() << "L";
break;
case t_base_type::TYPE_DOUBLE:
if (value->get_type() == t_const_value::CV_INTEGER) {
- render << "Number(" << value->get_integer() << ")";
+ render << "(double)" << value->get_integer();
} else {
render << value->get_double();
}
@@ -2473,7 +2465,7 @@ string t_as3_generator::base_type_name(t
case t_base_type::TYPE_I32:
return "int";
case t_base_type::TYPE_I64:
- return "BigInteger";
+ throw "i64 is not yet supported in as3";
case t_base_type::TYPE_DOUBLE:
return "Number";
default:
@@ -2508,10 +2500,8 @@ string t_as3_generator::declare_field(t_
case t_base_type::TYPE_BYTE:
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
- result += " = 0"; //leaving this here even though it doesn't work with BigInteger because it's never called by the generator.
- break;
case t_base_type::TYPE_I64:
- result += " = new BigInteger(\"0x0\")";
+ result += " = 0";
break;
case t_base_type::TYPE_DOUBLE:
result += " = (double)0";
Modified: thrift/trunk/lib/as3/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/as3/build.xml?rev=1337007&r1=1337006&r2=1337007&view=diff
==============================================================================
--- thrift/trunk/lib/as3/build.xml (original)
+++ thrift/trunk/lib/as3/build.xml Fri May 11 02:23:00 2012
@@ -41,7 +41,6 @@
<property name="src" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/build"/>
- <property name="lib.dir" value="${basedir}/lib"/>
<property name="as3.swc.file" location="${build.dir}/${as3.final.name}.swc"/>
<property name="as3.pom.xml" location="${build.dir}/${as3.final.name}.pom"/>
@@ -82,9 +81,6 @@
<compc output="${as3.swc.file}" include-classes="${as.src.classes}">
<source-path path-element="${src}"/>
- <compiler.include-libraries dir="${lib.dir}" append="true">
- <include name="as3crypto-1.3.0-library.swc" />
- </compiler.include-libraries>
</compc>
</target>
Modified: thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as?rev=1337007&r1=1337006&r2=1337007&view=diff
==============================================================================
--- thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as (original)
+++ thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TBinaryProtocol.as Fri May 11 02:23:00 2012
@@ -21,7 +21,6 @@ package org.apache.thrift.protocol {
import flash.utils.ByteArray;
- import com.hurlant.math.BigInteger;
import org.apache.thrift.TError;
import org.apache.thrift.transport.THttpClient;
import org.apache.thrift.transport.TTransport;
@@ -155,20 +154,18 @@ package org.apache.thrift.protocol {
trans_.write(out, 0, 4);
}
- public function writeI64(i64:BigInteger):void {
- reset(out);
- var ba:ByteArray = i64.toByteArray();
- ba.position = 0;
-
- // pad the output to make sure this 64-bit number takes
- // all 64-bits, and no more since BigInteger can handle more
- var difference:int = 8 - Math.min(8, ba.length);
- for( ; difference > 0; difference-- ){
- out.writeByte(0);
- }
- out.writeBytes(ba, 0, Math.min(8, ba.bytesAvailable));
- trans_.write(out, 0, 8);
- }
+ //private byte[] i64out = new byte[8];
+ //public function writeI64(i64:Number):void {
+ //i64out[0] = (byte)(0xff & (i64 >> 56));
+ //i64out[1] = (byte)(0xff & (i64 >> 48));
+ //i64out[2] = (byte)(0xff & (i64 >> 40));
+ //i64out[3] = (byte)(0xff & (i64 >> 32));
+ //i64out[4] = (byte)(0xff & (i64 >> 24));
+ //i64out[5] = (byte)(0xff & (i64 >> 16));
+ //i64out[6] = (byte)(0xff & (i64 >> 8));
+ //i64out[7] = (byte)(0xff & (i64));
+ //trans_.write(i64out, 0, 8);
+ //}
public function writeDouble(dub:Number):void {
reset(out);
@@ -267,10 +264,21 @@ package org.apache.thrift.protocol {
return bytes.readInt();
}
- public function readI64():BigInteger {
- readAll(8);
- return new BigInteger(bytes);
+ //private byte[] i64rd = new byte[8];
+ /*
+ public function readI64() throws TException {
+ readAll(i64rd, 0, 8);
+ return
+ ((long)(i64rd[0] & 0xff) << 56) |
+ ((long)(i64rd[1] & 0xff) << 48) |
+ ((long)(i64rd[2] & 0xff) << 40) |
+ ((long)(i64rd[3] & 0xff) << 32) |
+ ((long)(i64rd[4] & 0xff) << 24) |
+ ((long)(i64rd[5] & 0xff) << 16) |
+ ((long)(i64rd[6] & 0xff) << 8) |
+ ((long)(i64rd[7] & 0xff));
}
+ */
public function readDouble():Number {
readAll(8);
Modified: thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TProtocol.as
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TProtocol.as?rev=1337007&r1=1337006&r2=1337007&view=diff
==============================================================================
--- thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TProtocol.as (original)
+++ thrift/trunk/lib/as3/src/org/apache/thrift/protocol/TProtocol.as Fri May 11 02:23:00 2012
@@ -22,8 +22,6 @@ package org.apache.thrift.protocol {
import org.apache.thrift.TError;
import org.apache.thrift.transport.TTransport;
- import com.hurlant.math.BigInteger;
-
import flash.utils.ByteArray;
/**
@@ -72,7 +70,7 @@ package org.apache.thrift.protocol {
function writeI32(i32:int):void;
- function writeI64(i64:BigInteger):void;
+ //function writeI64(i64:Number):void;
function writeDouble(dub:Number):void;
@@ -115,7 +113,7 @@ package org.apache.thrift.protocol {
function readI32():int;
- function readI64():BigInteger;
+ //function readI64():Number;
function readDouble():Number;
@@ -123,4 +121,4 @@ package org.apache.thrift.protocol {
function readBinary():ByteArray;
}
-}
+}
\ No newline at end of file