Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
800f65e2
Commit
800f65e2
authored
Aug 14, 2008
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch from Miguel de Icaza - tweaks to generated C#
parent
007f8596
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
73 additions
and
71 deletions
+73
-71
autogen.sh
autogen.sh
+2
-2
csharp_enum_field.cc
src/google/protobuf/compiler/csharp/csharp_enum_field.cc
+19
-16
csharp_extension.cc
src/google/protobuf/compiler/csharp/csharp_extension.cc
+2
-2
csharp_message.cc
src/google/protobuf/compiler/csharp/csharp_message.cc
+4
-4
csharp_message_field.cc
src/google/protobuf/compiler/csharp/csharp_message_field.cc
+43
-43
csharp_primitive_field.cc
...google/protobuf/compiler/csharp/csharp_primitive_field.cc
+2
-3
csharp_service.cc
src/google/protobuf/compiler/csharp/csharp_service.cc
+1
-1
No files found.
autogen.sh
View file @
800f65e2
...
...
@@ -17,10 +17,10 @@ set -ex
rm
-rf
autom4te.cache
aclocal-1.
9
--force
-I
m4
aclocal-1.
10
--force
-I
m4
libtoolize
-c
-f
autoheader
-f
-W
all
automake-1.
9
--foreign
-a
-c
-f
-W
all
automake-1.
10
--foreign
-a
-c
-f
-W
all
autoconf
-f
-W
all,no-obsolete
rm
-rf
autom4te.cache config.h.in~
...
...
src/google/protobuf/compiler/csharp/csharp_enum_field.cc
View file @
800f65e2
...
...
@@ -70,25 +70,25 @@ GenerateMembers(io::Printer* printer) const {
printer
->
Print
(
variables_
,
"private boolean has$capitalized_name$;
\r\n
"
"private $type$ $name$_ = $default$;
\r\n
"
"public boolean
h
as$capitalized_name$() { return has$capitalized_name$; }
\r\n
"
"public $type$
g
et$capitalized_name$() { return $name$_; }
\r\n
"
);
"public boolean
H
as$capitalized_name$() { return has$capitalized_name$; }
\r\n
"
"public $type$
G
et$capitalized_name$() { return $name$_; }
\r\n
"
);
}
void
EnumFieldGenerator
::
GenerateBuilderMembers
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"public boolean
h
as$capitalized_name$() {
\r\n
"
" return result.
h
as$capitalized_name$();
\r\n
"
"public boolean
H
as$capitalized_name$() {
\r\n
"
" return result.
H
as$capitalized_name$();
\r\n
"
"}
\r\n
"
"public $type$
g
et$capitalized_name$() {
\r\n
"
" return result.
g
et$capitalized_name$();
\r\n
"
"public $type$
G
et$capitalized_name$() {
\r\n
"
" return result.
G
et$capitalized_name$();
\r\n
"
"}
\r\n
"
"public Builder
s
et$capitalized_name$($type$ value) {
\r\n
"
"public Builder
S
et$capitalized_name$($type$ value) {
\r\n
"
" result.has$capitalized_name$ = true;
\r\n
"
" result.$name$_ = value;
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
"public Builder
c
lear$capitalized_name$() {
\r\n
"
"public Builder
C
lear$capitalized_name$() {
\r\n
"
" result.has$capitalized_name$ = false;
\r\n
"
" result.$name$_ = $default$;
\r\n
"
" return this;
\r\n
"
...
...
@@ -154,15 +154,18 @@ RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
void
RepeatedEnumFieldGenerator
::
GenerateMembers
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"private
java.util
.List<$type$> $name$_ =
\r\n
"
"
java.util.Collections.emptyList
();
\r\n
"
"public
java.util.List<$type$> get
$capitalized_name$List() {
\r\n
"
" return $name$_;
\r\n
"
// note: unmodifiable list
"private
System.Collections.Generic
.List<$type$> $name$_ =
\r\n
"
"
new System.Collections.Generic.List<$type$>
();
\r\n
"
"public
System.Collections.Generic.List<$type$>
$capitalized_name$List() {
\r\n
"
" return $name$_
.AsReadOnly ()
;
\r\n
"
// note: unmodifiable list
"}
\r\n
"
"public int get$capitalized_name$Count() { return $name$_.size(); }
\r\n
"
"public $type$ get$capitalized_name$(int index) {
\r\n
"
" return $name$_.get(index);
\r\n
"
"}
\r\n
"
);
// Redundant API calls?
//"public int $capitalized_name$Count() { get { return $name$_.Count; } }\r\n"
//"public $type$ get$capitalized_name$(int index) {\r\n"
//" return $name$_.get(index);\r\n"
//"}\r\n"
);
}
void
RepeatedEnumFieldGenerator
::
...
...
src/google/protobuf/compiler/csharp/csharp_extension.cc
View file @
800f65e2
...
...
@@ -63,7 +63,7 @@ void ExtensionGenerator::Generate(io::Printer* printer) {
" pb::GeneratedMessage
\r\n
"
" .newRepeatedGeneratedExtension(
\r\n
"
" getDescriptor().getExtensions().get($index$),
\r\n
"
"
$type$.class
);
\r\n
"
);
"
typeof ($type$)
);
\r\n
"
);
}
else
{
printer
->
Print
(
vars
,
"public static final
\r\n
"
...
...
@@ -72,7 +72,7 @@ void ExtensionGenerator::Generate(io::Printer* printer) {
" $type$> $name$ =
\r\n
"
" pb::GeneratedMessage.newGeneratedExtension(
\r\n
"
" getDescriptor().getExtensions().get($index$),
\r\n
"
"
$type$.class
);
\r\n
"
);
"
typeof ($type$)
);
\r\n
"
);
}
}
...
...
src/google/protobuf/compiler/csharp/csharp_message.cc
View file @
800f65e2
...
...
@@ -165,12 +165,12 @@ void MessageGenerator::GenerateStaticVariables(io::Printer* printer) {
// The descriptor for this type.
if
(
descriptor_
->
containing_type
()
==
NULL
)
{
printer
->
Print
(
vars
,
"$private$static readonly pb::Descriptors.Descriptor
{
\r\n
"
"$private$static readonly pb::Descriptors.Descriptor
\r\n
"
" internal_$identifier$_descriptor =
\r\n
"
" getDescriptor().getMessageTypes().get($index$);
\r\n
"
);
}
else
{
printer
->
Print
(
vars
,
"$private$static readonly pb::Descriptors.Descriptor
{
\r\n
"
"$private$static readonly pb::Descriptors.Descriptor
\r\n
"
" internal_$identifier$_descriptor =
\r\n
"
" internal_$parent$_descriptor.getNestedTypes().get($index$);
\r\n
"
);
}
...
...
@@ -190,8 +190,8 @@ void MessageGenerator::GenerateStaticVariables(io::Printer* printer) {
UnderscoresToCapitalizedCamelCase
(
descriptor_
->
field
(
i
)));
}
printer
->
Print
(
"},
\r\n
"
"
$classname$.class
,
\r\n
"
"
$classname$.Builder.class
);
\r\n
"
,
"
typeof ($classname$)
,
\r\n
"
"
typeof ($classname$.Builder)
);
\r\n
"
,
"classname"
,
ClassName
(
descriptor_
));
// Generate static members for all nested types.
...
...
src/google/protobuf/compiler/csharp/csharp_message_field.cc
View file @
800f65e2
...
...
@@ -175,14 +175,15 @@ RepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}
void
RepeatedMessageFieldGenerator
::
GenerateMembers
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"private java.util.List<$type$> $name$_ =
\r\n
"
" java.util.Collections.emptyList();
\r\n
"
"public java.util.List<$type$> get$capitalized_name$List() {
\r\n
"
" return $name$_;
\r\n
"
// note: unmodifiable list
"internal System.Collections.Generic.IList<$type$> Empty$capitalized_name$ =
\r\n
"
" new System.Collections.ReadOnlyCollection<$type$> ();
\r\n
"
"internal System.Collections.Generic.IList<$type$> $name$_ = Empty$capitalized_name$;
\r\n
"
"public System.Collections.Generic.IList<$type$> $capitalized_name$List {
\r\n
"
" get { return $name$_; }
\r\n
"
// note: unmodifiable list
"}
\r\n
"
"public int
get$capitalized_name$Count() { return $name$_.size();
}
\r\n
"
"public $type$
get
$capitalized_name$(int index) {
\r\n
"
" return $name$_
.get(index)
;
\r\n
"
"public int
$capitalized_name$Count { get { return $name$_.Count; }
}
\r\n
"
"public $type$ $capitalized_name$(int index) {
\r\n
"
" return $name$_
[index]
;
\r\n
"
"}
\r\n
"
);
}
...
...
@@ -193,48 +194,47 @@ GenerateBuilderMembers(io::Printer* printer) const {
// could hold on to the returned list and modify it after the message
// has been built, thus mutating the message which is supposed to be
// immutable.
"public java.util.List<$type$> get$capitalized_name$List() {
\r\n
"
" return java.util.Collections.unmodifiableList(result.$name$_);
\r\n
"
"public System.Collections.Generic.IList<$type$> Get$capitalized_name$List() {
\r\n
"
" if (result.$name$_ == $type$.Empty$capitalized_name$)
\r\n
"
" return result.$name$;
\r\n
"
" return result.$name$_.AsReadOnly ();
\r\n
"
"}
\r\n
"
"public int
g
et$capitalized_name$Count() {
\r\n
"
" return result.
g
et$capitalized_name$Count();
\r\n
"
"public int
G
et$capitalized_name$Count() {
\r\n
"
" return result.
G
et$capitalized_name$Count();
\r\n
"
"}
\r\n
"
"public $type$
g
et$capitalized_name$(int index) {
\r\n
"
" return result.
g
et$capitalized_name$(index);
\r\n
"
"public $type$
G
et$capitalized_name$(int index) {
\r\n
"
" return result.
G
et$capitalized_name$(index);
\r\n
"
"}
\r\n
"
"public Builder
s
et$capitalized_name$(int index, $type$ value) {
\r\n
"
" result.$name$_
.set(index, value)
;
\r\n
"
"public Builder
S
et$capitalized_name$(int index, $type$ value) {
\r\n
"
" result.$name$_
[index] = value
;
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
"public Builder
s
et$capitalized_name$(int index, "
"public Builder
S
et$capitalized_name$(int index, "
"$type$.Builder builderForValue) {
\r\n
"
" result.$name$_
.set(index, builderForValue.build()
);
\r\n
"
" result.$name$_
[index] = builderForValue.build(
);
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
"public Builder add$capitalized_name$($type$ value) {
\r\n
"
" if (result.$name$_.isEmpty()) {
\r\n
"
" result.$name$_ = new java.util.ArrayList<$type$>();
\r\n
"
" }
\r\n
"
" result.$name$_.add(value);
\r\n
"
"public Builder Add$capitalized_name$($type$ value) {
\r\n
"
" if (result.$name$ == $type$.Empty$capitalized_name$)
\r\n
"
" result.$name$ = new System.Collections.Generic.List<$type$>();
\r\n
"
" result.$name$_.Add(value);
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
"public Builder add$capitalized_name$($type$.Builder builderForValue) {
\r\n
"
" if (result.$name$_.isEmpty()) {
\r\n
"
" result.$name$_ = new java.util.ArrayList<$type$>();
\r\n
"
" }
\r\n
"
" result.$name$_.add(builderForValue.build());
\r\n
"
"public Builder Add$capitalized_name$($type$.Builder builderForValue) {
\r\n
"
" if (result.$name$ == $type$.Empty$capitalized_name$)
\r\n
"
" result.$name$ = new System.Collections.Generic.List<$type$>();
\r\n
"
" result.$name$_.Add(builderForValue.build());
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
"public Builder
a
ddAll$capitalized_name$<T>(
\r\n
"
"public Builder
A
ddAll$capitalized_name$<T>(
\r\n
"
" global::System.Collections.Generic.IEnumerable<T> values) where T : $type$ {
\r\n
"
" if (result.$name$_.isEmpty()) {
\r\n
"
" result.$name$_ = new java.util.ArrayList<$type$>();
\r\n
"
" }
\r\n
"
" super.addAll(values, result.$name$_);
\r\n
"
" if (result.$name$ == $type$.Empty$capitalized_name$)
\r\n
"
" result.$name$ = new System.Collections.Generic.List<$type$>();
\r\n
"
" result.$name$_.AddEnumerable (values);
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
"public Builder
c
lear$capitalized_name$() {
\r\n
"
" result.$name$_ =
java.util.Collections.emptyList()
;
\r\n
"
"public Builder
C
lear$capitalized_name$() {
\r\n
"
" result.$name$_ =
$type$.Empty$capitalized_name$
;
\r\n
"
" return this;
\r\n
"
"}
\r\n
"
);
}
...
...
@@ -242,20 +242,20 @@ GenerateBuilderMembers(io::Printer* printer) const {
void
RepeatedMessageFieldGenerator
::
GenerateMergingCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"if (!other.$name$_
.isEmpty()
) {
\r\n
"
" if (result.$name$_
.isEmpty()
) {
\r\n
"
" result.$name$_ = new
java.util.Array
List<$type$>();
\r\n
"
"if (!other.$name$_
!= $type$.Empty$capitalized_name$
) {
\r\n
"
" if (result.$name$_
== $type$.Empty$capitalized_name$
) {
\r\n
"
" result.$name$_ = new
System.Collections.Generic.
List<$type$>();
\r\n
"
" }
\r\n
"
" result.$name$_.
addAll
(other.$name$_);
\r\n
"
" result.$name$_.
AddCollection
(other.$name$_);
\r\n
"
"}
\r\n
"
);
}
void
RepeatedMessageFieldGenerator
::
GenerateBuildingCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"if (result.$name$_ !=
java.util.Collections.EMPTY_LIST
) {
\r\n
"
"if (result.$name$_ !=
$type$.Empty$capitalized_name$
) {
\r\n
"
" result.$name$_ =
\r\n
"
"
java.util.Collections.unmodifiableList(result.$name$_
);
\r\n
"
"
result.$name$_.AsReadOnly (
);
\r\n
"
"}
\r\n
"
);
}
...
...
@@ -273,13 +273,13 @@ GenerateParsingCode(io::Printer* printer) const {
}
printer
->
Print
(
variables_
,
"
a
dd$capitalized_name$(subBuilder.buildPartial());
\r\n
"
);
"
A
dd$capitalized_name$(subBuilder.buildPartial());
\r\n
"
);
}
void
RepeatedMessageFieldGenerator
::
GenerateSerializationCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"for
($type$ element : g
et$capitalized_name$List()) {
\r\n
"
"for
each ($type$ element in G
et$capitalized_name$List()) {
\r\n
"
" output.write$group_or_message$($number$, element);
\r\n
"
"}
\r\n
"
);
}
...
...
@@ -287,7 +287,7 @@ GenerateSerializationCode(io::Printer* printer) const {
void
RepeatedMessageFieldGenerator
::
GenerateSerializedSizeCode
(
io
::
Printer
*
printer
)
const
{
printer
->
Print
(
variables_
,
"for
($type$ element : g
et$capitalized_name$List()) {
\r\n
"
"for
each ($type$ element in G
et$capitalized_name$List()) {
\r\n
"
" size += pb::CodedOutputStream
\r\n
"
" .compute$group_or_message$Size($number$, element);
\r\n
"
"}
\r\n
"
);
...
...
src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
View file @
800f65e2
...
...
@@ -102,12 +102,11 @@ string DefaultValue(const FieldDescriptor* field) {
case
FieldDescriptor
:
:
CPPTYPE_INT32
:
return
SimpleItoa
(
field
->
default_value_int32
());
case
FieldDescriptor
:
:
CPPTYPE_UINT32
:
// Need to print as a signed int since Java has no unsigned.
return
SimpleItoa
(
static_cast
<
int32
>
(
field
->
default_value_uint32
()));
return
SimpleItoa
(
field
->
default_value_uint32
());
case
FieldDescriptor
:
:
CPPTYPE_INT64
:
return
SimpleItoa
(
field
->
default_value_int64
())
+
"L"
;
case
FieldDescriptor
:
:
CPPTYPE_UINT64
:
return
SimpleItoa
(
static_cast
<
int64
>
(
field
->
default_value_uint64
()
))
+
return
SimpleItoa
(
field
->
default_value_uint64
(
))
+
"L"
;
case
FieldDescriptor
:
:
CPPTYPE_DOUBLE
:
return
SimpleDtoa
(
field
->
default_value_double
())
+
"D"
;
...
...
src/google/protobuf/compiler/csharp/csharp_service.cc
View file @
800f65e2
...
...
@@ -211,7 +211,7 @@ void ServiceGenerator::GenerateStub(io::Printer* printer) {
" $output$.getDefaultInstance(),
\r\n
"
" pb::RpcUtil.generalizeCallback(
\r\n
"
" done,
\r\n
"
"
$output$.class
,
\r\n
"
"
typeof ($output$)
,
\r\n
"
" $output$.getDefaultInstance()));
\r\n
"
"}
\r\n
"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment