Commit af34538a authored by alien's avatar alien

Merge branch 'master' of https://github.com/google/protobuf into csharp_json_name

parents 6f8dd211 261ee021
...@@ -71,5 +71,14 @@ matrix: ...@@ -71,5 +71,14 @@ matrix:
# we moved to an OS X image that is 10.11. # we moved to an OS X image that is 10.11.
- os: osx - os: osx
env: CONFIG=python_cpp env: CONFIG=python_cpp
# xctool 0.2.8 seems to have a bug where it randomly kills tests saying
# they failed.
# https://github.com/facebook/xctool/issues/619
# https://github.com/google/protobuf/issues/1232
# travis updated their images to include 0.2.8:
# https://blog.travis-ci.com/2016-03-23-xcode-image-updates
# Mark the iOS test as flakey so these failures don't turn things red.
- os: osx
env: CONFIG=objectivec_ios
notifications: notifications:
email: false email: false
...@@ -194,6 +194,12 @@ RELATIVE_WELL_KNOWN_PROTOS = [ ...@@ -194,6 +194,12 @@ RELATIVE_WELL_KNOWN_PROTOS = [
WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
filegroup(
name = "well_known_protos",
srcs = WELL_KNOWN_PROTOS,
visibility = ["//visibility:public"],
)
cc_proto_library( cc_proto_library(
name = "cc_wkt_protos", name = "cc_wkt_protos",
srcs = WELL_KNOWN_PROTOS, srcs = WELL_KNOWN_PROTOS,
......
...@@ -951,16 +951,15 @@ public class JsonFormat { ...@@ -951,16 +951,15 @@ public class JsonFormat {
} }
} }
private static final String TYPE_URL_PREFIX = "type.googleapis.com";
private static String getTypeName(String typeUrl) private static String getTypeName(String typeUrl)
throws InvalidProtocolBufferException { throws InvalidProtocolBufferException {
String[] parts = typeUrl.split("/"); String[] parts = typeUrl.split("/");
if (parts.length != 2 || !parts[0].equals(TYPE_URL_PREFIX)) { if (parts.length == 1) {
throw new InvalidProtocolBufferException( throw new InvalidProtocolBufferException(
"Invalid type url found: " + typeUrl); "Invalid type url found: " + typeUrl);
} }
return parts[1]; return parts[parts.length - 1];
} }
private static class ParserImpl { private static class ParserImpl {
......
...@@ -556,6 +556,7 @@ static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) { ...@@ -556,6 +556,7 @@ static id GetArrayIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); id array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!array) { if (!array) {
// Check again after getting the lock. // Check again after getting the lock.
GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
array = GPBGetObjectIvarWithFieldNoAutocreate(self, field); array = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!array) { if (!array) {
...@@ -586,6 +587,7 @@ static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) { ...@@ -586,6 +587,7 @@ static id GetMapIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); id dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!dict) { if (!dict) {
// Check again after getting the lock. // Check again after getting the lock.
GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field); dict = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!dict) { if (!dict) {
...@@ -791,8 +793,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { ...@@ -791,8 +793,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if ((self = [super init])) { if ((self = [super init])) {
messageStorage_ = (GPBMessage_StoragePtr)( messageStorage_ = (GPBMessage_StoragePtr)(
((uint8_t *)self) + class_getInstanceSize([self class])); ((uint8_t *)self) + class_getInstanceSize([self class]));
readOnlySemaphore_ = dispatch_semaphore_create(1);
} }
return self; return self;
...@@ -868,7 +868,9 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { ...@@ -868,7 +868,9 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (void)dealloc { - (void)dealloc {
[self internalClear:NO]; [self internalClear:NO];
NSCAssert(!autocreator_, @"Autocreator was not cleared before dealloc."); NSCAssert(!autocreator_, @"Autocreator was not cleared before dealloc.");
if (readOnlySemaphore_) {
dispatch_release(readOnlySemaphore_); dispatch_release(readOnlySemaphore_);
}
[super dealloc]; [super dealloc];
} }
...@@ -1706,6 +1708,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { ...@@ -1706,6 +1708,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
} }
// Check for an autocreated value. // Check for an autocreated value.
GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(readOnlySemaphore_, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(readOnlySemaphore_, DISPATCH_TIME_FOREVER);
value = [autocreatedExtensionMap_ objectForKey:extension]; value = [autocreatedExtensionMap_ objectForKey:extension];
if (!value) { if (!value) {
...@@ -1917,7 +1920,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { ...@@ -1917,7 +1920,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
} }
} }
@catch (NSException *exception) { @catch (NSException *exception) {
[message release];
message = nil; message = nil;
if (errorPtr) { if (errorPtr) {
*errorPtr = MessageErrorWithReason(GPBMessageErrorCodeMalformedData, *errorPtr = MessageErrorWithReason(GPBMessageErrorCodeMalformedData,
...@@ -1926,7 +1928,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { ...@@ -1926,7 +1928,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
} }
#ifdef DEBUG #ifdef DEBUG
if (message && !message.initialized) { if (message && !message.initialized) {
[message release];
message = nil; message = nil;
if (errorPtr) { if (errorPtr) {
*errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil); *errorPtr = MessageError(GPBMessageErrorCodeMissingRequiredField, nil);
......
...@@ -67,6 +67,10 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr; ...@@ -67,6 +67,10 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// priority inversion: // priority inversion:
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/ // http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
// Use of readOnlySemaphore_ must be prefaced by a call to
// GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
// readOnlySemaphore_ to be only created when actually needed.
dispatch_once_t readOnlySemaphoreCreationOnce_;
dispatch_semaphore_t readOnlySemaphore_; dispatch_semaphore_t readOnlySemaphore_;
} }
...@@ -103,6 +107,14 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr; ...@@ -103,6 +107,14 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
CF_EXTERN_C_BEGIN CF_EXTERN_C_BEGIN
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
NS_INLINE void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
dispatch_once(&self->readOnlySemaphoreCreationOnce_, ^{
self->readOnlySemaphore_ = dispatch_semaphore_create(1);
});
}
// Returns a new instance that was automatically created by |autocreator| for // Returns a new instance that was automatically created by |autocreator| for
// its field |field|. // its field |field|.
GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass, GPBMessage *GPBCreateMessageWithAutocreator(Class msgClass,
......
...@@ -412,6 +412,7 @@ id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) { ...@@ -412,6 +412,7 @@ id GPBGetObjectIvarWithField(GPBMessage *self, GPBFieldDescriptor *field) {
return field.defaultValue.valueMessage; return field.defaultValue.valueMessage;
} }
GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(self->readOnlySemaphore_, DISPATCH_TIME_FOREVER);
GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field); GPBMessage *result = GPBGetObjectIvarWithFieldNoAutocreate(self, field);
if (!result) { if (!result) {
......
...@@ -1136,7 +1136,7 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) { ...@@ -1136,7 +1136,7 @@ inline void CodedOutputStream::WriteVarint32(uint32 value) {
// this write won't cross the end, so we can skip the checks. // this write won't cross the end, so we can skip the checks.
uint8* target = buffer_; uint8* target = buffer_;
uint8* end = WriteVarint32ToArray(value, target); uint8* end = WriteVarint32ToArray(value, target);
int size = end - target; int size = static_cast<int>(end - target);
Advance(size); Advance(size);
} else { } else {
WriteVarint32SlowPath(value); WriteVarint32SlowPath(value);
......
...@@ -171,13 +171,7 @@ internal_objectivec_common () { ...@@ -171,13 +171,7 @@ internal_objectivec_common () {
# http://docs.travis-ci.com/user/osx-ci-environment/ # http://docs.travis-ci.com/user/osx-ci-environment/
# We don't use a before_install because we test multiple OSes. # We don't use a before_install because we test multiple OSes.
brew update brew update
# xctool 0.2.8 seems to have a bug where it randomly kills tests saying brew outdated xctool || brew upgrade xctool
# they failed. Disabling the updates, but letting it report about being
# updates as a hint that this needs to eventually get re-enabled.
# https://github.com/facebook/xctool/issues/619
# https://github.com/google/protobuf/issues/1232
brew outdated xctool || true
#brew outdated xctool || brew upgrade xctool
# Reused the build script that takes care of configuring and ensuring things # Reused the build script that takes care of configuring and ensuring things
# are up to date. Xcode and conformance tests will be directly invoked. # are up to date. Xcode and conformance tests will be directly invoked.
objectivec/DevTools/full_mac_build.sh \ objectivec/DevTools/full_mac_build.sh \
......
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