|
1 |
| -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- |
2 |
| -// |
| 1 | + |
3 | 2 | // class.h: Rcpp R/C++ interface class library -- Rcpp modules
|
4 | 3 | //
|
5 | 4 | // Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois
|
|
136 | 135 | SEXP newInstance( SEXP* args, int nargs ){
|
137 | 136 | BEGIN_RCPP
|
138 | 137 | signed_constructor_class* p ;
|
139 |
| - int n = constructors.size() ; |
140 |
| - for( int i=0; i<n; i++ ){ |
| 138 | + size_t n = constructors.size() ; |
| 139 | + for( size_t i=0; i<n; i++ ){ |
141 | 140 | p = constructors[i];
|
142 | 141 | bool ok = (p->valid)(args, nargs) ;
|
143 | 142 | if( ok ){
|
|
148 | 147 |
|
149 | 148 | signed_factory_class* pfact ;
|
150 | 149 | n = factories.size() ;
|
151 |
| - for( int i=0; i<n; i++){ |
| 150 | + for( size_t i=0; i<n; i++){ |
152 | 151 | pfact = factories[i] ;
|
153 | 152 | bool ok = (pfact->valid)(args, nargs) ;
|
154 | 153 | if( ok ){
|
|
162 | 161 | }
|
163 | 162 |
|
164 | 163 | bool has_default_constructor(){
|
165 |
| - int n = constructors.size() ; |
| 164 | + size_t n = constructors.size() ; |
166 | 165 | signed_constructor_class* p ;
|
167 |
| - for( int i=0; i<n; i++ ){ |
| 166 | + for( size_t i=0; i<n; i++ ){ |
168 | 167 | p = constructors[i];
|
169 | 168 | if( p->nargs() == 0 ) return true ;
|
170 | 169 | }
|
171 | 170 | n = factories.size() ;
|
172 | 171 | signed_factory_class* pfact ;
|
173 |
| - for( int i=0; i<n; i++ ){ |
| 172 | + for( size_t i=0; i<n; i++ ){ |
174 | 173 | pfact = factories[i];
|
175 | 174 | if( pfact->nargs() == 0 ) return true ;
|
176 | 175 | }
|
|
182 | 181 |
|
183 | 182 | vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
|
184 | 183 | typename vec_signed_method::iterator it = mets->begin() ;
|
185 |
| - int n = mets->size() ; |
| 184 | + size_t n = mets->size() ; |
186 | 185 | method_class* m = 0 ;
|
187 | 186 | bool ok = false ;
|
188 |
| - for( int i=0; i<n; i++, ++it ){ |
| 187 | + for( size_t i=0; i<n; i++, ++it ){ |
189 | 188 | if( ( (*it)->valid )( args, nargs) ){
|
190 | 189 | m = (*it)->method ;
|
191 | 190 | ok = true ;
|
|
209 | 208 |
|
210 | 209 | vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
|
211 | 210 | typename vec_signed_method::iterator it = mets->begin() ;
|
212 |
| - int n = mets->size() ; |
| 211 | + size_t n = mets->size() ; |
213 | 212 | method_class* m = 0 ;
|
214 | 213 | bool ok = false ;
|
215 |
| - for( int i=0; i<n; i++, ++it ){ |
| 214 | + for( size_t i=0; i<n; i++, ++it ){ |
216 | 215 | if( ( (*it)->valid )( args, nargs) ){
|
217 | 216 | m = (*it)->method ;
|
218 | 217 | ok = true ;
|
|
231 | 230 |
|
232 | 231 | vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( R_ExternalPtrAddr( method_xp ) ) ;
|
233 | 232 | typename vec_signed_method::iterator it = mets->begin() ;
|
234 |
| - int n = mets->size() ; |
| 233 | + size_t n = mets->size() ; |
235 | 234 | method_class* m = 0 ;
|
236 | 235 | bool ok = false ;
|
237 |
| - for( int i=0; i<n; i++, ++it ){ |
| 236 | + for( size_t i=0; i<n; i++, ++it ){ |
238 | 237 | if( ( (*it)->valid )( args, nargs) ){
|
239 | 238 | m = (*it)->method ;
|
240 | 239 | ok = true ;
|
|
326 | 325 | }
|
327 | 326 |
|
328 | 327 | Rcpp::CharacterVector method_names(){
|
329 |
| - int n = 0 ; |
330 |
| - int s = vec_methods.size() ; |
| 328 | + size_t n = 0 ; |
| 329 | + size_t s = vec_methods.size() ; |
331 | 330 | typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
|
332 |
| - for( int i=0; i<s; i++, ++it){ |
| 331 | + for( size_t i=0; i<s; i++, ++it){ |
333 | 332 | n += (it->second)->size() ;
|
334 | 333 | }
|
335 | 334 | Rcpp::CharacterVector out(n) ;
|
336 | 335 | it = vec_methods.begin() ;
|
337 |
| - int k = 0 ; |
338 |
| - for( int i=0; i<s; i++, ++it){ |
| 336 | + size_t k = 0 ; |
| 337 | + for( size_t i=0; i<s; i++, ++it){ |
339 | 338 | n = (it->second)->size() ;
|
340 | 339 | std::string name = it->first ;
|
341 |
| - for( int j=0; j<n; j++, k++){ |
| 340 | + for( size_t j=0; j<n; j++, k++){ |
342 | 341 | out[k] = name ;
|
343 | 342 | }
|
344 | 343 | }
|
345 | 344 | return out ;
|
346 | 345 | }
|
347 | 346 |
|
348 | 347 | Rcpp::IntegerVector methods_arity(){
|
349 |
| - int n = 0 ; |
350 |
| - int s = vec_methods.size() ; |
| 348 | + size_t n = 0 ; |
| 349 | + size_t s = vec_methods.size() ; |
351 | 350 | typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
|
352 |
| - for( int i=0; i<s; i++, ++it){ |
| 351 | + for( size_t i=0; i<s; i++, ++it){ |
353 | 352 | n += (it->second)->size() ;
|
354 | 353 | }
|
355 | 354 | Rcpp::CharacterVector mnames(n) ;
|
356 | 355 | Rcpp::IntegerVector res(n) ;
|
357 | 356 | it = vec_methods.begin() ;
|
358 |
| - int k = 0 ; |
359 |
| - for( int i=0; i<s; i++, ++it){ |
| 357 | + size_t k = 0 ; |
| 358 | + for( size_t i=0; i<s; i++, ++it){ |
360 | 359 | n = (it->second)->size() ;
|
361 | 360 | std::string name = it->first ;
|
362 | 361 | typename vec_signed_method::iterator m_it = (it->second)->begin() ;
|
363 |
| - for( int j=0; j<n; j++, k++, ++m_it){ |
| 362 | + for( size_t j=0; j<n; j++, k++, ++m_it){ |
364 | 363 | mnames[k] = name ;
|
365 | 364 | res[k] = (*m_it)->nargs() ;
|
366 | 365 | }
|
|
370 | 369 | }
|
371 | 370 |
|
372 | 371 | Rcpp::LogicalVector methods_voidness(){
|
373 |
| - int n = 0 ; |
374 |
| - int s = vec_methods.size() ; |
| 372 | + size_t n = 0 ; |
| 373 | + size_t s = vec_methods.size() ; |
375 | 374 | typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
|
376 |
| - for( int i=0; i<s; i++, ++it){ |
| 375 | + for( size_t i=0; i<s; i++, ++it){ |
377 | 376 | n += (it->second)->size() ;
|
378 | 377 | }
|
379 | 378 | Rcpp::CharacterVector mnames(n) ;
|
380 | 379 | Rcpp::LogicalVector res(n) ;
|
381 | 380 | it = vec_methods.begin() ;
|
382 |
| - int k = 0 ; |
383 |
| - for( int i=0; i<s; i++, ++it){ |
| 381 | + size_t k = 0 ; |
| 382 | + for( size_t i=0; i<s; i++, ++it){ |
384 | 383 | n = (it->second)->size() ;
|
385 | 384 | std::string name = it->first ;
|
386 | 385 | typename vec_signed_method::iterator m_it = (it->second)->begin() ;
|
387 |
| - for( int j=0; j<n; j++, k++, ++m_it){ |
| 386 | + for( size_t j=0; j<n; j++, k++, ++m_it){ |
388 | 387 | mnames[k] = name ;
|
389 | 388 | res[k] = (*m_it)->is_void() ;
|
390 | 389 | }
|
|
395 | 394 |
|
396 | 395 |
|
397 | 396 | Rcpp::CharacterVector property_names(){
|
398 |
| - int n = properties.size() ; |
| 397 | + size_t n = properties.size() ; |
399 | 398 | Rcpp::CharacterVector out(n) ;
|
400 | 399 | typename PROPERTY_MAP::iterator it = properties.begin( ) ;
|
401 |
| - for( int i=0; i<n; i++, ++it){ |
| 400 | + for( size_t i=0; i<n; i++, ++it){ |
402 | 401 | out[i] = it->first ;
|
403 | 402 | }
|
404 | 403 | return out ;
|
405 | 404 | }
|
406 | 405 |
|
407 | 406 | Rcpp::List property_classes(){
|
408 |
| - int n = properties.size() ; |
| 407 | + size_t n = properties.size() ; |
409 | 408 | Rcpp::CharacterVector pnames(n) ;
|
410 | 409 | Rcpp::List out(n) ;
|
411 | 410 | typename PROPERTY_MAP::iterator it = properties.begin( ) ;
|
412 |
| - for( int i=0; i<n; i++, ++it){ |
| 411 | + for( size_t i=0; i<n; i++, ++it){ |
413 | 412 | pnames[i] = it->first ;
|
414 | 413 | out[i] = it->second->get_class() ;
|
415 | 414 | }
|
|
418 | 417 | }
|
419 | 418 |
|
420 | 419 | Rcpp::CharacterVector complete(){
|
421 |
| - int n = vec_methods.size() - specials ; |
422 |
| - int ntotal = n + properties.size() ; |
| 420 | + size_t n = vec_methods.size() - specials ; |
| 421 | + size_t ntotal = n + properties.size() ; |
423 | 422 | Rcpp::CharacterVector out(ntotal) ;
|
424 | 423 | typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
|
425 | 424 | std::string buffer ;
|
426 |
| - int i=0 ; |
| 425 | + size_t i=0 ; |
427 | 426 | for( ; i<n; ++it){
|
428 | 427 | buffer = it->first ;
|
429 | 428 | if( buffer[0] == '[' ) continue ;
|
|
459 | 458 |
|
460 | 459 |
|
461 | 460 | Rcpp::List fields( const XP_Class& class_xp ){
|
462 |
| - int n = properties.size() ; |
| 461 | + size_t n = properties.size() ; |
463 | 462 | Rcpp::CharacterVector pnames(n) ;
|
464 | 463 | Rcpp::List out(n) ;
|
465 | 464 | typename PROPERTY_MAP::iterator it = properties.begin( ) ;
|
466 |
| - for( int i=0; i<n; i++, ++it){ |
| 465 | + for( size_t i=0; i<n; i++, ++it){ |
467 | 466 | pnames[i] = it->first ;
|
468 | 467 | out[i] = S4_field<Class>( it->second, class_xp ) ;
|
469 | 468 | }
|
|
476 | 475 | #if RCPP_DEBUG_LEVEL > 0
|
477 | 476 | Rf_PrintValue( class_xp ) ;
|
478 | 477 | #endif
|
479 |
| - int n = vec_methods.size() ; |
| 478 | + size_t n = vec_methods.size() ; |
480 | 479 | Rcpp::CharacterVector mnames(n) ;
|
481 | 480 | Rcpp::List res(n) ;
|
482 | 481 | typename map_vec_signed_method::iterator it = vec_methods.begin( ) ;
|
483 | 482 | vec_signed_method* v;
|
484 |
| - for( int i=0; i<n; i++, ++it){ |
| 483 | + for( size_t i=0; i<n; i++, ++it){ |
485 | 484 | mnames[i] = it->first ;
|
486 | 485 | v = it->second ;
|
487 | 486 | res[i] = S4_CppOverloadedMethods<Class>( v , class_xp, it->first.c_str(), buffer ) ;
|
|
491 | 490 | }
|
492 | 491 |
|
493 | 492 | Rcpp::List getConstructors( const XP_Class& class_xp, std::string& buffer){
|
494 |
| - int n = constructors.size() ; |
| 493 | + size_t n = constructors.size() ; |
495 | 494 | Rcpp::List out(n) ;
|
496 | 495 | typename vec_signed_constructor::iterator it = constructors.begin( ) ;
|
497 |
| - for( int i=0; i<n; i++, ++it){ |
| 496 | + for( size_t i=0; i<n; i++, ++it){ |
498 | 497 | out[i] = S4_CppConstructor<Class>( *it , class_xp, name, buffer ) ;
|
499 | 498 | }
|
500 | 499 | return out ;
|
|
0 commit comments