aboutsummaryrefslogtreecommitdiff
path: root/src/dctv/pyobj.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dctv/pyobj.cpp')
-rw-r--r--src/dctv/pyobj.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/dctv/pyobj.cpp b/src/dctv/pyobj.cpp
new file mode 100644
index 0000000..91e956b
--- /dev/null
+++ b/src/dctv/pyobj.cpp
@@ -0,0 +1,32 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#include "pyobj.h"
+
+namespace dctv {
+
+PyObject*
+tp_alloc_for_gc(PyTypeObject* type, Py_ssize_t n) noexcept
+{
+ assert(PyType_IS_GC(type));
+ assert(n == 0);
+ return PyObject_GC_New(PyObject, type);
+}
+
+PyObject*
+return_self(PyObject* obj) noexcept
+{
+ return addref(obj).release();
+}
+
+} // namespace dctv