Rcpp Version 0.9.10
Language.cpp
Go to the documentation of this file.
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
00002 //
00003 // Language.cpp: Rcpp R/C++ interface class library -- Language objects ( calls )
00004 //
00005 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
00006 //
00007 // This file is part of Rcpp.
00008 //
00009 // Rcpp is free software: you can redistribute it and/or modify it
00010 // under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 2 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // Rcpp is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
00021 
00022 #include <Rcpp/Language.h>
00023 
00024 namespace Rcpp {
00025         
00026     Language::Language() : DottedPair() {}
00027         
00028     Language::Language( SEXP x ) : DottedPair(){
00029         setSEXP( r_cast<LANGSXP>(x) ) ;
00030     }
00031         
00032     Language::Language( const Language& other): DottedPair(){
00033         setSEXP( other.asSexp() ) ;
00034     }
00035         
00036     Language& Language::operator=(const Language& other){
00037         setSEXP( other.asSexp() ) ;
00038         return *this ;
00039     }
00040         
00041     Language::Language( const std::string& symbol ): DottedPair() {
00042         setSEXP( Rf_lang1( Symbol(symbol) ) );
00043     }
00044         
00045     Language::Language( const Symbol& symbol ): DottedPair() {
00046         setSEXP( Rf_lang1( symbol ) ) ;
00047     }
00048         
00049     Language::Language( const Function& function): DottedPair() {
00050         setSEXP( Rf_lang1( function ) ) ;               
00051     }
00052         
00053     Language::~Language(){}
00054 
00055     void Language::setSymbol( const std::string& symbol){
00056         setSymbol( Symbol( symbol ) ) ;
00057     }
00058         
00059     void Language::setSymbol( const Symbol& symbol){
00060         SETCAR( m_sexp, symbol ) ;
00061         SET_TAG(m_sexp, R_NilValue);/* probably not necessary */
00062     }
00063         
00064     void Language::setFunction( const Function& function){
00065         SETCAR( m_sexp, function );
00066         SET_TAG(m_sexp, R_NilValue); /* probably not necessary */
00067     }
00068         
00069     void Language::update(){ 
00070         SET_TYPEOF( m_sexp, LANGSXP ) ;
00071         SET_TAG( m_sexp, R_NilValue ) ;
00072     }
00073         
00074     SEXP Language::eval() {
00075         return eval( R_GlobalEnv ) ;
00076     }
00077         
00078     SEXP Language::eval( SEXP env ) {
00079         return internal::try_catch( m_sexp, env );
00080     }
00081         
00082 } // namespace Rcpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Defines