Title: [213737] trunk/Source/WebKit/win
Revision
213737
Author
bfulg...@apple.com
Date
2017-03-10 16:58:42 -0800 (Fri, 10 Mar 2017)

Log 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 _javascript_Core 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 _javascript_Core library functions and
re-export them from WebKit.dll.
* WebKitDLL.h: Only advertise these functions when building WebKt itself.

Modified Paths

Diff

Modified: trunk/Source/WebKit/win/ChangeLog (213736 => 213737)


--- trunk/Source/WebKit/win/ChangeLog	2017-03-11 00:46:44 UTC (rev 213736)
+++ trunk/Source/WebKit/win/ChangeLog	2017-03-11 00:58:42 UTC (rev 213737)
@@ -1,3 +1,21 @@
+2017-03-10  Brent Fulgham  <bfulg...@apple.com>
+
+        [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 _javascript_Core 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 _javascript_Core library functions and
+        re-export them from WebKit.dll.
+        * WebKitDLL.h: Only advertise these functions when building WebKt itself.
+
 2017-03-06  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Expand font-weight and font-stretch to take any number

Modified: trunk/Source/WebKit/win/WebKitDLL.cpp (213736 => 213737)


--- trunk/Source/WebKit/win/WebKitDLL.cpp	2017-03-11 00:46:44 UTC (rev 213736)
+++ trunk/Source/WebKit/win/WebKitDLL.cpp	2017-03-11 00:58:42 UTC (rev 213737)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2014-2015 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,6 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
+#define DEPRECATED_EXPORT_SYMBOLS 1
 #include "WebKitDLL.h"
 
 #if USE(CG)
@@ -65,6 +66,7 @@
     return gClassNameCount.get();
 }
 
+void bindJavaScriptTrampoline();
 
 STDAPI_(BOOL) DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID /*lpReserved*/)
 {
@@ -73,6 +75,7 @@
             gLockCount = gClassCount = 0;
             gInstance = hModule;
             WebCore::setInstanceHandle(hModule);
+            bindJavaScriptTrampoline();
             return TRUE;
 
         case DLL_PROCESS_DETACH:
@@ -219,3 +222,171 @@
 
     return WebCore::SharedBuffer::create(reinterpret_cast<const char*>(resource), size);
 }
+
+// Force symbols to be included so we can export them for legacy clients.
+// DEPRECATED! People should get these symbols from _javascript_Core.dll, not WebKit.dll!
+// #include <_javascript_Core/JSObjectRef.h>
+
+typedef JSClassRef (*JSClassCreateFunction)(const JSClassDefinition* definition);
+typedef void* (*JSObjectGetPrivateFunction)(JSObjectRef);
+typedef JSObjectRef (*JSObjectMakeFunctionStub)(JSContextRef, JSClassRef, void*);
+typedef void (*JSObjectSetPropertyFunction)(JSContextRef, JSObjectRef, JSStringRef propertyName, JSValueRef, JSPropertyAttributes, JSValueRef* exception);
+typedef JSStringRef (*JSStringCreateWithCFStringFunction)(CFStringRef);
+typedef JSStringRef (*JSStringCreateWithUTF8CStringFunction)(const char*);
+typedef const JSChar* (*JSStringGetCharactersPtrFunction)(JSStringRef);
+typedef size_t (*JSStringGetLengthFunction)(JSStringRef);
+typedef void (*JSStringReleaseFunction)(JSStringRef);
+typedef bool (*JSValueIsTypeFunction)(JSContextRef, JSValueRef);
+typedef JSValueRef(*JSValueMakeUndefinedFunction)(JSContextRef);
+typedef double(*JSValueToNumberFunction)(JSContextRef, JSValueRef, JSValueRef* exception);
+typedef JSValueRef(*JSValueMakeStringFunction)(JSContextRef, JSStringRef);
+typedef JSStringRef (*JSValueToStringCopyFunction)(JSContextRef, JSValueRef, JSValueRef* exception);
+
+JSClassCreateFunction m_jsClassCreateFunction = nullptr;
+JSObjectGetPrivateFunction m_jsObjectGetPrivateFunction = nullptr;
+JSObjectMakeFunctionStub m_jsObjectMakeFunction = nullptr;
+JSObjectSetPropertyFunction m_jsObjectSetPropertyFunction = nullptr;
+JSStringCreateWithCFStringFunction m_jsStringCreateWithCFStringFunction = nullptr;
+JSStringCreateWithUTF8CStringFunction m_jsStringCreateWithUTF8CStringFunction = nullptr;
+JSStringGetCharactersPtrFunction m_jsStringGetCharactersPtrFunction = nullptr;
+JSStringGetLengthFunction m_jsStringGetLengthFunction = nullptr;
+JSStringReleaseFunction m_jsStringReleaseFunction = nullptr;
+JSValueIsTypeFunction m_jsValueIsNumberFunction = nullptr;
+JSValueIsTypeFunction m_jsValueIsStringFunction = nullptr;
+JSValueMakeUndefinedFunction m_jsValueMakeUndefinedFunction = nullptr;
+JSValueToNumberFunction m_jsValueToNumberFunction = nullptr;
+JSValueMakeStringFunction m_jsValueMakeStringFunction = nullptr;
+JSValueToStringCopyFunction m_jsValueToStringCopyFunction = nullptr;
+
+void bindJavaScriptTrampoline()
+{
+    const wchar_t* libraryName = L"_javascript_Core.dll";
+
+    HMODULE library = ::LoadLibrary(libraryName);
+    if (!library)
+        return;
+
+    m_jsClassCreateFunction = reinterpret_cast<JSClassCreateFunction>(::GetProcAddress(library, "JSClassCreate"));
+    m_jsObjectGetPrivateFunction = reinterpret_cast<JSObjectGetPrivateFunction>(::GetProcAddress(library, "JSObjectGetPrivate"));
+    m_jsObjectMakeFunction = reinterpret_cast<JSObjectMakeFunctionStub>(::GetProcAddress(library, "JSObjectMake"));
+    m_jsObjectSetPropertyFunction = reinterpret_cast<JSObjectSetPropertyFunction>(::GetProcAddress(library, "JSObjectSetProperty"));;
+    m_jsStringCreateWithCFStringFunction = reinterpret_cast<JSStringCreateWithCFStringFunction>(::GetProcAddress(library, "JSStringCreateWithCFString"));
+    m_jsStringCreateWithUTF8CStringFunction = reinterpret_cast<JSStringCreateWithUTF8CStringFunction>(::GetProcAddress(library, "JSStringCreateWithUTF8CString"));
+    m_jsStringGetCharactersPtrFunction = reinterpret_cast<JSStringGetCharactersPtrFunction>(::GetProcAddress(library, "JSStringGetCharactersPtr"));
+    m_jsStringGetLengthFunction = reinterpret_cast<JSStringGetLengthFunction>(::GetProcAddress(library, "JSStringGetLength"));
+    m_jsStringReleaseFunction = reinterpret_cast<JSStringReleaseFunction>(::GetProcAddress(library, "JSStringRelease"));
+    m_jsValueIsNumberFunction = reinterpret_cast<JSValueIsTypeFunction>(::GetProcAddress(library, "JSValueIsNumber"));
+    m_jsValueIsStringFunction = reinterpret_cast<JSValueIsTypeFunction>(::GetProcAddress(library, "JSValueIsString"));
+    m_jsValueMakeStringFunction = reinterpret_cast<JSValueMakeStringFunction>(::GetProcAddress(library, "JSValueMakeString"));
+    m_jsValueMakeUndefinedFunction = reinterpret_cast<JSValueMakeUndefinedFunction>(::GetProcAddress(library, "JSValueMakeUndefined"));
+    m_jsValueToNumberFunction = reinterpret_cast<JSValueToNumberFunction>(::GetProcAddress(library, "JSValueToNumber"));
+    m_jsValueToStringCopyFunction = reinterpret_cast<JSValueToStringCopyFunction>(::GetProcAddress(library, "JSValueToStringCopy"));
+}
+
+extern "C"
+{
+
+JSClassRef JSClassCreate(const JSClassDefinition* definition)
+{
+    if (m_jsClassCreateFunction)
+        return m_jsClassCreateFunction(definition);
+    return nullptr;
+}
+
+void* JSObjectGetPrivate(JSObjectRef object)
+{
+    if (m_jsObjectGetPrivateFunction)
+        return m_jsObjectGetPrivateFunction(object);
+    return nullptr;
+}
+
+JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef classRef, void* data)
+{
+    if (m_jsObjectMakeFunction)
+        return m_jsObjectMakeFunction(ctx, classRef, data);
+    return nullptr;
+}
+
+void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
+{
+    if (m_jsObjectSetPropertyFunction)
+        m_jsObjectSetPropertyFunction(ctx, object, propertyName, value, attributes, exception);
+}
+
+JSStringRef JSStringCreateWithCFString(CFStringRef value)
+{
+    if (m_jsStringCreateWithCFStringFunction)
+        return m_jsStringCreateWithCFStringFunction(value);
+    return nullptr;
+}
+
+JSStringRef JSStringCreateWithUTF8CString(const char* value)
+{
+    if (m_jsStringCreateWithUTF8CStringFunction)
+        return m_jsStringCreateWithUTF8CStringFunction(value);
+    return nullptr;
+}
+
+const JSChar* JSStringGetCharactersPtr(JSStringRef value)
+{
+    if (m_jsStringGetCharactersPtrFunction)
+        return m_jsStringGetCharactersPtrFunction(value);
+    return nullptr;
+}
+
+size_t JSStringGetLength(JSStringRef value)
+{
+    if (m_jsStringGetLengthFunction)
+        return m_jsStringGetLengthFunction(value);
+    return 0;
+}
+
+void JSStringRelease(JSStringRef value)
+{
+    if (m_jsStringReleaseFunction)
+        return m_jsStringReleaseFunction(value);
+}
+
+bool JSValueIsNumber(JSContextRef ctx, JSValueRef value)
+{
+    if (m_jsValueIsNumberFunction)
+        return m_jsValueIsNumberFunction(ctx, value);
+    return false;
+}
+
+bool JSValueIsString(JSContextRef ctx, JSValueRef value)
+{
+    if (m_jsValueIsStringFunction)
+        return m_jsValueIsStringFunction(ctx, value);
+    return false;
+}
+
+JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef value)
+{
+    if (m_jsValueMakeStringFunction)
+        return m_jsValueMakeStringFunction(ctx, value);
+    return nullptr;
+}
+
+JSValueRef JSValueMakeUndefined(JSContextRef ctx)
+{
+    if (m_jsValueMakeUndefinedFunction)
+        return m_jsValueMakeUndefinedFunction(ctx);
+    return nullptr;
+}
+
+double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
+{
+    if (m_jsValueToNumberFunction)
+        return m_jsValueToNumberFunction(ctx, value, exception);
+    return 0;
+}
+
+JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
+{
+    if (m_jsValueToStringCopyFunction)
+        return m_jsValueToStringCopyFunction(ctx, value, exception);
+    return nullptr;
+}
+
+}

Modified: trunk/Source/WebKit/win/WebKitDLL.h (213736 => 213737)


--- trunk/Source/WebKit/win/WebKitDLL.h	2017-03-11 00:46:44 UTC (rev 213736)
+++ trunk/Source/WebKit/win/WebKitDLL.h	2017-03-11 00:58:42 UTC (rev 213737)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006-2017 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -56,6 +56,37 @@
 
 WEBKIT_API void shutDownWebKit();
 
+#if defined(DEPRECATED_EXPORT_SYMBOLS)
+
+#include <_javascript_Core/JSObjectRef.h>
+
+// Force symbols to be included so we can export them for legacy clients.
+// DEPRECATED! People should get these symbols from _javascript_Core.dll, not WebKit.dll!
+typedef struct OpaqueJSClass* JSClassRef;
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef const struct OpaqueJSValue* JSValueRef;
+typedef struct OpaqueJSString* JSStringRef;
+typedef wchar_t JSChar;
+typedef unsigned JSPropertyAttributes;
+
+WEBKIT_API JSClassRef JSClassCreate(const JSClassDefinition*);
+WEBKIT_API void* JSObjectGetPrivate(JSObjectRef);
+WEBKIT_API JSObjectRef JSObjectMake(JSContextRef, JSClassRef, void*);
+WEBKIT_API void JSObjectSetProperty(JSContextRef, JSObjectRef, JSStringRef propertyName, JSValueRef, JSPropertyAttributes, JSValueRef* exception);
+WEBKIT_API JSStringRef JSStringCreateWithCFString(CFStringRef);
+WEBKIT_API JSStringRef JSStringCreateWithUTF8CString(const char*);
+WEBKIT_API const JSChar* JSStringGetCharactersPtr(JSStringRef);
+WEBKIT_API size_t JSStringGetLength(JSStringRef);
+WEBKIT_API void JSStringRelease(JSStringRef);
+WEBKIT_API bool JSValueIsNumber(JSContextRef, JSValueRef);
+WEBKIT_API bool JSValueIsString(JSContextRef, JSValueRef);
+WEBKIT_API JSValueRef JSValueMakeString(JSContextRef, JSStringRef);
+WEBKIT_API JSValueRef JSValueMakeUndefined(JSContextRef ctx);
+WEBKIT_API double JSValueToNumber(JSContextRef, JSValueRef, JSValueRef*);
+WEBKIT_API JSStringRef JSValueToStringCopy(JSContextRef, JSValueRef, JSValueRef* exception);
+// End
+#endif
+
 #ifdef __cplusplus
 }
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to