Remove some duplication in the documentation of API that's shared between Rust and C++

This change makes the start of sharing the docs for the `TimerMode` enum
between Rust and C++. The reference to Timer::start in there works as
both doxygen and rustdoc find the right reference, but this needs
careful editing in the future and double-checking!

Another "caveat" is that the docs for the TimerMode enum say that the
enum is defined in the file "sixtyfps_generated_public.h", which is
correct as-is but not as pretty as "sixtyfps.h". I tried various ways
with \file and \includedoc, but couldn't get it working differently.

To implement this, the cppdocs steps now also runs cbindgen and cbindgen
generates a new sixtyfps_generated_public.h file that contains types we
do want to have in the public sixtyfps namespace.
This commit is contained in:
Simon Hausmann 2022-01-05 14:40:17 +01:00 committed by Simon Hausmann
parent 81602353e2
commit 174fd2659f
6 changed files with 72 additions and 36 deletions

View file

@ -337,20 +337,6 @@ private:
private_api::WindowRc inner;
};
#if !defined(DOXYGEN)
using cbindgen_private::TimerMode;
#else
/// The TimerMode specifies what should happen after the timer fired.
///
/// Used by the sixtyfps::Timer::start() function.
enum class TimerMode {
/// A SingleShot timer is fired only once.
SingleShot,
/// A Repeated timer is fired repeatedly until it is stopped or dropped.
Repeated,
};
#endif
/// A Timer that can call a callback at repeated interval
///
/// Use the static single_shot function to make a single shot timer
@ -367,7 +353,7 @@ struct Timer
template<typename F>
Timer(std::chrono::milliseconds interval, F callback)
: id(cbindgen_private::sixtyfps_timer_start(
-1, cbindgen_private::TimerMode::Repeated, interval.count(),
-1, TimerMode::Repeated, interval.count(),
[](void *data) { (*reinterpret_cast<F *>(data))(); }, new F(std::move(callback)),
[](void *data) { delete reinterpret_cast<F *>(data); }))
{