Ignore:
Timestamp:
Jul 25, 2018, 7:32:25 PM (7 years ago)
Author:
[email protected]
Message:

[JSC API] We should support the symbol type in our C/Obj-C API
https://bugs.webkit.org/show_bug.cgi?id=175836

Reviewed by Filip Pizlo.

This patch makes the following API additions:
1) Test if a JSValue/JSValueRef is a symbol via any of the methods API are able to test for the types of other JSValues.
2) Create a symbol on both APIs.
3) Get/Set/Delete/Define property now take ids in the Obj-C API.
4) Add Get/Set/Delete in the C API.

We can do 3 because it is both binary and source compatable with
the existing API. I added (4) because the current property access
APIs only have the ability to get Strings. It was possible to
merge symbols into JSStringRef but that felt confusing and exposes
implementation details of our engine. The new functions match the
same meaning that they have in JS, thus should be forward
compatible with any future language extensions.

Lastly, this patch adds the same availability preproccessing phase
in WebCore to JavaScriptCore, which enables TBA features for
testing on previous releases.

  • API/APICast.h:
  • API/JSBasePrivate.h:
  • API/JSContext.h:
  • API/JSContextPrivate.h:
  • API/JSContextRef.h:
  • API/JSContextRefInternal.h:
  • API/JSContextRefPrivate.h:
  • API/JSManagedValue.h:
  • API/JSObjectRef.cpp:

(JSObjectHasPropertyKey):
(JSObjectGetPropertyKey):
(JSObjectSetPropertyKey):
(JSObjectDeletePropertyKey):

  • API/JSObjectRef.h:
  • API/JSRemoteInspector.h:
  • API/JSTypedArray.h:
  • API/JSValue.h:
  • API/JSValue.mm:

(+[JSValue valueWithNewSymbolFromDescription:inContext:]):
(performPropertyOperation):
(-[JSValue valueForProperty:valueForProperty:]):
(-[JSValue setValue:forProperty:setValue:forProperty:]):
(-[JSValue deleteProperty:deleteProperty:]):
(-[JSValue hasProperty:hasProperty:]):
(-[JSValue defineProperty:descriptor:defineProperty:descriptor:]):
(-[JSValue isSymbol]):
(-[JSValue objectForKeyedSubscript:]):
(-[JSValue setObject:forKeyedSubscript:]):
(-[JSValue valueForProperty:]): Deleted.
(-[JSValue setValue:forProperty:]): Deleted.
(-[JSValue deleteProperty:]): Deleted.
(-[JSValue hasProperty:]): Deleted.
(-[JSValue defineProperty:descriptor:]): Deleted.

  • API/JSValueRef.cpp:

(JSValueGetType):
(JSValueIsSymbol):
(JSValueMakeSymbol):

  • API/JSValueRef.h:
  • API/WebKitAvailability.h:
  • API/tests/CurrentThisInsideBlockGetterTest.mm:
  • API/tests/CustomGlobalObjectClassTest.c:
  • API/tests/DateTests.mm:
  • API/tests/JSExportTests.mm:
  • API/tests/JSNode.c:
  • API/tests/JSNodeList.c:
  • API/tests/Node.c:
  • API/tests/NodeList.c:
  • API/tests/minidom.c:
  • API/tests/testapi.c:

(main):

  • API/tests/testapi.cpp: Added.

(APIString::APIString):
(APIString::~APIString):
(APIString::operator JSStringRef):
(APIContext::APIContext):
(APIContext::~APIContext):
(APIContext::operator JSGlobalContextRef):
(APIVector::APIVector):
(APIVector::~APIVector):
(APIVector::append):
(testCAPIViaCpp):
(TestAPI::evaluateScript):
(TestAPI::callFunction):
(TestAPI::functionReturnsTrue):
(TestAPI::check):
(TestAPI::checkJSAndAPIMatch):
(TestAPI::interestingObjects):
(TestAPI::interestingKeys):
(TestAPI::run):

  • API/tests/testapi.mm:

(testObjectiveCAPIMain):

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • config.h:
  • postprocess-headers.sh:
  • shell/CMakeLists.txt:
  • testmem/testmem.mm:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/config.h

    r224277 r234227  
    2424#endif
    2525
     26#define JSC_API_AVAILABLE(...)
     27// Use zero since it will be less than any possible version number.
     28#define JSC_MAC_VERSION_TBA 0
     29#define JSC_IOS_VERSION_TBA 0
     30
    2631#include "JSExportMacros.h"
    2732
Note: See TracChangeset for help on using the changeset viewer.