-
Notifications
You must be signed in to change notification settings - Fork 170
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
add c api bindings for lgraph #180
Conversation
f1e4c63
to
69ca7b7
Compare
1c5dc4a
to
9e2c254
Compare
9e2c254
to
1b2638b
Compare
src/c/CMakeLists.txt
Outdated
@@ -0,0 +1,3 @@ | |||
add_library(lgraph-cbindings STATIC c.cpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first thing to remember is that the declaration of lgraph_api is in include
directory, and its definition is in src/lgraph_api
directory.
Logically c-bindings is part of lgraph_api, now the problem is that C API has been added into include
, but its definition is not packed in ${TARGET_LGRAPH}
. Please fix this in BuildLGraphApi.cmake
.
src/c/c.cpp
Outdated
@@ -0,0 +1,2835 @@ | |||
/** | |||
* Copyright 2022 AntGroup CO., Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the implementation directory, it is recommended to rearrange this to src/lgraph_api/c.cpp
.
src/CMakeLists.txt
Outdated
@@ -9,6 +9,7 @@ include(BuildLGraphServer.cmake) | |||
include(BuildCypherLib.cmake) | |||
include(BuildClients.cmake) | |||
include(BuildCythonExtension.cmake) | |||
add_subdirectory(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend merging the cmakelists file of build-c-bindings into BuildLGraphApi.cmake
, since c-bindings should be part of lgraph_api
Now, c biindings are packed into lgraph_api target and src/c/c.cpp is moved to src/lgraph_api/c.cpp. @wangtao9 |
Here are c api bindings for lgraph.
The implementation is really intuitive.
struct lgraph_api_cxx_class_name_t
.lgraph_api_cxx_class_name_t* lgraph_api_cxx_class_name_create(param1, param2, ...)
void lgraph_api_cxx_class_name_destroy(lgraph_api_cxx_class_name_t*)
return_type lgraph_api_cxx_class_name_method_name(param1, param2, ...)
. If there are multiple overloaded variants, there should be likereturn_type lgraph_api_cxx_class_name_method_name_{by, with}_param1(param1, param2, ...)