Skip to content

Commit

Permalink
consistent macro naming throughout the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenzel Jakob committed Oct 18, 2015
1 parent 041a865 commit b1b7140
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 150 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ 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 -DPYBIND11_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
- CTEST_OUTPUT_ON_FAILURE=TRUE make test
- os: osx
compiler: clang
script:
- cmake -DPYBIND_PYTHON_VERSION=2.7
- cmake -DPYBIND11_PYTHON_VERSION=2.7
- make -j 2
- CTEST_OUTPUT_ON_FAILURE=TRUE make test
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(PYBIND11_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)
Expand All @@ -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 ${PYBIND11_PYTHON_VERSION} REQUIRED)
find_package(PythonInterp ${PYBIND11_PYTHON_VERSION} REQUIRED)

if (UNIX)
# Enable C++11 mode
Expand Down
18 changes: 9 additions & 9 deletions docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ to Python.
#include <pybind11/operators.h>
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Vector2>(m, "Vector2")
Expand Down Expand Up @@ -127,7 +127,7 @@ trivial to generate binding code for both of these functions.
#include <pybind11/functional.h>
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("func_arg", &func_arg);
Expand Down Expand Up @@ -199,7 +199,7 @@ Normally, the binding code for these classes would look as follows:

.. code-block:: cpp
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Animal> animal(m, "Animal");
Expand Down Expand Up @@ -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(
PYBIND11_OVERLOAD_PURE(
std::string, /* Return type */
Animal, /* Parent class */
go, /* Name of function */
Expand All @@ -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:`PYBIND11_OVERLOAD_PURE` should be used for pure virtual
functions, and :func:`PYBIND11_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) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<PyAnimal> animal(m, "Animal");
Expand Down Expand Up @@ -375,7 +375,7 @@ See below for an example that uses the
Internal internal;
};
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Example>(m, "Example")
Expand Down Expand Up @@ -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>);
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
.. seealso::

Expand Down
4 changes: 2 additions & 2 deletions docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ a file named :file:`example.cpp` with the following contents:
namespace py = pybind11;
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
m.def("add", &add, "A function which adds two numbers");
return m.ptr();
}
The :func:`PYBIND_PLUGIN` macro creates a function that will be called when an
The :func:`PYBIND11_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
Expand Down
2 changes: 1 addition & 1 deletion docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The binding code for ``Pet`` looks as follows:
namespace py = pybind11;
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind11 example plugin");
py::class_<Pet>(m, "Pet")
Expand Down
4 changes: 2 additions & 2 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Reference
Macros
======

.. function:: PYBIND_PLUGIN(const char *name)
.. function:: PYBIND11_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
Expand All @@ -21,7 +21,7 @@ Macros

.. code-block:: cpp
PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
pybind11::module m("example", "pybind11 example plugin");
/// Set up bindings here
return m.ptr();
Expand Down
2 changes: 1 addition & 1 deletion example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void init_ex10(py::module &);
void init_ex11(py::module &);
void init_ex12(py::module &);

PYBIND_PLUGIN(example) {
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind example plugin");

init_ex1(m);
Expand Down
4 changes: 2 additions & 2 deletions example/example12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PyExample12 : public Example12 {

virtual int run(int value) {
/* Generate wrapping code that enables native function overloading */
PYBIND_OVERLOAD(
PYBIND11_OVERLOAD(
int, /* Return type */
Example12, /* Parent class */
run, /* Name of function */
Expand All @@ -48,7 +48,7 @@ class PyExample12 : public Example12 {
}

virtual void pure_virtual() {
PYBIND_OVERLOAD_PURE(
PYBIND11_OVERLOAD_PURE(
void, /* Return type */
Example12, /* Parent class */
pure_virtual /* Name of function */
Expand Down
2 changes: 1 addition & 1 deletion example/example8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MyObject : public Object {
};

/// Make pybind aware of the ref-counted wrapper type
PYBIND_DECLARE_HOLDER_TYPE(T, ref<T>);
PYBIND11_DECLARE_HOLDER_TYPE(T, ref<T>);

Object *make_object_1() { return new MyObject(1); }
ref<Object> make_object_2() { return new MyObject(2); }
Expand Down
66 changes: 33 additions & 33 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ NAMESPACE_BEGIN(detail)
#endif

#if PY_MAJOR_VERSION >= 3
#define PYBIND_AS_STRING PyBytes_AsString
#define PYBIND11_AS_STRING PyBytes_AsString
#else
#define PYBIND_AS_STRING PyString_AsString
#define PYBIND11_AS_STRING PyString_AsString
#endif

/** Linked list descriptor type for function signatures (produces smaller binaries
Expand Down Expand Up @@ -214,7 +214,7 @@ template <typename type> class type_caster {
object temp;
};

#define PYBIND_TYPE_CASTER(type, py_name) \
#define PYBIND11_TYPE_CASTER(type, py_name) \
protected: \
type value; \
public: \
Expand All @@ -225,7 +225,7 @@ template <typename type> class type_caster {
operator type*() { return &value; } \
operator type&() { return value; } \

#define PYBIND_TYPE_CASTER_NUMBER(type, py_type, from_type, to_pytype) \
#define PYBIND11_TYPE_CASTER_NUMBER(type, py_type, from_type, to_pytype) \
template <> class type_caster<type> { \
public: \
bool load(PyObject *src, bool) { \
Expand All @@ -244,7 +244,7 @@ template <typename type> class type_caster {
static PyObject *cast(type src, return_value_policy /* policy */, PyObject * /* parent */) { \
return to_pytype((py_type) src); \
} \
PYBIND_TYPE_CASTER(type, #type); \
PYBIND11_TYPE_CASTER(type, #type); \
};

#if PY_MAJOR_VERSION >= 3
Expand All @@ -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)
PYBIND11_TYPE_CASTER_NUMBER(int8_t, long, PyLong_AsLong, PyLong_FromLong)
PYBIND11_TYPE_CASTER_NUMBER(uint8_t, unsigned long, PyLong_AsUnsignedLong, PyLong_FromUnsignedLong)
PYBIND11_TYPE_CASTER_NUMBER(int16_t, long, PyLong_AsLong, PyLong_FromLong)
PYBIND11_TYPE_CASTER_NUMBER(uint16_t, unsigned long, PyLong_AsUnsignedLong, PyLong_FromUnsignedLong)
PYBIND11_TYPE_CASTER_NUMBER(int32_t, long, PyLong_AsLong, PyLong_FromLong)
PYBIND11_TYPE_CASTER_NUMBER(uint32_t, unsigned long, PyLong_AsUnsignedLong, PyLong_FromUnsignedLong)
PYBIND11_TYPE_CASTER_NUMBER(int64_t, PY_LONG_LONG, PyLong_AsLongLong_Fixed, PyLong_FromLongLong)
PYBIND11_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)
PYBIND11_TYPE_CASTER_NUMBER(ssize_t, Py_ssize_t, PyLong_AsSsize_t, PyLong_FromSsize_t)
PYBIND11_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)
PYBIND11_TYPE_CASTER_NUMBER(ssize_t, PY_LONG_LONG, PyLong_AsLongLong_Fixed, PyLong_FromLongLong)
PYBIND11_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)
PYBIND11_TYPE_CASTER_NUMBER(float, double, PyFloat_AsDouble, PyFloat_FromDouble)
PYBIND11_TYPE_CASTER_NUMBER(double, double, PyFloat_AsDouble, PyFloat_FromDouble)

template <> class type_caster<void_type> {
public:
Expand All @@ -295,7 +295,7 @@ template <> class type_caster<void_type> {
Py_INCREF(Py_None);
return Py_None;
}
PYBIND_TYPE_CASTER(void_type, "None");
PYBIND11_TYPE_CASTER(void_type, "None");
};

template <> class type_caster<void> : public type_caster<void_type> {
Expand All @@ -313,7 +313,7 @@ template <> class type_caster<bool> {
Py_INCREF(result);
return result;
}
PYBIND_TYPE_CASTER(bool, "bool");
PYBIND11_TYPE_CASTER(bool, "bool");
};

template <> class type_caster<std::string> {
Expand All @@ -325,15 +325,15 @@ template <> class type_caster<std::string> {
object temp(PyUnicode_AsUTF8String(src), false);
const char *ptr = nullptr;
if (temp)
ptr = PYBIND_AS_STRING(temp.ptr());
ptr = PYBIND11_AS_STRING(temp.ptr());
if (!ptr) { PyErr_Clear(); return false; }
value = ptr;
return true;
}
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");
PYBIND11_TYPE_CASTER(std::string, "str");
};

template <> class type_caster<char> {
Expand All @@ -345,7 +345,7 @@ template <> class type_caster<char> {
object temp(PyUnicode_AsUTF8String(src), false);
const char *ptr = nullptr;
if (temp)
ptr = PYBIND_AS_STRING(temp.ptr());
ptr = PYBIND11_AS_STRING(temp.ptr());
if (!ptr) { PyErr_Clear(); return false; }
value = ptr;
return true;
Expand Down Expand Up @@ -527,7 +527,7 @@ template <typename type, typename holder_type> class type_caster_holder : public
holder_type holder;
};

#define PYBIND_DECLARE_HOLDER_TYPE(type, holder_type) \
#define PYBIND11_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> { }; \
Expand All @@ -543,24 +543,24 @@ template <> class type_caster<handle> {
src.inc_ref();
return (PyObject *) src.ptr();
}
PYBIND_TYPE_CASTER(handle, "handle");
PYBIND11_TYPE_CASTER(handle, "handle");
};

#define PYBIND_TYPE_CASTER_PYTYPE(name) \
#define PYBIND11_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); \
PYBIND11_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)
PYBIND11_TYPE_CASTER_PYTYPE(object) PYBIND11_TYPE_CASTER_PYTYPE(buffer)
PYBIND11_TYPE_CASTER_PYTYPE(capsule) PYBIND11_TYPE_CASTER_PYTYPE(dict)
PYBIND11_TYPE_CASTER_PYTYPE(float_) PYBIND11_TYPE_CASTER_PYTYPE(int_)
PYBIND11_TYPE_CASTER_PYTYPE(list) PYBIND11_TYPE_CASTER_PYTYPE(slice)
PYBIND11_TYPE_CASTER_PYTYPE(tuple) PYBIND11_TYPE_CASTER_PYTYPE(function)

NAMESPACE_END(detail)

Expand Down

0 comments on commit b1b7140

Please sign in to comment.