11# types from SymEngine to Julia
22# # CSetBasic
3- type CSetBasic
4- ptr:: Ptr{Void }
3+ mutable struct CSetBasic
4+ ptr:: Ptr{Cvoid }
55end
66
77function 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
1111end
1212
1313function 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
1818end
1919
2020function Base. length (s:: CSetBasic )
21- ccall ((:setbasic_size , libsymengine), UInt, (Ptr{Void },), s. ptr)
21+ ccall ((:setbasic_size , libsymengine), UInt, (Ptr{Cvoid },), s. ptr)
2222end
2323
2424function 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
2828end
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 }
4040end
4141
4242function 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
4646end
4747
4848function 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
5353end
5454
5555function Base. length (s:: CVecBasic )
56- ccall ((:vecbasic_size , libsymengine), UInt, (Ptr{Void },), s. ptr)
56+ ccall ((:vecbasic_size , libsymengine), UInt, (Ptr{Cvoid },), s. ptr)
5757end
5858
5959function 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
6363end
6464
@@ -68,13 +68,13 @@ function Base.convert(::Type{Vector}, x::CVecBasic)
6868end
6969
7070# # CMapBasicBasic
71- type CMapBasicBasic
72- ptr:: Ptr{Void }
71+ mutable struct CMapBasicBasic
72+ ptr:: Ptr{Cvoid }
7373end
7474
7575function 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
7979end
8080
8888
8989function 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
9494end
9595
9696function Base. length (s:: CMapBasicBasic )
97- ccall ((:mapbasicbasic_size , libsymengine), UInt, (Ptr{Void },), s. ptr)
97+ ccall ((:mapbasicbasic_size , libsymengine), UInt, (Ptr{Cvoid },), s. ptr)
9898end
9999
100100function 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
107107end
108108
109109function 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)
111111end
112112
113113Base. 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 }
119119end
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
123123function 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
128128end
129129
130130function 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
134134end
135135
136136function 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
140140end
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]
158158end
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
164164function 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
170170end
0 commit comments