-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HPy_CallTupleDict, HPyCallable_Check and HPyTuple_Check. #147
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ffa8004
Add HPy_Call, HPy_CallObject and HPyCallable_Check.
hodgestar 6a38dfa
Reactivate unicode exceptions test.
hodgestar 5c2fc69
Add tests for HPy_Call, HPy_CallObject and HPyCallable_Check.
hodgestar def721e
Replace HPy_Call with HPy_CallTupleDict.
hodgestar cc4cdfe
Implement initial HPy_CallTupleDict.
hodgestar 3ef7267
Update UnicodeError tests to HPy_CallTupleDict.
hodgestar c14af6f
Implement HPy_CallTupleDict cases where args or kw are NULL.
hodgestar d4954f7
Update HPy_CallTupleDict tests.
hodgestar 342bfa0
Update tests to match expected HPy_CallTupleDict behaviour.
hodgestar 98f448a
Add HPyTuple_Check.
hodgestar 287e63b
Add type checking for handles used to pass arguments to HPy_CallTuple…
hodgestar b6540a2
Use keywords for argument_combination arguments.
hodgestar 085542f
Add microbenchmarks for HPy_CallTupleDict.
hodgestar 49c6b7e
Merge branch 'master' into feature/add-hpy-call
hodgestar 39da59f
Add porting docs for HPy_CallTupleDict.
hodgestar c520f3e
Add test for HPyTuple_Check.
hodgestar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef HPY_COMMON_RUNTIME_CALL_H | ||
#define HPY_COMMON_RUNTIME_CALL_H | ||
|
||
#include <Python.h> | ||
#include "hpy.h" | ||
|
||
_HPy_HIDDEN HPy | ||
ctx_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw); | ||
|
||
#endif /* HPY_COMMON_RUNTIME_CALL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <Python.h> | ||
#include "hpy.h" | ||
|
||
#ifdef HPY_UNIVERSAL_ABI | ||
// for _h2py and _py2h | ||
# include "handles.h" | ||
#endif | ||
|
||
_HPy_HIDDEN HPy | ||
ctx_CallTupleDict(HPyContext ctx, HPy callable, HPy args, HPy kw) | ||
{ | ||
PyObject *obj; | ||
if (!HPy_IsNull(args) && !HPyTuple_Check(ctx, args)) { | ||
HPyErr_SetString(ctx, ctx->h_TypeError, | ||
"HPy_CallTupleDict requires args to be a tuple or null handle"); | ||
return HPy_NULL; | ||
} | ||
if (!HPy_IsNull(kw) && !HPyDict_Check(ctx, kw)) { | ||
HPyErr_SetString(ctx, ctx->h_TypeError, | ||
"HPy_CallTupleDict requires kw to be a dict or null handle"); | ||
return HPy_NULL; | ||
} | ||
if (HPy_IsNull(kw)) { | ||
obj = PyObject_CallObject(_h2py(callable), _h2py(args)); | ||
} | ||
else if (!HPy_IsNull(args)){ | ||
obj = PyObject_Call(_h2py(callable), _h2py(args), _h2py(kw)); | ||
} | ||
else { | ||
// args is null, but kw is not, so we need to create an empty args tuple | ||
// for CPython's PyObject_Call | ||
HPy items[] = {}; | ||
HPy empty_tuple = HPyTuple_FromArray(ctx, items, 0); | ||
obj = PyObject_Call(_h2py(callable), _h2py(empty_tuple), _h2py(kw)); | ||
HPy_Close(ctx, empty_tuple); | ||
} | ||
return _py2h(obj); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, nice catch. I didn't know that CPython doesn't have a way to pass only kwargs. I don't know if it will be actually useful but it doesn't cost anything to add support for it, so it's probably a good idea to be more complete, +1