@@ -9,7 +9,7 @@ macro_rules! replace_expr {
9
9
10
10
#[ macro_export]
11
11
macro_rules! count_tts {
12
- ( $( $tts: tt) * ) => { 0usize $( + replace_expr!( $tts 1usize ) ) * } ;
12
+ ( $( $tts: tt) * ) => { 0usize $( + $crate :: replace_expr!( $tts 1usize ) ) * } ;
13
13
}
14
14
15
15
#[ macro_export]
@@ -20,6 +20,8 @@ macro_rules! type_check {
20
20
let arg = & $args. args[ $arg_count] ;
21
21
22
22
if !$crate:: obj:: objtype:: isinstance( arg, & expected_type) {
23
+ use $crate:: pyobject:: TypeProtocol ;
24
+
23
25
let arg_typ = arg. class( ) ;
24
26
let expected_type_name = $vm. to_pystr( & expected_type) ?;
25
27
let actual_type = $vm. to_pystr( & arg_typ) ?;
@@ -45,14 +47,14 @@ macro_rules! arg_check {
45
47
}
46
48
} ;
47
49
( $vm: ident, $args: ident, required=[ $( ( $arg_name: ident, $arg_type: expr) ) ,* ] ) => {
48
- arg_check!( $vm, $args, required=[ $( ( $arg_name, $arg_type) ) ,* ] , optional=[ ] ) ;
50
+ $crate :: arg_check!( $vm, $args, required=[ $( ( $arg_name, $arg_type) ) ,* ] , optional=[ ] ) ;
49
51
} ;
50
52
( $vm: ident, $args: ident, required=[ $( ( $arg_name: ident, $arg_type: expr) ) ,* ] , optional=[ $( ( $optional_arg_name: ident, $optional_arg_type: expr) ) ,* ] ) => {
51
53
let mut arg_count = 0 ;
52
54
53
55
// use macro magic to compile-time count number of required and optional arguments
54
- let minimum_arg_count = count_tts!( $( $arg_name) * ) ;
55
- let maximum_arg_count = minimum_arg_count + count_tts!( $( $optional_arg_name) * ) ;
56
+ let minimum_arg_count = $crate :: count_tts!( $( $arg_name) * ) ;
57
+ let maximum_arg_count = minimum_arg_count + $crate :: count_tts!( $( $optional_arg_name) * ) ;
56
58
57
59
// verify that the number of given arguments is right
58
60
if $args. args. len( ) < minimum_arg_count || $args. args. len( ) > maximum_arg_count {
@@ -72,7 +74,7 @@ macro_rules! arg_check {
72
74
// check if the type matches. If not, return with error
73
75
// assign the arg to a variable
74
76
$(
75
- type_check!( $vm, $args, arg_count, $arg_name, $arg_type) ;
77
+ $crate :: type_check!( $vm, $args, arg_count, $arg_name, $arg_type) ;
76
78
let $arg_name = & $args. args[ arg_count] ;
77
79
#[ allow( unused_assignments) ]
78
80
{
@@ -85,7 +87,7 @@ macro_rules! arg_check {
85
87
// assign the arg to a variable
86
88
$(
87
89
let $optional_arg_name = if arg_count < $args. args. len( ) {
88
- type_check!( $vm, $args, arg_count, $optional_arg_name, $optional_arg_type) ;
90
+ $crate :: type_check!( $vm, $args, arg_count, $optional_arg_name, $optional_arg_type) ;
89
91
let ret = Some ( & $args. args[ arg_count] ) ;
90
92
#[ allow( unused_assignments) ]
91
93
{
@@ -226,7 +228,7 @@ macro_rules! match_class {
226
228
( $obj: expr, $binding: ident @ $class: ty => $expr: expr, $( $rest: tt) * ) => {
227
229
match $obj. downcast:: <$class>( ) {
228
230
Ok ( $binding) => $expr,
229
- Err ( _obj) => match_class!( _obj, $( $rest) * ) ,
231
+ Err ( _obj) => $crate :: match_class!( _obj, $( $rest) * ) ,
230
232
}
231
233
} ;
232
234
@@ -236,7 +238,7 @@ macro_rules! match_class {
236
238
if $obj. payload_is:: <$class>( ) {
237
239
$expr
238
240
} else {
239
- match_class!( $obj, $( $rest) * )
241
+ $crate :: match_class!( $obj, $( $rest) * )
240
242
}
241
243
} ;
242
244
}
0 commit comments