1
0
mirror of https://github.com/exaloop/codon.git synced 2025-06-03 15:03:52 +08:00

Add PyFunction::keywords field

This commit is contained in:
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,6 +756,9 @@ 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;
if (pyfunc.keywords) {
flag = PYEXT_METH_FASTCALL | PYEXT_METH_KEYWORDS;
} else {
switch (pyfunc.nargs) { switch (pyfunc.nargs) {
case 0: case 0:
flag = PYEXT_METH_NOARGS; flag = PYEXT_METH_NOARGS;
@ -767,6 +770,7 @@ void LLVMVisitor::writeToPythonExtension(const PyModule &pymod,
flag = PYEXT_METH_FASTCALL; flag = PYEXT_METH_FASTCALL;
break; break;
} }
}
switch (pyfunc.type) { switch (pyfunc.type) {
case PyFunction::CLASS: case PyFunction::CLASS:

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;
}; };