@@ -220,7 +220,9 @@ namespace upywrap
220
220
static mp_obj_t AsPyObj ( T* p, bool own )
221
221
{
222
222
if ( own )
223
+ {
223
224
return AsPyObj ( native_obj_t ( p ) );
225
+ }
224
226
return AsPyObj ( native_obj_t ( p, NoDelete ) );
225
227
}
226
228
#else
@@ -343,7 +345,9 @@ namespace upywrap
343
345
{
344
346
auto ret = map.find ( attr );
345
347
if ( ret == map.end () )
348
+ {
346
349
return nullptr ;
350
+ }
347
351
return ret->second ;
348
352
}
349
353
@@ -352,7 +356,9 @@ namespace upywrap
352
356
{
353
357
const auto attrValue = FindAttrMaybe ( map, attr );
354
358
if ( !attrValue )
359
+ {
355
360
RaiseAttributeException ( type.name , attr );
361
+ }
356
362
return attrValue;
357
363
}
358
364
@@ -381,7 +387,9 @@ namespace upywrap
381
387
this_type* self = (this_type*) self_in;
382
388
const auto attrValue = FindAttrMaybe ( self->getters , attr );
383
389
if ( attrValue )
390
+ {
384
391
*dest = attrValue->Call ( self );
392
+ }
385
393
}
386
394
}
387
395
@@ -405,7 +413,9 @@ namespace upywrap
405
413
auto self = (this_type*) self_in;
406
414
auto other = (this_type*) other_in;
407
415
if ( op != MP_BINARY_OP_EQUAL )
416
+ {
408
417
return MP_OBJ_NULL; // not supported
418
+ }
409
419
return ToPy ( self->GetPtr () == other->GetPtr () );
410
420
}
411
421
@@ -461,7 +471,9 @@ namespace upywrap
461
471
static void CheckTypeIsRegistered ()
462
472
{
463
473
if ( type.base .type == nullptr )
474
+ {
464
475
RaiseTypeException ( (std::string ( " Native type " ) + typeid ( T ).name () + " has not been registered" ).data () );
476
+ }
465
477
}
466
478
467
479
void AddFunctionToTable ( const qstr name, mp_obj_t fun )
@@ -480,7 +492,9 @@ namespace upywrap
480
492
typedef NativeMemberCall< name, Ret, A... > call_type;
481
493
auto callerObject = call_type::CreateCaller ( f );
482
494
if ( conv )
495
+ {
483
496
callerObject->convert_retval = conv;
497
+ }
484
498
functionPointers[ (void *) name ] = callerObject;
485
499
AddFunctionToTable ( name (), call_type::CreateUPyFunction () );
486
500
}
@@ -626,7 +640,9 @@ namespace upywrap
626
640
static mp_obj_t MakeNew ( const mp_obj_type_t *, mp_uint_t n_args, mp_uint_t , const mp_obj_t *args )
627
641
{
628
642
if ( n_args != sizeof ...( A ) )
643
+ {
629
644
RaiseTypeException ( " Wrong number of arguments for constructor" );
645
+ }
630
646
auto f = (init_call_type*) this_type::functionPointers[ (void *) index ];
631
647
UPYWRAP_TRY
632
648
return AsPyObj ( native_obj_t ( Apply ( f, args, make_index_sequence< sizeof ...( A ) >() ) ) );
@@ -644,7 +660,9 @@ namespace upywrap
644
660
static mp_obj_t CallN ( mp_uint_t n_args, const mp_obj_t * args )
645
661
{
646
662
if ( n_args != sizeof ...( A ) + 1 )
663
+ {
647
664
RaiseTypeException ( " Wrong number of arguments" );
665
+ }
648
666
auto self = (this_type*) args[ 0 ];
649
667
auto firstArg = &args[ 1 ];
650
668
auto f = (call_type*) this_type::functionPointers[ (void *) index ];
@@ -791,7 +809,9 @@ namespace upywrap
791
809
// Return None instead which is either useful (e.g. used as 'optional' return value),
792
810
// or will lead to an actual Python exception when used anyway.
793
811
if ( !p )
812
+ {
794
813
return mp_const_none;
814
+ }
795
815
return ClassWrapper< T >::AsPyObj ( std::move ( p ) );
796
816
}
797
817
};
0 commit comments