Rcpp Version 1.0.14
Loading...
Searching...
No Matches
xp.h
Go to the documentation of this file.
1// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2//
3// xp.h: Rcpp R/C++ interface class library -- pre processor help
4//
5// Copyright (C) 2012 - 2015 Dirk Eddelbuettel and Romain Francois
6//
7// This file is part of Rcpp.
8//
9// Rcpp is free software: you can redistribute it and/or modify it
10// under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 2 of the License, or
12// (at your option) any later version.
13//
14// Rcpp is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
21
22#ifndef Rcpp__macros_xp_h
23#define Rcpp__macros_xp_h
24
25#define RCPP_XP_FIELD_GET(__NAME__,__CLASS__,__FIELD__) \
26extern "C" SEXP RCPP_PP_CAT(__NAME__,__rcpp_info__)(){ \
27 using Rcpp::_ ; \
28 Rcpp::List info = Rcpp::List::create( \
29 _["class"] = #__CLASS__ , \
30 _["field"] = #__FIELD__ \
31 ) ; \
32 info.attr( "class" ) = "rcppxpfieldgetinfo" ; \
33 return info ; \
34} \
35extern "C" SEXP __NAME__( SEXP xp ){ \
36 BEGIN_RCPP \
37 SEXP res = R_NilValue ; \
38 ::Rcpp::XPtr< __CLASS__ > ptr(xp) ; \
39 res = ::Rcpp::wrap( ptr->__FIELD__ ) ; \
40 return res ; \
41 END_RCPP \
42}
43
44#define RCPP_XP_FIELD_SET(__NAME__,__CLASS__,__FIELD__) \
45extern "C" SEXP RCPP_PP_CAT(__NAME__,__rcpp_info__)(){ \
46 using Rcpp::_ ; \
47 Rcpp::List info = Rcpp::List::create( \
48 _["class"] = #__CLASS__ , \
49 _["field"] = #__FIELD__ \
50 ) ; \
51 info.attr( "class" ) = "rcppxpfieldsetinfo" ; \
52 return info ; \
53} \
54extern "C" SEXP __NAME__( SEXP xp, SEXP value ){ \
55 BEGIN_RCPP \
56 ::Rcpp::XPtr< __CLASS__ > ptr(xp) ; \
57 ptr->__FIELD__ = ::Rcpp::internal::converter(value) ; \
58 END_RCPP \
59}
60
61#define RCPP_XP_FIELD(__PREFIX__,__CLASS__,__FIELD__) \
62RCPP_XP_FIELD_GET( RCPP_PP_CAT(__PREFIX__,_get), __CLASS__, __FIELD__ ) \
63RCPP_XP_FIELD_SET( RCPP_PP_CAT(__PREFIX__,_set), __CLASS__, __FIELD__ )
64
65#endif