You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2014/12/13 21:30:10 UTC
thrift git commit: THRIFT-2882 Lua Generator: using string.len
funtion to get struct(map, list, set) size
Repository: thrift
Updated Branches:
refs/heads/master 3c5a788d8 -> de76a3772
THRIFT-2882 Lua Generator: using string.len funtion to get struct(map,list,set) size
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/de76a377
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/de76a377
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/de76a377
Branch: refs/heads/master
Commit: de76a3772b5642d093765e2cf1de5b9e0201067c
Parents: 3c5a788
Author: winsweet <wi...@gmail.com>
Authored: Tue Dec 9 16:14:51 2014 +0800
Committer: Roger Meier <ro...@apache.org>
Committed: Sat Dec 13 21:29:55 2014 +0100
----------------------------------------------------------------------
compiler/cpp/src/generate/t_lua_generator.cc | 6 +++---
lib/lua/Thrift.lua | 8 ++++++++
2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/de76a377/compiler/cpp/src/generate/t_lua_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_lua_generator.cc b/compiler/cpp/src/generate/t_lua_generator.cc
index 5703ecb..46a9a90 100644
--- a/compiler/cpp/src/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/generate/t_lua_generator.cc
@@ -963,14 +963,14 @@ void t_lua_generator::generate_serialize_container(ofstream& out, t_type* ttype,
if (ttype->is_map()) {
indent(out) << "oprot:writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", "
<< type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
- << "string.len(" << prefix << "))" << endl;
+ << "ttable_size(" << prefix << "))" << endl;
} else if (ttype->is_set()) {
indent(out) << "oprot:writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", "
- << "string.len(" << prefix << "))" << endl;
+ << "ttable_size(" << prefix << "))" << endl;
} else if (ttype->is_list()) {
indent(out) << "oprot:writeListBegin(" << type_to_enum(((t_list*)ttype)->get_elem_type())
<< ", "
- << "string.len(" << prefix << "))" << endl;
+ << "#" << prefix << ")" << endl;
}
// Serialize
http://git-wip-us.apache.org/repos/asf/thrift/blob/de76a377/lib/lua/Thrift.lua
----------------------------------------------------------------------
diff --git a/lib/lua/Thrift.lua b/lib/lua/Thrift.lua
index da5bb63..a9a9078 100644
--- a/lib/lua/Thrift.lua
+++ b/lib/lua/Thrift.lua
@@ -40,6 +40,14 @@ function terror(e)
error(e)
end
+function ttable_size(t)
+ local count = 0
+ for k, v in pairs(t) do
+ count = count + 1
+ end
+ return count
+end
+
version = 1.0
TType = {