-
-
Save isuruf/4fcb76eaf27daa820bc7b9d1c7a0df50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/mathops.jl b/src/mathops.jl | |
index 09f85ca..42bb7c5 100644 | |
--- a/src/mathops.jl | |
+++ b/src/mathops.jl | |
@@ -49,19 +49,23 @@ for op in [:IM, :PI, :E, :EulerGamma] | |
eval(Expr(:export, op)) | |
end | |
-function init_constants() | |
- for (op, libnm) in [(:IM, :I), | |
- (:PI, :pi), | |
- (:E, :E), | |
- (:EulerGamma, :EulerGamma) | |
- ] | |
- tup = (Base.Symbol("basic_const_$libnm"), libsymengine) | |
- @eval begin | |
- ccall((:basic_new_stack, libsymengine), Void, (Ptr{Basic}, ), &($op)) | |
+macro init_constant(op, libnm) | |
+ tup = (Base.Symbol("basic_const_$libnm"), libsymengine) | |
+ alloc_tup = (:basic_new_stack, libsymengine) | |
+ :( | |
+ begin | |
+ ccall($alloc_tup, Void, (Ptr{Basic}, ), &($op)) | |
ccall($tup, Void, (Ptr{Basic}, ), &($op)) | |
finalizer($op, basic_free) | |
end | |
- end | |
+ ) | |
+end | |
+ | |
+function init_constants() | |
+ @init_constant IM I | |
+ @init_constant PI pi | |
+ @init_constant E E | |
+ @init_constant EulerGamma EulerGamma | |
end | |
## ## Conversions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment