Commit Graph

54 Commits

Author SHA1 Message Date
Johan Dahlin
7a383b6126 [girepository] Correct GI_IS_ENUM_INFO macro
A GIEnumInfo represents either an enum or a set of flags
2010-05-30 21:56:25 -03:00
Johan Dahlin
a8eff27124 Remove leftover function 2010-05-28 08:49:49 -03:00
Johan Dahlin
e66f46042d [girepository] Add macros for checking struct type
Add macros for checking the sub-struct type. These are
similar to the standard GObject macros.
2010-05-27 23:18:58 -03:00
Colin Walters
23e9949e1d Remove g_arg_info_is_dipper from public API
It wasn't useful, the new g_arg_info_is_caller_allocates is.
2010-05-26 18:14:39 -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
Johan Dahlin
9505b6eb44 [docs] Document GICallableInfo and GIArgInfo
Make docs more consistent and also fix a couple of broken links
2010-05-21 18:30:58 -03:00
Johan Dahlin
51118b3338 [girepository] Document most of the structs 2010-05-18 18:11:58 -03: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
Colin Walters
e6ac69fccd Allow stack allocating GIBaseInfo, add stack retrieval variants
We don't want to malloc each GIBaseInfo when they can be used in
function invocation; instead, allow stack allocation.

There were a lot of structure typedefs which were actually just
exactly the same as GIBaseInfo, with the one exception of GITypeInfo.

Instead, just put the single GITypeInfo boolean inside GIBaseInfo
as a bit in a bitfield.

GIBaseInfo is still opaque publicly; GIRealInfo is the new
internal structure.

Using this, add new functions to retrieve arguments and argument types
on the stack.

https://bugzilla.gnome.org/show_bug.cgi?id=604074
2009-12-16 18:18:35 -05:00
Simon van der Linden
46e36632af Add a method to compare infos
Add g_base_info_equal.
2009-11-20 10:40:07 +01: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
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
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
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
Johan Dahlin
8c2ef112b7 Rename namespace to namespace_ to make the header compilable with a C++ compiler
svn path=/trunk/; revision=1094
2009-02-10 21:01:08 +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
ca638d9ecf Bug 567087 - generic marshaller
Since GObject-Introspection depends on both ffi and GObject, it's
a convenient home for jdahlin's generic signal marshaller until
such time as GObject can directly depend on ffi.

When it gets added to GObject, we can simply point our marshaller
at that one.

svn path=/trunk/; revision=1022
2009-01-12 21:31:43 +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
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
Owen Taylor
c7ae662dbe Bug 552371 – implement struct field get/set
Add convenience functions g_field_info_set_field() and
g_field_info_get_field() to set and get fields based on the offsets
in GIFieldInfo.

svn path=/trunk/; revision=929
2008-11-16 21:14:19 +00:00
Colin Walters
1ffeeab3d4 g_irepository_dump implementation
svn path=/trunk/; revision=911
2008-11-13 19:57:09 +00:00
Johan Dahlin
bc1f9c5bbb Add a g_irepository_get_search_path, so we can access the search paths
2008-11-12  Johan Dahlin  <jdahlin@async.com.br>

        * girepository/girepository.c (g_irepository_get_search_path):
        * girepository/girepository.h:
        Add a g_irepository_get_search_path, so we can access the search
        paths from runtime.


svn path=/trunk/; revision=893
2008-11-12 12:40:34 +00:00
Colin Walters
310f119141 Bug 557791 – g_irepository_require() could return a GTypelib *
svn path=/trunk/; revision=816
2008-10-25 15:48:50 +00:00
Colin Walters
832328d59a Bug 557786 - support fixed size arrays
svn path=/trunk/; revision=814
2008-10-25 15:20:54 +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
Johan Bilien
03d8379142 add g_union_info_find_method
2008-10-14  Johan Bilien  <jobi@via.ecp.fr>

	* girepository/ginfo.c, girepository/girepository.h: add
	g_union_info_find_method


svn path=/trunk/; revision=706
2008-10-14 22:25:13 +00:00
Colin Walters
5069680682 Document g_irepository_get_dependencies
svn path=/trunk/; revision=701
2008-10-13 16:59:09 +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
b26d8d2dce Bug 554632: Create type tag for GType
svn path=/trunk/; revision=641
2008-10-02 13:25:46 +00:00
Colin Walters
8fc943f941 Merge branch 'bug552566-timet/wip'
svn path=/trunk/; revision=624
2008-09-23 18:20:25 +00:00
Colin Walters
dcd4fe622a Add back unresolved
svn path=/trunk/; revision=545
2008-08-30 20:31:16 +00:00
Colin Walters
74651b01bd Remove g_irepository_unregister, add GIRepositoryLoadFlags
svn path=/trunk/; revision=543
2008-08-30 20:31:12 +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
Colin Walters
c09cf789a0 Add new function g_irepository_get_typelib_path which tells us from where
2008-08-20  Colin Walters  <walters@verbum.org>

	* girepository/girepository.c: Add new function
	g_irepository_get_typelib_path which tells
	us from where we loaded a namespace.

svn path=/trunk/; revision=429
2008-08-21 03:06:13 +00:00
Colin Walters
61ae81c9c8 Remove g_irepository_register_file in favor of g_irepository_require.
2008-08-20  Colin Walters  <walters@verbum.org>

	* girepository/girepository.c: Remove
	g_irepository_register_file in favor of
	g_irepository_require.  There are two
	possible deployment scenarios for typelibs:
	First, separate in $DATADIR/gitypelibs/.  Second,
	they may be embedded in shlibs.  However since
	the first is now the normal case, the API is
	optimized around it.

	Refactor internals to look up typelibs for
	namespaces just-in-time, but we expect
	consumers to call g_irepository_require.

	Also, add some docs.  No one has died from that
	before.
	* gir/Makefile.am: Need --library for glib.
	* giscanner/girwriter.py: Write out shared-library.
	* tools/g-ir-writer: Take the first --library
	argument as the target of shared-library.  In
	the future we should make this nicer with pkg-config
	probably.

svn path=/trunk/; revision=426
2008-08-20 23:56:40 +00:00
Johan Dahlin
b3312fb83f Make enum serializing functions public. Clean up some whitespace.
2008-08-18  Johan Dahlin  <johan@gnome.org>

    * girepository/girepository.c (g_type_tag_to_string):
    * girepository/girepository.h:
    * girepository/girnode.c (g_ir_node_get_full_size_internal),
    (find_entry_node):
    * girepository/girnode.h:
    Make enum serializing functions public. Clean up some whitespace.


svn path=/trunk/; revision=394
2008-08-18 08:52:47 +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
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
Havoc Pennington
db7b378221 new function to get the GType given a RegisteredTypeInfo
2008-04-22  Havoc Pennington  <hp@pobox.com>

 	* girepository/ginfo.c (g_registered_type_info_get_g_type): new
	function to get the GType given a RegisteredTypeInfo


svn path=/trunk/; revision=216
2008-04-23 00:57:48 +00:00