Last change
on this file since 993 was
993,
checked in by pooh, 18 years ago
|
- Fixed a typo in the previous changeset.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
838 bytes
|
Line | |
---|
1 | #ifndef __rf_integer_ih__ |
---|
2 | #define __rf_integer_ih__ |
---|
3 | |
---|
4 | #include "rf_integer.hh" |
---|
5 | #include "rf_expr.ih" |
---|
6 | #include "rf_term.ih" |
---|
7 | #include "pxx_chunk_allocator.ih" |
---|
8 | |
---|
9 | namespace rftype |
---|
10 | { |
---|
11 | |
---|
12 | using namespace rfrt; |
---|
13 | |
---|
14 | inline Integer::Integer (intptr_t _n) : |
---|
15 | Term(type_integer) |
---|
16 | { |
---|
17 | mpz_t* p = mpz_allocator.allocate(); |
---|
18 | ptr_data2 = p; |
---|
19 | mpz_init(*p); |
---|
20 | mpz_set_si(*p, _n); |
---|
21 | } |
---|
22 | |
---|
23 | inline Integer::Integer (pxx::WString& _str) : |
---|
24 | Term(type_integer) |
---|
25 | { |
---|
26 | mpz_t* p = mpz_allocator.allocate(); |
---|
27 | ptr_data2 = p; |
---|
28 | mpz_init(*p); |
---|
29 | size_t len = wcstombs(null, _str.get_data(), 0); |
---|
30 | char* s = static_cast<char*>(alloca(len + 1)); |
---|
31 | wcstombs(s, _str.get_data(), len); |
---|
32 | s[len] = 0; |
---|
33 | mpz_set_str(*p, s, 0); |
---|
34 | } |
---|
35 | |
---|
36 | inline Integer::~Integer () |
---|
37 | { |
---|
38 | mpz_t* p = static_cast<mpz_t*>(ptr_data2); |
---|
39 | mpz_clear(*p); |
---|
40 | mpz_allocator.deallocate(p); |
---|
41 | } |
---|
42 | |
---|
43 | } |
---|
44 | |
---|
45 | #endif // __rf_integer_ih__ |
---|
Note: See
TracBrowser
for help on using the repository browser.