more work on binding docs
This commit is contained in:
parent
6397aae326
commit
d2b4478318
@ -9,8 +9,8 @@
|
|||||||
<refpurpose>Writing bindings for libvips</refpurpose>
|
<refpurpose>Writing bindings for libvips</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
|
|
||||||
There are full libvips bindings for quite a few languages now: C, C++, Ruby,
|
There are full libvips bindings for quite a few environments now: C, C++,
|
||||||
PHP, Python and JavaScript.
|
command-line, Ruby, PHP, Python and JavaScript (node).
|
||||||
|
|
||||||
This chapter runs through the four main styles that have been found to work
|
This chapter runs through the four main styles that have been found to work
|
||||||
well. If you want to write a new binding, one of these should be close
|
well. If you want to write a new binding, one of these should be close
|
||||||
@ -182,21 +182,17 @@ it's as simple as:
|
|||||||
from gi.repository import Vips
|
from gi.repository import Vips
|
||||||
```
|
```
|
||||||
|
|
||||||
libvips used in this way is likely to be rather bare-bones. For Python, we
|
You can now use all of the libvips introspection machinery, as noted above.
|
||||||
wrote a set of overrides which layer a more Pythonesque interface on top
|
|
||||||
of the one provided for libvips by pygobject. These overrides are simply
|
|
||||||
a set of Python classes.
|
|
||||||
|
|
||||||
To call a vips operation, you'll need to make a new operation with
|
Unfortunately g-o-i has some strong disadvantages. It is not very portable,
|
||||||
vips_operation_new() (all it does is look up the operation by name
|
since you will need a g-o-i layer for whatever platform you are targetting,
|
||||||
with vips_type_find(), then call g_object_new() for you), then use
|
it does not cross-compile well since typelibs include a lot of very-low level
|
||||||
vips_argument_map() and friends to loop over the operation's arguments setting
|
data (such as exact structure layouts), and installation for your users is
|
||||||
them. Once you have set all arguments, use vips_cache_operation_build()
|
likely to be tricky.
|
||||||
to look up the operation in the cache and either build or dup it. If
|
|
||||||
something goes wrong, you'll need to use vips_object_unref_outputs() and
|
If you have a choice, I would recommend simply using FFI.
|
||||||
g_object_unref() to free the partially-built object. The Python binding uses
|
|
||||||
this technique to implement a function which can call any vips operation,
|
# Documentation
|
||||||
turning optional vips arguments into Python keyword arguments.
|
|
||||||
|
|
||||||
You can generate searchable docs from a <code>.gir</code> (the thing that
|
You can generate searchable docs from a <code>.gir</code> (the thing that
|
||||||
is built from scanning libvips and which in turn turn the typelib is
|
is built from scanning libvips and which in turn turn the typelib is
|
||||||
|
Loading…
Reference in New Issue
Block a user