Changeset 151749 in webkit
- Timestamp:
- Jun 19, 2013 1:09:33 PM (11 years ago)
- Location:
- branches/dfgFourthTier/Source/JavaScriptCore
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dfgFourthTier/Source/JavaScriptCore/API/JSCallbackFunction.cpp
r149636 r151749 27 27 #include "JSCallbackFunction.h" 28 28 29 #include "APICallbackFunction.h" 30 #include "APICast.h" 29 31 #include "APIShims.h" 30 #include "APICast.h"31 32 #include "CodeBlock.h" 32 33 #include "Error.h" … … 64 65 } 65 66 66 EncodedJSValue JSCallbackFunction::call(ExecState* exec)67 {68 JSContextRef execRef = toRef(exec);69 JSObjectRef functionRef = toRef(exec->callee());70 JSObjectRef thisObjRef = toRef(jsCast<JSObject*>(exec->hostThisValue().toThis(exec, NotStrictMode)));71 72 int argumentCount = static_cast<int>(exec->argumentCount());73 Vector<JSValueRef, 16> arguments(argumentCount);74 for (int i = 0; i < argumentCount; i++)75 arguments[i] = toRef(exec, exec->argument(i));76 77 JSValueRef exception = 0;78 JSValueRef result;79 {80 APICallbackShim callbackShim(exec);81 result = jsCast<JSCallbackFunction*>(toJS(functionRef))->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);82 }83 if (exception)84 throwError(exec, toJS(exec, exception));85 86 // result must be a valid JSValue.87 if (!result)88 return JSValue::encode(jsUndefined());89 90 return JSValue::encode(toJS(exec, result));91 }92 93 67 CallType JSCallbackFunction::getCallData(JSCell*, CallData& callData) 94 68 { 95 callData.native.function = call;69 callData.native.function = APICallbackFunction::call<JSCallbackFunction>; 96 70 return CallTypeHost; 97 71 } -
branches/dfgFourthTier/Source/JavaScriptCore/API/JSCallbackFunction.h
r148697 r151749 33 33 34 34 class JSCallbackFunction : public InternalFunction { 35 protected: 36 JSCallbackFunction(JSGlobalObject*, Structure*, JSObjectCallAsFunctionCallback); 37 void finishCreation(VM&, const String& name); 38 35 friend struct APICallbackFunction; 39 36 public: 40 37 typedef InternalFunction Base; … … 51 48 } 52 49 53 protected: 50 private: 51 JSCallbackFunction(JSGlobalObject*, Structure*, JSObjectCallAsFunctionCallback); 52 void finishCreation(VM&, const String& name); 53 54 54 static CallType getCallData(JSCell*, CallData&); 55 56 private:57 static EncodedJSValue JSC_HOST_CALL call(ExecState*);58 55 59 56 JSObjectCallAsFunctionCallback m_callback; -
branches/dfgFourthTier/Source/JavaScriptCore/API/ObjCCallbackFunction.h
r148697 r151749 43 43 class ObjCCallbackFunctionImpl; 44 44 45 class ObjCCallbackFunction : public JSCallbackFunction { 45 class ObjCCallbackFunction : public InternalFunction { 46 friend struct APICallbackFunction; 46 47 public: 47 typedef JSCallbackFunction Base;48 typedef InternalFunction Base; 48 49 49 50 static ObjCCallbackFunction* create(ExecState*, JSGlobalObject*, const String& name, PassOwnPtr<ObjCCallbackFunctionImpl>); … … 64 65 65 66 private: 67 static CallType getCallData(JSCell*, CallData&); 68 69 JSObjectCallAsFunctionCallback m_callback; 66 70 OwnPtr<ObjCCallbackFunctionImpl> m_impl; 67 71 }; -
branches/dfgFourthTier/Source/JavaScriptCore/API/ObjCCallbackFunction.mm
r148697 r151749 29 29 #if JSC_OBJC_API_ENABLED 30 30 31 #import "APICallbackFunction.h" 31 32 #import "APICast.h" 32 33 #import "APIShims.h" … … 470 471 471 472 ObjCCallbackFunction::ObjCCallbackFunction(JSC::JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, PassOwnPtr<ObjCCallbackFunctionImpl> impl) 472 : Base(globalObject, globalObject->objcCallbackFunctionStructure(), callback) 473 : Base(globalObject, globalObject->objcCallbackFunctionStructure()) 474 , m_callback(callback) 473 475 , m_impl(impl) 474 476 { … … 485 487 { 486 488 static_cast<ObjCCallbackFunction*>(cell)->ObjCCallbackFunction::~ObjCCallbackFunction(); 489 } 490 491 CallType ObjCCallbackFunction::getCallData(JSCell*, CallData& callData) 492 { 493 callData.native.function = APICallbackFunction::call<ObjCCallbackFunction>; 494 return CallTypeHost; 487 495 } 488 496 -
branches/dfgFourthTier/Source/JavaScriptCore/ChangeLog
r151744 r151749 1 2013-06-19 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 Refactor ObjCCallbackFunction to inherit directly from InternalFunction 4 https://bugs.webkit.org/show_bug.cgi?id=117595 5 6 Reviewed by Geoffrey Garen. 7 8 * API/APICallbackFunction.h: Added. New struct that allows JSCallbackFunction and 9 ObjCCallbackFunction to share their host call() implementation through the magic of 10 templates. 11 (JSC::APICallbackFunction::call): 12 * API/JSCallbackFunction.cpp: 13 (JSC::JSCallbackFunction::getCallData): Changed to get the template-ized version of 14 the host function. 15 * API/JSCallbackFunction.h: 16 * API/ObjCCallbackFunction.h: Now inherits directly from InternalFunction. 17 * API/ObjCCallbackFunction.mm: 18 (JSC::ObjCCallbackFunction::ObjCCallbackFunction): 19 (JSC::ObjCCallbackFunction::getCallData): Ditto. 20 * GNUmakefile.list.am: Build files! 21 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 22 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 23 * JavaScriptCore.xcodeproj/project.pbxproj: 24 1 25 2013-06-19 Michael Saboff <msaboff@apple.com> 2 26 -
branches/dfgFourthTier/Source/JavaScriptCore/GNUmakefile.list.am
r151651 r151749 33 33 34 34 javascriptcore_sources += \ 35 Source/JavaScriptCore/API/APICallbackFunction.h \ 35 36 Source/JavaScriptCore/API/APICast.h \ 36 37 Source/JavaScriptCore/API/APIShims.h \ -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r151651 r151749 402 402 </ItemGroup> 403 403 <ItemGroup> 404 <ClInclude Include="..\API\APICallbackFunction.h" /> 404 405 <ClInclude Include="..\API\APICast.h" /> 405 406 <ClInclude Include="..\API\JavaScript.h" /> -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r151651 r151749 765 765 </ItemGroup> 766 766 <ItemGroup> 767 <ClInclude Include="..\API\APICallbackFunction.h"> 768 <Filter>API</Filter> 769 </ClInclude> 767 770 <ClInclude Include="..\API\APICast.h"> 768 771 <Filter>API</Filter> -
branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r151651 r151749 599 599 2600B5A6152BAAA70091EE5F /* JSStringJoiner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2600B5A4152BAAA70091EE5F /* JSStringJoiner.cpp */; }; 600 600 2600B5A7152BAAA70091EE5F /* JSStringJoiner.h in Headers */ = {isa = PBXBuildFile; fileRef = 2600B5A5152BAAA70091EE5F /* JSStringJoiner.h */; }; 601 2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = C211B574176A224D000E2A23 /* APICallbackFunction.h */; }; 601 602 41359CF30FDD89AD00206180 /* DateConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = D21202290AD4310C00ED79B6 /* DateConversion.h */; }; 602 603 4443AE3316E188D90076F110 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51F0EB6105C86C6B00E6DF1B /* Foundation.framework */; }; … … 1918 1919 C21122DF15DD9AB300790E3A /* GCThreadSharedData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCThreadSharedData.h; sourceTree = "<group>"; }; 1919 1920 C21122E015DD9AB300790E3A /* MarkStackInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkStackInlines.h; sourceTree = "<group>"; }; 1921 C211B574176A224D000E2A23 /* APICallbackFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICallbackFunction.h; sourceTree = "<group>"; }; 1920 1922 C218D13F1655CFD50062BB81 /* CopyWorkList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CopyWorkList.h; sourceTree = "<group>"; }; 1921 1923 C2239D1216262BDD005AC5FD /* CopyVisitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CopyVisitor.cpp; sourceTree = "<group>"; }; … … 2447 2449 isa = PBXGroup; 2448 2450 children = ( 2451 C211B574176A224D000E2A23 /* APICallbackFunction.h */, 2449 2452 1482B78A0A4305AB00517CFC /* APICast.h */, 2450 2453 865F408710E7D56300947361 /* APIShims.h */, … … 3723 3726 C2FE18A416BAEC4000AF3061 /* StructureRareData.h in Headers */, 3724 3727 C20BA92D16BB1C1500B3AEA2 /* StructureRareDataInlines.h in Headers */, 3728 2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */, 3725 3729 0F9332A514CA7DDD0085F3C6 /* StructureSet.h in Headers */, 3726 3730 0F766D3915AE4A1F008F363E /* StructureStubClearingWatchpoint.h in Headers */,
Note: See TracChangeset
for help on using the changeset viewer.