Rectify an assumption that nodes are ordered according to offset
- since this assumption was not true, attributes ended up being not
ordered either and the bsearch() when looking up attributes failed
mysteriously. Instead of making such assumptions, simply sort the
list of nodes we want to extract attributes from.
The total attribute size computation was wrong as we didn't properly
descend into subnodes. This resulted in memory access violations
when writing the typelib (because not enough data was allocated).
Instead of having a separate function for this, just include the
attribute size in the existing function.
See https://bugzilla.gnome.org/show_bug.cgi?id=571548
Signed-off-by: David Zeuthen <davidz@redhat.com>
Use g_slice to allocate instead of g_new(x, 1); It uses a memory
pool internally and should be faster, especially for GBaseInfo/GRealInfo,
structs which are tiny.
To make things really better we should track the line origin of
element from the .gir file (and actually we need to do better
checking in the scanner), but this is slightly less lame.
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.
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.
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
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
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
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
For some things, like computing structure offsets to put into the typelib
we need more than just the aliases from included modules. Do a completel
parse of included modules and store in module->included_modules.
Also add g_ir_find_node() to find node information from within the
active set of modules and their includes.
svn path=/trunk/; revision=874
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
* 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-21 Colin Walters <walters@verbum.org>
* girepository/girmodule.c (g_ir_module_build_typelib):
Revert change to increment header_size; we do that in
write_string.
svn path=/trunk/; revision=440
2008-08-21 Colin Walters <walters@verbum.org>
* girepository/girnode.c (write_string): Tweak to
use UINT instead of INT. Not likely to matter.
* girepository/girmodule.c (g_ir_module_build_typelib):
Add to header_offset as well for header strings
to match what write_string does.
* girepository/gtypelib.c: Replace is_name with
validate_name, which more strongly validates and
handles errors in a better way. Update all callers.
* giscanner/glibtransformer.py: Handle constructors
better.
svn path=/trunk/; revision=439