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
08927e98
Commit
08927e98
authored
Mar 26, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tabs->spaces
parent
9883ec01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
include/pybind11/cast.h
+30
-30
No files found.
include/pybind11/cast.h
View file @
08927e98
...
...
@@ -406,14 +406,14 @@ protected:
template
<>
class
type_caster
<
std
::
wstring
>
{
public
:
bool
load
(
handle
src
,
bool
)
{
object
temp
;
handle
load_src
=
src
;
if
(
!
PyUnicode_Check
(
load_src
.
ptr
()))
{
temp
=
object
(
PyUnicode_FromObject
(
load_src
.
ptr
()),
false
);
if
(
!
temp
)
{
PyErr_Clear
();
return
false
;
}
load_src
=
temp
;
}
bool
load
(
handle
src
,
bool
)
{
object
temp
;
handle
load_src
=
src
;
if
(
!
PyUnicode_Check
(
load_src
.
ptr
()))
{
temp
=
object
(
PyUnicode_FromObject
(
load_src
.
ptr
()),
false
);
if
(
!
temp
)
{
PyErr_Clear
();
return
false
;
}
load_src
=
temp
;
}
wchar_t
*
buffer
=
nullptr
;
ssize_t
length
=
-
1
;
#if PY_MAJOR_VERSION >= 3
...
...
@@ -430,24 +430,24 @@ public:
}
#endif
if
(
!
buffer
)
{
PyErr_Clear
();
return
false
;
}
value
=
std
::
wstring
(
buffer
,
length
);
success
=
true
;
return
true
;
}
value
=
std
::
wstring
(
buffer
,
length
);
success
=
true
;
return
true
;
}
static
handle
cast
(
const
std
::
wstring
&
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
return
PyUnicode_FromWideChar
(
src
.
c_str
(),
src
.
length
());
}
static
handle
cast
(
const
std
::
wstring
&
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
return
PyUnicode_FromWideChar
(
src
.
c_str
(),
src
.
length
());
}
PYBIND11_TYPE_CASTER
(
std
::
wstring
,
_
(
PYBIND11_STRING_NAME
));
PYBIND11_TYPE_CASTER
(
std
::
wstring
,
_
(
PYBIND11_STRING_NAME
));
protected
:
bool
success
=
false
;
};
template
<>
class
type_caster
<
char
>
:
public
type_caster
<
std
::
string
>
{
public
:
bool
load
(
handle
src
,
bool
convert
)
{
if
(
src
.
ptr
()
==
Py_None
)
{
return
true
;
}
bool
load
(
handle
src
,
bool
convert
)
{
if
(
src
.
ptr
()
==
Py_None
)
{
return
true
;
}
return
type_caster
<
std
::
string
>::
load
(
src
,
convert
);
}
...
...
@@ -462,32 +462,32 @@ public:
}
operator
char
*
()
{
return
success
?
(
char
*
)
value
.
c_str
()
:
nullptr
;
}
operator
char
&
()
{
return
value
[
0
];
}
operator
char
&
()
{
return
value
[
0
];
}
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
_
(
PYBIND11_STRING_NAME
));
}
};
template
<>
class
type_caster
<
wchar_t
>
:
public
type_caster
<
std
::
wstring
>
{
public
:
bool
load
(
handle
src
,
bool
convert
)
{
if
(
src
.
ptr
()
==
Py_None
)
{
return
true
;
}
bool
load
(
handle
src
,
bool
convert
)
{
if
(
src
.
ptr
()
==
Py_None
)
{
return
true
;
}
return
type_caster
<
std
::
wstring
>::
load
(
src
,
convert
);
}
static
handle
cast
(
const
wchar_t
*
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
static
handle
cast
(
const
wchar_t
*
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
if
(
src
==
nullptr
)
return
handle
(
Py_None
).
inc_ref
();
return
PyUnicode_FromWideChar
(
src
,
wcslen
(
src
));
}
return
PyUnicode_FromWideChar
(
src
,
wcslen
(
src
));
}
static
handle
cast
(
wchar_t
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
wchar_t
wstr
[
2
]
=
{
src
,
L'\0'
};
return
PyUnicode_FromWideChar
(
wstr
,
1
);
}
static
handle
cast
(
wchar_t
src
,
return_value_policy
/* policy */
,
handle
/* parent */
)
{
wchar_t
wstr
[
2
]
=
{
src
,
L'\0'
};
return
PyUnicode_FromWideChar
(
wstr
,
1
);
}
operator
wchar_t
*
()
{
return
success
?
(
wchar_t
*
)
value
.
c_str
()
:
nullptr
;
}
operator
wchar_t
&
()
{
return
value
[
0
];
}
operator
wchar_t
&
()
{
return
value
[
0
];
}
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
_
(
PYBIND11_STRING_NAME
));
}
static
PYBIND11_DESCR
name
()
{
return
type_descr
(
_
(
PYBIND11_STRING_NAME
));
}
};
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