Skip to content

Commit 9c393c3

Browse files
authored
Merge pull request #118 from isuruf/compat
Julia v0.7 support
2 parents 4b0615b + 3d299ea commit 9c393c3

File tree

16 files changed

+216
-201
lines changed

16 files changed

+216
-201
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
julia 0.6
2-
Compat 0.25.0
2+
Compat 0.63.0
33
RecipesBase 0.0.6
44
BinDeps 0.4.0
55
Conda 0.4.0

deps/build.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
using BinDeps
22
using Compat
3+
import BinDeps: lower
34
using Conda
45

6+
if VERSION > VersionNumber("0.7.0-DEV")
7+
# TODO: Remove this hack when BinDeps is fixed
8+
lower(s::Base.Process, c::BinDeps.SynchronousStepCollection) = nothing
9+
end
10+
511
@BinDeps.setup
612

713
# Use x.y.z for downloading binaries, but only check for x.y in shared libraries

src/SymEngine.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ __precompile__()
33
module SymEngine
44

55
import Base: show, convert, real, imag
6-
import Compat: String, unsafe_string, @compat, denominator, numerator, invokelatest
6+
import Compat: String, unsafe_string, @compat, denominator, numerator, invokelatest, Cvoid, Nothing, MathConstants.γ, MathConstants.e, MathConstants.φ, MathConstants.catalan, LinearAlgebra, finalizer, Libdl
77

88
export Basic, symbols, @vars, @funs, SymFunction
99
export free_symbols, get_args
@@ -26,6 +26,12 @@ const have_mpfr = have_component("mpfr")
2626
const have_mpc = have_component("mpc")
2727
const libversion = get_libversion()
2828

29+
if VERSION > VersionNumber("0.7.0-DEV")
30+
_finalizer(f, o) = finalizer(f, o)
31+
else
32+
_finalizer(f, o) = finalizer(o, f)
33+
end
34+
2935
include("types.jl")
3036
include("ctypes.jl")
3137
include("display.jl")

src/calculus.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Base: diff
99

1010
function diff(b1::SymbolicType, b2::BasicType{Val{:Symbol}})
1111
a = Basic()
12-
ret = ccall((:basic_diff, libsymengine), Int, (Ptr{Basic}, Ptr{Basic}, Ptr{Basic}), &a, &b1, &b2)
12+
ret = ccall((:basic_diff, libsymengine), Int, (Ref{Basic}, Ref{Basic}, Ref{Basic}), a, b1, b2)
1313
return a
1414
end
1515

src/ctypes.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# types from SymEngine to Julia
22
## CSetBasic
3-
type CSetBasic
4-
ptr::Ptr{Void}
3+
mutable struct CSetBasic
4+
ptr::Ptr{Cvoid}
55
end
66

77
function CSetBasic()
8-
z = CSetBasic(ccall((:setbasic_new, libsymengine), Ptr{Void}, ()))
9-
finalizer(z, CSetBasic_free)
8+
z = CSetBasic(ccall((:setbasic_new, libsymengine), Ptr{Cvoid}, ()))
9+
_finalizer(CSetBasic_free, z)
1010
z
1111
end
1212

1313
function CSetBasic_free(x::CSetBasic)
1414
if x.ptr != C_NULL
15-
ccall((:setbasic_free, libsymengine), Void, (Ptr{Void},), x.ptr)
15+
ccall((:setbasic_free, libsymengine), Nothing, (Ptr{Cvoid},), x.ptr)
1616
x.ptr = C_NULL
1717
end
1818
end
1919

2020
function Base.length(s::CSetBasic)
21-
ccall((:setbasic_size, libsymengine), UInt, (Ptr{Void},), s.ptr)
21+
ccall((:setbasic_size, libsymengine), UInt, (Ptr{Cvoid},), s.ptr)
2222
end
2323

2424
function Base.getindex(s::CSetBasic, n::UInt)
2525
result = Basic()
26-
ccall((:setbasic_get, libsymengine), Void, (Ptr{Void}, UInt, Ptr{Basic}), s.ptr, n, &result)
26+
ccall((:setbasic_get, libsymengine), Nothing, (Ptr{Cvoid}, UInt, Ref{Basic}), s.ptr, n, result)
2727
result
2828
end
2929

@@ -35,30 +35,30 @@ Base.convert(::Type{Set}, x::CSetBasic) = Set(convert(Vector, x))
3535

3636
## VecBasic Need this for get_args...
3737

38-
type CVecBasic
39-
ptr::Ptr{Void}
38+
mutable struct CVecBasic
39+
ptr::Ptr{Cvoid}
4040
end
4141

4242
function CVecBasic()
43-
z = CVecBasic(ccall((:vecbasic_new, libsymengine), Ptr{Void}, ()))
44-
finalizer(z, CVecBasic_free)
43+
z = CVecBasic(ccall((:vecbasic_new, libsymengine), Ptr{Cvoid}, ()))
44+
_finalizer(CVecBasic_free, z)
4545
z
4646
end
4747

4848
function CVecBasic_free(x::CVecBasic)
4949
if x.ptr != C_NULL
50-
ccall((:vecbasic_free, libsymengine), Void, (Ptr{Void},), x.ptr)
50+
ccall((:vecbasic_free, libsymengine), Nothing, (Ptr{Cvoid},), x.ptr)
5151
x.ptr = C_NULL
5252
end
5353
end
5454

5555
function Base.length(s::CVecBasic)
56-
ccall((:vecbasic_size, libsymengine), UInt, (Ptr{Void},), s.ptr)
56+
ccall((:vecbasic_size, libsymengine), UInt, (Ptr{Cvoid},), s.ptr)
5757
end
5858

5959
function Base.getindex(s::CVecBasic, n::UInt)
6060
result = Basic()
61-
ccall((:vecbasic_get, libsymengine), Void, (Ptr{Void}, UInt, Ptr{Basic}), s.ptr, n, &result)
61+
ccall((:vecbasic_get, libsymengine), Nothing, (Ptr{Cvoid}, UInt, Ref{Basic}), s.ptr, n, result)
6262
result
6363
end
6464

@@ -68,13 +68,13 @@ function Base.convert(::Type{Vector}, x::CVecBasic)
6868
end
6969

7070
## CMapBasicBasic
71-
type CMapBasicBasic
72-
ptr::Ptr{Void}
71+
mutable struct CMapBasicBasic
72+
ptr::Ptr{Cvoid}
7373
end
7474

7575
function CMapBasicBasic()
76-
z = CMapBasicBasic(ccall((:mapbasicbasic_new, libsymengine), Ptr{Void}, ()))
77-
finalizer(z, CMapBasicBasic_free)
76+
z = CMapBasicBasic(ccall((:mapbasicbasic_new, libsymengine), Ptr{Cvoid}, ()))
77+
_finalizer(CMapBasicBasic_free, z)
7878
z
7979
end
8080

@@ -88,59 +88,59 @@ end
8888

8989
function CMapBasicBasic_free(x::CMapBasicBasic)
9090
if x.ptr != C_NULL
91-
ccall((:mapbasicbasic_free, libsymengine), Void, (Ptr{Void},), x.ptr)
91+
ccall((:mapbasicbasic_free, libsymengine), Nothing, (Ptr{Cvoid},), x.ptr)
9292
x.ptr = C_NULL
9393
end
9494
end
9595

9696
function Base.length(s::CMapBasicBasic)
97-
ccall((:mapbasicbasic_size, libsymengine), UInt, (Ptr{Void},), s.ptr)
97+
ccall((:mapbasicbasic_size, libsymengine), UInt, (Ptr{Cvoid},), s.ptr)
9898
end
9999

100100
function Base.getindex(s::CMapBasicBasic, k::Basic)
101101
result = Basic()
102-
ret = ccall((:mapbasicbasic_get, libsymengine), Cint, (Ptr{Void}, Ptr{Basic}, Ptr{Basic}), s.ptr, &k, &result)
102+
ret = ccall((:mapbasicbasic_get, libsymengine), Cint, (Ptr{Cvoid}, Ref{Basic}, Ref{Basic}), s.ptr, k, result)
103103
if ret == 0
104104
throw(KeyError("Key not found"))
105105
end
106106
result
107107
end
108108

109109
function Base.setindex!(s::CMapBasicBasic, k::Basic, v::Basic)
110-
ccall((:mapbasicbasic_insert, libsymengine), Void, (Ptr{Void}, Ptr{Basic}, Ptr{Basic}), s.ptr, &k, &v)
110+
ccall((:mapbasicbasic_insert, libsymengine), Nothing, (Ptr{Cvoid}, Ref{Basic}, Ref{Basic}), s.ptr, k, v)
111111
end
112112

113113
Base.convert(::Type{CMapBasicBasic}, x::Dict{Any, Any}) = CMapBasicBasic(x)
114114

115115
## Dense matrix
116116

117-
type CDenseMatrix <: DenseArray{Basic, 2}
118-
ptr::Ptr{Void}
117+
mutable struct CDenseMatrix <: DenseArray{Basic, 2}
118+
ptr::Ptr{Cvoid}
119119
end
120120

121-
Base.promote_rule{T <: Basic}(::Type{CDenseMatrix}, ::Type{Matrix{T}} ) = CDenseMatrix
121+
Base.promote_rule(::Type{CDenseMatrix}, ::Type{Matrix{T}} ) where {T <: Basic} = CDenseMatrix
122122

123123
function CDenseMatrix_free(x::CDenseMatrix)
124124
if x.ptr != C_NULL
125-
ccall((:dense_matrix_free, libsymengine), Void, (Ptr{Void},), x.ptr)
125+
ccall((:dense_matrix_free, libsymengine), Nothing, (Ptr{Cvoid},), x.ptr)
126126
x.ptr = C_NULL
127127
end
128128
end
129129

130130
function CDenseMatrix()
131-
z = CDenseMatrix(ccall((:dense_matrix_new, libsymengine), Ptr{Void}, ()))
132-
finalizer(z, CDenseMatrix_free)
131+
z = CDenseMatrix(ccall((:dense_matrix_new, libsymengine), Ptr{Cvoid}, ()))
132+
_finalizer(CDenseMatrix_free, z)
133133
z
134134
end
135135

136136
function CDenseMatrix(m::Int, n::Int)
137-
z = CDenseMatrix(ccall((:dense_matrix_new_rows_cols, libsymengine), Ptr{Void}, (Int, Int), m, n))
138-
finalizer(z, CDenseMatrix_free)
137+
z = CDenseMatrix(ccall((:dense_matrix_new_rows_cols, libsymengine), Ptr{Cvoid}, (Int, Int), m, n))
138+
_finalizer(CDenseMatrix_free, z)
139139
z
140140
end
141141

142142

143-
function CDenseMatrix{T}(x::Array{T, 2})
143+
function CDenseMatrix(x::Array{T, 2}) where T
144144
r,c = size(x)
145145
M = CDenseMatrix(r, c)
146146
for j in 1:c
@@ -157,14 +157,14 @@ function Base.convert(::Type{Matrix}, x::CDenseMatrix)
157157
[x[i,j] for i in 1:m, j in 1:n]
158158
end
159159

160-
Base.convert{T}(::Type{CDenseMatrix}, x::Array{T, 2}) = CDenseMatrix(x)
161-
Base.convert{T}(::Type{CDenseMatrix}, x::Array{T, 1}) = convert(CDenseMatrix, reshape(x, length(x), 1))
160+
Base.convert(::Type{CDenseMatrix}, x::Array{T, 2}) where {T} = CDenseMatrix(x)
161+
Base.convert(::Type{CDenseMatrix}, x::Array{T, 1}) where {T} = convert(CDenseMatrix, reshape(x, length(x), 1))
162162

163163

164164
function toString(b::CDenseMatrix)
165-
a = ccall((:dense_matrix_str, libsymengine), Cstring, (Ptr{Void}, ), b.ptr)
165+
a = ccall((:dense_matrix_str, libsymengine), Cstring, (Ptr{Cvoid}, ), b.ptr)
166166
string = unsafe_string(a)
167-
ccall((:basic_str_free, libsymengine), Void, (Cstring, ), a)
167+
ccall((:basic_str_free, libsymengine), Nothing, (Cstring, ), a)
168168
string = replace(string, "**", "^") # de pythonify
169169
return string
170170
end

0 commit comments

Comments
 (0)