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
17cdb06c
Commit
17cdb06c
authored
Mar 10, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix severe regression involving character arrays (fixes #137)
parent
cf8b3028
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
8 deletions
+33
-8
CMakeLists.txt
+4
-4
example/example.cpp
+2
-0
example/issues.cpp
+18
-0
example/issues.py
+8
-0
example/issues.ref
+1
-0
include/pybind11/cast.h
+0
-4
No files found.
CMakeLists.txt
View file @
17cdb06c
...
@@ -119,9 +119,8 @@ set(PYBIND11_EXAMPLES
...
@@ -119,9 +119,8 @@ set(PYBIND11_EXAMPLES
example/example11.cpp
example/example11.cpp
example/example12.cpp
example/example12.cpp
example/example13.cpp
example/example13.cpp
example/issues.cpp
)
)
set
(
PYBIND11_FIRSTEXAMPLE 1
)
list
(
LENGTH PYBIND11_EXAMPLES PYBIND11_LASTEXAMPLE
)
# Create the binding library
# Create the binding library
add_library
(
example SHARED
add_library
(
example SHARED
...
@@ -208,8 +207,9 @@ if (MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
...
@@ -208,8 +207,9 @@ if (MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set
(
RUN_TEST
${
RUN_TEST
}
--relaxed
)
set
(
RUN_TEST
${
RUN_TEST
}
--relaxed
)
endif
()
endif
()
foreach
(
i RANGE
${
PYBIND11_FIRSTEXAMPLE
}
${
PYBIND11_LASTEXAMPLE
}
)
foreach
(
VALUE
${
PYBIND11_EXAMPLES
}
)
add_test
(
NAME example
${
i
}
COMMAND
${
RUN_TEST
}
example
${
i
}
)
string
(
REGEX REPLACE
"^example/(.+).cpp$"
"
\\
1"
EXAMPLE_NAME
"
${
VALUE
}
"
)
add_test
(
NAME
${
EXAMPLE_NAME
}
COMMAND
${
RUN_TEST
}
${
EXAMPLE_NAME
}
)
endforeach
()
endforeach
()
if
(
PYBIND11_INSTALL
)
if
(
PYBIND11_INSTALL
)
...
...
example/example.cpp
View file @
17cdb06c
...
@@ -22,6 +22,7 @@ void init_ex10(py::module &);
...
@@ -22,6 +22,7 @@ void init_ex10(py::module &);
void
init_ex11
(
py
::
module
&
);
void
init_ex11
(
py
::
module
&
);
void
init_ex12
(
py
::
module
&
);
void
init_ex12
(
py
::
module
&
);
void
init_ex13
(
py
::
module
&
);
void
init_ex13
(
py
::
module
&
);
void
init_issues
(
py
::
module
&
);
PYBIND11_PLUGIN
(
example
)
{
PYBIND11_PLUGIN
(
example
)
{
py
::
module
m
(
"example"
,
"pybind example plugin"
);
py
::
module
m
(
"example"
,
"pybind example plugin"
);
...
@@ -39,6 +40,7 @@ PYBIND11_PLUGIN(example) {
...
@@ -39,6 +40,7 @@ PYBIND11_PLUGIN(example) {
init_ex11
(
m
);
init_ex11
(
m
);
init_ex12
(
m
);
init_ex12
(
m
);
init_ex13
(
m
);
init_ex13
(
m
);
init_issues
(
m
);
return
m
.
ptr
();
return
m
.
ptr
();
}
}
example/issues.cpp
0 → 100644
View file @
17cdb06c
/*
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
;
});
}
example/issues.py
0 → 100644
View file @
17cdb06c
#!/usr/bin/env python
from
__future__
import
print_function
import
sys
sys
.
path
.
append
(
'.'
)
from
example.issues
import
print_cchar
print_cchar
(
"const char *"
)
example/issues.ref
0 → 100644
View file @
17cdb06c
const char *
include/pybind11/cast.h
View file @
17cdb06c
...
@@ -401,8 +401,6 @@ public:
...
@@ -401,8 +401,6 @@ public:
operator
char
()
{
if
(
value
.
length
()
>
0
)
return
value
[
0
];
else
return
'\0'
;
}
operator
char
()
{
if
(
value
.
length
()
>
0
)
return
value
[
0
];
else
return
'\0'
;
}
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
_
(
PYBIND11_STRING_NAME
));
}
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
>
{
template
<>
class
type_caster
<
wchar_t
>
:
public
type_caster
<
std
::
wstring
>
{
...
@@ -420,8 +418,6 @@ public:
...
@@ -420,8 +418,6 @@ public:
operator
wchar_t
()
{
if
(
value
.
length
()
>
0
)
return
value
[
0
];
else
return
L'\0'
;
}
operator
wchar_t
()
{
if
(
value
.
length
()
>
0
)
return
value
[
0
];
else
return
L'\0'
;
}
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
_
(
PYBIND11_STRING_NAME
));
}
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
>>
{
template
<
typename
T1
,
typename
T2
>
class
type_caster
<
std
::
pair
<
T1
,
T2
>>
{
...
...
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