WebKit Bugzilla
Attachment 346966 Details for
Bug 188484
: [GLIB] Add symbol types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188484-20180812044833.patch (text/plain), 6.68 KB, created by
Yusuke Suzuki
on 2018-08-11 12:48:35 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-08-11 12:48:35 PDT
Size:
6.68 KB
patch
obsolete
>Subversion Revision: 234783 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 812ab3ef9b09f5797542dfc9e81527c4e05a8a19..61b17787d5feb1877856b39e8bd86fe17bdabaf5 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,18 @@ >+2018-08-11 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ [GLIB] Add symbol types >+ https://bugs.webkit.org/show_bug.cgi?id=188484 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In this patch, we first add symbol factory and predicate functions to glib JSC APIs. >+ >+ * API/glib/JSCValue.cpp: >+ (jsc_value_new_symbol): >+ (jsc_value_new_symbol_from_bytes): >+ (jsc_value_is_symbol): >+ * API/glib/JSCValue.h: >+ > 2018-08-10 Joseph Pecoraro <pecoraro@apple.com> > > Web Inspector: console.log fires getters for deep properties >diff --git a/Source/JavaScriptCore/API/glib/JSCValue.cpp b/Source/JavaScriptCore/API/glib/JSCValue.cpp >index 79e5316fd36293c8dd0233623bad03baa85d9c3b..7e851d174291b5090f6a19c71e2162404d135a33 100644 >--- a/Source/JavaScriptCore/API/glib/JSCValue.cpp >+++ b/Source/JavaScriptCore/API/glib/JSCValue.cpp >@@ -456,6 +456,68 @@ GBytes* jsc_value_to_string_as_bytes(JSCValue* value) > return g_bytes_new_with_free_func(string, stringSize - 1, fastFree, string); > } > >+/** >+ * jsc_value_new_symbol: >+ * @context: a #JSCContext >+ * @description: (nullable): a null-terminated string >+ * >+ * Create a new #JSCValue from @description. If you need to create a #JSCValue from a >+ * string containing null characters, use jsc_value_new_symbol_from_bytes() instead. >+ * >+ * Returns: (transfer full): a #JSCValue. >+ */ >+JSCValue* jsc_value_new_symbol(JSCContext* context, const char* description) >+{ >+ g_return_val_if_fail(JSC_IS_CONTEXT(context), nullptr); >+ >+ JSValueRef jsStringValue; >+ if (description) { >+ JSRetainPtr<JSStringRef> jsString(Adopt, JSStringCreateWithUTF8CString(description)); >+ jsStringValue = JSValueMakeSymbol(jscContextGetJSContext(context), jsString.get()); >+ } else >+ jsStringValue = JSValueMakeSymbol(jscContextGetJSContext(context), nullptr); >+ return jscContextGetOrCreateValue(context, jsStringValue).leakRef(); >+} >+ >+/** >+ * jsc_value_new_symbol_from_bytes: >+ * @context: a #JSCContext >+ * @bytes: (nullable): a #GBytes >+ * >+ * Create a new #JSCValue from @bytes. >+ * >+ * Returns: (transfer full): a #JSCValue. >+ */ >+JSCValue* jsc_value_new_symbol_from_bytes(JSCContext* context, GBytes* bytes) >+{ >+ g_return_val_if_fail(JSC_IS_CONTEXT(context), nullptr); >+ >+ if (!bytes) >+ return jsc_value_new_symbol(context, nullptr); >+ >+ gsize dataSize; >+ const auto* data = static_cast<const char*>(g_bytes_get_data(bytes, &dataSize)); >+ auto string = String::fromUTF8(data, dataSize); >+ JSRetainPtr<JSStringRef> jsString(Adopt, OpaqueJSString::create(WTFMove(string)).leakRef()); >+ return jscContextGetOrCreateValue(context, JSValueMakeSymbol(jscContextGetJSContext(context), jsString.get())).leakRef(); >+} >+ >+/** >+ * jsc_value_is_symbol: >+ * @value: a #JSCValue >+ * >+ * Get whether the value referenced by @value is a symbol >+ * >+ * Returns: whether the value is a symbol >+ */ >+gboolean jsc_value_is_symbol(JSCValue* value) >+{ >+ g_return_val_if_fail(JSC_IS_VALUE(value), FALSE); >+ >+ JSCValuePrivate* priv = value->priv; >+ return JSValueIsSymbol(jscContextGetJSContext(priv->context.get()), priv->jsValue); >+} >+ > /** > * jsc_value_new_array: (skip) > * @context: a #JSCContext >diff --git a/Source/JavaScriptCore/API/glib/JSCValue.h b/Source/JavaScriptCore/API/glib/JSCValue.h >index eb5f5fe13eb6f962b2211780c727b17c5eaa1af5..eb58837779651f78cbb222a8ce5af36ee6bc2e40 100644 >--- a/Source/JavaScriptCore/API/glib/JSCValue.h >+++ b/Source/JavaScriptCore/API/glib/JSCValue.h >@@ -121,6 +121,17 @@ jsc_value_to_string (JSCValue *value); > JSC_API GBytes * > jsc_value_to_string_as_bytes (JSCValue *value); > >+JSC_API JSCValue * >+jsc_value_new_symbol (JSCContext *context, >+ const char *description); >+ >+JSC_API JSCValue * >+jsc_value_new_symbol_from_bytes (JSCContext *context, >+ GBytes *bytes); >+ >+JSC_API gboolean >+jsc_value_is_symbol (JSCValue *value); >+ > JSC_API JSCValue * > jsc_value_new_array (JSCContext *context, > GType first_item_type, >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index cf2a4a57e25ccac46386d887f9696e18ce930765..a1a13fdee05d90671540401782a8f1487fb2bfaa 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,15 @@ >+2018-08-11 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ [GLIB] Add symbol types >+ https://bugs.webkit.org/show_bug.cgi?id=188484 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add tests for jsc_value_new_symbol, jsc_value_new_symbol_from_bytes, and jsc_value_is_symbol. >+ >+ * TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp: >+ (testJSCTypes): >+ > 2018-08-10 Daniel Bates <dabates@apple.com> > > webkit-patch setup-git-clone should set Git core editor to commit-log-editor >diff --git a/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp b/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp >index 4aca8e23e7850c4d2fb84c4704db2d551f3094d0..a23af624990856451e07730ef7e53197fd245e63 100644 >--- a/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp >+++ b/Tools/TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp >@@ -385,6 +385,25 @@ static void testJSCTypes() > checker.watch(result.get()); > g_assert_true(result.get() == value.get()); > >+ value = adoptGRef(jsc_value_new_symbol(context.get(), nullptr)); >+ checker.watch(value.get()); >+ g_assert_true(jsc_value_is_symbol(value.get())); >+ >+ value = adoptGRef(jsc_value_new_symbol(context.get(), "12.5")); >+ checker.watch(value.get()); >+ g_assert_true(jsc_value_is_symbol(value.get())); >+ >+ GString* expected = g_string_new("String"); >+ expected = g_string_append_c(expected, '\0'); >+ expected = g_string_append(expected, "With"); >+ expected = g_string_append_c(expected, '\0'); >+ expected = g_string_append(expected, "Null"); >+ GRefPtr<GBytes> expectedBytes = adoptGRef(g_string_free_to_bytes(expected)); >+ >+ value = adoptGRef(jsc_value_new_symbol_from_bytes(context.get(), expectedBytes.get())); >+ checker.watch(value.get()); >+ g_assert_true(jsc_value_is_symbol(value.get())); >+ > value = adoptGRef(jsc_value_new_array(context.get(), G_TYPE_NONE)); > checker.watch(value.get()); > g_assert_true(jsc_value_is_array(value.get()));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188484
:
346966
|
346969