Commit Graph

28 Commits

Author SHA1 Message Date
Simon Feltman
220fbf35b8 girepository: Use constant time calculation for sections after Object fields
Add "n_field_callbacks" to ObjectBlob which represents the number of object
fields which are also callbacks. This a allows a constant time computation
for accessing sections after fields. Track writing of this field by passing
an extra argument through the girnode writers recursive call structure. This
essentally reverts a portion of commit 7027bb256d0d1ab which added a linear
time computation for accessing sections after fields.
Update typelib validator to also ensure n_field_callbacks is properly set.

https://bugzilla.gnome.org/show_bug.cgi?id=700338
2015-10-10 17:41:24 -04:00
Garrett Regier
96deb9ede5 girepository: Support GError exceptions on callbacks
Generalize "throws" attribute to SignatureBlob which can be used by all
callable blob types. Keep FunctionBlob and VFuncBlob throw attributes
around and functional for compatibility. Refactor girwriter.c to write
out throws attribute for all callable types.

Based on a patch by Simon Feltman.

https://bugzilla.gnome.org/show_bug.cgi?id=729543
2015-06-21 13:01:25 -07:00
Philip Withnall
5389e87a29 girepository: Document semantics of dependencies and includes better
Make it clear that both the dependencies field in the typelib, and the
include elements in the GIR AST, are for immediate dependencies, not
transitive ones.

https://bugzilla.gnome.org/show_bug.cgi?id=743782
2015-02-16 08:49:28 +00:00
Chun-wei Fan
265ea792c1 girepository: Add Header for Version Macros
This adds a header to the girepository library, which is then included
either directly or indirectly by the other headers so that all the public
symbols (and the 2 symbols in gitypelib-internal.h used by the tools) are
decorated by a macro, that can later be used to export the symbols and also
to be used to display compile-time warnings for usage of deprecated APIs,
which is like what is now being done in GLib (and GTK+, Clutter, and so
on).

This marks the first step that we begin to stop depending on the .symbols/
.def files to export the symbols.

https://bugzilla.gnome.org/show_bug.cgi?id=732669
2014-08-15 09:45:41 +08:00
Giovanni Campagna
9921571eb0 Parse and expose ownership transfer for instance parameters
Knowing the ownership transfer for instance parameters is
necessary for correct memory management of functions which
"eat" their instance argument, such as g_dbus_method_invocation_return_*.
Parse this information from the gir file and store in the
typelib, and then provide new API on GICallableInfo to
retrieve this.

https://bugzilla.gnome.org/show_bug.cgi?id=729662
2014-07-03 10:31:17 +02:00
Ryan Lortie
6d1df44ff7 girepository: ArgBlob: rename allow_none parameter
Rename the "allow_none" parameter on internal/private structure ArgBlob
to "nullable".

This is a straight rename with no other changes.

https://bugzilla.gnome.org/show_bug.cgi?id=660879
2014-05-06 08:18:41 -04:00
Dieter Verfaillie
bb7f8d57c2 docs: fix up reference docs a bit
- require GTK-Doc 1.19
      - remove sgml mode
      - automatically generate gi.types (needs GTK-Doc 1.19)
      - fix https://bugzilla.gnome.org/show_bug.cgi?id=700025
[WIP] - rearange sections a bit
[WIP] - add gi-building, gi-programming sections
[WIP] - mark missing docs with TODO, which is only marginaly
        better than nothing but at least can be grepped :)

https://bugzilla.gnome.org/show_bug.cgi?id=571648
2013-10-10 16:48:51 -04:00
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
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
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
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
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
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
David Zeuthen
b35c985e15 Add support for the (skip) annotation on parameters or return values
This was discussed in bug 649657.

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

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-13 14:18:48 -04:00
Colin Walters
a1d7beda01 Add directory index section
Use the internal perfect hashing API to add an index to the directory.

To support this, add the notion of additional "sections" to the
typelib.  A section index is inserted between the header and the
directory.

https://bugzilla.gnome.org/show_bug.cgi?id=554943
2010-12-03 16:03:33 -05:00
Colin Walters
409c40f663 Add internal hashing API designed for the typelib
In multiple places in the typelib, but most importantly the directory,
we need some fast indexing.  Perfect hashing, as implemented by CMPH
(previous commit), is an exact fit for the problem domain.

Add an API built on top of CMPH which maps strings->guint16 (we just
need a guint16 for the typelib index).

https://bugzilla.gnome.org/show_bug.cgi?id=554943
2010-12-03 16:03:32 -05:00
Owen W. Taylor
ec76ea8628 Handle enumerations with the full range of signed and unsigned values
The C compiler will pick an enumeration type that accomodates the specified
values for the enumeration, so ignoring 64-bit enumerations, we can
have enumeration values from MININT32 to MAXUINT32. To handle this properly:

 - Use gint64 for holding eumeration values when scanning
 - Add a 'unsigned_value' bit to ValueBlob so we can distinguish the
   int32 vs. uint32 cases in the typelib
 - Change the return value of g_value_info_get_value() to gint64.

https://bugzilla.gnome.org/show_bug.cgi?id=629704
2010-11-01 17:25:45 -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
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
Colin Walters
9771d87b4d Add BLOB_TYPE_FLAGS to BLOB_IS_REGISTERED_TYPE 2010-07-28 16:35:47 +02:00
Johan Dahlin
b6d50e2951 Add support for non-GObject fundamental objects
This patch adds support for instantiable fundamental object types,
which are not GObject based. This is mostly interesting for being
able to support GstMiniObject's which are extensivly used in GStreamer.
Includes a big test case to the Everything module (inspired by
GstMiniObject) which should be used by language bindings who wishes to
test this functionallity.

This patch increases the size of the typelib and breaks compatibility
with older typelibs.

https://bugzilla.gnome.org/show_bug.cgi?id=568913
2010-07-09 10:15:45 -03:00
David Zeuthen
3d0dc7d214 Allow attributes on parameters and return values
Any annotation where the key has a dot in the name will go into the
attribute list. For example

  * @arg: (foo.bar baz): some arg

the parameter @arg will get the attribute with key foo.bar and value
baz. This also works for.

  * Returns: (foo.bar2 baz2): the return value

Also add tests for this new feature.

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

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-06-24 11:53:18 -04:00
Johan Dahlin
bd0c9a4170 [gitypelib-internal.h] Add missing <public> 2010-06-11 21:05:42 -03:00
Tomeu Vizoso
518765acf3 Support the (transfer) annotation for properties.
* girepository/*: Add g_property_info_get_ownership_transfer() and write
  the transfer attribute of properties into the typelib.

* giscanner/*: Parse the (transfer) annotation and write it into the .gir.

* tools/generate.c: Read the transfer annotation for properties and write
  to the .tgir.

https://bugzilla.gnome.org/show_bug.cgi?id=620484
2010-06-08 17:35:12 +02: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