Changeset 213737 in webkit


Ignore:
Timestamp:
Mar 10, 2017 4:58:42 PM (7 years ago)
Author:
Brent Fulgham
Message:

[Win] Re-export a few symbols for backwards compatibility
https://bugs.webkit.org/show_bug.cgi?id=169490
<rdar://problem/30983623>

Reviewed by Dean Jackson.

Re-introduce a workaround that re-exports a few JavaScriptCore functions
that had been erroneously exported by WebKit in older builds. This
is needed so that we do not break certain old software still being used.

  • WebKitDLL.cpp:

(DllMain): Bind functions at startup.
(bindJavaScriptTrampoline): Find JavaScriptCore library functions and
re-export them from WebKit.dll.

  • WebKitDLL.h: Only advertise these functions when building WebKt itself.
Location:
trunk/Source/WebKit/win
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/win/ChangeLog

    r213464 r213737  
     12017-03-10  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Win] Re-export a few symbols for backwards compatibility
     4        https://bugs.webkit.org/show_bug.cgi?id=169490
     5        <rdar://problem/30983623>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Re-introduce a workaround that re-exports a few JavaScriptCore functions
     10        that had been erroneously exported by WebKit in older builds. This
     11        is needed so that we do not break certain old software still being used.
     12
     13        * WebKitDLL.cpp:
     14        (DllMain): Bind functions at startup.
     15        (bindJavaScriptTrampoline): Find JavaScriptCore library functions and
     16        re-export them from WebKit.dll.
     17        * WebKitDLL.h: Only advertise these functions when building WebKt itself.
     18
    1192017-03-06  Myles C. Maxfield  <mmaxfield@apple.com>
    220
  • trunk/Source/WebKit/win/WebKitDLL.cpp

    r208505 r213737  
    11/*
    2  * Copyright (C) 2006, 2007, 2014-2015 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2017 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
     26#define DEPRECATED_EXPORT_SYMBOLS 1
    2627#include "WebKitDLL.h"
    2728
     
    6667}
    6768
     69void bindJavaScriptTrampoline();
    6870
    6971STDAPI_(BOOL) DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID /*lpReserved*/)
     
    7476            gInstance = hModule;
    7577            WebCore::setInstanceHandle(hModule);
     78            bindJavaScriptTrampoline();
    7679            return TRUE;
    7780
     
    220223    return WebCore::SharedBuffer::create(reinterpret_cast<const char*>(resource), size);
    221224}
     225
     226// Force symbols to be included so we can export them for legacy clients.
     227// DEPRECATED! People should get these symbols from JavaScriptCore.dll, not WebKit.dll!
     228// #include <JavaScriptCore/JSObjectRef.h>
     229
     230typedef JSClassRef (*JSClassCreateFunction)(const JSClassDefinition* definition);
     231typedef void* (*JSObjectGetPrivateFunction)(JSObjectRef);
     232typedef JSObjectRef (*JSObjectMakeFunctionStub)(JSContextRef, JSClassRef, void*);
     233typedef void (*JSObjectSetPropertyFunction)(JSContextRef, JSObjectRef, JSStringRef propertyName, JSValueRef, JSPropertyAttributes, JSValueRef* exception);
     234typedef JSStringRef (*JSStringCreateWithCFStringFunction)(CFStringRef);
     235typedef JSStringRef (*JSStringCreateWithUTF8CStringFunction)(const char*);
     236typedef const JSChar* (*JSStringGetCharactersPtrFunction)(JSStringRef);
     237typedef size_t (*JSStringGetLengthFunction)(JSStringRef);
     238typedef void (*JSStringReleaseFunction)(JSStringRef);
     239typedef bool (*JSValueIsTypeFunction)(JSContextRef, JSValueRef);
     240typedef JSValueRef(*JSValueMakeUndefinedFunction)(JSContextRef);
     241typedef double(*JSValueToNumberFunction)(JSContextRef, JSValueRef, JSValueRef* exception);
     242typedef JSValueRef(*JSValueMakeStringFunction)(JSContextRef, JSStringRef);
     243typedef JSStringRef (*JSValueToStringCopyFunction)(JSContextRef, JSValueRef, JSValueRef* exception);
     244
     245JSClassCreateFunction m_jsClassCreateFunction = nullptr;
     246JSObjectGetPrivateFunction m_jsObjectGetPrivateFunction = nullptr;
     247JSObjectMakeFunctionStub m_jsObjectMakeFunction = nullptr;
     248JSObjectSetPropertyFunction m_jsObjectSetPropertyFunction = nullptr;
     249JSStringCreateWithCFStringFunction m_jsStringCreateWithCFStringFunction = nullptr;
     250JSStringCreateWithUTF8CStringFunction m_jsStringCreateWithUTF8CStringFunction = nullptr;
     251JSStringGetCharactersPtrFunction m_jsStringGetCharactersPtrFunction = nullptr;
     252JSStringGetLengthFunction m_jsStringGetLengthFunction = nullptr;
     253JSStringReleaseFunction m_jsStringReleaseFunction = nullptr;
     254JSValueIsTypeFunction m_jsValueIsNumberFunction = nullptr;
     255JSValueIsTypeFunction m_jsValueIsStringFunction = nullptr;
     256JSValueMakeUndefinedFunction m_jsValueMakeUndefinedFunction = nullptr;
     257JSValueToNumberFunction m_jsValueToNumberFunction = nullptr;
     258JSValueMakeStringFunction m_jsValueMakeStringFunction = nullptr;
     259JSValueToStringCopyFunction m_jsValueToStringCopyFunction = nullptr;
     260
     261void bindJavaScriptTrampoline()
     262{
     263    const wchar_t* libraryName = L"JavaScriptCore.dll";
     264
     265    HMODULE library = ::LoadLibrary(libraryName);
     266    if (!library)
     267        return;
     268
     269    m_jsClassCreateFunction = reinterpret_cast<JSClassCreateFunction>(::GetProcAddress(library, "JSClassCreate"));
     270    m_jsObjectGetPrivateFunction = reinterpret_cast<JSObjectGetPrivateFunction>(::GetProcAddress(library, "JSObjectGetPrivate"));
     271    m_jsObjectMakeFunction = reinterpret_cast<JSObjectMakeFunctionStub>(::GetProcAddress(library, "JSObjectMake"));
     272    m_jsObjectSetPropertyFunction = reinterpret_cast<JSObjectSetPropertyFunction>(::GetProcAddress(library, "JSObjectSetProperty"));;
     273    m_jsStringCreateWithCFStringFunction = reinterpret_cast<JSStringCreateWithCFStringFunction>(::GetProcAddress(library, "JSStringCreateWithCFString"));
     274    m_jsStringCreateWithUTF8CStringFunction = reinterpret_cast<JSStringCreateWithUTF8CStringFunction>(::GetProcAddress(library, "JSStringCreateWithUTF8CString"));
     275    m_jsStringGetCharactersPtrFunction = reinterpret_cast<JSStringGetCharactersPtrFunction>(::GetProcAddress(library, "JSStringGetCharactersPtr"));
     276    m_jsStringGetLengthFunction = reinterpret_cast<JSStringGetLengthFunction>(::GetProcAddress(library, "JSStringGetLength"));
     277    m_jsStringReleaseFunction = reinterpret_cast<JSStringReleaseFunction>(::GetProcAddress(library, "JSStringRelease"));
     278    m_jsValueIsNumberFunction = reinterpret_cast<JSValueIsTypeFunction>(::GetProcAddress(library, "JSValueIsNumber"));
     279    m_jsValueIsStringFunction = reinterpret_cast<JSValueIsTypeFunction>(::GetProcAddress(library, "JSValueIsString"));
     280    m_jsValueMakeStringFunction = reinterpret_cast<JSValueMakeStringFunction>(::GetProcAddress(library, "JSValueMakeString"));
     281    m_jsValueMakeUndefinedFunction = reinterpret_cast<JSValueMakeUndefinedFunction>(::GetProcAddress(library, "JSValueMakeUndefined"));
     282    m_jsValueToNumberFunction = reinterpret_cast<JSValueToNumberFunction>(::GetProcAddress(library, "JSValueToNumber"));
     283    m_jsValueToStringCopyFunction = reinterpret_cast<JSValueToStringCopyFunction>(::GetProcAddress(library, "JSValueToStringCopy"));
     284}
     285
     286extern "C"
     287{
     288
     289JSClassRef JSClassCreate(const JSClassDefinition* definition)
     290{
     291    if (m_jsClassCreateFunction)
     292        return m_jsClassCreateFunction(definition);
     293    return nullptr;
     294}
     295
     296void* JSObjectGetPrivate(JSObjectRef object)
     297{
     298    if (m_jsObjectGetPrivateFunction)
     299        return m_jsObjectGetPrivateFunction(object);
     300    return nullptr;
     301}
     302
     303JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef classRef, void* data)
     304{
     305    if (m_jsObjectMakeFunction)
     306        return m_jsObjectMakeFunction(ctx, classRef, data);
     307    return nullptr;
     308}
     309
     310void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
     311{
     312    if (m_jsObjectSetPropertyFunction)
     313        m_jsObjectSetPropertyFunction(ctx, object, propertyName, value, attributes, exception);
     314}
     315
     316JSStringRef JSStringCreateWithCFString(CFStringRef value)
     317{
     318    if (m_jsStringCreateWithCFStringFunction)
     319        return m_jsStringCreateWithCFStringFunction(value);
     320    return nullptr;
     321}
     322
     323JSStringRef JSStringCreateWithUTF8CString(const char* value)
     324{
     325    if (m_jsStringCreateWithUTF8CStringFunction)
     326        return m_jsStringCreateWithUTF8CStringFunction(value);
     327    return nullptr;
     328}
     329
     330const JSChar* JSStringGetCharactersPtr(JSStringRef value)
     331{
     332    if (m_jsStringGetCharactersPtrFunction)
     333        return m_jsStringGetCharactersPtrFunction(value);
     334    return nullptr;
     335}
     336
     337size_t JSStringGetLength(JSStringRef value)
     338{
     339    if (m_jsStringGetLengthFunction)
     340        return m_jsStringGetLengthFunction(value);
     341    return 0;
     342}
     343
     344void JSStringRelease(JSStringRef value)
     345{
     346    if (m_jsStringReleaseFunction)
     347        return m_jsStringReleaseFunction(value);
     348}
     349
     350bool JSValueIsNumber(JSContextRef ctx, JSValueRef value)
     351{
     352    if (m_jsValueIsNumberFunction)
     353        return m_jsValueIsNumberFunction(ctx, value);
     354    return false;
     355}
     356
     357bool JSValueIsString(JSContextRef ctx, JSValueRef value)
     358{
     359    if (m_jsValueIsStringFunction)
     360        return m_jsValueIsStringFunction(ctx, value);
     361    return false;
     362}
     363
     364JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef value)
     365{
     366    if (m_jsValueMakeStringFunction)
     367        return m_jsValueMakeStringFunction(ctx, value);
     368    return nullptr;
     369}
     370
     371JSValueRef JSValueMakeUndefined(JSContextRef ctx)
     372{
     373    if (m_jsValueMakeUndefinedFunction)
     374        return m_jsValueMakeUndefinedFunction(ctx);
     375    return nullptr;
     376}
     377
     378double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
     379{
     380    if (m_jsValueToNumberFunction)
     381        return m_jsValueToNumberFunction(ctx, value, exception);
     382    return 0;
     383}
     384
     385JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
     386{
     387    if (m_jsValueToStringCopyFunction)
     388        return m_jsValueToStringCopyFunction(ctx, value, exception);
     389    return nullptr;
     390}
     391
     392}
  • trunk/Source/WebKit/win/WebKitDLL.h

    r180653 r213737  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2006-2017 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5757WEBKIT_API void shutDownWebKit();
    5858
     59#if defined(DEPRECATED_EXPORT_SYMBOLS)
     60
     61#include <JavaScriptCore/JSObjectRef.h>
     62
     63// Force symbols to be included so we can export them for legacy clients.
     64// DEPRECATED! People should get these symbols from JavaScriptCore.dll, not WebKit.dll!
     65typedef struct OpaqueJSClass* JSClassRef;
     66typedef const struct OpaqueJSContext* JSContextRef;
     67typedef const struct OpaqueJSValue* JSValueRef;
     68typedef struct OpaqueJSString* JSStringRef;
     69typedef wchar_t JSChar;
     70typedef unsigned JSPropertyAttributes;
     71
     72WEBKIT_API JSClassRef JSClassCreate(const JSClassDefinition*);
     73WEBKIT_API void* JSObjectGetPrivate(JSObjectRef);
     74WEBKIT_API JSObjectRef JSObjectMake(JSContextRef, JSClassRef, void*);
     75WEBKIT_API void JSObjectSetProperty(JSContextRef, JSObjectRef, JSStringRef propertyName, JSValueRef, JSPropertyAttributes, JSValueRef* exception);
     76WEBKIT_API JSStringRef JSStringCreateWithCFString(CFStringRef);
     77WEBKIT_API JSStringRef JSStringCreateWithUTF8CString(const char*);
     78WEBKIT_API const JSChar* JSStringGetCharactersPtr(JSStringRef);
     79WEBKIT_API size_t JSStringGetLength(JSStringRef);
     80WEBKIT_API void JSStringRelease(JSStringRef);
     81WEBKIT_API bool JSValueIsNumber(JSContextRef, JSValueRef);
     82WEBKIT_API bool JSValueIsString(JSContextRef, JSValueRef);
     83WEBKIT_API JSValueRef JSValueMakeString(JSContextRef, JSStringRef);
     84WEBKIT_API JSValueRef JSValueMakeUndefined(JSContextRef ctx);
     85WEBKIT_API double JSValueToNumber(JSContextRef, JSValueRef, JSValueRef*);
     86WEBKIT_API JSStringRef JSValueToStringCopy(JSContextRef, JSValueRef, JSValueRef* exception);
     87// End
     88#endif
     89
    5990#ifdef __cplusplus
    6091}
Note: See TracChangeset for help on using the changeset viewer.