[sysrepo-devel] C++ bindings for Sysrepo

Mislav Novakovic mislav.novakovic at sartura.hr
Wed Oct 5 16:05:39 UTC 2016


Hi Jan,

I would be happy if you contribute to the code.

The C++ bindings started as a intermediate product for generating better
swig bindings to other languages and that can be visible in the design
philosophy.

At the moment there are some still lose ends with the C++ bindings, I would
like to simplify the swig infrastructure so it would be easier for me to
follow the C++ changes and after that I will redesign the Counter class to
use templates.

The main design goals for me in the C++ bindings are:

1) use shared_ptr so the C++ classes are automatically freed in the swig
language bindings

2) add a #define for every std::shared_ptr class, in some swig languages it
is simpler to use boost library (will be useful later)

3) it would be nice if the C++ API is similar to other language bindings


I agree with you about the Throw_Exception class. For the 'void
*private_ctx' in the callbacks I am open to change.
At the moment only Java bindings use that class and there shouldn't be any
major problem of mapping the C++ changes to Java.

It would be great if you could hide (make them private or protected) the
class methods that return C struct pointer. I will document what needs to
be public for the swig files, maybe I can hide them but I am not sure.

Sorry about the pull request:
https://github.com/sysrepo/sysrepo/pull/367

I had some bug fixes today, came across that bug then fixed it in the
meantime I forgot about your pull request. Next time I will be more careful.

It is definitely great that you want to move this conversation to the
Sysrepo mailing list. I added the Sysrepo devel mailing list to CC.

Best regards,
Mislav Novakovic


On Tue, Oct 4, 2016 at 9:42 PM, Jan Kundrát <jan.kundrat at cesnet.cz> wrote:

> Hi Mislav,
> thanks for your C++ bindings for sysrepo. We're playing with using these
> in an internal project, and I think I'll be able to contribute to them.
> I've got a few questions/comments if you're interested.
>
> I believe that your requirements are OK with C++11 given the use of
> std::shared_ptr.
>
> Is the API that you use set in stone already? Some aspects of it look a
> bit C-ish to me. For example the callbacks all take a `void *private_ctx`
> which is a necessity in C; however, the design already goes with a `class
> Callback` that a user is supposed to subclass anyway so that they have an
> opportunity to pass any data they need, etc. I would like to make this
> easier to use, either by reducing the signatures of these virtual methods,
> or by adding support for the users to pass anything, including functors and
> lambdas as callbacks.
>
> Everything is derived from Throw_Exception. It seems to me that this can
> be replaced by a freestanding function so that the inheritance tree is
> cleaner.
>
> If you don't mind and are open to changes in these C++ bindings, can we
> talk about this on the main sysrepo mailing list? Should I send
> patches/pull requests right away?
>
> With kind regards,
> Jan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sysrepo.org/archives/sysrepo-devel/attachments/20161005/61d07f4b/attachment.html>


More information about the sysrepo-devel mailing list