[Rprotobuf-commits] r532 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 13 03:20:04 CEST 2013
Author: murray
Date: 2013-09-13 03:20:02 +0200 (Fri, 13 Sep 2013)
New Revision: 532
Added:
pkg/src/RcppMacros.h
Modified:
pkg/src/mutators.cpp
pkg/src/rprotobuf.cpp
pkg/src/wrapper_ArrayInputStream.cpp
pkg/src/wrapper_ArrayOutputStream.cpp
pkg/src/wrapper_Descriptor.cpp
pkg/src/wrapper_EnumDescriptor.cpp
pkg/src/wrapper_EnumValueDescriptor.cpp
pkg/src/wrapper_FieldDescriptor.cpp
pkg/src/wrapper_FileDescriptor.cpp
pkg/src/wrapper_Message.cpp
pkg/src/wrapper_MethodDescriptor.cpp
pkg/src/wrapper_ServiceDescriptor.cpp
Log:
Introduce simplified RPB_FUNCTION.* macros and update all instances of
the deprecated RCPP_FUNCTION.* macros to use the new ones.
We can still move to Rcpp Modules, but this at least lets us work with
out all the deprecation warnings.
Added: pkg/src/RcppMacros.h
===================================================================
--- pkg/src/RcppMacros.h (rev 0)
+++ pkg/src/RcppMacros.h 2013-09-13 01:20:02 UTC (rev 532)
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2013 Google Inc. All Rights Reserved.
+ * Author: Murray Stokely
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+/*
+ * This file contains macros for taking C++ functions that expect
+ * native C++ types, automatically generating new stub functions that
+ * take SEXPs and call the appropriate Rcpp conversion functions
+ * before calling the original function. It is based on slightly more
+ * complex macros that were originally in Rcpp but have been
+ * deprecated.
+ *
+ * In the future, Rcpp Modules would likely be a better more modern
+ * way to implement RProtoBuf.
+ */
+
+#ifndef RPROTOBUF_RCPP_MACROS_H
+#define RPROTOBUF_RCPP_MACROS_H
+
+#include <Rcpp/macros/macros.h> // RCPP_DECORATE, BEGIN_RCPP, END_RCPP
+
+#define RPB_FUNCTION_0(__OUT__,__NAME__) \
+__OUT__ RCPP_DECORATE(__NAME__)(); \
+extern "C" SEXP __NAME__(){ \
+SEXP res = R_NilValue ; \
+BEGIN_RCPP \
+res = ::Rcpp::wrap( RCPP_DECORATE(__NAME__)() ) ; \
+return res ; \
+END_RCPP \
+} \
+__OUT__ RCPP_DECORATE(__NAME__)()
+
+#define RPB_FUNCTION_1(__OUT__,__NAME__, ___0) \
+__OUT__ RCPP_DECORATE(__NAME__)(___0); \
+extern "C" SEXP __NAME__(SEXP x0){ \
+SEXP res = R_NilValue ; \
+BEGIN_RCPP \
+res = ::Rcpp::wrap( RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 )) ) ; \
+return res ; \
+END_RCPP \
+} \
+__OUT__ RCPP_DECORATE(__NAME__)(___0)
+
+#define RPB_FUNCTION_2(__OUT__,__NAME__, ___0, ___1) \
+__OUT__ RCPP_DECORATE(__NAME__)(___0, ___1); \
+extern "C" SEXP __NAME__(SEXP x0, SEXP x1){ \
+SEXP res = R_NilValue ; \
+BEGIN_RCPP \
+res = ::Rcpp::wrap( RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 ), ::Rcpp::internal::converter( x1 )) ) ; \
+return res ; \
+END_RCPP \
+} \
+__OUT__ RCPP_DECORATE(__NAME__)(___0, ___1)
+
+#define RPB_FUNCTION_3(__OUT__,__NAME__, ___0, ___1, ___2) \
+__OUT__ RCPP_DECORATE(__NAME__)(___0, ___1, ___2); \
+extern "C" SEXP __NAME__(SEXP x0, SEXP x1, SEXP x2){ \
+SEXP res = R_NilValue ; \
+BEGIN_RCPP \
+res = ::Rcpp::wrap( RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 ), ::Rcpp::internal::converter( x1 ), ::Rcpp::internal::converter( x2 )) ) ; \
+return res ; \
+END_RCPP \
+} \
+__OUT__ RCPP_DECORATE(__NAME__)(___0, ___1, ___2)
+
+#define RPB_FUNCTION_4(__OUT__,__NAME__, ___0, ___1, ___2, ___3) \
+__OUT__ RCPP_DECORATE(__NAME__)(___0, ___1, ___2, ___3); \
+extern "C" SEXP __NAME__(SEXP x0, SEXP x1, SEXP x2, SEXP x3){ \
+SEXP res = R_NilValue ; \
+BEGIN_RCPP \
+res = ::Rcpp::wrap( RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 ), ::Rcpp::internal::converter( x1 ), ::Rcpp::internal::converter( x2 )), ::Rcpp::internal::converter( x3 )) ) ; \
+return res ; \
+END_RCPP \
+} \
+__OUT__ RCPP_DECORATE(__NAME__)(___0, ___1, ___2, ___3)
+
+#define RPB_FUNCTION_VOID_0(__NAME__) \
+void RCPP_DECORATE(__NAME__)(); \
+extern "C" SEXP __NAME__(){ \
+BEGIN_RCPP \
+RCPP_DECORATE(__NAME__)(); \
+END_RCPP \
+} \
+void RCPP_DECORATE(__NAME__)()
+
+#define RPB_FUNCTION_VOID_1(__NAME__, ___0) \
+void RCPP_DECORATE(__NAME__)(___0); \
+extern "C" SEXP __NAME__(SEXP x0){ \
+BEGIN_RCPP \
+RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 )); \
+END_RCPP \
+} \
+void RCPP_DECORATE(__NAME__)(___0)
+
+#define RPB_FUNCTION_VOID_2(__NAME__, ___0, ___1) \
+void RCPP_DECORATE(__NAME__)(___0, ___1); \
+extern "C" SEXP __NAME__(SEXP x0, SEXP x1){ \
+BEGIN_RCPP \
+RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 ), ::Rcpp::internal::converter( x1 )); \
+END_RCPP \
+} \
+void RCPP_DECORATE(__NAME__)(___0, ___1)
+
+#define RPB_FUNCTION_VOID_3(__NAME__, ___0, ___1, ___2) \
+void RCPP_DECORATE(__NAME__)(___0, ___1, ___2); \
+extern "C" SEXP __NAME__(SEXP x0, SEXP x1, SEXP x2){ \
+BEGIN_RCPP \
+RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 ), ::Rcpp::internal::converter( x1 ), ::Rcpp::internal::converter( x2 )); \
+END_RCPP \
+} \
+void RCPP_DECORATE(__NAME__)(___0, ___1, ___2)
+
+#define RPB_FUNCTION_VOID_4(__NAME__, ___0, ___1, ___2, ___3) \
+void RCPP_DECORATE(__NAME__)(___0, ___1, ___2, ___3); \
+extern "C" SEXP __NAME__(SEXP x0, SEXP x1, SEXP x2, SEXP x3){ \
+BEGIN_RCPP \
+RCPP_DECORATE(__NAME__)(::Rcpp::internal::converter( x0 ), ::Rcpp::internal::converter( x1 ), ::Rcpp::internal::converter( x2 ), ::Rcpp::internal::converter( x3 )); \
+END_RCPP \
+} \
+void RCPP_DECORATE(__NAME__)(___0, ___1, ___2, ___3)
+
+#endif
Modified: pkg/src/mutators.cpp
===================================================================
--- pkg/src/mutators.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/mutators.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -20,6 +20,7 @@
#include "rprotobuf.h"
#include "fieldtypes.h"
+#include "RcppMacros.h"
namespace rprotobuf{
@@ -1171,7 +1172,7 @@
}
-RCPP_FUNCTION_VOID_2( update_message, Rcpp::XPtr<GPB::Message> message, Rcpp::List list ){
+RPB_FUNCTION_VOID_2( update_message, Rcpp::XPtr<GPB::Message> message, Rcpp::List list ){
Rcpp::CharacterVector names = list.attr( "names" ) ;
int n = list.size() ;
for( int i=0; i<n; i++){
Modified: pkg/src/rprotobuf.cpp
===================================================================
--- pkg/src/rprotobuf.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/rprotobuf.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -1,5 +1,6 @@
#include "rprotobuf.h"
#include "DescriptorPoolLookup.h"
+#include "RcppMacros.h"
namespace rprotobuf{
@@ -258,13 +259,13 @@
return field_desc ;
}
-RCPP_FUNCTION_VOID_1( check_libprotobuf_version, int minversion ){
+RPB_FUNCTION_VOID_1( check_libprotobuf_version, int minversion ){
if( GOOGLE_PROTOBUF_VERSION < minversion ){
throw std::range_error( "The protobuf library you are using is too old for this package, please upgrade" ) ;
}
}
-RCPP_FUNCTION_0(int, get_protobuf_library_version){
+RPB_FUNCTION_0(int, get_protobuf_library_version){
return GOOGLE_PROTOBUF_VERSION;
}
Modified: pkg/src/wrapper_ArrayInputStream.cpp
===================================================================
--- pkg/src/wrapper_ArrayInputStream.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_ArrayInputStream.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -1,11 +1,11 @@
#include "rprotobuf.h"
+#include "RcppMacros.h"
namespace rprotobuf{
- RCPP_FUNCTION_2( S4_ArrayInputStream, ArrayInputStream__new, Rcpp::RawVector payload, int block_size){
+ RPB_FUNCTION_2( S4_ArrayInputStream, ArrayInputStream__new, Rcpp::RawVector payload, int block_size){
return S4_ArrayInputStream( payload, block_size );
}
}
-
Modified: pkg/src/wrapper_ArrayOutputStream.cpp
===================================================================
--- pkg/src/wrapper_ArrayOutputStream.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_ArrayOutputStream.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -1,11 +1,11 @@
#include "rprotobuf.h"
+#include "RcppMacros.h"
namespace rprotobuf{
- RCPP_FUNCTION_2( S4_ArrayOutputStream, ArrayOutputStream__new, int size, int block_size){
+ RPB_FUNCTION_2( S4_ArrayOutputStream, ArrayOutputStream__new, int size, int block_size){
return S4_ArrayOutputStream( size, block_size ) ;
}
}
-
Modified: pkg/src/wrapper_Descriptor.cpp
===================================================================
--- pkg/src/wrapper_Descriptor.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_Descriptor.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -1,4 +1,5 @@
#include "rprotobuf.h"
+#include "RcppMacros.h"
namespace rprotobuf{
@@ -21,7 +22,7 @@
*
* @return member names, as an R character vector (STRSXP)
*/
-RCPP_FUNCTION_1( Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::Descriptor> desc ){
+RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::Descriptor> desc ){
int nfields = desc->field_count() ;
int ntypes = desc->nested_type_count() ;
@@ -45,7 +46,7 @@
* @param xp external pointer to a Descriptor
* @return the descriptor as an R list
*/
-RCPP_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::Descriptor> desc ){
+RPB_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::Descriptor> desc ){
int nfields = desc->field_count() ;
int ntypes = desc->nested_type_count() ;
@@ -76,50 +77,50 @@
return res;
}
-RCPP_FUNCTION_1(S4_Message, METHOD(as_Message) , Rcpp::XPtr<GPB::Descriptor> d ){
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message) , Rcpp::XPtr<GPB::Descriptor> d ){
GPB::DescriptorProto* message = new GPB::DescriptorProto() ;
d->CopyTo( message );
return message ;
}
-RCPP_FUNCTION_2( S4_FieldDescriptor, METHOD(field), Rcpp::XPtr<GPB::Descriptor> d, int i){
+RPB_FUNCTION_2( S4_FieldDescriptor, METHOD(field), Rcpp::XPtr<GPB::Descriptor> d, int i){
return d->field( i ) ;
}
-RCPP_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByNumber), Rcpp::XPtr<GPB::Descriptor> d, int num){
+RPB_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByNumber), Rcpp::XPtr<GPB::Descriptor> d, int num){
return d->FindFieldByNumber( num ) ;
}
-RCPP_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam ){
+RPB_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam ){
return d->FindFieldByName( nam ) ;
}
-RCPP_FUNCTION_2( S4_Descriptor, METHOD(nested_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
+RPB_FUNCTION_2( S4_Descriptor, METHOD(nested_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
return d->nested_type( i ) ;
}
-RCPP_FUNCTION_2( S4_Descriptor, METHOD(FindNestedTypeByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam){
+RPB_FUNCTION_2( S4_Descriptor, METHOD(FindNestedTypeByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam){
return d->FindNestedTypeByName( nam ) ;
}
-RCPP_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
+RPB_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
return d->enum_type( i ) ;
}
// FIXME: two methods cant have the same name
-// RCPP_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, std::string name){
+// RPB_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, std::string name){
// return d->FindEnumTypeByName( i ) ;
// }
-RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::Descriptor> desc){
+RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::Descriptor> desc){
return S4_FileDescriptor( desc->file() );
}
-RCPP_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::Descriptor> d, bool full){
+RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::Descriptor> d, bool full){
return full ? d->full_name() : d->name() ;
}
-RCPP_FUNCTION_2( S4_Message, METHOD(readMessageFromFile), Rcpp::XPtr<GPB::Descriptor> desc, std::string filename ){
+RPB_FUNCTION_2( S4_Message, METHOD(readMessageFromFile), Rcpp::XPtr<GPB::Descriptor> desc, std::string filename ){
/* open the file to read in binary mode */
int file = open( filename.c_str() , O_RDONLY | O_BINARY);
@@ -135,7 +136,7 @@
return( S4_Message( message ) ) ;
}
-RCPP_FUNCTION_2( S4_Message, METHOD(readMessageFromConnection), Rcpp::XPtr<GPB::Descriptor> desc, int conn_id ){
+RPB_FUNCTION_2( S4_Message, METHOD(readMessageFromConnection), Rcpp::XPtr<GPB::Descriptor> desc, int conn_id ){
RconnectionCopyingInputStream wrapper( conn_id ) ;
GPB::io::CopyingInputStreamAdaptor stream( &wrapper ) ;
GPB::io::CodedInputStream coded_stream(&stream ) ;
@@ -151,7 +152,7 @@
return res ;
}
-RCPP_FUNCTION_2( S4_Message, METHOD(readMessageFromRawVector), Rcpp::XPtr<GPB::Descriptor> desc, Rcpp::RawVector raw){
+RPB_FUNCTION_2( S4_Message, METHOD(readMessageFromRawVector), Rcpp::XPtr<GPB::Descriptor> desc, Rcpp::RawVector raw){
GPB::io::ArrayInputStream ais( (void*)raw.begin(), raw.size() );
GPB::io::CodedInputStream stream( &ais ) ;
@@ -164,7 +165,7 @@
return( S4_Message( message ) ) ;
}
-RCPP_FUNCTION_2( S4_Message, METHOD(readASCIIFromString), Rcpp::XPtr<GPB::Descriptor> desc, std::string input){
+RPB_FUNCTION_2( S4_Message, METHOD(readASCIIFromString), Rcpp::XPtr<GPB::Descriptor> desc, std::string input){
GPB::Message* message = PROTOTYPE( desc ) ;
if (GPB::TextFormat::ParseFromString( input, message ) ) {
return( S4_Message( message ) ) ;
@@ -173,7 +174,7 @@
}
}
-RCPP_FUNCTION_2( S4_Message, METHOD(readASCIIFromConnection), Rcpp::XPtr<GPB::Descriptor> desc, int conn_id){
+RPB_FUNCTION_2( S4_Message, METHOD(readASCIIFromConnection), Rcpp::XPtr<GPB::Descriptor> desc, int conn_id){
RconnectionCopyingInputStream wrapper( conn_id ) ;
GPB::io::CopyingInputStreamAdaptor stream( &wrapper ) ;
Modified: pkg/src/wrapper_EnumDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumDescriptor.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_EnumDescriptor.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -20,6 +20,7 @@
// along with RProtoBuf. If not, see <http://www.gnu.org/licenses/>.
#include "rprotobuf.h"
+#include "RcppMacros.h"
namespace rprotobuf{
@@ -30,11 +31,11 @@
RCPP_XP_METHOD_0(METHOD(length) ,GPB::EnumDescriptor,value_count)
RCPP_XP_METHOD_0(METHOD(value_count) ,GPB::EnumDescriptor,value_count)
- RCPP_FUNCTION_1(S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+ RPB_FUNCTION_1(S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::EnumDescriptor> d ){
return S4_Descriptor( d->containing_type() ) ;
}
- RCPP_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByIndex) , Rcpp::XPtr<GPB::EnumDescriptor> d, int index){
+ RPB_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByIndex) , Rcpp::XPtr<GPB::EnumDescriptor> d, int index){
if ((index >= 0) && (index < d->value_count())) {
return S4_EnumValueDescriptor( d->value(index) ) ;
} else {
@@ -42,14 +43,14 @@
}
}
- RCPP_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByNumber), Rcpp::XPtr<GPB::EnumDescriptor> d, int i ){
+ RPB_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByNumber), Rcpp::XPtr<GPB::EnumDescriptor> d, int i ){
return S4_EnumValueDescriptor( d->FindValueByNumber(i) ) ;
}
- RCPP_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByName) , Rcpp::XPtr<GPB::EnumDescriptor> d , std::string name ){
+ RPB_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByName) , Rcpp::XPtr<GPB::EnumDescriptor> d , std::string name ){
return S4_EnumValueDescriptor( d->FindValueByName(name) ) ;
}
- RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+ RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::EnumDescriptor> d ){
GPB::EnumDescriptorProto* message = new GPB::EnumDescriptorProto() ;
d->CopyTo( message );
return S4_Message(message) ;
@@ -63,7 +64,7 @@
*
* @param the value associated with the name
*/
-RCPP_FUNCTION_2(int,get_value_of_enum,
+RPB_FUNCTION_2(int,get_value_of_enum,
Rcpp::XPtr<GPB::EnumDescriptor> d, std::string name){
const GPB::EnumValueDescriptor* evd = d->FindValueByName(name) ;
@@ -81,7 +82,7 @@
* @param name the name of the enum
* @return logical
*/
-RCPP_FUNCTION_2(bool,has_enum_name,
+RPB_FUNCTION_2(bool,has_enum_name,
Rcpp::XPtr<GPB::EnumDescriptor> d, std::string name){
const GPB::EnumValueDescriptor* evd = d->FindValueByName(name) ;
return (evd != NULL);
@@ -91,7 +92,7 @@
* @param xp external pointer to a Descriptor
* @return the descriptor as an R list
*/
-RCPP_FUNCTION_1( Rcpp::IntegerVector, METHOD(as_list), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+RPB_FUNCTION_1( Rcpp::IntegerVector, METHOD(as_list), Rcpp::XPtr<GPB::EnumDescriptor> d ){
int n = d->value_count() ;
Rcpp::IntegerVector values(n) ;
@@ -106,7 +107,7 @@
return values;
}
-RCPP_FUNCTION_1( Rcpp::CharacterVector, METHOD(getConstantNames), Rcpp::XPtr<GPB::EnumDescriptor> d){
+RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(getConstantNames), Rcpp::XPtr<GPB::EnumDescriptor> d){
int n = d->value_count() ;
Rcpp::CharacterVector res( n) ;
for( int i=0; i<n; i++){
@@ -115,11 +116,11 @@
return res ;
}
-RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::EnumDescriptor> desc){
+RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::EnumDescriptor> desc){
return S4_FileDescriptor( desc->file() );
}
-RCPP_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d, bool full){
+RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d, bool full){
return full ? d->full_name() : d->name() ;
}
Modified: pkg/src/wrapper_EnumValueDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumValueDescriptor.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_EnumValueDescriptor.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -20,6 +20,7 @@
// along with RProtoBuf. If not, see <http://www.gnu.org/licenses/>.
#include "rprotobuf.h"
+#include "RcppMacros.h"
namespace rprotobuf{
@@ -28,17 +29,17 @@
RCPP_XP_METHOD_0( METHOD(as_character) , GPB::EnumValueDescriptor , DebugString) ;
-RCPP_FUNCTION_1(S4_Message, METHOD(as_Message) , Rcpp::XPtr<GPB::EnumValueDescriptor> d ){
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message) , Rcpp::XPtr<GPB::EnumValueDescriptor> d ){
GPB::EnumValueDescriptorProto* message = new GPB::EnumValueDescriptorProto() ;
d->CopyTo( message );
return S4_Message(message) ;
}
-RCPP_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumValueDescriptor> d, bool full) {
+RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumValueDescriptor> d, bool full) {
return full ? d->full_name() : d->name() ;
}
-RCPP_FUNCTION_1( int, METHOD(number), Rcpp::XPtr<GPB::EnumValueDescriptor> d) {
+RPB_FUNCTION_1( int, METHOD(number), Rcpp::XPtr<GPB::EnumValueDescriptor> d) {
return d->number() ;
}
Modified: pkg/src/wrapper_FieldDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FieldDescriptor.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_FieldDescriptor.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -20,6 +20,7 @@
#include "rprotobuf.h"
#include "fieldtypes.h"
+#include "RcppMacros.h"
namespace rprotobuf {
@@ -37,7 +38,7 @@
RCPP_XP_METHOD_0( METHOD(is_required) , GPB::FieldDescriptor, is_required )
RCPP_XP_METHOD_0( METHOD(has_default_value) , GPB::FieldDescriptor, has_default_value )
- RCPP_FUNCTION_1( S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
+ RPB_FUNCTION_1( S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
return S4_Descriptor( d->containing_type() ) ;
}
@@ -48,7 +49,7 @@
break ; \
}
- RCPP_FUNCTION_1( SEXP, METHOD(default_value) , Rcpp::XPtr<GPB::FieldDescriptor> d ){
+ RPB_FUNCTION_1( SEXP, METHOD(default_value) , Rcpp::XPtr<GPB::FieldDescriptor> d ){
switch( d->cpp_type() ){
RPB_HANDLE_CASE(INT32,int32)
@@ -73,31 +74,31 @@
return R_NilValue ;
}
- RCPP_FUNCTION_1(S4_Descriptor, METHOD(message_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
+ RPB_FUNCTION_1(S4_Descriptor, METHOD(message_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
if( d->cpp_type() != CPPTYPE_MESSAGE ){
throw Rcpp::not_compatible( "not a message type field" ) ;
}
return S4_Descriptor( d->message_type() ) ;
}
- RCPP_FUNCTION_1(S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
+ RPB_FUNCTION_1(S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
if( d->cpp_type() != CPPTYPE_ENUM ){
throwException( "not an enum type field", "NotEnumType" );
}
return S4_EnumDescriptor( d->enum_type() ) ;
}
- RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FieldDescriptor> d ){
+ RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FieldDescriptor> d ){
GPB::FieldDescriptorProto* message = new GPB::FieldDescriptorProto() ;
d->CopyTo( message );
return S4_Message( message ) ;
}
- RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::FieldDescriptor> desc){
+ RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::FieldDescriptor> desc){
return S4_FileDescriptor( desc->file() );
}
- RCPP_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::FieldDescriptor> d, bool full){
+ RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::FieldDescriptor> d, bool full){
return full ? d->full_name() : d->name() ;
}
@@ -107,4 +108,3 @@
} // namespace rprotobuf
-
Modified: pkg/src/wrapper_FileDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FileDescriptor.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_FileDescriptor.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -1,4 +1,5 @@
#include "rprotobuf.h"
+#include "RcppMacros.h"
namespace rprotobuf{
@@ -7,14 +8,14 @@
RCPP_XP_METHOD_0( METHOD(as_character) , GPB::FileDescriptor , DebugString) ;
-RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FileDescriptor> d ){
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FileDescriptor> d ){
GPB::FileDescriptorProto* message = new GPB::FileDescriptorProto() ;
d->CopyTo( message );
return S4_Message( message ) ;
}
-RCPP_FUNCTION_1( Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::FileDescriptor> desc ){
+RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::FileDescriptor> desc ){
int ntypes = desc->message_type_count() ;
int nenums = desc->enum_type_count() ;
int nserv = desc->service_count() ;
@@ -54,7 +55,7 @@
* @param xp (GPB::FileDescriptor*) external pointer
* @return the descriptor as an R list
*/
-RCPP_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::FileDescriptor> desc ){
+RPB_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::FileDescriptor> desc ){
int ntypes = desc->message_type_count() ;
int nenums = desc->enum_type_count() ;
int nserv = desc->service_count() ;
@@ -86,7 +87,7 @@
return res;
}
-RCPP_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::FileDescriptor> desc ){
+RPB_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::FileDescriptor> desc ){
return desc->name() ;
}
Modified: pkg/src/wrapper_Message.cpp
===================================================================
--- pkg/src/wrapper_Message.cpp 2013-09-12 03:58:01 UTC (rev 531)
+++ pkg/src/wrapper_Message.cpp 2013-09-13 01:20:02 UTC (rev 532)
@@ -1,5 +1,6 @@
#include "rprotobuf.h"
#include "fieldtypes.h"
+#include "RcppMacros.h"
#define SAME(x,y,tol) ( (tol==0.0 && x == y ) || ( ( (x-y)*(x-y) < tol*tol ) ? 1 : 0 ) )
@@ -63,7 +64,7 @@
* @param xp external pointer to a message
* @return a new message, clone of the input message
*/
-RCPP_FUNCTION_1( S4_Message, METHOD(clone) , Rcpp::XPtr<GPB::Message> message ){
+RPB_FUNCTION_1( S4_Message, METHOD(clone) , Rcpp::XPtr<GPB::Message> message ){
/* cloning message as sheep */
GPB::Message* sheep = message->New() ;
sheep->CopyFrom( *message );
@@ -79,7 +80,7 @@
* @param xp external pointer to the Message
* @param name name of the field
*/
-RCPP_FUNCTION_2(bool, METHOD(field_exists), Rcpp::XPtr<GPB::Message> message, std::string name ){
+RPB_FUNCTION_2(bool, METHOD(field_exists), Rcpp::XPtr<GPB::Message> message, std::string name ){
const GPB::Descriptor* desc = message->GetDescriptor();
const GPB::FieldDescriptor* field_desc = desc->FindFieldByName( name ) ;
return (field_desc != NULL);
@@ -92,7 +93,7 @@
* @param xp external pointer to the Message
* @param name name of the field
*/
-RCPP_FUNCTION_2(bool, METHOD(has_field), Rcpp::XPtr<GPB::Message> message, std::string name ){
+RPB_FUNCTION_2(bool, METHOD(has_field), Rcpp::XPtr<GPB::Message> message, std::string name ){
const GPB::Descriptor* desc = message->GetDescriptor();
const GPB::FieldDescriptor* field_desc = desc->FindFieldByName( name ) ;
@@ -115,7 +116,7 @@
*
* @param xp external pointer to the Message
*/
-RCPP_FUNCTION_1( bool, METHOD(is_initialized), Rcpp::XPtr<GPB::Message> message){
+RPB_FUNCTION_1( bool, METHOD(is_initialized), Rcpp::XPtr<GPB::Message> message){
return message->IsInitialized() ;
}
@@ -126,7 +127,7 @@
* @param xp external pointer to a GPB::Message*
* @param filename file name where to serialize
*/
-RCPP_FUNCTION_VOID_2( METHOD(serialize_to_file) , Rcpp::XPtr<GPB::Message> message, const char* filename){
+RPB_FUNCTION_VOID_2( METHOD(serialize_to_file) , Rcpp::XPtr<GPB::Message> message, const char* filename){
/* open the file in binary mode to write */
/* we make sure in the R side that filename is the full path of the file */
@@ -145,7 +146,7 @@
*
* @param xp xternal pointer to the message
*/
-RCPP_FUNCTION_1( Rcpp::RawVector, METHOD(get_payload), Rcpp::XPtr<GPB::Message> message ){
+RPB_FUNCTION_1( Rcpp::RawVector, METHOD(get_payload), Rcpp::XPtr<GPB::Message> message ){
/* create a raw vector of the appropriate size */
int size = message->ByteSize() ;
@@ -165,7 +166,7 @@
* @param xp (GPB::Message*) external pointer
* @param field name or tag of the field
*/
-RCPP_FUNCTION_VOID_2(METHOD(clear_field), Rcpp::XPtr<GPB::Message> m, SEXP field ){
+RPB_FUNCTION_VOID_2(METHOD(clear_field), Rcpp::XPtr<GPB::Message> m, SEXP field ){
GPB::FieldDescriptor* field_desc = getFieldDescriptor( m, field ) ;
const GPB::Reflection* ref = m->GetReflection();
ref->ClearField( m, field_desc ) ;
@@ -176,7 +177,7 @@
* @param xp external pointer to a Message
* @return the message as an R list
*/
-RCPP_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::Message> message ){
+RPB_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::Message> message ){
const GPB::Descriptor* desc = message->GetDescriptor() ;
int nf = desc->field_count() ;
@@ -201,7 +202,7 @@
*
* @param xp external pointer to the Message
*/
-RCPP_FUNCTION_1(int, METHOD(length), Rcpp::XPtr<GPB::Message> message){
+RPB_FUNCTION_1(int, METHOD(length), Rcpp::XPtr<GPB::Message> message){
const GPB::Descriptor* desc = message->GetDescriptor();
const GPB::Reflection * ref = message->GetReflection() ;
@@ -229,7 +230,7 @@
*
* @param xp external pointer to the Message
*/
-RCPP_FUNCTION_1(int, METHOD(num_extensions), Rcpp::XPtr<GPB::Message> message){
+RPB_FUNCTION_1(int, METHOD(num_extensions), Rcpp::XPtr<GPB::Message> message){
const GPB::Reflection * ref = message->GetReflection() ;
int nexts = 0;
vector<const FieldDescriptor*> fields;
@@ -248,14 +249,14 @@
* @param xp (GPB::Message*) external pointer
* @return the descriptor, as a Descriptor R S4 object
*/
-RCPP_FUNCTION_1(S4_Descriptor, METHOD(descriptor), Rcpp::XPtr<GPB::Message> message ){
+RPB_FUNCTION_1(S4_Descriptor, METHOD(descriptor), Rcpp::XPtr<GPB::Message> message ){
return( message->GetDescriptor() ) ;
}
RCPP_XP_METHOD_0( METHOD(as_character) , GPB::Message, DebugString)
RCPP_XP_METHOD_0( METHOD(bytesize), GPB::Message, ByteSize )
-RCPP_FUNCTION_2( int, METHOD(field_size), Rcpp::XPtr<GPB::Message> message, SEXP field ){
+RPB_FUNCTION_2( int, METHOD(field_size), Rcpp::XPtr<GPB::Message> message, SEXP field ){
GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field ) ;
@@ -268,12 +269,12 @@
return res ;
}
-RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::Message> message ){
+RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::Message> message ){
return S4_FileDescriptor( message->GetDescriptor()->file() ) ;
}
-RCPP_FUNCTION_VOID_3( METHOD(set_field_size), Rcpp::XPtr<GPB::Message> message, SEXP field, int target){
+RPB_FUNCTION_VOID_3( METHOD(set_field_size), Rcpp::XPtr<GPB::Message> message, SEXP field, int target){
GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field ) ;
const GPB::Reflection* ref = message->GetReflection() ;
@@ -444,7 +445,7 @@
*
* @return field names, as an R character vector (STRSXP)
*/
-RCPP_FUNCTION_1( Rcpp::CharacterVector, METHOD(fieldNames), Rcpp::XPtr<GPB::Message> message){
+RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(fieldNames), Rcpp::XPtr<GPB::Message> message){
const GPB::Descriptor* desc = message->GetDescriptor() ;
int nfields = desc->field_count() ;
@@ -642,15 +643,15 @@
}
-RCPP_FUNCTION_2( bool, identical_messages, Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2){
+RPB_FUNCTION_2( bool, identical_messages, Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2){
return identical_messages_( m1, m2, 0.0 ) ;
}
-RCPP_FUNCTION_3( bool, all_equal_messages, Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2, double tol){
+RPB_FUNCTION_3( bool, all_equal_messages, Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2, double tol){
return identical_messages_( m1, m2, tol ) ;
}
-RCPP_FUNCTION_VOID_4( METHOD(swap), Rcpp::XPtr<GPB::Message> message, SEXP field, Rcpp::IntegerVector left, Rcpp::IntegerVector right){
+RPB_FUNCTION_VOID_4( METHOD(swap), Rcpp::XPtr<GPB::Message> message, SEXP field, Rcpp::IntegerVector left, Rcpp::IntegerVector right){
GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field ) ;
const GPB::Reflection* ref = message->GetReflection();
if( ! field_desc->is_repeated() ){
@@ -670,7 +671,7 @@
*
* @return a new message, as an R object of "Message" S4 class
*/
-RCPP_FUNCTION_2( S4_Message, METHOD(merge), Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2){
+RPB_FUNCTION_2( S4_Message, METHOD(merge), Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2){
GPB::Message* merged = m1->New() ;
merged->MergeFrom( *m1 ) ;
merged->MergeFrom( *m2 );
@@ -685,7 +686,7 @@
* @param field field tag number or name
* @param values values to append
*/
-RCPP_FUNCTION_VOID_3( METHOD(add_values), Rcpp::XPtr<GPB::Message> message, SEXP field, SEXP values){
+RPB_FUNCTION_VOID_3( METHOD(add_values), Rcpp::XPtr<GPB::Message> message, SEXP field, SEXP values){
const Reflection * ref = message->GetReflection() ;
GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field );
@@ -981,7 +982,7 @@
* @param field name or tag number of the field
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rprotobuf -r 532
More information about the Rprotobuf-commits
mailing list