Add PyFunction::keywords field

pull/335/head
A. R. Shajii 2023-03-04 16:46:38 -05:00
parent 7f82194c06
commit 691c1b8fec
2 changed files with 15 additions and 10 deletions

View File

@ -756,16 +756,20 @@ void LLVMVisitor::writeToPythonExtension(const PyModule &pymod,
std::vector<llvm::Constant *> pyMethods; std::vector<llvm::Constant *> pyMethods;
for (auto &pyfunc : functions) { for (auto &pyfunc : functions) {
int flag = 0; int flag = 0;
switch (pyfunc.nargs) { if (pyfunc.keywords) {
case 0: flag = PYEXT_METH_FASTCALL | PYEXT_METH_KEYWORDS;
flag = PYEXT_METH_NOARGS; } else {
break; switch (pyfunc.nargs) {
case 1: case 0:
flag = PYEXT_METH_O; flag = PYEXT_METH_NOARGS;
break; break;
default: case 1:
flag = PYEXT_METH_FASTCALL; flag = PYEXT_METH_O;
break; break;
default:
flag = PYEXT_METH_FASTCALL;
break;
}
} }
switch (pyfunc.type) { switch (pyfunc.type) {

View File

@ -18,6 +18,7 @@ struct PyFunction {
Func *func = nullptr; Func *func = nullptr;
Type type = Type::TOPLEVEL; Type type = Type::TOPLEVEL;
int nargs = 0; int nargs = 0;
bool keywords = false;
bool coexist = false; bool coexist = false;
}; };