Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pygolang
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
pygolang
Commits
2476f47e
Commit
2476f47e
authored
Mar 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time: Move constants .pxd -> .h
This makes them available for C++ users as well.
parent
5e1cb5ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
26 deletions
+20
-26
golang/_time.pxd
golang/_time.pxd
+9
-24
golang/time.h
golang/time.h
+11
-2
No files found.
golang/_time.pxd
View file @
2476f47e
# cython: language_level=2
# Copyright (C) 2019 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
# Copyright (C) 2019
-2020
Nexedi SA and Contributors.
#
Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
...
...
@@ -30,29 +30,14 @@ See also https://golang.org/pkg/time for Go time package documentation.
from
golang
cimport
chan
,
cbool
,
refptr
# golang/pyx - the same as std python - represents time as float
cdef
extern
from
*
nogil
:
# XXX how to declare/share constants without C verbatim?
"""
#ifndef _golang_time_pxd_h
#define _golang_time_pxd_h
# define golang_time_second (1.0)
# define golang_time_nanosecond (1E-9 * golang_time_second)
# define golang_time_microsecond (1E-6 * golang_time_second)
# define golang_time_millisecond (1E-3 * golang_time_second)
# define golang_time_minute (60 * golang_time_second)
# define golang_time_hour (60 * golang_time_minute)
#endif // _golang_time_pxd_h
"""
const
double
second
"golang_time_second"
const
double
nanosecond
"golang_time_nanosecond"
const
double
microsecond
"golang_time_microsecond"
const
double
millisecond
"golang_time_millisecond"
const
double
minute
"golang_time_minute"
const
double
hour
"golang_time_hour"
cdef
extern
from
"golang/time.h"
namespace
"golang::time"
nogil
:
const
double
second
const
double
nanosecond
const
double
microsecond
const
double
millisecond
const
double
minute
const
double
hour
void
sleep
(
double
dt
)
double
now
()
...
...
golang/time.h
View file @
2476f47e
#ifndef _NXD_LIBGOLANG_TIME_H
#define _NXD_LIBGOLANG_TIME_H
// Copyright (C) 2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Copyright (C) 2019
-2020
Nexedi SA and Contributors.
//
Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
...
...
@@ -67,6 +67,15 @@ LIBGOLANG_API uint64_t _nanotime(void);
namespace
golang
{
namespace
time
{
// golang/pyx/c++ - the same as std python - represents time as float
constexpr
double
second
=
1.0
;
constexpr
double
nanosecond
=
1E-9
*
second
;
constexpr
double
microsecond
=
1E-6
*
second
;
constexpr
double
millisecond
=
1E-3
*
second
;
constexpr
double
minute
=
60
*
second
;
constexpr
double
hour
=
60
*
minute
;
// sleep pauses current goroutine for at least dt seconds.
LIBGOLANG_API
void
sleep
(
double
dt
);
...
...
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