Fixed <rdar://problem/3964634> undefined property value from binding seems to evalua...
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jan 2005 00:41:59 +0000 (00:41 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jan 2005 00:41:59 +0000 (00:41 +0000)
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

JavaScriptCore/ChangeLog
JavaScriptCore/bindings/objc/objc_runtime.h
JavaScriptCore/bindings/objc/objc_runtime.mm
JavaScriptCore/bindings/testbindings.mm

index d593ffb1f5f8b13303fcf6a0b50e3d0ce98e60fb..721409405277bdd931511e4354d4ccb5975598bf 100644 (file)
@@ -1,3 +1,23 @@
+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>
index fd4a81335de1603c0a904e932377fd1fb12b8f45..e8e69c968eb2c70403d105b7ce050785384daf6b 100644 (file)
@@ -188,6 +188,9 @@ public:
 
     virtual Value defaultValue(ExecState *exec, Type hint) const;
 
+    virtual Type type() const;
+    virtual bool toBoolean(ExecState *exec) const;
+
 private:
     static const ClassInfo info;
 
index 8c83e57963055e7fe690540d3e2b65c193f5e1c6..bcc00da113a52753c22b3e68bf80c92e344d9e08 100644 (file)
@@ -283,9 +283,24 @@ bool ObjcFallbackObjectImp::canPut(ExecState *exec, const Identifier &propertyNa
 }
 
 
+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)
@@ -334,3 +349,12 @@ Value ObjcFallbackObjectImp::defaultValue(ExecState *exec, Type hint) const
     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;
+}
index 3a950214c0dd8628ef594667e273a085a3119c0a..8a9d4b3a7794207afeaf26b5207c4b7ebcd3f529 100644 (file)
     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
 {