CHelper
chelper is C/C++/ObjC headers converting to pascal utility.
Read more about it on freepascal wiki
Code
Public Repository: https://svn.code.sf.net/p/lazarus-ccr/svn/components/chelper/
CConvert
cconvert is a command-line utility that's used for parsing headers. It's designed to be a stand-alone parser. The converted should produce read-for-use pascal headers.
-defines - allows to add additional C-preprocess definitions. This is used to add additional defines that are defined outside of the converted the converted header. It's allowed to define multiple definition files. If two different definitions are sharing the same name, the later definition takes precedence.
It's quite common for a C library to have one base headers that's used to store definitions. The base header is (in)directly included by other headers of the library. Definitions declared in the base headers would be used by other headers of the library.
-configuration file represents pascal code generation settings. The format of the file is .ini file. Following sections and values are expected to be in the file.
Section [Main]
- RecordsArePacked (0 / 1 default) - if set, the pascal code would explicitly set "packed" record for each C-struct defined
- FuncsAreExternal (0 / 1 default) - if set, any function declaration is considered as external function (otherwise "extern" modified is expected). You want to set this flag to 0, if you're intent to use static object files, rather than dynamically loaded library
- EnumAsConst (0 / 1 default) - the flag indicates, if enumerations should be declare in pascal as (integer) constants. Having enumeration declare as constants, rather than enumerations has it's own benefits, such as extensibility (an integer would accept any value) and well-defined file size (by default, pascal enumerations byte size, depends on the number of elements. C enumerations by default as 4-bytes, matching "int").
- TypeNamePrefix (string) - the prefix that should be added to each non-pointer type. It's a common convention to name types in object pascal starting with "T". However, when creating an interface to C, it's usually omitted.
- RefTypeNamePrefix (string, default "P") - prefix that should be added to each reference type (pointer). I'ts a common convention to name reference types in object pascal starting with "P". C syntax allows NOT to declare a special type name for reference type, for Pascal the ref-type declaration is required. Since there's usually no corresponding C-type it's fine to put "P" prefix for these auxilary types.
- FuncConv (string, default "cdecl") - function calling convention that should be used. When creating an interface for Win.DLL, it's likely that convention should be set to "stdcall"
- FuncDeclPostfix (string) - additional pascal verbiage that should be added after the pascal function declaration (after function convention)
- ParamPrefix (string, default "par") - name of parameter, that's used for "nameless" function declarations (common for C++ dialect or C)
- ExtLibName (string) - the library name that should be added for "external" modified in pascal declarations.
Section (Types) The section consists of pair - CType=Pascal Type name.
bool=LongBool double=Double float'=Single float*=PSingle
It suggests the pascal name equivalent for a C-declared type. Useful to avoid reserved named conflicts.