Commit Graph

273 Commits

Author SHA1 Message Date
Philip Withnall
4d5b6599fc gibaseinfo: Allow parent types to be specified for derived types
This doesn’t change the type hierarchy for now (i.e. it introduces no
functional changes), but it will allow us to add some intermediate types
into the `GIBaseInfo` hierarchy in an upcoming commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
71a19a6f65 gibaseinfo: Allow type flags to be specified for derived types
This doesn’t change any of the flags for now (i.e. it introduces no
functional changes), but it will allow us to make some of the types
abstract in an upcoming commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
8e3d98fc98 girepository: Add get_type() wrapper macros
This makes `GIBaseInfo` and derived types more consistent with GObject
convention, and thus a bit more comfortable to use.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
9377a0dd54 girepository: Split GIValueInfo out of gienuminfo.c
It’s a separate type, so it would be less confusing if it were in its
own file.

This doesn’t change any API.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-18 13:15:22 +00:00
Philip Withnall
515b3fc1dc giroffsets: Uniformly handle alignments as size_t
Do this by tracking the state of the size/alignment calculations
separately, rather than bunging it into the `alignment` field using
magic values.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-18 13:09:29 +00:00
Philip Withnall
9fcec66115 giarginfo: Return indexes as uints
As with previous commits, don’t use up half the return value space to
indicate an invalid index.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-17 10:36:45 +00:00
Philip Withnall
fe6f9a661b gitypeinfo: Change gi_type_info_get_array_length_index() to return uint
Rather than mixing `-1` and valid indexes, split out the indication of
whether the type is an array with a length argument from the actual
index of the length argument.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-16 23:26:02 +00:00
Philip Withnall
33f157bd6b gitypeinfo: Remove invalid return value from gi_type_info_get_array_type()
`-1` isn’t part of `GIArrayType`, so it’s not particularly type safe to
return it from `gi_type_info_get_array_type()`. Instead, make it an
error to call that function on a type which isn’t an array type.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-16 23:17:19 +00:00
Philip Withnall
6a7806da4d gitypeinfo: Change gi_type_info_get_array_fixed_size() to return size_t
Return information about whether the type is a fixed-size array
separately from the array size, which allows us to use the full `size_t`
for the array size.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3155
2024-01-16 23:13:01 +00:00
Philip Withnall
bb37da24a6 Merge branch 'gir-standard-types' into 'main'
girepository: Use standard types instead of glib specific

See merge request GNOME/glib!3780
2024-01-16 18:43:54 +00:00
Marco Trevisan (Treviño)
6cc655f86e girepository: Use single-bit sized elements for the GIIrNode structures
Leave to the compiler some more hints to optimize these structures for
being packed when possible.
2024-01-16 18:56:57 +01:00
Marco Trevisan (Treviño)
e9bdbfaf4b cmph-bdz-test: Use more size_t 2024-01-16 18:56:57 +01:00
Marco Trevisan (Treviño)
a201cbd719 girepository: Various indentation cleanups
Various random syntax cleanups found while refactoring
2024-01-16 18:56:57 +01:00
Marco Trevisan (Treviño)
b68857e707 giroffsets: Use size types for size and alignments
Note that for alignments we should actually use size_t, but this would
imply some refactors since this value can be acually set to -1 in our
implementation.

So we use gssize for now, that at least on gcc is defined.
2024-01-16 18:55:45 +01:00
Marco Trevisan (Treviño)
223acf44ba gitypelib: Replace gi_typelib_check_format with compile-time static checks only
There's no much time to have checks at runtime when the compiler can
make sure that the structures size match the expected ones.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
c8eeca9492 girnode: Use size_t to compute gir node size and ensure value is valid 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
a73cc6d5a2 girepository: Use size_t to keep track of the number of interfaces 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
bd29b0bf65 gtypelib: Use size_t for size-related arguments 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
6ef67b9a0d gtypelib: Use proper formatting for sizeof value
That returns a size_t, so we should use the z printf directive.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
25ae968fc2 girepository: Use expected signed types for iterating
We are using various indexes types, but not always using the correct
sign or size, so let's adapt this to ensure we're consistent with the
values we're comparing with.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
91a3399027 girmodule: Ensure we actually use unsigned for gi_ir_module_fatal line 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
13791b47f6 gistructinfo: Use proper types for offset lookup
This is a private function so we can just use the expected types.

Also this avoids a signed/unsigned conversion.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
19476db825 girepository: Ensure indexed access on members is not overflowing
Even though we expose member access as size_t, a GI info blob can
typically just access to an a number of values that is never bigger
than uint16_t, as that's how the typelib is defined (cfr. typelib
internal header blob sizes and n_* elements).

So let's avoid this to happen by adding a check.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
acabaa1568 gibaseinfo: Ensure the typelib offset is within the allowed limits
Even though we expose the offset as a size_t value, we actually have
a less space for it, so let's ensure this is the case at runtime.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
157f93d2ee girepository: Use size_t for size-related arguments and return types
We used to use unsigned values, while they should be big enough to old
the data we're handling here, it's cleaner and clearer if we use size_t
as type for such values, as it makes straight forward to understand what
a value should contain. It also makes these values more future proof.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
de8ac339fb gitypeinfo: Use gssize to return the array length index
Use a bigger integer value, even though int is more than enough, but
to make it clearer that we're returning a size-related value.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
a3d29b6437 giarginfo: Use gssize to return the closure and destroy indexes
Use a bigger integer value, even though int is more than enough, but
to make it clearer that we're returning a size-related value.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
bc2e4b3de5 girrepository: Replace usage of gsize with standard size_t
We just do a safe s/gsize/size_t/ replacement here without doing any
changes to places in which different size of size_t and gsize may be
actually different and create troubles.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
c8aecbb834 girepository: Use uint8_t pointers instead of guchar 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
e3aac4281d girrepository: Remove unneeded static check
The check was added to ensure compatibility with previous versions but
this is not something we care anymore with this API/ABI break.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
5c96b0231a girnode: Use unsigned type for unsigned values
Also use proper sized casting for blob values.
2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
9f33015a25 girrepository: Use standard int sized types instead of g[u]int* 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
e5353ef0c1 girnode: Assign negative value to signed integer 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
8891429a5b girepository: Use char instead of glib-specific gchar 2024-01-16 18:40:42 +01:00
Marco Trevisan (Treviño)
eda4bfcf95 girrepository: Use void* instead of gpointer 2024-01-16 18:40:37 +01:00
Marco Trevisan (Treviño)
44e4555765 girepository/cmph-bdz-test: Avoid using unused temporary variable 2024-01-16 17:30:49 +01:00
Marco Trevisan (Treviño)
91fc45ea57 girepository: Replace tabs with spaces in indentation
We don't use tabs anywhere and the mixed setup just makes many editors
to cry. So let's just replace the tabs with 8 spaces.
2024-01-16 17:30:37 +01:00
David King
bd56539f73 g-ir-compiler: Fix leaks in write_out_typelib
Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1938731
2024-01-15 22:44:41 -08:00
Christoph Reiter
98daf20188 Add a --version option to g-ir-compiler and g-ir-generate. Fixes #55 2024-01-15 22:44:41 -08:00
Ting-Wei Lan
496669495c g-ir-{compiler,generate,inspect}: Call setlocale in main function
It is required to correctly show translated messages on some locales.

https://bugzilla.gnome.org/show_bug.cgi?id=760419
2024-01-15 22:44:41 -08:00
Garrett Regier
380ec88f48 g-ir-compiler: Allow multiple --shared-library
https://bugzilla.gnome.org/show_bug.cgi?id=744535
Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
2024-01-15 22:44:41 -08:00
Ben Boeckel
276bbf8f94 g-ir-compiler: message when arguments are wrong
Otherwise the error is "no input files" which is very confusing.

https://bugzilla.gnome.org/show_bug.cgi?id=753160

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2024-01-15 22:44:41 -08:00
Dieter Verfaillie
9c428a6a9e g-ir-compiler: remove references to --code, remove --no-init options
The "--code" option was removed years ago in d5b8d8d523c3bc26aa9fe6c364d3a17d325b55b6
so remove references to it from README and g-ir-compiler(1)

Remove the "--no-init" option from g-ir-compiler and g-ir-compiler(1)
as it was documented to "can only be used if --code is also specified",
so no reason to keep it around.
2024-01-15 22:44:41 -08:00
Colin Walters
3f1cd04b20 Drop calls to g_type_init()
And bump our GLib requirement.
2024-01-15 22:44:41 -08:00
Colin Walters
1820dcacf1 Add Emacs mode lines to C sources 2024-01-15 22:44:41 -08:00
Owen W. Taylor
5fa171ea21 Fix error handling when writing out typelib
Return a non-zero result when opening the output file fails and
don't use g_error() for other failures when writing out the file,
since such errors should not produce a core dump.
2024-01-15 22:44:41 -08:00
Colin Walters
70a1394652 girepository: Consistently prefix internal functions with _
This should better avoid them being exported.  Rename
girepository-parser.la to girepository-internals.la for clarity.
2024-01-15 22:44:41 -08:00
Johan Dahlin
35c46e2e2e [GIRepository] Rename GTypelib to GITypelib
Keep a typedef for backwards compatibility, until
the major bindings has moved over.
2024-01-15 22:44:41 -08:00
Colin Walters
45a04358b6 [gircompiler] Clean up parsing
We never actually include multiple modules in the compiler,
so just nuke that.  Also rather than passing around GIrModule
consistently pass around a GIrTypelibBuild structure which
has various things.

This lets us maintain a stack there which we can walk for
better error messages.

Also, fix up the node lookup in giroffsets.c; previously
it didn't really handle includes correctly.  We really need to
switch to always using Foo.Bar (i.e. GIName) names internally...
2024-01-15 22:44:41 -08:00
Colin Walters
b2df59c315 compiler: Remove --code argument
It can't really work right now because we rely on dumping data at runtime,
which requires the library.  If in the future we support static scanning,
we can reinvestigate embedded typelibs.
2024-01-15 22:44:41 -08:00
Colin Walters
75cdddb576 [girepository] Actually verify header of loaded typelibs in g_irepository_require
Take a GError * for typelib loading code, validate the header.  This
fixes bizarre errors from gjs where g_irepository_require would happily
load old typelibs.
2024-01-15 22:44:41 -08:00
Johan Dahlin
f414299339 [gtypelib.ch] Rename to gitypelib.ch
Rename gtypelib.h -> gitypelib-internal.h and rename
gtypelib.c to gitypelib.c
2024-01-15 22:44:41 -08:00
C. Scott Ananian
2ed6e7573f Bug 585584: Fix warnings in girparser backtrace functionality and compiler.c 2024-01-15 22:44:41 -08:00
Colin Walters
7f4477c610 Bug 577534 - Use rename to write new typelibs, instead of in-place overwrite
This avoids having processes with the typelibs currently open exploding
immediately.
2024-01-15 22:44:41 -08:00
Johan Dahlin
f3d30afed7 Handle the return value to fwrite properly 2024-01-15 22:44:41 -08:00
Dan Winship
4dd500c22a Misc warning fixes
* giscanner/scannerparser.y: Fix the "Ignoring non-UTF-8 constant
	string" error to print the right value.

	* tests/scanner/annotation.c (backslash_parsing_tester)
	(backslash_parsing_tester_2): make these non-static to avoid a
	warning.
	(annotation_object_string_out)
	(annotation_string_zero_terminated): fix return values

	* tests/scanner/annotation.h (annotation_object_with_voidp):
	prototype this

	* tests/scanner/gtkfrob.c:
	* tests/scanner/gtkfrob.h (gtk_frob_language_manager_get_default):
	fix prototype. (s/()/(void)/).

	* tools/compiler.c (format_output): fix signed/unsigned warning.
	Output a prototype for register_typelib() to avoid warnings later.

svn path=/trunk/; revision=1071
2024-01-15 22:44:41 -08:00
Owen Taylor
582a675584 Add a GirParser object to hold the state of a compilation
Add a toplevel GirParser object to hold state that is global across
a compilation. Currently just holds the include path, but will
eventually also keep a cached list of parsed modules.

svn path=/trunk/; revision=901
2024-01-15 22:44:41 -08:00
Tommi Komulainen
4043597a94 Bug 556543 – reduce compiler warnings
2008-10-16  Tommi Komulainen  <tommi.komulainen@iki.fi>

	Bug 556543 – reduce compiler warnings

	* girepository/ginfo.c:
	* girepository/girepository.c (register_internal,
	count_interfaces, find_interface, find_namespace_version,
	parse_version, g_irepository_require):
	* girepository/girmodule.c (g_ir_module_build_typelib):
	* girepository/girnode.c (init_stats, dump_stats,
	_g_irnode_init_stats, _g_irnode_dump_stats,
	g_ir_node_can_have_member):
	* girepository/girparser.c (firstpass_end_element_handler,
	locate_gir, parse_basic, parse_type_internal, resolve_aliases,
	start_alias, start_type, end_type_top, parse_include, cleanup,
	post_filter):
	* girepository/gtypelib.c (validate_function_blob, validate_enum_blob):
	* giscanner/giscannermodule.c (directive_get_options,
	type_get_child_list):
	* giscanner/scannerlexer.l (parse_gtkdoc):
	* giscanner/scannerparser.y (ctype_free):
	* giscanner/sourcescanner.c:
	* giscanner/sourcescanner.h (gi_source_scanner_parse_macros):
	* tests/types/gitesttypes.c:
	* tools/compiler.c (main):
	* tools/generate.c (write_repository): Remove unused variables
	and code, add missing includes, declarations and case
	statements.

svn path=/trunk/; revision=730
2024-01-15 22:44:41 -08:00
Colin Walters
6114478cf8 Remove g_irepository_unregister, add GIRepositoryLoadFlags
svn path=/trunk/; revision=543
2024-01-15 22:44:41 -08:00
Colin Walters
91dcce4159 Put dependencies in typelibs, resolve them when loading
* gir/Makefile.am: Dep on Makefile
	* girepository/ginfo.c: Print out a nicer error
	message if we failed to load something.
	* girepository/girepository.c: Clean up
	default typelib handling; remove global
	default_typelib variable.  Ensure we handle
	NULL repository in more places.
	Support dependency resolution.
	* tests/Makefile.am: Kill off gobject.gir,
	it conflicts with the real one.
	* tests/Object.gir: Depend on GObject.
	* tools/generate.c: Take --includedir
	argument to say which directories to search
	for typelibs.  Print out dependencies.

svn path=/trunk/; revision=541
2024-01-15 22:44:41 -08:00
Colin Walters
8dd1802d1f Fix --includedir handling
* tests/scanner/Makefile.am: Pass the right
	--includedir args.  Add a Makefile dep.
	* tools/compiler.c: Pass includedirs down.
	* girepository/girparser.c: Actually put
	includedirs in context, pass down.  Fix
	locate_gir.

svn path=/trunk/; revision=514
2024-01-15 22:44:41 -08:00
Colin Walters
85bdf52b87 Expand aliases when generating typelibs
* gir/Makefile.am: Use --includedir
	* girepository/girparser.c: Recursively parse
	includes to pull in aliases and expand them.
	We need this to	avoid putting unknown names in
	the typelibs.
	* tools/compiler.c: Add --includedir option.

svn path=/trunk/; revision=512
2024-01-15 22:44:41 -08:00
Tor Lillqvist
b8f6c2b388 Use binary mode for output file on Windows.
2008-08-28  Tor Lillqvist  <tml@novell.com>

	* tools/compiler.c (write_out_typelib): Use binary mode for output
	file on Windows.

	* girepository/girnode.c: Don't print NULL strings.

	* tests/invoke/Makefile.am
	* tests/scanner/Makefile.am: Use -no-undefined on Windows to
	convince libtool to build shared libraries.

	* tests/invoke/invoke.c: Don't needlessly include <dlfcn.h>. Use
	g_assert() instead of printing out expected errors.


svn path=/trunk/; revision=509
2024-01-15 22:44:41 -08:00
Colin Walters
6f791d89cf Default to --raw. Update.
2008-08-22  Colin Walters  <walters@verbum.org>

	* tools/generate.c, tools/compiler.c: Default
	to --raw.
	* all Makefile.am: Update.

svn path=/trunk/; revision=462
2024-01-15 22:44:41 -08:00
Johan Dahlin
b1039a6dc9 Rename metadata to typelib in variable names, comments and apis.
2008-08-09  Johan Dahlin  <johan@gnome.org>

    * *.[ch]:
    Rename metadata to typelib in variable names,
    comments and apis.


svn path=/trunk/; revision=339
2024-01-15 22:44:41 -08:00
Johan Dahlin
04a5cdf05d Merge in the gir-compiler branch. Thanks to Philip and Colin for their
2008-08-08  Johan Dahlin  <johan@gnome.org>

    * girepository/gtypelib.c (validate_header):
    * girepository/gtypelib.h:
    * giscanner/ast.py:
    * giscanner/girwriter.py:
    * giscanner/sourcescanner.c (gi_source_symbol_ref),
    (gi_source_symbol_unref):
    * tests/array.test:
    * tests/boxed.test:
    * tests/constant.test:
    * tests/enum.test:
    * tests/errors.test:
    * tests/function.test:
    * tests/gobject.test:
    * tests/interface.test:
    * tests/invoke/Makefile.am:
    * tests/invoke/testfns.xml:
    * tests/object.test:
    * tests/parser/Makefile.am:
    * tests/roundtrips.sh:
    * tests/struct.test:
    * tests/types.test:
    * tests/union.test:
    * tests/xref1.test:
    * tests/xref2.test:
    * tools/Makefile.am:
    * tools/compiler.c (main):
    * tools/generate.c (write_callable_info), (write_function_info),
    (write_repository):
    * tools/gidlmodule.c:
    * tools/gidlmodule.h:
    * tools/gidlnode.c:
    * tools/gidlnode.h:
    * tools/gidlparser.c:
    * tools/gidlparser.h:
    * tools/gidlwriter.c:
    * tools/gidlwriter.h:
    * tools/scanner.c (create_node_from_gtype),
    (create_node_from_ctype), (g_igenerator_process_properties),
    (g_igenerator_process_signals), (g_igenerator_create_object),
    (g_igenerator_create_interface), (g_igenerator_create_boxed),
    (g_igenerator_create_enum), (g_igenerator_create_flags),
    (g_igenerator_process_function_symbol),
    (g_igenerator_process_unregistered_struct_typedef),
    (g_igenerator_process_struct_typedef),
    (g_igenerator_process_union_typedef),
    (g_igenerator_process_enum_typedef),
    (g_igenerator_process_function_typedef),
    (g_igenerator_process_constant), (g_igenerator_process_symbols),
    (g_igenerator_add_module), (g_igenerator_add_include_idl):
    Merge in the gir-compiler branch.
    Thanks to Philip and Colin for their help.


svn path=/trunk/; revision=325
2024-01-15 22:44:41 -08:00
Philip Van Hoof
397d16145c tools/gidlnode.c
2008-06-08  Philip Van Hoof  <pvanhoof@gnome.org>

        * girepository/girepository.c:
        * girepository/gtypelib.c:
        * girepository/ginfo.c:
        * girepository/ginvoke.c:
        * girepository/girepository.h:
        * girepository/gtypelib.h:
        * girepository/gmetadata.c:
        * girepository/Makefile.am:
        * girepository/gmetadata.h:
        * tools/compiler.c:
        * tools/gidlmodule.c:
        * tools/gidlnode.c
        * tools/generate.c:
        * tools/gidlmodule.h:
        * tools/gidlparser.c:

        Renamed GMetadata to GTypelib


svn path=/trunk/; revision=288
2024-01-15 22:44:41 -08:00
Johan Dahlin
c0b53bde4d Revert revisions 157,149-148,136-129 and 120. Move back to using
2008-04-22  Johan Dahlin  <johan@gnome.org>

    * girepository/ginfo.c (g_info_from_entry), (g_type_info_new),
    (g_type_info_is_pointer), (g_type_info_get_tag),
    (g_type_info_get_param_type), (g_type_info_get_interface),
    (g_type_info_get_array_length), (g_type_info_is_zero_terminated),
    (g_type_info_get_n_error_domains), (g_type_info_get_error_domain),
    (g_error_domain_info_get_codes), (g_enum_info_get_value),
    (g_object_info_get_interface), (g_object_info_get_field),
    (g_interface_info_get_prerequisite),
    (g_signal_info_get_class_closure), (g_constant_info_get_value):
    * girepository/ginvoke.c (get_ffi_type):
    * girepository/girepository.h:
    * girepository/gmetadata.c (g_metadata_get_dir_entry),
    (g_metadata_check_sanity), (validate_header),
    (validate_array_type_blob), (validate_iface_type_blob),
    (validate_param_type_blob), (validate_error_type_blob),
    (validate_type_blob), (validate_constant_blob),
    (validate_struct_blob), (validate_enum_blob):
    * girepository/gmetadata.h:
    * tests/Makefile.am:
    * tests/invoke/Makefile.am:
    * tests/invoke/invoke.c (main):
    * tests/roundtrips.sh:
    * tools/Makefile.am:
    * tools/compiler.c (format_output), (write_out_metadata), (main):
    * tools/generate.c (write_type_name), (write_type_info),
    (write_constant_value), (write_enum_info), (load_metadata), (main):
    * tools/gidlcompilercontext.c:
    * tools/gidlcompilercontext.h:
    * tools/gidlcompilerentrynode.c:
    * tools/gidlcompilerentrynode.h:
    * tools/gidlcompilertypenode.c:
    * tools/gidlcompilertypenode.h:
    * tools/gidlmodule.c (g_idl_module_build_metadata):
    * tools/gidlmodule.h:
    * tools/gidlnode.c (init_stats), (dump_stats),
    (g_idl_node_get_size), (g_idl_node_get_full_size),
    (g_idl_node_cmp), (g_idl_node_can_have_member),
    (g_idl_node_add_member), (g_idl_node_param_direction_string),
    (parse_int_value), (parse_uint_value), (parse_float_value),
    (parse_boolean_value), (find_entry_node), (find_entry),
    (serialize_type), (g_idl_node_build_metadata), (write_string):
    * tools/gidlnode.h:
    * tools/gidlparser.c (parse_type_internal):
    * tools/quote-file.sh:
    Revert revisions 157,149-148,136-129 and 120.
    Move back to using g-idl-generate to generate the metadata and
    avoids dependency on a c compiler.


svn path=/trunk/; revision=214
2024-01-15 22:44:41 -08:00
Johan Dahlin
3c6a7cd907 Remove most global variables
2008-03-11  Johan Dahlin  <johan@gnome.org>

        * tools/compiler.c:
        * tools/generate.c:
        Remove most global variables


svn path=/trunk/; revision=153
2024-01-15 22:44:41 -08:00
Johan Dahlin
1f233b5915 Remove unused imports
svn path=/trunk/; revision=152
2024-01-15 22:44:41 -08:00
Johan Dahlin
f9f1d8e4c8 Coding style fixes
2008-03-11  Johan Dahlin  <johan@gnome.org>

	* tools/compiler.c (main): Coding style fixes


svn path=/trunk/; revision=144
2024-01-15 22:44:41 -08:00
Mark Doffman
048debb50b tools/quote-file.sh tools/compiler.c tools/generate.c
2008-02-22  Mark Doffman  <mark.doffman@codethink.co.uk>

    * tools/quote-file.sh
    * tools/compiler.c
    * tools/generate.c

      Move to using the 'C' struct compiler code.

WARNING: This commit does not compile. It is a partial change.

svn path=/trunk/; revision=135
2024-01-15 22:44:41 -08:00
Rob Taylor
125fa5e786 Added: Added: Renamed to tools/Makefile.am: Renamed to tools/compiler.c:
2008-02-08  Rob Taylor  <rob.taylor@codethink.co.uk>

	* Makefile.am:
	* configure.ac:
	* gidl/Makefile.am: Added:
	* girepository/Makefile.am: Added:
	* src/Makefile.am: Renamed to tools/Makefile.am:
	* src/compiler.c: Renamed to tools/compiler.c:
	* src/g-idl-offsets.pl: Renamed to tools/g-idl-offsets.pl:
	* src/generate.c: Renamed to tools/generate.c:
	* src/gidlmodule.c: Renamed to tools/gidlmodule.c:
	* src/gidlmodule.h: Renamed to tools/gidlmodule.h:
	* src/gidlnode.c: Renamed to tools/gidlnode.c:
	* src/gidlnode.h: Renamed to tools/gidlnode.h:
	* src/gidlparser.c: Renamed to tools/gidlparser.c:
	* src/gidlparser.h: Renamed to tools/gidlparser.h:
	* src/gidlwriter.c: Renamed to tools/gidlwriter.c:
	* src/gidlwriter.h: Renamed to tools/gidlwriter.h:
	* src/ginfo.c: Renamed to girepository/ginfo.c:
	* src/ginvoke.c: Renamed to girepository/ginvoke.c:
	* src/girepository.c: Renamed to girepository/girepository.c:
	* src/girepository.h: Renamed to girepository/girepository.h:
	* src/gmetadata.c: Renamed to girepository/gmetadata.c:
	* src/gmetadata.h: Renamed to girepository/gmetadata.h:
	* src/scanner.c: Renamed to tools/scanner.c:
	* src/scanner.h: Renamed to tools/scanner.h:
	* src/scannerlexer.l: Renamed to tools/scannerlexer.l:
	* src/scannerparser.y: Renamed to tools/scannerparser.y:
	* tests/invoke/Makefile.am:
	Split src/ into girepository/ and tools/

	* Makefile.am:
	* configure.ac:
	* girepository/Makefile.am:
	* tests/Makefile.am:
	* tests/invoke/Makefile.am:
	* tests/parser/Makefile.am:
	* tests/roundtrips.sh:
	* tools/Makefile.am:
	Make distcheck work.

svn path=/trunk/; revision=104
2024-01-15 22:44:41 -08:00
Gustavo J. A. M. Carneiro
cec833af42 reviewed by: Johan Dahlin <johan@gnome.org>
2007-12-06  Gustavo J. A. M. Carneiro  <gjc@gnome.org>

	reviewed by: Johan Dahlin  <johan@gnome.org>

	* configure.ac:
	* gobject-introspection.pc.in:
	* src/Makefile.am:
	* src/compiler.c: (format_output), (write_out_metadata), (main):
	* src/gen-introspect.c: (main):
	* src/gen-introspect.h:
	* src/generate.c: (write_callable_info), (write_repository),
	(load_metadata), (main):
	* src/gidlmodule.c: (g_idl_module_new),
	(g_idl_module_build_metadata):
	* src/gidlmodule.h:
	* src/gidlparser.c: (start_element_handler):
	* src/ginfo.c: (g_info_new), (g_info_from_entry),
	(g_base_info_get_name), (g_base_info_get_namespace),
	(g_base_info_is_deprecated), (g_base_info_get_annotation),
	(g_base_info_get_metadata), (g_function_info_get_symbol),
	(g_function_info_get_flags), (g_function_info_get_property),
	(g_function_info_get_vfunc), (signature_offset), (g_type_info_new),
	(g_callable_info_may_return_null),
	(g_callable_info_get_caller_owns), (g_callable_info_get_n_args),
	(g_callable_info_get_arg), (g_arg_info_get_direction),
	(g_arg_info_is_return_value), (g_arg_info_is_dipper),
	(g_arg_info_is_optional), (g_arg_info_may_be_null),
	(g_arg_info_get_ownership_transfer), (g_type_info_is_pointer),
	(g_type_info_get_tag), (g_type_info_get_param_type),
	(g_type_info_get_interface), (g_type_info_get_array_length),
	(g_type_info_is_zero_terminated),
	(g_type_info_get_n_error_domains), (g_type_info_get_error_domain),
	(g_error_domain_info_get_quark), (g_error_domain_info_get_codes),
	(g_value_info_get_value), (g_field_info_get_flags),
	(g_field_info_get_size), (g_field_info_get_offset),
	(g_registered_type_info_get_type_name),
	(g_registered_type_info_get_type_init),
	(g_struct_info_get_n_fields), (g_struct_info_get_field),
	(g_struct_info_get_n_methods), (g_struct_info_get_method),
	(find_method), (g_struct_info_find_method),
	(g_enum_info_get_n_values), (g_enum_info_get_value),
	(g_object_info_get_parent), (g_object_info_get_type_name),
	(g_object_info_get_type_init), (g_object_info_get_n_interfaces),
	(g_object_info_get_interface), (g_object_info_get_n_fields),
	(g_object_info_get_field), (g_object_info_get_n_properties),
	(g_object_info_get_property), (g_object_info_get_n_methods),
	(g_object_info_get_method), (g_object_info_find_method),
	(g_object_info_get_n_signals), (g_object_info_get_signal),
	(g_object_info_get_n_vfuncs), (g_object_info_get_vfunc),
	(g_object_info_get_n_constants), (g_object_info_get_constant),
	(g_interface_info_get_n_prerequisites),
	(g_interface_info_get_prerequisite),
	(g_interface_info_get_n_properties),
	(g_interface_info_get_property), (g_interface_info_get_n_methods),
	(g_interface_info_get_method), (g_interface_info_find_method),
	(g_interface_info_get_n_signals), (g_interface_info_get_signal),
	(g_interface_info_get_n_vfuncs), (g_interface_info_get_vfunc),
	(g_interface_info_get_n_constants),
	(g_interface_info_get_constant), (g_property_info_get_flags),
	(g_signal_info_get_flags), (g_signal_info_get_class_closure),
	(g_signal_info_true_stops_emit), (g_vfunc_info_get_flags),
	(g_vfunc_info_get_offset), (g_vfunc_info_get_signal),
	(g_constant_info_get_value), (g_union_info_get_n_fields),
	(g_union_info_get_field), (g_union_info_get_n_methods),
	(g_union_info_get_method), (g_union_info_is_discriminated),
	(g_union_info_get_discriminator_offset),
	(g_union_info_get_discriminator):
	* src/ginvoke.c: (g_function_info_invoke):
	* src/girepository.c: (g_irepository_register),
	(g_irepository_unregister), (g_irepository_get_default),
	(count_interfaces), (g_irepository_get_n_infos), (find_interface),
	(g_irepository_get_info), (g_irepository_find_by_name),
	(g_irepository_get_shared_library),
	(g_irepository_build_search_path), (g_irepository_register_file),
	(g_irepository_error_quark):
	* src/girepository.h:
	* src/gmetadata.c: (g_metadata_get_dir_entry),
	(g_metadata_check_sanity), (validate_header),
	(validate_array_type_blob), (validate_iface_type_blob),
	(validate_param_type_blob), (validate_error_type_blob),
	(validate_type_blob), (validate_arg_blob),
	(validate_signature_blob), (validate_function_blob),
	(validate_callback_blob), (validate_constant_blob),
	(validate_value_blob), (validate_field_blob),
	(validate_property_blob), (validate_signal_blob),
	(validate_vfunc_blob), (validate_struct_blob),
	(validate_enum_blob), (validate_object_blob),
	(validate_interface_blob), (validate_errordomain_blob),
	(validate_union_blob), (validate_blob), (validate_directory),
	(validate_annotations), (g_metadata_validate), (_g_metadata_init),
	(g_metadata_new_from_memory), (g_metadata_new_from_const_memory),
	(g_metadata_new_from_mapped_file), (g_metadata_free),
	(g_metadata_set_module), (g_metadata_get_namespace):
	* src/gmetadata.h:
	* tests/Makefile.am:
	* tests/invoke/Makefile.am:
	* tests/invoke/invoke-namespace-find.sh:
	* tests/invoke/invoke.c: (main):

	Add a namespace/shared library mapping. fixes #313268.


svn path=/trunk/; revision=66
2024-01-15 22:44:41 -08:00
Torsten Schönfeld
35527e755c Hush compiler warnings about return values, signedness mismatches, unused
* src/compiler.c, src/generate.c, src/gidlnode.c,
	src/gidlparser.c, src/ginfo.c, src/girepository.c,
	tests/invoke/invoke.c, test/invoke/testfns.c: Hush compiler
	warnings about return values, signedness mismatches, unused
	variables, and unhandles enum values in switch statements.

	* tests/invoke/Makefile.am: Don't install the invoke test program.
	Add -I ../../src to the cflags used for the test functions files.
2024-01-15 22:44:41 -08:00
Matthias Clasen
f8e471a64c Use it here to validate the generated metadata.
2005-05-24  Matthias Clasen  <mclasen@redhat.com>

	* src/compiler.c (main): Use it here to validate
	the generated metadata.

	* src/gmetadata.[hc]: Add code to validate a
	metadata blob.
2024-01-15 22:44:41 -08:00
Matthias Clasen
30d7eb93c5 Make the generated C code compile.
2005-05-13  Matthias Clasen  <mclasen@redhat.com>

	* src/compiler.c (format_output): Make the generated
	C code compile.

	* README: Point to a recent libffi snapshot.

	* tests/invoke/*: Some invoke tests.

	* src/Makefile: Add ginvoke.c and the necessary
	libffi information.

	* src/girepository.h (g_function_info_invoke): Add
	a GError argument.

	* src/ginvoke.c (g_function_info_invoke): Initial
	implementation of invoke functionality based on libffi.
2024-01-15 22:44:41 -08:00
Matthias Clasen
f10d33064a Some fixes 2024-01-15 22:44:40 -08:00
Matthias Clasen
18f3b27fa0 Add a --verbose cmdline option and only log messages if it is specified.
2005-05-11  Matthias Clasen  <mclasen@redhat.com>

	* src/compiler.c (main): Add a --verbose cmdline option
	and only log messages if it is specified.

	* src/gidlnode.h:
	* src/gidlnode.c (init_stats, dump_stats): Collect some
	statistics on string and type sharing.

	* src/gidlmodule.c (g_idl_module_build_metadata): Use
	g_message() instead of fprintf().

	* src/gidlnode.c (g_idl_node_free): Make this more robust.
	(g_idl_node_get_size): Implement for structs.
	(g_idl_node_get_full_size): Handle parent being NULL.
	(serialize_type): Handle lookup failures more gracefully.
2024-01-15 22:44:40 -08:00
Matthias Clasen
4d84e48c1a Correct the size calculation for 2-parameter types and for objects.
2005-05-10  Matthias Clasen  <mclasen@redhat.com>

	* src/gidlnode.c (g_idl_node_get_full_size): Correct the
	size calculation for 2-parameter types and for objects.

	* src/compiler.c: Add a cmdline option for debug output
	and install a log handler to implement it.
	* src/gidlnode.c: Add some debug spew.
2024-01-15 22:44:40 -08:00
Matthias Clasen
bc21d3a976 Free the option context.
2005-05-09  Matthias Clasen  <mclasen@redhat.com>

	* src/compiler.c (main): Free the option context.
2024-01-15 22:44:40 -08:00
Matthias Clasen
5aada59bcb Initial revision 2024-01-15 22:44:40 -08:00
Philip Withnall
35fe0d0bba Merge branch 'girrepository-cleanups' into 'main'
girepository: Misc cleanups

See merge request GNOME/glib!3823
2024-01-15 22:25:03 +00:00
Marco Trevisan (Treviño)
2ee2088f4a girrepository: Drop trailing new line on GMessages 2024-01-15 21:26:53 +00:00
Marco Trevisan (Treviño)
d78b6c55bc girepository/tests: Add further checks on GObject methods infos 2024-01-15 21:26:42 +00:00
Marco Trevisan (Treviño)
18d0b0eb40 girepository: Move cmph-bdz test to tests subfolder
We can avoid to maintain the special case and still works fine
2024-01-15 21:26:40 +00:00
Alex Richardson
dd2a42cad2 brz.c: Use uintptr_t instead of a hardcoded list of 64-bit arches
This also fixes the build for AArch64 since cmph_uint32 is not big
enough to hold a pointer there. I found this while building for CHERI
since the compiler errors there when casting from a non-inptr_t integer.
This also fixes warnings when building for AArch64 with clang.
2024-01-15 13:10:32 -08:00
Marco Trevisan (Treviño)
8a4755106d girepository: Add gthash test to tests and run it 2024-01-15 18:16:56 +01:00
Philip Withnall
dcf1884790 gicallableinfo: Drop const qualifier from out-args of invoke()
Not sure what it was doing there — these arguments get written to as
part of the invocation. The in-args should be `const` qualified, but not
the out-args.

This is an API break in libgirepository, but since it’s not been in a
stable release yet, that’s fine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:58:37 +00:00
Philip Withnall
e49ec6d7d8 gicallableinfo: Remove unnecessary arguments from invoke()
The whole point of a `GICallableInfo` struct is to contain information
about how a function is callable, and that includes information about
whether it’s a method and whether it throws a `GError`. The caller
shouldn’t need to specify those things separately.

So drop those arguments.

This is an API break in libgirepository, but since it’s not been in a
stable release yet, that’s fine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:58:37 +00:00
Philip Withnall
8e5ff50dd4 ginvoke: Fix signedness of variable in closure marshaller
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:58:37 +00:00
Philip Withnall
5a56518852 girffi: Fix signedness of argument in internal helper function
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:51:32 +00:00
Philip Withnall
513e178144 gitypelib: Rename gi_typelib_check_sanity() to gi_typelib_check_format()
It’s more descriptive and less offensive.

This is not an API break as it’s not a public API.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:51:28 +00:00
Philip Withnall
0910e2f6ad girepository: Drop outdated/unused GIInfoType member
It was deprecated since before libgirepository was moved into this
repository. Take the opportunity now to remove it entirely, as it’s a
bit confusing to have it in the public API.

This should not affect the binary typelib format, as it still has its
`BLOB_TYPE_INVALID_0` member, and that will remain in place until the
binary format next breaks compatibility (no plans to do that).

This is an API break in libgirepository, but since it’s not been in a
stable release yet, that’s fine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:51:23 +00:00
Philip Withnall
64725d8cae girepository: Make gi_repository_get_shared_library() return an array
And rename it to `gi_repository_get_shared_libraries()`. Previously it
returned a comma-separated string, which wasn’t particularly typesafe or
machine-friendly. Now it returns the same data as an array.

This is an API break in libgirepository, but since it’s not been in a
stable release yet, that’s fine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:51:18 +00:00
Philip Withnall
bbe9046ade girepository: Make gi_repository_get_info() not nullable
Having it be nullable means the type system forces the caller to check
the result for nullability every time, even though it’s straightforward
for the caller to check the index argument in advance and guarantee a
non-`NULL` result.

Change `gi_repository_get_info()` to never return `NULL` to tidy this
up. This also brings it inline with other `gi_*_get_info()` functions,
which are not nullable.

This is an API break in libgirepository, but since it’s not been in a
stable release yet, that’s fine.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2024-01-05 13:51:13 +00:00
Simon McVittie
e6c8c75ccc girepository: Skip GIRepository versions not matching GIRepository-3.0
A few applications such as gnome-music load the GIRepository typelib
and use it to adjust their search paths.

GLib 2.79.x now provides libgirepository-2.0.so.0 (GIRepository-3.0),
but each OS distribution is likely to have a transitional period during
which GLib's libgirepository-2.0.so.0 has become available, but bindings
like PyGI and gjs are still linked to gobject-introspection's
libgirepository-1.0.so.1 (GIRepository-2.0).

During this transitional period, interpreted languages that load the
GIRepository namespace could get the "wrong" version, which will result
in adjusting a search path that will not actually affect the language
binding's typelib lookup, and could also lead to symbol and type-system
conflicts.

We can avoid this collision by making GLib's GIRepository library refuse
to load versions of the GIRepository typelib that are not 3.0, and
similarly making gobject-introspection's GIRepository library refuse to
load typelib versions that are not 2.0. A relatively neat way to achieve
that is to make each version behave as if the other one doesn't exist.

Signed-off-by: Simon McVittie <smcv@debian.org>
2023-12-29 15:45:02 +00:00
Philip Withnall
ec3fb9a48c Merge branch 'glib-gir-sources' into 'main'
gobject: Make GLib-2.0 gir build depend on GObject dependency

See merge request GNOME/glib!3772
2023-12-22 14:45:37 +00:00
Philip Withnall
a35c6f764d girepository: Re-number GIR file from 2.0 to 3.0
The library shipped by gobject-introspection.git was
`libgirepository-1.0.so`, but for some reason (accident?), it was
accompanied by `GIRepository-2.0.gir`. That’s been the case for the last
6 years.

In moving libgirepository to glib.git, we’ve bumped the version to
`libgirepository-2.0.so`, and have changed the API.

In order to avoid a collision between the new `GIRepository-2.0.gir` and
the old `GIRepository-2.0.gir`, we can either:
 * Rename the basename of the library (confusing).
 * Re-version the whole thing to 3.0 (would mean it’s completely out of
   sync with the rest of glib.git, and would lead to build system
   misery).
 * Re-version only the GIR file (a bit confusing, but hopefully less
   confusing).

So I’ve done the final option: glib.git now ships
`libgirepository-2.0.so` and `GIRepository-3.0.gir`. This avoids
collisions with what’s shipped by gobject-introspection.git, while
hopefully still making some sense.

We considered using version number 2.1 rather than 3.0, but decided
against it because that makes it look like it’s compatible with version
2.0, which it isn’t.

Note that none of these changes touch the
`${prefix}/lib/girepository-1.0` and `${prefix}/share/gir-1.0`
directories. The version numbers in those refer to the versions of the
GIR and typelib file formats, which have not changed.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3155
2023-12-22 12:21:57 +00:00
Marco Trevisan (Treviño)
8e26e7aee2 girepository: Clarify docstring about which kind of strings are formatted 2023-12-21 14:14:27 +01:00