X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=src%2Fpolynomial%2Felem%2Fcl_UP_named.cc;h=dd797347e9067d8429f63545f3c6f01a3c25e354;hb=8b3d91dec77438c0fe679b10869ab29e6cdeba58;hp=959f08ba6caa2ef741cea814e7ff003870045455;hpb=dd9e0f894eec7e2a8cf85078330ddc0a6639090b;p=cln.git diff --git a/src/polynomial/elem/cl_UP_named.cc b/src/polynomial/elem/cl_UP_named.cc index 959f08b..dd79734 100644 --- a/src/polynomial/elem/cl_UP_named.cc +++ b/src/polynomial/elem/cl_UP_named.cc @@ -1,4 +1,4 @@ -// cl_find_univpoly_ring(). +// find_univpoly_ring(). // General includes. #include "cl_sysdep.h" @@ -6,13 +6,15 @@ CL_PROVIDE(cl_UP_named) // Specification. -#include "cl_univpoly.h" +#include "cln/univpoly.h" // Implementation. #include "cl_UP.h" +namespace cln { + // Create a new univariate polynomial ring with a named variable. static inline cl_heap_univpoly_ring* cl_make_univpoly_ring (const cl_ring& r, const cl_symbol& varname) @@ -22,25 +24,28 @@ static inline cl_heap_univpoly_ring* cl_make_univpoly_ring (const cl_ring& r, co return UPR; } +} // namespace cln // The table of univariate polynomial rings with named variable. // A weak hash table (cl_ring,cl_symbol) -> cl_univpoly_ring. #include "cl_rcpointer2_hashweak_rcpointer.h" +namespace cln { + // An entry can be collected when the value (the ring) isn't referenced any more // except from the hash table, and when the keys (the base ring and the name) // are't referenced any more except from the hash table and the ring. Note that // the ring contains exactly one reference to the base ring and exactly one // reference to the name (on the property list). -static cl_boolean maygc_htentry (const cl_htentry_from_rcpointer2_to_rcpointer& entry) +static bool maygc_htentry (const cl_htentry_from_rcpointer2_to_rcpointer& entry) { if (!entry.key1.pointer_p() || (entry.key1.heappointer->refcount == 2)) if (!entry.key2.pointer_p() || (entry.key2.heappointer->refcount == 2)) if (!entry.val.pointer_p() || (entry.val.heappointer->refcount == 1)) - return cl_true; - return cl_false; + return true; + return false; } static const cl_wht_from_rcpointer2_to_rcpointer univpoly_ring_table = cl_wht_from_rcpointer2_to_rcpointer(maygc_htentry); @@ -57,7 +62,7 @@ static inline void store_univpoly_ring (const cl_univpoly_ring& R) } -const cl_univpoly_ring cl_find_univpoly_ring (const cl_ring& r, const cl_symbol& varname) +const cl_univpoly_ring find_univpoly_ring (const cl_ring& r, const cl_symbol& varname) { var cl_univpoly_ring* ring_in_table = get_univpoly_ring(r,varname); if (!ring_in_table) { @@ -65,9 +70,11 @@ const cl_univpoly_ring cl_find_univpoly_ring (const cl_ring& r, const cl_symbol& store_univpoly_ring(R); ring_in_table = get_univpoly_ring(r,varname); if (!ring_in_table) - cl_abort(); + throw runtime_exception(); } return *ring_in_table; } +} // namespace cln + CL_PROVIDE_END(cl_UP_named)