Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
02c9d02e
Commit
02c9d02e
authored
Aug 23, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update PyObj definition
parent
58e0a3dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
10 deletions
+63
-10
rt/include/python/builtins.hpp
rt/include/python/builtins.hpp
+63
-10
No files found.
rt/include/python/builtins.hpp
View file @
02c9d02e
...
...
@@ -36,7 +36,7 @@
#define FUNCTION(ret, name, args, ...) \
struct
{
\
ret
operator
()
args
__VA_ARGS__
\
ret
operator
()
args
const
__VA_ARGS__
\
}
static
constexpr
name
;
using
namespace
std
::
literals
;
...
...
@@ -59,7 +59,67 @@ template <PySmartPtr T> struct RealType<T> {
using
type
=
typename
T
::
element_type
;
};
template
<
typename
T
>
using
PyObj
=
std
::
shared_ptr
<
typename
RealType
<
T
>::
type
>
;
//template <typename T> using PyObj = std::shared_ptr<typename RealType<T>::type>;
template
<
typename
T
>
class
PyObj
:
public
std
::
shared_ptr
<
typename
RealType
<
T
>::
type
>
{
public:
using
inner
=
typename
RealType
<
T
>::
type
;
/*PyObj() : std::shared_ptr<inner>() {}
PyObj(std::nullptr_t) : std::shared_ptr<inner>(nullptr) {}
PyObj(inner *ptr) : std::shared_ptr<inner>(ptr) {}
PyObj(const std::shared_ptr<inner> &ptr) : std::shared_ptr<inner>(ptr) {}
PyObj(std::shared_ptr<inner> &&ptr) : std::shared_ptr<inner>(ptr) {}
PyObj(const PyObj &ptr) : std::shared_ptr<inner>(ptr) {}
PyObj(PyObj &&ptr) : std::shared_ptr<inner>(ptr) {}
PyObj &operator=(const PyObj &ptr) { std::shared_ptr<inner>::operator=(ptr); return *this; }
PyObj &operator=(PyObj &&ptr) { std::shared_ptr<inner>::operator=(ptr); return *this; }
PyObj &operator=(std::nullptr_t) { std::shared_ptr<inner>::operator=(nullptr); return *this; }
PyObj &operator=(inner *ptr) { std::shared_ptr<inner>::operator=(ptr); return *this; }
PyObj &operator=(const std::shared_ptr<inner> &ptr) { std::shared_ptr<inner>::operator=(ptr); return *this; }
template<typename U>
PyObj(const PyObj<U> &ptr) : std::shared_ptr<inner>(ptr) {}
template<typename U>
PyObj(PyObj<U> &&ptr) : std::shared_ptr<inner>(ptr) {}*/
template
<
typename
...
Args
>
PyObj
(
Args
&&
...
args
)
:
std
::
shared_ptr
<
inner
>
(
std
::
forward
<
Args
>
(
args
)...)
{}
// using make_shared
template
<
class
U
>
PyObj
(
const
U
&
other
)
:
std
::
shared_ptr
<
inner
>
(
std
::
make_shared
<
T
>
(
other
))
{}
template
<
class
U
>
bool
operator
==
(
const
PyObj
<
U
>
&
other
)
const
{
// check null
if
(
this
->
get
()
==
other
.
get
())
{
return
true
;
}
if
(
this
->
get
()
==
nullptr
||
other
.
get
()
==
nullptr
)
{
return
false
;
}
return
*
this
->
get
()
==
*
other
.
get
();
}
template
<
class
U
>
bool
operator
==
(
const
U
&
other
)
const
{
if
(
this
->
get
()
==
nullptr
)
{
return
false
;
}
return
*
this
->
get
()
==
other
;
}
template
<
class
U
>
bool
py_is
(
const
PyObj
<
U
>
&
other
)
const
{
return
this
->
get
()
==
other
.
get
();
}
};
template
<
typename
T
,
typename
...
Args
>
auto
pyobj
(
Args
&&
...
args
)
->
PyObj
<
T
>
{
return
std
::
make_shared
<
typename
RealType
<
T
>::
type
>
(
...
...
@@ -123,14 +183,7 @@ std::ostream &operator<<(std::ostream &os, std::optional<T> const &opt) {
bool
is_cpp
()
{
return
true
;
}
class
NoneType
{
public:
template
<
typename
T
>
operator
T
*
()
const
{
return
nullptr
;
}
template
<
typename
T
>
operator
std
::
optional
<
T
>
()
const
{
return
std
::
nullopt
;
}
}
PyNone
{};
static
constexpr
auto
PyNone
=
std
::
nullopt
;
#define system_error(err, message) \
do
{
\
...
...
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