Can't get non-standard Javascript syntaxes to function

8 views
Skip to first unread message

Ian Beck

unread,
Jul 29, 2010, 3:22:06 PM7/29/10
to JSCocoa
When I include this code on the first line of my Javascript file
(taken from the JSCocoa website):

class NSButton
{
// Swizzle an instance method of an existing class
Swizzle- (void)drawRect:(NSRect)rect
{
// Call original swizzled method, this will call
NSButton's drawRect:
this.Original(arguments)
}
}

JSCocoa spits this out to the Console:

JSException: SyntaxError: Parse error on line 1

Why is this syntax failing? I can't seem to get ANY of the non-
standard syntaxes up and running in my experiments (Objective-J syntax
fails with syntax errors, too). I'm using the latest version of the
JSCocoa.framework and evaluating the Javascript like so:

JSCocoaController *jsc = [JSCocoa sharedController];
[jsc evalJSFile:@"/path/to/file.js"];

Thanks for any insight you can give me!

Ian

Patrick Geiller

unread,
Jul 30, 2010, 6:43:59 PM7/30/10
to jsc...@googlegroups.com
> JSCocoa spits this out to the Console:
>
> JSException: SyntaxError: Parse error on line 1
>
> Why is this syntax failing? I can't seem to get ANY of the non-
> standard syntaxes up and running in my experiments (Objective-J syntax
> fails with syntax errors, too). I'm using the latest version of the
> JSCocoa.framework and evaluating the Javascript like so:

Have you added class.js, jslint-jscocoa.js into the 'Copy Bundle Resources' of your project ? By default XCode sets them to be compiled.

-Patrick

Ian Beck

unread,
Aug 1, 2010, 4:15:08 PM8/1/10
to JSCocoa
Ah, that's likely the problem. I'll double check and make sure that
they're getting copied rather than compiled. Thanks!

Ian
Reply all
Reply to author
Forward
0 new messages