These are chat archives for ChaiScript/ChaiScript

Dec 2015
Sandu Liviu Catalin
Dec 26 2015 12:25

Is there a way of receiving a function from the script without knowing it's declaration at compile time? I mean, to receive them without using std::function which requires their declaration to be known at compile time.

I need to store multiple type of functions with different argument types. The other solution would be to have a generic std::function< void(Boxed_Value &) > and pack all arguments in a map or something.

Jason Turner
Dec 26 2015 15:30
@iSLC the question is: do you need to be able to call the function from C++, or just store it then pass it back into chaiscript land at some point?
Sandu Liviu Catalin
Dec 26 2015 23:18

I need to be able to call it. But if possible to cast it to the correct syntax in one of the member methods of the class that's forwarding the call. The class it's more like a wrapper which is a slot that receives events from a signal. And there's about 100+ types of events and having to create the class templated and register the class for each even type really ads to my executable size.

So far I've went with the generic declaration. And even dropped the (Boxed_Value &) argument. I'll create some global functions that retrieve current event information only if necessary. For my current situation this could work even better because not all arguments are be used uppon call in the event receivers. So I get a bit of a performance boost and trim down the executable size.