Difference between revisions of "iPhone headers translator"

From Free Pascal wiki
Jump to navigationJump to search
Line 2: Line 2:
 
===Author===
 
===Author===
 
Anton  e-mail: ast DOT a_s AT mail DOT ru
 
Anton  e-mail: ast DOT a_s AT mail DOT ru
 +
 
===Introduction===
 
===Introduction===
 
There are 7 files in attached zip:
 
There are 7 files in attached zip:
Line 12: Line 13:
 
*decltypes.pas - contains class to manage translated types.
 
*decltypes.pas - contains class to manage translated types.
  
To build parser "fpc parser" is enough. Of course you need to install iPhone SDK. Cause I have only simulator, I will use its SDK. Typically it is installed to /Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk (for 5.0 version). The path to SDK will be used as parameter of parser. Indeed, it's time to start it. Parser contains a little help, so it can be used (--help or without parameters).
+
===Features (main goals of project)===
 +
*do not require any additional (input) files, only iPhone SDK C-headers;
 +
*produced Pascal units must not need any manual fixes to be compiled;
 +
*translate also implementations of helper functions
 +
 
 +
===How to parse===
 +
To build parser "fpc parser" is enough. Of course you need to install iPhone SDK. Cause I have only simulator, I will use its SDK. Typically it is installed to /Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk (for 5.0 version). The path to SDK will be used as a parameter of parser. Indeed, it's time to start it. Parser contains a little help, so it can be used (--help or without parameters).
  
 
Parser parameters:
 
Parser parameters:
Line 25: Line 32:
  
 
will translate UIKit and all dependant frameworks (cfnetwork, corefoundation, coregraphics, coreimage, corevideo, foundation, opengles, security).
 
will translate UIKit and all dependant frameworks (cfnetwork, corefoundation, coregraphics, coreimage, corevideo, foundation, opengles, security).
I've tested it for SDKs 3.0, 3.2, 4.0, 4.1, 4.2, 4.3, 5.0. Although now it works good there are some "todo's" and unimplemented parts, so it would be nice to place it in svn.
+
I've tested it for SDKs 3.0, 3.2, 4.0, 4.1, 4.2, 4.3, 5.0. Although now it works good there are some "todo's" and unimplemented parts.
 
My test program is also attached (ipt.zip contains Lazarus project).
 
My test program is also attached (ipt.zip contains Lazarus project).
To compile it you need some modifications to IDE
+
Project output directory must be changed.
(iphonesim_objccat.patch). Project output directory must be changed.
+
In order to run it in Simulator I have created empty XCode project
In order to run it in Simulator I have created empty xCode project
+
"iphone_test" and run it. After that I've closed XCode and run only
"iphone_test" and run it. After it I've closed xcode and run only
 
 
simulator - it has contained my new program "iphone_test". After that
 
simulator - it has contained my new program "iphone_test". After that
 
I've simply replaced binary
 
I've simply replaced binary
Line 38: Line 44:
 
From here:
 
From here:
 
http://sourceforge.net/projects/p-tools/files/iPhone%20headers%20translator/
 
http://sourceforge.net/projects/p-tools/files/iPhone%20headers%20translator/
 +
 
==See Also==
 
==See Also==
 
*[[iPhone/iPod development]]
 
*[[iPhone/iPod development]]

Revision as of 22:06, 1 April 2012

Pascal iPhone header translator

Author

Anton e-mail: ast DOT a_s AT mail DOT ru

Introduction

There are 7 files in attached zip:

  • parser.pas - main program;
  • htranslator.pas - contains main class that perform translation (indeed it only manage this process);
  • hscanner.pas - contains "c-header scanner" class;
  • hparser.pas - contains common c-header parser, that translates c declarations (without helper functions with implementations (bodies));
  • bparser.pas - extends header parser to handle functions with bodies too;
  • ocparser.pas - extends parser to handle objective-c declarations;
  • decltypes.pas - contains class to manage translated types.

Features (main goals of project)

  • do not require any additional (input) files, only iPhone SDK C-headers;
  • produced Pascal units must not need any manual fixes to be compiled;
  • translate also implementations of helper functions

How to parse

To build parser "fpc parser" is enough. Of course you need to install iPhone SDK. Cause I have only simulator, I will use its SDK. Typically it is installed to /Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk (for 5.0 version). The path to SDK will be used as a parameter of parser. Indeed, it's time to start it. Parser contains a little help, so it can be used (--help or without parameters).

Parser parameters:

  1. one of parameter must be sdk="path_to_sdk" (mandatory);
  2. there can be parameter dest="output_path" (to place Pascal units, if not specified "src" is used);
  3. all other parameters are regarded as names of frameworks to parse.

Example:

$ ./parser sdk=/Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk UIKit

will translate UIKit and all dependant frameworks (cfnetwork, corefoundation, coregraphics, coreimage, corevideo, foundation, opengles, security). I've tested it for SDKs 3.0, 3.2, 4.0, 4.1, 4.2, 4.3, 5.0. Although now it works good there are some "todo's" and unimplemented parts. My test program is also attached (ipt.zip contains Lazarus project). Project output directory must be changed. In order to run it in Simulator I have created empty XCode project "iphone_test" and run it. After that I've closed XCode and run only simulator - it has contained my new program "iphone_test". After that I've simply replaced binary /Users/macuser/Library/Application Support/iPhone Simulator/5.0/Applications/C93F7A57-E612-4A40-B155-DB106CA860D6/iphone_test.app/iphone_test

Download

From here: http://sourceforge.net/projects/p-tools/files/iPhone%20headers%20translator/

See Also