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

Port from modules to RcppR6 #86

Closed
richfitz opened this issue Aug 19, 2014 · 4 comments
Closed

Port from modules to RcppR6 #86

richfitz opened this issue Aug 19, 2014 · 4 comments
Assignees

Comments

@richfitz
Copy link
Member

Motivation for this is to avoid the long load time, allow using devtools, and allow templated plant types. This will also remove the virtual functions/inheritence in the low-level things, which will clean things up a little.

RcppR6 looks about ready: the main thing required will be default arguments as the current implementation does not support these, and will never support multiple constructors. Converting things will take a little while though. Here's an example (untested) switching the Interpolator class:

  Rcpp::class_<interpolator::Interpolator>("Interpolator")
    .constructor()
    .constructor<bool,bool>()
    .property("type",     &interpolator::Interpolator::type)
    .method("init",       &interpolator::Interpolator::init)
    .method("eval",       &interpolator::Interpolator::r_eval)
    .method("deriv",      &interpolator::Interpolator::r_deriv)
    .property("x",        &interpolator::Interpolator::get_x)
    .property("y",        &interpolator::Interpolator::get_y)
    .property("xy",       &interpolator::Interpolator::r_get_xy)
    .property("size",     &interpolator::Interpolator::size)
    .property("min",      &interpolator::Interpolator::min)
    .property("max",      &interpolator::Interpolator::max)
    ;
Interpolator:
  roxygen: @export
  name_cpp: interpolator::Interpolator
  constructor:
    # Need defaults to make this work nicely:
    args: [is_akima: bool=TRUE, is_linear: bool=TRUE]
  methods:
    init:
      args: [x: "const std::vector<double>&", 
        y: "const std::vector<double>&"]
      return_type: void
    eval: 
      name_cpp: r_eval
      args: [x: "std::vector<double>"]
      return_type: "std::vector<double>"
    deriv:
      name_cpp: r_deriv
      args: [x: "std::vector<double>"]
      return_type: "std::vector<double>"
  active:
    type: {type: std::string, access: method}
    x: {type: "std::vector<double>", access: member, name_cpp: get_x}
    y: {type: "std::vector<double>", access: member, name_cpp: get_y}
    xy: {type: "Rcpp::NumericMatrix", type: member, name_cpp: get_xy}
    size: {type: size_t, access: member}
    min: {type: double, access: member}
    max: {type: double, access: member}
@richfitz
Copy link
Member Author

OK, support for default parameter values added as of richfitz/RcppR6@152ab52

@richfitz
Copy link
Member Author

Won't happen before review. Perhaps late November/December?

@richfitz
Copy link
Member Author

I'm seeing lines in the knitr output like

Quitting from lines 26-29 (equilibrium.Rmd) 
Error in (function (x)  : attempt to apply non-function

as the modules code gets grumpy. I accidentally managed to trigger recover on this error yesterday, and it looks like it's got to do with finalisers on classes that use inheritance, perhaps (though I see it on forest without that).

@richfitz
Copy link
Member Author

OK, the modules bug now always triggers with options(error=recover), which is more than a little annoying as when it turns up it bails with a bunch of errors that you have to skip past.

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