The comprehensive fix for this problem requires new API, as described in
3965326. However,
given that we can't add new API at this point, the 'ObjcFallbackObjectImp' will behave
like and Undefined object if invokeUndefinedMethodFromWebScript:withArguments: isn't
implemented on the bound object.
Reviewed by Chris.
* bindings/objc/objc_runtime.h:
* bindings/objc/objc_runtime.mm:
(ObjcFallbackObjectImp::type):
(ObjcFallbackObjectImp::implementsCall):
(ObjcFallbackObjectImp::toBoolean):
* bindings/testbindings.mm:
(+[MyFirstInterface isSelectorExcludedFromWebScript:]):
(+[MyFirstInterface isKeyExcludedFromWebScript:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8418
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-01-20 Richard Williamson <rjw@apple.com>
+
+ Fixed <rdar://problem/3964634> undefined property value from binding seems to evaluate to true in an if statement
+
+ The comprehensive fix for this problem requires new API, as described in 3965326. However,
+ given that we can't add new API at this point, the 'ObjcFallbackObjectImp' will behave
+ like and Undefined object if invokeUndefinedMethodFromWebScript:withArguments: isn't
+ implemented on the bound object.
+
+ Reviewed by Chris.
+
+ * bindings/objc/objc_runtime.h:
+ * bindings/objc/objc_runtime.mm:
+ (ObjcFallbackObjectImp::type):
+ (ObjcFallbackObjectImp::implementsCall):
+ (ObjcFallbackObjectImp::toBoolean):
+ * bindings/testbindings.mm:
+ (+[MyFirstInterface isSelectorExcludedFromWebScript:]):
+ (+[MyFirstInterface isKeyExcludedFromWebScript:]):
+
=== Safari-180 ===
2005-01-19 Richard Williamson <rjw@apple.com>
virtual Value defaultValue(ExecState *exec, Type hint) const;
+ virtual Type type() const;
+ virtual bool toBoolean(ExecState *exec) const;
+
private:
static const ClassInfo info;
}
+Type ObjcFallbackObjectImp::type() const
+{
+ id targetObject = _instance->getObject();
+
+ if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+ return ObjectType;
+
+ return UndefinedType;
+}
+
bool ObjcFallbackObjectImp::implementsCall() const
{
- return true;
+ id targetObject = _instance->getObject();
+
+ if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+ return true;
+
+ return false;
}
Value ObjcFallbackObjectImp::call(ExecState *exec, Object &thisObj, const List &args)
return _instance->getValueOfUndefinedField(exec, _item, hint);
}
+bool ObjcFallbackObjectImp::toBoolean(ExecState *exec) const
+{
+ id targetObject = _instance->getObject();
+
+ if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
+ return true;
+
+ return false;
+}
return nil;
}
++ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
+{
+ return NO;
+}
+
++ (BOOL)isKeyExcludedFromWebScript:(const char *)name
+{
+ return NO;
+}
+
+/*
- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args;
{
NSLog (@"Call to undefined method %@", name);
}
return @"success";
}
+*/
+/*
- (id)valueForUndefinedKey:(NSString *)key
{
NSLog (@"%s: key = %@", __PRETTY_FUNCTION__, key);
return @"aValue";
}
+*/
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{