Skip to content
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

Keyword arguments and generalized unpacking for C++ API #372

Merged
merged 10 commits into from
Sep 6, 2016

Commits on Sep 6, 2016

  1. Configuration menu
    Copy the full SHA
    317524f View commit details
    Browse the repository at this point in the history
  2. Support keyword arguments and generalized unpacking in C++

    A Python function can be called with the syntax:
    ```python
    foo(a1, a2, *args, ka=1, kb=2, **kwargs)
    ```
    This commit adds support for the equivalent syntax in C++:
    ```c++
    foo(a1, a2, *args, "ka"_a=1, "kb"_a=2, **kwargs)
    ```
    
    In addition, generalized unpacking is implemented, as per PEP 448,
    which allows calls with multiple * and ** unpacking:
    ```python
    bar(*args1, 99, *args2, 101, **kwargs1, kz=200, **kwargs2)
    ```
    and
    ```c++
    bar(*args1, 99, *args2, 101, **kwargs1, "kz"_a=200, **kwargs2)
    ```
    dean0x7d committed Sep 6, 2016
    Configuration menu
    Copy the full SHA
    c743e1b View commit details
    Browse the repository at this point in the history
  3. Add py::print() function

    Replicates Python API including keyword arguments.
    dean0x7d committed Sep 6, 2016
    Configuration menu
    Copy the full SHA
    67990d9 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    66aa272 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    15a112f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    625bd48 View commit details
    Browse the repository at this point in the history
  7. Remove superseded handle::operator() overloads

    The variadic handle::operator() offers the same functionality as well
    as mixed positional, keyword, * and ** arguments. The tests are also
    superseded by the ones in `test_callbacks`.
    dean0x7d committed Sep 6, 2016
    Configuration menu
    Copy the full SHA
    16db1bf View commit details
    Browse the repository at this point in the history
  8. Workaround for py::dict() constructor on MSVC

    MSVC fails to compile if the constructor is defined out-of-line.
    The error states that it cannot deduce the type of the default template
    parameter which is used for SFINAE.
    dean0x7d committed Sep 6, 2016
    Configuration menu
    Copy the full SHA
    56e86ed View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    8fe13b8 View commit details
    Browse the repository at this point in the history
  10. Make keyword argument hold a py::object instead of T*

    With this change arg_t is no longer a template, but it must remain so
    for backward compatibility. Thus, a non-template arg_v is introduced,
    while a dummy template alias arg_t is there to keep old code from
    breaking. This can be remove in the next major release.
    
    The implementation of arg_v also needed to be placed a little earlier in
    the headers because it's not a template any more and unpacking_collector
    needs more than a forward declaration.
    dean0x7d committed Sep 6, 2016
    Configuration menu
    Copy the full SHA
    60b2680 View commit details
    Browse the repository at this point in the history