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
This is because when calling equal, not_equal and assign methods from the namespace chaiscript::bootstrap::operators, the first argument t_module is required to be of type Module, since the first argument of equal etc. is of type Module&:
m.add(chaiscript::fun([](const T &lhs, const T &rhs) { return lhs == rhs; }), "==");
}
I know that one solution is to create a Module instance, use add_class on the Module instance, and then add the Module instance to the ChaiScript instance. However this feels like additional steps that don't seem to be necessary, especially when the add_class variant for non enum types works with the first argument being a ChaiScript reference fine. Since there is a template argument for the first argument, I do feel that there was intention to make it work with a ChaiScript reference, and maybe other types, though as for enum classes it only works with Module.
I think a good fix would be to give to all functions in chaiscript::bootstrap::operators a second template argument for the first parameter, so they can accept any other type than Module, like this:
So when giving M=chaiscript::ChaiScript it should still work as it has the add method, and it will also make add_class work with ChaiScript as first parameter type at the same time. There might be other solutions I don't know, but I think it would be nice if I could just add enums directly to the ChaiScript without having to pass through a Module.
PS: Btw great project! Integrating it to my program was surprisingly very fast, but it does lack a lot of documentation and hasn't been updated very much...
The text was updated successfully, but these errors were encountered:
I want to add an enum class to ChaiScript, for this I use
chaiscript::utility::add_class
.My first attempt is to simply pass a reference to the
chaiscript::ChaiScript
class instance as the first argument, like this:However, in the latest version 6.1, this results to a compile error:
Indeed, if we take a look inside
add_class
:ChaiScript/include/chaiscript/utility/utility.hpp
Lines 85 to 101 in 2898ae6
This is because when calling
equal
,not_equal
andassign
methods from the namespacechaiscript::bootstrap::operators
, the first argumentt_module
is required to be of typeModule
, since the first argument ofequal
etc. is of typeModule&
:ChaiScript/include/chaiscript/dispatchkit/operators.hpp
Lines 83 to 86 in 2898ae6
I know that one solution is to create a
Module
instance, useadd_class
on theModule
instance, and then add theModule
instance to theChaiScript
instance. However this feels like additional steps that don't seem to be necessary, especially when theadd_class
variant for non enum types works with the first argument being aChaiScript
reference fine. Since there is a template argument for the first argument, I do feel that there was intention to make it work with aChaiScript
reference, and maybe other types, though as for enum classes it only works withModule
.I think a good fix would be to give to all functions in
chaiscript::bootstrap::operators
a second template argument for the first parameter, so they can accept any other type thanModule
, like this:So when giving M=
chaiscript::ChaiScript
it should still work as it has theadd
method, and it will also makeadd_class
work withChaiScript
as first parameter type at the same time. There might be other solutions I don't know, but I think it would be nice if I could just add enums directly to theChaiScript
without having to pass through aModule
.PS: Btw great project! Integrating it to my program was surprisingly very fast, but it does lack a lot of documentation and hasn't been updated very much...
The text was updated successfully, but these errors were encountered: