Changeset 157234 in webkit for trunk/Source/JavaScriptCore/API/APICallbackFunction.h
- Timestamp:
- Oct 10, 2013, 11:20:13 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/APICallbackFunction.h
r156240 r157234 30 30 #include "APIShims.h" 31 31 #include "Error.h" 32 #include "JSCallbackConstructor.h" 32 33 #include <wtf/Vector.h> 33 34 … … 37 38 38 39 template <typename T> static EncodedJSValue JSC_HOST_CALL call(ExecState*); 40 template <typename T> static EncodedJSValue JSC_HOST_CALL construct(ExecState*); 39 41 40 42 }; … … 57 59 { 58 60 APICallbackShim callbackShim(exec); 59 result = jsCast<T*>(toJS(functionRef))-> m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);61 result = jsCast<T*>(toJS(functionRef))->functionCallback()(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception); 60 62 } 61 63 if (exception) … … 68 70 return JSValue::encode(toJS(exec, result)); 69 71 } 72 73 template <typename T> 74 EncodedJSValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec) 75 { 76 JSObject* constructor = exec->callee(); 77 JSContextRef ctx = toRef(exec); 78 JSObjectRef constructorRef = toRef(constructor); 79 80 JSObjectCallAsConstructorCallback callback = jsCast<T*>(constructor)->constructCallback(); 81 if (callback) { 82 size_t argumentCount = exec->argumentCount(); 83 Vector<JSValueRef, 16> arguments; 84 arguments.reserveInitialCapacity(argumentCount); 85 for (size_t i = 0; i < argumentCount; ++i) 86 arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i))); 87 88 JSValueRef exception = 0; 89 JSObjectRef result; 90 { 91 APICallbackShim callbackShim(exec); 92 result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception); 93 } 94 if (exception) { 95 exec->vm().throwException(exec, toJS(exec, exception)); 96 return JSValue::encode(toJS(exec, exception)); 97 } 98 // result must be a valid JSValue. 99 if (!result) 100 return throwVMTypeError(exec); 101 return JSValue::encode(toJS(result)); 102 } 103 104 return JSValue::encode(toJS(JSObjectMake(ctx, jsCast<JSCallbackConstructor*>(constructor)->classRef(), 0))); 105 } 106 70 107 } // namespace JSC 71 108
Note:
See TracChangeset
for help on using the changeset viewer.