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
578ab3c4
Commit
578ab3c4
authored
Nov 03, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix include cycle
parent
98ffcdd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
+25
-15
typon/include/python/builtins/print.hpp
typon/include/python/builtins/print.hpp
+1
-14
typon/include/python/builtins/str.hpp
typon/include/python/builtins/str.hpp
+24
-1
No files found.
typon/include/python/builtins/print.hpp
View file @
578ab3c4
...
...
@@ -8,7 +8,6 @@
#include <iostream>
#include <ostream>
#include <functional>
#include "str.hpp"
#include <typon/typon.hpp>
template
<
typename
T
>
...
...
@@ -62,10 +61,6 @@ void repr_to(const std::function<T> &x, std::ostream &s) {
<<
">"
;
}
template
<
>
void
repr_to
(
const
PyStr
&
x
,
std
::
ostream
&
s
)
{
s
<<
'"'
<<
x
<<
'"'
;
}
template
<
Streamable
T
>
requires
(
Reprable
<
T
>
)
void
print_to
(
const
T
&
x
,
std
::
ostream
&
s
)
{
...
...
@@ -82,7 +77,6 @@ void repr_to(const std::shared_ptr<T> &x, std::ostream &s) {
repr_to
(
*
x
,
s
);
}
template
<
>
void
print_to
<
PyStr
>
(
const
PyStr
&
x
,
std
::
ostream
&
s
)
{
s
<<
x
;
}
/*
template <Printable T, Printable... Args>
typon::Task<void> print(T const &head, Args const &...args) {
...
...
@@ -103,13 +97,6 @@ struct {
}
print
;
// typon::Task<void> print() { std::cout << '\n'; co_return; }
struct
{
PyStr
operator
()(
const
PyStr
&
s
=
""
_ps
)
{
std
::
cout
<<
s
;
PyStr
input
;
std
::
getline
(
std
::
cin
,
input
);
return
input
;
}
}
input
;
#endif // TYPON_PRINT_HPP
typon/include/python/builtins/str.hpp
View file @
578ab3c4
...
...
@@ -16,6 +16,7 @@ using namespace std::literals;
#include "slice.hpp"
// #include <format>
#include <fmt/format.h>
#include <pybind11/cast.h>
class
PyStr
:
public
std
::
string
{
public:
...
...
@@ -119,7 +120,7 @@ template <typename T> PyStr str(const T &x) {
template
<
typename
T
>
PyStr
repr
(
const
T
&
x
)
{
std
::
stringstream
s
;
repr_to
(
x
,
s
);
::
repr_to
(
x
,
s
);
return
s
.
str
();
}
...
...
@@ -129,4 +130,26 @@ template <> struct std::hash<PyStr> {
}
};
namespace
PYBIND11_NAMESPACE
{
namespace
detail
{
template
<
>
struct
type_caster
<
PyStr
>
:
string_caster
<
PyStr
>
{};
}}
template
<
>
void
repr_to
(
const
PyStr
&
x
,
std
::
ostream
&
s
)
{
s
<<
'"'
<<
x
<<
'"'
;
}
template
<
>
void
print_to
<
PyStr
>
(
const
PyStr
&
x
,
std
::
ostream
&
s
)
{
s
<<
x
;
}
struct
{
PyStr
operator
()(
const
PyStr
&
s
=
""
_ps
)
{
std
::
cout
<<
s
;
PyStr
input
;
std
::
getline
(
std
::
cin
,
input
);
return
input
;
}
}
input
;
#endif // TYPON_STR_HPP
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