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