DWT Mac OS X
This is a temporarily repository for the Mac OS X port of DWT.
Note, this is a port of SWT 3.5.
The plan is to finishing the Mac OS X port in this repository using D1 and Tango. When the port is finished we will move the repository to a new one and integrated it with the DWT repository. When that is done we will port the code to D2 and drop the support for D1.
There's an archive with prepared sources. These are the original Java files with a few modifications:
- All trailing whitespace are removed
- All tabs are converted to spaces
- Imports are expanded
- SWT is replaced with DWT in a few places
We're aiming to support both 32 and 64bit systems in the same repository with this port.
In Java a pointer is represented as an integer, usually declared as
int /*long*/. This will
int is used on 32bit systems and
long is used on 64bit systems. These integer types
are replaced with their actual native pointer type.
In many cases a type declared as
int /*long*/ will mean an integer type with different size
on different architectures. Here we again replace it with the actual native type, for example
NSInteger, declared in
Floating point numbers declared as
float /*double*/ should in most cases be replaced with
CGFloat, declared in
The id type
id type is a native used to store Objective-C objects. This is the only way to store an
Objective-C object in D. In Objective-C this type can store any type of value, even
See also The Objective-C Programming Language
There's also type named
id in the Java code. This is a regular class containing a pointer to
an Objective-C object, represented with an integer in Java and the native
id type in D. This
is the base class of all Objective-C classes in D/Java.
For more info about bridging Objective-C and D see: http://www.dsource.org/projects/dstep
For more info about Objective-C see:
The Callback class is completely remove and replaced with native function pointers.
The dwt.internal.cocoa.OS module
All native functions declared in the Java file are replaced with aliases in the D code. The actual function declaration are in another module, usually some of the following modules:
The same approach is used for integer values representing enums, but these are replaced with actual enums on a need to need basis.
The binding modules
Any module named
binding contains bindings to C functions. These modules are rarely used
directly but are instead brought into scope by aliasing or wrapping them into another module.
class_addIvar is declared in
dwt.internal.objc.bindings but are then later
class_addProtocol declared in
and is then aliased into scope in
The reason for this is to be able to wrap some methods and convert the arguments, i.e. converting D strings to C strings.