[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[jscocoa] 002 structures, missing bindings
Code
| missing |
missing := #( #NSMakePoint #NSMakeRect #NSInsetRect ) select: [:nsName|
(Smalltalk nativeObjectAt: nsName ifAbsent: [ ]) isNil
].
missing notEmpty ifTrue: [
self print: 'Missing globals ',missing printString.
self cancelFileIn
]!
| p r inset | [
p := # #NSMakePoint: 10 y: 20.
p#x = 10 ifFalse: [ self error: 'Invalid NSPoint.x' ].
p#y = 20 ifFalse: [ self error: 'Invalid NSPoint.y' ].
r := # #NSMakeRect: 10 top: 20 width: 30 height: 40.
r#origin#x = 10 ifFalse: [ self error: 'Invalid NSRect.origin.x' ].
r#origin#y = 20 ifFalse: [ self error: 'Invalid NSRect.origin.y' ].
r#size#width = 30 ifFalse: [ self error: 'Invalid NSRect.size.width' ].
r#size#height = 40 ifFalse: [ self error: 'Invalid NSRect.size.height' ].
inset := # #NSInsetRect: r x: 1 y: 5.
inset#origin#x = 11 ifFalse: [ self error: 'Invalid inset.origin.x' ].
inset#origin#y = 25 ifFalse: [ self error: 'Invalid inset.origin.y' ].
inset#size#width = 28 ifFalse: [ self error: 'Invalid inset.size.width' ].
inset#size#height = 30 ifFalse: [ self error: 'Invalid inset.size.height' ].
] on: Error do: [:ex|
self print: 'Error - ',ex description.
self cancelFileIn
]!
| jsRect inset |
jsRect :=
( #origin -> (#x -> 10 , (#y -> 20))
,(#size -> (#width -> 30 , (#height -> 40)))
) json.
inset := # #NSInsetRect: jsRect x: 1 y: 5.
inset#origin#x = 11 ifFalse: [ self error: 'Invalid inset.origin.x' ].
inset#origin#y = 25 ifFalse: [ self error: 'Invalid inset.origin.y' ].
inset#size#width = 28 ifFalse: [ self error: 'Invalid inset.size.width' ].
inset#size#height = 30 ifFalse: [ self error: 'Invalid inset.size.height' ].
References