-template <class Base>
-double JSCallbackObject<Base>::toNumber(ExecState* exec) const
-{
- // We need this check to guard against the case where this object is rhs of
- // a binary expression where lhs threw an exception in its conversion to
- // primitive
- if (exec->hadException())
- return NaN;
- JSContextRef ctx = toRef(exec);
- JSObjectRef thisRef = toRef(this);
-
- for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
- if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
- JSValueRef exception = 0;
- JSValueRef value;
- {
- APICallbackShim callbackShim(exec);
- value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
- }
- if (exception) {
- exec->setException(toJS(exec, exception));
- return 0;
- }
-
- double dValue;
- if (value)
- return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
- }
-
- return Base::toNumber(exec);
-}
-
-template <class Base>
-UString JSCallbackObject<Base>::toString(ExecState* exec) const
-{
- JSContextRef ctx = toRef(exec);
- JSObjectRef thisRef = toRef(this);
-
- for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
- if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
- JSValueRef exception = 0;
- JSValueRef value;
- {
- APICallbackShim callbackShim(exec);
- value = convertToType(ctx, thisRef, kJSTypeString, &exception);
- }
- if (exception) {
- exec->setException(toJS(exec, exception));
- return "";
- }
- if (value)
- return toJS(exec, value).getString(exec);
- }
-
- return Base::toString(exec);
-}
-
-template <class Base>
-void JSCallbackObject<Base>::setPrivate(void* data)