Skip to content

Register function with namespace #262

Description

@nbenn

When registering a function in a namespace such as

[[cpp11::register]] int foo::bar(int a) {
  return a;
}

decor recognizes the function name as foo::bar and all would be fine (as far as I can tell), if the generated extern "C" wrapper

cpp11/R/register.R

Lines 171 to 176 in c22dc9b

{return_type} {name}({real_params});
extern "C" SEXP _{package}_{name}({sexp_params}) {{
BEGIN_CPP11
{calls}
END_CPP11
}}

would not blindly forward the ::. Some further minor adjustments are required for the generation of the R-side functions. For the R-side function name, we could for example strip away anything that comes before the last scope resolution operator.

I started putting something together under main...nbenn:main and I'm happy to clean this up a bit, add some tests and submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions