@@ -9,6 +9,8 @@ Licensed under MIT License, see LICENSE.md
9
9
__precompile__ ()
10
10
module PCRE2
11
11
12
+ const V6_COMPAT = VERSION < v " 0.7.0-DEV"
13
+
12
14
if VERSION >= v " 0.7.0-DEV.3382"
13
15
import Libdl
14
16
end
28
30
29
31
const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
30
32
31
- @static if VERSION < v " v0.7.0-DEV "
33
+ @static if V6_COMPAT
32
34
macro preserve (args... )
33
35
syms = args[1 : end - 1 ]
34
36
for x in syms
35
37
isa (x, Symbol) || error (" Preserved variable must be a symbol" )
36
38
end
37
39
esc (quote ; $ (args[end ]) ; end )
38
40
end
39
- ev (s ) = eval (parse (s ))
41
+ evr (str, rep, sub ) = eval (current_module (), parse (replace (str, rep, sub) ))
40
42
const Nothing = Void
41
43
const Cvoid = Void
42
44
_ncodeunits (:: Type{UInt8} , s) = sizeof (s)
@@ -46,7 +48,7 @@ const CodeUnitTypes = Union{UInt8, UInt16, UInt32}
46
48
create_vector (T, len) = Vector {T} (len)
47
49
else # !V6_COMPAT
48
50
import Base. GC: @preserve
49
- ev (s ) = eval (Meta. parse (s ))
51
+ evr (str, rep, sub ) = Core . eval (@__MODULE__ , Meta. parse (replace (str, rep => sub) ))
50
52
const _ncodeunits = ncodeunits
51
53
create_vector (T, len) = Vector {T} (undef, len)
52
54
end
@@ -62,9 +64,8 @@ for siz in (8,16,32), (nam, ret, sig) in funclist
62
64
l = SubString (" a,b,c,d,e,f,g,h,i,j,k,l,m" , 1 , length (sig)* 2 - 1 )
63
65
# parms = string(["$('a'+i-1)::$(sig[i]), " for i=1:length(sig)]...)[1:end-1]
64
66
sub = " UInt$siz "
65
- rep = " PCRE2._UCHAR"
66
67
str = " $nam (::Type{$sub },$l )=ccall((:pcre2_$(nam) _$siz , libpcre2_$siz ),$ret ,$sig ,$l )"
67
- ev ( @static VERSION < v " v0.7.0-DEV " ? replace (str, rep, sub) : replace (str, rep => sub) )
68
+ evr (str, " PCRE2._UCHAR " , sub)
68
69
end
69
70
70
71
const UNSET = ~ Csize_t (0 ) # Indicates that an output vector element is unset
0 commit comments