Commit Graph

31 Commits

Author SHA1 Message Date
wp_xyz
1e7cf4ebe3 Revised default project icon (less memory usage). Text in logos as graphic, no need for a special font. All by Roland Hahn. 2024-07-29 12:26:08 +02:00
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
ed310974db gir2pas: Enabled passing max version CLO multiple times.
This allows to constraint each library separately, as for example:
```sh
gir2pas -e Set -i /usr/share/gir-1.0/Gtk-3.0.gir -o gtk3-test \
        -M atk-2.36 \
        -M pango-1.16 \
        -M pangocairo-1.46 \
        -M glib-2.66 \
        -M gtk-3.24
```
2023-06-18 14:30:11 +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
ec6cbdbee7 gir2pas: Fixed make file.
Create units output directory upon build.

Remove output directory recursively.
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
bb05d66329 Renamed executable from gir2pascal to gir2pas. 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
b2013f8634 Fixed issue causing generation of duplicate declarations for some opaque types.
There was an issue with the logic for resolving opaque types that misses
some types due to not comparing C types with opaque type name.

This is now fixed and all Gtk3 units now compile without any manual
modification.

Tested with
43cac7495f
using
`./gir2pas/gir2pas -i gir-rs-files/Gtk-3.0.gir -o gtk3-test-enums -e Enum`
2023-05-23 12:57:27 +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
Abou Al Montacir
7920db790b Issue #39988: Forbid duplicate paths in directories search list.
As the directories search list is not sorted, FPC implementation of
`TStringList` ignores the `dupIgnore` option and thus leads to having
the same entry multiple times in the list.

We forbid this manually in order to avoid searching multiple times for
the same file in the very same directory.

We also add more default search paths (Debian based).
2023-05-12 21:44:21 +00:00
Abou Al Montacir
9c5b942b66 Issue #39988: Use system path separator instead in folders search list.
This is more consistent with other tools and allows passing drives on
MS Windows systems.
2023-05-12 21:44:21 +00:00
Abou Al Montacir
5c34ab0510 Issue #39988: Try to create output directory if it does not exist.
This is more convenient for users and when included in a script.
2023-05-12 21:44:21 +00:00
Abou Al Montacir
f64c1307f9 Issue #39988: Changed order of folders where to search for included files.
The order of folders where to search for included files should be
related to user preference as follows:
 1. directory where the input is located,
 2. directories supplied by user at command line in the order they were
    passed,
 3. default system directories, where distributions used to put them.

 This way, user can easily override files in the default system
 directories without the need to have write access to such folder, as in
 most Unix systems this will require root access.

 Also, one expects, that if copy of an included file is placed in the
 same directory as the input one, then this copy should be used.
 This makes sens, because people generally work on the same directory,
 and will consider their local work copy the preferred one to be used.
2023-05-11 15:46:44 +00:00
Abou Al Montacir
8a7116f248 Issue #39988: Added support for .typelib files.
Debian ships .gir files in a compressed binary format with .typelib
extension. We use `g-it-generate`to decompress them on the fly.
2023-05-10 22:00:29 +00: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
f5dc6e64a4 Tools: updated gir2pascal README.md 2022-07-19 01:41:02 +03:00
Maxim Ganetsky
7c8e197abd Tools: updated gir2pascal .gitignore 2022-07-19 01:18:18 +03:00
Maxim Ganetsky
5194609a53 Tools: updated gir2pascal LPI and icon 2022-07-19 01:14:42 +03:00
Maxim Ganetsky
697d41437c Tools: initial import of gir2pascal sources from https://github.com/n1tehawk/gir2pascal 2022-07-19 01:01:00 +03:00