Commit 2476f47e authored by Kirill Smelkov's avatar Kirill Smelkov

time: Move constants .pxd -> .h

This makes them available for C++ users as well.
parent 5e1cb5ea
# cython: language_level=2
# Copyright (C) 2019 Nexedi SA and Contributors.
# 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
......@@ -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()
......
#ifndef _NXD_LIBGOLANG_TIME_H
#define _NXD_LIBGOLANG_TIME_H
// Copyright (C) 2019 Nexedi SA and Contributors.
// 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
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment