Commit Graph

487 Commits

Author SHA1 Message Date
Pavel Holejsovsky
8af8aaa4a8 girepository: avoid crash when querying nonexistent info
It appears that cmph library can return (n+1) when querying item not
present in its original n-item-sized set.  Adjust code so that it
detects this condition and do not chase stray pointers resulting from
this bogus(?) hash result.

https://bugzilla.gnome.org/show_bug.cgi?id=675939
2012-05-12 20:48:55 +02:00
Johan Dahlin
0a96da9284 Make introspection compile with -Wall -Werror
Address all gcc warnings, -Werror is not enabled yet but at least
-Wall -Werror passes on my machine.
2012-04-09 14:19:23 -03:00
Pavel Holejsovsky
d0b8813d14 Avoid _get_func() consuming reference from input info
Fix of leak in 4c9424e18d71237f438a99bc5f2d45ae7de60b78 was a bit
overaggressive, stealing also one reference from input 'info'
argument.

Also fixes another bug in that commit - local 'func' shadowing the
return value, causing that function always returned NULL even when
some result was actually found.

https://bugzilla.gnome.org/show_bug.cgi?id=673282
2012-04-07 18:13:23 +02:00
Dieter Verfaillie
5374f24d38 Fix malformed GTK-Doc comment blocks:
- add missing colons
- invalid annotations
- invalid parameters and tags
- correct parameter name
- preserve description indentation
- no description parts
- comment end marker
- invalid empty lines
- line numbers

AnnotationParser now emits warnings which are considered as
errors by "make check" so fix those warnings...

https://bugzilla.gnome.org/show_bug.cgi?id=672254
2012-04-05 10:23:03 -03:00
Tomeu Vizoso
320fd24734 Make g_callable_info_invoke public
So it can be used for invoking callbacks

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

Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2012-03-27 17:42:30 +02:00
Michel Dänzer
b2eef541e9 repository: Remove extraneous leftover assignment to rvalue.
Signed-off-by: Michel Dänzer <michel@daenzer.net>

https://bugzilla.gnome.org/show_bug.cgi?id=668902
2012-03-08 09:32:34 -05:00
Colin Walters
4b71be0ef0 repository: Add new public gi_type_info_extract_ffi_return_value() API
Dealing with FFI and return values is very tricky; this API allows
sharing the bits to do it between gobject-introspection and gjs (and
potentially other FFI binding consumers).

**NOTE** I swapped the order of the arguments, under the premise that
out arguments should generally be last.

https://bugzilla.gnome.org/show_bug.cgi?id=668902
2012-03-05 09:56:56 -05:00
Michel Dänzer
0d58e2e924 repository: Fix conversion of FFI values on big-endian architectures
Adapted from the fixes for (see bug 665152). It makes sure values are
properly converted between glib and FFI, which is critical for big
endian architectures.

Patch adjusted to use GIArgument instead of custom union types
by Colin Walters <walters@verbum.org>

https://bugzilla.gnome.org/show_bug.cgi?id=668902
2012-03-05 09:56:55 -05:00
Jean Bréfort
4359a037db repository: Ensure error is set if we're parsing a malformed file
https://bugzilla.gnome.org/show_bug.cgi?id=661951
2012-02-17 11:48:35 -05:00
Jasper St. Pierre
a714bef965 girffi: Virtual functions are methods 2012-02-10 10:19:17 -05:00
Thorsten Glaser
87857869e9 typelib: Fix invalid alignment assumptions
The current source has invalid assumptions about structure alignment
that break on platforms like m68k where 32-bit integers are aligned to
16-bit only. Fix this by introducing explicit structure padding for
32-bit quantities following odd numbers of 16-bit quantities and
structure trail padding, to make the binary representation generated
by the compiler match the text of the specification exactly.

https://bugzilla.gnome.org/show_bug.cgi?id=661839
2012-02-08 09:07:13 -05:00
Jesse van den Kieboom
c2d79efd53 Plug memory leak in lazy typelibs hash table
https://bugzilla.gnome.org/show_bug.cgi?id=669317
2012-02-05 15:45:09 +01:00
Jasper St. Pierre
04cf2f480d girffi: Fix g_function_info_new_for_address to respect G_VFUNC_THROWS 2012-02-03 13:48:39 -05:00
Colin Walters
e865dcb7b4 Add Emacs mode lines to C sources 2012-02-03 13:42:56 -05:00
Colin Walters
b9d0981460 girepository: Add GI_VFUNC_THROWS
Virtual functions can definitely throw an error.  Right now the
scanner omits the GError parameter for them and adds throws="1", but
g-ir-compiler ignores this.

https://bugzilla.gnome.org/show_bug.cgi?id=669332
2012-02-03 13:20:57 -05:00
Jasper St. Pierre
3aaf08b49d giobjectinfo: Add g_object_info_find_vfunc_using_interfaces
As an analogue to g_object_info_find_method_using_interfaces, add a
new API so that we can find a vfunc using the same strategy.
2012-02-03 11:52:33 -05:00
Jasper St. Pierre
a0d19ca066 girffi: Add new g_function_invoker_new_for_address
This is a new method designed to make a GIFunctionInvoker for
any GICallableInfo*, for bindings to use.
2012-02-03 11:52:33 -05:00
Jasper St. Pierre
3e1486f924 girffi: Fix compiler warnings 2012-01-06 15:00:46 -05:00
Jasper St. Pierre
c18e0be549 repository: Squash memory leak in _get_func and fix up style 2012-01-06 15:00:39 -05:00
Ray Strode
c99df8f34c ffi: Treat enums as 32 bit signed values to fix PPC64
To call a function dynamically using ffi, the caller
first has to tell ffi the size of all the input arguments
of the function. On little endian architectures (like x86_64)
specifying a size that's too large will happen to work because
of how the bits are laid out in memory.  On big endian architectures,
however, specifying the wrong size can lead to reading the wrong
bits.

The function g_type_info_get_ffi_type maps input giargument types to
specific sizes. It was assuming enums were word (pointer) sized; in
fact they can be in theory any size (1,2,4,8 bytes), but in practice
in introspection (via GIArgument) as well as GValue we're limited to 4
byte enums.

This commit fixes PPC64 (big endian, 64 bit).

Signed-off-by: Colin Walters <walters@verbum.org>

https://bugzilla.gnome.org/show_bug.cgi?id=665150
2011-12-21 15:55:18 -05:00
Jasper St. Pierre
cfcbd719ea gitypelib: Fix compiler warnings
These variables are unused.

https://bugzilla.gnome.org/show_bug.cgi?id=665249
2011-12-01 10:55:19 -05:00
Jasper St. Pierre
fd0625aa6e gibaseinfo: Fix compiler warnings
g_slice_free complains when you pass it a pointer of a different type
than it was expecting, like it should.

https://bugzilla.gnome.org/show_bug.cgi?id=665249
2011-12-01 10:55:19 -05:00
Sjoerd Simons
acd55584c2 Use the correct size when freeing unused info
A GIBaseInfo struct can underneath either be GIRealInfo *or*
GIUnresolvedInfo if the type is GI_INFO_TYPE_UNRESOLVED. So when we
eventually free the structures slice use the correct struct type
otherwise things get unhappy.
2011-10-20 10:24:33 +02:00
Alberto Ruiz
c87a386cd1 parser: prevents a segfault when _g_ir_parser_parse_string returns NULL error was not set.
Noticed the segmentation fault while using Vala to generate a .gir, a bug has
been filed tomake sure Vala doesn't export gir symbols outside of a namespace
(see https://bugzilla.gnome.org/show_bug.cgi?id=661952)

https://bugzilla.gnome.org/show_bug.cgi?id=661951
2011-10-18 16:59:34 +01:00
Jasper St. Pierre
b75e788785 giconstantinfo: Add API to fix memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=654069
2011-10-05 16:46:33 -04:00
Colin Walters
11cf4c56f3 repository: Fix g_irepository_get_c_prefix()
It was returning the wrong data.

https://bugzilla.gnome.org/show_bug.cgi?id=659749
2011-09-21 14:05:52 -04:00
Pavel Holejsovsky
87fd1d5dad Fix g_type_info_is_pointer() for overriden types of arguments.
Algorithm which detects whether argument type is pointer checks for
trailing '*' characters in c:type .gir elements.  This failed if ctype
is either 'gpointer' or 'gconstpointer'.  Add specific check for
gpointer/gconstpointer types when deducing pointerness of the type.

https://bugzilla.gnome.org/show_bug.cgi?id=658848
2011-09-12 20:16:32 +02:00
Dieter Verfaillie
8461962337 Windows port: compute GOBJECT_INTROSPECTION_LIBDIR at runtime.
Otherwise, we fail to properly locate the typelibs, because on Windows
the value of GOBJECT_INTROSPECTION_LIBDIR depends on where Glib has been
installed. Due to the nature of how we handle software that depends on
Glib on Windows (it is recommended that each program bundles it's private
copy), we're working in a "multi-prefixed" environment. Hence the value
computed at build time will most likely not even exist at runtime.

https://bugzilla.gnome.org/show_bug.cgi?id=620566
2011-09-07 22:00:09 +02:00
Dieter Verfaillie
522ebcd2d6 Windows port: cmph_time.h includes sys/resource.h which is not available on Windows.
So only include it when WIN32 is not defined.

https://bugzilla.gnome.org/show_bug.cgi?id=620566
2011-09-07 21:59:52 +02:00
Colin Walters
61c8a0dda2 gi-dump-types: New uninstalled debugging program
Usage: ./_build/gi-dump-types g_object_get_type
2011-09-03 12:34:29 -04:00
Colin Walters
6f0cf9a0aa girffi: Remove unnecessary sys/mman.h include
While we're here move config.h to the top for consistency.
2011-09-03 12:03:34 -04:00
Pavel Holejsovsky
b8010062b5 Fix g_irepository_find_by_gtype() for GDK_TYPE_RECTANGLE
Complement fix for g-ir-scanner which converts every GdkRectangle
gtype to CairoRectangleInt.  Make sure that C-side API is also aware
of this workaround.

Use case requiring this patch:

When binding implementation wants to get/set property, it can use either
GI-based approach (g_property_info_xxx() funcs), or just GLib facilities.
Although former is probably preferred, there are cases when latter is still
needed (e.g. gstreamer uses dynamic properties, which are not present in the
gir).  In this case, binding implementation queries the type of the propertyb
(using g_object_class_find_property()), it gets GDK_TYPE_RECTANGLE,
and without the patch it cannot map it to any known type.

https://bugzilla.gnome.org/show_bug.cgi?id=655423
2011-08-25 21:22:25 +02:00
Torsten Schönfeld
13069a377f Add 'Since:' tags to the newly added GIEnumInfo methods 2011-08-18 22:51:57 +02:00
Torsten Schönfeld
322ac4f0a3 Allow enums and bitfields to have static methods
This uses the same backcompat machinery that was introduced for static
methods for non-class types, so this change does not break users of the
existing presentations.

New libgirepository API:

    g_enum_info_get_n_methods
    g_enum_info_get_method

https://bugzilla.gnome.org/show_bug.cgi?id=656499
2011-08-16 18:43:23 +02:00
Johan Dahlin
5167265aae Merge remote-tracking branch 'origin/gir-docbook'
Conflicts:
	.gitignore
	tests/scanner/Regress-1.0-expected.gir
2011-08-13 14:42:05 -03:00
Johan Dahlin
4ce922a903 Add signal flags
This adds all GSignalFlags into the gir.

https://bugzilla.gnome.org/show_bug.cgi?id=656457
2011-08-13 11:21:05 -03:00
Johan Dahlin
1dcf01a490 Add signal flags
This adds all GSignalFlags into the gir.

https://bugzilla.gnome.org/show_bug.cgi?id=656457
2011-08-13 11:10:21 -03:00
Dan Winship
ff6cada552 Add g_irepository_find_by_error_domain()
Add a method to look up a GIEnumInfo given its associated error quark.

Based on a patch from Colin Walters.

https://bugzilla.gnome.org/show_bug.cgi?id=602516
2011-08-13 09:42:38 -03:00
Dan Winship
215d83ebb0 Switch to storing string form of error quarks
Instead of storing the name of the function to call to get the
error quark, store the string form of the error quark, which
we derive from the introspection binary during scanning.

Update EnumBlob and GIEnumInfo to include the new information.

This will allow determining a back-mapping from error quark
to error domain without having to dlsym() and call all the
known error quark functions.

Based on earlier patches from Owen Taylor and Maxim Ermilov.

https://bugzilla.gnome.org/show_bug.cgi?id=602516
2011-08-13 09:42:37 -03:00
Dan Winship
6ee82c14e8 Deprecate ErrorDomain
The previous ErrorDomain blob was never actually scanned or used, and
it was kind of a lame API conceptually.

To keep some compatibility, rather than removing the enumeration
values, rename them to _INVALID, and don't bump the typelib version.
This should in theory allow a new libgirepository to read an old
typelib.

Based on a patch from Colin Walters

https://bugzilla.gnome.org/show_bug.cgi?id=602516
2011-08-13 09:42:37 -03:00
Dan Winship
34c298a51e girepository: fix some doc comment syntax 2011-08-13 09:42:37 -03:00
Dan Winship
bf9c31f49c Add g_irepository_find_by_error_domain()
Add a method to look up a GIEnumInfo given its associated error quark.

Based on a patch from Colin Walters.

https://bugzilla.gnome.org/show_bug.cgi?id=602516
2011-08-12 11:11:45 -04:00
Dan Winship
57554d4b2d Switch to storing string form of error quarks
Instead of storing the name of the function to call to get the
error quark, store the string form of the error quark, which
we derive from the introspection binary during scanning.

Update EnumBlob and GIEnumInfo to include the new information.

This will allow determining a back-mapping from error quark
to error domain without having to dlsym() and call all the
known error quark functions.

Based on earlier patches from Owen Taylor and Maxim Ermilov.

https://bugzilla.gnome.org/show_bug.cgi?id=602516
2011-08-12 11:10:43 -04:00
Dan Winship
f9ebb4e99d Deprecate ErrorDomain
The previous ErrorDomain blob was never actually scanned or used, and
it was kind of a lame API conceptually.

To keep some compatibility, rather than removing the enumeration
values, rename them to _INVALID, and don't bump the typelib version.
This should in theory allow a new libgirepository to read an old
typelib.

Based on a patch from Colin Walters

https://bugzilla.gnome.org/show_bug.cgi?id=602516
2011-08-12 11:10:43 -04:00
Dan Winship
2c0d884330 girepository: fix some doc comment syntax 2011-08-12 11:10:43 -04:00
Jasper Lievisse Adriaanse
a9b2dfd09a Rename ALIGN to GI_ALIGN to prevent redefining this macro on some platforms
https://bugzilla.gnome.org/show_bug.cgi?id=652625
2011-06-21 13:44:56 +02:00
Giovanni Campagna
98067194d6 Free allocated ffi_types in g_callable_info_free_closure()
g_callable_info_prepare_closure() allocates memory for the argument
types in the ffi_cif, so we need to free it.

https://bugzilla.gnome.org/show_bug.cgi?id=652954
2011-06-20 21:19:05 +02:00
Giovanni Campagna
a1b527c79f Rework how fundamental GObject types are introspected
Change the special code for handling GObject and GInitiallyUnowned
so that it exposes GParamSpec as a class, and it allows GVariant to
have a GType without using the deprecate g_variant_get_gtype.

It is a sort of ABI break, in that new typelibs won't work with
previous versions of libgirepository.

https://bugzilla.gnome.org/show_bug.cgi?id=646635
2011-06-08 17:45:31 +02:00
Giovanni Campagna
fef2a7b8dd Fix accessing structure fields that are arrays
We need to distinguish inline arrays inside structures, and arrays
that are pointers and annotations, and we can do it with
g_type_info_is_pointer(), setting it to FALSE for fixed size arrays.
As a side effect, (array fixed-size=N) on a pointer type has no longer
the expected result.

https://bugzilla.gnome.org/show_bug.cgi?id=646635
2011-06-08 17:45:13 +02:00
Tomeu Vizoso
343c76431a Assume only that an array is embedded in a struct if it's fixed size 2011-06-06 20:13:50 +02:00