These are chat archives for ChaiScript/ChaiScript

7th
Dec 2016
Jason Turner
@lefticus
Dec 07 2016 05:23
@StanEpp committed a fix. The code was fine
M00NLight
@Puti_ZL_twitter
Dec 07 2016 10:23
Hi all, How to add a function with variable params?
like this uint64_t chai_call(uint64_t address, uint16_t cnt, ...)
StanEpp
@StanEpp
Dec 07 2016 11:32

@Puti_ZL_twitter Hi! The number of your parameters will be determined at compile time. Registering a variadic template function would mean that determining the number of parameters must be postponed until the execution of your script. I don't see any way how to achieve this. What you can do is to register specific versions of chai_call. You can make use of a variadic function to register all you versions of chai_call. I have a similar situation in my project. You can do it in the following way:

template<class... TArgs>
void register_Chai_Call() {
  // ......
  m_chaiDefModule->add(chaiscript::fun(&chai_call<TArgs...>),  "chai_call");
  // ......
}

Of course you need to register every version of your chai_call function which you want to use in your script.

StanEpp
@StanEpp
Dec 07 2016 11:51
@lefticus Great! No more pages of Warnings. :D Though there are still two warnings which the compiler throws:
C4503 "chaiscript::dispatch::detail::call_func" : decorated name length exceeded, name was truncated
proxy_functions_detail.hpp(123): warning C4702 : unreachable code
AFAIK the former warning is no problem when no linker errors occur due to the truncated name. The latter warning seems to be a bug since you are already surpressing the warning at that point.
Jason Turner
@lefticus
Dec 07 2016 14:35
@StanEpp yeah, I even have a comment that says "msvc is wrong and it won't let me suppress the warning" or something
StanEpp
@StanEpp
Dec 07 2016 15:38
@lefticus Exactly