Commit Graph

30 Commits

Author SHA1 Message Date
Jasper St. Pierre
04cf2f480d girffi: Fix g_function_info_new_for_address to respect G_VFUNC_THROWS 2012-02-03 13:48:39 -05:00
Colin Walters
e865dcb7b4 Add Emacs mode lines to C sources 2012-02-03 13:42:56 -05:00
Jasper St. Pierre
a0d19ca066 girffi: Add new g_function_invoker_new_for_address
This is a new method designed to make a GIFunctionInvoker for
any GICallableInfo*, for bindings to use.
2012-02-03 11:52:33 -05:00
Jasper St. Pierre
3e1486f924 girffi: Fix compiler warnings 2012-01-06 15:00:46 -05:00
Ray Strode
c99df8f34c ffi: Treat enums as 32 bit signed values to fix PPC64
To call a function dynamically using ffi, the caller
first has to tell ffi the size of all the input arguments
of the function. On little endian architectures (like x86_64)
specifying a size that's too large will happen to work because
of how the bits are laid out in memory.  On big endian architectures,
however, specifying the wrong size can lead to reading the wrong
bits.

The function g_type_info_get_ffi_type maps input giargument types to
specific sizes. It was assuming enums were word (pointer) sized; in
fact they can be in theory any size (1,2,4,8 bytes), but in practice
in introspection (via GIArgument) as well as GValue we're limited to 4
byte enums.

This commit fixes PPC64 (big endian, 64 bit).

Signed-off-by: Colin Walters <walters@verbum.org>

https://bugzilla.gnome.org/show_bug.cgi?id=665150
2011-12-21 15:55:18 -05:00
Colin Walters
6f0cf9a0aa girffi: Remove unnecessary sys/mman.h include
While we're here move config.h to the top for consistency.
2011-09-03 12:03:34 -04:00
Giovanni Campagna
98067194d6 Free allocated ffi_types in g_callable_info_free_closure()
g_callable_info_prepare_closure() allocates memory for the argument
types in the ffi_cif, so we need to free it.

https://bugzilla.gnome.org/show_bug.cgi?id=652954
2011-06-20 21:19:05 +02:00
Jonathan Matthew
5debbc28a9 Account for arg direction in g_callable_info_get_ffi_arg_types
https://bugzilla.gnome.org/show_bug.cgi?id=641647
2011-02-09 07:52:53 +10: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
Colin Walters
e6bb30500c Export gi_type_tag_get_ffi_type
This is needed by the offsets code, and is generally useful.  We
need to export it for a future patch which won't export symbols
with a leading _.
2010-11-09 17:07:26 -05: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
6b4647c088 [girepository] Kill girffi-private.h 2010-06-06 23:22:57 -03:00
Johan Dahlin
51118b3338 [girepository] Document most of the structs 2010-05-18 18:11:58 -03:00
Owen W. Taylor
9d2fd90f0a Correctly use ffi_closure_alloc(), fixing mmap permissions error
This restores the reverted-commit ed8634d:

    Author: Dan Winship <danw@gnome.org>
    Date:   Mon Apr 5 14:05:52 2010 -0400

    g_callable_info_prepare_closure: handle mmap permissions error

    When SELinux or similar is active, a process may not be able to mmap()
    a segment that is both writable and executable, which would causing
    g_callable_info_prepare_closure() to fail. Libffi has a workaround for
    this problem though (it maps the same non-anonymous region twice, once
    writable and once executable, and returns two separate pointers to
    it), so use that.

But with an added fix, when using ffi_closure_alloc(), we need to use
ffi_prep_closure_loc() so we can pass in the executable address of the
trampoline separately from the writable address, rather than the
deprecated ffi_prep_closure().

https://bugzilla.gnome.org/show_bug.cgi?id=615105
2010-04-08 10:50:04 -04:00
Colin Walters
6545640515 Revert "g_callable_info_prepare_closure: handle mmap permissions error"
This reverts commit ed8634ddf73a56cb1935fd87254b3c6c04352893.

This commit caused crashes in gjs/gnome-shell, which we're still trying
to track down.  See: http://bugzilla.gnome.org/615078
2010-04-07 15:22:00 -04:00
Dan Winship
24363834ff g_callable_info_prepare_closure: handle mmap permissions error
When SELinux or similar is active, a process may not be able to mmap()
a segment that is both writable and executable, which would causing
g_callable_info_prepare_closure() to fail. Libffi has a workaround for
this problem though (it maps the same non-anonymous region twice, once
writable and once executable, and returns two separate pointers to
it), so use that.

https://bugzilla.gnome.org/show_bug.cgi?id=614903
2010-04-06 08:33:54 -04:00
Johan Dahlin
6b0463dd16 [girepository] Remove trailing whitespace 2010-03-24 15:02:05 -03:00
Johan Dahlin
109159ee05 The private header should be included in girffi.c
Not in the public girffi.h.
2009-12-31 17:37:21 +01:00
Colin Walters
f2f0625622 [girffi] Clean up API, add g_function_info_prep_invoker
Rather than having bindings use g_function_info_invoke, which is basically
a toy/demo API, export a convenience utility function which takes the introspection
information and sets up things we need to pass to libffi.

Then invocation can be done directly to libffi by a binding.

As part of this work, remove some (unused by gjs) public functions from the
girffi API, and instead export a function to map to libffi which can work
semi-correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=604074
2009-12-16 18:17:12 -05:00
Johan Dahlin
954312db60 Revert "GI_TYPE_TAG_VOID != ffi_type_void"
This reverts commit 28cccba737ec2214da66b0d74059278162cf5fd0.
2009-12-15 11:00:52 -02:00
Iain Nicol
c22f11f1b8 Remove some unportable integral type size assumptions
https://bugzilla.gnome.org/show_bug.cgi?id=602762
2009-12-02 10:45:20 -02:00
Jasper Lievisse Adriaanse
a7c04b69de Fix build on OpenBSD
Due to a missing header, gobject-introspection fails to compile on OpenBSD.
And only due to headers-including-headers practice this doesn't blow up on
many other platforms.

https://bugzilla.gnome.org/show_bug.cgi?id=596226
2009-12-02 10:39:31 -02:00
Maxim Ermilov
4b796371ae GI_TYPE_TAG_VOID != ffi_type_void
https://bugzilla.gnome.org/show_bug.cgi?id=603157
2009-12-02 10:37:19 -02:00
Maxim Ermilov
a668ac5303 Plug a leak in g_callable_info_get_ffi_return_type
https://bugzilla.gnome.org/show_bug.cgi?id=603526
2009-12-02 10:19:45 -02:00
Tomeu Vizoso
43f1c2db17 Add g_ir_ffi_convert_arguments 2009-11-12 10:53:45 +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
Johan Dahlin
fe8c6d34c4 Add gtk-doc support 2009-02-12 01:32:25 -02:00
Johan Dahlin
314ad462dc Add utility functions for invocing closures given a GICallableInfo using
2009-02-04  Johan Dahlin  <jdahlin@async.com.br>

    * girepository/Makefile.am:
    * girepository/girffi.c (g_callable_info_get_ffi_arg_types),
    (g_callable_info_get_ffi_return_type),
    (g_callable_info_prepare_closure), (g_callable_info_free_closure):
    * girepository/girffi.h:
    Add utility functions for invocing closures given a GICallableInfo
    using libffi.


svn path=/trunk/; revision=1084
2009-02-05 00:40:14 +00:00
Owen Taylor
3b0bf76d21 girepository/girffi.c: Fix "Unexpected time for time_t" message.
svn path=/trunk/; revision=919
2008-11-13 21:38:42 +00:00
Owen Taylor
d041deae59 Split g_ir_ffi_get_ffi_type() out from ginvoke.c
Extract a function to convert GITypeTag to ffi_type from the internals
of ginvoke.c. This will be useful in figure out structure alignment.

Also fix handling of gsize and time_t to be portable. (Add a check
to configure.ac to figure out the width of time_t.)

svn path=/trunk/; revision=873
2008-11-11 00:04:45 +00:00