Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
e33bf6d1
Commit
e33bf6d1
authored
Mar 26, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix call_sync for bound methods
parent
c307f373
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
17 deletions
+32
-17
typon/include/python/builtins.hpp
typon/include/python/builtins.hpp
+29
-14
typon/include/python/builtins/mutex.hpp
typon/include/python/builtins/mutex.hpp
+2
-2
typon/include/python/builtins/range.hpp
typon/include/python/builtins/range.hpp
+1
-1
No files found.
typon/include/python/builtins.hpp
View file @
e33bf6d1
...
...
@@ -15,7 +15,6 @@
#include <typon/typon.hpp>
#ifdef __cpp_lib_unreachable
#include <utility>
[[
noreturn
]]
inline
void
TYPON_UNREACHABLE
()
{
std
::
unreachable
();
}
...
...
@@ -394,6 +393,21 @@ using InterpGuard = py::scoped_interpreter;
template
<
typename
T
>
concept
HasSync
=
requires
(
T
t
)
{
typename
T
::
has_sync
;
};
template
<
typename
T
>
struct
HasBoundSync_t
{
static
constexpr
bool
value
=
false
;
};
template
<
typename
S
,
typename
F
>
struct
HasBoundSync_t
<
referencemodel
::
boundmethod
<
S
,
F
>>
{
static
constexpr
bool
value
=
HasSync
<
F
>
;
auto
operator
()(
auto
...
args
)
{
return
F
{}.
typon
$$
sync
(
S
{},
std
::
forward
<
decltype
(
args
)
>
(
args
)...);
}
};
template
<
typename
T
>
concept
HasBoundSync
=
HasBoundSync_t
<
T
>::
value
;
/*auto call_sync(auto f, auto... args) {
if constexpr (HasSync<decltype(f)>) {
return f.sync(std::forward<decltype(args)>(args)...);
...
...
@@ -407,6 +421,8 @@ auto call_sync(auto f) {
return
[
f
](
auto
...
args
)
{
return
f
.
typon
$$
sync
(
std
::
forward
<
decltype
(
args
)
>
(
args
)...);
};
}
else
if
constexpr
(
HasBoundSync
<
decltype
(
f
)
>
)
{
return
HasBoundSync_t
<
decltype
(
f
)
>
{};
}
else
{
return
f
;
}
...
...
@@ -422,23 +438,22 @@ template <auto IDX, typename T> auto constant_get(T &&val) {
}
struct
{
using
has_sync
=
std
::
true_type
;
using
has_sync
=
std
::
true_type
;
template
<
typename
T
>
auto
typon
$$
sync
(
T
value
)
const
->
decltype
(
referencemodel
::
Rc
(
future
(
std
::
declval
<
Task
<
T
>>
())))
{
//
return referencemodel::Rc(future(task));
throw
;
}
template
<
typename
T
>
auto
typon
$$
sync
(
T
value
)
const
->
decltype
(
referencemodel
::
Rc
(
future
(
std
::
declval
<
Task
<
T
>>
())))
{
//
return referencemodel::Rc(future(task));
throw
;
}
template
<
typename
Task
>
auto
operator
()(
Task
task
)
const
->
typon
::
Task
<
decltype
(
referencemodel
::
Rc
(
future
(
std
::
move
(
task
))))
>
{
co_return
referencemodel
::
Rc
(
co_await
future
(
std
::
move
(
task
)));
}
template
<
typename
Task
>
auto
operator
()(
Task
task
)
const
->
typon
::
Task
<
decltype
(
referencemodel
::
Rc
(
future
(
std
::
move
(
task
))))
>
{
co_return
referencemodel
::
Rc
(
co_await
future
(
std
::
move
(
task
)));
}
}
static
constexpr
future_stdlib
{};
}
;
// namespace typon
#endif // TYPON_BUILTINS_HPP
typon/include/python/builtins/mutex.hpp
View file @
e33bf6d1
...
...
@@ -6,8 +6,8 @@
namespace
view
=
std
::
views
;
#include <python/basedef.hpp>
#include "print.hpp"
#include <python/basedef.hpp>
namespace
typon
{
using
namespace
referencemodel
;
...
...
@@ -40,7 +40,7 @@ struct TyMutex__oo : classtype<_Base0, TyMutex__oo<>> {
auto
typon
$$
sync
(
auto
,
auto
)
->
TyNone
const
{
return
None
;
}
auto
operator
()(
auto
_self
,
auto
callback
)
->
typon
::
Task
<
TyNone
>
const
{
print
(
"1"
_ps
);
print
(
"1"
_ps
);
auto
self
=
arc
(
_self
);
print
(
"2"
_ps
);
auto
lock
=
dot
(
self
,
mutex
).
lock
();
...
...
typon/include/python/builtins/range.hpp
View file @
e33bf6d1
...
...
@@ -9,8 +9,8 @@
namespace
view
=
std
::
views
;
#include <python/basedef.hpp>
#include "int.hpp"
#include <python/basedef.hpp>
auto
stride
=
[](
int
n
)
{
return
[
s
=
-
1
,
n
](
auto
const
&
)
mutable
{
...
...
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