Commit Graph

18 Commits

Author SHA1 Message Date
Maxim Ganetsky
0e65a9fbeb Revert erroneous renaming of file in "gir2pas: Added code to disable warning about non ascending enumeration values." (commit 508bd102b0). The change made to file contents is kept. 2023-11-16 02:35:22 +03:00
Abou Al Montacir
508bd102b0 gir2pas: Added code to disable warning about non ascending enumeration values.
FPC does warn about non strictly ascending enumeration values.
Unfortunately, some GTK enum identifiers share the same value and this
warning can safely be ignored. We shut it up.
2023-11-15 22:47:52 +01:00
Abou Al Montacir
25b8bc2160 git2pas: Removed unneeded conditional compilation flag.
This allows having the same code compiled for both Windows and Linux.
2023-06-18 20:15:15 +02:00
Abou Al Montacir
bcf79bffc1 gir2pas: Fixed generation of types based on int32 standard C type.
This fixes code generated for FreeType library.
Now FreeType bindings generated code does not need any manual change
to be used in Lazarus.
2023-06-18 16:24:01 +00:00
Abou Al Montacir
d94e263cdc gir2pas: Fixed generation of enumeration types other than bit fields.
When enum types is set as `goEnumAsSet` by user, we need to add
`goEnumAsEnum` also in order to correctly handle non bit fields enums.

This should be done at the very beginning, upon CLO handling, otherwise
some enums are generated as integer constants.
2023-06-17 21:57:38 +02:00
Abou Al Montacir
aba8308de3 gir2pas: Fixed issues when generating bit fields with a null or duplicate masks.
In this case, the code used to create a wrong index with value 255.
This is now detected and fixed.

Also, the code was not able to handle bit fields with duplicates.
Now this is also fixed.
2023-06-04 19:11:02 +02:00
Abou Al Montacir
524cc642eb Enabled generating code for bit masks defined within C bitfields enum.
These masks are handled as non typed set constants.
2023-06-04 14:04:45 +02:00
Abou Al Montacir
cd0756f17b gir2pas: Enabled generating Pascal sets to C bitfield enums by CLO.
Based on command line option (CLO) `-e/--declare-enums-as` that
selects the way how to define C enums and bit fields.

Added support for 5th options in addition 4 already implemented.
 1. `IntConst`: No type, just use integer non typed constants. This was
    already implemented, but not easily selected at CLI.
 2. `TypedIntConst`: Use non strict type aliases and typed constants.
    This was already implemented, selected by default in the code.
 3. `IntAliasConst`: Use strict type aliases and non typed constants.
    This was newly added.
 4. `Enum`: Use Pascal enumeration type for both C enums and bit fields.
    This was newly added.
 5. `Set`: Use Pascal enumeration type for both C enums and Pascal sets
    for bit fields. This is now implemented.
2023-06-04 10:10:42 +00:00
Abou Al Montacir
050dfa3884 gir2pascal: Small code improvements.
These changes are:
 1. Added line break to last line of generated files.
 2. Removed unused field `FEnumImpl` from `TGirConsoleConverter`.
 3. Moved command line from .lpi to .lps as this depends on the path
    of the user debugging the program.
2023-05-27 15:53:56 +00:00
Abou Al Montacir
0838345684 Fixed generation of unnamed unions handling within objects.
The generated code was missing an identifier and thus was unable to
compile.

Now we generated a name based on the type and this seems for fix the
issues with Gtk3.gir file.
2023-05-22 22:22:51 +00:00
Abou Al Montacir
8ebe4628c8 Generate pointer types for all declared types.
If the type is not used within the unit it was declared in, then pointer
types will not generated. This causes an error when a pointer type is
used by a unit using it.

An example is a compilation error on `Pango1` that uses `Glib2` because
the type `Pgconstpointer` was not defined.

The new code generates a lost of pointer types, but at least it allows
get a code that compiles fine.
2023-05-21 22:09:42 +00:00
Abou Al Montacir
08ee4a27b4 gir2pascal: Created a dedicated section for declaring enumeration types, issue #FP39988.
This section is placed just after the constants section in order to
avoid declaration of function parameters and variables of enumeration
types that are not yet declared.

The issue was hidden in the typed constants implementation because the
constants section is placed at the beginning of the unit. This is not
true anymore and thus we need a dedicated section.
2023-05-21 15:50:48 +00:00
Abou Al Montacir
194cc1a4fc git2pascal: Refactored code to avoid duplication.
Inserting `external` directive for `C` identifiers was done manually.
This commit adds a method to add such a directive for any identifier.
This helps keeping inserted code consistent and if a change is to be
done in the future, we do it at one place only.
2023-05-20 13:32:33 +00:00
Abou Al Montacir
5c6f02b8ee gir2pascal: Used consistent naming of MsWindows directive.
Compilation directive `MsWindows`is inserted in 3 different places with
3 different case mixing.

Also white spaces around it are some times added and sometimes not.

This commit fixes all to a single convention.
2023-05-19 18:58:31 +02:00
Abou Al Montacir
d1f64050ea gir2pascal: Generate C enums based pascal type selected by CLO, issue #39988.
Added a new command line option (CLO) `-e/--declare-enums-as` that
selects the way how to define C enums and bit fields.

Added support for 4 options and a 5th to be implemented later.
 1. `IntConst`: No type, just use integer non typed constants. This was
    already implemented, but not easily selected at CLI.
 2. `TypedIntConst`: Use non strict type aliases and typed constants.
    This was already implemented, selected by default in the code.
 3. `IntAliasConst`: Use strict type aliases and non typed constants.
    This was newly added.
 4. `Enum`: Use Pascal enumeration type for both C enums and bit fields.
    This was newly added.
 5. `Set`: Use Pascal enumeration type for both C enums and Pascal sets
    for bit fields. This is not yet added.
2023-05-18 10:44:10 +02:00
Maxim Ganetsky
debb889759 gir2pascal: Updated to support generating Gtk4 bindings. Patch from theo222, issue #40196. 2023-04-06 01:49:50 +03:00
marcoonthegit
13d8a9cbb2 * initial support to make generated headers work on Windows with minimal editing, or to start from .gir files with Windows DLL names in them.
(for some glib/gobject based libs on Windows, like Aravis)
2022-08-16 13:52:53 +02:00
Maxim Ganetsky
697d41437c Tools: initial import of gir2pascal sources from https://github.com/n1tehawk/gir2pascal 2022-07-19 01:01:00 +03:00