Sign in Join
Wiki copytemporary

ObjCParser: what changed

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

Title: ObjCParser

OldNewLine
1+## Overview
2+
3+ObjCparser is the tool that helps to convert Objective-C headers to FPC headers as described at [[PasCocoa]]
4+
5+Currently, the ObjCParser supports the Objective-C 1.0 language specification. (Objective-C 2.0 properties are not yet supported).
6+
7+## Installation
8+
9+ObjCParser is available from the PasCocoa/Parser folder:
10+
11+SVN: <https://sourceforge.net/p/lazarus-ccr/svn/475/tree/bindings/pascocoa/parser/>
12+
13+## Usage
14+
15+The command line usage of the Parser is the following:
16+
17+objcparser \[switches\] \[headername.h\]
18+
19+Supported switches:
20+
21+-all (any file named *.h is considered a header file and being parsed);
22+
23+-ini (setting file)
24+
25+-uini (setting file to write to updated files. Type definition information \[TypeDefs\] is written to the specified file )
26+
27+-noout (.inc files are not generated. However, if specified, the config file is still written)
28+
29+### Configuration File Sections
30+
31+The configuration file uses the simple .INI file format. So, it can be easily edited by any editor available.
32+
33+### Common flags
34+
35+Following parsing settings are defined in the \[Common\] section
36+
37+- mainunit=mainunitname
38+
39+defines the main unit specifier to be added to the generated pascal files
40+
41+` [Common]`\
42+` mainunit=HelloWorld.pas`
43+
44+As a result, each .inc generated file contains
45+
46+``` pascal
47+{$mainunit HelloWorld.pas}
48+```
49+
50+- ignoreinclude
51+
52+specifies, 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)
53+
54+Files specified as ignoreinclude value should be space separated.
55+
56+It is possible to define any number of ignoreinclude values, but they must be prefixed whith 'ignoreinclude'.
57+
58+Example:
59+
60+` [Common]`\
61+` ignoreinclude = "ioctrl.h"`\
62+` ignoreinclude1 = "iostd.h conio.h SomeLib/"`\
63+` ignoreinclude2 = "Foundation/ MyLib/hello2.h"`
64+
65+in 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.
66+
67+There is no difference whether \<\> or "" is used to \#include or \#import a file.
68+
69+### Type replacement
70+
71+\[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)
72+
73+Example:
74+
75+`[TypeReplace]`\
76+`NSUInteger = Longword;`\
77+`NSUInteger* = PLongWord;`
78+
79+This generates the following code: objc: \<objc\> -(NSUInteger) doSomethingWithNumber: (NSUInteger *) num \</objc\>
80+
81+pascal:
82+
83+``` pascal
84+function SomeClass.doSomethingWithNumber(num: PLongword): LongWord;
85+```
86+
87+### Type name definition
88+
89+\[TypeDefs\] Specifies the type name usage.
90+
91+There are 4 types available:
92+
93+- int (any type that can be cast to a 4-byte integer)
94+
95+- float (floating point value: single or double)
96+
97+- struct (any type or structure that cannot be cast to a 4 byte integer or larger than 4 bytes)
98+
99+- objcclass (objective-c class)
100+
101+if no type definition is specified, it is considered to be int-typed.
102+
103+this 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.
104+
105+### Token Replacement
106+
107+Token replacement (currently REMOVE ONLY) should be used to get rid of C pre-compiler defined values.
108+
109+`[TokenReplace]`\
110+`AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER=""`
111+
112+AVAILABLE_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
113+
114+---
115+*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).*
116+Category: Lazarus-CCR
117+Category: Objective Pascal
118+Category: Objective-C
119+Category: macOS

Back to history