File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed
Expand file tree Collapse file tree 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -12,19 +12,12 @@ const _FT_TYPE_REPLACEMENTS = Dict{Symbol,Symbol}(
1212 :PyJuliaValueObject => :PyJuliaValueObjectFT ,
1313)
1414
15- _ft_replace (sym:: Symbol ) = get (_FT_TYPE_REPLACEMENTS, sym, sym)
16-
1715function _ft_transform (ex)
1816 if ex isa Symbol
19- return _ft_replace ( ex)
17+ return get (_FT_TYPE_REPLACEMENTS, ex, ex)
2018 elseif ex isa QuoteNode
21- v = ex. value
22- return v isa Symbol ? QuoteNode (_ft_replace (v)) : ex
19+ return QuoteNode (_ft_transform (ex. value))
2320 elseif ex isa Expr
24- # Handle dotted refs like `C.PyObject` (Expr(:., ...)).
25- if ex. head === :. && length (ex. args) == 2 && ex. args[2 ] isa QuoteNode && ex. args[2 ]. value isa Symbol
26- return Expr (:., _ft_transform (ex. args[1 ]), QuoteNode (_ft_replace (ex. args[2 ]. value)))
27- end
2821 return Expr (ex. head, map (_ft_transform, ex. args)... )
2922 else
3023 return ex
@@ -43,12 +36,8 @@ CTX.is_free_threaded` throughout the code.
4336"""
4437macro ft (ex)
4538 ex_ft = _ft_transform (ex)
46- ctx = GlobalRef (@__MODULE__ , :CTX )
47- return esc (:(if $ ctx. is_free_threaded
48- $ ex_ft
49- else
50- $ ex
51- end ))
39+ m = @__MODULE__
40+ return esc (:($ m. CTX. is_free_threaded ? $ ex_ft : $ ex))
5241end
5342
5443Py_Type (x) = Base. GC. @preserve x @ft PyPtr (UnsafePtr {PyObject} (asptr (x)). type[! ])
You can’t perform that action at this time.
0 commit comments