Difference between revisions of "iPhone headers translator"

From Free Pascal wiki
Jump to navigationJump to search
(New page: ==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.p...)
 
Line 3: Line 3:
 
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:
parser.pas - main program;
+
*parser.pas - main program;
htranslator.pas - contains main class that perform translation (indeed
+
*htranslator.pas - contains main class that perform translation (indeed it only manage this process);
it only manage this process);
+
*hscanner.pas - contains "c-header scanner" class;
hscanner.pas - contains "c-header scanner" class;
+
*hparser.pas - contains common c-header parser, that translates c declarations (without helper functions with implementations (bodies));
hparser.pas - contains common c-header parser, that translates c
+
* bparser.pas - extends header parser to handle functions with bodies too;
declarations (without helper functions with implementations (bodies));
+
*ocparser.pas - extends parser to handle objective-c declarations;
bparser.pas - extends header parser to handle functions with bodies
+
*decltypes.pas - contains class to manage translated types.
too;
+
 
ocparser.pas - extends parser to handle objective-c declarations;
+
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).
decltypes.pas - contains class to manage translated types.
+
 
To build parser "fpc parser" is enough. Of course you need to install
+
Parser parameters:
iPhone SDK. Cause I have only simulator, I will use its SDK.
+
 
Typically it is installed to
+
#one of parameter must be sdk="path_to_sdk" (mandatory);
/Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.
+
#there can be parameter dest="output_path" (to place Pascal units, if not specified "src" is used);
sdk (for 5.0 version). The path to SDK will be used as parameter of
+
#all other parameters are regarded as names of frameworks to parse.
parser. Indeed, it's time to start it. Parser contains a little help,
+
 
so it can be used (--help or without parameters).
+
Example:
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
 
  $ ./parser sdk=/Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk UIKit
will translate UIKit and all dependant frameworks (cfnetwork,
+
 
corefoundation, coregraphics, coreimage, corevideo, foundation,
+
will translate UIKit and all dependant frameworks (cfnetwork, corefoundation, coregraphics, coreimage, corevideo, foundation, opengles, security).
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 where some "todo's" 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
+
My test program is also attached (ipt.zip contains Lazarus project).
now it works good where some "todo's" so it would be nice to place it
+
To compile it you need some modifications to IDE
in svn.
+
(iphonesim_objccat.patch). Project output directory must be changed.
My test program is also attached (ipt.zip contains Lazarus project).
+
In order to run it in Simulator I have created empty xCode project
To compile it you need some modifications to IDE
+
"iphone_test" and run it. After it I've closed xcode and run only
(iphonesim_objccat.patch). Project output directory must be changed.
+
simulator - it has contained my new program "iphone_test". After that
In order to run it in Simulator I have created empty xCode project
+
I've simply replaced binary
"iphone_test" and run it. After it I've closed xcode and run only
+
/Users/macuser/Library/Application Support/iPhone Simulator/5.0/Applications/C93F7A57-E612-4A40-B155-DB106CA860D6/iphone_test.app/iphone_test
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===
 
===Download===
 
From here:
 
From here:

Revision as of 22:33, 19 March 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.

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).

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 where some "todo's" so it would be nice to place it in svn. My test program is also attached (ipt.zip contains Lazarus project). To compile it you need some modifications to IDE (iphonesim_objccat.patch). 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 it 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