Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
b1b71402
Commit
b1b71402
authored
Oct 18, 2015
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consistent macro naming throughout the project
parent
041a8656
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
150 additions
and
150 deletions
+150
-150
.travis.yml
+2
-2
CMakeLists.txt
+3
-3
docs/advanced.rst
+9
-9
docs/basics.rst
+2
-2
docs/classes.rst
+1
-1
docs/reference.rst
+2
-2
example/example.cpp
+1
-1
example/example12.cpp
+2
-2
example/example8.cpp
+1
-1
include/pybind11/cast.h
+33
-33
include/pybind11/common.h
+11
-11
include/pybind11/complex.h
+3
-3
include/pybind11/functional.h
+1
-1
include/pybind11/numpy.h
+11
-11
include/pybind11/operators.h
+42
-42
include/pybind11/pybind11.h
+8
-8
include/pybind11/pytypes.h
+16
-16
include/pybind11/stl.h
+2
-2
No files found.
.travis.yml
View file @
b1b71402
...
...
@@ -16,7 +16,7 @@ matrix:
compiler
:
gcc-4.8
script
:
-
pyvenv-3.5 venv
-
cmake -DPYBIND_PYTHON_VERSION=3.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.5m -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -DPYTHON_EXECUTABLE:FILEPATH=`pwd`/venv/bin/python3.5 -DCMAKE_CXX_COMPILER=g++-4.8
-
cmake -DPYBIND
11
_PYTHON_VERSION=3.5 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.5m -DPYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -DPYTHON_EXECUTABLE:FILEPATH=`pwd`/venv/bin/python3.5 -DCMAKE_CXX_COMPILER=g++-4.8
-
make -j 2
-
source venv/bin/activate
-
pip install numpy
...
...
@@ -24,6 +24,6 @@ matrix:
-
os
:
osx
compiler
:
clang
script
:
-
cmake -DPYBIND_PYTHON_VERSION=2.7
-
cmake -DPYBIND
11
_PYTHON_VERSION=2.7
-
make -j 2
-
CTEST_OUTPUT_ON_FAILURE=TRUE make test
CMakeLists.txt
View file @
b1b71402
...
...
@@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 2.8)
project
(
pybind11
)
# Add a CMake parameter for choosing a desired Python version
set
(
PYBIND_PYTHON_VERSION
""
CACHE STRING
"Python version to use for compiling the example application"
)
set
(
PYBIND
11
_PYTHON_VERSION
""
CACHE STRING
"Python version to use for compiling the example application"
)
# Set a default build configuration if none is specified. 'MinSizeRel' produces the smallest binaries
if
(
NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES
)
...
...
@@ -22,8 +22,8 @@ endif()
string
(
TOUPPER
"
${
CMAKE_BUILD_TYPE
}
"
U_CMAKE_BUILD_TYPE
)
set
(
Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6
)
find_package
(
PythonLibs
${
PYBIND_PYTHON_VERSION
}
REQUIRED
)
find_package
(
PythonInterp
${
PYBIND_PYTHON_VERSION
}
REQUIRED
)
find_package
(
PythonLibs
${
PYBIND
11
_PYTHON_VERSION
}
REQUIRED
)
find_package
(
PythonInterp
${
PYBIND
11
_PYTHON_VERSION
}
REQUIRED
)
if
(
UNIX
)
# Enable C++11 mode
...
...
docs/advanced.rst
View file @
b1b71402
...
...
@@ -45,7 +45,7 @@ to Python.
#include <pybind11/operators.h>
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Vector2>(m, "Vector2")
...
...
@@ -127,7 +127,7 @@ trivial to generate binding code for both of these functions.
#include <pybind11/functional.h>
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("func_arg", &func_arg);
...
...
@@ -199,7 +199,7 @@ Normally, the binding code for these classes would look as follows:
.. code-block:: cpp
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Animal> animal(m, "Animal");
...
...
@@ -230,7 +230,7 @@ helper class that is defined as follows:
/* Trampoline (need one for each virtual function) */
std::string go(int n_times) {
PYBIND_OVERLOAD_PURE(
PYBIND
11
_OVERLOAD_PURE(
std::string, /* Return type */
Animal, /* Parent class */
go, /* Name of function */
...
...
@@ -239,15 +239,15 @@ helper class that is defined as follows:
}
};
The macro :func:`PYBIND_OVERLOAD_PURE` should be used for pure virtual
functions, and :func:`PYBIND_OVERLOAD` should be used for functions which have
The macro :func:`PYBIND
11
_OVERLOAD_PURE` should be used for pure virtual
functions, and :func:`PYBIND
11
_OVERLOAD` should be used for functions which have
a default implementation. The binding code also needs a few minor adaptations
(highlighted):
.. code-block:: cpp
:emphasize-lines: 4,6,7
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<PyAnimal> animal(m, "Animal");
...
...
@@ -375,7 +375,7 @@ See below for an example that uses the
Internal internal;
};
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Example>(m, "Example")
...
...
@@ -441,7 +441,7 @@ be declared at the top level before any binding code:
.. code-block:: cpp
PYBIND_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
PYBIND
11
_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
.. seealso::
...
...
docs/basics.rst
View file @
b1b71402
...
...
@@ -87,7 +87,7 @@ a file named :file:`example.cpp` with the following contents:
namespace py = pybind11;
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("add", &add, "A function which adds two numbers");
...
...
@@ -95,7 +95,7 @@ a file named :file:`example.cpp` with the following contents:
return m.ptr();
}
The :func:`PYBIND_PLUGIN` macro creates a function that will be called when an
The :func:`PYBIND
11
_PLUGIN` macro creates a function that will be called when an
``import`` statement is issued from within Python. The next line creates a
module named ``example`` (with the supplied docstring). The method
:func:`module::def` generates binding code that exposes the
...
...
docs/classes.rst
View file @
b1b71402
...
...
@@ -27,7 +27,7 @@ The binding code for ``Pet`` looks as follows:
namespace py = pybind11;
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Pet>(m, "Pet")
...
...
docs/reference.rst
View file @
b1b71402
...
...
@@ -12,7 +12,7 @@ Reference
Macros
======
.. function:: PYBIND_PLUGIN(const char *name)
.. function:: PYBIND
11
_PLUGIN(const char *name)
This macro creates the entry point that will be invoked when the Python
interpreter imports a plugin library. Please create a
...
...
@@ -21,7 +21,7 @@ Macros
.. code-block:: cpp
PYBIND_PLUGIN(example) {
PYBIND
11
_PLUGIN(example) {
pybind11::module m("example", "pybind11 example plugin");
/// Set up bindings here
return m.ptr();
...
...
example/example.cpp
View file @
b1b71402
...
...
@@ -22,7 +22,7 @@ void init_ex10(py::module &);
void
init_ex11
(
py
::
module
&
);
void
init_ex12
(
py
::
module
&
);
PYBIND_PLUGIN
(
example
)
{
PYBIND
11
_PLUGIN
(
example
)
{
py
::
module
m
(
"example"
,
"pybind example plugin"
);
init_ex1
(
m
);
...
...
example/example12.cpp
View file @
b1b71402
...
...
@@ -39,7 +39,7 @@ public:
virtual
int
run
(
int
value
)
{
/* Generate wrapping code that enables native function overloading */
PYBIND_OVERLOAD
(
PYBIND
11
_OVERLOAD
(
int
,
/* Return type */
Example12
,
/* Parent class */
run
,
/* Name of function */
...
...
@@ -48,7 +48,7 @@ public:
}
virtual
void
pure_virtual
()
{
PYBIND_OVERLOAD_PURE
(
PYBIND
11
_OVERLOAD_PURE
(
void
,
/* Return type */
Example12
,
/* Parent class */
pure_virtual
/* Name of function */
...
...
example/example8.cpp
View file @
b1b71402
...
...
@@ -32,7 +32,7 @@ private:
};
/// Make pybind aware of the ref-counted wrapper type
PYBIND_DECLARE_HOLDER_TYPE
(
T
,
ref
<
T
>
);
PYBIND
11
_DECLARE_HOLDER_TYPE
(
T
,
ref
<
T
>
);
Object
*
make_object_1
()
{
return
new
MyObject
(
1
);
}
ref
<
Object
>
make_object_2
()
{
return
new
MyObject
(
2
);
}
...
...
include/pybind11/cast.h
View file @
b1b71402
...
...
@@ -25,9 +25,9 @@ NAMESPACE_BEGIN(detail)
#endif
#if PY_MAJOR_VERSION >= 3
#define PYBIND_AS_STRING PyBytes_AsString
#define PYBIND
11
_AS_STRING PyBytes_AsString
#else
#define PYBIND_AS_STRING PyString_AsString
#define PYBIND
11
_AS_STRING PyString_AsString
#endif
/** Linked list descriptor type for function signatures (produces smaller binaries
...
...
@@ -214,7 +214,7 @@ protected:
object
temp
;
};
#define PYBIND_TYPE_CASTER(type, py_name) \
#define PYBIND
11
_TYPE_CASTER(type, py_name) \
protected: \
type value; \
public: \
...
...
@@ -225,7 +225,7 @@ protected:
operator type*() { return &value; } \
operator type&() { return value; } \
#define PYBIND_TYPE_CASTER_NUMBER(type, py_type, from_type, to_pytype) \
#define PYBIND
11
_TYPE_CASTER_NUMBER(type, py_type, from_type, to_pytype) \
template <> class type_caster<type> { \
public: \
bool load(PyObject *src, bool) { \
...
...
@@ -244,7 +244,7 @@ protected:
static PyObject *cast(type src, return_value_policy
/* policy */
, PyObject *
/* parent */
) { \
return to_pytype((py_type) src); \
} \
PYBIND_TYPE_CASTER(type, #type); \
PYBIND
11
_TYPE_CASTER(type, #type); \
};
#if PY_MAJOR_VERSION >= 3
...
...
@@ -266,27 +266,27 @@ inline unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong_Fixed(PyObject *o) {
}
#endif
PYBIND_TYPE_CASTER_NUMBER
(
int8_t
,
long
,
PyLong_AsLong
,
PyLong_FromLong
)
PYBIND_TYPE_CASTER_NUMBER
(
uint8_t
,
unsigned
long
,
PyLong_AsUnsignedLong
,
PyLong_FromUnsignedLong
)
PYBIND_TYPE_CASTER_NUMBER
(
int16_t
,
long
,
PyLong_AsLong
,
PyLong_FromLong
)
PYBIND_TYPE_CASTER_NUMBER
(
uint16_t
,
unsigned
long
,
PyLong_AsUnsignedLong
,
PyLong_FromUnsignedLong
)
PYBIND_TYPE_CASTER_NUMBER
(
int32_t
,
long
,
PyLong_AsLong
,
PyLong_FromLong
)
PYBIND_TYPE_CASTER_NUMBER
(
uint32_t
,
unsigned
long
,
PyLong_AsUnsignedLong
,
PyLong_FromUnsignedLong
)
PYBIND_TYPE_CASTER_NUMBER
(
int64_t
,
PY_LONG_LONG
,
PyLong_AsLongLong_Fixed
,
PyLong_FromLongLong
)
PYBIND_TYPE_CASTER_NUMBER
(
uint64_t
,
unsigned
PY_LONG_LONG
,
PyLong_AsUnsignedLongLong_Fixed
,
PyLong_FromUnsignedLongLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
int8_t
,
long
,
PyLong_AsLong
,
PyLong_FromLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
uint8_t
,
unsigned
long
,
PyLong_AsUnsignedLong
,
PyLong_FromUnsignedLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
int16_t
,
long
,
PyLong_AsLong
,
PyLong_FromLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
uint16_t
,
unsigned
long
,
PyLong_AsUnsignedLong
,
PyLong_FromUnsignedLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
int32_t
,
long
,
PyLong_AsLong
,
PyLong_FromLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
uint32_t
,
unsigned
long
,
PyLong_AsUnsignedLong
,
PyLong_FromUnsignedLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
int64_t
,
PY_LONG_LONG
,
PyLong_AsLongLong_Fixed
,
PyLong_FromLongLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
uint64_t
,
unsigned
PY_LONG_LONG
,
PyLong_AsUnsignedLongLong_Fixed
,
PyLong_FromUnsignedLongLong
)
#if defined(__APPLE__) // size_t/ssize_t are separate types on Mac OS X
#if PY_MAJOR_VERSION >= 3
PYBIND_TYPE_CASTER_NUMBER
(
ssize_t
,
Py_ssize_t
,
PyLong_AsSsize_t
,
PyLong_FromSsize_t
)
PYBIND_TYPE_CASTER_NUMBER
(
size_t
,
size_t
,
PyLong_AsSize_t
,
PyLong_FromSize_t
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
ssize_t
,
Py_ssize_t
,
PyLong_AsSsize_t
,
PyLong_FromSsize_t
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
size_t
,
size_t
,
PyLong_AsSize_t
,
PyLong_FromSize_t
)
#else
PYBIND_TYPE_CASTER_NUMBER
(
ssize_t
,
PY_LONG_LONG
,
PyLong_AsLongLong_Fixed
,
PyLong_FromLongLong
)
PYBIND_TYPE_CASTER_NUMBER
(
size_t
,
unsigned
PY_LONG_LONG
,
PyLong_AsUnsignedLongLong_Fixed
,
PyLong_FromUnsignedLongLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
ssize_t
,
PY_LONG_LONG
,
PyLong_AsLongLong_Fixed
,
PyLong_FromLongLong
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
size_t
,
unsigned
PY_LONG_LONG
,
PyLong_AsUnsignedLongLong_Fixed
,
PyLong_FromUnsignedLongLong
)
#endif
#endif
PYBIND_TYPE_CASTER_NUMBER
(
float
,
double
,
PyFloat_AsDouble
,
PyFloat_FromDouble
)
PYBIND_TYPE_CASTER_NUMBER
(
double
,
double
,
PyFloat_AsDouble
,
PyFloat_FromDouble
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
float
,
double
,
PyFloat_AsDouble
,
PyFloat_FromDouble
)
PYBIND
11
_TYPE_CASTER_NUMBER
(
double
,
double
,
PyFloat_AsDouble
,
PyFloat_FromDouble
)
template
<>
class
type_caster
<
void_type
>
{
public
:
...
...
@@ -295,7 +295,7 @@ public:
Py_INCREF
(
Py_None
);
return
Py_None
;
}
PYBIND_TYPE_CASTER
(
void_type
,
"None"
);
PYBIND
11
_TYPE_CASTER
(
void_type
,
"None"
);
};
template
<>
class
type_caster
<
void
>
:
public
type_caster
<
void_type
>
{
...
...
@@ -313,7 +313,7 @@ public:
Py_INCREF
(
result
);
return
result
;
}
PYBIND_TYPE_CASTER
(
bool
,
"bool"
);
PYBIND
11
_TYPE_CASTER
(
bool
,
"bool"
);
};
template
<>
class
type_caster
<
std
::
string
>
{
...
...
@@ -325,7 +325,7 @@ public:
object
temp
(
PyUnicode_AsUTF8String
(
src
),
false
);
const
char
*
ptr
=
nullptr
;
if
(
temp
)
ptr
=
PYBIND_AS_STRING
(
temp
.
ptr
());
ptr
=
PYBIND
11
_AS_STRING
(
temp
.
ptr
());
if
(
!
ptr
)
{
PyErr_Clear
();
return
false
;
}
value
=
ptr
;
return
true
;
...
...
@@ -333,7 +333,7 @@ public:
static
PyObject
*
cast
(
const
std
::
string
&
src
,
return_value_policy
/* policy */
,
PyObject
*
/* parent */
)
{
return
PyUnicode_FromString
(
src
.
c_str
());
}
PYBIND_TYPE_CASTER
(
std
::
string
,
"str"
);
PYBIND
11
_TYPE_CASTER
(
std
::
string
,
"str"
);
};
template
<>
class
type_caster
<
char
>
{
...
...
@@ -345,7 +345,7 @@ public:
object
temp
(
PyUnicode_AsUTF8String
(
src
),
false
);
const
char
*
ptr
=
nullptr
;
if
(
temp
)
ptr
=
PYBIND_AS_STRING
(
temp
.
ptr
());
ptr
=
PYBIND
11
_AS_STRING
(
temp
.
ptr
());
if
(
!
ptr
)
{
PyErr_Clear
();
return
false
;
}
value
=
ptr
;
return
true
;
...
...
@@ -527,7 +527,7 @@ protected:
holder_type
holder
;
};
#define PYBIND_DECLARE_HOLDER_TYPE(type, holder_type) \
#define PYBIND
11
_DECLARE_HOLDER_TYPE(type, holder_type) \
namespace pybind11 { namespace detail { \
template <typename type> class type_caster<holder_type> \
: public type_caster_holder<type, holder_type> { }; \
...
...
@@ -543,24 +543,24 @@ public:
src
.
inc_ref
();
return
(
PyObject
*
)
src
.
ptr
();
}
PYBIND_TYPE_CASTER
(
handle
,
"handle"
);
PYBIND
11
_TYPE_CASTER
(
handle
,
"handle"
);
};
#define PYBIND_TYPE_CASTER_PYTYPE(name) \
#define PYBIND
11
_TYPE_CASTER_PYTYPE(name) \
template <> class type_caster<name> { \
public: \
bool load(PyObject *src, bool) { value = name(src, true); return true; } \
static PyObject *cast(const name &src, return_value_policy
/* policy */
, PyObject *
/* parent */
) { \
src.inc_ref(); return (PyObject *) src.ptr(); \
} \
PYBIND_TYPE_CASTER(name, #name); \
PYBIND
11
_TYPE_CASTER(name, #name); \
};
PYBIND
_TYPE_CASTER_PYTYPE
(
object
)
PYBIND
_TYPE_CASTER_PYTYPE
(
buffer
)
PYBIND
_TYPE_CASTER_PYTYPE
(
capsule
)
PYBIND
_TYPE_CASTER_PYTYPE
(
dict
)
PYBIND
_TYPE_CASTER_PYTYPE
(
float_
)
PYBIND
_TYPE_CASTER_PYTYPE
(
int_
)
PYBIND
_TYPE_CASTER_PYTYPE
(
list
)
PYBIND
_TYPE_CASTER_PYTYPE
(
slice
)
PYBIND
_TYPE_CASTER_PYTYPE
(
tuple
)
PYBIND
_TYPE_CASTER_PYTYPE
(
function
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
object
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
buffer
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
capsule
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
dict
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
float_
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
int_
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
list
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
slice
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
tuple
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
function
)
NAMESPACE_END
(
detail
)
...
...
include/pybind11/common.h
View file @
b1b71402
...
...
@@ -16,11 +16,11 @@
#define NAMESPACE_END(name) }
#endif
#if !defined(PYBIND_EXPORT)
#if !defined(PYBIND
11
_EXPORT)
#if defined(WIN32) || defined(_WIN32)
#define PYBIND_EXPORT __declspec(dllexport)
#define PYBIND
11
_EXPORT __declspec(dllexport)
#else
#define PYBIND_EXPORT __attribute__ ((visibility("default")))
#define PYBIND
11
_EXPORT __attribute__ ((visibility("default")))
#endif
#endif
...
...
@@ -61,11 +61,11 @@
#endif
#if PY_MAJOR_VERSION >= 3
#define PYBIND_PLUGIN(name) \
extern "C" PYBIND_EXPORT PyObject *PyInit_##name()
#define PYBIND
11
_PLUGIN(name) \
extern "C" PYBIND
11
_EXPORT PyObject *PyInit_##name()
#else
#define PYBIND_PLUGIN(name) \
extern "C" PYBIND_EXPORT PyObject *init##name()
#define PYBIND
11
_PLUGIN(name) \
extern "C" PYBIND
11
_EXPORT PyObject *init##name()
#endif
NAMESPACE_BEGIN
(
pybind11
)
...
...
@@ -93,10 +93,10 @@ enum class return_value_policy : int {
/// Format strings for basic number types
template
<
typename
type
>
struct
format_descriptor
{
};
#define PYBIND_DECL_FMT(t, n) template<> struct format_descriptor<t> { static std::string value() { return n; }; };
PYBIND
_DECL_FMT
(
int8_t
,
"b"
);
PYBIND_DECL_FMT
(
uint8_t
,
"B"
);
PYBIND_DECL_FMT
(
int16_t
,
"h"
);
PYBIND
_DECL_FMT
(
uint16_t
,
"H"
);
PYBIND
_DECL_FMT
(
int32_t
,
"i"
);
PYBIND_DECL_FMT
(
uint32_t
,
"I"
);
PYBIND_DECL_FMT
(
int64_t
,
"q"
);
PYBIND
_DECL_FMT
(
uint64_t
,
"Q"
);
PYBIND
_DECL_FMT
(
float
,
"f"
);
PYBIND_DECL_FMT
(
double
,
"d"
);
PYBIND
_DECL_FMT
(
bool
,
"?"
);
#define PYBIND
11
_DECL_FMT(t, n) template<> struct format_descriptor<t> { static std::string value() { return n; }; };
PYBIND
11_DECL_FMT
(
int8_t
,
"b"
);
PYBIND11_DECL_FMT
(
uint8_t
,
"B"
);
PYBIND11_DECL_FMT
(
int16_t
,
"h"
);
PYBIND11
_DECL_FMT
(
uint16_t
,
"H"
);
PYBIND
11_DECL_FMT
(
int32_t
,
"i"
);
PYBIND11_DECL_FMT
(
uint32_t
,
"I"
);
PYBIND11_DECL_FMT
(
int64_t
,
"q"
);
PYBIND11
_DECL_FMT
(
uint64_t
,
"Q"
);
PYBIND
11_DECL_FMT
(
float
,
"f"
);
PYBIND11_DECL_FMT
(
double
,
"d"
);
PYBIND11
_DECL_FMT
(
bool
,
"?"
);
/// Information record describing a Python buffer object
struct
buffer_info
{
...
...
include/pybind11/complex.h
View file @
b1b71402
...
...
@@ -14,8 +14,8 @@
NAMESPACE_BEGIN
(
pybind11
)
PYBIND_DECL_FMT
(
std
::
complex
<
float
>
,
"Zf"
);
PYBIND_DECL_FMT
(
std
::
complex
<
double
>
,
"Zd"
);
PYBIND
11
_DECL_FMT
(
std
::
complex
<
float
>
,
"Zf"
);
PYBIND
11
_DECL_FMT
(
std
::
complex
<
double
>
,
"Zd"
);
NAMESPACE_BEGIN
(
detail
)
template
<
typename
T
>
class
type_caster
<
std
::
complex
<
T
>>
{
...
...
@@ -34,7 +34,7 @@ public:
return
PyComplex_FromDoubles
((
double
)
src
.
real
(),
(
double
)
src
.
imag
());
}
PYBIND_TYPE_CASTER
(
std
::
complex
<
T
>
,
"complex"
);
PYBIND
11
_TYPE_CASTER
(
std
::
complex
<
T
>
,
"complex"
);
};
NAMESPACE_END
(
detail
)
NAMESPACE_END
(
pybind11
)
include/pybind11/functional.h
View file @
b1b71402
...
...
@@ -39,7 +39,7 @@ public:
}
PYBIND_TYPE_CASTER
(
type
,
detail
::
descr
(
"function<"
)
+
PYBIND
11
_TYPE_CASTER
(
type
,
detail
::
descr
(
"function<"
)
+
type_caster
<
std
::
tuple
<
Args
...
>>::
name
()
+
detail
::
descr
(
" -> "
)
+
type_caster
<
typename
decay
<
Return
>::
type
>::
name
()
+
detail
::
descr
(
">"
));
...
...
include/pybind11/numpy.h
View file @
b1b71402
...
...
@@ -76,7 +76,7 @@ public:
PyObject
*
(
*
PyArray_FromAny
)
(
PyObject
*
,
PyObject
*
,
int
,
int
,
int
,
PyObject
*
);
};
PYBIND_OBJECT_DEFAULT
(
array
,
buffer
,
lookup_api
().
PyArray_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
array
,
buffer
,
lookup_api
().
PyArray_Check
)
template
<
typename
Type
>
array
(
size_t
size
,
const
Type
*
ptr
)
{
API
&
api
=
lookup_api
();
...
...
@@ -126,7 +126,7 @@ protected:
template
<
typename
T
>
class
array_t
:
public
array
{
public
:
PYBIND_OBJECT_CVT
(
array_t
,
array
,
is_non_null
,
m_ptr
=
ensure
(
m_ptr
));
PYBIND
11
_OBJECT_CVT
(
array_t
,
array
,
is_non_null
,
m_ptr
=
ensure
(
m_ptr
));
array_t
()
:
array
()
{
}
static
bool
is_non_null
(
PyObject
*
ptr
)
{
return
ptr
!=
nullptr
;
}
PyObject
*
ensure
(
PyObject
*
ptr
)
{
...
...
@@ -150,15 +150,15 @@ DECL_FMT(std::complex<double>, NPY_CDOUBLE);
NAMESPACE_BEGIN
(
detail
)
PYBIND_TYPE_CASTER_PYTYPE
(
array
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
int8_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
uint8_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
int16_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
uint16_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
int32_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
uint32_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
int64_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
uint64_t
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
float
>
)
PYBIND
_TYPE_CASTER_PYTYPE
(
array_t
<
double
>
)
PYBIND_TYPE_CASTER_PYTYPE
(
array_t
<
std
::
complex
<
float
>>
)
PYBIND_TYPE_CASTER_PYTYPE
(
array_t
<
std
::
complex
<
double
>>
)
PYBIND_TYPE_CASTER_PYTYPE
(
array_t
<
bool
>
)
PYBIND
11
_TYPE_CASTER_PYTYPE
(
array
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
array_t
<
int8_t
>
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
array_t
<
uint8_t
>
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
array_t
<
int16_t
>
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
array_t
<
uint16_t
>
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
array_t
<
int32_t
>
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
array_t
<
uint32_t
>
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
array_t
<
int64_t
>
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
array_t
<
uint64_t
>
)
PYBIND
11_TYPE_CASTER_PYTYPE
(
array_t
<
float
>
)
PYBIND11
_TYPE_CASTER_PYTYPE
(
array_t
<
double
>
)
PYBIND
11
_TYPE_CASTER_PYTYPE
(
array_t
<
std
::
complex
<
float
>>
)
PYBIND
11
_TYPE_CASTER_PYTYPE
(
array_t
<
std
::
complex
<
double
>>
)
PYBIND
11
_TYPE_CASTER_PYTYPE
(
array_t
<
bool
>
)
template
<
typename
Func
,
typename
Return
,
typename
...
Args
>
struct
vectorize_helper
{
...
...
include/pybind11/operators.h
View file @
b1b71402
...
...
@@ -59,7 +59,7 @@ template <op_id id, op_type ot, typename L, typename R> struct op_ {
}
};
#define PYBIND_BINARY_OPERATOR(id, rid, op, expr) \
#define PYBIND
11
_BINARY_OPERATOR(id, rid, op, expr) \
template <typename B, typename L, typename R> struct op_impl<op_##id, op_l, B, L, R> { \
static char const* name() { return "__" #id "__"; } \
static auto execute(const L &l, const R &r) -> decltype(expr) { return (expr); } \
...
...
@@ -80,7 +80,7 @@ template <typename T> op_<op_##id, op_r, T, self_t> op(const T &, const self_t &
return op_<op_##id, op_r, T, self_t>(); \
};
#define PYBIND_INPLACE_OPERATOR(id, op, expr) \
#define PYBIND
11
_INPLACE_OPERATOR(id, op, expr) \
template <typename B, typename L, typename R> struct op_impl<op_##id, op_l, B, L, R> { \
static char const* name() { return "__" #id "__"; } \
static auto execute(L &l, const R &r) -> decltype(expr) { return expr; } \
...
...
@@ -90,7 +90,7 @@ template <typename T> op_<op_##id, op_l, self_t, T> op(const self_t &, const T &
return op_<op_##id, op_l, self_t, T>(); \
};
#define PYBIND_UNARY_OPERATOR(id, op, expr) \
#define PYBIND
11
_UNARY_OPERATOR(id, op, expr) \
template <typename B, typename L> struct op_impl<op_##id, op_u, B, L, undefined_t> { \
static char const* name() { return "__" #id "__"; } \
static auto execute(const L &l) -> decltype(expr) { return expr; } \
...
...
@@ -100,48 +100,48 @@ inline op_<op_##id, op_u, self_t, undefined_t> op(const self_t &) {
return op_<op_##id, op_u, self_t, undefined_t>(); \
};
PYBIND_BINARY_OPERATOR
(
sub
,
rsub
,
operator
-
,
l
-
r
)
PYBIND_BINARY_OPERATOR
(
add
,
radd
,
operator
+
,
l
+
r
)
PYBIND_BINARY_OPERATOR
(
mul
,
rmul
,
operator
*
,
l
*
r
)
PYBIND
11
_BINARY_OPERATOR
(
sub
,
rsub
,
operator
-
,
l
-
r
)
PYBIND
11
_BINARY_OPERATOR
(
add
,
radd
,
operator
+
,
l
+
r
)
PYBIND
11
_BINARY_OPERATOR
(
mul
,
rmul
,
operator
*
,
l
*
r
)
#if PY_MAJOR_VERSION >= 3
PYBIND_BINARY_OPERATOR
(
truediv
,
rtruediv
,
operator
/
,
l
/
r
)
PYBIND
11
_BINARY_OPERATOR
(
truediv
,
rtruediv
,
operator
/
,
l
/
r
)
#else
PYBIND_BINARY_OPERATOR
(
div
,
rdiv
,
operator
/
,
l
/
r
)
PYBIND
11
_BINARY_OPERATOR
(
div
,
rdiv
,
operator
/
,
l
/
r
)
#endif
PYBIND_BINARY_OPERATOR
(
mod
,
rmod
,
operator
%
,
l
%
r
)
PYBIND_BINARY_OPERATOR
(
lshift
,
rlshift
,
operator
<<
,
l
<<
r
)
PYBIND_BINARY_OPERATOR
(
rshift
,
rrshift
,
operator
>>
,
l
>>
r
)
PYBIND_BINARY_OPERATOR
(
and
,
rand
,
operator
&
,
l
&
r
)
PYBIND_BINARY_OPERATOR
(
xor
,
rxor
,
operator
^
,
l
^
r
)
PYBIND_BINARY_OPERATOR
(
eq
,
eq
,
operator
==
,
l
==
r
)
PYBIND_BINARY_OPERATOR
(
ne
,
ne
,
operator
!=
,
l
!=
r
)
PYBIND_BINARY_OPERATOR
(
or
,
ror
,
operator
|
,
l
|
r
)
PYBIND_BINARY_OPERATOR
(
gt
,
lt
,
operator
>
,
l
>
r
)
PYBIND_BINARY_OPERATOR
(
ge
,
le
,
operator
>=
,
l
>=
r
)
PYBIND_BINARY_OPERATOR
(
lt
,
gt
,
operator
<
,
l
<
r
)
PYBIND_BINARY_OPERATOR
(
le
,
ge
,
operator
<=
,
l
<=
r
)
//PYBIND_BINARY_OPERATOR(pow, rpow, pow, std::pow(l, r))
PYBIND_INPLACE_OPERATOR
(
iadd
,
operator
+=
,
l
+=
r
)
PYBIND_INPLACE_OPERATOR
(
isub
,
operator
-=
,
l
-=
r
)
PYBIND_INPLACE_OPERATOR
(
imul
,
operator
*=
,
l
*=
r
)
PYBIND_INPLACE_OPERATOR
(
idiv
,
operator
/=
,
l
/=
r
)
PYBIND_INPLACE_OPERATOR
(
imod
,
operator
%=
,
l
%=
r
)
PYBIND_INPLACE_OPERATOR
(
ilshift
,
operator
<<=
,
l
<<=
r
)
PYBIND_INPLACE_OPERATOR
(
irshift
,
operator
>>=
,
l
>>=
r
)
PYBIND_INPLACE_OPERATOR
(
iand
,
operator
&=
,
l
&=
r
)
PYBIND_INPLACE_OPERATOR
(
ixor
,
operator
^=
,
l
^=
r
)
PYBIND_INPLACE_OPERATOR
(
ior
,
operator
|=
,
l
|=
r
)
PYBIND_UNARY_OPERATOR
(
neg
,
operator
-
,
-
l
)
PYBIND_UNARY_OPERATOR
(
pos
,
operator
+
,
+
l
)
PYBIND_UNARY_OPERATOR
(
abs
,
abs
,
std
::
abs
(
l
))
PYBIND_UNARY_OPERATOR
(
invert
,
operator
~
,
~
l
)
PYBIND_UNARY_OPERATOR
(
bool
,
operator
!
,
!!
l
)
PYBIND_UNARY_OPERATOR
(
int
,
int_
,
(
int
)
l
)
PYBIND_UNARY_OPERATOR
(
float
,
float_
,
(
double
)
l
)
#undef PYBIND_BINARY_OPERATOR
#undef PYBIND_INPLACE_OPERATOR
#undef PYBIND_UNARY_OPERATOR
PYBIND
11
_BINARY_OPERATOR
(
mod
,
rmod
,
operator
%
,
l
%
r
)
PYBIND
11
_BINARY_OPERATOR
(
lshift
,
rlshift
,
operator
<<
,
l
<<
r
)
PYBIND
11
_BINARY_OPERATOR
(
rshift
,
rrshift
,
operator
>>
,
l
>>
r
)
PYBIND
11
_BINARY_OPERATOR
(
and
,
rand
,
operator
&
,
l
&
r
)
PYBIND
11
_BINARY_OPERATOR
(
xor
,
rxor
,
operator
^
,
l
^
r
)
PYBIND
11
_BINARY_OPERATOR
(
eq
,
eq
,
operator
==
,
l
==
r
)
PYBIND
11
_BINARY_OPERATOR
(
ne
,
ne
,
operator
!=
,
l
!=
r
)
PYBIND
11
_BINARY_OPERATOR
(
or
,
ror
,
operator
|
,
l
|
r
)
PYBIND
11
_BINARY_OPERATOR
(
gt
,
lt
,
operator
>
,
l
>
r
)
PYBIND
11
_BINARY_OPERATOR
(
ge
,
le
,
operator
>=
,
l
>=
r
)
PYBIND
11
_BINARY_OPERATOR
(
lt
,
gt
,
operator
<
,
l
<
r
)
PYBIND
11
_BINARY_OPERATOR
(
le
,
ge
,
operator
<=
,
l
<=
r
)
//PYBIND
11
_BINARY_OPERATOR(pow, rpow, pow, std::pow(l, r))
PYBIND
11
_INPLACE_OPERATOR
(
iadd
,
operator
+=
,
l
+=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
isub
,
operator
-=
,
l
-=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
imul
,
operator
*=
,
l
*=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
idiv
,
operator
/=
,
l
/=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
imod
,
operator
%=
,
l
%=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
ilshift
,
operator
<<=
,
l
<<=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
irshift
,
operator
>>=
,
l
>>=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
iand
,
operator
&=
,
l
&=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
ixor
,
operator
^=
,
l
^=
r
)
PYBIND
11
_INPLACE_OPERATOR
(
ior
,
operator
|=
,
l
|=
r
)
PYBIND
11
_UNARY_OPERATOR
(
neg
,
operator
-
,
-
l
)
PYBIND
11
_UNARY_OPERATOR
(
pos
,
operator
+
,
+
l
)
PYBIND
11
_UNARY_OPERATOR
(
abs
,
abs
,
std
::
abs
(
l
))
PYBIND
11
_UNARY_OPERATOR
(
invert
,
operator
~
,
~
l
)
PYBIND
11
_UNARY_OPERATOR
(
bool
,
operator
!
,
!!
l
)
PYBIND
11
_UNARY_OPERATOR
(
int
,
int_
,
(
int
)
l
)
PYBIND
11
_UNARY_OPERATOR
(
float
,
float_
,
(
double
)
l
)
#undef PYBIND
11
_BINARY_OPERATOR
#undef PYBIND
11
_INPLACE_OPERATOR
#undef PYBIND
11
_UNARY_OPERATOR
NAMESPACE_END
(
detail
)
using
detail
::
self
;
...
...
include/pybind11/pybind11.h
View file @
b1b71402
...
...
@@ -429,7 +429,7 @@ private:
class
module
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
module
,
object
,
PyModule_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
module
,
object
,
PyModule_Check
)
module
(
const
char
*
name
,
const
char
*
doc
=
nullptr
)
{
#if PY_MAJOR_VERSION >= 3
...
...
@@ -476,7 +476,7 @@ NAMESPACE_BEGIN(detail)
/// Basic support for creating new Python heap types
class
custom_type
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
custom_type
,
object
,
PyType_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
custom_type
,
object
,
PyType_Check
)
custom_type
(
object
&
scope
,
const
char
*
name_
,
const
std
::
type_info
*
tinfo
,
size_t
type_size
,
size_t
instance_size
,
...
...
@@ -667,7 +667,7 @@ template <typename type, typename holder_type = std::unique_ptr<type>> class cla
public
:
typedef
detail
::
instance
<
type
,
holder_type
>
instance_type
;
PYBIND_OBJECT
(
class_
,
detail
::
custom_type
,
PyType_Check
)
PYBIND
11
_OBJECT
(
class_
,
detail
::
custom_type
,
PyType_Check
)
class_
(
object
&
scope
,
const
char
*
name
,
const
char
*
doc
=
nullptr
)
:
detail
::
custom_type
(
scope
,
name
,
&
typeid
(
type
),
sizeof
(
type
),
...
...
@@ -925,18 +925,18 @@ inline function get_overload(const void *this_ptr, const char *name) {
return
overload
;
}
#define PYBIND_OVERLOAD_INT(ret_type, class_name, name, ...) { \
#define PYBIND
11
_OVERLOAD_INT(ret_type, class_name, name, ...) { \
pybind11::gil_scoped_acquire gil; \
pybind11::function overload = pybind11::get_overload(this, #name); \
if (overload) \
return overload.call(__VA_ARGS__).cast<ret_type>(); }
#define PYBIND_OVERLOAD(ret_type, class_name, name, ...) \
PYBIND_OVERLOAD_INT(ret_type, class_name, name, __VA_ARGS__) \
#define PYBIND
11
_OVERLOAD(ret_type, class_name, name, ...) \
PYBIND
11
_OVERLOAD_INT(ret_type, class_name, name, __VA_ARGS__) \
return class_name::name(__VA_ARGS__)
#define PYBIND_OVERLOAD_PURE(ret_type, class_name, name, ...) \
PYBIND_OVERLOAD_INT(ret_type, class_name, name, __VA_ARGS__) \
#define PYBIND
11
_OVERLOAD_PURE(ret_type, class_name, name, ...) \
PYBIND
11
_OVERLOAD_INT(ret_type, class_name, name, __VA_ARGS__) \
throw std::runtime_error("Tried to call pure virtual function \"" #name "\"");
NAMESPACE_END
(
pybind11
)
...
...
include/pybind11/pytypes.h
View file @
b1b71402
...
...
@@ -195,7 +195,7 @@ inline detail::accessor handle::operator[](const char *key) { return detail::acc
inline
detail
::
accessor
handle
::
attr
(
handle
key
)
{
return
detail
::
accessor
(
ptr
(),
key
.
ptr
(),
true
);
}
inline
detail
::
accessor
handle
::
attr
(
const
char
*
key
)
{
return
detail
::
accessor
(
ptr
(),
key
,
true
);
}
#define PYBIND_OBJECT_CVT(Name, Parent, CheckFun, CvtStmt) \
#define PYBIND
11
_OBJECT_CVT(Name, Parent, CheckFun, CvtStmt) \
Name(const handle &h, bool borrowed) : Parent(h, borrowed) { CvtStmt; } \
Name(const object& o): Parent(o) { CvtStmt; } \
Name(object&& o): Parent(std::move(o)) { CvtStmt; } \
...
...
@@ -203,16 +203,16 @@ inline detail::accessor handle::attr(const char *key) { return detail::accessor(
Name& operator=(object& o) { return static_cast<Name&>(object::operator=(o)); CvtStmt; } \
bool check() const { return m_ptr != nullptr && (bool) CheckFun(m_ptr); }
#define PYBIND_OBJECT(Name, Parent, CheckFun) \
PYBIND_OBJECT_CVT(Name, Parent, CheckFun, )
#define PYBIND
11
_OBJECT(Name, Parent, CheckFun) \
PYBIND
11
_OBJECT_CVT(Name, Parent, CheckFun, )
#define PYBIND_OBJECT_DEFAULT(Name, Parent, CheckFun) \
PYBIND_OBJECT(Name, Parent, CheckFun) \
#define PYBIND
11
_OBJECT_DEFAULT(Name, Parent, CheckFun) \
PYBIND
11
_OBJECT(Name, Parent, CheckFun) \
Name() : Parent() { }
class
str
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
str
,
object
,
PyUnicode_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
str
,
object
,
PyUnicode_Check
)
str
(
const
char
*
s
)
:
object
(
PyUnicode_FromString
(
s
),
false
)
{
}
operator
const
char
*
()
const
{
#if PY_MAJOR_VERSION >= 3
...
...
@@ -241,13 +241,13 @@ inline pybind11::str handle::str() const {
class
bool_
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
bool_
,
object
,
PyBool_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
bool_
,
object
,
PyBool_Check
)
operator
bool
()
const
{
return
m_ptr
&&
PyLong_AsLong
(
m_ptr
)
!=
0
;
}
};
class
int_
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
int_
,
object
,
PyLong_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
int_
,
object
,
PyLong_Check
)
int_
(
int
value
)
:
object
(
PyLong_FromLong
((
long
)
value
),
false
)
{
}
int_
(
size_t
value
)
:
object
(
PyLong_FromSize_t
(
value
),
false
)
{
}
#if !defined(WIN32) || defined(_WIN64)
...
...
@@ -258,7 +258,7 @@ public:
class
float_
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
float_
,
object
,
PyFloat_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
float_
,
object
,
PyFloat_Check
)
float_
(
float
value
)
:
object
(
PyFloat_FromDouble
((
double
)
value
),
false
)
{
}
float_
(
double
value
)
:
object
(
PyFloat_FromDouble
((
double
)
value
),
false
)
{
}
operator
float
()
const
{
return
(
float
)
PyFloat_AsDouble
(
m_ptr
);
}
...
...
@@ -267,7 +267,7 @@ public:
class
slice
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
slice
,
object
,
PySlice_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
slice
,
object
,
PySlice_Check
)
slice
(
ssize_t
start_
,
ssize_t
stop_
,
ssize_t
step_
)
{
int_
start
(
start_
),
stop
(
stop_
),
step
(
step_
);
m_ptr
=
PySlice_New
(
start
.
ptr
(),
stop
.
ptr
(),
step
.
ptr
());
...
...
@@ -285,7 +285,7 @@ public:
class
capsule
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
capsule
,
object
,
PyCapsule_CheckExact
)
PYBIND
11
_OBJECT_DEFAULT
(
capsule
,
object
,
PyCapsule_CheckExact
)
capsule
(
PyObject
*
obj
,
bool
borrowed
)
:
object
(
obj
,
borrowed
)
{
}
capsule
(
void
*
value
,
void
(
*
destruct
)(
PyObject
*
)
=
nullptr
)
:
object
(
PyCapsule_New
(
value
,
nullptr
,
destruct
),
false
)
{
}
template
<
typename
T
>
operator
T
*
()
const
{
...
...
@@ -297,7 +297,7 @@ public:
class
tuple
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
tuple
,
object
,
PyTuple_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
tuple
,
object
,
PyTuple_Check
)
tuple
(
size_t
size
)
:
object
(
PyTuple_New
((
Py_ssize_t
)
size
),
false
)
{
}
size_t
size
()
const
{
return
(
size_t
)
PyTuple_Size
(
m_ptr
);
}
detail
::
tuple_accessor
operator
[](
size_t
index
)
{
return
detail
::
tuple_accessor
(
ptr
(),
index
);
}
...
...
@@ -305,7 +305,7 @@ public:
class
dict
:
public
object
{
public
:
PYBIND_OBJECT
(
dict
,
object
,
PyDict_Check
)
PYBIND
11
_OBJECT
(
dict
,
object
,
PyDict_Check
)
dict
()
:
object
(
PyDict_New
(),
false
)
{
}
size_t
size
()
const
{
return
(
size_t
)
PyDict_Size
(
m_ptr
);
}
detail
::
dict_iterator
begin
()
{
return
(
++
detail
::
dict_iterator
(
ptr
(),
0
));
}
...
...
@@ -314,7 +314,7 @@ public:
class
list
:
public
object
{
public
:
PYBIND_OBJECT
(
list
,
object
,
PyList_Check
)
PYBIND
11
_OBJECT
(
list
,
object
,
PyList_Check
)
list
(
size_t
size
=
0
)
:
object
(
PyList_New
((
ssize_t
)
size
),
false
)
{
}
size_t
size
()
const
{
return
(
size_t
)
PyList_Size
(
m_ptr
);
}
detail
::
list_iterator
begin
()
{
return
detail
::
list_iterator
(
ptr
(),
0
);
}
...
...
@@ -325,7 +325,7 @@ public:
class
function
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
function
,
object
,
PyFunction_Check
)
PYBIND
11
_OBJECT_DEFAULT
(
function
,
object
,
PyFunction_Check
)
bool
is_cpp_function
()
{
PyObject
*
ptr
=
m_ptr
;
...
...
@@ -343,7 +343,7 @@ public:
class
buffer
:
public
object
{
public
:
PYBIND_OBJECT_DEFAULT
(
buffer
,
object
,
PyObject_CheckBuffer
)
PYBIND
11
_OBJECT_DEFAULT
(
buffer
,
object
,
PyObject_CheckBuffer
)
buffer_info
request
(
bool
writable
=
false
)
{
int
flags
=
PyBUF_STRIDES
|
PyBUF_FORMAT
;
...
...
include/pybind11/stl.h
View file @
b1b71402
...
...
@@ -54,7 +54,7 @@ public:
}
return
list
;
}
PYBIND_TYPE_CASTER
(
type
,
detail
::
descr
(
"list<"
)
+
value_conv
::
name
()
+
detail
::
descr
(
">"
));
PYBIND
11
_TYPE_CASTER
(
type
,
detail
::
descr
(
"list<"
)
+
value_conv
::
name
()
+
detail
::
descr
(
">"
));
};
template
<
typename
Key
,
typename
Value
>
struct
type_caster
<
std
::
map
<
Key
,
Value
>>
{
...
...
@@ -97,7 +97,7 @@ public:
return
dict
;
}
PYBIND_TYPE_CASTER
(
type
,
detail
::
descr
(
"dict<"
)
+
key_conv
::
name
()
+
detail
::
descr
(
", "
)
+
value_conv
::
name
()
+
detail
::
descr
(
">"
));
PYBIND
11
_TYPE_CASTER
(
type
,
detail
::
descr
(
"dict<"
)
+
key_conv
::
name
()
+
detail
::
descr
(
", "
)
+
value_conv
::
name
()
+
detail
::
descr
(
">"
));
};
NAMESPACE_END
(
detail
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment