Title: [233409] trunk/Source
Revision
233409
Author
[email protected]
Date
2018-07-01 11:23:52 -0700 (Sun, 01 Jul 2018)

Log Message

[Cocoa] Improve ARC compatibility of more code in _javascript_Core
https://bugs.webkit.org/show_bug.cgi?id=186973

Reviewed by Dan Bernstein.

Source/_javascript_Core:

* API/JSContext.mm:
(WeakContextRef::WeakContextRef): Deleted.
(WeakContextRef::~WeakContextRef): Deleted.
(WeakContextRef::get): Deleted.
(WeakContextRef::set): Deleted.

* API/JSContextInternal.h: Removed unneeded header guards since this is
an Objective-C++ header. Removed unused WeakContextRef class. Removed declaration
of method -[JSContext initWithGlobalContextRef:] and JSContext property wrapperMap
since neither is used outside the class implementation.

* API/JSManagedValue.mm:
(-[JSManagedValue initWithValue:]): Use a bridging cast.
(-[JSManagedValue dealloc]): Ditto.
(-[JSManagedValue didAddOwner:]): Ditto.
(-[JSManagedValue didRemoveOwner:]): Ditto.
(JSManagedValueHandleOwner::isReachableFromOpaqueRoots): Ditto.
(JSManagedValueHandleOwner::finalize): Ditto.
* API/JSValue.mm:
(+[JSValue valueWithNewRegularExpressionFromPattern:flags:inContext:]): Ditto.
(+[JSValue valueWithNewErrorFromMessage:inContext:]): Ditto.
(-[JSValue valueForProperty:]): Ditto.
(-[JSValue setValue:forProperty:]): Ditto.
(-[JSValue deleteProperty:]): Ditto.
(-[JSValue hasProperty:]): Ditto.
(-[JSValue invokeMethod:withArguments:]): Ditto.
(valueToObjectWithoutCopy): Ditto. Also removed unneeded explicit type names.
(valueToArray): Ditto.
(valueToDictionary): Ditto.
(objectToValueWithoutCopy): Ditto.
(objectToValue): Ditto.
* API/JSVirtualMachine.mm:
(+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]): Ditto.
(+[JSVMWrapperCache wrapperForJSContextGroupRef:]): Ditto.
(-[JSVirtualMachine isOldExternalObject:]): Ditto.
(-[JSVirtualMachine addManagedReference:withOwner:]): Ditto.
(-[JSVirtualMachine removeManagedReference:withOwner:]): Ditto.
(-[JSVirtualMachine contextForGlobalContextRef:]): Ditto.
(-[JSVirtualMachine addContext:forGlobalContextRef:]): Ditto.
(scanExternalObjectGraph): Ditto.
(scanExternalRememberedSet): Ditto.
* API/JSWrapperMap.mm:
(makeWrapper): Ditto.
(-[JSObjCClassInfo wrapperForObject:inContext:]): Ditto.
(-[JSWrapperMap objcWrapperForJSValueRef:inContext:]): Ditto.
(tryUnwrapObjcObject): Ditto.
* API/ObjCCallbackFunction.mm:
(blockSignatureContainsClass): Ditto.
(objCCallbackFunctionForMethod): Switched from retain to CFRetain, but not
sure we will be keeping this the same way under ARC.
(objCCallbackFunctionForBlock): Use a bridging cast.

* API/ObjcRuntimeExtras.h:
(protocolImplementsProtocol): Use a more specific type that includes the
explicit __unsafe_unretained for copied protocol lists.
(forEachProtocolImplementingProtocol): Ditto.

* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::convertNSNullToNil): Added to replace the CONVERT_NSNULL_TO_NIL macro.
(Inspector::RemoteInspector::receivedSetupMessage): Use convertNSNullToNil.

* inspector/remote/cocoa/RemoteInspectorXPCConnection.mm: Moved the
CFXPCBridge SPI to a header named CFXPCBridgeSPI.h.
(auditTokenHasEntitlement): Deleted. Moved to Entitlements.h/cpp in WTF.
(Inspector::RemoteInspectorXPCConnection::handleEvent): Use WTF::hasEntitlement.
(Inspector::RemoteInspectorXPCConnection::sendMessage): Use a bridging cast.

Source/WebKit:

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::hasEntitlement): Use WTF::hasEntitlement.

* Shared/mac/SandboxUtilities.h: Removed connectedProcessHasEntitlement since
we can now use WTF::hasEntitlement instead.
* Shared/mac/SandboxUtilities.mm: Ditto.

* StorageProcess/ios/StorageProcessIOS.mm:
(WebKit::StorageProcess::parentProcessHasServiceWorkerEntitlement): Use
WTF::hasEntitlement.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::parentProcessHasServiceWorkerEntitlement): Ditto.

Source/WTF:

* WTF.xcodeproj/project.pbxproj: Added CFXPCBridgeSPI.h, fixed a few
other small problems in the project file, and let Xcode fix a few too.

* wtf/cocoa/Entitlements.h: Added hasEntitlement function with overloads
for an audit token and an XPC connection.
* wtf/cocoa/Entitlements.mm:
(WTF::hasEntitlement): Added, with overloads for a SecTask, an audit token,
and an XPC connection.
(WTF::processHasEntitlement): Refactored to use the function above.

* wtf/spi/cocoa/CFXPCBridgeSPI.h: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSContext.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/API/JSContext.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/JSContext.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -337,24 +337,4 @@
 
 @end
 
-WeakContextRef::WeakContextRef(JSContext *context)
-{
-    objc_initWeak(&m_weakContext, context);
-}
-
-WeakContextRef::~WeakContextRef()
-{
-    objc_destroyWeak(&m_weakContext);
-}
-
-JSContext * WeakContextRef::get()
-{
-    return objc_loadWeak(&m_weakContext);
-}
-
-void WeakContextRef::set(JSContext *context)
-{
-    objc_storeWeak(&m_weakContext, context);
-}
-
 #endif

Modified: trunk/Source/_javascript_Core/API/JSContextInternal.h (233408 => 233409)


--- trunk/Source/_javascript_Core/API/JSContextInternal.h	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/JSContextInternal.h	2018-07-01 18:23:52 UTC (rev 233409)
@@ -23,9 +23,6 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef JSContextInternal_h
-#define JSContextInternal_h
-
 #import <_javascript_Core/_javascript_Core.h>
 
 #if JSC_OBJC_API_ENABLED
@@ -33,7 +30,7 @@
 #import <_javascript_Core/JSContext.h>
 
 struct CallbackData {
-    CallbackData *next;
+    CallbackData* next;
     JSContext *context;
     JSValue *preservedException;
     JSValueRef calleeValue;
@@ -43,24 +40,10 @@
     NSArray *currentArguments;
 };
 
-class WeakContextRef {
-public:
-    WeakContextRef(JSContext * = nil);
-    ~WeakContextRef();
-
-    JSContext * get();
-    void set(JSContext *);
-
-private:
-    JSContext *m_weakContext;
-};
-
 @class JSWrapperMap;
 
 @interface JSContext(Internal)
 
-- (instancetype)initWithGlobalContextRef:(JSGlobalContextRef)context;
-
 - (void)notifyException:(JSValueRef)exception;
 - (JSValue *)valueFromNotifyException:(JSValueRef)exception;
 - (BOOL)boolFromNotifyException:(JSValueRef)exception;
@@ -71,10 +54,6 @@
 - (JSValue *)wrapperForObjCObject:(id)object;
 - (JSValue *)wrapperForJSObject:(JSValueRef)value;
 
-@property (readonly, retain) JSWrapperMap *wrapperMap;
-
 @end
 
 #endif
-
-#endif // JSContextInternal_h

Modified: trunk/Source/_javascript_Core/API/JSManagedValue.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/API/JSManagedValue.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/JSManagedValue.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -88,7 +88,7 @@
     JSC::ExecState* exec = toJS([value.context JSGlobalContextRef]);
     JSC::JSGlobalObject* globalObject = exec->lexicalGlobalObject();
     auto& owner = managedValueHandleOwner();
-    JSC::Weak<JSC::JSGlobalObject> weak(globalObject, &owner, self);
+    JSC::Weak<JSC::JSGlobalObject> weak(globalObject, &owner, (__bridge void*)self);
     m_globalObject.swap(weak);
 
     m_lock = &exec->vm().apiLock();
@@ -99,9 +99,9 @@
 
     JSC::JSValue jsValue = toJS(exec, [value JSValueRef]);
     if (jsValue.isObject())
-        m_weakValue.setObject(JSC::jsCast<JSC::JSObject*>(jsValue.asCell()), owner, self);
+        m_weakValue.setObject(JSC::jsCast<JSC::JSObject*>(jsValue.asCell()), owner, (__bridge void*)self);
     else if (jsValue.isString())
-        m_weakValue.setString(JSC::jsCast<JSC::JSString*>(jsValue.asCell()), owner, self);
+        m_weakValue.setString(JSC::jsCast<JSC::JSString*>(jsValue.asCell()), owner, (__bridge void*)self);
     else
         m_weakValue.setPrimitive(jsValue);
     return self;
@@ -113,7 +113,7 @@
     if (virtualMachine) {
         NSMapTable *copy = [m_owners copy];
         for (id owner in [copy keyEnumerator]) {
-            size_t count = reinterpret_cast<size_t>(NSMapGet(m_owners, owner));
+            size_t count = reinterpret_cast<size_t>(NSMapGet(m_owners, (__bridge void*)owner));
             while (count--)
                 [virtualMachine removeManagedReference:self withOwner:owner];
         }
@@ -127,23 +127,23 @@
 
 - (void)didAddOwner:(id)owner
 {
-    size_t count = reinterpret_cast<size_t>(NSMapGet(m_owners, owner));
-    NSMapInsert(m_owners, owner, reinterpret_cast<void*>(count + 1));
+    size_t count = reinterpret_cast<size_t>(NSMapGet(m_owners, (__bridge void*)owner));
+    NSMapInsert(m_owners, (__bridge void*)owner, reinterpret_cast<void*>(count + 1));
 }
 
 - (void)didRemoveOwner:(id)owner
 {
-    size_t count = reinterpret_cast<size_t>(NSMapGet(m_owners, owner));
+    size_t count = reinterpret_cast<size_t>(NSMapGet(m_owners, (__bridge void*)owner));
 
     if (!count)
         return;
 
     if (count == 1) {
-        NSMapRemove(m_owners, owner);
+        NSMapRemove(m_owners, (__bridge void*)owner);
         return;
     }
 
-    NSMapInsert(m_owners, owner, reinterpret_cast<void*>(count - 1));
+    NSMapInsert(m_owners, (__bridge void*)owner, reinterpret_cast<void*>(count - 1));
 }
 
 - (JSValue *)value
@@ -184,13 +184,13 @@
 
 bool JSManagedValueHandleOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor& visitor)
 {
-    JSManagedValue *managedValue = static_cast<JSManagedValue *>(context);
-    return visitor.containsOpaqueRoot(managedValue);
+    JSManagedValue *managedValue = (__bridge JSManagedValue *)context;
+    return visitor.containsOpaqueRoot((__bridge void*)managedValue);
 }
 
 void JSManagedValueHandleOwner::finalize(JSC::Handle<JSC::Unknown>, void* context)
 {
-    JSManagedValue *managedValue = static_cast<JSManagedValue *>(context);
+    JSManagedValue *managedValue = (__bridge JSManagedValue *)context;
     [managedValue disconnectValue];
 }
 

Modified: trunk/Source/_javascript_Core/API/JSValue.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/API/JSValue.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/JSValue.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -123,8 +123,8 @@
 
 + (JSValue *)valueWithNewRegularExpressionFromPattern:(NSString *)pattern flags:(NSString *)flags inContext:(JSContext *)context
 {
-    JSStringRef patternString = JSStringCreateWithCFString((CFStringRef)pattern);
-    JSStringRef flagsString = JSStringCreateWithCFString((CFStringRef)flags);
+    JSStringRef patternString = JSStringCreateWithCFString((__bridge CFStringRef)pattern);
+    JSStringRef flagsString = JSStringCreateWithCFString((__bridge CFStringRef)flags);
     JSValueRef arguments[2] = { JSValueMakeString([context JSGlobalContextRef], patternString), JSValueMakeString([context JSGlobalContextRef], flagsString) };
     JSStringRelease(patternString);
     JSStringRelease(flagsString);
@@ -134,7 +134,7 @@
 
 + (JSValue *)valueWithNewErrorFromMessage:(NSString *)message inContext:(JSContext *)context
 {
-    JSStringRef string = JSStringCreateWithCFString((CFStringRef)message);
+    JSStringRef string = JSStringCreateWithCFString((__bridge CFStringRef)message);
     JSValueRef argument = JSValueMakeString([context JSGlobalContextRef], string);
     JSStringRelease(string);
 
@@ -241,7 +241,7 @@
     if (exception)
         return [_context valueFromNotifyException:exception];
 
-    JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
+    JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);
     JSValueRef result = JSObjectGetProperty([_context JSGlobalContextRef], object, name, &exception);
     JSStringRelease(name);
     if (exception)
@@ -259,7 +259,7 @@
         return;
     }
 
-    JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
+    JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);
     JSObjectSetProperty([_context JSGlobalContextRef], object, name, objectToValue(_context, value), 0, &exception);
     JSStringRelease(name);
     if (exception) {
@@ -275,7 +275,7 @@
     if (exception)
         return [_context boolFromNotifyException:exception];
 
-    JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
+    JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);
     BOOL result = JSObjectDeleteProperty([_context JSGlobalContextRef], object, name, &exception);
     JSStringRelease(name);
     if (exception)
@@ -291,7 +291,7 @@
     if (exception)
         return [_context boolFromNotifyException:exception];
 
-    JSStringRef name = JSStringCreateWithCFString((CFStringRef)propertyName);
+    JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)propertyName);
     BOOL result = JSObjectHasProperty([_context JSGlobalContextRef], object, name);
     JSStringRelease(name);
     return result;
@@ -461,7 +461,7 @@
     if (exception)
         return [_context valueFromNotifyException:exception];
 
-    JSStringRef name = JSStringCreateWithCFString((CFStringRef)method);
+    JSStringRef name = JSStringCreateWithCFString((__bridge CFStringRef)method);
     JSValueRef function = JSObjectGetProperty([_context JSGlobalContextRef], thisObject, name, &exception);
     JSStringRelease(name);
     if (exception)
@@ -694,21 +694,21 @@
             ASSERT(JSValueIsUndefined(context, value));
             primitive = nil;
         }
-        return (JSContainerConvertor::Task){ value, primitive, ContainerNone };
+        return { value, primitive, ContainerNone };
     }
 
     JSObjectRef object = JSValueToObject(context, value, 0);
 
     if (id wrapped = tryUnwrapObjcObject(context, object))
-        return (JSContainerConvertor::Task){ object, wrapped, ContainerNone };
+        return { object, wrapped, ContainerNone };
 
     if (isDate(vm, object, context))
-        return (JSContainerConvertor::Task){ object, [NSDate dateWithTimeIntervalSince1970:JSValueToNumber(context, object, 0) / 1000.0], ContainerNone };
+        return { object, [NSDate dateWithTimeIntervalSince1970:JSValueToNumber(context, object, 0) / 1000.0], ContainerNone };
 
     if (isArray(vm, object, context))
-        return (JSContainerConvertor::Task){ object, [NSMutableArray array], ContainerArray };
+        return { object, [NSMutableArray array], ContainerArray };
 
-    return (JSContainerConvertor::Task){ object, [NSMutableDictionary dictionary], ContainerDictionary };
+    return { object, [NSMutableDictionary dictionary], ContainerDictionary };
 }
 
 static id containerValueToObject(JSGlobalContextRef context, JSContainerConvertor::Task task)
@@ -822,7 +822,7 @@
     }
 
     if (JSValueIsObject(context, value))
-        return containerValueToObject(context, (JSContainerConvertor::Task){ value, [NSMutableArray array], ContainerArray});
+        return containerValueToObject(context, { value, [NSMutableArray array], ContainerArray});
 
     JSC::JSLockHolder locker(toJS(context));
     if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) {
@@ -844,7 +844,7 @@
     }
 
     if (JSValueIsObject(context, value))
-        return containerValueToObject(context, (JSContainerConvertor::Task){ value, [NSMutableDictionary dictionary], ContainerDictionary});
+        return containerValueToObject(context, { value, [NSMutableDictionary dictionary], ContainerDictionary});
 
     JSC::JSLockHolder locker(toJS(context));
     if (!(JSValueIsNull(context, value) || JSValueIsUndefined(context, value))) {
@@ -925,49 +925,49 @@
     JSGlobalContextRef contextRef = [context JSGlobalContextRef];
 
     if (!object)
-        return (ObjcContainerConvertor::Task){ object, JSValueMakeUndefined(contextRef), ContainerNone };
+        return { object, JSValueMakeUndefined(contextRef), ContainerNone };
 
     if (!class_conformsToProtocol(object_getClass(object), getJSExportProtocol())) {
         if ([object isKindOfClass:[NSArray class]])
-            return (ObjcContainerConvertor::Task){ object, JSObjectMakeArray(contextRef, 0, NULL, 0), ContainerArray };
+            return { object, JSObjectMakeArray(contextRef, 0, NULL, 0), ContainerArray };
 
         if ([object isKindOfClass:[NSDictionary class]])
-            return (ObjcContainerConvertor::Task){ object, JSObjectMake(contextRef, 0, 0), ContainerDictionary };
+            return { object, JSObjectMake(contextRef, 0, 0), ContainerDictionary };
 
         if ([object isKindOfClass:[NSNull class]])
-            return (ObjcContainerConvertor::Task){ object, JSValueMakeNull(contextRef), ContainerNone };
+            return { object, JSValueMakeNull(contextRef), ContainerNone };
 
         if ([object isKindOfClass:[JSValue class]])
-            return (ObjcContainerConvertor::Task){ object, ((JSValue *)object)->m_value, ContainerNone };
+            return { object, ((JSValue *)object)->m_value, ContainerNone };
 
         if ([object isKindOfClass:[NSString class]]) {
-            JSStringRef string = JSStringCreateWithCFString((CFStringRef)object);
+            JSStringRef string = JSStringCreateWithCFString((__bridge CFStringRef)object);
             JSValueRef js = JSValueMakeString(contextRef, string);
             JSStringRelease(string);
-            return (ObjcContainerConvertor::Task){ object, js, ContainerNone };
+            return { object, js, ContainerNone };
         }
 
         if ([object isKindOfClass:[NSNumber class]]) {
             if (isNSBoolean(object))
-                return (ObjcContainerConvertor::Task){ object, JSValueMakeBoolean(contextRef, [object boolValue]), ContainerNone };
-            return (ObjcContainerConvertor::Task){ object, JSValueMakeNumber(contextRef, [object doubleValue]), ContainerNone };
+                return { object, JSValueMakeBoolean(contextRef, [object boolValue]), ContainerNone };
+            return { object, JSValueMakeNumber(contextRef, [object doubleValue]), ContainerNone };
         }
 
         if ([object isKindOfClass:[NSDate class]]) {
             JSValueRef argument = JSValueMakeNumber(contextRef, [object timeIntervalSince1970] * 1000.0);
             JSObjectRef result = JSObjectMakeDate(contextRef, 1, &argument, 0);
-            return (ObjcContainerConvertor::Task){ object, result, ContainerNone };
+            return { object, result, ContainerNone };
         }
 
         if ([object isKindOfClass:[JSManagedValue class]]) {
             JSValue *value = [static_cast<JSManagedValue *>(object) value];
             if (!value)
-                return (ObjcContainerConvertor::Task) { object, JSValueMakeUndefined(contextRef), ContainerNone };
-            return (ObjcContainerConvertor::Task){ object, value->m_value, ContainerNone };
+                return  { object, JSValueMakeUndefined(contextRef), ContainerNone };
+            return { object, value->m_value, ContainerNone };
         }
     }
 
-    return (ObjcContainerConvertor::Task){ object, valueInternalValue([context wrapperForObjCObject:object]), ContainerNone };
+    return { object, valueInternalValue([context wrapperForObjCObject:object]), ContainerNone };
 }
 
 JSValueRef objectToValue(JSContext *context, id object)
@@ -1000,7 +1000,7 @@
             NSDictionary *dictionary = (NSDictionary *)current.objc;
             for (id key in [dictionary keyEnumerator]) {
                 if ([key isKindOfClass:[NSString class]]) {
-                    JSStringRef propertyName = JSStringCreateWithCFString((CFStringRef)key);
+                    JSStringRef propertyName = JSStringCreateWithCFString((__bridge CFStringRef)key);
                     JSObjectSetProperty(contextRef, js, propertyName, convertor.convert([dictionary objectForKey:key]), 0, 0);
                     JSStringRelease(propertyName);
                 }

Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/API/JSVirtualMachine.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -70,13 +70,13 @@
 + (void)addWrapper:(JSVirtualMachine *)wrapper forJSContextGroupRef:(JSContextGroupRef)group
 {
     std::lock_guard<Lock> lock(wrapperCacheMutex);
-    NSMapInsert(wrapperCache(), group, wrapper);
+    NSMapInsert(wrapperCache(), group, (__bridge void*)wrapper);
 }
 
 + (JSVirtualMachine *)wrapperForJSContextGroupRef:(JSContextGroupRef)group
 {
     std::lock_guard<Lock> lock(wrapperCacheMutex);
-    return static_cast<JSVirtualMachine *>(NSMapGet(wrapperCache(), group));
+    return (__bridge JSVirtualMachine *)NSMapGet(wrapperCache(), group);
 }
 
 @end
@@ -154,7 +154,7 @@
 - (bool)isOldExternalObject:(id)object
 {
     JSC::VM* vm = toJS(m_group);
-    return vm->heap.collectorSlotVisitor().containsOpaqueRoot(object);
+    return vm->heap.collectorSlotVisitor().containsOpaqueRoot((__bridge void*)object);
 }
 
 - (void)addExternalRememberedObject:(id)object
@@ -187,11 +187,10 @@
         ownedObjects = [[NSMapTable alloc] initWithKeyOptions:weakIDOptions valueOptions:integerOptions capacity:1];
 
         [m_externalObjectGraph setObject:ownedObjects forKey:owner];
-        [ownedObjects release];
     }
 
-    size_t count = reinterpret_cast<size_t>(NSMapGet(ownedObjects, object));
-    NSMapInsert(ownedObjects, object, reinterpret_cast<void*>(count + 1));
+    size_t count = reinterpret_cast<size_t>(NSMapGet(ownedObjects, (__bridge void*)object));
+    NSMapInsert(ownedObjects, (__bridge void*)object, reinterpret_cast<void*>(count + 1));
 }
 
 - (void)removeManagedReference:(id)object withOwner:(id)owner
@@ -212,14 +211,14 @@
     if (!ownedObjects)
         return;
    
-    size_t count = reinterpret_cast<size_t>(NSMapGet(ownedObjects, object));
+    size_t count = reinterpret_cast<size_t>(NSMapGet(ownedObjects, (__bridge void*)object));
     if (count > 1) {
-        NSMapInsert(ownedObjects, object, reinterpret_cast<void*>(count - 1));
+        NSMapInsert(ownedObjects, (__bridge void*)object, reinterpret_cast<void*>(count - 1));
         return;
     }
     
     if (count == 1)
-        NSMapRemove(ownedObjects, object);
+        NSMapRemove(ownedObjects, (__bridge void*)object);
 
     if (![ownedObjects count]) {
         [m_externalObjectGraph removeObjectForKey:owner];
@@ -246,12 +245,12 @@
 
 - (JSContext *)contextForGlobalContextRef:(JSGlobalContextRef)globalContext
 {
-    return static_cast<JSContext *>(NSMapGet(m_contextCache, globalContext));
+    return (__bridge JSContext *)NSMapGet(m_contextCache, globalContext);
 }
 
 - (void)addContext:(JSContext *)wrapper forGlobalContextRef:(JSGlobalContextRef)globalContext
 {
-    NSMapInsert(m_contextCache, globalContext, wrapper);
+    NSMapInsert(m_contextCache, globalContext, (__bridge void*)wrapper);
 }
 
 - (Lock&)externalDataMutex
@@ -321,9 +320,9 @@
                 continue;
 
             auto appendOwnedObjects = [&] {
-                NSMapTable *ownedObjects = [externalObjectGraph objectForKey:static_cast<id>(nextRoot)];
+                NSMapTable *ownedObjects = [externalObjectGraph objectForKey:(__bridge id)nextRoot];
                 for (id ownedObject in ownedObjects)
-                    stack.append(static_cast<void*>(ownedObject));
+                    stack.append((__bridge void*)ownedObject);
             };
 
             if (lockAcquired)
@@ -356,7 +355,7 @@
             NSMapTable *ownedObjects = [externalObjectGraph objectForKey:key];
             bool lockAcquired = true;
             for (id ownedObject in ownedObjects)
-                scanExternalObjectGraph(vm, visitor, ownedObject, lockAcquired);
+                scanExternalObjectGraph(vm, visitor, (__bridge void*)ownedObject, lockAcquired);
         }
         [externalRememberedSet removeAllObjects];
     }

Modified: trunk/Source/_javascript_Core/API/JSWrapperMap.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/API/JSWrapperMap.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/JSWrapperMap.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -125,7 +125,7 @@
 
     ASSERT(jsClass);
     JSC::JSCallbackObject<JSC::JSAPIWrapperObject>* object = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->objcWrapperObjectStructure(), jsClass, 0);
-    object->setWrappedObject(wrappedObject);
+    object->setWrappedObject((__bridge void*)wrappedObject);
     if (JSC::JSObject* prototype = jsClass->prototype(exec))
         object->setPrototypeDirect(vm, prototype);
 
@@ -524,8 +524,8 @@
     JSC::VM& vm = exec->vm();
     JSC::JSLockHolder locker(vm);
 
-    JSC::JSCallbackObject<JSC::JSAPIWrapperObject>* wrapper = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::create(exec, exec->lexicalGlobalObject(), structure, m_classRef, 0);
-    wrapper->setWrappedObject(object);
+    auto wrapper = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::create(exec, exec->lexicalGlobalObject(), structure, m_classRef, 0);
+    wrapper->setWrappedObject((__bridge void*)object);
     return wrapper;
 }
 
@@ -644,10 +644,10 @@
 - (JSValue *)objcWrapperForJSValueRef:(JSValueRef)value inContext:context
 {
     ASSERT(toJSGlobalObject([context JSGlobalContextRef])->wrapperMap() == self);
-    JSValue *wrapper = static_cast<JSValue *>(NSMapGet(m_cachedObjCWrappers, value));
+    JSValue *wrapper = (__bridge JSValue *)NSMapGet(m_cachedObjCWrappers, value);
     if (!wrapper) {
         wrapper = [[[JSValue alloc] initWithValue:value inContext:context] autorelease];
-        NSMapInsert(m_cachedObjCWrappers, value, wrapper);
+        NSMapInsert(m_cachedObjCWrappers, value, (__bridge void*)wrapper);
     }
     return wrapper;
 }
@@ -664,7 +664,7 @@
     JSC::JSLockHolder locker(toJS(context));
     JSC::VM& vm = toJS(context)->vm();
     if (toJS(object)->inherits<JSC::JSCallbackObject<JSC::JSAPIWrapperObject>>(vm))
-        return (id)JSC::jsCast<JSC::JSAPIWrapperObject*>(toJS(object))->wrappedObject();
+        return (__bridge id)JSC::jsCast<JSC::JSAPIWrapperObject*>(toJS(object))->wrappedObject();
     if (id target = tryUnwrapConstructor(&vm, object))
         return target;
     return nil;

Modified: trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/ObjCCallbackFunction.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -603,7 +603,7 @@
 {
     static bool containsClass = ^{
         id block = ^(NSString *string){ return string; };
-        return _Block_has_signature(block) && strstr(_Block_signature(block), "NSString");
+        return _Block_has_signature((__bridge void*)block) && strstr(_Block_signature((__bridge void*)block), "NSString");
     }();
     return containsClass;
 }
@@ -677,18 +677,20 @@
 {
     NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[NSMethodSignature signatureWithObjCTypes:types]];
     [invocation setSelector:sel];
-    // We need to retain the target Class because m_invocation doesn't retain it by default (and we don't want it to).
-    // FIXME: What releases it?
-    if (!isInstanceMethod)
-        [invocation setTarget:[cls retain]];
+    if (!isInstanceMethod) {
+        [invocation setTarget:cls];
+        // We need to retain the target Class because m_invocation doesn't retain it by default (and we don't want it to).
+        // FIXME: What releases it?
+        CFRetain((__bridge CFTypeRef)cls);
+    }
     return objCCallbackFunctionForInvocation(context, invocation, isInstanceMethod ? CallbackInstanceMethod : CallbackClassMethod, isInstanceMethod ? cls : nil, _protocol_getMethodTypeEncoding(protocol, sel, YES, isInstanceMethod));
 }
 
 JSObjectRef objCCallbackFunctionForBlock(JSContext *context, id target)
 {
-    if (!_Block_has_signature(target))
+    if (!_Block_has_signature((__bridge void*)target))
         return nullptr;
-    const char* signature = _Block_signature(target);
+    const char* signature = _Block_signature((__bridge void*)target);
     NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[NSMethodSignature signatureWithObjCTypes:signature]];
 
     // We don't want to use -retainArguments because that leaks memory. Arguments 

Modified: trunk/Source/_javascript_Core/API/ObjcRuntimeExtras.h (233408 => 233409)


--- trunk/Source/_javascript_Core/API/ObjcRuntimeExtras.h	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/API/ObjcRuntimeExtras.h	2018-07-01 18:23:52 UTC (rev 233409)
@@ -40,7 +40,7 @@
 inline bool protocolImplementsProtocol(Protocol *candidate, Protocol *target)
 {
     unsigned protocolProtocolsCount;
-    auto protocolProtocols = adoptSystem<Protocol*[]>(protocol_copyProtocolList(candidate, &protocolProtocolsCount));
+    auto protocolProtocols = adoptSystem<__unsafe_unretained Protocol*[]>(protocol_copyProtocolList(candidate, &protocolProtocolsCount));
     for (unsigned i = 0; i < protocolProtocolsCount; ++i) {
         if (protocol_isEqual(protocolProtocols[i], target))
             return true;
@@ -59,7 +59,7 @@
     // Initially fill the worklist with the Class's protocols.
     {
         unsigned protocolsCount;
-        auto protocols = adoptSystem<Protocol*[]>(class_copyProtocolList(cls, &protocolsCount));
+        auto protocols = adoptSystem<__unsafe_unretained Protocol*[]>(class_copyProtocolList(cls, &protocolsCount));
         worklist.append(protocols.get(), protocolsCount);
     }
 
@@ -69,7 +69,7 @@
         worklist.removeLast();
 
         // Are we encountering this Protocol for the first time?
-        if (!visited.add(protocol).isNewEntry)
+        if (!visited.add((__bridge void*)protocol).isNewEntry)
             continue;
 
         // If it implements the protocol, make the callback.
@@ -82,7 +82,7 @@
         // Add incorporated protocols to the worklist.
         {
             unsigned protocolsCount;
-            auto protocols = adoptSystem<Protocol*[]>(protocol_copyProtocolList(protocol, &protocolsCount));
+            auto protocols = adoptSystem<__unsafe_unretained Protocol*[]>(protocol_copyProtocolList(protocol, &protocolsCount));
             worklist.append(protocols.get(), protocolsCount);
         }
     }

Modified: trunk/Source/_javascript_Core/ChangeLog (233408 => 233409)


--- trunk/Source/_javascript_Core/ChangeLog	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-07-01 18:23:52 UTC (rev 233409)
@@ -1,3 +1,77 @@
+2018-06-23  Darin Adler  <[email protected]>
+
+        [Cocoa] Improve ARC compatibility of more code in _javascript_Core
+        https://bugs.webkit.org/show_bug.cgi?id=186973
+
+        Reviewed by Dan Bernstein.
+
+        * API/JSContext.mm:
+        (WeakContextRef::WeakContextRef): Deleted.
+        (WeakContextRef::~WeakContextRef): Deleted.
+        (WeakContextRef::get): Deleted.
+        (WeakContextRef::set): Deleted.
+
+        * API/JSContextInternal.h: Removed unneeded header guards since this is
+        an Objective-C++ header. Removed unused WeakContextRef class. Removed declaration
+        of method -[JSContext initWithGlobalContextRef:] and JSContext property wrapperMap
+        since neither is used outside the class implementation.
+
+        * API/JSManagedValue.mm:
+        (-[JSManagedValue initWithValue:]): Use a bridging cast.
+        (-[JSManagedValue dealloc]): Ditto.
+        (-[JSManagedValue didAddOwner:]): Ditto.
+        (-[JSManagedValue didRemoveOwner:]): Ditto.
+        (JSManagedValueHandleOwner::isReachableFromOpaqueRoots): Ditto.
+        (JSManagedValueHandleOwner::finalize): Ditto.
+        * API/JSValue.mm:
+        (+[JSValue valueWithNewRegularExpressionFromPattern:flags:inContext:]): Ditto.
+        (+[JSValue valueWithNewErrorFromMessage:inContext:]): Ditto.
+        (-[JSValue valueForProperty:]): Ditto.
+        (-[JSValue setValue:forProperty:]): Ditto.
+        (-[JSValue deleteProperty:]): Ditto.
+        (-[JSValue hasProperty:]): Ditto.
+        (-[JSValue invokeMethod:withArguments:]): Ditto.
+        (valueToObjectWithoutCopy): Ditto. Also removed unneeded explicit type names.
+        (valueToArray): Ditto.
+        (valueToDictionary): Ditto.
+        (objectToValueWithoutCopy): Ditto.
+        (objectToValue): Ditto.
+        * API/JSVirtualMachine.mm:
+        (+[JSVMWrapperCache addWrapper:forJSContextGroupRef:]): Ditto.
+        (+[JSVMWrapperCache wrapperForJSContextGroupRef:]): Ditto.
+        (-[JSVirtualMachine isOldExternalObject:]): Ditto.
+        (-[JSVirtualMachine addManagedReference:withOwner:]): Ditto.
+        (-[JSVirtualMachine removeManagedReference:withOwner:]): Ditto.
+        (-[JSVirtualMachine contextForGlobalContextRef:]): Ditto.
+        (-[JSVirtualMachine addContext:forGlobalContextRef:]): Ditto.
+        (scanExternalObjectGraph): Ditto.
+        (scanExternalRememberedSet): Ditto.
+        * API/JSWrapperMap.mm:
+        (makeWrapper): Ditto.
+        (-[JSObjCClassInfo wrapperForObject:inContext:]): Ditto.
+        (-[JSWrapperMap objcWrapperForJSValueRef:inContext:]): Ditto.
+        (tryUnwrapObjcObject): Ditto.
+        * API/ObjCCallbackFunction.mm:
+        (blockSignatureContainsClass): Ditto.
+        (objCCallbackFunctionForMethod): Switched from retain to CFRetain, but not
+        sure we will be keeping this the same way under ARC.
+        (objCCallbackFunctionForBlock): Use a bridging cast.
+
+        * API/ObjcRuntimeExtras.h:
+        (protocolImplementsProtocol): Use a more specific type that includes the
+        explicit __unsafe_unretained for copied protocol lists.
+        (forEachProtocolImplementingProtocol): Ditto.
+
+        * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+        (Inspector::convertNSNullToNil): Added to replace the CONVERT_NSNULL_TO_NIL macro.
+        (Inspector::RemoteInspector::receivedSetupMessage): Use convertNSNullToNil.
+
+        * inspector/remote/cocoa/RemoteInspectorXPCConnection.mm: Moved the
+        CFXPCBridge SPI to a header named CFXPCBridgeSPI.h.
+        (auditTokenHasEntitlement): Deleted. Moved to Entitlements.h/cpp in WTF.
+        (Inspector::RemoteInspectorXPCConnection::handleEvent): Use WTF::hasEntitlement.
+        (Inspector::RemoteInspectorXPCConnection::sendMessage): Use a bridging cast.
+
 2018-06-30  Adam Barth  <[email protected]>
 
         Port _javascript_Core to OS(FUCHSIA)

Modified: trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorCocoa.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -59,15 +59,14 @@
             return;                                             \
     } while (0);
 
-#define CONVERT_NSNULL_TO_NIL(expr)          \
-    do {                                     \
-        if ([expr isEqual:[NSNull null]])    \
-            expr = nil;                      \
-    } while (0);
+namespace Inspector {
 
+static void convertNSNullToNil(__strong NSNumber *& number)
+{
+    if ([number isEqual:[NSNull null]])
+        number = nil;
+}
 
-namespace Inspector {
-
 static bool canAccessWebInspectorMachPort()
 {
     return !sandbox_check(getpid(), "mach-lookup", static_cast<enum sandbox_filter_type>(SANDBOX_FILTER_GLOBAL_NAME | SANDBOX_CHECK_NO_REPORT), WIRXPCMachPortName);
@@ -491,7 +490,7 @@
     BAIL_IF_UNEXPECTED_TYPE(sender, [NSString class]);
 
     NSNumber *automaticallyPauseNumber = userInfo[WIRAutomaticallyPause];
-    CONVERT_NSNULL_TO_NIL(automaticallyPauseNumber);
+    convertNSNullToNil(automaticallyPauseNumber);
     BAIL_IF_UNEXPECTED_TYPE_ALLOWING_NIL(automaticallyPauseNumber, [NSNumber class]);
     BOOL automaticallyPause = automaticallyPauseNumber.boolValue;
 

Modified: trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorXPCConnection.mm (233408 => 233409)


--- trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorXPCConnection.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/_javascript_Core/inspector/remote/cocoa/RemoteInspectorXPCConnection.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -34,36 +34,11 @@
 #import <wtf/Lock.h>
 #import <wtf/Ref.h>
 #import <wtf/RetainPtr.h>
+#import <wtf/cocoa/Entitlements.h>
+#import <wtf/spi/cocoa/CFXPCBridgeSPI.h>
 #import <wtf/spi/cocoa/SecuritySPI.h>
 #import <wtf/spi/darwin/XPCSPI.h>
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <CoreFoundation/CFXPCBridge.h>
-#else
-extern "C" {
-    xpc_object_t _CFXPCCreateXPCMessageWithCFObject(CFTypeRef);
-    CFTypeRef _CFXPCCreateCFObjectFromXPCMessage(xpc_object_t);
-}
-#endif
-
-#if PLATFORM(MAC)
-static bool auditTokenHasEntitlement(audit_token_t token, NSString *entitlement)
-{
-    auto task = adoptCF(SecTaskCreateWithAuditToken(kCFAllocatorDefault, token));
-    if (!task)
-        return false;
-
-    auto value = adoptCF(SecTaskCopyValueForEntitlement(task.get(), (CFStringRef)entitlement, nullptr));
-    if (!value)
-        return false;
-
-    if (CFGetTypeID(value.get()) != CFBooleanGetTypeID())
-        return false;
-
-    return CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()));
-}
-#endif
-
 namespace Inspector {
 
 // Constants private to this file for message serialization on both ends.
@@ -173,7 +148,7 @@
     if (!m_validated) {
         audit_token_t token;
         xpc_connection_get_audit_token(m_connection, &token);
-        if (!auditTokenHasEntitlement(token, @"com.apple.private.webinspector.webinspectord")) {
+        if (!WTF::hasEntitlement(token, "com.apple.private.webinspector.webinspectord")) {
             std::lock_guard<Lock> lock(m_mutex);
             // This will trigger one last XPC_ERROR_CONNECTION_INVALID event on the queue and deref us.
             closeOnQueue();
@@ -211,7 +186,7 @@
     if (userInfo)
         [dictionary setObject:userInfo forKey:RemoteInspectorXPCConnectionUserInfoKey];
 
-    xpc_object_t xpcDictionary = _CFXPCCreateXPCMessageWithCFObject((CFDictionaryRef)dictionary.get());
+    xpc_object_t xpcDictionary = _CFXPCCreateXPCMessageWithCFObject((__bridge CFDictionaryRef)dictionary.get());
     ASSERT_WITH_MESSAGE(xpcDictionary && xpc_get_type(xpcDictionary) == XPC_TYPE_DICTIONARY, "Unable to serialize xpc message");
     if (!xpcDictionary)
         return;

Modified: trunk/Source/WTF/ChangeLog (233408 => 233409)


--- trunk/Source/WTF/ChangeLog	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WTF/ChangeLog	2018-07-01 18:23:52 UTC (rev 233409)
@@ -1,3 +1,22 @@
+2018-06-23  Darin Adler  <[email protected]>
+
+        [Cocoa] Improve ARC compatibility of more code in _javascript_Core
+        https://bugs.webkit.org/show_bug.cgi?id=186973
+
+        Reviewed by Dan Bernstein.
+
+        * WTF.xcodeproj/project.pbxproj: Added CFXPCBridgeSPI.h, fixed a few
+        other small problems in the project file, and let Xcode fix a few too.
+
+        * wtf/cocoa/Entitlements.h: Added hasEntitlement function with overloads
+        for an audit token and an XPC connection.
+        * wtf/cocoa/Entitlements.mm:
+        (WTF::hasEntitlement): Added, with overloads for a SecTask, an audit token,
+        and an XPC connection.
+        (WTF::processHasEntitlement): Refactored to use the function above.
+
+        * wtf/spi/cocoa/CFXPCBridgeSPI.h: Added.
+
 2018-06-30  Adam Barth  <[email protected]>
 
         Port _javascript_Core to OS(FUCHSIA)

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (233408 => 233409)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2018-07-01 18:23:52 UTC (rev 233409)
@@ -44,7 +44,7 @@
 		0FEC3C5E1F368A9700F59B6C /* ReadWriteLock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FEC3C5C1F368A9700F59B6C /* ReadWriteLock.cpp */; };
 		0FFF19DC1BB334EB00886D91 /* ParallelHelperPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFF19DA1BB334EB00886D91 /* ParallelHelperPool.cpp */; };
 		14022F4118F5C3FC007FF0EB /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14022F4018F5C3FC007FF0EB /* libbmalloc.a */; };
-		143DDE9620C8BC37007F76FA /* Entitlements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143DDE9520C8BC37007F76FA /* Entitlements.cpp */; };
+		143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */ = {isa = PBXBuildFile; fileRef = 143DDE9520C8BC37007F76FA /* Entitlements.mm */; };
 		143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; };
 		1447AEC618FCE57700B3D7FF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1447AEC518FCE57700B3D7FF /* Foundation.framework */; };
 		1447AEC718FCE58000B3D7FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D247B6214689B8600E78B76 /* libWTF.a */; };
@@ -271,7 +271,7 @@
 		0FFF19DB1BB334EB00886D91 /* ParallelHelperPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallelHelperPool.h; sourceTree = "<group>"; };
 		132743924FC54E469F5A8E6E /* StdUnorderedSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdUnorderedSet.h; sourceTree = "<group>"; };
 		14022F4018F5C3FC007FF0EB /* libbmalloc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libbmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
-		143DDE9520C8BC37007F76FA /* Entitlements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Entitlements.cpp; sourceTree = "<group>"; };
+		143DDE9520C8BC37007F76FA /* Entitlements.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Entitlements.mm; sourceTree = "<group>"; };
 		143DDE9720C8BE99007F76FA /* Entitlements.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entitlements.h; sourceTree = "<group>"; };
 		143F611D1565F0F900DB514A /* RAMSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RAMSize.cpp; sourceTree = "<group>"; };
 		143F611E1565F0F900DB514A /* RAMSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAMSize.h; sourceTree = "<group>"; };
@@ -315,9 +315,9 @@
 		1C181C8D1D307AB800F5FA16 /* UTextProviderUTF16.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UTextProviderUTF16.cpp; sourceTree = "<group>"; };
 		1C181C8E1D307AB800F5FA16 /* UTextProviderUTF16.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTextProviderUTF16.h; sourceTree = "<group>"; };
 		1C181C951D30800A00F5FA16 /* TextBreakIteratorInternalICUCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBreakIteratorInternalICUCocoa.cpp; sourceTree = "<group>"; };
-		1CCDB1491E566626006C73C0 /* TextBreakIteratorCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextBreakIteratorCF.h; path = cf/TextBreakIteratorCF.h; sourceTree = "<group>"; };
+		1CCDB1491E566626006C73C0 /* TextBreakIteratorCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBreakIteratorCF.h; sourceTree = "<group>"; };
 		1CCDB14D1E566898006C73C0 /* TextBreakIteratorICU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBreakIteratorICU.h; sourceTree = "<group>"; };
-		1CCDB1511E566BC5006C73C0 /* CFStringSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFStringSPI.h; path = cf/CFStringSPI.h; sourceTree = "<group>"; };
+		1CCDB1511E566BC5006C73C0 /* CFStringSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringSPI.h; sourceTree = "<group>"; };
 		1FA47C88152502DA00568D1B /* WebCoreThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreThread.cpp; sourceTree = "<group>"; };
 		1FA47C89152502DA00568D1B /* WebCoreThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThread.h; sourceTree = "<group>"; };
 		24F1B248619F412296D1C19C /* RandomDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomDevice.h; sourceTree = "<group>"; };
@@ -407,8 +407,9 @@
 		83FBA93119DF459700F30ADB /* TypeCasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCasts.h; sourceTree = "<group>"; };
 		86F46F5F1A2840EE00CCBF22 /* RefCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RefCounter.h; sourceTree = "<group>"; };
 		933D63191FCB6AB90032ECD6 /* StringHasher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHasher.h; sourceTree = "<group>"; };
+		9384B73E20DEA284005B73B2 /* CFXPCBridgeSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFXPCBridgeSPI.h; sourceTree = "<group>"; };
 		93934BD218A1E8C300D0D6A1 /* StringViewCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringViewCocoa.mm; sourceTree = "<group>"; };
-		93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringViewCF.cpp; path = cf/StringViewCF.cpp; sourceTree = "<group>"; };
+		93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringViewCF.cpp; sourceTree = "<group>"; };
 		93AC91A718942FC400244939 /* LChar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LChar.h; sourceTree = "<group>"; };
 		93D191CF20CAECE800C51B8E /* FoundationSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FoundationSPI.h; sourceTree = "<group>"; };
 		93DDE9311CDC052D00FD3491 /* dyldSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dyldSPI.h; sourceTree = "<group>"; };
@@ -428,9 +429,9 @@
 		A561F30F1DF2642100FF675D /* DeprecatedOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeprecatedOptional.h; sourceTree = "<group>"; };
 		A5BA15F2182433A900A82E69 /* StringMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = StringMac.mm; path = ../mac/StringMac.mm; sourceTree = "<group>"; };
 		A5BA15F41824348000A82E69 /* StringImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringImplCocoa.mm; sourceTree = "<group>"; };
-		A5BA15F7182435A600A82E69 /* AtomicStringImplCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AtomicStringImplCF.cpp; path = cf/AtomicStringImplCF.cpp; sourceTree = "<group>"; };
-		A5BA15F8182435A600A82E69 /* StringCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringCF.cpp; path = cf/StringCF.cpp; sourceTree = "<group>"; };
-		A5BA15F9182435A600A82E69 /* StringImplCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringImplCF.cpp; path = cf/StringImplCF.cpp; sourceTree = "<group>"; };
+		A5BA15F7182435A600A82E69 /* AtomicStringImplCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomicStringImplCF.cpp; sourceTree = "<group>"; };
+		A5BA15F8182435A600A82E69 /* StringCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringCF.cpp; sourceTree = "<group>"; };
+		A5BA15F9182435A600A82E69 /* StringImplCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringImplCF.cpp; sourceTree = "<group>"; };
 		A70DA0821799F04D00529A9B /* Insertion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Insertion.h; sourceTree = "<group>"; };
 		A70DA0831799F04D00529A9B /* ListDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListDump.h; sourceTree = "<group>"; };
 		A748744F17A0BDAE00FA04CB /* SixCharacterHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SixCharacterHash.cpp; sourceTree = "<group>"; };
@@ -610,7 +611,7 @@
 		CD7600FF1F90A3CA00026E26 /* UnsafePointer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnsafePointer.h; sourceTree = "<group>"; };
 		CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMapTableSPI.h; sourceTree = "<group>"; };
 		CE73E02419DCB7AB00580D5C /* XPCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCSPI.h; sourceTree = "<group>"; };
-		DCEE21FA1CEA7538000C2396 /* CFBundleSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFBundleSPI.h; path = cf/CFBundleSPI.h; sourceTree = "<group>"; };
+		DCEE21FA1CEA7538000C2396 /* CFBundleSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFBundleSPI.h; sourceTree = "<group>"; };
 		DCEE21FC1CEA7551000C2396 /* BlockObjCExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockObjCExceptions.h; sourceTree = "<group>"; };
 		DCEE21FD1CEA7551000C2396 /* BlockObjCExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockObjCExceptions.mm; sourceTree = "<group>"; };
 		DCEE22041CEB9869000C2396 /* BackwardsGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackwardsGraph.h; sourceTree = "<group>"; };
@@ -788,7 +789,7 @@
 				93934BD418A1F16900D0D6A1 /* StringViewCF.cpp */,
 				1CCDB1491E566626006C73C0 /* TextBreakIteratorCF.h */,
 			);
-			name = cf;
+			path = cf;
 			sourceTree = "<group>";
 		};
 		A876DBD6151816E500DADB95 /* wtf */ = {
@@ -1274,6 +1275,7 @@
 		CE46516C19DB1FB4003ECA05 /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				9384B73E20DEA284005B73B2 /* CFXPCBridgeSPI.h */,
 				93D191CF20CAECE800C51B8E /* FoundationSPI.h */,
 				CE46516D19DB1FB4003ECA05 /* NSMapTableSPI.h */,
 				A5098B011C16A4F900087797 /* SecuritySPI.h */,
@@ -1308,7 +1310,7 @@
 				DCEE21FA1CEA7538000C2396 /* CFBundleSPI.h */,
 				1CCDB1511E566BC5006C73C0 /* CFStringSPI.h */,
 			);
-			name = cf;
+			path = cf;
 			sourceTree = "<group>";
 		};
 		E43A46851E228B5700276B05 /* persistence */ = {
@@ -1330,8 +1332,8 @@
 			children = (
 				1469419B16EAB10A0024E146 /* AutodrainedPool.cpp */,
 				E38C41241EB4E04C0042957D /* CPUTimeCocoa.cpp */,
-				143DDE9520C8BC37007F76FA /* Entitlements.cpp */,
 				143DDE9720C8BE99007F76FA /* Entitlements.h */,
+				143DDE9520C8BC37007F76FA /* Entitlements.mm */,
 				7A6EBA3320746C34004F9C44 /* MachSendRight.cpp */,
 				ADF2CE651E39F106006889DB /* MemoryFootprintCocoa.cpp */,
 				AD89B6B91E64150F0090707F /* MemoryPressureHandlerCocoa.mm */,
@@ -1483,7 +1485,7 @@
 				A8A473AE151A825B004123FF /* diy-fp.cc in Sources */,
 				A8A473B0151A825B004123FF /* double-conversion.cc in Sources */,
 				A8A473BA151A825B004123FF /* dtoa.cpp in Sources */,
-				143DDE9620C8BC37007F76FA /* Entitlements.cpp in Sources */,
+				143DDE9620C8BC37007F76FA /* Entitlements.mm in Sources */,
 				A8A473B3151A825B004123FF /* fast-dtoa.cc in Sources */,
 				0F7C5FB61D885CF20044F5E2 /* FastBitVector.cpp in Sources */,
 				A8A473C3151A825B004123FF /* FastMalloc.cpp in Sources */,
@@ -1547,8 +1549,8 @@
 				A5BA15FB182435A600A82E69 /* StringCF.cpp in Sources */,
 				A8A47440151A825B004123FF /* StringImpl.cpp in Sources */,
 				A5BA15FC182435A600A82E69 /* StringImplCF.cpp in Sources */,
+				A5BA15F51824348000A82E69 /* StringImplCocoa.mm in Sources */,
 				A5BA15F3182433A900A82E69 /* StringMac.mm in Sources */,
-				A5BA15F51824348000A82E69 /* StringImplCocoa.mm in Sources */,
 				0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */,
 				93F1993E19D7958D00C2390B /* StringView.cpp in Sources */,
 				93934BD518A1F16900D0D6A1 /* StringViewCF.cpp in Sources */,

Deleted: trunk/Source/WTF/wtf/cocoa/Entitlements.cpp (233408 => 233409)


--- trunk/Source/WTF/wtf/cocoa/Entitlements.cpp	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WTF/wtf/cocoa/Entitlements.cpp	2018-07-01 18:23:52 UTC (rev 233409)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Entitlements.h"
-
-#include <wtf/RetainPtr.h>
-#include <wtf/spi/cocoa/SecuritySPI.h>
-
-namespace WTF {
-
-bool processHasEntitlement(const char* entitlement)
-{
-    auto task = adoptCF(SecTaskCreateFromSelf(kCFAllocatorDefault));
-    if (!task)
-        return false;
-
-    auto cfEntitlement = adoptCF(CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, entitlement, kCFStringEncodingUTF8, kCFAllocatorNull));
-    auto value = adoptCF(SecTaskCopyValueForEntitlement(task.get(), cfEntitlement.get(), nullptr));
-    if (!value)
-        return false;
-
-    if (CFGetTypeID(value.get()) != CFBooleanGetTypeID())
-        return false;
-
-    return CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()));
-}
-
-} // namespace WTF

Modified: trunk/Source/WTF/wtf/cocoa/Entitlements.h (233408 => 233409)


--- trunk/Source/WTF/wtf/cocoa/Entitlements.h	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WTF/wtf/cocoa/Entitlements.h	2018-07-01 18:23:52 UTC (rev 233409)
@@ -25,8 +25,12 @@
 
 #if PLATFORM(COCOA)
 
+#include <wtf/spi/darwin/XPCSPI.h>
+
 namespace WTF {
 
+WTF_EXPORT bool hasEntitlement(audit_token_t, const char* entitlement);
+WTF_EXPORT bool hasEntitlement(xpc_connection_t, const char* entitlement);
 WTF_EXPORT bool processHasEntitlement(const char* entitlement);
 
 } // namespace WTF

Copied: trunk/Source/WTF/wtf/cocoa/Entitlements.mm (from rev 233408, trunk/Source/WTF/wtf/cocoa/Entitlements.cpp) (0 => 233409)


--- trunk/Source/WTF/wtf/cocoa/Entitlements.mm	                        (rev 0)
+++ trunk/Source/WTF/wtf/cocoa/Entitlements.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Entitlements.h"
+
+#include <wtf/OSObjectPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/spi/cocoa/SecuritySPI.h>
+
+namespace WTF {
+
+static bool hasEntitlement(SecTaskRef task, const char* entitlement)
+{
+    if (!task)
+        return false;
+    auto string = adoptCF(CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, entitlement, kCFStringEncodingASCII, kCFAllocatorNull));
+    auto value = adoptCF(SecTaskCopyValueForEntitlement(task, string.get(), nullptr));
+    return value && CFGetTypeID(value.get()) == CFBooleanGetTypeID() && CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()));
+}
+
+bool hasEntitlement(audit_token_t token, const char* entitlement)
+{
+    return hasEntitlement(adoptCF(SecTaskCreateWithAuditToken(kCFAllocatorDefault, token)).get(), entitlement);
+}
+
+bool hasEntitlement(xpc_connection_t connection, const char *entitlement)
+{
+    auto value = adoptOSObject(xpc_connection_copy_entitlement_value(connection, entitlement));
+    return value && xpc_get_type(value.get()) == XPC_TYPE_BOOL && xpc_bool_get_value(value.get());
+}
+
+bool processHasEntitlement(const char* entitlement)
+{
+    return hasEntitlement(adoptCF(SecTaskCreateFromSelf(kCFAllocatorDefault)).get(), entitlement);
+}
+
+} // namespace WTF

Property changes: trunk/Source/WTF/wtf/cocoa/Entitlements.mm


Added: svn:eol-style

+native \ No newline at end of property

Added: trunk/Source/WTF/wtf/spi/cocoa/CFXPCBridgeSPI.h (0 => 233409)


--- trunk/Source/WTF/wtf/spi/cocoa/CFXPCBridgeSPI.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/spi/cocoa/CFXPCBridgeSPI.h	2018-07-01 18:23:52 UTC (rev 233409)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <CoreFoundation/CFXPCBridge.h>
+#endif
+
+WTF_EXTERN_C_BEGIN
+
+xpc_object_t _CFXPCCreateXPCMessageWithCFObject(CFTypeRef);
+CFTypeRef _CFXPCCreateCFObjectFromXPCMessage(xpc_object_t);
+
+WTF_EXTERN_C_END

Modified: trunk/Source/WebKit/ChangeLog (233408 => 233409)


--- trunk/Source/WebKit/ChangeLog	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WebKit/ChangeLog	2018-07-01 18:23:52 UTC (rev 233409)
@@ -1,3 +1,23 @@
+2018-06-23  Darin Adler  <[email protected]>
+
+        [Cocoa] Improve ARC compatibility of more code in _javascript_Core
+        https://bugs.webkit.org/show_bug.cgi?id=186973
+
+        Reviewed by Dan Bernstein.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceInitializerDelegate::hasEntitlement): Use WTF::hasEntitlement.
+
+        * Shared/mac/SandboxUtilities.h: Removed connectedProcessHasEntitlement since
+        we can now use WTF::hasEntitlement instead.
+        * Shared/mac/SandboxUtilities.mm: Ditto.
+
+        * StorageProcess/ios/StorageProcessIOS.mm:
+        (WebKit::StorageProcess::parentProcessHasServiceWorkerEntitlement): Use
+        WTF::hasEntitlement.
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::parentProcessHasServiceWorkerEntitlement): Ditto.
+
 2018-06-30  David Kilzer  <[email protected]>
 
         Fix clang static analyzer warnings: Garbage return value

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (233408 => 233409)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -29,6 +29,7 @@
 #import "SandboxUtilities.h"
 #import "XPCServiceEntryPoint.h"
 #import <WebCore/Process.h>
+#import <wtf/cocoa/Entitlements.h>
 
 using namespace WebCore;
 
@@ -140,11 +141,7 @@
 
 bool XPCServiceInitializerDelegate::hasEntitlement(const char* entitlement)
 {
-    auto value = adoptOSObject(xpc_connection_copy_entitlement_value(m_connection.get(), entitlement));
-    if (!value)
-        return false;
-
-    return xpc_get_type(value.get()) == XPC_TYPE_BOOL && xpc_bool_get_value(value.get());
+    return WTF::hasEntitlement(m_connection.get(), entitlement);
 }
 
 bool XPCServiceInitializerDelegate::isClientSandboxed()

Modified: trunk/Source/WebKit/Shared/mac/SandboxUtilities.h (233408 => 233409)


--- trunk/Source/WebKit/Shared/mac/SandboxUtilities.h	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WebKit/Shared/mac/SandboxUtilities.h	2018-07-01 18:23:52 UTC (rev 233409)
@@ -38,6 +38,4 @@
 // Returns an empty string if the process is not in a container.
 String pathForProcessContainer();
 
-bool connectedProcessHasEntitlement(xpc_connection_t, const char *entitlement);
-
 }

Modified: trunk/Source/WebKit/Shared/mac/SandboxUtilities.mm (233408 => 233409)


--- trunk/Source/WebKit/Shared/mac/SandboxUtilities.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WebKit/Shared/mac/SandboxUtilities.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -29,7 +29,6 @@
 #import <array>
 #import <sys/param.h>
 #import <wtf/OSObjectPtr.h>
-#import <wtf/cocoa/Entitlements.h>
 #import <wtf/spi/darwin/SandboxSPI.h>
 #import <wtf/spi/darwin/XPCSPI.h>
 #import <wtf/text/WTFString.h>
@@ -77,13 +76,4 @@
     return String::fromUTF8(path.data());
 }
 
-bool connectedProcessHasEntitlement(xpc_connection_t connection, const char *entitlement)
-{
-    auto value = adoptOSObject(xpc_connection_copy_entitlement_value(connection, entitlement));
-    if (!value)
-        return false;
-
-    return xpc_get_type(value.get()) == XPC_TYPE_BOOL && xpc_bool_get_value(value.get());
 }
-
-}

Modified: trunk/Source/WebKit/StorageProcess/ios/StorageProcessIOS.mm (233408 => 233409)


--- trunk/Source/WebKit/StorageProcess/ios/StorageProcessIOS.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WebKit/StorageProcess/ios/StorageProcessIOS.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -30,13 +30,8 @@
 #import "StorageProcess.h"
 
 #import "SandboxInitializationParameters.h"
-#import "SandboxUtilities.h"
-#import <WebCore/FileSystem.h>
-#import <WebCore/LocalizedStrings.h>
-#import <WebCore/NotImplemented.h>
+#import <wtf/cocoa/Entitlements.h>
 
-using namespace WebCore;
-
 #define ENABLE_MANUAL_DATABASE_SANDBOXING 0
 
 namespace WebKit {
@@ -61,7 +56,7 @@
 
 bool StorageProcess::parentProcessHasServiceWorkerEntitlement() const
 {
-    static bool hasEntitlement = connectedProcessHasEntitlement(parentProcessConnection()->xpcConnection(), "com.apple.developer.WebKit.ServiceWorkers");
+    static bool hasEntitlement = WTF::hasEntitlement(parentProcessConnection()->xpcConnection(), "com.apple.developer.WebKit.ServiceWorkers");
     return hasEntitlement;
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (233408 => 233409)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-07-01 06:52:34 UTC (rev 233408)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-07-01 18:23:52 UTC (rev 233409)
@@ -113,6 +113,7 @@
 #import <wtf/MemoryPressureHandler.h>
 #import <wtf/SetForScope.h>
 #import <wtf/SoftLinking.h>
+#import <wtf/cocoa/Entitlements.h>
 #import <wtf/text/TextStream.h>
 
 #if ENABLE(MEDIA_STREAM)
@@ -399,7 +400,7 @@
 
 bool WebPage::parentProcessHasServiceWorkerEntitlement() const
 {
-    static bool hasEntitlement = connectedProcessHasEntitlement(WebProcess::singleton().parentProcessConnection()->xpcConnection(), "com.apple.developer.WebKit.ServiceWorkers");
+    static bool hasEntitlement = WTF::hasEntitlement(WebProcess::singleton().parentProcessConnection()->xpcConnection(), "com.apple.developer.WebKit.ServiceWorkers");
     return hasEntitlement;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to