Skip to content

Commit 8835cf7

Browse files
committed
shuffle to define types first
1 parent 0c18a0d commit 8835cf7

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/SymEngine.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const have_mpc = have_component("mpc")
2121
const libversion = get_libversion()
2222

2323
include("exceptions.jl")
24-
include("types.jl")
2524
include("ctypes.jl")
25+
include("types.jl")
2626
include("decl.jl")
2727
include("display.jl")
2828
include("mathops.jl")

src/ctypes.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
# types from SymEngine to Julia
2+
3+
## Basic
4+
## Hold a reference to a SymEngine object
5+
mutable struct Basic <: Number
6+
ptr::Ptr{Cvoid}
7+
function Basic()
8+
z = new(C_NULL)
9+
ccall((:basic_new_stack, libsymengine), Nothing, (Ref{Basic}, ), z)
10+
finalizer(basic_free, z)
11+
return z
12+
end
13+
function Basic(v::Ptr{Cvoid})
14+
z = new(v)
15+
return z
16+
end
17+
end
18+
219
## CSetBasic
320
mutable struct CSetBasic
421
ptr::Ptr{Cvoid}
@@ -160,7 +177,7 @@ function CDenseMatrix(x::Array{T, 2}) where T
160177
end
161178

162179

163-
function Base.convert(::Type{Matrix}, x::CDenseMatrix)
180+
function Base.convert(::Type{Matrix}, x::CDenseMatrix)
164181
m,n = Base.size(x)
165182
[x[i,j] for i in 1:m, j in 1:n]
166183
end

src/types.jl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@
1010
##
1111
## To control dispatch, one might have `N(b::Basic) = N(BasicType(b))` and then define `N` for types of interest
1212

13-
## Hold a reference to a SymEngine object
14-
mutable struct Basic <: Number
15-
ptr::Ptr{Cvoid}
16-
function Basic()
17-
z = new(C_NULL)
18-
ccall((:basic_new_stack, libsymengine), Nothing, (Ref{Basic}, ), z)
19-
finalizer(basic_free, z)
20-
return z
21-
end
22-
function Basic(v::Ptr{Cvoid})
23-
z = new(v)
24-
return z
25-
end
26-
end
2713

2814
basic_free(b::Basic) = ccall((:basic_free_stack, libsymengine), Nothing, (Ref{Basic}, ), b)
2915

0 commit comments

Comments
 (0)