]> www.ginac.de Git - cln.git/blobdiff - src/complex/ring/cl_C_ring.cc
Use paths relative the `src' directory in the #include directives.
[cln.git] / src / complex / ring / cl_C_ring.cc
index 296971aaa327c64e34af28a6aae503723cb5f400..ab941c8b6ac72b8e219c0f392aab6f54b27dc670 100644 (file)
@@ -1,9 +1,7 @@
 // Ring of complex numbers.
 
 // General includes.
-#include "cl_sysdep.h"
-
-CL_PROVIDE(cl_C_ring)
+#include "base/cl_sysdep.h"
 
 // Specification.
 #include "cln/complex_ring.h"
@@ -13,7 +11,7 @@ CL_PROVIDE(cl_C_ring)
 
 #include "cln/complex.h"
 #include "cln/complex_io.h"
-#include "cl_C.h"
+#include "complex/cl_C.h"
 
 namespace cln {
 
@@ -144,19 +142,34 @@ static void cl_complex_ring_dprint (cl_heap* pointer)
        fprint(cl_debugout, "(cl_complex_ring) cl_C_ring");
 }
 
-cl_class cl_class_complex_ring = {
-       cl_complex_ring_destructor,
-       cl_class_flags_number_ring,
-       cl_complex_ring_dprint
-};
+cl_class cl_class_complex_ring;
+static cl_heap_complex_ring* cl_heap_complex_ring_instance;
+const cl_complex_ring cl_C_ring = cl_C_ring;
 
 // Constructor.
 template <>
 inline cl_complex_ring::cl_specialized_number_ring ()
-       : cl_number_ring (new cl_heap_complex_ring()) {}
+       : cl_number_ring(cl_heap_complex_ring_instance) { }
+
+int cl_C_ring_init_helper::count = 0;
+
+cl_C_ring_init_helper::cl_C_ring_init_helper()
+{
+       if (count++ == 0) {
+               cl_class_complex_ring.destruct = cl_complex_ring_destructor;
+               cl_class_complex_ring.flags = cl_class_flags_number_ring;
+               cl_class_complex_ring.dprint = cl_complex_ring_dprint;
+               cl_heap_complex_ring_instance = new cl_heap_complex_ring();
+               new ((void *)&cl_C_ring) cl_complex_ring();
+       }
+}
 
-const cl_complex_ring cl_C_ring;
+cl_C_ring_init_helper::~cl_C_ring_init_helper()
+{
+       if (--count == 0) {
+               delete cl_heap_complex_ring_instance;
+       }
+}
 
 }  // namespace cln
 
-CL_PROVIDE_END(cl_C_ring)