PasCocoa is a Pascal bridge to the Cocoa API written for FPC. This package I have created are based off the original PasCocoa which can be found here. I therefore consider these to be additions to PasCocoa and name this project PasCocoaKit.

PasCocoaKit Additions

  • Accessing instance variables to Pascal wrapper classes
  • Memory management for dealing with wrappers, similar to Cocoa
  • Complete AppKit/Foundation ported to Pascal
  • Users work with wrappers almost exclusively, instead of using “handles” to Cocoa objects.
  • Instantiating Pascal objects from InterfaceBuilder
  • IBActions and IBOutlets
  • A PHP parser script for the Cocoa frameworks
  • Support for delegate methods
  • Wrappers for overriding existing Cocoa classes

Example

Here is an example of what a PasCocoa program may look like written in PascalGladiator.

Download

The package contains source code examples, AppKit/Foundation interfaces, supporting binding code (including NSObjectCore the PasCocoa root class), framework parser script and short manual.

Please note FPC 2.2.4 or higher is required and I have not tested on PPC so assume this is Intel only, for now.

harddisk-download_32x32 Download PasCocoaKit 0.2

  • Download Cocoa framework parser PHP script.
  • Download the latest source code examples.
  • Download the latest interfaces (appkit/foundation and bindings).

Latest Changes

  • Abstract methods were removed from NSDelegatesAll.inc to increase compiler performance.
  • super_ prefixed methods were removed to increase compiler performance. You can access super now via inherited in an implemented_ method.
  • Type “id” is no longer changed to NSObject for safety. You must manually create wrappers as needed.
  • “alloc” was introduced to give inline access to accessor methods and Objective-C like syntax. This is not the same as alloc in Cocoa, you never need to alloc objects directly in PasCocoa.
  • Protocols are parsed and implemented as procedural code. Read “PasCocoa Additions Guide” for more info.
  • framework_parser.php now has a command line interface. To run cd the pascocoa folder then type “php framework_parser.php [switches]” in the terminal.
  • Compiling with -CX -XX has fixed the massive binary issue! They are smaller now, about 800k, which still large for a 100 line program.
  • New TableView example demonstrating NSTableView with drag and drop and NIBs.
  • New HICocoaView example demonstrating how to use NSView in Carbon windows.

Documentation

There is a short manual explaining most the basics of PasCocoaKit here. Currently, it does not include instructions on how to use InterfaceBuilder, but the NIB’s are there to study.

I will make tutorial style documentation for the existing example code including screenshots of InterfaceBuilder, which can be confusing to explain.

Issues

  • FPC needs better runtime support to avoid some annoying boiler plate code.
  • I will make a PHP script eventually that will convert a Pascal unit into Objective-C for use with InterfaceBuilder which you can run periodically. Until then you will have to manually add actions, outlets and classes to the NIB file.
  • IBActions and IBOutlets can’t be read from the NIB but until FPC has better runtime access and manipulation it won’t help very much.
  • Methods that return structures (struct) are still not well tested. This is actually a potentially big issue and means that PasCocoa is not safe on Intel/PPC depending on certain methods. Read Mac OS X ABI Function Call Guide for more information.

Thank you in particular to Gorazd Krosl, Dmitry Boyarintsev and Jonas Maebe for answering constant questions for 2 solid months!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • BarraPunto
  • blinkbits
  • BlinkList
  • blogmarks
  • Facebook
  • StumbleUpon
  • TwitThis