Skip to content

Commit

Permalink
use standard constructor for grid units from C++
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Feb 21, 2020
1 parent 5cc4b40 commit 1fe736a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/grid.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#include "grid.h"

NumericVector unit_pt(NumericVector x) {
NumericVector out(x);
out.attr("class") = "unit";
out.attr("valid.unit") = IntegerVector(1, 8);
out.attr("unit") = "pt";

return out;
//NumericVector out(x);
//out.attr("class") = "unit";
//out.attr("valid.unit") = IntegerVector(1, 8);
//out.attr("unit") = "pt";

// create unit vector by calling back to R
Environment env = Environment::namespace_env("grid");
Function unit = env["unit"];
return unit(x, "pt");
}

NumericVector unit_pt(Length x) {
NumericVector out(1, x);
out.attr("class") = "unit";
out.attr("valid.unit") = IntegerVector(1, 8);
out.attr("unit") = "pt";
//out.attr("class") = "unit";
//out.attr("valid.unit") = IntegerVector(1, 8);
//out.attr("unit") = "pt";
//return out;

return out;
return unit_pt(out);
}

List gpar_empty() {
Expand Down

0 comments on commit 1fe736a

Please sign in to comment.