You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to bind the tree-sitter library to Lua.
I have already used sol2 to bind ImGui, ImNodes, some GLFW and custom functions of my own. These work nicely. I can pass-in or return pointers with ImGui/ImNodes/GLFW/etc without problem.
However, when I tried to bind tree-sitter functions, all functions that return a pointer to a struct (ei. TSRange *, TSTree *, etc) do not work. I have pasted the monstrous error message it gives me below.
Tree-sitter is a C library if that matters.
I can avoid the problem by writing a wrapper on the function I want to pass and casting the return pointer to void* (ei. return (void*)result; )
Then, for any function that takes a pointer as input, I can make another wrapper which takes (void *) and casts it to the proper type.
This compiles (although I have not tried running the code) and seems like a functional way to create the binding.
However, that solution is tiresome to write and looks really inelegant.
What makes these tree-sitter function different than other functions that returns pointers?
In file included from /usr/include/c++/9/bits/move.h:55,
from /usr/include/c++/9/bits/nested_exception.h:40,
from /usr/include/c++/9/exception:144,
from /usr/include/c++/9/stdexcept:38,
from /usr/include/c++/9/system_error:41,
from /usr/include/c++/9/bits/fs_fwd.h:35,
from /usr/include/c++/9/filesystem:36,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/main.cpp:3:
/usr/include/c++/9/type_traits: In instantiation of ‘constexpr const bool std::is_base_of_v<sol::stack_reference, TSTree>’:
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:857:113: required from ‘struct sol::is_lua_reference<TSTree>’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:860:24: required from ‘constexpr const bool sol::is_lua_reference_v<TSTree>’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:889:187: required from ‘struct sol::is_container<TSTree>’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:893:24: required from ‘constexpr const bool sol::is_container_v<TSTree>’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/usertype_container_launch.hpp:409:49: required by substitution of ‘template<class T> struct sol::stack::unqualified_pusher<T*, typename std::enable_if<is_container_v<T>, void>::type> [with T = TSTree]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:904:28: [ skipping 27 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:439:5: required from ‘sol::basic_table_core<<anonymous>, <template-parameter-1-2> >& sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set(Args&& ...) [with Args = {std::tuple<const char (&)[15]>, sol::function_arguments<sol::function_sig<>, main(int, char**)::<lambda(void*)>&>}; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:630:4: required from ‘void sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set_fx(sol::types<>, Key&&, Fx&&, Args&& ...) [with Fx = main(int, char**)::<lambda(void*)>&; Key = std::tuple<const char (&)[15]>; Args = {}; typename std::enable_if<std::integral_constant<bool, (! sol::meta::all<sol::meta::meta_detail::is_specialization_of<typename std::remove_cv<typename std::remove_cv<typename std::remove_reference<_SrcTuple>::type>::type>::type, sol::overload_set> >::value)>::value, sol::meta::enable_t>::type <anonymous> = sol::meta::enable_t::_; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:603:4: required from ‘sol::basic_table_core<<anonymous>, <template-parameter-1-2> >& sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set_function(Key&&, Args&& ...) [with Key = std::tuple<const char (&)[15]>; Args = {main(int, char**)::<lambda(void*)>&}; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_proxy.hpp:100:4: required from ‘sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >&& sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >::set_function(Args&& ...) && [with Args = {main(int, char**)::<lambda(void*)>&}; Table = sol::basic_table_core<true, sol::basic_reference<false> >&; Key = std::tuple<const char (&)[15]>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_proxy.hpp:119:64: required from ‘sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >&& sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(T&&) && [with T = main(int, char**)::<lambda(void*)>&; Table = sol::basic_table_core<true, sol::basic_reference<false> >&; Key = std::tuple<const char (&)[15]>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/main.cpp:1332:28: required from here
/usr/include/c++/9/type_traits:2991:25: error: ‘value’ is not a member of ‘std::is_base_of<sol::stack_reference, TSTree>’
2991 | inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
| ^~~~~~~~~~~~
In file included from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/trampoline.hpp:27,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack.hpp:27,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/sol.hpp:51,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/main.cpp:31:
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp: In instantiation of ‘constexpr const bool sol::is_lua_reference_v<TSTree>’:
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:889:187: required from ‘struct sol::is_container<TSTree>’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:893:24: required from ‘constexpr const bool sol::is_container_v<TSTree>’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/usertype_container_launch.hpp:409:49: required by substitution of ‘template<class T> struct sol::stack::unqualified_pusher<T*, typename std::enable_if<is_container_v<T>, void>::type> [with T = TSTree]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:904:28: required from ‘int sol::stack::push(lua_State*, T&&, Args&& ...) [with T = TSTree*; Args = {}; lua_State = lua_State]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:957:27: required from ‘int sol::stack::stack_detail::push_reference(lua_State*, Arg&&, Args&& ...) [with T = TSTree*; Arg = TSTree*; Args = {}; lua_State = lua_State]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:964:42: [ skipping 25 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:439:5: required from ‘sol::basic_table_core<<anonymous>, <template-parameter-1-2> >& sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set(Args&& ...) [with Args = {std::tuple<const char (&)[15]>, sol::function_arguments<sol::function_sig<>, main(int, char**)::<lambda(void*)>&>}; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:630:4: required from ‘void sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set_fx(sol::types<>, Key&&, Fx&&, Args&& ...) [with Fx = main(int, char**)::<lambda(void*)>&; Key = std::tuple<const char (&)[15]>; Args = {}; typename std::enable_if<std::integral_constant<bool, (! sol::meta::all<sol::meta::meta_detail::is_specialization_of<typename std::remove_cv<typename std::remove_cv<typename std::remove_reference<_SrcTuple>::type>::type>::type, sol::overload_set> >::value)>::value, sol::meta::enable_t>::type <anonymous> = sol::meta::enable_t::_; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:603:4: required from ‘sol::basic_table_core<<anonymous>, <template-parameter-1-2> >& sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set_function(Key&&, Args&& ...) [with Key = std::tuple<const char (&)[15]>; Args = {main(int, char**)::<lambda(void*)>&}; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_proxy.hpp:100:4: required from ‘sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >&& sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >::set_function(Args&& ...) && [with Args = {main(int, char**)::<lambda(void*)>&}; Table = sol::basic_table_core<true, sol::basic_reference<false> >&; Key = std::tuple<const char (&)[15]>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_proxy.hpp:119:64: required from ‘sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >&& sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(T&&) && [with T = main(int, char**)::<lambda(void*)>&; Table = sol::basic_table_core<true, sol::basic_reference<false> >&; Key = std::tuple<const char (&)[15]>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/main.cpp:1332:28: required from here
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:860:24: error: ‘value’ is not a member of ‘sol::is_lua_reference<TSTree>’
860 | inline constexpr bool is_lua_reference_v = is_lua_reference<T>::value;
| ^~~~~~~~~~~~~~~~~~
In file included from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/trampoline.hpp:27,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack.hpp:27,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/sol.hpp:51,
from /media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/main.cpp:31:
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp: In instantiation of ‘constexpr const bool sol::is_container_v<TSTree>’:
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/usertype_container_launch.hpp:409:49: required by substitution of ‘template<class T> struct sol::stack::unqualified_pusher<T*, typename std::enable_if<is_container_v<T>, void>::type> [with T = TSTree]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:904:28: required from ‘int sol::stack::push(lua_State*, T&&, Args&& ...) [with T = TSTree*; Args = {}; lua_State = lua_State]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:957:27: required from ‘int sol::stack::stack_detail::push_reference(lua_State*, Arg&&, Args&& ...) [with T = TSTree*; Arg = TSTree*; Args = {}; lua_State = lua_State]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack_core.hpp:964:42: required from ‘int sol::stack::push_reference(lua_State*, T&&, Args&& ...) [with T = TSTree*; Args = {}; lua_State = lua_State]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/stack.hpp:248:26: required from ‘int sol::stack::call_into_lua(sol::types<R, Args ...>, sol::types<Args ...>, lua_State*, int, Fx&&, FxArgs&& ...) [with bool check_args = true; bool clean_stack = true; Ret0 = TSTree*; Ret = {}; Args = {void*}; Fx = sol::wrapper<TSTree* (*)(void*), void>::caller; FxArgs = {TSTree* (*&)(void*)}; lua_State = lua_State]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/call.hpp:363:56: [ skipping 23 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:439:5: required from ‘sol::basic_table_core<<anonymous>, <template-parameter-1-2> >& sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set(Args&& ...) [with Args = {std::tuple<const char (&)[15]>, sol::function_arguments<sol::function_sig<>, main(int, char**)::<lambda(void*)>&>}; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:630:4: required from ‘void sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set_fx(sol::types<>, Key&&, Fx&&, Args&& ...) [with Fx = main(int, char**)::<lambda(void*)>&; Key = std::tuple<const char (&)[15]>; Args = {}; typename std::enable_if<std::integral_constant<bool, (! sol::meta::all<sol::meta::meta_detail::is_specialization_of<typename std::remove_cv<typename std::remove_cv<typename std::remove_reference<_SrcTuple>::type>::type>::type, sol::overload_set> >::value)>::value, sol::meta::enable_t>::type <anonymous> = sol::meta::enable_t::_; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_core.hpp:603:4: required from ‘sol::basic_table_core<<anonymous>, <template-parameter-1-2> >& sol::basic_table_core<<anonymous>, <template-parameter-1-2> >::set_function(Key&&, Args&& ...) [with Key = std::tuple<const char (&)[15]>; Args = {main(int, char**)::<lambda(void*)>&}; bool top_level = true; ref_t = sol::basic_reference<false>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_proxy.hpp:100:4: required from ‘sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >&& sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >::set_function(Args&& ...) && [with Args = {main(int, char**)::<lambda(void*)>&}; Table = sol::basic_table_core<true, sol::basic_reference<false> >&; Key = std::tuple<const char (&)[15]>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/table_proxy.hpp:119:64: required from ‘sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >&& sol::table_proxy< <template-parameter-1-1>, <template-parameter-1-2> >::operator=(T&&) && [with T = main(int, char**)::<lambda(void*)>&; Table = sol::basic_table_core<true, sol::basic_reference<false> >&; Key = std::tuple<const char (&)[15]>]’
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/main.cpp:1332:28: required from here
/media/sdb1/Workspace/DESK/Own_projects_atom/imgui-in-c/editor_attempt_with_tree_sitter/include/sol/types.hpp:893:24: error: ‘value’ is not a member of ‘sol::is_container<TSTree>’
893 | constexpr inline bool is_container_v = is_container<T>::value;
The text was updated successfully, but these errors were encountered:
I am trying to bind the tree-sitter library to Lua.
I have already used sol2 to bind ImGui, ImNodes, some GLFW and custom functions of my own. These work nicely. I can pass-in or return pointers with ImGui/ImNodes/GLFW/etc without problem.
However, when I tried to bind tree-sitter functions, all functions that return a pointer to a struct (ei. TSRange *, TSTree *, etc) do not work. I have pasted the monstrous error message it gives me below.
Tree-sitter is a C library if that matters.
I can avoid the problem by writing a wrapper on the function I want to pass and casting the return pointer to void* (ei.
return (void*)result;
)Then, for any function that takes a pointer as input, I can make another wrapper which takes (void *) and casts it to the proper type.
This compiles (although I have not tried running the code) and seems like a functional way to create the binding.
However, that solution is tiresome to write and looks really inelegant.
What makes these tree-sitter function different than other functions that returns pointers?
The text was updated successfully, but these errors were encountered: