Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
http-server
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
Stefane Fermigier
http-server
Commits
518f6ec7
Commit
518f6ec7
authored
Oct 29, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helloworld.pyx
parent
2ddd8aaa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
2 deletions
+57
-2
src/Makefile
src/Makefile
+14
-0
src/helloworld.pyx
src/helloworld.pyx
+17
-0
src/setup.py
src/setup.py
+21
-0
src/stdlib/string.pxd
src/stdlib/string.pxd
+5
-2
No files found.
src/Makefile
0 → 100644
View file @
518f6ec7
%.so
:
%.pyx
python3 setup.py build_ext
--inplace
$*
&&
mv
$*
.
*
.so
$@
%
:
%.so
@
echo
">>> import
$@
"
&&
python3
-c
"import
$@
"
clean
:
rm
-rf
build
rm
-rf
*
.cpp
*
.c
rm
-rf
*
.so
.PHONY
:
clean
.PRECIOUS
:
%.so
.SUFFIXES
:
src/helloworld.pyx
0 → 100644
View file @
518f6ec7
from
stdlib.string
cimport
Str
from
libc.stdio
cimport
puts
def
main
():
with
nogil
:
hello
=
Str
(
"hello"
)
world
=
Str
(
"world"
)
hello_world
=
hello
+
world
puts
(
Str
.
to_c_str
(
hello_world
))
hello_again
=
hello_world
.
slice
(
0
,
5
)
puts
(
Str
.
to_c_str
(
hello_again
))
world_again
=
hello_world
.
slice
(
5
,
10
)
puts
(
Str
.
to_c_str
(
world_again
))
main
()
src/setup.py
0 → 100644
View file @
518f6ec7
from
distutils.core
import
setup
from
distutils.extension
import
Extension
from
Cython.Build
import
cythonize
import
sys
src
=
sys
.
argv
[
-
1
]
sys
.
argv
[:]
=
sys
.
argv
[:
-
1
]
extensions
=
[
Extension
(
src
,
language
=
'c++'
,
sources
=
[
src
+
'.pyx'
],
extra_compile_args
=
[
'-std=c++17'
],
)
]
setup
(
ext_modules
=
cythonize
(
extensions
)
)
src/stdlib/string.pxd
View file @
518f6ec7
...
...
@@ -77,8 +77,11 @@ cdef cypclass Str:
cat
.
_s
=
string_view
(
s
,
l1
+
l2
)
return
cat
const
char
*
to_c_str
(
self
):
return
self
.
_s
.
data
()
@
staticmethod
const
char
*
to_c_str
(
Str
s
):
if
s
is
NULL
:
return
NULL
return
s
.
_s
.
data
()
@
staticmethod
Str
steal_c_str
(
const
char
*
s
,
size_t
size
):
...
...
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