diff options
author | David Reiss <dreiss@apache.org> | 2008-02-06 22:09:58 +0000 |
---|---|---|
committer | David Reiss <dreiss@apache.org> | 2008-02-06 22:09:58 +0000 |
commit | 46dc62950d24cf785415de040255b3b0c67ecb3a (patch) | |
tree | d9ef9c5a5261285903108c7cb40391ad3b07ea8b | |
parent | cba5727a3fc49a1c8e93bc8cfd5ba4e20326cbc3 (diff) | |
download | thrift-46dc62950d24cf785415de040255b3b0c67ecb3a.tar.gz |
Thrift: Miscellaneous optimizations for C#.
Reviewed By: mcslee
Test Plan: Built it after a future revision.
Revert Plan: ok
Other Notes:
Submitted by Ben Maurer.
Actually reviewed by Todd Berman.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665464 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | compiler/cpp/src/generate/t_csharp_generator.cc | 10 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TField.cs | 6 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TList.cs | 6 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TMap.cs | 6 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TMessage.cs | 6 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TProtocolException.cs | 1 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TSet.cs | 6 | ||||
-rw-r--r-- | lib/csharp/src/Protocol/TStruct.cs | 6 |
8 files changed, 11 insertions, 36 deletions
diff --git a/compiler/cpp/src/generate/t_csharp_generator.cc b/compiler/cpp/src/generate/t_csharp_generator.cc index 48df1b09b..fceec8497 100644 --- a/compiler/cpp/src/generate/t_csharp_generator.cc +++ b/compiler/cpp/src/generate/t_csharp_generator.cc @@ -321,12 +321,12 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream &out, t_stru if (members.size() > 0) { out << endl << - indent() << "public Isset __isset = new Isset();" << endl << - indent() << "public sealed class Isset {" << endl; + indent() << "public Isset __isset;" << endl << + indent() << "public struct Isset {" << endl; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << - "public bool " << (*m_iter)->get_name() << " = false;" << endl; + "public bool " << (*m_iter)->get_name() << ";" << endl; } indent_down(); @@ -593,7 +593,7 @@ void t_csharp_generator::generate_csharp_struct_tostring(ofstream& out, t_struct t_type* ttype = (*f_iter)->get_type(); if (ttype->is_xception() || ttype->is_struct()) { indent(out) << - "sb.Append(this." << (*f_iter)->get_name() << ".ToString());" << endl; + "sb.Append(this." << (*f_iter)->get_name() << "== null ? \"<null>\" : "<< "this." << (*f_iter)->get_name() << ".ToString());" << endl; } else { indent(out) << "sb.Append(this." << (*f_iter)->get_name() << ");" << endl; @@ -1384,7 +1384,7 @@ string t_csharp_generator::type_name(t_type* ttype, bool in_container, bool in_i } if (ttype->is_base_type()) { - return base_type_name(((t_base_type*)ttype)->get_base(), in_container); + return base_type_name((t_base_type*)ttype, in_container); } else if (ttype->is_map()) { t_map *tmap = (t_map*) ttype; return "Dictionary<" + type_name(tmap->get_key_type(), true) + diff --git a/lib/csharp/src/Protocol/TField.cs b/lib/csharp/src/Protocol/TField.cs index f18381ff9..932953095 100644 --- a/lib/csharp/src/Protocol/TField.cs +++ b/lib/csharp/src/Protocol/TField.cs @@ -16,12 +16,8 @@ using System.Text; namespace Thrift.Protocol { - public class TField + public struct TField { - public TField() - { - } - public TField(string name, TType type, short id) { Name = name; diff --git a/lib/csharp/src/Protocol/TList.cs b/lib/csharp/src/Protocol/TList.cs index ff6aa533c..72056cb89 100644 --- a/lib/csharp/src/Protocol/TList.cs +++ b/lib/csharp/src/Protocol/TList.cs @@ -16,12 +16,8 @@ using System.Text; namespace Thrift.Protocol { - public class TList + public struct TList { - public TList() - { - } - public TList(TType elementType, int count) { ElementType = elementType; diff --git a/lib/csharp/src/Protocol/TMap.cs b/lib/csharp/src/Protocol/TMap.cs index 495bf7cc4..586aa4f60 100644 --- a/lib/csharp/src/Protocol/TMap.cs +++ b/lib/csharp/src/Protocol/TMap.cs @@ -16,12 +16,8 @@ using System.Text; namespace Thrift.Protocol { - public class TMap + public struct TMap { - public TMap() - { - } - public TMap(TType keyType, TType valueType, int count) { KeyType = keyType; diff --git a/lib/csharp/src/Protocol/TMessage.cs b/lib/csharp/src/Protocol/TMessage.cs index 60df66074..a9522ff0e 100644 --- a/lib/csharp/src/Protocol/TMessage.cs +++ b/lib/csharp/src/Protocol/TMessage.cs @@ -16,12 +16,8 @@ using System.Text; namespace Thrift.Protocol { - public class TMessage + public struct TMessage { - public TMessage() - { - } - public TMessage(string name, TMessageType type, int seqid) { Name = name; diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs index 0941a81e2..db38d88cf 100644 --- a/lib/csharp/src/Protocol/TProtocolException.cs +++ b/lib/csharp/src/Protocol/TProtocolException.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Thrift.Protocol diff --git a/lib/csharp/src/Protocol/TSet.cs b/lib/csharp/src/Protocol/TSet.cs index c4c6fc333..1f172e47d 100644 --- a/lib/csharp/src/Protocol/TSet.cs +++ b/lib/csharp/src/Protocol/TSet.cs @@ -16,12 +16,8 @@ using System.Text; namespace Thrift.Protocol { - public class TSet + public struct TSet { - public TSet() - { - } - public TSet(TType elementType, int count) { ElementType = elementType; diff --git a/lib/csharp/src/Protocol/TStruct.cs b/lib/csharp/src/Protocol/TStruct.cs index 88f12df6d..000ebf115 100644 --- a/lib/csharp/src/Protocol/TStruct.cs +++ b/lib/csharp/src/Protocol/TStruct.cs @@ -15,12 +15,8 @@ using System.Text; namespace Thrift.Protocol { - public class TStruct + public struct TStruct { - public TStruct() - { - } - public TStruct(string name) { Name = name; |