[JSC API] We should support the symbol type in our C/Obj-C API
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2018 02:32:25 +0000 (02:32 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2018 02:32:25 +0000 (02:32 +0000)
commitf162f6516ebc352ae86daaf545e29c959860b78d
treec7b60fa77f9d08eb7940d49f17cd8a415107ebb1
parent1c8dff27569bfc5e08fcef50706e4309b528f4ac
[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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234227 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
Source/JavaScriptCore/API/APICast.h
Source/JavaScriptCore/API/JSBasePrivate.h
Source/JavaScriptCore/API/JSContext.h
Source/JavaScriptCore/API/JSContextPrivate.h
Source/JavaScriptCore/API/JSContextRef.h
Source/JavaScriptCore/API/JSContextRefInternal.h
Source/JavaScriptCore/API/JSContextRefPrivate.h
Source/JavaScriptCore/API/JSManagedValue.h
Source/JavaScriptCore/API/JSObjectRef.cpp
Source/JavaScriptCore/API/JSObjectRef.h
Source/JavaScriptCore/API/JSRemoteInspector.h
Source/JavaScriptCore/API/JSTypedArray.h
Source/JavaScriptCore/API/JSValue.h
Source/JavaScriptCore/API/JSValue.mm
Source/JavaScriptCore/API/JSValueRef.cpp
Source/JavaScriptCore/API/JSValueRef.h
Source/JavaScriptCore/API/WebKitAvailability.h
Source/JavaScriptCore/API/tests/CurrentThisInsideBlockGetterTest.mm
Source/JavaScriptCore/API/tests/CustomGlobalObjectClassTest.c
Source/JavaScriptCore/API/tests/DateTests.mm
Source/JavaScriptCore/API/tests/JSExportTests.mm
Source/JavaScriptCore/API/tests/JSNode.c
Source/JavaScriptCore/API/tests/JSNodeList.c
Source/JavaScriptCore/API/tests/Node.c
Source/JavaScriptCore/API/tests/NodeList.c
Source/JavaScriptCore/API/tests/minidom.c
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/API/tests/testapi.cpp [new file with mode: 0644]
Source/JavaScriptCore/API/tests/testapi.mm
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/config.h
Source/JavaScriptCore/postprocess-headers.sh
Source/JavaScriptCore/shell/CMakeLists.txt
Source/JavaScriptCore/testmem/testmem.mm