lenmus / lomse

A C++ library for rendering, editing and playing back music scores.
MIT License
117 stars 28 forks source link

Implement C wrappers #359

Open azmeuk opened 2 years ago

azmeuk commented 2 years ago

I would like to use lomse in a GTK C program. I could implement C wrappers for lomse in my application, but maybe it would be better to implement them directly in lomse so other people could use them. What do you think?

cecilios commented 2 years ago

Thanks for your proposal.

IMO it is always better to keep the wrapper separate from your application, so that other people could benefit from it and contribute. I have no experience in writing C wrappers but it will be necessary to define a C API for Lomse and there could be problems with smart pointers, std strings or other, as well as with exceptions. Perhaps it will be necessary to remove exceptions from Lomse or to create in the C wrapper an additional layer of C++ that handles exceptions.

I like the idea and will try to help with any convenient changes in Lomse. The C wrapper is also an opportunity to improve the C++ API and will help to define public and private lomse headers.

I would start the C wrapper in a separate repo (either in your account, in Lenmus account or in any other place, I don't mind), to gain experience and knowledge about its viability, the C API, the required changes in Lomse, etc. And once we are sure, we could decide if it should be integrated in Lomse repo or maintained as a separate repo. A naive question: Any gain in merging in Lomse repo? I only see an increment in Lomse sources without any gain for people don't using the C wrapper, but as said, I have no experience on this.

azmeuk commented 2 years ago

Thank you for your answer. I might give a try depending on how much time I can spend on this.

Any gain in merging in Lomse repo?

It would ensure that the C wrappers would fit the C++ API. A separate project could be outdated if the C++ API changes.

cecilios commented 2 years ago

I might give a try depending on how much time I can spend on this.

Time is always the problem! ;)

A separate project could be outdated if the C++ API changes.

Depends on how repos are related and on automated test before merging Lomse PRs. Let me think on this.

andre2007 commented 1 year ago

Providing a C wrapper would be fantastic. I would like to use Lomse within a project developed in the D Programming Language. By providing a C wrapper you would open the door to almost any programming language.

cecilios commented 1 year ago

By providing a C wrapper you would open the door to almost any programming language

Probably, but first there must be team of contributors to develop and maintain the project. I can not do more alone. Feel free to contribute to develop the C wrapper or to do any other task.

andre2007 commented 1 year ago

Thanks for the info. My C knowledge is quite limited and my C++ knowledge is even worse. I just did a Google search and it seems SWIG is maybe able to automatically generate the C wrapper code.

cecilios commented 1 year ago

Thank you for the info. I know nothing about SWIG and probably could be of help. But for sure implementing a C wrapper, even using SWIG, will require an amount of work that, currently, I can not afford. Think that, even having good knowledge of SWIG (and it this is not the case), just testing the Lomse C wrapper and writing automated tests and documentation will be a lot work.