Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): xcode 11 / ios 13 compatiility #325

Merged
merged 4 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions iphone/hooks/generate/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function getResultWrapper (state, json, obj, instance) {
return '';
}
case 'struct': {
name = getStructNameFromEncoding(obj.encoding) || name;
name = getStructNameFromEncoding(obj.encoding) || getStructNameFromEncoding(obj.type.encoding) || name;
if (name === '?') {
// TODO: Handle this property
return '';
Expand Down Expand Up @@ -497,8 +497,7 @@ function getObjCReturnType (value) {
return value.value || getPrimitiveValue(value.type);
}
console.log(value);
logger.error("cannot figure out objc return type", value);
process.exit(1);
throw new Error("cannot figure out objc return type");
}

function getObjCReturnResult (value, name, returns, asPointer) {
Expand Down Expand Up @@ -595,8 +594,7 @@ function getObjCReturnResult (value, name, returns, asPointer) {
}
}
console.log(value);
logger.error("cannot figure out objc return result", value);
process.exit(1);
throw new Error("cannot figure out objc return result");
}

function generateImport (name, fp) {
Expand Down
7 changes: 6 additions & 1 deletion iphone/src/pointer.m
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ -(NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
}

-(BOOL)isEqual:(id)obj {
if ([_object isKindOfClass:NSURLSessionConfiguration.class] && ![obj isKindOfClass:NSURLSessionConfiguration.class]) {
// iOS 13 bug, calling isEqual on NSURLSessionConfiguration with anything else
// then another NSURLSessionConfiguration instance causes a crash.
return false;
}
if ([_object isEqual:obj]) {
return YES;
} else if (_clazz == (Class)obj) {
Expand Down Expand Up @@ -581,7 +586,7 @@ -(type)name##Value { \
\
+(type)name##Value:(id) value{\
if (value && [value respondsToSelector:@selector(name##Value)]) {\
return [value name##Value];\
return [value name##Value];\
}\
return def;\
}\
Expand Down
8 changes: 8 additions & 0 deletions iphone/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,13 @@
*/
+(BOOL)booleanify:(id)val;

/**
* Performs isEqual with iOS 13 sanity checks.
*
* NSURLSessionConfiguration crashes when calling isEqual with anything else
* than another NSURLSessionConfiguration.
*/
+(BOOL)safeIsEqual:(id)value with:(id)other;

@end

17 changes: 13 additions & 4 deletions iphone/src/utils.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ +(id)unmarshalObject:(NSInvocation *)invocation arg:(id)arg index:(NSUInteger)in
#if defined(DEBUG_INVOKE) && DEBUG_INVOKE == 1
NSLog(@"[DEBUG] unmarshalObject %@ -> %@ at %zu", invocation, [arg class], index);
#endif
if (arg == nil || [arg isEqual:[NSNull null]]) {
if (arg == nil || [HyperloopUtils safeIsEqual:arg with:[NSNull null]]) {
if (invocation) {
arg = nil;
[invocation setArgument:&arg atIndex:index];
Expand Down Expand Up @@ -73,7 +73,7 @@ +(id)unmarshalObject:(NSInvocation *)invocation arg:(id)arg index:(NSUInteger)in
for (id key in [copy allKeys]) {
id obj = [copy objectForKey:key];
id newobj = [HyperloopUtils unmarshalObject:nil arg:obj index:0];
if ([obj isEqual:newobj] == NO) {
if ([HyperloopUtils safeIsEqual:obj with:newobj] == NO) {
[copy setObject:newobj forKey:key];
}
}
Expand Down Expand Up @@ -109,7 +109,7 @@ +(id)unmarshalObject:(NSInvocation *)invocation arg:(id)arg index:(NSUInteger)in
#define SETVALUE(c, typev, sel) \
case c: {\
typev value;\
if ([arg isEqual:[NSNull null]]) {\
if ([HyperloopUtils safeIsEqual:arg with:[NSNull null]]) {\
if (invocation) {\
[invocation setArgument:&arg atIndex:index];\
} else {\
Expand Down Expand Up @@ -197,7 +197,7 @@ +(id)unmarshalObject:(NSInvocation *)invocation arg:(id)arg index:(NSUInteger)in
case enc: {\
type __autoreleasing value = nil;\
[invocation getReturnValue:&value];\
if (!value) return value; \
if (!value) return value; \
if ([value isKindOfClass:[HyperloopPointer class]]) {\
result = (id)value;\
} else {\
Expand Down Expand Up @@ -452,4 +452,13 @@ +(id)invokeCustomCallback:(NSArray *)args identifier:(NSString *)identifier this
return result;
}

+(BOOL)safeIsEqual:(id)value with:(id)other
{
if ([value isKindOfClass:NSURLSessionConfiguration.class] && ![other isKindOfClass:NSURLSessionConfiguration.class]) {
return false;
}

return [value isEqual:other];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
24F555191BAD1F9200EC7113 /* function.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 24F555181BAD1F9200EC7113 /* function.cpp */; };
24F5551C1BAD27C800EC7113 /* struct.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 24F5551B1BAD27C800EC7113 /* struct.cpp */; };
24F5551F1BAE122500EC7113 /* union.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 24F5551E1BAE122500EC7113 /* union.cpp */; };
4A4A4E291F87C359009DE64F /* BlockParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A4A4E271F87C359009DE64F /* BlockParser.cpp */; };
4AF257FD232133FC00B88C4C /* block.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AF257FB232133FC00B88C4C /* block.cpp */; };
B626CE681B3E79A4000D2988 /* libclang.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B626CE671B3E79A4000D2988 /* libclang.dylib */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -90,8 +90,8 @@
24F5551B1BAD27C800EC7113 /* struct.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = struct.cpp; path = src/struct.cpp; sourceTree = SOURCE_ROOT; };
24F5551D1BAE122500EC7113 /* union.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = union.h; path = src/union.h; sourceTree = SOURCE_ROOT; };
24F5551E1BAE122500EC7113 /* union.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = union.cpp; path = src/union.cpp; sourceTree = SOURCE_ROOT; };
4A4A4E271F87C359009DE64F /* BlockParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = BlockParser.cpp; path = src/BlockParser.cpp; sourceTree = SOURCE_ROOT; };
4A4A4E281F87C359009DE64F /* BlockParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BlockParser.h; path = src/BlockParser.h; sourceTree = SOURCE_ROOT; };
4AF257FB232133FC00B88C4C /* block.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = block.cpp; path = src/block.cpp; sourceTree = SOURCE_ROOT; };
4AF257FC232133FC00B88C4C /* block.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = block.h; path = src/block.h; sourceTree = SOURCE_ROOT; };
B626CE381B3E77D0000D2988 /* hyperloop-metabase */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "hyperloop-metabase"; sourceTree = BUILT_PRODUCTS_DIR; };
B626CE671B3E79A4000D2988 /* libclang.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libclang.dylib; path = Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -147,6 +147,8 @@
B626CE3A1B3E77D0000D2988 /* src */ = {
isa = PBXGroup;
children = (
4AF257FB232133FC00B88C4C /* block.cpp */,
4AF257FC232133FC00B88C4C /* block.h */,
24F554FD1BAB906700EC7113 /* class.cpp */,
24F554FE1BAB906700EC7113 /* class.h */,
24F554FF1BAB906700EC7113 /* def.cpp */,
Expand Down Expand Up @@ -174,8 +176,6 @@
24F554FA1BAB906700EC7113 /* util.h */,
24F554FB1BAB906700EC7113 /* var.cpp */,
24F554FC1BAB906700EC7113 /* var.h */,
4A4A4E271F87C359009DE64F /* BlockParser.cpp */,
4A4A4E281F87C359009DE64F /* BlockParser.h */,
);
name = src;
path = "hyperloop-metabase";
Expand Down Expand Up @@ -240,7 +240,7 @@
B626CE301B3E77D0000D2988 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Appcelerator, Inc.";
TargetAttributes = {
24B035421BC4CAD600F3D9E5 = {
Expand All @@ -256,7 +256,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
English,
);
mainGroup = B626CE2F1B3E77D0000D2988;
productRefGroup = B626CE391B3E77D0000D2988 /* Products */;
Expand Down Expand Up @@ -310,10 +310,10 @@
24F555161BABD6D100EC7113 /* property.cpp in Sources */,
24F5550E1BAB906700EC7113 /* def.cpp in Sources */,
24F5550F1BAB906700EC7113 /* enum.cpp in Sources */,
4AF257FD232133FC00B88C4C /* block.cpp in Sources */,
24F5551C1BAD27C800EC7113 /* struct.cpp in Sources */,
24F5550C1BAB906700EC7113 /* var.cpp in Sources */,
24F5551F1BAE122500EC7113 /* union.cpp in Sources */,
4A4A4E291F87C359009DE64F /* BlockParser.cpp in Sources */,
24F5550A1BAB906700EC7113 /* typedef.cpp in Sources */,
24F555121BAB906700EC7113 /* method.cpp in Sources */,
24F5550B1BAB906700EC7113 /* util.cpp in Sources */,
Expand Down Expand Up @@ -360,17 +360,28 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -404,17 +415,28 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
Expand Down
31 changes: 15 additions & 16 deletions packages/hyperloop-ios-metabase/include/clang-c/BuildSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ extern "C" {
*/

/**
* \brief Return the timestamp for use with Clang's
* Return the timestamp for use with Clang's
* \c -fbuild-session-timestamp= option.
*/
CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void);

/**
* \brief Object encapsulating information about overlaying virtual
* Object encapsulating information about overlaying virtual
* file/directories over the real file system.
*/
typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay;

/**
* \brief Create a \c CXVirtualFileOverlay object.
* Create a \c CXVirtualFileOverlay object.
* Must be disposed with \c clang_VirtualFileOverlay_dispose().
*
* \param options is reserved, always pass 0.
Expand All @@ -49,7 +49,7 @@ CINDEX_LINKAGE CXVirtualFileOverlay
clang_VirtualFileOverlay_create(unsigned options);

/**
* \brief Map an absolute virtual file path to an absolute real one.
* Map an absolute virtual file path to an absolute real one.
* The virtual path must be canonicalized (not contain "."/"..").
* \returns 0 for success, non-zero to indicate an error.
*/
Expand All @@ -59,17 +59,17 @@ clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay,
const char *realPath);

/**
* \brief Set the case sensitivity for the \c CXVirtualFileOverlay object.
* Set the case sensitivity for the \c CXVirtualFileOverlay object.
* The \c CXVirtualFileOverlay object is case-sensitive by default, this
* option can be used to override the default.
* \returns 0 for success, non-zero to indicate an error.
*/
CINDEX_LINKAGE enum CXErrorCode
clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay,
int caseSensitive);
int caseSensitive);

/**
* \brief Write out the \c CXVirtualFileOverlay object to a char buffer.
* Write out the \c CXVirtualFileOverlay object to a char buffer.
*
* \param options is reserved, always pass 0.
* \param out_buffer_ptr pointer to receive the buffer pointer, which should be
Expand All @@ -83,25 +83,25 @@ clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options,
unsigned *out_buffer_size);

/**
* \brief free memory allocated by libclang, such as the buffer returned by
* free memory allocated by libclang, such as the buffer returned by
* \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer().
*
* \param buffer memory pointer to free.
*/
CINDEX_LINKAGE void clang_free(void *buffer);

/**
* \brief Dispose a \c CXVirtualFileOverlay object.
* Dispose a \c CXVirtualFileOverlay object.
*/
CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay);

/**
* \brief Object encapsulating information about a module.map file.
* Object encapsulating information about a module.map file.
*/
typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor;

/**
* \brief Create a \c CXModuleMapDescriptor object.
* Create a \c CXModuleMapDescriptor object.
* Must be disposed with \c clang_ModuleMapDescriptor_dispose().
*
* \param options is reserved, always pass 0.
Expand All @@ -110,23 +110,23 @@ CINDEX_LINKAGE CXModuleMapDescriptor
clang_ModuleMapDescriptor_create(unsigned options);

/**
* \brief Sets the framework module name that the module.map describes.
* Sets the framework module name that the module.map describes.
* \returns 0 for success, non-zero to indicate an error.
*/
CINDEX_LINKAGE enum CXErrorCode
clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor,
const char *name);

/**
* \brief Sets the umbrealla header name that the module.map describes.
* Sets the umbrealla header name that the module.map describes.
* \returns 0 for success, non-zero to indicate an error.
*/
CINDEX_LINKAGE enum CXErrorCode
clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor,
const char *name);

/**
* \brief Write out the \c CXModuleMapDescriptor object to a char buffer.
* Write out the \c CXModuleMapDescriptor object to a char buffer.
*
* \param options is reserved, always pass 0.
* \param out_buffer_ptr pointer to receive the buffer pointer, which should be
Expand All @@ -140,7 +140,7 @@ clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options,
unsigned *out_buffer_size);

/**
* \brief Dispose a \c CXModuleMapDescriptor object.
* Dispose a \c CXModuleMapDescriptor object.
*/
CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor);

Expand All @@ -153,4 +153,3 @@ CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor);
#endif

#endif /* CLANG_C_BUILD_SYSTEM_H */