Bug 116844 - Deleting static properties defined with the JSC API should work
Summary: Deleting static properties defined with the JSC API should work
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-27 14:11 PDT by Mark Hahnenberg
Modified: 2013-06-13 16:08 PDT (History)
1 user (show)

See Also:


Attachments
Patch (20.91 KB, patch)
2013-05-27 15:45 PDT, Mark Hahnenberg
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hahnenberg 2013-05-27 14:11:59 PDT
Currently it is impossible to delete static properties defined via the C API from API objects.
Comment 1 Mark Hahnenberg 2013-05-27 15:45:30 PDT
Created attachment 203013 [details]
Patch
Comment 2 Darin Adler 2013-05-27 15:54:48 PDT
Comment on attachment 203013 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=203013&action=review

> Source/JavaScriptCore/ChangeLog:21
> +        (JSC::::getOwnPropertySlot):

The script screws up parsing these function names. You should put in the JSCallbackObject part by hand if you are leaving these lines in.

> Source/JavaScriptCore/API/JSCallbackObject.h:82
> +        if (!m_deletedStaticProperties)
> +            return false;
> +        return m_deletedStaticProperties->contains(name);

I like to write these with && instead of an early return.
Comment 3 Darin Adler 2013-05-27 15:55:06 PDT
Is there a similar issue for the Objective-C API?
Comment 4 Mark Hahnenberg 2013-05-27 19:49:10 PDT
(In reply to comment #3)
> Is there a similar issue for the Objective-C API?

I don't think so. We don't really have a concept of static functions in the Objective-C API. All properties are real properties on the underlying JS wrapper objects. The accessors added to the JS wrappers for Objective-C @properties are set to be "configurable" which means they can be deleted.
Comment 5 Geoffrey Garen 2013-06-13 16:08:14 PDT
Comment on attachment 203013 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=203013&action=review

This patch will remove the *interface* for a static property in response to a delete request -- I don't think that's quite what our client wanted. They wanted an object that could implement a custom property, but store the backing for that property in normal object backing, and then use delete to remove it. Maybe we need to clear this up with them.

> Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:393
> +                    thisObject->m_callbackObjectData->deleteStaticProperty(name);
> +                    bool result = Parent::deleteProperty(thisObject, exec, propertyName);
> +                    ASSERT(result);
> +                    return result;

This isn't quite right. We should only call through to Parent::deleteProperty() if we did not find a static property to delete, and our return value should depend on whether we found anything to delete.

> Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:406
> +                    thisObject->m_callbackObjectData->deleteStaticProperty(name);
> +                    bool result = Parent::deleteProperty(thisObject, exec, propertyName);
> +                    ASSERT(result);
> +                    return result;

Ditto.