Commit Graph

31 Commits

Author SHA1 Message Date
Colin Walters
a837d99ee6 Enumerations can be negative
Change the internal type for ValueBlob to gint32, since it's perfectly
valid for enumerations to have negative values.

https://bugzilla.gnome.org/show_bug.cgi?id=613203
2010-03-18 09:50:33 -04: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
Colin Walters
8ba5a13d17 [gtypelib.h] Document SimpleTypeBlob more 2009-11-04 11:43:13 -05: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
Tobias Mueller
65e241fab8 Name unions to enable compilation on Solaris
Patch by Brian Cameron <brian.cameron@sun.com>.
Fixes bug 578199.
2009-06-24 23:52:05 +02:00
C. Scott Ananian
7f29f620a4 Update doc comments.
The enumeration values cited here were out of date.  Rewrite to eliminate
the explicit mention of the enumeration value, to prevent it from
drifting out of date again in the future.
2009-05-12 16:11:32 +01: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
361de29ba0 Bug 571373 - Add padding to typelib objects
Expand various typelib objects to ensure we have at least 16 bits
left for each one to add another string indirection or directory offset,
and also that we have at least a few bits for more flags.
2009-02-18 21:54:04 -05:00
Colin Walters
ff6c10e53c Bug 571373 - Move typelib docs from typelib-format.txt into girepository.h
typelib-format.txt was growing out of date; a good solution to this is
to move it closer to the code it's documenting.  By doing this we also
gain the ability to use gtk-doc on it.
2009-02-18 21:53:59 -05: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
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
Owen Taylor
05d5158001 Add "storage type" to the typelib data for enums
In order to set and get enum and flag fields in structures, we need
to know the integral type that the enumeration is stored as. We are already
computing that at compile time in order to compute struct offsets, so the
easiest thing to do is to save that in the typelib.

* docs/typelib-format.txt girepository/girnode.[ch] girepository/giroffsets.c
girepository/gtypelib.h: Add 'storage_type' to the typelib format for EnumBlob
and compute and save it at compile time.

* girepository/girepository.h girepository/ginfo.c:
Add g_enum_info_get_storage_type().

* girepository/gfield.c: Implement reading and writing enum and flags fields
based on the storage type.

http://bugzilla.gnome.org/show_bug.cgi?id=561296

svn path=/trunk/; revision=944
2008-11-18 12:29:10 +00:00
Owen Taylor
6cb96533b9 Bug 560825 – Add size and alignment to typelib
Include the size and alignment of structures and unions in the typelib,
and add getter methods to retrieve them from GIStructInfo/GIUnionInfo.

* docs/typelib-format.txt girepository/gtypelib.h girepository/girnode.c
girepository/girmodule.c girepository/gtypelib.c: Add size and alignment
to StructBlob and UnionBlob.

* girepository/ginfo.c girepository/girepository.h:
Add g_[struct|union]_get[size|alignment]().

* test/offsets/gen-gitestoffsets: Test overall structure size and alignment.

svn path=/trunk/; revision=930
2008-11-16 21:15:54 +00:00
Colin Walters
832328d59a Bug 557786 - support fixed size arrays
svn path=/trunk/; revision=814
2008-10-25 15:20:54 +00:00
Tommi Komulainen
04c5badd69 Bug 557405 – Use 'allow-none' consistently
2008-10-22  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* docs/typelib-format.txt:
	* girepository/ginfo.c (g_arg_info_may_be_null):
	* girepository/girnode.c (g_ir_node_build_typelib):
	* girepository/girnode.h (struct _GIrNodeParam):
	* girepository/girparser.c (start_parameter):
	* girepository/girwriter.c (function_generate):
	* girepository/gtypelib.h (ArgBlob):
	* tests/errors.gir:
	* tests/function.gir:
	* tools/generate.c (write_callable_info): Use 'allow-none'
	consistently throughout

svn path=/trunk/; revision=782
2008-10-22 14:02:02 +00:00
Johan Bilien
727bb01805 Bug 557241 – "throws" flag for functions
2008-10-21  Johan Bilien  <jobi@via.ecp.fr>

	Bug 557241 – "throws" flag for functions

	* tests/scanner/drawable-1.0-expected.gir,
	tests/scanner/drawable-injected-1.0-expected.gir,
	tests/scanner/drawable.[ch]: add simple test for throwing
	function (has GError ** as last argument)

	* giscanner/ast.py: add a 'throws' flag to Function
	* giscanner/glibtransformer.py: if a function's last paramerter is
	a GError, set the 'throws' flag and remove that parameter
	* giscanner/girwriter.py: write out the 'throws' attribute
	* giscanner/girparser.py: support parsing the 'throws' attribute

	* tests/repository/gitestthrows.c: add a simple test to check the
	throws flag in a typelib and invoke the function

	* girepository/ginfo.c, girepository/girnode.[ch],
	girepository/girnode.h, girepository/girparser.c,
	girepository/girepository.h: Add and parse the GI_FUNCTION_THROWS flag

	* girepository/ginvoke.c: if a function throws, add a GError as last
	arguments, and propagate the error to the invoker.


svn path=/trunk/; revision=773
2008-10-21 17:04:11 +00:00
Colin Walters
c3330c06c7 Bug 557011 - Add g_object_info_get_abstract
svn path=/trunk/; revision=757
2008-10-20 17:04:17 +00:00
Tommi Komulainen
6a82099f9b Bug 556048 – Crash in g_irepository_find_by_gtype
* girepository/gtypelib.h (BLOB_IS_REGISTERED_TYPE): added
	* girepository/girepository.c (find_interface): Fix
	find_by_gtype case to get the type name from right offset

svn path=/trunk/; revision=686
2008-10-12 20:53:26 +00:00
Tommi Komulainen
44172e786a make 'unregistered' one bit wide as everywhere else
2008-10-12  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* girepository/gtypelib.h (RegisteredTypeBlob): make
	'unregistered' one bit wide as everywhere else

svn path=/trunk/; revision=684
2008-10-12 19:30:22 +00:00
Colin Walters
3be641f836 Bug 552858: versioning
This is a big patch.  You should probably remove your installation
	tree to be cleaner.

	* docs/typelib-format.txt: Add nsversion entry which holds
	version of namespace.
	* girepository/girepository.h: Add 'version' parameter to
	g_irepository_require.  This may be NULL.  Normally
	bindings should pass an explicit version though.
	* girepository/girepository.c: Lots of infrastructure to
	support versioning.  Add some more documentation.  Disallow
	some usage of NULL namespaces.
	* girepository/girmodule.c: Add version parameter.
	* girepository/gtypelib.c: Update header size.
	* giscanner/ast.py: Add version to Namespace.
	* giscanner/girparser.py: Parse version attribute from
	XML, pass to Namespace.
	* giscanner/girwriter.py: Write out version parameter.
	* giscanner/transformer.py: Clean up include registration.
	* tests/*: Add version attribute.
	* tests/invoke/invoke.c: Don't try looking up test before
	it's loaded in repository.
	* tools/generate.c: Output version parameter.
	* gir/Makefile.am: Add 2.0 version to .gir files.

svn path=/trunk/; revision=677
2008-10-12 04:51:48 +00:00
Lucas Rocha
728beb0424 Bug 555294: Add support for multiple shared libraries per typelib.
2008-10-06  Lucas Rocha  <lucasr@gnome.org>

	Bug 555294: Add support for multiple shared libraries per typelib.

	* girepository/ginvoke.c (g_function_info_invoke),
	girepository/ginfo.c(g_registered_type_info_get_g_type): use
	g_typelib_symbol instead of g_module_symbol.
	* girepository/girepository.h: remove g_typelib_set_module and add
	g_typelib_symbol.
	* girepository/gtypelib.[ch] (find_some_symbol, _g_typelib_init,
	g_typelib_new_from_memory, g_typelib_new_from_const_memory,
	g_typelib_free, g_typelib_symbol): chnage GTypeLib to hold a list of
	modules instead of just one. The symbol lookup is now abstracted
	behind g_typelib_symbol which tries to find the passed symbol name in
	one of its modules.
	* giscanner/girwriter.py, tools/g-ir-scanner: change scanner to read
	and write shared_library attribute as a comma-separated list of libs.

svn path=/trunk/; revision=660
2008-10-07 21:25:01 +00:00
Colin Walters
6e656b4498 Put dependencies in typelibs, resolve them when loading
* gir/Makefile.am: Dep on Makefile
	* girepository/ginfo.c: Print out a nicer error
	message if we failed to load something.
	* girepository/girepository.c: Clean up
	default typelib handling; remove global
	default_typelib variable.  Ensure we handle
	NULL repository in more places.
	Support dependency resolution.
	* tests/Makefile.am: Kill off gobject.gir,
	it conflicts with the real one.
	* tests/Object.gir: Depend on GObject.
	* tools/generate.c: Take --includedir
	argument to say which directories to search
	for typelibs.  Print out dependencies.

svn path=/trunk/; revision=541
2008-08-30 20:31:07 +00:00
Tor Lillqvist
0969efd5a5 Change type of bitfield fields from guint to the most suitable smaller
2008-08-28  Tor Lillqvist  <tml@novell.com>

	* girepository/gtypelib.h: Change type of bitfield fields from
	guint to the most suitable smaller type. This makes the struct
	sizes match the ones on Linux that the sanity check expects when
	using gcc -mms-bitfields on Windows.


svn path=/trunk/; revision=508
2008-08-28 10:24:35 +00:00
Colin Walters
0ed07b5934 Remove usage of (GAPI-oriented) TypeTag in favor of GITypeTag from
2008-08-12  Colin Walters  <walters@verbum.org>

	* girepository/girparser.c, girepository/gtypelib.c,
	girepository/gtypelib.h, girepository/girnode.c:
	Remove usage of (GAPI-oriented) TypeTag in favor of
	GITypeTag from girepository.h.



svn path=/trunk/; revision=347
2008-08-12 15:34:27 +00:00
Johan Dahlin
33455bc3ef Rename metadata to typelib in variable names, comments and apis.
2008-08-09  Johan Dahlin  <johan@gnome.org>

    * *.[ch]:
    Rename metadata to typelib in variable names,
    comments and apis.


svn path=/trunk/; revision=339
2008-08-09 12:55:32 +00:00
Johan Dahlin
e1c3498df8 Merge in the gir-compiler branch. Thanks to Philip and Colin for their
2008-08-08  Johan Dahlin  <johan@gnome.org>

    * girepository/gtypelib.c (validate_header):
    * girepository/gtypelib.h:
    * giscanner/ast.py:
    * giscanner/girwriter.py:
    * giscanner/sourcescanner.c (gi_source_symbol_ref),
    (gi_source_symbol_unref):
    * tests/array.test:
    * tests/boxed.test:
    * tests/constant.test:
    * tests/enum.test:
    * tests/errors.test:
    * tests/function.test:
    * tests/gobject.test:
    * tests/interface.test:
    * tests/invoke/Makefile.am:
    * tests/invoke/testfns.xml:
    * tests/object.test:
    * tests/parser/Makefile.am:
    * tests/roundtrips.sh:
    * tests/struct.test:
    * tests/types.test:
    * tests/union.test:
    * tests/xref1.test:
    * tests/xref2.test:
    * tools/Makefile.am:
    * tools/compiler.c (main):
    * tools/generate.c (write_callable_info), (write_function_info),
    (write_repository):
    * tools/gidlmodule.c:
    * tools/gidlmodule.h:
    * tools/gidlnode.c:
    * tools/gidlnode.h:
    * tools/gidlparser.c:
    * tools/gidlparser.h:
    * tools/gidlwriter.c:
    * tools/gidlwriter.h:
    * tools/scanner.c (create_node_from_gtype),
    (create_node_from_ctype), (g_igenerator_process_properties),
    (g_igenerator_process_signals), (g_igenerator_create_object),
    (g_igenerator_create_interface), (g_igenerator_create_boxed),
    (g_igenerator_create_enum), (g_igenerator_create_flags),
    (g_igenerator_process_function_symbol),
    (g_igenerator_process_unregistered_struct_typedef),
    (g_igenerator_process_struct_typedef),
    (g_igenerator_process_union_typedef),
    (g_igenerator_process_enum_typedef),
    (g_igenerator_process_function_typedef),
    (g_igenerator_process_constant), (g_igenerator_process_symbols),
    (g_igenerator_add_module), (g_igenerator_add_include_idl):
    Merge in the gir-compiler branch.
    Thanks to Philip and Colin for their help.


svn path=/trunk/; revision=325
2008-08-08 19:09:17 +00:00
Philip Van Hoof
776ee5f79e tools/gidlnode.c
2008-06-08  Philip Van Hoof  <pvanhoof@gnome.org>

        * girepository/girepository.c:
        * girepository/gtypelib.c:
        * girepository/ginfo.c:
        * girepository/ginvoke.c:
        * girepository/girepository.h:
        * girepository/gtypelib.h:
        * girepository/gmetadata.c:
        * girepository/Makefile.am:
        * girepository/gmetadata.h:
        * tools/compiler.c:
        * tools/gidlmodule.c:
        * tools/gidlnode.c
        * tools/generate.c:
        * tools/gidlmodule.h:
        * tools/gidlparser.c:

        Renamed GMetadata to GTypelib


svn path=/trunk/; revision=288
2008-06-08 14:37:30 +00:00