diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/arrow/r/inst/include/cpp11/declarations.hpp | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/arrow/r/inst/include/cpp11/declarations.hpp')
-rw-r--r-- | src/arrow/r/inst/include/cpp11/declarations.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/arrow/r/inst/include/cpp11/declarations.hpp b/src/arrow/r/inst/include/cpp11/declarations.hpp new file mode 100644 index 000000000..c67c9db1b --- /dev/null +++ b/src/arrow/r/inst/include/cpp11/declarations.hpp @@ -0,0 +1,54 @@ +// cpp11 version: 0.3.1.1 +// vendored on: 2021-08-11 +#pragma once + +#include <cstring> +#include <string> +#include <vector> + +#ifndef CPP11_PARTIAL +#include "cpp11.hpp" +using namespace cpp11; +namespace writable = cpp11::writable; +#endif + +#include <R_ext/Rdynload.h> + +namespace cpp11 { +template <class T> +T& unmove(T&& t) { + return t; +} +} // namespace cpp11 + +#ifdef HAS_UNWIND_PROTECT +#define CPP11_UNWIND R_ContinueUnwind(err); +#else +#define CPP11_UNWIND \ + do { \ + } while (false); +#endif + +#define CPP11_ERROR_BUFSIZE 8192 + +#define BEGIN_CPP11 \ + SEXP err = R_NilValue; \ + char buf[CPP11_ERROR_BUFSIZE] = ""; \ + try { +#define END_CPP11 \ + } \ + catch (cpp11::unwind_exception & e) { \ + err = e.token; \ + } \ + catch (std::exception & e) { \ + strncpy(buf, e.what(), sizeof(buf) - 1); \ + } \ + catch (...) { \ + strncpy(buf, "C++ error (unknown cause)", sizeof(buf) - 1); \ + } \ + if (buf[0] != '\0') { \ + Rf_errorcall(R_NilValue, "%s", buf); \ + } else if (err != R_NilValue) { \ + CPP11_UNWIND \ + } \ + return R_NilValue; |