this repo has no description
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
2#include "api-handle.h"
3#include "bytecode.h"
4#include "dict-builtins.h"
5#include "interpreter.h"
6#include "runtime.h"
7
8namespace py {
9
10PY_EXPORT PyObject* _PyNamespace_New(PyObject* kwds) {
11 Thread* thread = Thread::current();
12 HandleScope scope(thread);
13 Runtime* runtime = thread->runtime();
14 Object result(&scope, NoneType::object());
15 if (kwds == nullptr) {
16 result = thread->invokeFunction0(ID(builtins), ID(SimpleNamespace));
17 } else {
18 Object type(&scope, runtime->lookupNameInModule(thread, ID(builtins),
19 ID(SimpleNamespace)));
20 thread->stackPush(*type);
21 thread->stackPush(runtime->emptyTuple());
22 thread->stackPush(ApiHandle::asObject(ApiHandle::fromPyObject(kwds)));
23 result = Interpreter::callEx(thread, CallFunctionExFlag::VAR_KEYWORDS);
24 }
25 if (result.isError()) {
26 return nullptr;
27 }
28 return ApiHandle::newReferenceWithManaged(runtime, *result);
29}
30
31} // namespace py