@@ -910,18 +910,18 @@ SEXP rnng_set_opt(SEXP object, SEXP opt, SEXP value) {
910910 break ;
911911 case REALSXP :
912912 case INTSXP :
913- case LGLSXP :
914913 val = Rf_asInteger (value );
915914 xc = nng_socket_set_ms (* sock , op , (nng_duration ) val );
916915 if (xc == 0 ) break ;
917916 xc = nng_socket_set_size (* sock , op , (size_t ) val );
918917 if (xc == 0 ) break ;
919918 xc = nng_socket_set_int (* sock , op , val );
920919 if (xc == 0 ) break ;
921- xc = nng_socket_set_bool (* sock , op , (bool ) val );
922- if (xc == 0 ) break ;
923920 xc = nng_socket_set_uint64 (* sock , op , (uint64_t ) val );
924921 break ;
922+ case LGLSXP :
923+ xc = nng_socket_set_bool (* sock , op , (bool ) LOGICAL (value )[0 ]);
924+ break ;
925925 default :
926926 Rf_error ("type of 'value' not supported" );
927927 }
@@ -938,18 +938,18 @@ SEXP rnng_set_opt(SEXP object, SEXP opt, SEXP value) {
938938 break ;
939939 case REALSXP :
940940 case INTSXP :
941- case LGLSXP :
942941 val = Rf_asInteger (value );
943942 xc = nng_ctx_set_ms (* ctx , op , (nng_duration ) val );
944943 if (xc == 0 ) break ;
945944 xc = nng_ctx_set_size (* ctx , op , (size_t ) val );
946945 if (xc == 0 ) break ;
947946 xc = nng_ctx_set_int (* ctx , op , val );
948947 if (xc == 0 ) break ;
949- xc = nng_ctx_set_bool (* ctx , op , (bool ) val );
950- if (xc == 0 ) break ;
951948 xc = nng_ctx_set_uint64 (* ctx , op , (uint64_t ) val );
952949 break ;
950+ case LGLSXP :
951+ xc = nng_ctx_set_bool (* ctx , op , (bool ) LOGICAL (value )[0 ]);
952+ break ;
953953 default :
954954 Rf_error ("type of 'value' not supported" );
955955 }
@@ -966,18 +966,18 @@ SEXP rnng_set_opt(SEXP object, SEXP opt, SEXP value) {
966966 break ;
967967 case REALSXP :
968968 case INTSXP :
969- case LGLSXP :
970969 val = Rf_asInteger (value );
971970 xc = nng_stream_set_ms (st , op , (nng_duration ) val );
972971 if (xc == 0 ) break ;
973972 xc = nng_stream_set_size (st , op , (size_t ) val );
974973 if (xc == 0 ) break ;
975974 xc = nng_stream_set_int (st , op , val );
976975 if (xc == 0 ) break ;
977- xc = nng_stream_set_bool (st , op , (bool ) val );
978- if (xc == 0 ) break ;
979976 xc = nng_stream_set_uint64 (st , op , (uint64_t ) val );
980977 break ;
978+ case LGLSXP :
979+ xc = nng_stream_set_bool (st , op , (bool ) LOGICAL (value )[0 ]);
980+ break ;
981981 default :
982982 Rf_error ("type of 'value' not supported" );
983983 }
@@ -994,18 +994,18 @@ SEXP rnng_set_opt(SEXP object, SEXP opt, SEXP value) {
994994 break ;
995995 case REALSXP :
996996 case INTSXP :
997- case LGLSXP :
998997 val = Rf_asInteger (value );
999998 xc = nng_listener_set_ms (* list , op , (nng_duration ) val );
1000999 if (xc == 0 ) break ;
10011000 xc = nng_listener_set_size (* list , op , (size_t ) val );
10021001 if (xc == 0 ) break ;
10031002 xc = nng_listener_set_int (* list , op , val );
10041003 if (xc == 0 ) break ;
1005- xc = nng_listener_set_bool (* list , op , (bool ) val );
1006- if (xc == 0 ) break ;
10071004 xc = nng_listener_set_uint64 (* list , op , (uint64_t ) val );
10081005 break ;
1006+ case LGLSXP :
1007+ xc = nng_listener_set_bool (* list , op , (bool ) LOGICAL (value )[0 ]);
1008+ break ;
10091009 default :
10101010 Rf_error ("type of 'value' not supported" );
10111011 }
@@ -1022,18 +1022,18 @@ SEXP rnng_set_opt(SEXP object, SEXP opt, SEXP value) {
10221022 break ;
10231023 case REALSXP :
10241024 case INTSXP :
1025- case LGLSXP :
10261025 val = Rf_asInteger (value );
10271026 xc = nng_dialer_set_ms (* dial , op , (nng_duration ) val );
10281027 if (xc == 0 ) break ;
10291028 xc = nng_dialer_set_size (* dial , op , (size_t ) val );
10301029 if (xc == 0 ) break ;
10311030 xc = nng_dialer_set_int (* dial , op , val );
10321031 if (xc == 0 ) break ;
1033- xc = nng_dialer_set_bool (* dial , op , (bool ) val );
1034- if (xc == 0 ) break ;
10351032 xc = nng_dialer_set_uint64 (* dial , op , (uint64_t ) val );
10361033 break ;
1034+ case LGLSXP :
1035+ xc = nng_dialer_set_bool (* dial , op , (bool ) LOGICAL (value )[0 ]);
1036+ break ;
10371037 default :
10381038 Rf_error ("type of 'value' not supported" );
10391039 }
@@ -1049,12 +1049,12 @@ SEXP rnng_set_opt(SEXP object, SEXP opt, SEXP value) {
10491049
10501050}
10511051
1052- SEXP rnng_subscribe (SEXP object , SEXP type , SEXP value ) {
1052+ SEXP rnng_subscribe (SEXP object , SEXP value , SEXP sub ) {
10531053
10541054 if (TYPEOF (object ) != EXTPTRSXP )
10551055 Rf_error ("'object' is not a valid Socket, Context, Stream, Listener or Dialer" );
10561056
1057- const char * op = INTEGER ( type )[0 ] ? "sub:subscribe" : "sub:unsubscribe" ;
1057+ const char * op = LOGICAL ( sub )[0 ] ? "sub:subscribe" : "sub:unsubscribe" ;
10581058 int xc ;
10591059
10601060 const SEXP ptrtag = R_ExternalPtrTag (object );
0 commit comments