Commit Graph

89 Commits

Author SHA1 Message Date
Daniel Drake
33afebb2d7 Optimize g_irepository_find_by_gtype
When g_irepository_find_by_gtype() doesn't succeed on a simple prefix
match (the current 'fastpass' mechanism), it ends up taking a
considerable amount of CPU time, traversing the contents of all typelibs.

I imagine that the reasons to have the exhaustive search fallback are
not as strong as they used to be. For example, the case mentioned
(Clutter including Cogl) no longer seems to be true.

Also, typelibs (as generated by g-ir-scanner) now provide
comma-separated C prefix info for cases when the typelib includes
introspection info for multiple prefixes. For example, the Sugar typelib
has a c_prefix string of Sugar,EggSM,Gsm,Acme. So I imagine there are
not many remaining justified cases where the exhaustive search is needed.

With that in mind, I found two ways to optimize this function:

1. Support comma-separated C prefixes

2. Don't bother with an exhaustive search if we did find a typelib
   claiming support for the prefix. For example, if we're looking for
   GdkDeviceManagerXI2 (currently non-introspectable) and we already found
   typelib files providing the 'Gdk' prefix that didn't offer this, lets
   not bother with the exhaustive search, we aren't going to find anything.
2013-04-08 11:22:39 -04:00
Colin Walters
35091ec7df repo: Drop deprecated GStaticMutex usage
In favor of GOnce, since we just want initialize-once semantics.
2012-12-17 09:57:24 -05: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
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
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
Colin Walters
e865dcb7b4 Add Emacs mode lines to C sources 2012-02-03 13:42:56 -05: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
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
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
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
Colin Walters
f9a3bb7300 Add support for gunichar in typelib
Some API such as gtk_text_iter_get_char returns an individual
"gunichar"; we should support this.

https://bugzilla.gnome.org/show_bug.cgi?id=633197
2010-11-12 16:00:10 -05:00
Colin Walters
3d7bb7feaf Fix regression in g_irepository_get_info
Commit f97cc8687469f25752f79275 broke the lookup in
g_irepository_get_info; the passed offset is 0-based, then
we convert it to 1-based (and then back to 0 later...which needs
to be fixed).
2010-10-21 15:01:07 -04:00
Colin Walters
54a1a7be49 girepository: Refactor lookup code
This is a cleanup patch in preparation for future indexing
patches.

The lookup code was a mess trying to mash in the 3 different
cases of name, GType, and index into one mega-function.

Split it up properly, and move the core typelib internal-scanning
bits into gitypelib.c where it belongs.
2010-10-18 12:04:08 -04:00
Pavel Holejsovsky
508edb91ad Fix memory leak. 2010-09-25 11:32:28 -03:00
Pavel Holejsovsky
916798b704 Update annotations for GIRepository.Repository.
https://bugzilla.gnome.org/show_bug.cgi?id=628753
2010-09-15 09:48:46 -03:00
Pavel Holejsovsky
bc6a8d2f23 [girepository] Document GIStructInfo & GIUnionInfo
https://bugzilla.gnome.org/show_bug.cgi?id=628753
2010-09-05 11:04:27 -03:00
Colin Walters
b18a6580d2 girepository: Call init_globals()
This fixes the search path initialization if g_irepository_require
is called first thing.
2010-09-02 17:43:23 -04:00
Johan Dahlin
14edb06326 [GIRepository] Rename GTypelib to GITypelib
Keep a typedef for backwards compatibility, until
the major bindings has moved over.
2010-08-31 17:37:10 -03:00
Johan Dahlin
180e1b61eb [girepository] Add a couple of missing transfer 2010-08-31 17:29:13 -03:00
Colin Walters
f5ec6f6698 Use GLib types consistently
Rather than have the scanner/parser handle both e.g. "glong" and
"long", simply use the GLib types everywhere.

This commit adds TYPE_LONG_LONG and TYPE_LONG_DOUBLE to the
scanner types; however, rather than add them to the typelib,
they're just marked as not-introspectable.
2010-08-31 16:05:56 -04:00
Steve Frécinaux
318843cead Fix warning when using g_irepository_enumerate_version()
The reason for the warning was that g_irepository_get_version() expects
the typelib to be already loaded, but enumerate_version() can be called
on typelibs that are not.
2010-08-18 22:45:19 +02:00
Steve Frécinaux
2b07f1ed31 Include the loaded version in g_irepository_enumerate_versions()
Logically speaking, the already loaded version of a namespace is part of
the currently available versions, and can be forgotten if we only
consider the versions available in GI_TYPELIB_PATH, as it could have
been loaded using g_irepository_require_private().

As a side effect, it meant that bindings relying on enumerate_version()
(like pygobject) were not able to require private versions through their
classical requirement scheme.

This patch fixes it by adding the loaded version to the unsorted list of
available versions returned by g_irepository_enumerate_versions()

This patch also uses g_list_prepend() instead of g_list_append() in that
function.

https://bugzilla.gnome.org/show_bug.cgi?id=625983
2010-08-18 20:07:18 +02:00
Colin Walters
9b1bb64e83 [girepository] Fix up error printing
We didn't show the right error message if we failed to find
the symbol; fix this by removing error printing from the
middle of the dumper, and add it correctly to the toplevel
dump entry point.
2010-08-17 13:12:52 -04:00
Steve Frécinaux
439753a5b3 Do not leak typelibs with wrong header info.
Previously the typelibs that were loaded but whose header information
weren't right were just leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=625672
2010-08-03 23:42:08 +02:00
Steve Frécinaux
e3b7e76b86 Add new API g_typelib_require_private()
This is equivalent to g_typelib_require() but intended for use with
private typelibs, which get loaded from the provided directory.

https://bugzilla.gnome.org/show_bug.cgi?id=625672
2010-08-03 23:36:54 +02:00
Johan Dahlin
c93fbff870 [girepository] Update documentation 2010-07-28 08:52:45 -03:00
Johan Dahlin
ab9085eda3 [GIRepository] Rename g_irepository_enumerate
Rename it to g_irepository_enumerate_versions
2010-07-28 08:52:05 -03:00
Tomeu Vizoso
da698167a0 Add g_info_type_to_string (GIInfoType type) 2010-07-28 12:24:10 +02:00
Colin Walters
958b70d8b0 Add g_irepository_enumerate
This will be used for pygobject to enumerate namespaces.
2010-07-27 17:56:36 +02:00
Colin Walters
c0b26bf0a0 [girepository] Include path to file in typelib load failure error
This makes version conflicts more obvious.
2010-07-22 13:48:32 -04:00
Florian Müllner
5b5ab282a6 [girepository] Fix ordering in override_search_path
Entries in the GI_TYPELIB_PATH environment variable are added to the
global search path in reverse order - instead, add entries in the
same order in which they are specified.
2010-07-15 23:40:28 +02:00
Colin Walters
1b8bf7a4dc [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.
2010-07-14 11:59:11 -04:00
Colin Walters
3a310fd242 Don't include machine-dependent integral types in the typelib
Previously we had both e.g. GI_TYPE_TAG_LONG and GI_TYPE_TAG_INT64,
but in fact the typelib is already machine-specific, so it makes sense
to just encode this as a fixed type.  The .gir remains abstract.

We also remove size_t from the typelib; one would never want to treat
it differently than an integer.

time_t is removed as well; while bindings like gjs had special handling
to turn it into e.g. a JS Date object, I don't think we should encourage
people to use these POSIX types in their API.  Use GTimeVal or the like
instead.

Because the typelib is now really machine-specific, we need to remove
the -expected.tgirs from git.  (We could potentially add a check
which wasn't just a literal diff later)

https://bugzilla.gnome.org/show_bug.cgi?id=623774
2010-07-09 14:15:52 -04:00
Johan Dahlin
292033c7dc [girepository] Move GICallableInfo out of ginfo.ch 2010-06-05 12:40:28 -03:00
Johan Dahlin
64ee6cb5b0 [gtypelib.ch] Rename to gitypelib.ch
Rename gtypelib.h -> gitypelib-internal.h and rename
gtypelib.c to gitypelib.c
2010-05-31 17:47:50 -03:00
Johan Dahlin
7e2e379388 [girepository] Use g_slice
Use g_slice to allocate instead of g_new(x, 1); It uses a memory
pool internally and should be faster, especially for GBaseInfo/GRealInfo,
structs which are tiny.
2010-05-20 11:41:44 -03:00
Johan Dahlin
51118b3338 [girepository] Document most of the structs 2010-05-18 18:11:58 -03:00
Johan Dahlin
9f4cadec60 [girepository] Update gtk-doc syntax
Update the gtk-doc syntax to remove a couple of warnings
2010-05-18 18:11:57 -03:00
Johan Dahlin
6b0463dd16 [girepository] Remove trailing whitespace 2010-03-24 15:02:05 -03:00
Javier Jardón
e568b5f9fd Substitute deprecated Glib symbol: g_mapped_file_free
glib-compat.h file created to use g_mapped_file_unref only if
glib >= 2.22 is available

https://bugzilla.gnome.org/show_bug.cgi?id=603727
2009-12-15 11:06:50 -02:00
Colin Walters
1735ebde9a [typelib] Clean up dlopen handling
It's was busted that g_typelib_new_* does the dlopen() since that caused
g-ir-compiler to load the modules even though it wasn't going to do
anything with them.

Instead, change things so that g_module_symbol does the dlopen on-demand.
Remove the extra dlopen(NULL) inside girepository.c, we had another
already in gtypelib.c.

Thanks to Owen Taylor for suggesting this approach.
2009-08-19 11:05:08 -04:00
Mark Lee
378350f3a9 Bug 584423 – Add short/ushort support
Add type tags for short and ushort, plus all of the requisite code needed
to utilize them in libgirepository.
Add support in the scanner's AST files.
Add test functions to the everything library and the expected gir file.

gtypelib.c constant validation fixed by Colin Walters <walters@verbum.org>
2009-06-22 14:01:56 -04:00
Colin Walters
2898d23962 Bug 564016 - Include c:prefix in typelib, use it to optimize find_by_gtype
Parse the c:prefix from the .gir, include it in the header.  Armed with this
information, we can now optimize lookups of GTypes because we
have the requirement that GTypes must start with the c:prefix.  We do
fall back though if a lookup fails.
2009-03-17 16:29:08 -04:00
Robert Carr
cd46d2fa0b Fix build 2009-02-12 09:51:16 -05:00
Johan Dahlin
fe8c6d34c4 Add gtk-doc support 2009-02-12 01:32:25 -02:00
Johan Dahlin
9bf5ee61a4 Bug 567813 – Everything should be versioned
2009-01-15  Johan Dahlin  <jdahlin@async.com.br>

        Bug 567813 – Everything should be versioned

        * gir/Makefile.am:
        * girepository/Makefile.am:
        * girepository/girepository.c (init_globals):
        * girepository/girparser.c (locate_gir):
        * giscanner/dumper.py:
        * giscanner/transformer.py:
        * gobject-introspection-1.0.pc.in:
        * tests/everything/Makefile.am:
        * tests/invoke/Makefile.am:
        * tests/offsets/Makefile.am:
        * tests/repository/Makefile.am:
        * tests/scanner/Makefile.am:
        * tools/Makefile.am:


svn path=/trunk/; revision=1046
2009-01-15 22:31:07 +00:00
Colin Walters
3fff99dfcc Bug 562914: Order GI_TYPELIB_PATH before anything else
We want the environment variable to override so that people can
easily write scripts that run their programs uninstalled.

svn path=/trunk/; revision=1024
2009-01-12 21:42:58 +00:00
Colin Walters
2971e35fe6 Bug 567212: Exit after dumping
The intended use of g_irepository_get_option_group is that your
application more transparently supports --introspection-dump; we
should exit so that your app doesn't continue trying to launch.

svn path=/trunk/; revision=1023
2009-01-12 21:31:45 +00:00
Johan Bilien
bb9820839a Bug 563998 – Cache the GIBaseInfo for GTypes
2008-12-10  Johan Bilien  <jobi@via.ecp.fr>

	Bug 563998 – Cache the GIBaseInfo for GTypes

	* girepository/girepository.c (g_irepository_find_by_gtype):
	add a cache of GType -> GIBaseInfo.


svn path=/trunk/; revision=991
2008-12-10 17:53:09 +00:00