[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] libvirt boolean type



Hi.

The following patch's intend is to get a discussion started first.

Rationale:

Many functions in libvirt return "1 for <TRUE>, 0 for <FALSE> and -1
on <ERROR>".

When calling a function you need to read the documentation, skipping
to the "Returns:" text in order to determine what return values to
expect from the function and how to interpret them.

This is cumbersome and takes an extra step which could be avoided.

Advantages:

+ enum is binary compatible with int, so no ABI changes

+ without reading the documentation, you see what return values to expect
  at a glance

+ code generators in higher level languages could use it to generate proper
  wrappings to "boolean" automatically

+ compilers can probably warn when returning a value not part of the enum

Claudio Bley (1):
  Implement a virBool type

 include/libvirt/libvirt.h.in |   25 +++++++++++++++++++++----
 python/generator.py          |   16 ++++++++++++++++
 src/libvirt.c                |    8 ++++----
 3 files changed, 41 insertions(+), 8 deletions(-)

-- 
1.7.9.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]