Ignore:
Timestamp:
Jun 14, 2017, 10:57:27 PM (8 years ago)
Author:
[email protected]
Message:

[Cocoa] Objective-C class whose name begins with an underscore can’t be exported to JavaScript
https://bugs.webkit.org/show_bug.cgi?id=168578

Reviewed by Geoff Garen.

  • API/JSWrapperMap.mm:

(allocateConstructorForCustomClass): Updated for change to forEachProtocolImplementingProtocol.
(-[JSObjCClassInfo allocateConstructorAndPrototype]): Ditto.
(-[JSWrapperMap classInfoForClass:]): If the class name begins with an underscore, check if

it defines conformance to a JSExport-derived protocol and if so, avoid using the
superclass as a substitute as we’d normally do.

  • API/ObjcRuntimeExtras.h:

(forEachProtocolImplementingProtocol): Added a "stop" argument to the block to let callers

bail out.

  • API/tests/JSExportTests.mm:

(+[JSExportTests classNamePrefixedWithUnderscoreTest]): New test for this.
(runJSExportTests): Run new test.

File:
1 edited

Legend:

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

    r185122 r218316  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4343}
    4444
    45 inline void forEachProtocolImplementingProtocol(Class cls, Protocol *target, void (^callback)(Protocol *))
     45inline void forEachProtocolImplementingProtocol(Class cls, Protocol *target, void (^callback)(Protocol *, bool& stop))
    4646{
    4747    ASSERT(cls);
     
    5757    free(protocols);
    5858
     59    bool stop = false;
    5960    while (!worklist.isEmpty()) {
    6061        Protocol *protocol = worklist.last();
     
    6667
    6768        // If it implements the protocol, make the callback.
    68         if (protocolImplementsProtocol(protocol, target))
    69             callback(protocol);
     69        if (protocolImplementsProtocol(protocol, target)) {
     70            callback(protocol, stop);
     71            if (stop)
     72                break;
     73        }
    7074
    7175        // Add incorporated protocols to the worklist.
Note: See TracChangeset for help on using the changeset viewer.