source: webkit/trunk/JavaScriptCore/API/JSContextRef.cpp@ 55633

Last change on this file since 55633 was 55633, checked in by [email protected], 15 years ago

Remove unnecessary includes of wtf/Platform.h. This is already pulled in by config.h.

Rubber-stamped by Sam Weinig.

JavaScriptCore:

Remove unnecessary includes of wtf/Platform.h. This is already pulled in by config.h.

  • API/APICast.h:
  • API/JSCallbackFunction.cpp:
  • API/JSContextRef.cpp:
  • API/JSObjectRef.cpp:
  • API/JSValueRef.cpp:
  • assembler/ARMAssembler.h:
  • assembler/ARMv7Assembler.h:
  • assembler/AbstractMacroAssembler.h:
  • assembler/AssemblerBuffer.h:
  • assembler/AssemblerBufferWithConstantPool.h:
  • assembler/CodeLocation.h:
  • assembler/LinkBuffer.h:
  • assembler/MIPSAssembler.h:
  • assembler/MacroAssembler.h:
  • assembler/MacroAssemblerARM.h:
  • assembler/MacroAssemblerARMv7.h:
  • assembler/MacroAssemblerCodeRef.h:
  • assembler/MacroAssemblerMIPS.h:
  • assembler/MacroAssemblerX86.h:
  • assembler/MacroAssemblerX86Common.h:
  • assembler/MacroAssemblerX86_64.h:
  • assembler/RepatchBuffer.h:
  • assembler/X86Assembler.h:
  • jit/JIT.h:
  • jit/JITCode.h:
  • jit/JITInlineMethods.h:
  • jit/JITStubs.h:
  • os-win32/stdint.h:
  • runtime/JSAPIValueWrapper.h:
  • runtime/JSImmediate.h:
  • wtf/ASCIICType.h:
  • wtf/StdLibExtras.h:
  • wtf/VMTags.h:
  • yarr/RegexCompiler.h:
  • yarr/RegexInterpreter.h:
  • yarr/RegexJIT.h:
  • yarr/RegexParser.h:
  • yarr/RegexPattern.h:

WebCore:

Remove unnecessary includes of wtf/Platform.h. This is already pulled in by config.h.

  • accessibility/AccessibilityObject.h:
  • dom/XMLTokenizer.cpp:
  • dom/XMLTokenizerLibxml2.cpp:
  • dom/XMLTokenizerQt.cpp:
  • editing/TextAffinity.h:
  • loader/FrameLoaderClient.h:
  • page/FocusController.cpp:
  • page/FrameTree.cpp:
  • page/Geolocation.h:
  • page/PositionCallback.h:
  • page/PositionErrorCallback.h:
  • platform/Cursor.h:
  • platform/FileSystem.h:
  • platform/FloatConversion.h:
  • platform/KeyboardCodes.h:
  • platform/PlatformKeyboardEvent.h:
  • platform/PlatformTouchPoint.h:
  • platform/SuddenTermination.h:
  • platform/Widget.h:
  • platform/graphics/Color.h:
  • platform/graphics/FloatPoint.h:
  • platform/graphics/FloatSize.h:
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/IntPoint.h:
  • platform/graphics/IntRect.h:
  • platform/graphics/IntSize.h:
  • platform/graphics/openvg/PainterOpenVG.h:
  • platform/graphics/openvg/SurfaceOpenVG.h:
  • platform/network/ResourceHandleClient.h:
  • platform/text/Base64.cpp:
  • rendering/style/SVGRenderStyle.h:
  • xml/XSLTProcessor.cpp:
  • xml/XSLTProcessorLibxslt.cpp:
  • xml/XSLTProcessorQt.cpp:

WebKit/qt:

Remove unnecessary includes of wtf/Platform.h. This is already pulled in by the prefix header.

  • WebCoreSupport/EditCommandQt.cpp:
  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1/*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "JSContextRef.h"
28#include "JSContextRefPrivate.h"
29
30#include "APICast.h"
31#include "InitializeThreading.h"
32#include "JSCallbackObject.h"
33#include "JSClassRef.h"
34#include "JSGlobalObject.h"
35#include "JSObject.h"
36
37#if OS(DARWIN)
38#include <mach-o/dyld.h>
39
40static const int32_t webkitFirstVersionWithConcurrentGlobalContexts = 0x2100500; // 528.5.0
41#endif
42
43using namespace JSC;
44
45JSContextGroupRef JSContextGroupCreate()
46{
47 initializeThreading();
48 return toRef(JSGlobalData::createNonDefault().releaseRef());
49}
50
51JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group)
52{
53 toJS(group)->ref();
54 return group;
55}
56
57void JSContextGroupRelease(JSContextGroupRef group)
58{
59 toJS(group)->deref();
60}
61
62JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
63{
64 initializeThreading();
65#if OS(DARWIN)
66 // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed
67 // to use a unique JSGlobalData, we use a shared one for compatibility.
68#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
69 if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) {
70#else
71 {
72#endif
73 JSLock lock(LockForReal);
74 return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass);
75 }
76#endif // OS(DARWIN)
77
78 return JSGlobalContextCreateInGroup(0, globalObjectClass);
79}
80
81JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass)
82{
83 initializeThreading();
84
85 JSLock lock(LockForReal);
86 RefPtr<JSGlobalData> globalData = group ? PassRefPtr<JSGlobalData>(toJS(group)) : JSGlobalData::createNonDefault();
87
88 APIEntryShim entryShim(globalData.get(), false);
89
90#if ENABLE(JSC_MULTIPLE_THREADS)
91 globalData->makeUsableFromMultipleThreads();
92#endif
93
94 if (!globalObjectClass) {
95 JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject;
96 return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
97 }
98
99 JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(globalObjectClass);
100 ExecState* exec = globalObject->globalExec();
101 JSValue prototype = globalObjectClass->prototype(exec);
102 if (!prototype)
103 prototype = jsNull();
104 globalObject->resetPrototype(prototype);
105 return JSGlobalContextRetain(toGlobalRef(exec));
106}
107
108JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
109{
110 ExecState* exec = toJS(ctx);
111 APIEntryShim entryShim(exec);
112
113 JSGlobalData& globalData = exec->globalData();
114 gcProtect(exec->dynamicGlobalObject());
115 globalData.ref();
116 return ctx;
117}
118
119void JSGlobalContextRelease(JSGlobalContextRef ctx)
120{
121 ExecState* exec = toJS(ctx);
122 JSLock lock(exec);
123
124 JSGlobalData& globalData = exec->globalData();
125 IdentifierTable* savedIdentifierTable = setCurrentIdentifierTable(globalData.identifierTable);
126
127 gcUnprotect(exec->dynamicGlobalObject());
128
129 if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain().
130 // The last reference was released, this is our last chance to collect.
131 globalData.heap.destroy();
132 } else
133 globalData.heap.collectAllGarbage();
134
135 globalData.deref();
136
137 setCurrentIdentifierTable(savedIdentifierTable);
138}
139
140JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
141{
142 ExecState* exec = toJS(ctx);
143 APIEntryShim entryShim(exec);
144
145 // It is necessary to call toThisObject to get the wrapper object when used with WebCore.
146 return toRef(exec->lexicalGlobalObject()->toThisObject(exec));
147}
148
149JSContextGroupRef JSContextGetGroup(JSContextRef ctx)
150{
151 ExecState* exec = toJS(ctx);
152 return toRef(&exec->globalData());
153}
154
155JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx)
156{
157 ExecState* exec = toJS(ctx);
158 APIEntryShim entryShim(exec);
159
160 return toGlobalRef(exec->lexicalGlobalObject()->globalExec());
161}
Note: See TracBrowser for help on using the repository browser.