Commit Graph

482 Commits

Author SHA1 Message Date
Colin Walters
ff45096d96 Fix indentation
svn path=/trunk/; revision=618
2024-02-08 13:53:59 +00:00
Colin Walters
4ae9d0f2fa Add check to make sure we're not hitting out unresolved types
svn path=/trunk/; revision=616
2024-02-08 13:53:59 +00:00
Colin Walters
95b9645166 Print out "any" for VOID+pointer, not "none"
* tools/generate.c: Print out "any" for VOID+pointer,
	not "none"

svn path=/trunk/; revision=610
2024-02-08 13:53:59 +00:00
Colin Walters
77683a327f Allow both union and struct to be boxed or not
* girepository/girnode.c: Allow gtype_name
	and gtype_init in struct and union.
	* girepository/girparser.c: Parse glib:
	boxed bits for both structure and union.
	* girepository/gtypelib.c: Don't barf
	if structure is boxed.
	* giscanner/girparser.py: Parse new XML
	format.
	* giscanner/girwriter.py: Write out new
	XML format.
	* giscanner/glibast.py: Define new classes
	which are both Boxed and Struct/Union, as
	well as an "Other" for everything else.
	* giscanner/glibtransformer.py: Handle
	boxed types specially; we try to merge
	them with a struct/union if one exists,
	otherwise fall back to generic boxed.
	* tests/*: Update.
	* tools/generate.c: Write out new format.

svn path=/trunk/; revision=575
2024-02-08 13:53:59 +00:00
Colin Walters
886b9c66c5 Remove g_irepository_unregister, add GIRepositoryLoadFlags
svn path=/trunk/; revision=543
2024-02-08 13:53:59 +00:00
Colin Walters
030b17bc9f 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-02-08 13:53:59 +00:00
Colin Walters
56428ae349 Correctly handle GLib.List, GLib.Error etc
* girepository/girparser.c: Accept both List (for
	compiling GLib) and GLib.List (what the scanner
	generates).
	* tests/ - Update.
	* tools/generate.c: Generate canonical form.

svn path=/trunk/; revision=522
2024-02-08 13:53:59 +00:00
Tor Lillqvist
97e04b2b5d Make g-ir-scanner work on Windows. Still problems with the typelib code.
2008-08-27  Tor Lillqvist  <tml@novell.com>

	Make g-ir-scanner work on Windows. Still problems with the typelib
	code. Changes okayed by jdahlin.

	* configure.ac: Check for Windows, set Automake conditional
	OS_WIN32. Change backslashes to forward slashes in pyexecdir to
	avoid shell quoting issues
	
	* girepository/Makefile.am: Use -no-undefined so that libtool
	agrees to build a shared library on Windows.

	* girepository/girparser.c (backtrace_stderr): No backtrace() on
	Windows. Empty implementation on Windows so far.

	* girepository/gtypelib.c (g_typelib_check_sanity): Give more
	informative error message for the assertion failures. Tell also
	what the expected size of the struct is. Check all sizes first and
	fail afterwards if at least one size was different from expected.

	* tools/Makefile.am: Reorder libraries into proper logical
	dependency order.

	* tools/generate.c: Don't include <dlfcn.h>, not used.

	* giscanner/Makefile.am: On Windows, link with the Python library,
	and install the module DLL as _giscanner.pyd. Remove the
	unnecessary import library and libtool library that libtool has
	installed.

	* giscanner/scannerlexer.l: Recognize the gcc __attribute__ syntax
	and just skip it. Recognize also two "l" suffixes for long long
	constants. Recognize also __inline__.

	* giscanner/grealpath.h (g_realpath): Implement on Windows, using
	GetFullPathName(). As such, GetFullPathName() does more than the
	UNIX realpath(). It also changes relative paths into absolute
	paths. But for our purposes that shouldn't matter.

	* giscanner/giscannermodule.c (pygi_source_scanner_parse_file): On
	Windows the file descriptor passed to us is from Python. Python
	Python2.5 uses the msvcr71.dll C library, while mingw-built code
	uses msvcrt.dll. On Windows, file descriptors are specific to
	which C library is used. So we must find out what underlying OS
	handle corresponds to the file descriptor Python passes us, and
	then make that into a file descriptor valid for the C library this
	code uses.

	* giscanner/sourcescanner.py (_parse): Don't need to bypass
	__attribute__ as the lexer now handles it. The definition as empty
	was ineffective for mingw anyway, as mingw's _mingw.h undefines
	__attribute__. Close the temp file before unlinking it.

	* giscanner/cgobject.py: Use correct library name for the gobject
	DLL on Windows.

	* gir/Makefile.am: Must pass the full basename of the DLLs on
	Windows to g-ir-scanner. It's a bit ugly that we have to "know"
	that the names of the GLib DLLs are like libglib-2.0-0.dll, but in
	reality they won't change, until there is a GLib 3, and then also
	the Unix code here needs changing.

	Must pass CPPFLAGS to g-ir-scanner when building GLib.gir so that
	libintl.h is found.


svn path=/trunk/; revision=503
2024-02-08 13:53:59 +00:00
Colin Walters
c306fea286 Parse new implements syntax, drop gapi one. Update. Generate new syntax.
2008-08-25  Colin Walters  <walters@verbum.org>

	* girepository/girparser.c: Parse new implements
	syntax, drop gapi one.
	* tests/object.gir: Update.
	* tools/generate.c: Generate new syntax.

svn path=/trunk/; revision=492
2024-02-08 13:53:59 +00:00
Colin Walters
fc4cffc61d 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-02-08 13:53:59 +00:00
Colin Walters
a91b3dba67 Install config.py, better error handling if we forget --raw
svn path=/trunk/; revision=461
2024-02-08 13:53:59 +00:00
Colin Walters
cf73901c6b Pass through recursive types. Avoid overwriting errors. Always write the
2008-08-22  Colin Walters  <walters@verbum.org>

	* girepository/girparser.c: Pass through
	recursive types.  Avoid overwriting errors.
	* giscanner/xmlwriter.py: Always write the
	XML header.
	* tests/*.gir: Adjust.
	* tests/scanner/Makefile.am: Build typelibs,
	and generate XML from those.  Once we
	have a good diff mechanism...
	* tests/scanner/*-expected.gir: Add XML
	header.
	* tools/g-ir-scanner: Accept --typelib-xml
	option.
	* tools/generate.c: Better defaults for transfer.

svn path=/trunk/; revision=457
2024-02-08 13:53:59 +00:00
Colin Walters
ab1e9433db Don't put * in types, suppress transfer="none"
svn path=/trunk/; revision=453
2024-02-08 13:53:59 +00:00
Colin Walters
e1cd668950 Fix unref sequence.
2008-08-22  Colin Walters  <walters@verbum.org>

	* tools/generate.c (write_callable_info): Fix unref
	sequence.

svn path=/trunk/; revision=449
2024-02-08 13:53:59 +00:00
Colin Walters
d922fdb5fc Add g-ir-generate. Support $(DEBUG) Do immediate close tags if no
2008-08-22  Colin Walters  <walters@verbum.org>

	* gobject-introspection-1.0.pc.in: Add g-ir-generate.
	* tests/Makefile.am: Support $(DEBUG)
	* tools/generate.c: Do immediate close tags if no
	sub-elements.

svn path=/trunk/; revision=448
2024-02-08 13:53:59 +00:00
Johan Dahlin
2f803f62e6 Fix generator for constant/gobject/struct
2008-08-14  Johan Dahlin  <johan@gnome.org>

    * tests/Makefile.am:
    * tests/constant.gir:
    * tests/gobject.gir:
    * tests/struct.gir:
    * tools/generate.c (write_struct_info):
    Fix generator for constant/gobject/struct


svn path=/trunk/; revision=379
2024-02-08 13:53:59 +00:00
Johan Dahlin
5d3fe6f2f0 Fix generation of enum/bitfields
2008-08-14  Johan Dahlin  <johan@gnome.org>

    * tests/Makefile.am:
    * tests/enum.gir:
    * tools/generate.c (write_enum_info):
    Fix generation of enum/bitfields


svn path=/trunk/; revision=378
2024-02-08 13:53:59 +00:00
Johan Dahlin
f49fa21c31 Clear up constant parsing
2008-08-14  Johan Dahlin  <johan@gnome.org>

    * girepository/girparser.c (start_field), (start_constant),
    (start_type), (end_element_handler):
    Clear up constant parsing

    * tests/object.gir:
    Update

    * tools/generate.c (write_callable_info), (write_function_info),
    (write_callback_info), (write_constant_info), (write_signal_info),
    (write_vfunc_info), (write_property_info), (write_object_info),
    (write_interface_info):
    Constants/Signals are handled now.


svn path=/trunk/; revision=377
2024-02-08 13:53:59 +00:00
Johan Dahlin
8ed19c3d86 Don't require c:type. Test boxed.gir Update, remove parts we don't support
2008-08-14  Johan Dahlin  <johan@gnome.org>

    * girepository/girparser.c (start_type):
    Don't require c:type.
    * tests/Makefile.am:
    Test boxed.gir
    * tests/boxed.gir:
    Update, remove parts we don't support yet
    * tests/roundtrips.sh:
    Remove
    * tools/generate.c (write_type_info), (write_field_info),
    (write_callable_info), (write_struct_info):
    Make it emit proper gir.


svn path=/trunk/; revision=376
2024-02-08 13:53:59 +00:00
Johan Dahlin
c2bbd6ecba 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-02-08 13:53:59 +00:00
Johan Dahlin
dcd26fddc7 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-02-08 13:53:59 +00:00
Philip Van Hoof
5d80d5082c 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-02-08 13:53:59 +00:00
Johan Dahlin
64d32c97b5 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-02-08 13:53:59 +00:00
Johan Dahlin
c7c1c96c2b 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-02-08 13:53:59 +00:00
Mark Doffman
cff3cc7ad9 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-02-08 13:53:59 +00:00
Mark Doffman
eb13d2e55b girepository/ginfo.c tools/generate.c
2008-02-21  Mark Doffman  <mark.doffman@codethink.co.uk>

    * girepository/ginfo.c
    * tools/generate.c

    Change the way that external references with no namespace
    are dealt with. External references with no namespace
    are placed into the XML as-if they are a local reference.
    This is temporary, but helps with roundtrip tests.

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

svn path=/trunk/; revision=134
2024-02-08 13:53:59 +00:00
Mark Doffman
e56744c907 girepository/ginfo.c girepository/girepository.h tools/generate.c
2008-02-21  Mark Doffman  <mark.doffman@codethink.co.uk>

    * girepository/ginfo.c
    * girepository/girepository.h
    * tools/generate.c

      Add a function to check if an enum is registered or not.
      Previously anything testing this relied on the g-type
      string offset having a value of 0.

    * girepository/gmetadata.c
    * girepository/gmetadata.h
    * tools/generate.c

      Remove unneccesary or erroneous checks. There were two
      metadata validation checks which made sure that the blob
      sizes were the same as some magic numbers compiled into the code.
      This is wrong as it breaks any forwards compatibility that may
      be possible.

      Checks were also present that made sure that unregistered type
      blobs had a value of 0 in the g-type offset field. This is
      unneccessary. If a type blob is unregistered then any value
      in its g-type field is simply invalid.

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

svn path=/trunk/; revision=132
2024-02-08 13:53:59 +00:00
Mark Doffman
9e6472853a girepository/ginvoke.c girepository/girepository.h
2008-02-21  Mark Doffman  <mark.doffman@codethink.co.uk>

    * girepository/ginvoke.c
    * girepository/girepository.h
    * girepository/gmetadata.c
    * girepository/gmetadata.h
    * tools/generate.c
    * tools/gidlparser.c

      Modify TYPE_TAG_INTERFACE to TYPE_TAG_SYMBOL
      to avoid confusion with the interface blob.

    * tools/generate.c
    * tools/gidlparser.c

      Remove magic numbers and replace with type-tag
      enumeration symbols.

    * girepository/gmetadata.c
      Add validate declaration.

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

svn path=/trunk/; revision=129
2024-02-08 13:53:59 +00:00
Rob Taylor
a7d0962d46 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-02-08 13:53:59 +00:00
Gustavo J. A. M. Carneiro
2b0304b865 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-02-08 13:53:59 +00:00
Torsten Schönfeld
00a6f8ada0 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-02-08 13:53:59 +00:00
Matthias Clasen
94d45e70a0 Fix a segfault 2024-02-08 13:53:59 +00:00
Matthias Clasen
b1cf4d87c9 Add struct offsets to field and vfunc elements.
2005-05-22  Matthias Clasen  <mclasen@redhat.com>

	* tests/*: Add struct offsets to field and vfunc
	elements.

	* src/generate.c (write_vfunc_info): Write offset
	information for vfuncs.

	* src/gidlnode.c (g_idl_node_build_metadata): Write
	the struct offsets into the metadata.

	* src/gidlparser.c: Parse the offset attributes of
	field and vfunc elements.

	* src/gidlnode.h: Add offset members to field and
	vfunc nodes.
2024-02-08 13:53:59 +00:00
Matthias Clasen
1ae704b2b7 Basic type cleanup 2024-02-08 13:53:59 +00:00
Matthias Clasen
45405a6143 Add gdk-pixbuf.gidl as an example, and fix the code to handle it. 2024-02-08 13:53:59 +00:00
Matthias Clasen
45cf94a492 Add union.test.
2005-05-15  Matthias Clasen  <mclasen@redhat.com>

        * tests/roundtrips.sh (SIMPLE_TESTS): Add union.test.

        * tests/union.test: Add a union test.

        * src/generate.c: Handle unions.

        * src/girepository.h:
        * src/ginfo.c: Add GIUnionInfo and functions to access it.

        * src/gidlnode.c: Handle GIdlNodeUnion nodes.

        * src/gidlparser.c (start_union): Parse <union> elements.

        * src/gidlnode.h: Add a GIdlNodeUnion.

        * gidl.dtd: Add a <union> element.

        * src/gmetadata.c (g_metadata_check_sanity): Check
        union_blob_size.

        * src/gmetadata.h: Add union_blob_size to Header,
        add a UnionBlob.

        * metadata-format.txt: Add a UnionBlob.
2024-02-08 13:53:59 +00:00
Matthias Clasen
264b3adc76 Update testcases.
2005-05-13  Matthias Clasen  <mclasen@redhat.com>

	* tests/*: Update testcases.

	* src/generate.c (write_callable_info): Don't forget to
	write transfer and null-ok attributes for return types
	and parameters.

	* src/girepository.h:
	* src/ginfo.c (g_callable_info_may_return_null):
	New function to find out if a function may return NULL.
2024-02-08 13:53:59 +00:00
Johan Dahlin
02ef0d66f2 Generate consistent end tags.
* src/generate.c: Generate consistent end tags.

	* tests/*: Update
2024-02-08 13:53:59 +00:00
Matthias Clasen
b0fa1e8965 Some fixes 2024-02-08 13:53:58 +00:00
Matthias Clasen
bf4631bf28 Clean up handling of names. All elements have a "name", only the elements
2005-05-09  Matthias Clasen  <mclasen@redhat.com>

	* gidl.dtd: Clean up handling of names. All elements
	have a "name", only the elements corresponding to
	actual callable functions (function, method, constructor),
	have an additional "symbol" attribute holding the
	dlsym()-able function name.

	* src/generate.c: Adapt to generate xml matching the
	new dtd.

	* src/gidlparser.c:
	* src/gidlnode.c: Adapt to parse the new dtd.

	* tests/*.test: Adjust to the new dtd.

	* metadata-format.txt:
	* src/gmetadata.h: Remove the short_name field
	from the ValueBlob.
	* src/gmetadata.c: Shrink size of ValueBlob to 12.
	* src/girepository.h:
	* src/ginfo.c (g_value_info_get_short_name): Removed
2024-02-08 13:53:58 +00:00
Matthias Clasen
34f49b2ca9 Initial revision 2024-02-08 13:53:58 +00:00
Philip Withnall
343027d5de girepository: Make GIInfoType private
Eventually, we want to move to using `GType` directly for everything,
since `GIBaseInfo` and its subclasses are all using `GTypeInstance`.

However, that requires quite a lot of changes and we’re about to hit the
API freeze.

So do the smallest set of changes possible to remove `GIInfoType` and
related functions from the public API, which gives us freedom to make
more changes later without breaking API.

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

Helps: #3155
2024-02-08 12:56:02 +00:00
Philip Withnall
86cd95f1ae Merge branch 'gi-info-new' into 'main'
gibaseinfo: Rename gi_info_new() to gi_base_info_new()

See merge request GNOME/glib!3903
2024-02-08 10:34:40 +00:00
Philip Withnall
beb59595b7 gibaseinfo: Rename gi_info_new() to gi_base_info_new()
It’s actually a factory method rather than a constructor, since
`GIBaseInfo` is abstract, but despite that, changing the name so it sits
inside the `GIBaseInfo` class makes sense. There is no `GIInfo` type.

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

Helps: #3155
2024-02-08 10:34:40 +00:00
Philip Withnall
e1cff511e5 Merge branch '3155-union-tests' into 'main'
gitypes: Fix integer values of GIInfoType and add unit tests for GIUnionInfo

See merge request GNOME/glib!3888
2024-02-08 10:25:13 +00:00
Philip Withnall
78698af73f Merge branch '3246-object-info-docs' into 'main'
girepository: Fix declaration of ‘find using interfaces’ methods

Closes #3246

See merge request GNOME/glib!3883
2024-02-08 10:19:16 +00:00
Philip Withnall
62abd578cd Merge branch '3155-typelib-boxed' into 'main'
gitypelib: Switch to refcounting

See merge request GNOME/glib!3900
2024-02-08 10:18:40 +00:00
Philip Withnall
a138589d57 Merge branch 'repository-n-elements' into 'main'
girepository: Add length ‘out’ arguments to several getter methods

See merge request GNOME/glib!3901
2024-02-08 10:18:12 +00:00
Philip Withnall
6929632ecb gitypelib: Add boxed type
This is needed because `GITypelib` is exposed in the public
libgirepository API, so needs to be introspectable.

This should fix a couple of warnings about `gi_repository_require()` and
related APIs not being introspectable as they return an unintrospectable
type.

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

Helps: #3155
2024-02-07 21:07:18 +00:00
Philip Withnall
5cc5f413f5 gitypelib: Switch to refcounting
Since `GITypelib` is exposed in the public libgirepository API, it needs
to be a boxed type. So we either need to add a `copy` method to mirror
the existing `free` method, or switch to refcounting. The latter option
seems better, since a `GITypelib` contains internal state about open
`GModule`s and the semantics for copying that would be potentially
complex.

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

Helps: #3155
2024-02-07 21:07:18 +00:00
Philip Withnall
389e8a439b gicallableinfo: Clarify docs for callables with no return type
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 15:59:56 +00:00
Philip Withnall
8f6926d4ce girepository: Document NULL-termination/length semantics for methods
This doesn’t change the existing behaviour, just documents it a bit more
clearly.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 15:47:13 +00:00
Philip Withnall
01f9796532 girepository: Add length ‘out’ arguments to several getter methods
This makes them consistent with the other getter methods in
`GIRepository` which return lists/arrays. It’s useful to return the
length, as that means the caller doesn’t have to work it out by
iterating over the entire array.

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

Helps: #3155
2024-02-07 15:47:13 +00:00
Philip Withnall
44e3ebccd1 tests: Add basic tests for GIUnionInfo
These would have caught the regression fixed in the previous commit.

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

Helps: #3155
2024-02-06 13:42:43 +00:00
Philip Withnall
c8946b8a92 gitypes: Fix integer values of GIInfoType
This effectively reverts commit 0910e2f6ad. I thought that `GIInfoType`
was decoupled from `GITypelibBlobType`, but it turns out that
`girepository.c` calls `gi_info_new_full()` with blob types, implicitly
converting them to info types.

This was causing anything with a type higher than the `INVALID_0` value
to be loaded as the wrong type.

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

Helps: #3155
2024-02-06 13:40:20 +00:00
Philip Withnall
e286497c1f giunioninfo: Mark get_discriminator_type() as nullable
It may (and should) return `NULL` if called on a union which isn’t
discriminated.

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

Helps: #3155
2024-02-06 13:35:23 +00:00
Philip Withnall
11e8075e51 giunioninfo: Split success and return value for get_discriminator_offset()
Otherwise there’s no obvious suitable return value to return when the
union is *not* discriminated.

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

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

Helps: #3155
2024-02-06 13:34:17 +00:00
Philip Chimento
614437107a tests: Add a test for finding methods and vfuncs in a GIObjectInfo
Helps: #3246
2024-02-05 18:40:58 +00:00
Philip Withnall
7acef299c2 girepository: Fix declaration of ‘find using interfaces’ methods
Fix the declaration and documentation of
`gi_object_info_find_method_using_interfaces()` and
`gi_object_info_find_vfunc_using_interfaces()`. The documentation was
wrong when I wrote it: the value returned is the object or interface
which declares the method or vfunc, not the one which implements it.

The returned declarer info may be a `GIObjectInfo` or a
`GIInterfaceInfo`. Since those two types have no subtype relation
between them, the return type has to be changed to `GIBaseInfo`. Using
`GIObjectInfo` would have been fine in girepository-1.0 because all
`*Info` types were aliases of each other — but since the move to
`GTypeInstance` this is no longer true.

A unit test will be in the following commit.

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

Fixes: #3246
2024-02-05 18:40:03 +00:00
Philip Withnall
c8132fdf78 girepository: Rename gi_arg_info_load_type() to gi_arg_info_load_type_info()
So that it matches `gi_arg_info_get_type_info()`. We can’t use
`gi_arg_info_get_type()` because that collides with the `GType` getter
for the type.

Spotted by Philip Chimento.

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

Fixes: #3243
2024-02-05 15:13:46 +00:00
Philip Chimento
3a01629955 girepository: Fix copy-paste error in type check macro
GI_IS_REGISTERED_TYPE_INFO() wasn't working because it was actually
defined to be the same as GI_IS_OBJECT_INFO().

Add some desultory type-checking assertions to the repository tests.
2024-02-04 10:16:31 -08:00
Philip Chimento
f19115213a girepository: Add type check to instance parameter
gi_repository_enumerate_versions() was missing a type check of the
instance parameter. This helps catch mistakes when porting from
girepository 1.x where the parameter was allowed to be null.
2024-02-04 09:14:51 -08:00
Philip Withnall
2a99d4b168 girepository: Expose GITypeInfo and GIArgInfo as stack allocatable
There are a handful of APIs in libgirepository which are used on
performance-sensitive code paths in language bindings (such as looking
at arguments when doing function calls). Historically libgirepository
has provided a stack-allocated variant for them, which avoids returning
a newly allocated `GIBaseInfo`. Since moving to glib.git and porting to
`GTypeInstance`, that stack allocated version has been broken.

This commit fixes it, by exposing obfuscated stack allocatable versions
of `GITypeInfo` and `GIArgInfo`, which are the two `GIBaseInfo`
subtypes which can be returned by the stack allocation functions.

The commit includes unit tests for them.

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

Fixes: #3217
2024-01-31 15:49:38 +00:00
Philip Withnall
47b2fd8168 Merge branch 'repository-mfile-leak' into 'main'
girepository: Fix a memory leak of a mapped file

See merge request GNOME/glib!3861
2024-01-31 12:31:36 +00:00
Evan Welsh
3bd7635516 girepository: Cleanup compiler.c formatting 2024-01-31 11:13:16 +00:00
Evan Welsh
5d997cad03 girepository: Update gi-compile-repository and use it to compile GIRs
Adapt gi-compile-repository sources to compile against the updated
libgirepository that is included with GLib.

This also renames "g-ir-compiler" to "gi-compile-repository" to avoid
overwriting the existing binary and to simplify the binary name going
forward.
2024-01-31 11:13:16 +00:00
Philip Withnall
d5954664f2 girepository: Fix a memory leak of a mapped file
This was introduced by me in commit
1eec66c898, as the ownership transfer
semantics of `gi_typelib_new_from_mapped_file()` were not blatant.

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

Helps: #3237
2024-01-30 07:45:11 +00:00
Evan Welsh
f75221c7ea girepository: Move GIR generation into girepository and prior to tests
To enable tests which depend on libgirepository's GIR and typelib,
we need to refactor the order we're currently building these items.

We can also move everything under girepository/ to cleanup the
top-level.
2024-01-30 00:50:40 -06:00
Philip Withnall
b24b54af5b girepository: Drop gi_repository_get_default()
We now only support creating `GIRepository` instances as normal
GObjects, not as a global singleton. This makes the semantics of the
class a bit more standard and, in particular, makes it easier to ensure
that everything is freed when we’re done with libgirepository. This is
particularly useful for unit testing, but should also be useful when
unloading modules from bindings.

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

Helps: #3155
2024-01-26 12:08:17 +00:00
Philip Withnall
9ab84bc14a girwriter: Stop using the singleton GIRepository
It’s soon going to disappear.

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

Helps: #3155
2024-01-26 12:08:17 +00:00
Philip Withnall
80f9153a7f girepository: Move search and library paths into GIRepository
Rather than them being set and stored globally, make them members of
`GIRepository`. This helps us move away from the concept of a global
singleton `GIRepository`.

This is slightly complicated by the fact that the library paths are
needed within the module loading code in `GITypelib`, but at that point
the `GITypelib` doesn’t have access to its parent `GIRepository` to call
`gi_repository_get_library_path()`, so we have to cache them in
`typelib->library_paths`.

It also means that it’s no longer possible to retrieve the ‘unset’ paths
from the globals, so the test for that is removed from
`repository-search-paths.c`.

This commit makes some API breaks, but that’s OK because libgirepository
has not been in a stable release yet.

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

Helps: #3155
2024-01-26 12:08:17 +00:00
Philip Withnall
5ef1c7e110 girepository: Move library path functions over from gitypelib.c
This means they’re implemented in the same file as the typelib search
path, so it’s easier to refactor the code.

This adds `gi_repository_get_library_path()` to expose the library path,
both publicly and to internal users in `gitypelib.c`. And unit tests.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 12:01:01 +00:00
Philip Withnall
846abed197 girepository: Move a helper method
This introduces no functional changes, but simplifies an upcoming
commit.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 10:53:21 +00:00
Philip Withnall
b4063e1fa8 Merge branch 'typelib-bytes' into 'main'
gitypelib: Replace multiple constructors with gi_typelib_new_from_bytes()

See merge request GNOME/glib!3855
2024-01-26 10:15:49 +00:00
Philip Withnall
1eec66c898 gitypelib: Replace multiple constructors with gi_typelib_new_from_bytes()
`GBytes` provides a way of handling const memory blobs, stolen memory
blobs, and mapped files. Rather than having `GITypelib` implement all of
those itself, just take a `GBytes` as input.

This is an API break, but libgirepository hasn’t been in a stable
release yet.

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

Helps: #3155
2024-01-26 09:51:13 +00:00
Philip Withnall
0909b2e3ac girnode: Improve int types in GIIrNodeUnion
`GIIrNodeUnion` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

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

Helps: #3155

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 09:29:30 +00:00
Philip Withnall
2e7518bcc1 girnode: Improve int types in GIIrNodeEnum
`GIIrNodeEnum` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

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

Helps: #3155

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 09:29:30 +00:00
Philip Withnall
501ff95cea girnode: Improve int types in GIIrNodeField
`GIIrNodeField` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

This also includes some offset validity changes which were forgotten
from commit 515b3fc1dc.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
48d9f356c3 girnode: Improve int types in GIIrNodeVFunc
`GIIrNodeVFunc` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
468b926c2b girnode: Improve int types in GIIrNodeSignal
`class_closure` isn’t actually meaningfully set anywhere in the code yet
(there are FIXME comments), so I’m not sure of the best type for it. But
generally `unsigned` is more widely used than signed `int`.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
e7f26b1440 girnode: Improve int types in GIIrNodeType
`GIIrNodeType` is built dynamically at runtime (rather than being
mmapped from disk), so its types can accurately reflect their runtime
semantics, rather than an on-disk format.

As part of this, switch from `atoi()` to `g_ascii_string_to_unsigned()`
for parsing the relevant fields from a GIR XML file. This means we now
get error handling for invalid integers.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
543fea1df7 girmodule: Simplify a branch in gi_ir_module_new()
`g_strdup(NULL)` is guaranteed to return `NULL`, so there’s no need to
branch to handle that.

Add a stub private doc comment to hold a `(nullable)` annotation for
that argument, though, so that information isn’t lost.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
db0f69fbb8 girepository: Use G_DECLARE_FINAL_TYPE for GIRepository
Might as well move to a modern way of declaring GObjects. This means
that `GIRepository` is no longer derivable, but it would be a bit
unexpected if anyone was deriving from it.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
e301782865 girnode: Fix a couple of leaks from GIIrNode subclasses
Found by code inspection rather than hitting them at runtime.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-26 09:29:30 +00:00
Philip Withnall
2c2712e310 girnode: Document ownership and element types of internal structs
This is just for future reference for people reading the code in future.
I was going through and checking to see if any of them needed to be made
`const` (none of them did).

I did find a couple of memory leaks though; see the following commits.

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

Helps: #3155
2024-01-26 09:29:30 +00:00
Philip Withnall
7eb69d279d gibaseinfo: Break refcount cycle with GIRepository
By shifting responsibility for ensuring that the lifetime of a
`GIRepository` always exceeds the lifetime of any of its `GIBaseInfo`s
to the user.

Keeping a weak ref from each `GIBaseInfo` to its `GIRepository` would be
too expensive (`GIBaseInfo`s are supposed to be cheap to create and
destroy, as they are used within function calls in language bindings).

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

Fixes: #3234
2024-01-25 22:03:57 +00:00
Philip Chimento
ad9cd1762a girepository: Remove GI_FUNCTION_THROWS and GI_VFUNC_THROWS flags
These flags were replaced by gi_callable_info_can_throw_error() in
girepository 1.x, but the flags were maintained for backwards
compatibility. No need to hold on to them in the 2.x API.

Note that these flags are also still maintained as separate bits in the
binary format, which is not changing. So, they still need to be read
from FunctionBlob and VFuncBlob if the bit is not set in SignatureBlob.

This is an API break for girepository 2.x, which is OK because the API
has never been released yet.
2024-01-24 20:45:28 -08:00
Philip Chimento
cda9ebeb03 tests: Port over some GIRepository tests from g-i 1.x
These tests come from gobject-introspection/tests/repository/. They
include whatever wasn't already covered by the existing tests.

The original files didn't have copyright information. That's been
reconstructed from commit messages of commits that added a test or a
substantial part of one.
2024-01-23 22:04:52 -08:00
Philip Chimento
3c984faf23 tests: Use runtime casts
Using casts like GI_OBJECT_INFO() that log a critical when the
introspection info is of the wrong type, will help to locate bugs.
2024-01-23 22:04:52 -08:00
Philip Chimento
b8a65edb01 tests: Use fixture in GIRepository tests
This deduplicates some code and will allow writing further tests more
easily.
2024-01-23 22:04:52 -08:00
Philip Chimento
d41f05e9cf build: Add libffi dependency to girepository/function-info test
I found that this dependency is needed for girffi.h to find ffi.h.
2024-01-23 21:59:38 -08:00
Philip Withnall
9b5d008f60 girffi: Rename gi_function_invoker_destroy() to …_clear()
This brings its naming more in line with modern GLib conventions.

This is an API break, but libgirepository is not API frozen yet.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-23 22:55:35 +00:00
Philip Withnall
3e157c688e girffi: Add a test for gi_function_info_prep_invoker()
This test case was originally written by Philip Chimento as a reproducer
for #3218. Let’s add it to the test suite to catch regressions in
stack-allocated `GIBaseInfo` handling.

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

Helps: #3218
2024-01-23 18:10:03 +00:00
Philip Withnall
998baf9afb girffi: Expand docs for gi_function_info_prep_invoker()
Mention that the returned `GIFunctionInvoker` needs to be cleared.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-23 18:09:28 +00:00
Philip Withnall
bf4cf2d464 gibaseinfo: Fix use of stack-allocated GIBaseInfos
Most of the code for handling stack-allocated infos was correct, it was
just missing code to initialise the `GTypeInstance` member.

Since `GTypeInstance` isn’t really designed for stack allocation, this
is a little hacky — it requires setting up the member within
`GTypeInstance` manually. It works, though.

The externally visible consequence of this, though, is that
stack-allocated `GIBaseInfo`s now need to be cleared when they’re
finished being used. This allows the `GTypeClass` ref to be dropped.

All users of the stack-allocated APIs in libgirepository will need to
adapt to this change.

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

Fixes: #3218
2024-01-23 18:07:17 +00:00
Philip Withnall
eb94acce21 gibaseinfo: Make gi_info_init() take a GType rather than a GIInfoType
This is one more step towards removing `GIInfoType`, and will also help
in a following commit which will directly make use of the `GType`.

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

Helps: #3218
2024-01-23 18:06:08 +00:00
Philip Withnall
c8c1febc7d gibaseinfo: Fix a double-unref with stack-allocated GIBaseInfos
As documented in the commit, the internal members of `GIBaseInfo` are
not reffed if the `GIBaseInfo` is stack-allocated, as the caller can be
relied on to ensure their lifetime exceeds that of the `GIBaseInfo`.

Make sure that’s actually reflected in the code.

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

Helps: #3218
2024-01-23 17:55:26 +00:00
Philip Withnall
a3da3a032c gibaseinfo: Change argument type for gi_type_info_init()
Make it take a `GITypeInfo` rather than a `GIBaseInfo`, because that’s
what it actually operates on.

This is an internal API, so this isn’t an API break.

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

Helps: #3218
2024-01-23 17:53:15 +00:00
Simon McVittie
25ec19723c girepository: Exclude private symbols from the ABI
This removes the gthash utility functions from the ABI, so link those
into their automated test statically.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-19 12:07:30 +00:00
Philip Withnall
993eae63ab tests: Use g_assert_*() rather than g_assert() in gthash tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-18 13:15:22 +00:00
Philip Withnall
9cbe5ae67d tests: Add tests for several GIBaseInfo subclasses
They get at least these `GIBaseInfo` subclasses up to a reasonable (but
not complete) coverage level.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-18 13:15:22 +00:00
Philip Withnall
9aea530ac0 gibaseinfo: Add initialiser macro for GIAttributeIter
Makes it a little easier to use.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-01-18 13:15:22 +00:00
Philip Withnall
57d64b111f girepository: Add type-checking cast macros
These follow GObject conventions, using `G_TYPE_CHECK_INSTANCE_CAST` to
cast to the given type, and potentially performing some runtime checks
of the type instance’s `GType` too.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
9debaffe0e gibaseinfo: Remove need for casting for gi_base_info_ref() and unref()
Just like is done with `g_object_{ref,unref}()`, make these functions
take a `void*` rather than a `GIBaseInfo*`, since they’ll most likely be
called with a type which is derived from `GIBaseInfo*` rather than a
`GIBaseInfo*` itself.

Add some runtime type checks to make up for lowering the compile time
type safety.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
5423bf4df7 girepository: Rework IS_(type) macros to use G_TYPE_CHECK_INSTANCE_TYPE
This means they’re now using the `GType` type system rather than the old
`GIInfoType` type system. Given the preceding few commits, these two
systems should now be equivalent.

This makes the type handling more conventional and hence a bit simpler
for people to use if they have experience with GObject.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
a99a35ab39 giregisteredtypeinfo: Make abstract and add subtypes
There are various info types which were previously treated as subtypes
of `GIRegisteredTypeInfo` by the runtime type system in the old version
of libgirepository.

Change the new type tree to reflect that, making several types now be
subtypes of `GIRegisteredTypeInfo`, and making `GIRegisteredTypeInfo`
abstract.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
7228c6d3e0 giboxedinfo: Add a tag type for boxed types
Boxed types are already represented within `GIInfoType`, so they should
have a `GType` representation as well.

In an upcoming commit, this will allow us to represent the subtype
relation between `GIBoxedInfo` and `GIRegisteredTypeInfo` too.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
eafc35e5ed gienuminfo: Split out GIFlagsInfo as a derived type
Flag enums are already treated as a special kind of enum within
`GIInfoType`, so it would be tidier to give it its own `GType` too, with
a subtype relation to `GI_TYPE_ENUM_INFO`.

This will simplify implementing `GI_IS_ENUM_INFO` in a following commit
too.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
Philip Withnall
d82675ffd3 gicallableinfo: Make abstract and add derived types
Previously (and incorrectly), `GICallableInfo`, `GIFunctionInfo`,
`GICallbackInfo`, `GISignalInfo` and `GIVFuncInfo` were all derived
directly from `GIBaseInfo`. `GICallableInfo` is supposed to represent
all of the other types, though, so that type hierarchy was incorrect. It
dated from when all the types were aliases of each other and the type
management was done entirely at runtime.

Fix that by making the other four types derive from `GICallableInfo`,
and marking `GICallableInfo` as abstract.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3216
2024-01-18 13:15:22 +00:00
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