-
Notifications
You must be signed in to change notification settings - Fork 67
/
48 ObjJ syntax compatibility.js
68 lines (48 loc) · 1.31 KB
/
48 ObjJ syntax compatibility.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// Objective-J, JSTalk - like syntax
// class syntax compatibility
//
@implementation ObjJClassSyntax1 : NSObject
- (int)method1:(int)a and2:(int)b
{
return a+b+1
}
@end
@implementation ObjJClassSyntax2 : ObjJClassSyntax1
// Right now these are just skipped.
{
int var1
float var2
}
- (int)method1:(int)a and2:(int)b
{
return a+b+10+[super method1:a and2:b]
}
@end
@implementation ObjJClassSyntax2 (SomeExtraMethods)
- (id)hello
{
return 'hello'
}
- (id)world
{
return 'world'
}
// Check protocol indicator's generated encoding
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
return false
}
@end
var o = [ObjJClassSyntax1 instance]
var r = [o method1:4 and2:3]
if (r != (4+3+1)) throw 'ObjJ compat syntax failed (1)'
var o = [ObjJClassSyntax2 instance]
var r = [o method1:13 and2:36]
if (r != (13+36+1+10+13+36)) throw 'ObjJ compat syntax failed (2)'
if ([o hello] != 'hello') throw 'ObjJ compat syntax failed (3)'
if ([o world] != 'world') throw 'ObjJ compat syntax failed (4)'
// Protocol indicator
var protocolMethodSignature = [JSCocoa typeEncodingOfMethod:'validateUserInterfaceItem:' class:'ObjJClassSyntax2']
if (protocolMethodSignature != 'c@:@') throw 'ObjJ compat syntax failed (5)'
o = null