libvirt boolean type

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

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]