fix severe regression involving character arrays (fixes #137)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c692dc..f8a489c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,9 +119,8 @@
example/example11.cpp
example/example12.cpp
example/example13.cpp
+ example/issues.cpp
)
-set(PYBIND11_FIRSTEXAMPLE 1)
-list(LENGTH PYBIND11_EXAMPLES PYBIND11_LASTEXAMPLE)
# Create the binding library
add_library(example SHARED
@@ -208,8 +207,9 @@
set(RUN_TEST ${RUN_TEST} --relaxed)
endif()
-foreach(i RANGE ${PYBIND11_FIRSTEXAMPLE} ${PYBIND11_LASTEXAMPLE})
- add_test(NAME example${i} COMMAND ${RUN_TEST} example${i})
+foreach(VALUE ${PYBIND11_EXAMPLES})
+ string(REGEX REPLACE "^example/(.+).cpp$" "\\1" EXAMPLE_NAME "${VALUE}")
+ add_test(NAME ${EXAMPLE_NAME} COMMAND ${RUN_TEST} ${EXAMPLE_NAME})
endforeach()
if (PYBIND11_INSTALL)
diff --git a/example/example.cpp b/example/example.cpp
index d130551..d84b456 100644
--- a/example/example.cpp
+++ b/example/example.cpp
@@ -22,6 +22,7 @@
void init_ex11(py::module &);
void init_ex12(py::module &);
void init_ex13(py::module &);
+void init_issues(py::module &);
PYBIND11_PLUGIN(example) {
py::module m("example", "pybind example plugin");
@@ -39,6 +40,7 @@
init_ex11(m);
init_ex12(m);
init_ex13(m);
+ init_issues(m);
return m.ptr();
}
diff --git a/example/issues.cpp b/example/issues.cpp
new file mode 100644
index 0000000..e8cf831
--- /dev/null
+++ b/example/issues.cpp
@@ -0,0 +1,18 @@
+/*
+ example/issues.cpp -- collection of testcases for miscellaneous issues
+
+ Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
+
+ All rights reserved. Use of this source code is governed by a
+ BSD-style license that can be found in the LICENSE file.
+*/
+
+#include "example.h"
+
+
+void init_issues(py::module &m) {
+ py::module m2 = m.def_submodule("issues");
+
+ // #137: const char* isn't handled properly
+ m2.def("print_cchar", [](const char *string) { std::cout << string << std::endl; });
+}
diff --git a/example/issues.py b/example/issues.py
new file mode 100644
index 0000000..64bd7c6
--- /dev/null
+++ b/example/issues.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+from __future__ import print_function
+import sys
+sys.path.append('.')
+
+from example.issues import print_cchar
+
+print_cchar("const char *")
diff --git a/example/issues.ref b/example/issues.ref
new file mode 100644
index 0000000..6f672ff
--- /dev/null
+++ b/example/issues.ref
@@ -0,0 +1 @@
+const char *
diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h
index f22b670..89fcac1 100644
--- a/include/pybind11/cast.h
+++ b/include/pybind11/cast.h
@@ -401,8 +401,6 @@
operator char() { if (value.length() > 0) return value[0]; else return '\0'; }
static PYBIND11_DESCR name() { return type_descr(_(PYBIND11_STRING_NAME)); }
-protected:
- std::string value;
};
template <> class type_caster<wchar_t> : public type_caster<std::wstring> {
@@ -420,8 +418,6 @@
operator wchar_t() { if (value.length() > 0) return value[0]; else return L'\0'; }
static PYBIND11_DESCR name() { return type_descr(_(PYBIND11_STRING_NAME)); }
-protected:
- std::wstring value;
};
template <typename T1, typename T2> class type_caster<std::pair<T1, T2>> {