|
| 1 | +#!/usr/bin/Rscript |
| 2 | +# |
| 3 | +# Generator for inst/include/Rcpp/generated/InternalFunctionWithStdFunction_call.h |
| 4 | +# |
| 5 | +# Copyright (C) 2014 Christian Authmann |
| 6 | + |
| 7 | +fun <- function(i) { |
| 8 | + |
| 9 | + txt <- sprintf( ' |
| 10 | + template <typename RESULT_TYPE%s> |
| 11 | + RESULT_TYPE call(const std::function<RESULT_TYPE(%s)> &fun, SEXP* args) {%s |
| 12 | + return fun(%s); |
| 13 | + } |
| 14 | +', |
| 15 | + if (i == 0) "" else paste0(",", paste(sprintf("typename U%d", (1:i)-1), collapse = ", ")), |
| 16 | + if (i == 0) "" else paste(sprintf("U%d", (1:i)-1), collapse = ","), |
| 17 | + if (i == 0) "" else paste0("\n", paste(sprintf(" typename traits::input_parameter<U%d>::type x%d(args[%d]);", (1:i)-1, (1:i)-1, (1:i)-1 ), collapse = "\n")), |
| 18 | + if (i == 0) "" else paste(sprintf("x%d", (1:i)-1), collapse = ",") |
| 19 | + ) |
| 20 | +} |
| 21 | + |
| 22 | +file <- sprintf( |
| 23 | +'// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- |
| 24 | +// |
| 25 | +// InternalFunctionWithStdFunction_call.h -- generated helper code for |
| 26 | +// InternalFunctionWithStdFunction.h |
| 27 | +// see rcpp-scripts repo for generator script |
| 28 | +// |
| 29 | +// Copyright (C) 2010 - 2014 Dirk Eddelbuettel and Romain Francois |
| 30 | +// |
| 31 | +// This file is part of Rcpp. |
| 32 | +// |
| 33 | +// Rcpp is free software: you can redistribute it and/or modify it |
| 34 | +// under the terms of the GNU General Public License as published by |
| 35 | +// the Free Software Foundation, either version 2 of the License, or |
| 36 | +// (at your option) any later version. |
| 37 | +// |
| 38 | +// Rcpp is distributed in the hope that it will be useful, but |
| 39 | +// WITHOUT ANY WARRANTY; without even the implied warranty of |
| 40 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 41 | +// GNU General Public License for more details. |
| 42 | +// |
| 43 | +// You should have received a copy of the GNU General Public License |
| 44 | +// along with Rcpp. If not, see <http://www.gnu.org/licenses/>. |
| 45 | +
|
| 46 | +#ifndef Rcpp__generated__InternalFunctionWithStdFunction_calls_h |
| 47 | +#define Rcpp__generated__InternalFunctionWithStdFunction_calls_h |
| 48 | +
|
| 49 | +%s |
| 50 | +
|
| 51 | +#endif |
| 52 | +', paste(sapply(0:65, fun), collapse = "\n") |
| 53 | +) |
| 54 | + |
| 55 | +stopifnot(file.exists("inst/include/Rcpp/generated/")) |
| 56 | +writeLines(file, "inst/include/Rcpp/generated/InternalFunctionWithStdFunction_call.h") |
0 commit comments