this repo has no description
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
2// boolobject.c implementation
3
4#include "cpython-data.h"
5
6#include "api-handle.h"
7#include "objects.h"
8#include "runtime.h"
9
10namespace py {
11
12PY_EXPORT PyTypeObject* PyBool_Type_Ptr() {
13 Runtime* runtime = Thread::current()->runtime();
14 return reinterpret_cast<PyTypeObject*>(
15 ApiHandle::borrowedReference(runtime, runtime->typeAt(LayoutId::kBool)));
16}
17
18PY_EXPORT PyObject* PyTrue_Ptr() {
19 return ApiHandle::handleFromImmediate(Bool::trueObj());
20}
21
22PY_EXPORT PyObject* PyFalse_Ptr() {
23 return ApiHandle::handleFromImmediate(Bool::falseObj());
24}
25
26PY_EXPORT int PyBool_Check_Func(PyObject* obj) {
27 return ApiHandle::asObject(ApiHandle::fromPyObject(obj)).isBool();
28}
29
30PY_EXPORT PyObject* PyBool_FromLong(long v) {
31 return ApiHandle::handleFromImmediate(Bool::fromBool(v));
32}
33
34} // namespace py