Commit Graph

111 Commits

Author SHA1 Message Date
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
Colin Walters
44b1fde2db Add test for interface prereq
svn path=/trunk/; revision=935
2008-11-17 00:27:44 +00:00
Colin Walters
7916f49e55 Bug 559706 - interface prequisites
svn path=/trunk/; revision=932
2008-11-17 00:27:37 +00:00
Colin Walters
5a1f29d1c9 Bug 560241 - Out-arguments should not be marked as being pointers in all cases
svn path=/trunk/; revision=928
2008-11-16 20:58:35 +00:00
Owen Taylor
7fa1ffa6e7 Bug 560419 – Cache includes when parsing
Keep track of all modules parsed within a GIrParser, and when a
module is referenced a second time, use the existing parsed copy
instead of reparsing.

svn path=/trunk/; revision=906
2008-11-12 17:17:15 +00:00
Owen Taylor
9a36a18939 Fix management of ParseContext.includes_modules (#560419)
Fix some trivial bugs in managing the list of include modules.
(Add to module's list twice, not initialized to NULL, not freed.)

svn path=/trunk/; revision=905
2008-11-12 17:17:08 +00:00
Owen Taylor
b1c6e64049 Keep aliases and disguised_structures local to each module (#560419)
When parsing, keep keep a separate hash tables of aliases and
'disguised' flags for each module, and store that on the module.

After parsing an include merge the aliases/disguised flags to the
including module.

Remove 'prefix_aliases' flag and always prefix aliases/disguised
structure types when parsing; this simplifies the code considerably.

svn path=/trunk/; revision=904
2008-11-12 17:17:01 +00:00
Owen Taylor
102e08428b Only allow one <namespace/> element per <repository/> (#560419)
The logic in girparser.c didn't work very well if there were multiple
<namespace/> nodes within a single <repository/> (context->namespace
was always the overall filename and not the the name specified in the
<namespace/> element for one thing; this would cause aliases to
be mis-prefixed in include modules.) Also check that the "name" in
the <namespace/> node matches the filename.

svn path=/trunk/; revision=902
2008-11-12 17:16:49 +00:00
Owen Taylor
0faf142d0a Add a GirParser object to hold the state of a compilation
Add a toplevel GirParser object to hold state that is global across
a compilation. Currently just holds the include path, but will
eventually also keep a cached list of parsed modules.

svn path=/trunk/; revision=901
2008-11-12 17:16:42 +00:00
Johan Bilien
7bada628b9 Bug 560474 – g-ir-compiler crashes when compiling the glib gir
2008-11-12  Johan Bilien  <jobi@via.ecp.fr>

	Bug 560474 – g-ir-compiler crashes when compiling the glib gir

	* girepository/girparser.c: avoid freeing an uninitialized pointer


svn path=/trunk/; revision=891
2008-11-12 12:12:04 +00:00
Owen Taylor
744f3a3004 Bug 560404 – Prefix types when resolving aliases in included modules
* girepository/girparser.c: When resolving aliases in an included
module, prefix types before looking them up.

svn path=/trunk/; revision=889
2008-11-11 22:02:37 +00:00
Owen Taylor
ecc78cf338 Search provided include dirs before the default directories.
2008-11-11  Owen Taylor  <otaylor@redhat.com>

        * girepository/girparser.c: Search provided include dirs before
        the default directories.

svn path=/trunk/; revision=885
2008-11-11 15:25:59 +00:00