Sign in Join
Wiki copytemporary

ObjCParser: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Overview
22
33ObjCparser is the tool that helps to convert Objective-C headers to FPC headers as described at [[PasCocoa]]
44
55Currently, the ObjCParser supports the Objective-C 1.0 language specification. (Objective-C 2.0 properties are not yet supported).
66
77## Installation
88
99ObjCParser is available from the PasCocoa/Parser folder:
1010
1111SVN: <https://sourceforge.net/p/lazarus-ccr/svn/475/tree/bindings/pascocoa/parser/>
1212
1313## Usage
1414
1515The command line usage of the Parser is the following:
1616
1717objcparser \[switches\] \[headername.h\]
1818
1919Supported switches:
2020
2121-all (any file named *.h is considered a header file and being parsed);
2222
2323-ini (setting file)
2424
2525-uini (setting file to write to updated files. Type definition information \[TypeDefs\] is written to the specified file )
2626
2727-noout (.inc files are not generated. However, if specified, the config file is still written)
2828
2929### Configuration File Sections
3030
3131The configuration file uses the simple .INI file format. So, it can be easily edited by any editor available.
3232
3333### Common flags
3434
3535Following parsing settings are defined in the \[Common\] section
3636
3737- mainunit=mainunitname
3838
3939defines the main unit specifier to be added to the generated pascal files
4040
41-` [Common]`\
42-` mainunit=HelloWorld.pas`
41+```text
42+ [Common]
43+ mainunit=HelloWorld.pas
44+```
4345
4446As a result, each .inc generated file contains
4547
4648``` pascal
4749{$mainunit HelloWorld.pas}
4850```
4951
5052- ignoreinclude
5153
5254specifies, what file \#include or \#import must be ignored, otherwise file would be also \$include-d. The full file name must be specified, or if the file name ends with back slash (CoreFoundation/), all files that belongs to the path would also be ignored (like: CoreFoundation/SomeFile.h, CoreFoundation/SomeFile2.h)
5355
5456Files specified as ignoreinclude value should be space separated.
5557
5658It is possible to define any number of ignoreinclude values, but they must be prefixed whith 'ignoreinclude'.
5759
5860Example:
5961
60-` [Common]`\
61-` ignoreinclude = "ioctrl.h"`\
62-` ignoreinclude1 = "iostd.h conio.h SomeLib/"`\
63-` ignoreinclude2 = "Foundation/ MyLib/hello2.h"`
62+```text
63+ [Common]
64+ ignoreinclude = "ioctrl.h"
65+ ignoreinclude1 = "iostd.h conio.h SomeLib/"
66+ ignoreinclude2 = "Foundation/ MyLib/hello2.h"
67+```
6468
6569in this case: \#include or \#import definition containing: "ioctrl.h", "iostd.h", "conio.h" or "MyLib/hello2.h" or any file that is a sub-file to "Foundation" or "SomeLib" folders is ignored.
6670
6771There is no difference whether \<\> or "" is used to \#include or \#import a file.
6872
6973### Type replacement
7074
7175\[TypeReplace\] Replaces type name (at method params, results, and type structures) with the specified type name. type replacement can also be specified for type references, for this case type the name must end with '*' (asterisk)
7276
7377Example:
7478
75-`[TypeReplace]`\
76-`NSUInteger = Longword;`\
77-`NSUInteger* = PLongWord;`
79+```text
80+[TypeReplace]
81+NSUInteger = Longword;
82+NSUInteger* = PLongWord;
83+```
7884
7985This generates the following code: objc: \<objc\> -(NSUInteger) doSomethingWithNumber: (NSUInteger *) num \</objc\>
8086
8187pascal:
8288
8389``` pascal
8490function SomeClass.doSomethingWithNumber(num: PLongword): LongWord;
8591```
8692
8793### Type name definition
8894
8995\[TypeDefs\] Specifies the type name usage.
9096
9197There are 4 types available:
9298
9399- int (any type that can be cast to a 4-byte integer)
94100
95101- float (floating point value: single or double)
96102
97103- struct (any type or structure that cannot be cast to a 4 byte integer or larger than 4 bytes)
98104
99105- objcclass (objective-c class)
100106
101107if no type definition is specified, it is considered to be int-typed.
102108
103109this information is critical to select the proper objc_msgSend function (implementation section). objcclass types are also replaced with the 'objc.id' type to avoid type naming conflicts between pascal and objc class names.
104110
105111### Token Replacement
106112
107113Token replacement (currently REMOVE ONLY) should be used to get rid of C pre-compiler defined values.
108114
109-`[TokenReplace]`\
110-`AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER=""`
115+```text
116+[TokenReplace]
117+AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER=""
118+```
111119
112120AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER token is usually met by the method, function or type declaration. It should be removed or the file cannot be parsed correctly. Remember, that double quotes "" (empty string) must be specified or the parser ignores TokenReplacement
113121
114122---
115123*From the Free Pascal wiki, page "ObjCParser", as it stood on 2020-06-12 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
116124Category: Lazarus-CCR
117125Category: Objective Pascal
118126Category: Objective-C
119127Category: macOS

Back to history