Skip to content
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

Misleading documentation on Block::registerCallable #128

Open
ashley-b opened this issue Sep 19, 2017 · 3 comments
Open

Misleading documentation on Block::registerCallable #128

ashley-b opened this issue Sep 19, 2017 · 3 comments

Comments

@ashley-b
Copy link
Contributor

ashley-b commented Sep 19, 2017

I notice when I call Block::registerCallable on a method that has no arguments it does not register a slot for it.
I also noticed when I delved into the implementation that names that are prefix with underscore are treated as private and are not registered also. This should probable be mention in the docs

The doxygen for this method

/*!
* Export a function call on this block to set/get parameters.
* This call will automatically register a slot of the same name.
* \param name the name of the callable
* \param call the bound callable method
*/
void registerCallable(const std::string &name, const Callable &call);

@guruofquality
Copy link
Contributor

I notice when I call Block::registerCallable on a method that has no arguments it does not register a slot for it.

Good catch, I noticed this too when I added clearChannels() to the plotters. And it was funny because I kind of expected argument-less calls to automatically become slots, its seemed intuitive.

But I didn't do that.... probably because I didnt want to register getters that return values. But calls that return void and have no arguments are not gettings, so that should probably the the determination, and not the number of args.

For reference

//automatic registration of slots for calls that take arguments and are not "private"
    const bool isPrivate = name.front() == '_';
    if (call.getNumArgs() > 0 and not isPrivate and _namedInputs.count(name) == 0) this->registerSlot(name);

@guruofquality
Copy link
Contributor

Update: on master branch the codebase now uses the return type being void to register automatic slots. To facilitate the change -- its not an error throwing condition to call "registerSlot" for a call that was automatically registered.

No changes to the the private underscore rule. I found one place that used it, and it was the python block. I think this rule is probably unnecessary, although we may want a way to register a void return call and not make it a slot in the C++ API. So leaving this open for the time being.

@ashley-b
Copy link
Contributor Author

ashley-b commented Oct 2, 2017

Great, looks good. I just recompiled my block against the master and it seams all good. The void return slot gets registered with out registerSlot now and has no errors if I leave registerSlot in.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants