Commit Graph

159 Commits

Author SHA1 Message Date
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
Simon Feltman
cf4fb6a0fe g-ir-compiler: Add support for callback fields on GObjects
Use ParseState enum instead of a boolean for the ParseContexts embedded_type
flag. This allows specific tracking of the embedded type currently being
parsed which can now either be STATE_STRUCT_FIELD or STATE_CLASS_FIELD (or
allow for future expansion). Add ParseState::STATE_NONE as the default for
this field.

Fix GObject FieldBlob validation to take into account the sizeof
CallbackBlobs (copied from the struct validator).

Add static g_object_info_get_field_offset which parallels
g_struct_info_get_field_offset which is needed since callback fields may
vary in size.

https://bugzilla.gnome.org/show_bug.cgi?id=725198
2014-02-27 13:51:18 -08:00
Dieter Verfaillie
c87579bbb6 giscanner: fix description field storage in .gir files
GTK-Doc description fields for tags can contain multiple lines and
even multiple paragraphs. Whitespace cannot be preserved in XML
attributes, so we move the "deprecated" description text into
a "<doc-deprecated />" element right next to where we already have
the "<doc />" element. Keep the "deprecated" attribute around for
backwards compatibility though, but set its value to "1" (analogous
to the "writable", "contruct", etc attributes) if the annotated
symbol is marked as deprecated.

While at it, add <doc-version /> and <doc-stability /> which
was not yet available in the .gir files...

This takes care of the "Since:", "Stability:" and "Deprecated:"
GTK-Doc tags. Nothing needs to be done for the "Returns:" tag as
as we already write a "<doc />" child element on "<return-value />".
2013-10-08 20:56:10 +02:00
Simon Feltman
67ee43b667 Use case insensitive compare for signal "when" attribute
Update parser to use g_ascii_strcasecmp instead of strcmp. This fixes
incorrect flags being set when the incomming gir is using lowercase values
for the "when" attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=709462
2013-10-05 01:43:09 -07:00
Colin Walters
2e4e98c978 girparser: Also honor legacy c:prefix
vala generates this, and we need to honor it now that we're using the
c:prefix as an optimization when searching for gtypes.

https://bugzilla.gnome.org/697759
2013-04-15 09:26:26 -04:00
Jasper St. Pierre
ee4ee72ac3 girparser: Serialize and read back the instance_parameter
g-ir-doc-tool wants to use the instance parameter to read docs
and the parameter name, so it needs to be shuttled through the
GIR.

https://bugzilla.gnome.org/show_bug.cgi?id=693040
2013-02-01 19:37:21 -05:00
Jasper St. Pierre
06dfbc7dcb girparser: Clean up passthrough handling
Instead of remembering to have to set unknown_depth, smarten up
state_switch to do it for us.

https://bugzilla.gnome.org/show_bug.cgi?id=693040
2013-02-01 19:36:38 -05:00
Jasper St. Pierre
37791c8267 girparser: Move <doc> handling to passthrough
https://bugzilla.gnome.org/show_bug.cgi?id=693040
2013-02-01 19:20:35 -05:00
Martin Pitt
259c10f787 girepository: gchar is a signed type
gchar is signed, not unsigned. Add "guchar" alias as unsigned for completeness
(but usually it appears as guint8).

https://bugzilla.gnome.org/show_bug.cgi?id=691524
2013-01-11 10:09:25 +01:00
Chun-wei Fan
08da5d65ee girepository: Remove C99ism and other updates
-Make code using libgirepository_internals relocatable on Windows,
 like what is done in the GTK+ stack, and the girepository DLL.
-Remove C99isms
-"interface" is a reserved keyword on certain compilers, so change that to
 "giinterface"

https://bugzilla.gnome.org/show_bug.cgi?id=681820
2012-10-27 12:06:09 -04: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
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
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
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
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
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
Serkan Kaba
1611ff77df girparser: use c:identifier-prefixes instead of c:prefix
This bug was introduced with
http://git.gnome.org/browse/gobject-introspection/commit/?id=36aa515f1036978ced8d4ffb808260844f7229e0
due to rename of c:prefix to c:identifier-prefixes.

https://bugzilla.gnome.org/show_bug.cgi?id=640264
2011-03-26 12:18:40 -04:00
Laszlo Pandy
8304598583 Add "c:identifier" attribute to GIrNodeValue (for flags and enum values).
Flags and enums with a GType have a value_nick and value_name
strings available in the class struct. But for flags and enums
without GType, we need to get this information from introspection.

g_base_info_get_name() gives the string for value_nick. In the GIR,
the attribute "c:identifier" is the string neede for value_name.

This patch adds the "c:identifier" from GIR to the typelib for all
flags and enum values. It can be retireved using
g_base_info_get_attribute(info, "c:identifier").

https://bugzilla.gnome.org/show_bug.cgi?id=642757
2011-02-23 13:55:04 +01:00
Laszlo Pandy
f478da144f Fix argument name of MISSING_ATTRIBUTE macro ('ctx' => 'context').
The argument was called 'ctx' but the macro was using 'context'.
This wasn't causing the build to fail because the variable
'context' was already defined in all the scopes where this macro
was used.
2011-02-17 18:01:31 +01:00
Pavel Holejsovsky
5857d9c231 Add support for g[u]intptr in scanner and girwriter.
https://bugzilla.gnome.org/show_bug.cgi?id=634838
2011-01-13 16:20:01 +01:00
Andreas Rottmann
732911c703 Don't emit shadowed methods into the typelib
Ignore shadowed methods when parsing the GIR.
2010-12-07 00:07:08 +01:00
Colin Walters
ff33cc0791 girepository: Consistently prefix internal functions with _
This should better avoid them being exported.  Rename
girepository-parser.la to girepository-internals.la for clarity.
2010-11-16 16:58:39 -05: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
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
Tomeu Vizoso
9468bd36c9 Actually do something about fundamentals when parsing a .gir
https://bugzilla.gnome.org/show_bug.cgi?id=630710
2010-09-29 15:55:37 +02:00
Colin Walters
6bc078f1ee typelib compiler: Passthrough <doc> at any point
This should have been in the previous commit.
2010-09-14 12:31:58 -04:00
Steve Frécinaux
8548baf3b9 [VFuncBlob] Unknown struct offset should be 0xFFFF
Documentation says about g_vfunc_get_offset():

 "Obtain the offset of the function pointer in the class struct.
  The value 0xFFFF indicates that the struct offset is unknown."

But g-ir-compiler did set the value to 0 when the offset is unknown.
This patch fixes it.

https://bugzilla.gnome.org/show_bug.cgi?id=628270
2010-09-06 08:33:40 +02:00
Colin Walters
9a46475584 scanner: Fix previous rename-to handling commit 2010-09-03 18:17:28 -04:00
Colin Walters
f0eeec8cd8 scanner: Fix rename-to handling
We were writing the attributes backwards.  Also actually use
the attribute in the typelib generation.
2010-09-03 18:07:16 -04:00
Colin Walters
35cb08a25e Major rewrite
One of the first big changes in this rewrite is changing the Type
object to have separate target_fundamental and target_giname properties,
rather than just being strings.  Previously in the scanner, it was
awful because we used heuristics around strings.

The ast.py is refactored so that not everything is a Node - that
was a rather useless abstraction.  Now, only things which can have
a GIName are Node.  E.g. Type and Field are no longer Node.

More things were merged from glibast.py into ast.py, since it isn't
a very useful split.

transformer.py gains more intelligence and will e.g. turn GLib.List
into a List() object earlier.  The namespace processing is a lot
cleaner now; since we parse the included .girs, we know the C
prefix for each namespace, and have functions to parse both
C type names (GtkFooBar) and symbols gtk_foo_bar into their
symbols cleanly.  Type resolution is much, much saner because
we know Type(target_giname=Gtk.Foo) maps to the namespace Gtk.

glibtransformer.py now just handles the XML processing from the dump,
and a few miscellaneous things.

The major heavy lifting now lives in primarytransformer.py, which
is a combination of most of annotationparser.py and half of
glibtransformer.py.

annotationparser.py now literally just parses annotations; it's
no longer in the business of e.g. guessing transfer too.

finaltransformer.py is a new file which does post-analysis for
"introspectability" mainly.

girparser.c is fixed for some introspectable=0 processing.
2010-08-31 16:05:56 -04: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
Colin Walters
d853f196c1 Move alias target to <type>
This makes type parsing more uniform.

Delete the typedef for GSList in foo.h - that's not
supported anymore, or at least for now.
2010-08-31 16:05:56 -04:00
Colin Walters
62f1b65cc8 [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...
2010-08-17 13:14:51 -04:00
Colin Walters
f552f46f88 [girparser] Cleanly pass through c:include 2010-08-17 13:11:03 -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
4994c3d4b8 Remove trailing whitespace 2010-07-09 10:20:57 -03: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
Colin Walters
68b4fb43bb Move doc to toplevel element, write <any> for unknown containers
Moving to <doc> allows us to better preserve whitespace.  XML has no
facility for whitespace-preserving attributes.

Second, for arrays and lists, both types with unknown element_type can
occur in the current scanner; it's least wrong if we write out an
<any> type.
2010-07-08 14:42:54 -04: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
Colin Walters
e169006ed6 [girparser] Remove backtrace()
It's not useful; we never got good info from it, and modern operating
systems ship with crash catching systems.
2010-06-22 18:03:36 -04:00
Colin Walters
2f11782f51 Support introspectable=no attribute, add warnings framework
This work allows us to move closer to replacing gtk-doc, among other
things.  We add a generic attribute "introspectable", and inside the
typelib compiler if we see "introspectable=no", we don't put it in the
typelib.  This replaces the hackish pre-filter for varargs with a much
more generic mechanism.

The varargs is now handled in the scanner, and we emit
introspectable=no for them.

Add generic metadata to Node with references to file/line/column,
which currently comes from symbols.

Add scanner options --warn-all and --warn-error.

https://bugzilla.gnome.org/show_bug.cgi?id=621570
2010-06-17 13:05:59 -04:00
Colin Walters
911d98bb9d More explicitly document how we'll use the version= attribute on repository
I want to start bumping it on incompatible .gir changes.

https://bugzilla.gnome.org/show_bug.cgi?id=621895
2010-06-17 10:49:41 -04:00
Johan Dahlin
c3790c1af7 Revert "Support introspectable=no attribute, add warnings framework"
This reverts commit 074192b89c6afcdd7f062f03989972e44334b8bf.
2010-06-17 09:14:04 -03:00
Colin Walters
97c497bfea Support introspectable=no attribute, add warnings framework
This work allows us to move closer to replacing gtk-doc, among other
things.  We add a generic attribute "introspectable", and inside the
typelib compiler if we see "introspectable=no", we don't put it in the
typelib.  This replaces the hackish pre-filter for varargs with a much
more generic mechanism.

The varargs is now handled in the scanner, and we emit
introspectable=no for them.

Add generic metadata to Node with references to file/line/column,
which currently comes from symbols.

Add scanner options --Wall and --Werror.
2010-06-16 21:58:18 -04:00
Johan Dahlin
1223ef3560 [girparser] Annotate return transfer for public API 2010-06-12 11:31:06 -03:00
Tomeu Vizoso
ba97c98827 Use a default value for transfer-ownership in properties. 2010-06-08 19:20:06 +02: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