Commit Graph

138 Commits

Author SHA1 Message Date
Laszlo Pandy
f478da144f Fix argument name of MISSING_ATTRIBUTE macro ('ctx' => 'context').
The argument was called 'ctx' but the macro was using 'context'.
This wasn't causing the build to fail because the variable
'context' was already defined in all the scopes where this macro
was used.
2011-02-17 18:01:31 +01:00
Pavel Holejsovsky
5857d9c231 Add support for g[u]intptr in scanner and girwriter.
https://bugzilla.gnome.org/show_bug.cgi?id=634838
2011-01-13 16:20:01 +01:00
Andreas Rottmann
732911c703 Don't emit shadowed methods into the typelib
Ignore shadowed methods when parsing the GIR.
2010-12-07 00:07:08 +01:00
Colin Walters
ff33cc0791 girepository: Consistently prefix internal functions with _
This should better avoid them being exported.  Rename
girepository-parser.la to girepository-internals.la for clarity.
2010-11-16 16:58:39 -05:00
Colin Walters
f9a3bb7300 Add support for gunichar in typelib
Some API such as gtk_text_iter_get_char returns an individual
"gunichar"; we should support this.

https://bugzilla.gnome.org/show_bug.cgi?id=633197
2010-11-12 16:00:10 -05:00
Owen W. Taylor
ec76ea8628 Handle enumerations with the full range of signed and unsigned values
The C compiler will pick an enumeration type that accomodates the specified
values for the enumeration, so ignoring 64-bit enumerations, we can
have enumeration values from MININT32 to MAXUINT32. To handle this properly:

 - Use gint64 for holding eumeration values when scanning
 - Add a 'unsigned_value' bit to ValueBlob so we can distinguish the
   int32 vs. uint32 cases in the typelib
 - Change the return value of g_value_info_get_value() to gint64.

https://bugzilla.gnome.org/show_bug.cgi?id=629704
2010-11-01 17:25:45 -04:00
Tomeu Vizoso
9468bd36c9 Actually do something about fundamentals when parsing a .gir
https://bugzilla.gnome.org/show_bug.cgi?id=630710
2010-09-29 15:55:37 +02:00
Colin Walters
6bc078f1ee typelib compiler: Passthrough <doc> at any point
This should have been in the previous commit.
2010-09-14 12:31:58 -04:00
Steve Frécinaux
8548baf3b9 [VFuncBlob] Unknown struct offset should be 0xFFFF
Documentation says about g_vfunc_get_offset():

 "Obtain the offset of the function pointer in the class struct.
  The value 0xFFFF indicates that the struct offset is unknown."

But g-ir-compiler did set the value to 0 when the offset is unknown.
This patch fixes it.

https://bugzilla.gnome.org/show_bug.cgi?id=628270
2010-09-06 08:33:40 +02:00
Colin Walters
9a46475584 scanner: Fix previous rename-to handling commit 2010-09-03 18:17:28 -04:00
Colin Walters
f0eeec8cd8 scanner: Fix rename-to handling
We were writing the attributes backwards.  Also actually use
the attribute in the typelib generation.
2010-09-03 18:07:16 -04:00
Colin Walters
35cb08a25e Major rewrite
One of the first big changes in this rewrite is changing the Type
object to have separate target_fundamental and target_giname properties,
rather than just being strings.  Previously in the scanner, it was
awful because we used heuristics around strings.

The ast.py is refactored so that not everything is a Node - that
was a rather useless abstraction.  Now, only things which can have
a GIName are Node.  E.g. Type and Field are no longer Node.

More things were merged from glibast.py into ast.py, since it isn't
a very useful split.

transformer.py gains more intelligence and will e.g. turn GLib.List
into a List() object earlier.  The namespace processing is a lot
cleaner now; since we parse the included .girs, we know the C
prefix for each namespace, and have functions to parse both
C type names (GtkFooBar) and symbols gtk_foo_bar into their
symbols cleanly.  Type resolution is much, much saner because
we know Type(target_giname=Gtk.Foo) maps to the namespace Gtk.

glibtransformer.py now just handles the XML processing from the dump,
and a few miscellaneous things.

The major heavy lifting now lives in primarytransformer.py, which
is a combination of most of annotationparser.py and half of
glibtransformer.py.

annotationparser.py now literally just parses annotations; it's
no longer in the business of e.g. guessing transfer too.

finaltransformer.py is a new file which does post-analysis for
"introspectability" mainly.

girparser.c is fixed for some introspectable=0 processing.
2010-08-31 16:05:56 -04:00
Colin Walters
f5ec6f6698 Use GLib types consistently
Rather than have the scanner/parser handle both e.g. "glong" and
"long", simply use the GLib types everywhere.

This commit adds TYPE_LONG_LONG and TYPE_LONG_DOUBLE to the
scanner types; however, rather than add them to the typelib,
they're just marked as not-introspectable.
2010-08-31 16:05:56 -04:00
Colin Walters
d853f196c1 Move alias target to <type>
This makes type parsing more uniform.

Delete the typedef for GSList in foo.h - that's not
supported anymore, or at least for now.
2010-08-31 16:05:56 -04:00
Colin Walters
62f1b65cc8 [gircompiler] Clean up parsing
We never actually include multiple modules in the compiler,
so just nuke that.  Also rather than passing around GIrModule
consistently pass around a GIrTypelibBuild structure which
has various things.

This lets us maintain a stack there which we can walk for
better error messages.

Also, fix up the node lookup in giroffsets.c; previously
it didn't really handle includes correctly.  We really need to
switch to always using Foo.Bar (i.e. GIName) names internally...
2010-08-17 13:14:51 -04:00
Colin Walters
f552f46f88 [girparser] Cleanly pass through c:include 2010-08-17 13:11:03 -04:00
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