Ignore:
Timestamp:
May 8, 2017, 3:51:11 PM (8 years ago)
Author:
[email protected]
Message:

Expose a function to get proxy targets
https://bugs.webkit.org/show_bug.cgi?id=171797
<rdar://problem/32027549>

Reviewed by Mark Lam.

This exposes a new private API function, JSObjectGetProxyTarget(), that gets the target of a
proxy. It works with both ProxyObject and JSProxy, but it's primarily intended for use with
JSProxy.

  • API/JSObjectRef.cpp:

(JSObjectGetProxyTarget):

  • API/JSObjectRefPrivate.h:
  • API/tests/JSObjectGetProxyTargetTest.cpp: Added.

(testJSObjectGetProxyTarget):

  • API/tests/JSObjectGetProxyTargetTest.h: Added.
  • API/tests/testapi.c:

(main):

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/ProxyObject.h:
  • shell/PlatformWin.cmake:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSObjectRef.cpp

    r211247 r216460  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Kelvin W Sherlock ([email protected])
    44 *
     
    5353#include "ObjectPrototype.h"
    5454#include "PropertyNameArray.h"
     55#include "ProxyObject.h"
    5556#include "RegExpConstructor.h"
    5657
     
    676677    propertyNames->add(propertyName->identifier(propertyNames->vm()));
    677678}
     679
     680JSObjectRef JSObjectGetProxyTarget(JSObjectRef objectRef)
     681{
     682    JSObject* object = toJS(objectRef);
     683    if (!object)
     684        return nullptr;
     685    VM& vm = *object->vm();
     686    JSLockHolder locker(vm);
     687    JSObject* result = nullptr;
     688    if (JSProxy* proxy = jsDynamicCast<JSProxy*>(vm, object))
     689        result = proxy->target();
     690    else if (ProxyObject* proxy = jsDynamicCast<ProxyObject*>(vm, object))
     691        result = proxy->target();
     692    return toRef(result);
     693}
Note: See TracChangeset for help on using the changeset viewer.