]> www.ginac.de Git - cln.git/blob - src/complex/misc/cl_N_as.cc
* include/cln/number.h (As): Fix it in namespace by suffixing `_As'
[cln.git] / src / complex / misc / cl_N_as.cc
1 // cl_N_As().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/complex.h"
8
9
10 // Implementation.
11
12 #include "cl_N.h"
13
14 namespace cln {
15
16 // Cf. cl_N_p in cl_C_ring.cc.
17 // But here, for better inlining in g++, it is preferrable to finish every
18 // alternative with either "return cl_true;" or "return cl_false;".
19
20 inline cl_boolean cl_N_p (const cl_number& x)
21 {
22         if (!x.pointer_p())
23                 switch (x.nonpointer_tag()) {
24                 case cl_FN_tag:
25                 case cl_SF_tag:
26                 #if defined(CL_WIDE_POINTERS)
27                 case cl_FF_tag:
28                 #endif
29                         return cl_true;
30                 }
31         else
32                 if (x.pointer_type()->flags & cl_class_flags_subclass_complex)
33                         return cl_true;
34         return cl_false;
35 }
36
37 const cl_N& cl_N_As (const cl_number& x, const char * filename, int line)
38 {
39         if (cl_N_p(x)) {
40                 DeclareType(cl_N,x);
41                 return x;
42         } else
43                 cl_as_error(x,"a number",filename,line);
44 }
45
46 }  // namespace cln