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
5ac8de5b
Commit
5ac8de5b
authored
Apr 13, 2015
by
Jan Tattermusch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented HasRequiredFields logic
parent
db9060dc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
2 deletions
+37
-2
csharp_helpers.cc
src/google/protobuf/compiler/csharp/csharp_helpers.cc
+37
-2
No files found.
src/google/protobuf/compiler/csharp/csharp_helpers.cc
View file @
5ac8de5b
...
...
@@ -363,9 +363,44 @@ FieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor,
}
}
bool
HasRequiredFields
(
const
Descriptor
*
descriptor
,
std
::
set
<
const
Descriptor
*>*
already_seen
)
{
if
(
already_seen
->
find
(
descriptor
)
!=
already_seen
->
end
())
{
// The type is already in cache. This means that either:
// a. The type has no required fields.
// b. We are in the midst of checking if the type has required fields,
// somewhere up the stack. In this case, we know that if the type
// has any required fields, they'll be found when we return to it,
// and the whole call to HasRequiredFields() will return true.
// Therefore, we don't have to check if this type has required fields
// here.
return
false
;
}
already_seen
->
insert
(
descriptor
);
// If the type has extensions, an extension with message type could contain
// required fields, so we have to be conservative and assume such an
// extension exists.
if
(
descriptor
->
extension_count
()
>
0
)
{
return
true
;
}
for
(
int
i
=
0
;
i
<
descriptor
->
field_count
();
i
++
)
{
const
FieldDescriptor
*
field
=
descriptor
->
field
(
i
);
if
(
field
->
is_required
())
{
return
true
;
}
if
(
GetCSharpType
(
field
->
type
())
==
CSHARPTYPE_MESSAGE
)
{
if
(
HasRequiredFields
(
field
->
message_type
(),
already_seen
))
{
return
true
;
}
}
}
return
false
;
}
bool
HasRequiredFields
(
const
Descriptor
*
descriptor
)
{
// TODO(jtattermusch): implement HasRequiredFields logic.
return
true
;
std
::
set
<
const
Descriptor
*>
already_seen
;
return
HasRequiredFields
(
descriptor
,
&
already_seen
)
;
}
}
// namespace java
...
...
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