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
This commit is contained in:
David Reiss 2008-02-06 22:09:58 +00:00
parent cba5727a3f
commit 46dc62950d
8 changed files with 11 additions and 36 deletions

View File

@ -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) +

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Thrift.Protocol

View File

@ -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;

View File

@ -15,12 +15,8 @@ using System.Text;
namespace Thrift.Protocol
{
public class TStruct
public struct TStruct
{
public TStruct()
{
}
public TStruct(string name)
{
Name = name;