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

plugins registering wrong datatype for boolean params #48

Closed
rrrapha opened this issue Sep 6, 2018 · 1 comment
Closed

plugins registering wrong datatype for boolean params #48

rrrapha opened this issue Sep 6, 2018 · 1 comment

Comments

@rrrapha
Copy link
Contributor

rrrapha commented Sep 6, 2018

For example, tutorial.cpp has this code:

public:
    Tutorial(unsigned int width, unsigned int height)
    {
        register_param(m_barSize, "barSize", "Size of the black bar");
        register_param(m_pointerMethod, "pointerMethod", "Pointer Method (internal)");
...

private:
    f0r_param_double m_barSize;
    f0r_param_bool m_pointerMethod;
...

Because f0r_param_bool is of type 'double', the wrong register_param function is called for m_pointerMethod.

I see two ways of fixing this without breaking external API/ABI compatibility.

  1. change the param datatypes in tutorial.cpp:
    f0r_param_double m_barSize;
    bool m_pointerMethod;
  1. change the register_param function (in frei0r.hpp) to something like this:
    void register_param(f0r_param_t p_loc,
                        int type,
                        const std::string& name,
                        const std::string& desc)
    {
      param_ptrs.push_back(p_loc);
      s_params.push_back(param_info(name,desc,type));
    }

and change the calls in tutorial.cpp:

    register_param(&m_barSize, F0R_PARAM_DOUBLE, "barSize", "Size of the black bar");
    register_param(&m_pointerMethod, F0R_PARAM_BOOL, "pointerMethod", "Pointer Method (internal)");

I prefer the second version because most plugins already use f0r_param_bool for the boolean params and the calls to register_param could be changed mechanically.

@rrrapha
Copy link
Contributor Author

rrrapha commented Sep 6, 2018

After thinking about it some more, I now prefer the first version.
It seems better to just use bool instead of f0r_param_bool in the c++ plugins.

rrrapha added a commit to rrrapha/frei0r that referenced this issue Sep 6, 2018
ddennedy pushed a commit that referenced this issue Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant