Commit Graph

122 Commits

Author SHA1 Message Date
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
Johan Dahlin
b2575e8210 Philip, you didn't write all of this 2010-06-08 11:28:02 -03:00
Tomeu Vizoso
d531541b8a Fix marshalling of GStrv.
* gir/gimarshallingtests.[hc]: Add a test for GStrv in function args and
as struct fields.

* girepository/giroffsets.c: Correctly compute the size of structs with
  array fields

* girepository/girparser.c: Set is_pointer to FALSE for arrays with
  fixed size that are inside structs.

* giscanner/glibtransformer.py: Special case GStrv as arrays of utf8.

* giscanner/annotationparser.py: Make full transfer the default for
arrays of char* returned by functions.

https://bugzilla.gnome.org/show_bug.cgi?id=620170
2010-06-02 19:36:59 +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
Colin Walters
a20c2ad7c2 [girparser] Don't hard require caller-allocates since it breaks parsing
We need to support parsing older .girs for inclusion purposes.  (But
we should probably have an explicit .gir version, and require the
attribute for newer versions)
2010-05-26 13:53:29 -04:00
Colin Walters
46d9ef151e Support (out caller-allocates)
People have wanted support for marking (out) on functions of the
form:

/**
 * clutter_color_from_pixel:
 * @pixel: A pixel
 * @color: (out): Color to initialize with value of @pixel
 */
void
clutter_color_from_pixel (guint32 pixel, ClutterColor *color);

Where the caller is supposed to have allocated the argument; the
C function just initializes it.  This patch adds support for this
argument passing style to introspection.  In this case, we see the
(out), and notice that there's only a single indirection (*) on
the argument, and assume that this means (out caller-allocates).

https://bugzilla.gnome.org/show_bug.cgi?id=604749
2010-05-26 13:00:56 -04:00
Simon McVittie
456379be29 girparser: backtrace_stderr: fix int/ssize_t format mismatch
backtrace() is defined in terms of int, which differs from ssize_t on
x86-64, and @size is also an int.
2010-05-19 16:17:06 +01:00
Tomeu Vizoso
c9213eaea3 Add support for GArrays: add g_type_info_get_array_type() and properly scan GArray args
Based on a previous patch by C. Scott Ananian <cscott@litl.com>

https://bugzilla.gnome.org/show_bug.cgi?id=581687
2010-05-04 16:58:15 +02:00
Tomeu Vizoso
1301850f3d Revert "Add support for GArrays: add g_type_info_get_array_type() and properly scan GArray args"
This reverts commit 87291e08b0fd34b62e1ad9811c174108b38311a9.
2010-05-03 19:17:00 +02:00
Tomeu Vizoso
e12cea0a53 Add support for GArrays: add g_type_info_get_array_type() and properly scan GArray args
Based on a previous patch by C. Scott Ananian <cscott@litl.com>

https://bugzilla.gnome.org/show_bug.cgi?id=581687
2010-04-30 18:15:23 +02:00
Johan Dahlin
14f13c1760 Add support for foreign structs
Foreign structs are special in the sense that there might
be native bindings (for instance PyCairo for PyGI) that provides
the same functionallity as the introspected variant.

https://bugzilla.gnome.org/show_bug.cgi?id=610357
2010-03-25 23:12:12 -03:00
Johan Dahlin
6b0463dd16 [girepository] Remove trailing whitespace 2010-03-24 15:02:05 -03:00
Bastien Nocera
e3cd97d492 Make error more verbose in parser
By printing the function when arguments are missing

https://bugzilla.gnome.org/show_bug.cgi?id=604161
2009-12-09 11:22:24 +00:00
Tomeu Vizoso
03dc6a590b Implement callbacks as part of struct fields. Fixes #557383
gir: embed <callback> inside <field>
typelib: if a field contains a callback, store it just after the FieldBlob
girepository API: no additions
2009-11-11 13:55:00 +01: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
Simon van der Linden
0a046b7aa0 Bug 585328 - Only set zero_terminated flag for types we know are
Rationalize our setting of the zero_terminated flag; we shouldn't
set it if the gir doesn't say to.
2009-06-17 17:32:48 -04:00
C. Scott Ananian
1a256fd7bd Bug 585584: Fix warnings in girparser backtrace functionality and compiler.c 2009-06-12 12:31:43 -04:00
Holger Hans Peter Freyther
5917b5ba42 Make g-ir-compiler find files installed by make install
When ./configure --prefix $HOME/some/where is used gobject-introspection
will happily install the files into $HOME/some/where/data/gir-1.0 but
it will refuse to find them. Apply the same trick as in
girepository/girepository.c:init_globals to find the gir files.

Unifiy the name gir-1.0 in GIR_SUFFIX and use it throughout the
project, introduce GIR_DIR which holds the path to the gir files and
update girparser and transformer.py to look into this path.
2009-06-11 13:53:01 -04:00
Dan Winship
c5930c73c5 Fix 'Could not find GIR file ...' error to use right filename.
Also plug a leak; girname was previously only freed on error.
2009-03-28 08:34:36 -04:00
Andreas Rottmann
7937dd000e Bug 576605 - Get rid of GI_SCOPE_TYPE_OBJECT
Remove support for (scope object) as it lacks a real use case.
2009-03-27 19:31:55 +01:00
Didier 'Ptitjes
a515ab13b0 Bug 576323 - Fix inner constant parsing Signed-off-by: Didier 'Ptitjes <ptitjes@free.fr>
Signed-off-by: Colin Walters <walters@verbum.org>
2009-03-24 15:21:53 -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
Colin Walters
7299c89fc9 Bug 557383 - Virtual method support
Broadly speaking, this change adds the concept of <vfunc> to the .gir.
The typelib already had most of the infrastructure for virtual functions,
though there is one API addition.

The scanner assumes that any class callback slot that doesn't match
a signal name is a virtual.  In the .gir, we write out *both* the <method>
wrapper and a <vfunc>.  If we can determine an association between
them (based on the names matching, or a new Virtual: annotation),
then we notate that in the .gir.

The typelib gains an association from the vfunc to the function, if
it exists.  This will be useful for bindings since they already know
how to consume FunctionInfo.
2009-03-05 15:52:12 -05:00
Colin Walters
cd845500a5 Bug 571548 - Generic attributes
We now support an extensible mechanism where arbitrary key-value
pairs may be associated with almost all items, including objects,
methods, and properties.

These attributes appear in both the .gir and the .typelib.
2009-03-03 17:26:37 -05:00
Colin Walters
9dbb0bf80f Bug 572434 - Associate interfaces with their C structures
Similar to GObject class structs, we pair up GInterfaces with
their C structures.

Also, move some GLib-specific things into glibast.py, and make
the naming more generic.
2009-02-25 17:31:49 -05:00
Colin Walters
3333e4ed9e Merge branch 'master' of ssh://walters@git.gnome.org/git/gobject-introspection 2009-02-13 11:25:23 -05:00
Johan Dahlin
fe8c6d34c4 Add gtk-doc support 2009-02-12 01:32:25 -02:00
Colin Walters
0a74fdfec0 Bug 567906 - Put pkg-config dependencies in .gir files
When generating a .gir file, we now first parse all of our .gir includes
to pick up their <package> headers.  Then, we merge that with the set of
--pkg arguments passed to us, run pkg-config to gather the arguments,
and finally save the merged pkg-config list to our new .gir file.

This is useful for software which needs to map from .gir to pkg-config
in a programmatic way.
2009-02-11 15:03:16 -05:00
Colin Walters
97a2e7f5fc Bug 571248 - Ignore unknown elements in girparser
We want the gir to be extensible.

svn path=/trunk/; revision=1096
2009-02-11 00:08:49 +00:00
Rober Carr
3490a56ba4 Bug 569633 – Typelib compiler fails with vararg callbacks
2009-02-10  Rober Carr <carrr@rpi.edu>

	Bug 569633 – Typelib compiler fails with vararg callbacks

	* girepository/girparser.c: Also filter out callback functions
	which take vararg arguments.

svn path=/trunk/; revision=1095
2009-02-10 23:34:04 +00:00
Colin Walters
ff6b28c17b Bug 551738 - Associate classes with their structs
Inside glibtransformer, we now look at structures ending in "Class" and
see if they have an associated GlibObject (i.e. a structure of the same
name without the "Class" suffix).  If found, pair them up.

The .gir file for <class> gains an attribute denoting its associated
class struct.  Any <record> many now have a glib:is-class-struct-for
annotation which tells which (if any) <class> for which it defines the
layout.

In the .typelib, we record the association between the class and
its structure.  Generic structures however just have a boolean
saying whether they're a class struct.  (Going from a generic class
struct to its class should not be necessary).

Finally, we expose GIRepository APIs to access both bits of information
from the .typelib.

svn path=/trunk/; revision=1088
2009-02-06 18:37:13 +00:00
Colin Walters
52d2251c82 Bug 555960 - Nested structs and unions (generation portion)
Patch from Andreas Rottmann <a.rottmann@gmx.at>.

	* tests/scanner/utility.h (UtilityTaggedValue): Make the union
	member anonymous.
	(UtilityByte): New union typedef with an unnamed struct in it.

	* giscanner/transformer.py (Transformer._create_struct): Create
	unnamed structs for symbols with a None ident.
	(Transformer._create_union): Likewise.

	* giscanner/girwriter.py (GIRWriter._write_record): Allow name
	being None.
	(GIRWriter._write_union): Likewise.

	* girepository/girparser.c (start_struct): Allow a NULL name for
	non-toplevel structs.
	(start_union): Likewise.

	* tests/scanner/utility.h (UtilityTaggedValue): New struct
	typedef, which has a nested union member.
	* tests/scanner/utility-expected.gir: Adapted.

	* giscanner/transformer.py (Transformer._create_member): Create
	struct/union members if appropriate.
	(Transformer._create_struct, Transformer._create_union): Allow for
	structs/unions without a C type.

	* giscanner/glibtransformer.py (GLibTransformer._resolve_field):
	We don't need to resolve non-typef'd
	(GLibTransformer._resolve_field): Add cases for non-typedef'd
	struct/union "fields".

	* giscanner/girwriter.py (GIRWriter._write_record): Allow for
	records without a C type.
	(GIRWriter._write_field): structs and unions may appear in places
	where fields do.

svn path=/trunk/; revision=1082
2009-02-04 00:48:24 +00:00
Colin Walters
8a0cdd96e9 Bug 555960 - nested structs and unions
Patch from Andreas Rottmann <a.rottmann@gmx.at>.

This change modifies the parser to hold a stack of nodes, instead of
a single concept of "current" node.  This allows the parser to recurse
into nested nodes.

svn path=/trunk/; revision=1081
2009-02-04 00:48:17 +00:00
Robert Carr
3353523d11 Undo revision 1075
svn path=/trunk/; revision=1077
2009-01-29 10:43:05 +00:00
Robert Carr
8ac6225faf post_filter_varargs_functions should also filter callbacks. Add tests of
* girepository/girparser.c: post_filter_varargs_functions
  should also filter callbacks.
* tests/scanner/foo.h: Add tests of varargs callbacks.

svn path=/trunk/; revision=1075
2009-01-29 10:32:25 +00: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
Andreas Rottmann
b95d92aca0 Bug 556489 – callback annotations
2008-01-03  Andreas Rottmann  <a.rottmann@gmx.at>

	Bug 556489 – callback annotations
	
	* giscanner/transformer.py 

	* tools/generate.c (write_callable_info): Write out the new scope,
	closure and destroy attributes.

	* giscanner/transformer.py (Transformer._type_is_callback): New
	method, checking if a given type is a callback.
	(Transformer._augment_callback_params): New method; adds
	information (closure, destroy) to callback parameters.
	(Transformer._handle_closure, Transformer._handle_destroy): New methods, 
	auxiliary to _augment_callback_params.
	(Transformer._create_function): Call _augment_callback_params().
	(Transformer._create_parameter): Handle scope option.

	(Transformer._create_typedef_callback): New method, creates a
	callback, and registers it in the typedef namespace
	(Transformer._create_typedef): Use _create_typedef_callback()
	instead of the plain _create_callback().

	* giscanner/ast.py (Parameter): Added callback-related fields.
	* giscanner/girwriter.py: Write out new Parameter fields.

	* girepository/girnode.h (GIrNodeParam): Added fields scope, 
	closure and destroy.
	* girepository/gtypelib.h (ArgBlob): Ditto.
	* girepository/girparser.c (start_parameter): Handle new fields.

	* girepository/girmodule.c (g_ir_module_build_typelib): Adjust
	arg_blob_size, bump major version due to this change.
	* girepository/girnode.c (g_ir_node_get_full_size_internal)
	(g_ir_node_build_typelib)
	* girepository/gtypelib.c (g_typelib_check_sanity): ArgBlob size
	adjustments.
	(g_ir_node_build_typelib): Fill in new ArgBlob flags from param. 

	* girepository/girepository.h (GIScope): New enumeration, listing
	the different possible scopes for callbacks.

	* girepository/ginfo.c (g_arg_info_get_scope)
	(g_arg_info_get_closure, g_arg_info_get_destroy): Accessors for
	callback-related argument indices (callback scope, closure for a
	callback, destroy notification for a callback).

	* tests/scanner/: Added testcases for new features.

svn path=/trunk/; revision=998
2009-01-03 13:44:42 +00:00
Colin Walters
74e22b307c Bug 559705 – Missing association between static methods and classes
2008-11-25  Colin Walters  <walters@verbum.org>

        Bug 559705 – Missing association between static methods and classes

        * docs/typelib-format.txt:
        * girepository/ginfo.c (g_function_info_get_flags):
        * girepository/girmodule.c (g_ir_module_build_typelib):
        * girepository/girnode.c (g_ir_node_get_size),
        (g_ir_node_build_typelib):
        * girepository/girparser.c (start_function):
        * girepository/gtypelib.c (g_typelib_check_sanity),
        (validate_header), (validate_function_blob):
        * girepository/gtypelib.h:
        * giscanner/ast.py:
        * giscanner/girwriter.py:
        * giscanner/glibtransformer.py:
        * tests/scanner/foo-1.0-expected.gir:
        * tests/scanner/foo-1.0-expected.tgir:
        * tests/scanner/foo.h:


svn path=/trunk/; revision=972
2008-11-25 22:29:20 +00:00