-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPyComplex.cpp
More file actions
37 lines (28 loc) · 941 Bytes
/
Copy pathPyComplex.cpp
File metadata and controls
37 lines (28 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "PyComplex.hpp"
#include "runtime/PyObject.hpp"
#include "runtime/PyType.hpp"
#include "runtime/types/api.hpp"
using namespace py;
PyComplex::PyComplex(PyType *type) : PyBaseObject(type) {}
PyComplex::PyComplex(TypePrototype &type, std::complex<BigIntType> complex)
: PyBaseObject(type), m_complex(std::move(complex))
{}
PyComplex::PyComplex(PyType *type, std::complex<BigIntType> complex)
: PyBaseObject(type), m_complex(std::move(complex))
{}
PyType *PyComplex::static_type() const { return types::complex(); }
namespace {
std::once_flag complex_flag;
std::unique_ptr<TypePrototype> register_complex()
{
return std::move(klass<PyComplex>("complex").type);
}
}// namespace
std::function<std::unique_ptr<TypePrototype>()> PyComplex::type_factory()
{
return [] {
static std::unique_ptr<TypePrototype> type = nullptr;
std::call_once(complex_flag, []() { type = register_complex(); });
return std::move(type);
};
}