{ "c" "char" }
{ "i" "int" }
{ "s" "short" }
- { "l" "long" }
- { "q" "longlong" }
{ "C" "uchar" }
{ "I" "uint" }
{ "S" "ushort" }
- { "L" "ulong" }
- { "Q" "ulonglong" }
{ "f" "float" }
{ "d" "double" }
{ "B" "bool" }
{ "v" "void" }
{ "*" "char*" }
+ { "?" "unknown_type" }
{ "@" "id" }
{ "#" "id" }
{ ":" "SEL" }
-} objc>alien-types set-global
+}
+"ptrdiff_t" heap-size {
+ { 4 [ H{
+ { "l" "long" }
+ { "q" "longlong" }
+ { "L" "ulong" }
+ { "Q" "ulonglong" }
+ } ] }
+ { 8 [ H{
+ { "l" "long32" }
+ { "q" "long" }
+ { "L" "ulong32" }
+ { "Q" "ulong" }
+ } ] }
+} case
+assoc-union objc>alien-types set-global
! The transpose of the above map
SYMBOL: alien>objc-types
! A hack...
"ptrdiff_t" heap-size {
{ 4 [ H{
- { "NSPoint" "{_NSPoint=ff}" }
- { "NSRect" "{_NSRect=ffff}" }
- { "NSSize" "{_NSSize=ff}" }
- { "NSRange" "{_NSRange=II}" }
+ { "NSPoint" "{_NSPoint=ff}" }
+ { "NSRect" "{_NSRect={_NSPoint=ff}{_NSSize=ff}}" }
+ { "NSSize" "{_NSSize=ff}" }
+ { "NSRange" "{_NSRange=II}" }
+ { "NSInteger" "i" }
+ { "NSUInteger" "I" }
+ { "CGFloat" "f" }
} ] }
{ 8 [ H{
- { "NSPoint" "{_NSPoint=dd}" }
- { "NSRect" "{_NSRect=dddd}" }
- { "NSSize" "{_NSSize=dd}" }
- { "NSRange" "{_NSRange=QQ}" }
+ { "NSPoint" "{CGPoint=dd}" }
+ { "NSRect" "{CGRect={CGPoint=dd}{CGSize=dd}}" }
+ { "NSSize" "{CGSize=dd}" }
+ { "NSRange" "{_NSRange=QQ}" }
+ { "NSInteger" "q" }
+ { "NSUInteger" "Q" }
+ { "CGFloat" "d" }
} ] }
} case
assoc-union alien>objc-types set-global
{ 8 [ "double" ] }
} case "CGFloat" typedef >>
-C-STRUCT: NSRect
- { "CGFloat" "x" }
- { "CGFloat" "y" }
- { "CGFloat" "w" }
- { "CGFloat" "h" } ;
-
-TYPEDEF: NSRect _NSRect
-TYPEDEF: NSRect CGRect
-
-: <NSRect> ( x y w h -- rect )
- "NSRect" <c-object>
- [ set-NSRect-h ] keep
- [ set-NSRect-w ] keep
- [ set-NSRect-y ] keep
- [ set-NSRect-x ] keep ;
-
-: NSRect-x-y ( alien -- origin-x origin-y )
- [ NSRect-x ] keep NSRect-y ;
-
C-STRUCT: NSPoint
{ "CGFloat" "x" }
{ "CGFloat" "y" } ;
TYPEDEF: NSSize _NSSize
TYPEDEF: NSSize CGSize
-TYPEDEF: NSPoint CGPoint
: <NSSize> ( w h -- size )
"NSSize" <c-object>
[ set-NSSize-h ] keep
[ set-NSSize-w ] keep ;
+C-STRUCT: NSRect
+ { "NSPoint" "origin" }
+ { "NSSize" "size" } ;
+
+TYPEDEF: NSRect _NSRect
+TYPEDEF: NSRect CGRect
+
+: NSRect-x ( NSRect -- x )
+ NSRect-origin NSPoint-x ; inline
+: NSRect-y ( NSRect -- y )
+ NSRect-origin NSPoint-y ; inline
+: NSRect-w ( NSRect -- w )
+ NSRect-size NSSize-w ; inline
+: NSRect-h ( NSRect -- h )
+ NSRect-size NSSize-h ; inline
+
+: set-NSRect-x ( x NSRect -- )
+ NSRect-origin set-NSPoint-x ; inline
+: set-NSRect-y ( y NSRect -- )
+ NSRect-origin set-NSPoint-y ; inline
+: set-NSRect-w ( w NSRect -- )
+ NSRect-size set-NSSize-w ; inline
+: set-NSRect-h ( h NSRect -- )
+ NSRect-size set-NSSize-h ; inline
+
+: <NSRect> ( x y w h -- rect )
+ "NSRect" <c-object>
+ [ set-NSRect-h ] keep
+ [ set-NSRect-w ] keep
+ [ set-NSRect-y ] keep
+ [ set-NSRect-x ] keep ;
+
+: NSRect-x-y ( alien -- origin-x origin-y )
+ [ NSRect-x ] keep NSRect-y ;
+
C-STRUCT: NSRange
{ "NSUInteger" "location" }
{ "NSUInteger" "length" } ;
TYPEDEF: NSRange _NSRange
+! The "lL" type encodings refer to 32-bit values even in 64-bit mode
+TYPEDEF: int long32
+TYPEDEF: uint ulong32
+TYPEDEF: void* unknown_type
+
: <NSRange> ( length location -- size )
"NSRange" <c-object>
[ set-NSRange-length ] keep
}
! Rendering
-{ "drawRect:" "void" { "id" "SEL" "id" "NSRect" }
- [ 3drop window relayout-1 ]
+{ "drawRect:" "void" { "id" "SEL" "NSRect" }
+ [ 2drop window relayout-1 ]
}
! Events
[ 3drop 0 0 0 0 <NSRect> ]
}
-{ "conversationIdentifier" "long" { "id" "SEL" }
+{ "conversationIdentifier" "NSInteger" { "id" "SEL" }
[ drop alien-address ]
}