@@ -436,108 +436,48 @@ function init_pyconvert_extratypes()
436436 )
437437end
438438
439- function pyconvert_rule_specs ()
440- return PyConvertRuleSpec[
441- (func = pyconvert_rule_none, tname = " builtins:NoneType" , type = Nothing, scope = Any),
442- (func = pyconvert_rule_bool, tname = " builtins:bool" , type = Bool, scope = Any),
443- (func = pyconvert_rule_float, tname = " builtins:float" , type = Float64, scope = Any),
444- (
445- func = pyconvert_rule_complex,
446- tname = " builtins:complex" ,
447- type = Complex{Float64},
448- scope = Any,
449- ),
450- (func = pyconvert_rule_int, tname = " numbers:Integral" , type = Integer, scope = Any),
451- (func = pyconvert_rule_str, tname = " builtins:str" , type = String, scope = Any),
452- (
453- func = pyconvert_rule_bytes,
454- tname = " builtins:bytes" ,
455- type = Base. CodeUnits{UInt8,String},
456- scope = Any,
457- ),
458- (
459- func = pyconvert_rule_range,
460- tname = " builtins:range" ,
461- type = StepRange{<: Integer ,<: Integer },
462- scope = Any,
463- ),
464- (
465- func = pyconvert_rule_fraction,
466- tname = " numbers:Rational" ,
467- type = Rational{<: Integer },
468- scope = Any,
469- ),
470- (func = pyconvert_rule_iterable, tname = " builtins:tuple" , type = NamedTuple, scope = Any),
471- (func = pyconvert_rule_iterable, tname = " builtins:tuple" , type = Tuple, scope = Any),
472- (func = pyconvert_rule_datetime, tname = " datetime:datetime" , type = DateTime, scope = Any),
473- (func = pyconvert_rule_date, tname = " datetime:date" , type = Date, scope = Any),
474- (func = pyconvert_rule_time, tname = " datetime:time" , type = Time, scope = Any),
475- (
476- func = pyconvert_rule_timedelta,
477- tname = " datetime:timedelta" ,
478- type = Microsecond,
479- scope = Any,
480- ),
481- (
482- func = pyconvert_rule_exception,
483- tname = " builtins:BaseException" ,
484- type = PyException,
485- scope = Any,
486- ),
487- (func = pyconvert_rule_none, tname = " builtins:NoneType" , type = Missing, scope = Missing),
488- (func = pyconvert_rule_bool, tname = " builtins:bool" , type = Number, scope = Number),
489- (func = pyconvert_rule_float, tname = " numbers:Real" , type = Number, scope = Number),
490- (func = pyconvert_rule_float, tname = " builtins:float" , type = Nothing, scope = Nothing),
491- (func = pyconvert_rule_float, tname = " builtins:float" , type = Missing, scope = Missing),
492- (func = pyconvert_rule_complex, tname = " numbers:Complex" , type = Number, scope = Number),
493- (func = pyconvert_rule_int, tname = " numbers:Integral" , type = Number, scope = Number),
494- (func = pyconvert_rule_str, tname = " builtins:str" , type = Symbol, scope = Symbol),
495- (func = pyconvert_rule_str, tname = " builtins:str" , type = Char, scope = Char),
496- (func = pyconvert_rule_bytes, tname = " builtins:bytes" , type = Vector{UInt8}, scope = Vector{UInt8}),
497- (
498- func = pyconvert_rule_range,
499- tname = " builtins:range" ,
500- type = UnitRange{<: Integer },
501- scope = UnitRange{<: Integer },
502- ),
503- (func = pyconvert_rule_fraction, tname = " numbers:Rational" , type = Number, scope = Number),
504- (
505- func = pyconvert_rule_iterable,
506- tname = " collections.abc:Iterable" ,
507- type = Vector,
508- scope = Vector,
509- ),
510- (func = pyconvert_rule_iterable, tname = " collections.abc:Iterable" , type = Tuple, scope = Tuple),
511- (func = pyconvert_rule_iterable, tname = " collections.abc:Iterable" , type = Pair, scope = Pair),
512- (func = pyconvert_rule_iterable, tname = " collections.abc:Iterable" , type = Set, scope = Set),
513- (
514- func = pyconvert_rule_iterable,
515- tname = " collections.abc:Sequence" ,
516- type = Vector,
517- scope = Vector,
518- ),
519- (func = pyconvert_rule_iterable, tname = " collections.abc:Sequence" , type = Tuple, scope = Tuple),
520- (func = pyconvert_rule_iterable, tname = " collections.abc:Set" , type = Set, scope = Set),
521- (func = pyconvert_rule_mapping, tname = " collections.abc:Mapping" , type = Dict, scope = Dict),
522- (
523- func = pyconvert_rule_timedelta,
524- tname = " datetime:timedelta" ,
525- type = Millisecond,
526- scope = Millisecond,
527- ),
528- (func = pyconvert_rule_timedelta, tname = " datetime:timedelta" , type = Second, scope = Second),
529- (
530- func = pyconvert_rule_timedelta,
531- tname = " datetime:timedelta" ,
532- type = Nanosecond,
533- scope = Nanosecond,
534- ),
535- ]
439+ function register_pyconvert_rules! ()
440+ pyconvert_add_rule (pyconvert_rule_none, " builtins:NoneType" , Nothing, Any)
441+ pyconvert_add_rule (pyconvert_rule_bool, " builtins:bool" , Bool, Any)
442+ pyconvert_add_rule (pyconvert_rule_float, " builtins:float" , Float64, Any)
443+ pyconvert_add_rule (pyconvert_rule_complex, " builtins:complex" , Complex{Float64}, Any)
444+ pyconvert_add_rule (pyconvert_rule_int, " numbers:Integral" , Integer, Any)
445+ pyconvert_add_rule (pyconvert_rule_str, " builtins:str" , String, Any)
446+ pyconvert_add_rule (pyconvert_rule_bytes, " builtins:bytes" , Base. CodeUnits{UInt8,String}, Any)
447+ pyconvert_add_rule (pyconvert_rule_range, " builtins:range" , StepRange{<: Integer ,<: Integer }, Any)
448+ pyconvert_add_rule (pyconvert_rule_fraction, " numbers:Rational" , Rational{<: Integer }, Any)
449+ pyconvert_add_rule (pyconvert_rule_iterable, " builtins:tuple" , NamedTuple, Any)
450+ pyconvert_add_rule (pyconvert_rule_iterable, " builtins:tuple" , Tuple, Any)
451+ pyconvert_add_rule (pyconvert_rule_datetime, " datetime:datetime" , DateTime, Any)
452+ pyconvert_add_rule (pyconvert_rule_date, " datetime:date" , Date, Any)
453+ pyconvert_add_rule (pyconvert_rule_time, " datetime:time" , Time, Any)
454+ pyconvert_add_rule (pyconvert_rule_timedelta, " datetime:timedelta" , Microsecond, Any)
455+ pyconvert_add_rule (pyconvert_rule_exception, " builtins:BaseException" , PyException, Any)
456+ pyconvert_add_rule (pyconvert_rule_none, " builtins:NoneType" , Missing, Missing)
457+ pyconvert_add_rule (pyconvert_rule_bool, " builtins:bool" , Number, Number)
458+ pyconvert_add_rule (pyconvert_rule_float, " numbers:Real" , Number, Number)
459+ pyconvert_add_rule (pyconvert_rule_float, " builtins:float" , Nothing, Nothing)
460+ pyconvert_add_rule (pyconvert_rule_float, " builtins:float" , Missing, Missing)
461+ pyconvert_add_rule (pyconvert_rule_complex, " numbers:Complex" , Number, Number)
462+ pyconvert_add_rule (pyconvert_rule_int, " numbers:Integral" , Number, Number)
463+ pyconvert_add_rule (pyconvert_rule_str, " builtins:str" , Symbol, Symbol)
464+ pyconvert_add_rule (pyconvert_rule_str, " builtins:str" , Char, Char)
465+ pyconvert_add_rule (pyconvert_rule_bytes, " builtins:bytes" , Vector{UInt8}, Vector{UInt8})
466+ pyconvert_add_rule (pyconvert_rule_range, " builtins:range" , UnitRange{<: Integer }, UnitRange{<: Integer })
467+ pyconvert_add_rule (pyconvert_rule_fraction, " numbers:Rational" , Number, Number)
468+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Iterable" , Vector, Vector)
469+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Iterable" , Tuple, Tuple)
470+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Iterable" , Pair, Pair)
471+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Iterable" , Set, Set)
472+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Sequence" , Vector, Vector)
473+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Sequence" , Tuple, Tuple)
474+ pyconvert_add_rule (pyconvert_rule_iterable, " collections.abc:Set" , Set, Set)
475+ pyconvert_add_rule (pyconvert_rule_mapping, " collections.abc:Mapping" , Dict, Dict)
476+ pyconvert_add_rule (pyconvert_rule_timedelta, " datetime:timedelta" , Millisecond, Millisecond)
477+ pyconvert_add_rule (pyconvert_rule_timedelta, " datetime:timedelta" , Second, Second)
478+ pyconvert_add_rule (pyconvert_rule_timedelta, " datetime:timedelta" , Nanosecond, Nanosecond)
536479end
537480
538- pyconvert_fallback_rule_specs () = PyConvertRuleSpec[(
539- func = pyconvert_rule_object,
540- tname = " builtins:object" ,
541- type = Py,
542- scope = Any,
543- )]
481+ function register_pyconvert_fallback_rules! ()
482+ pyconvert_add_rule (pyconvert_rule_object, " builtins:object" , Py, Any)
483+ end
0 commit comments