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
098f9aef
Commit
098f9aef
authored
Jul 18, 2016
by
Ivan Smirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace 4096B format buffer with std::string
parent
f5f75c65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
include/pybind11/numpy.h
+3
-3
No files found.
include/pybind11/numpy.h
View file @
098f9aef
...
@@ -291,7 +291,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
...
@@ -291,7 +291,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
static
const
char
*
format
()
{
static
const
char
*
format
()
{
if
(
!
dtype_
())
if
(
!
dtype_
())
pybind11_fail
(
"NumPy: unsupported buffer format!"
);
pybind11_fail
(
"NumPy: unsupported buffer format!"
);
return
format_
();
return
format_
()
.
c_str
()
;
}
}
static
void
register_dtype
(
std
::
initializer_list
<
field_descriptor
>
fields
)
{
static
void
register_dtype
(
std
::
initializer_list
<
field_descriptor
>
fields
)
{
...
@@ -337,7 +337,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
...
@@ -337,7 +337,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
if
(
sizeof
(
T
)
>
offset
)
if
(
sizeof
(
T
)
>
offset
)
oss
<<
(
sizeof
(
T
)
-
offset
)
<<
'x'
;
oss
<<
(
sizeof
(
T
)
-
offset
)
<<
'x'
;
oss
<<
'}'
;
oss
<<
'}'
;
std
::
strncpy
(
format_
(),
oss
.
str
().
c_str
(),
4096
);
format_
()
=
oss
.
str
(
);
// Sanity check: verify that NumPy properly parses our buffer format string
// Sanity check: verify that NumPy properly parses our buffer format string
auto
arr
=
array
(
buffer_info
(
nullptr
,
sizeof
(
T
),
format
(),
1
,
{
0
},
{
sizeof
(
T
)
}));
auto
arr
=
array
(
buffer_info
(
nullptr
,
sizeof
(
T
),
format
(),
1
,
{
0
},
{
sizeof
(
T
)
}));
...
@@ -348,7 +348,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
...
@@ -348,7 +348,7 @@ struct npy_format_descriptor<T, typename std::enable_if<is_pod_struct<T>::value>
private
:
private
:
static
inline
PyObject
*&
dtype_
()
{
static
PyObject
*
ptr
=
nullptr
;
return
ptr
;
}
static
inline
PyObject
*&
dtype_
()
{
static
PyObject
*
ptr
=
nullptr
;
return
ptr
;
}
static
inline
char
*
format_
()
{
static
char
s
[
4096
]
;
return
s
;
}
static
inline
std
::
string
&
format_
()
{
static
std
::
string
s
;
return
s
;
}
};
};
// Extract name, offset and format descriptor for a struct field
// Extract name, offset and format descriptor for a struct field
...
...
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