-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design and document a stable C API #61
Comments
YES! I need to do this! Definitely! But right now I invite you to look into the main launcher https://github.com/ku-nlp/jumanpp/blob/master/src/jumandic/main/jumanpp.cc |
Yes that's good starting point, though currently as I'm on windows I cannot use jumanpp. Though it gave me idea to write some cross-platform mmap for C++ |
Yes, if you can work on that it should be wonderful. There are 3 pieces of unix api I use, |
The other thing is, on Windows, filesystem access should use W versions of API (and convert paths from/to utf-8). |
@DoumanAsh @kou what do you think. |
@eiennohito Should it be then just API in general? After all there will be also C++ API? 🤔 |
C++ API won't have stability guarantees (I will try not to break it much though) and won't support dynamic linking/systemwide installation as a library (basically, the current status-quo). |
Ah that's understandable of course. I guess the first thing we'd need to try to take a look at existing public API and see how it is to be used. I've somewhat busy lately but I'll try to take a look at existing API later on and give some inputs/suggestion on it. |
I'm a bit confused. |
Yes, C API will support consuming Juman++ as a dynamic object. I plan to build it with a bit different set of compile flags. In theory it is possible to build even the current version Juman++ with The second problem is symbol visibility. We don't want to export our version of Eigen and fmtlib to outside world, because that would confuse other software using their own version of Eigen. On Unixes we should use C API library will cleanly solve these problems by providing a single shared object with only C API marked as visible and all C++ state contained inside that object. |
Thanks. I understand what you explain. |
I'll try creating a C API and send feedback to Juman++ in a few months. |
I maybe start doing that earlier, but I'll post here when I will begin doing it. |
Nothing about C API yet, but I am writing a small tutorial on "How to use Juman++ to create your own morphological analyzers". |
Sorry. I couldn't work on this this year... |
For Juman++ to be widely usable, we want to have a documented and stable C API and an option to have a dynamically linked library.
That library probably should use
-fvisibility=hidden
and explicit visibility on exported symbols on Unixes and__declspec(dllimport/dllexport)
on Windows.The minimal API should be:
Additional things (low priority):
There should not be any exceptions passing that API boundary because of C.
One problem remains: what to do with strings.
Dictionary strings in Juman++ are never zero terminated (they are length prefixed). Probably the API should provide non-zero terminated strings by default (exposing some StringPiece-like C struct) and an easy way to convert such strings to zero-terminated ones.
The text was updated successfully, but these errors were encountered: