[Rprotobuf-commits] r329 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 14 20:33:36 CEST 2010
Author: romain
Date: 2010-07-14 20:33:36 +0200 (Wed, 14 Jul 2010)
New Revision: 329
Modified:
pkg/src/Rcppsupport.h
pkg/src/S4_classes.h
pkg/src/rprotobuf.cpp
pkg/src/rprotobuf.h
pkg/src/streams.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
pkg/src/wrapper_ZeroCopyInputStream.cpp
Log:
compiles now
Modified: pkg/src/Rcppsupport.h
===================================================================
--- pkg/src/Rcppsupport.h 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/Rcppsupport.h 2010-07-14 18:33:36 UTC (rev 329)
@@ -98,7 +98,7 @@
return ref->FieldSize( message, field ) ;
}
inline SEXP wrap(int i) const {
- return new_RS4_Message_( CLONE( &ref->GetRepeatedMessage( message, field, i ) ) ) ;
+ return S4_Message( CLONE( &ref->GetRepeatedMessage( message, field, i ) ) ) ;
}
private:
const GPB::Reflection* ref ;
Modified: pkg/src/S4_classes.h
===================================================================
--- pkg/src/S4_classes.h 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/S4_classes.h 2010-07-14 18:33:36 UTC (rev 329)
@@ -64,6 +64,24 @@
}
} ;
+ class S4_FileDescriptor : public Rcpp::S4 {
+ public:
+ S4_FileDescriptor( const GPB::FileDescriptor* d) : S4( "FileDescriptor" ){
+ slot( "pointer" ) = Rcpp::XPtr<GPB::FileDescriptor>(
+ const_cast<GPB::FileDescriptor*>(d), false) ;
+ // slot( "type" ) = d->full_name() ;
+ }
+
+ S4_FileDescriptor( const S4_FileDescriptor& other) : S4(){
+ setSEXP( other.asSexp() );
+ }
+ S4_FileDescriptor& operator=( const S4_FileDescriptor& other){
+ setSEXP( other.asSexp() );
+ return *this ;
+ }
+ } ;
+
+
class S4_FieldDescriptor : public Rcpp::S4 {
public:
S4_FieldDescriptor( const GPB::FieldDescriptor* d) : S4( "FieldDescriptor" ){
Modified: pkg/src/rprotobuf.cpp
===================================================================
--- pkg/src/rprotobuf.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/rprotobuf.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -113,7 +113,7 @@
Rprintf( "</newProtoMessage>\n" ) ;
#endif
- return( new_RS4_Message_( message ) ) ;
+ return( S4_Message( message ) ) ;
}
/**
Modified: pkg/src/rprotobuf.h
===================================================================
--- pkg/src/rprotobuf.h 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/rprotobuf.h 2010-07-14 18:33:36 UTC (rev 329)
@@ -187,9 +187,6 @@
RcppExport SEXP ConnectionOutputStream_new( SEXP , SEXP) ;
-RcppExport SEXP new_RS4_Message_( const GPB::Message* message );
-
-
/**
* simple class that wraps together a ZeroCopyOutputStream
* and its associated CodedOutputStream. Since we don't expose
@@ -231,6 +228,15 @@
} // namespace rprotobuf
-#include "S4_classes.h"
+#include "S4_classes.h"
+#include "RconnectionCopyingInputStream.h"
+#define GET_ZCIS(xp) ( (ZeroCopyInputStreamWrapper*)XPP(xp) )->get_stream()
+#define GET_CIS(xp) ( (ZeroCopyInputStreamWrapper*)XPP(xp) )->get_coded_stream()
+#define GET_FIS(xp) (GPB::io::FileInputStream*)( (ZeroCopyInputStreamWrapper*)XPP(xp) )->get_stream()
+
+#define GET_ZCOS(xp) ( (ZeroCopyOutputStreamWrapper*)XPP(xp) )->get_stream()
+#define GET_COS(xp) ( (ZeroCopyOutputStreamWrapper*)XPP(xp) )->get_coded_stream()
+#define GET_FOS(xp) (GPB::io::FileOutputStream*)( (ZeroCopyOutputStreamWrapper*)XPP(xp) )->get_stream()
+
#endif
Modified: pkg/src/streams.cpp
===================================================================
--- pkg/src/streams.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/streams.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -6,16 +6,15 @@
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
-#define GET_ZCIS(xp) ( (ZeroCopyInputStreamWrapper*)XPP(xp) )->get_stream()
-#define GET_CIS(xp) ( (ZeroCopyInputStreamWrapper*)XPP(xp) )->get_coded_stream()
-#define GET_FIS(xp) (GPB::io::FileInputStream*)( (ZeroCopyInputStreamWrapper*)XPP(xp) )->get_stream()
+namespace rprotobuf{
-#define GET_ZCOS(xp) ( (ZeroCopyOutputStreamWrapper*)XPP(xp) )->get_stream()
-#define GET_COS(xp) ( (ZeroCopyOutputStreamWrapper*)XPP(xp) )->get_coded_stream()
-#define GET_FOS(xp) (GPB::io::FileOutputStream*)( (ZeroCopyOutputStreamWrapper*)XPP(xp) )->get_stream()
+ void ZeroCopyInputStreamWrapper_finalizer( SEXP xp){
+ delete (ZeroCopyInputStreamWrapper*)XPP(xp) ;
+ }
+ void ZeroCopyOutputStreamWrapper_finalizer( SEXP xp){
+ delete (ZeroCopyOutputStreamWrapper*)XPP(xp) ;
+ }
-
-namespace rprotobuf{
// {{{ input streams
Modified: pkg/src/wrapper_EnumDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumDescriptor.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_EnumDescriptor.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -3,22 +3,31 @@
namespace rprotobuf{
#undef METHOD
-#define METHOD(__NAME__) RCPP_PP_CAT(Descriptor__,__NAME__)
+#define METHOD(__NAME__) RCPP_PP_CAT(EnumDescriptor__,__NAME__)
RCPP_XP_METHOD_0(METHOD(as_character), GPB::EnumDescriptor , DebugString) ;
RCPP_XP_METHOD_0(METHOD(length) ,GPB::EnumDescriptor,value_count)
RCPP_XP_METHOD_0(METHOD(value_count) ,GPB::EnumDescriptor,value_count)
- RCPP_XP_METHOD_CAST_0(METHOD(containing_type), GPB::EnumDescriptor, containing_type, RS4_Descriptor )
+ RCPP_FUNCTION_1(S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+ return S4_Descriptor( d->containing_type() ) ;
+ }
- RCPP_XP_METHOD_CAST_1(METHOD(getValueByIndex) , GPB::EnumDescriptor , value , S4_EnumValueDescriptor )
- RCPP_XP_METHOD_CAST_1(METHOD(getValueByNumber), GPB::EnumDescriptor , FindValueByNumber, S4_EnumValueDescriptor )
- RCPP_XP_METHOD_CAST_1(METHOD(getValueByName) , GPB::EnumDescriptor , FindValueByName , S4_EnumValueDescriptor )
+ RCPP_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByIndex) , Rcpp::XPtr<GPB::EnumDescriptor> d, int index){
+ return S4_EnumValueDescriptor( d->value(index) ) ;
+ }
+
+ RCPP_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 ){
+ return S4_EnumValueDescriptor( d->FindValueByName(name) ) ;
+ }
- RCPP_FUNCTION_1(S4_EnumDescriptor, METHOD(as_Message), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+ RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::EnumDescriptor> d ){
GPB::EnumDescriptorProto* message = new GPB::EnumDescriptorProto() ;
d->CopyTo( message );
- return message ;
+ return S4_Message(message) ;
}
/**
@@ -65,7 +74,7 @@
for( int i=0; i<n; i++){
res[i] = d->value(i)->name() ;
}
- return names ;
+ return res ;
}
RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::EnumDescriptor> desc){
Modified: pkg/src/wrapper_EnumValueDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumValueDescriptor.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_EnumValueDescriptor.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -7,10 +7,10 @@
RCPP_XP_METHOD_0( METHOD(as_character) , GPB::EnumValueDescriptor , DebugString) ;
-RCPP_FUNCTION_1(S4_EnumValueDescriptor, METHOD(as_Message) , Rcpp::XPtr<GPB::EnumValueDescriptor> d ){
+RCPP_FUNCTION_1(S4_Message, METHOD(as_Message) , Rcpp::XPtr<GPB::EnumValueDescriptor> d ){
GPB::EnumValueDescriptorProto* message = new GPB::EnumValueDescriptorProto() ;
d->CopyTo( message );
- return message ;
+ return S4_Message(message) ;
}
#undef METHOD
Modified: pkg/src/wrapper_FieldDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FieldDescriptor.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_FieldDescriptor.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -17,7 +17,9 @@
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_XP_METHOD_CAST_0( METHOD(containing_type), GPB::FieldDescriptor, containing_type, RS4_Descriptor )
+ RCPP_FUNCTION_1( S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
+ return S4_Descriptor( d->containing_type() ) ;
+ }
#define RPB_HANDLE_CASE(__CPP__,__LC__) \
case CPPTYPE_##__CPP__: \
@@ -63,10 +65,10 @@
return S4_EnumDescriptor( d->enum_type() ) ;
}
- RCPP_FUNCTION_1(S4_FieldDescriptor, METHOD(as_Message), Rcpp::XPtr<GPB::FieldDescriptor> d ){
+ RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FieldDescriptor> d ){
GPB::FieldDescriptorProto* message = new GPB::FieldDescriptorProto() ;
d->CopyTo( message );
- return message ;
+ return S4_Message( message ) ;
}
RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::FieldDescriptor> desc){
@@ -78,9 +80,6 @@
}
-}
-
-
#undef RPB_HANDLE_CASE
#undef METHOD
Modified: pkg/src/wrapper_FileDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FileDescriptor.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_FileDescriptor.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -7,10 +7,10 @@
RCPP_XP_METHOD_0( METHOD(as_character) , GPB::FileDescriptor , DebugString) ;
-RCPP_FUNCTION_1(S4_FileDescriptor, METHOD(as_Message), Rcpp::XPtr<GPB::FileDescriptor> d ){
+RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FileDescriptor> d ){
GPB::FileDescriptorProto* message = new GPB::FileDescriptorProto() ;
d->CopyTo( message );
- return message ;
+ return S4_Message( message ) ;
}
Modified: pkg/src/wrapper_Message.cpp
===================================================================
--- pkg/src/wrapper_Message.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_Message.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -57,16 +57,6 @@
#undef METHOD
#define METHOD(__NAME__) RCPP_PP_CAT(Message__,__NAME__)
-/* same as above, but get the type from the message */
-SEXP new_RS4_Message_( const GPB::Message* message ){
-
- Rcpp::S4 oo( "Message" ) ;
- Rcpp::XPtr<GPB::Message> xp(message, true ) ;
- oo.slot("pointer") = xp ;
- oo.slot("type" ) = message->GetDescriptor()->full_name() ;
- return oo ;
-}
-
/**
* clone a message
*
@@ -413,7 +403,6 @@
}
}
}
- return R_NilValue ;
}
/**
@@ -621,11 +610,11 @@
}
-RCPP_FUNCTION_2( bool, identical_messages, Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m1){
+RCPP_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> m1, double tol){
+RCPP_FUNCTION_3( bool, all_equal_messages, Rcpp::XPtr<GPB::Message> m1, Rcpp::XPtr<GPB::Message> m2, double tol){
return identical_messages_( m1, m2, tol ) ;
}
@@ -669,7 +658,7 @@
GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field );
if( values == R_NilValue || LENGTH(values) == 0 ){
- return(R_NilValue);
+ return ;
}
if( field_desc->is_repeated() ){
@@ -945,7 +934,7 @@
* @param field name or tag number of the field
* @param index
*/
- RCPP_FUNCTION_3( SEXP, METHOD(get_field_values), Rcpp::XPtr<GPB::Message>, SEXP field, Rcpp::IntegerVector index ){
+ RCPP_FUNCTION_3( SEXP, METHOD(get_field_values), Rcpp::XPtr<GPB::Message> message, SEXP field, Rcpp::IntegerVector index ){
GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field ) ;
if( !field_desc->is_repeated() ){
@@ -1145,8 +1134,9 @@
case STRSXP:
{
Rcpp::CharacterVector vals( values );
+ std::string val ;
for( int i=0; i<n; i++){
- std::string val = vals[i] ;
+ val = vals[i] ;
const GPB::EnumValueDescriptor* evd = enum_desc->FindValueByName(val) ;
ref->SetRepeatedEnum( message, field_desc, i, evd ) ;
}
Modified: pkg/src/wrapper_MethodDescriptor.cpp
===================================================================
--- pkg/src/wrapper_MethodDescriptor.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_MethodDescriptor.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -7,10 +7,10 @@
RCPP_XP_METHOD_0( METHOD(as_character) , GPB::MethodDescriptor , DebugString)
-RCPP_FUNCTION_1(S4_MethodDescriptor, METHOD(as_Message), Rcpp::XPtr<GPB::MethodDescriptor> d ){
+RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::MethodDescriptor> d ){
GPB::MethodDescriptorProto* message = new GPB::MethodDescriptorProto() ;
d->CopyTo( message );
- return message ;
+ return S4_Message( message ) ;
}
RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::MethodDescriptor> desc){
Modified: pkg/src/wrapper_ServiceDescriptor.cpp
===================================================================
--- pkg/src/wrapper_ServiceDescriptor.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_ServiceDescriptor.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -40,10 +40,10 @@
return res;
}
- RCPP_FUNCTION_1(S4_ServiceDescriptor, METHOD(as_Message), Rcpp::XPtr<GPB::ServiceDescriptor> d ){
+ RCPP_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::ServiceDescriptor> d ){
GPB::ServiceDescriptorProto* message = new GPB::ServiceDescriptorProto() ;
d->CopyTo( message );
- return message ;
+ return S4_Message( message ) ;
}
RCPP_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::ServiceDescriptor> desc){
Modified: pkg/src/wrapper_ZeroCopyInputStream.cpp
===================================================================
--- pkg/src/wrapper_ZeroCopyInputStream.cpp 2010-07-14 17:33:46 UTC (rev 328)
+++ pkg/src/wrapper_ZeroCopyInputStream.cpp 2010-07-14 18:33:36 UTC (rev 329)
@@ -12,7 +12,7 @@
if( !res ){
throw std::range_error( "cannot read from stream" ) ;
} else{
- result.assign( reinterpret_cast<Rbyte*>(in), reinterpret_cast<Rbyte*>(in) + s ) ;
+ result.assign( reinterpret_cast<const Rbyte*>(in), reinterpret_cast<const Rbyte*>(in) + s ) ;
}
return result ;
}
More information about the Rprotobuf-commits
mailing list