however this seems to produce the runtime exception:
*** Exception handlers were not properly removed. Some code has
jumped or returned out of an NS_DURING...NS_HANDLER region without
using the NS_VOIDRETURN or NS_VALUERETURN macros. Clearly I'm doing
something wrong here..
I'm not sure if I totally understand the role of
invokeUndefinedMethodFromWebScript:withArguments:
It doesn't seem to get called at all whether or not [wso
setValue:self forKey:@"logMessage"]; is present(I had it just print
an NSLog() message). Is it meant to be used as such:
--
Michael Hanna
email@hidden
iChat: michaelkhanna(AIM)
On 8-Dec-05, at 11:20 AM, Geoffrey Garen wrote:
Hi Michael. My comments are enclosed below.
I've been getting the error:
2005-12-07 16:19:18.587 DataTypeRoot01[4369] /SourceCache/
JavaScriptCore/JavaScriptCore-416.13/bindings/objc/
WebScriptObject.mm:211:[4369] JavaScript exception: Object
(result of expression logMessage) does not allow calls.
I'm not sure what this means..why would it expect an object that
does allow calls?
Because your code calls logMessage as a function, JavaScript
expects the logMessage 'object' to allow '[function] calls'. It
looks like logMessage is undefined, though. You can confirm this by
calling 'alert(logMessage)' and seeing if you get a function or
undefined.
Anyway,
on the call:
var lang = logMessage(strLang);
In the calling class(which contains these delegates:
if (aSel == @selector(logMessage:)) {
retval = @"logMessage";
}
in isSelectorExcludedFromWebScript:
if ( aSel == @selector(logMessage:)) {
return NO;
}
Can I access a selector without a namespace(such as this case)?
webScriptNameForSelector and isSelectorExcludedFromWebScript are
appropriate methods to implement if your object exposes member
functions to JavaScript. What you've done would enable calling
plugin.logMessage() if your object were defined in the page as
'plugin'.
In this case, your object doesn't expose member functions. Rather,
you want to expose an object that itself can be called as a
function. That requires constructing an object that implements
invokeDefaultMethodWithArguments:. You can read about that in the
WebKit Objective-C docs @ <http://developer.apple.com/documentation/
Cocoa/Reference/WebKit/ObjC_classic/Protocols/WebScripting.html>
I will say that the note there is a little tricky. It says "Invoked
when a script attempts to invoke a method on an exposed object
directly." I would say instead, "Invoked when a script attempts to
call an exposed object as a function."
Remember, to expose an object that isn't defined in the page as a
plugin, you need to call setValue:forKey: on the
windowScriptObject, passing in a valid object as the value and
@"logMessage" as the key.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden