Commit f9c5978f authored by kenton@google.com's avatar kenton@google.com

Hopefully fix build on Sun Studio.

parent c0ee4d2e
......@@ -35,6 +35,7 @@
#ifndef _WIN32
#include <errno.h>
#include <sys/wait.h>
#include <signal.h>
#endif
#include <algorithm>
......
......@@ -138,9 +138,9 @@ void ExtensionSet::RegisterEnumExtension(const MessageLite* containing_type,
EnumValidityFunc* is_valid) {
GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);
ExtensionInfo info(type, is_repeated, is_packed);
info.enum_is_valid = CallNoArgValidityFunc;
info.enum_validity_check.func = CallNoArgValidityFunc;
// See comment in CallNoArgValidityFunc() about why we use a c-style cast.
info.enum_is_valid_arg = (void*)is_valid;
info.enum_validity_check.arg = (void*)is_valid;
Register(containing_type, number, info);
}
......@@ -761,7 +761,8 @@ bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,
int value;
if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
input, &value)) return false;
if (extension.enum_is_valid(extension.enum_is_valid_arg, value)) {
if (extension.enum_validity_check.func(
extension.enum_validity_check.arg, value)) {
AddEnum(number, WireFormatLite::TYPE_ENUM, true, value,
extension.descriptor);
}
......@@ -814,7 +815,8 @@ bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,
if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
input, &value)) return false;
if (!extension.enum_is_valid(extension.enum_is_valid_arg, value)) {
if (!extension.enum_validity_check.func(
extension.enum_validity_check.arg, value)) {
// Invalid value. Treat as unknown.
field_skipper->SkipUnknownEnum(number, value);
} else if (extension.is_repeated) {
......
......@@ -99,9 +99,9 @@ struct ExtensionInfo {
union {
struct {
EnumValidityFuncWithArg* enum_is_valid;
const void* enum_is_valid_arg;
};
EnumValidityFuncWithArg* func;
const void* arg;
} enum_validity_check;
const MessageLite* message_prototype;
};
......
......@@ -175,8 +175,8 @@ bool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) {
<< "Extension factory's GetPrototype() returned NULL for extension: "
<< extension->full_name();
} else if (extension->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {
output->enum_is_valid = ValidateEnumUsingDescriptor;
output->enum_is_valid_arg = extension->enum_type();
output->enum_validity_check.func = ValidateEnumUsingDescriptor;
output->enum_validity_check.arg = extension->enum_type();
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment