]> www.ginac.de Git - cln.git/blob - src/integer/misc/cl_I_as.cc
* include/cln/number.h (As): Fix it in namespace by suffixing `_As'
[cln.git] / src / integer / misc / cl_I_as.cc
1 // cl_I_As().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "cl_N.h"
13
14 namespace cln {
15
16 // Cf. cl_I_p in cl_I_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_I_p (const cl_number& x)
21 {
22         if (!x.pointer_p())
23                 switch (x.nonpointer_tag()) {
24                 case cl_FN_tag:
25                         return cl_true;
26                 }
27         else
28                 if (x.pointer_type() == &cl_class_bignum)
29                         return cl_true;
30         return cl_false;
31 }
32
33 const cl_I& cl_I_As (const cl_number& x, const char * filename, int line)
34 {
35         if (cl_I_p(x)) {
36                 DeclareType(cl_I,x);
37                 return x;
38         } else
39                 cl_as_error(x,"an integer",filename,line);
40 }
41
42 }  // namespace cln