Ignore:
Timestamp:
Jul 1, 2018, 11:23:52 AM (7 years ago)
Author:
Darin Adler
Message:

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

Reviewed by Dan Bernstein.

Source/JavaScriptCore:

  • 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/ObjcRuntimeExtras.h

    r221723 r233409  
    4141{
    4242    unsigned protocolProtocolsCount;
    43     auto protocolProtocols = adoptSystem<Protocol*[]>(protocol_copyProtocolList(candidate, &protocolProtocolsCount));
     43    auto protocolProtocols = adoptSystem<__unsafe_unretained Protocol*[]>(protocol_copyProtocolList(candidate, &protocolProtocolsCount));
    4444    for (unsigned i = 0; i < protocolProtocolsCount; ++i) {
    4545        if (protocol_isEqual(protocolProtocols[i], target))
     
    6060    {
    6161        unsigned protocolsCount;
    62         auto protocols = adoptSystem<Protocol*[]>(class_copyProtocolList(cls, &protocolsCount));
     62        auto protocols = adoptSystem<__unsafe_unretained Protocol*[]>(class_copyProtocolList(cls, &protocolsCount));
    6363        worklist.append(protocols.get(), protocolsCount);
    6464    }
     
    7070
    7171        // Are we encountering this Protocol for the first time?
    72         if (!visited.add(protocol).isNewEntry)
     72        if (!visited.add((__bridge void*)protocol).isNewEntry)
    7373            continue;
    7474
     
    8383        {
    8484            unsigned protocolsCount;
    85             auto protocols = adoptSystem<Protocol*[]>(protocol_copyProtocolList(protocol, &protocolsCount));
     85            auto protocols = adoptSystem<__unsafe_unretained Protocol*[]>(protocol_copyProtocolList(protocol, &protocolsCount));
    8686            worklist.append(protocols.get(), protocolsCount);
    8787        }
Note: See TracChangeset for help on using the changeset viewer.