Rename ffi EventLoop to CppEventLoop in Rust

It's confusing to know which types are native to Rust and which
ones are C++ types. Most things have the convention of Cpp[SomeThing]
for ffi types. Do the same with the ffi EventLoop.

Change-Id: I8911048461c9b0e44473fdb2493a62dd238a14f9
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/events/event_loop_runtime.rs b/aos/events/event_loop_runtime.rs
index 9e6bcc5..dc1da07 100644
--- a/aos/events/event_loop_runtime.rs
+++ b/aos/events/event_loop_runtime.rs
@@ -71,6 +71,7 @@
 use aos_configuration::{ChannelLookupError, ConfigurationExt};
 
 pub use aos_uuid::UUID;
+pub use ffi::aos::EventLoop as CppEventLoop;
 pub use ffi::aos::EventLoopRuntime as CppEventLoopRuntime;
 pub use ffi::aos::ExitHandle as CppExitHandle;
 
@@ -97,8 +98,6 @@
 extern_cpp_type!("aos::UUID", crate::UUID)
 );
 
-pub type EventLoop = ffi::aos::EventLoop;
-
 /// A marker type which is invariant with respect to the given lifetime.
 ///
 /// When interacting with functions that take and return things with a given lifetime, the lifetime
@@ -169,13 +168,13 @@
 /// mostly-exclusive. In other words, nothing else may mutate it in any way except processing events
 /// (including dropping, because this object has to be the one to drop it).
 ///
-/// This also implies semantics similar to `Pin<&mut ffi::aos::EventLoop>` for the underlying object.
+/// This also implies semantics similar to `Pin<&mut CppEventLoop>` for the underlying object.
 /// Implementations of this trait must have exclusive ownership of it, and the underlying object
 /// must not be moved.
 pub unsafe trait EventLoopHolder {
     /// Converts this holder into a raw C++ pointer. This may be fed through other Rust and C++
     /// code, and eventually passed back to [`from_raw`].
-    fn into_raw(self) -> *mut ffi::aos::EventLoop;
+    fn into_raw(self) -> *mut CppEventLoop;
 
     /// Converts a raw C++ pointer back to a holder object.
     ///
@@ -183,7 +182,7 @@
     ///
     /// `raw` must be the result of [`into_raw`] on an instance of this same type. These raw
     /// pointers *are not* interchangeable between implementations of this trait.
-    unsafe fn from_raw(raw: *mut ffi::aos::EventLoop) -> Self;
+    unsafe fn from_raw(raw: *mut CppEventLoop) -> Self;
 }
 
 /// Owns an [`EventLoopRuntime`] and its underlying `aos::EventLoop`, with safe management of the
@@ -272,7 +271,7 @@
 }
 
 pub struct EventLoopRuntime<'event_loop>(
-    Pin<Box<ffi::aos::EventLoopRuntime>>,
+    Pin<Box<CppEventLoopRuntime>>,
     // See documentation of [`new`] for details.
     InvariantLifetime<'event_loop>,
 );
@@ -363,10 +362,10 @@
     /// Following these rules is very tricky. Be very cautious calling this function. It exposes an
     /// unbound lifetime, which means you should wrap it directly in a function that attaches a
     /// correct lifetime.
-    pub unsafe fn new(event_loop: *mut ffi::aos::EventLoop) -> Self {
+    pub unsafe fn new(event_loop: *mut CppEventLoop) -> Self {
         Self(
             // SAFETY: We push all the validity requirements for this up to our caller.
-            unsafe { ffi::aos::EventLoopRuntime::new(event_loop) }.within_box(),
+            unsafe { CppEventLoopRuntime::new(event_loop) }.within_box(),
             InvariantLifetime::default(),
         )
     }
@@ -383,7 +382,7 @@
     /// event loop in question isn't even an argument to this function so it's even trickier. Also
     /// note that you cannot call this on the result of [`into_cpp`] without violating those
     /// restrictions.
-    pub unsafe fn from_cpp(cpp: Pin<Box<ffi::aos::EventLoopRuntime>>) -> Self {
+    pub unsafe fn from_cpp(cpp: Pin<Box<CppEventLoopRuntime>>) -> Self {
         Self(cpp, InvariantLifetime::default())
     }
 
@@ -393,7 +392,7 @@
     ///
     /// Note that you *cannot* call [`from_cpp`] on the result of this, because that will violate
     /// [`from_cpp`]'s safety requirements.
-    pub fn into_cpp(self) -> Pin<Box<ffi::aos::EventLoopRuntime>> {
+    pub fn into_cpp(self) -> Pin<Box<CppEventLoopRuntime>> {
         self.0
     }
 
@@ -401,7 +400,7 @@
     ///
     /// The returned value should only be used for destroying it (_after_ `self` is dropped) or
     /// calling other C++ APIs.
-    pub fn raw_event_loop(&self) -> *mut ffi::aos::EventLoop {
+    pub fn raw_event_loop(&self) -> *mut CppEventLoop {
         self.0.event_loop()
     }
 
diff --git a/aos/events/event_loop_runtime_test_lib.rs b/aos/events/event_loop_runtime_test_lib.rs
index 120f8aa..ffcaa2e 100644
--- a/aos/events/event_loop_runtime_test_lib.rs
+++ b/aos/events/event_loop_runtime_test_lib.rs
@@ -1,7 +1,7 @@
 //! These test helpers have to live in a separate file because autocxx only generates one set of
 //! outputs per file, and that needs to be the non-`#[cfg(test)]` stuff.
 
-use aos_events_event_loop_runtime::{EventLoop, EventLoopRuntime, Fetcher, RawFetcher};
+use aos_events_event_loop_runtime::{CppEventLoop, EventLoopRuntime, Fetcher, RawFetcher};
 use ping_rust_fbs::aos::examples::{root_as_ping, Ping};
 use pong_rust_fbs::aos::examples::{Pong, PongBuilder};
 
@@ -151,7 +151,9 @@
         }
     }
 
-    unsafe fn make_test_application(event_loop: *mut EventLoop) -> Box<TestApplication<'static>> {
+    unsafe fn make_test_application(
+        event_loop: *mut CppEventLoop,
+    ) -> Box<TestApplication<'static>> {
         GLOBAL_STATE.with(|g| {
             let g = &mut *g.borrow_mut();
             g.creation_count += 1;
@@ -260,7 +262,7 @@
     }
 
     unsafe fn make_typed_test_application(
-        event_loop: *mut EventLoop,
+        event_loop: *mut CppEventLoop,
     ) -> Box<TypedTestApplication<'static>> {
         GLOBAL_STATE.with(|g| {
             let g = &mut *g.borrow_mut();
@@ -283,7 +285,9 @@
         }
     }
 
-    unsafe fn make_panic_application(event_loop: *mut EventLoop) -> Box<PanicApplication<'static>> {
+    unsafe fn make_panic_application(
+        event_loop: *mut CppEventLoop,
+    ) -> Box<PanicApplication<'static>> {
         Box::new(PanicApplication::new(EventLoopRuntime::new(event_loop)))
     }
 
@@ -304,7 +308,7 @@
     }
 
     unsafe fn make_panic_on_run_application(
-        event_loop: *mut EventLoop,
+        event_loop: *mut CppEventLoop,
     ) -> Box<PanicOnRunApplication<'static>> {
         Box::new(PanicOnRunApplication::new(EventLoopRuntime::new(
             event_loop,
@@ -315,19 +319,19 @@
     mod ffi_bridge {
         extern "Rust" {
             unsafe fn make_test_application(
-                event_loop: *mut EventLoop,
+                event_loop: *mut CppEventLoop,
             ) -> Box<TestApplication<'static>>;
 
             unsafe fn make_typed_test_application(
-                event_loop: *mut EventLoop,
+                event_loop: *mut CppEventLoop,
             ) -> Box<TypedTestApplication<'static>>;
 
             unsafe fn make_panic_application(
-                event_loop: *mut EventLoop,
+                event_loop: *mut CppEventLoop,
             ) -> Box<PanicApplication<'static>>;
 
             unsafe fn make_panic_on_run_application(
-                event_loop: *mut EventLoop,
+                event_loop: *mut CppEventLoop,
             ) -> Box<PanicOnRunApplication<'static>>;
 
             fn completed_test_count() -> u32;
@@ -359,7 +363,7 @@
         unsafe extern "C++" {
             include!("aos/events/event_loop.h");
             #[namespace = "aos"]
-            type EventLoop = crate::EventLoop;
+            type CppEventLoop = crate::CppEventLoop;
         }
     }
 }
diff --git a/aos/events/shm_event_loop.rs b/aos/events/shm_event_loop.rs
index 04cf42c..bc7cc0a 100644
--- a/aos/events/shm_event_loop.rs
+++ b/aos/events/shm_event_loop.rs
@@ -1,6 +1,7 @@
 pub use aos_configuration::{Configuration, ConfigurationExt};
-pub use aos_events_event_loop_runtime::EventLoop;
-pub use aos_events_event_loop_runtime::{CppExitHandle, EventLoopRuntime, ExitHandle};
+pub use aos_events_event_loop_runtime::{
+    CppEventLoop, CppExitHandle, EventLoopRuntime, ExitHandle,
+};
 
 use aos_configuration_fbs::aos::Configuration as RustConfiguration;
 use aos_flatbuffers::{transmute_table_to, Flatbuffer};
@@ -20,7 +21,7 @@
 
 extern_cpp_type!("aos::ExitHandle", crate::CppExitHandle)
 extern_cpp_type!("aos::Configuration", crate::Configuration)
-extern_cpp_type!("aos::EventLoop", crate::EventLoop)
+extern_cpp_type!("aos::EventLoop", crate::CppEventLoop)
 );
 
 /// A Rust-owned C++ `ShmEventLoop` object.
diff --git a/aos/events/simulated_event_loop.rs b/aos/events/simulated_event_loop.rs
index 0677efb..96c4e7e 100644
--- a/aos/events/simulated_event_loop.rs
+++ b/aos/events/simulated_event_loop.rs
@@ -5,7 +5,7 @@
 
 pub use aos_configuration::{Channel, Configuration, ConfigurationExt, Node};
 use aos_configuration_fbs::aos::Configuration as RustConfiguration;
-pub use aos_events_event_loop_runtime::{CppExitHandle, EventLoop, ExitHandle};
+pub use aos_events_event_loop_runtime::{CppEventLoop, CppExitHandle, ExitHandle};
 use aos_events_event_loop_runtime::{EventLoopHolder, EventLoopRuntime, EventLoopRuntimeHolder};
 use aos_flatbuffers::{transmute_table_to, Flatbuffer};
 
@@ -20,7 +20,7 @@
 extern_cpp_type!("aos::ExitHandle", crate::CppExitHandle)
 extern_cpp_type!("aos::Configuration", crate::Configuration)
 extern_cpp_type!("aos::Node", crate::Node)
-extern_cpp_type!("aos::EventLoop", crate::EventLoop)
+extern_cpp_type!("aos::EventLoop", crate::CppEventLoop)
 );
 
 /// A Rust-owned C++ `SimulatedEventLoopFactory` object.
@@ -62,7 +62,7 @@
     /// You probably don't want to call this directly if you're creating a Rust application. This
     /// is intended for creating C++ applications. Use [`make_runtime`] instead when creating Rust
     /// applications.
-    pub fn make_event_loop(&mut self, name: &str, node: Option<&Node>) -> UniquePtr<EventLoop> {
+    pub fn make_event_loop(&mut self, name: &str, node: Option<&Node>) -> UniquePtr<CppEventLoop> {
         // SAFETY:
         // * `self` has a valid C++ object.
         // * C++ doesn't need the lifetimes of `name` or `node` to last any longer than this method
@@ -121,11 +121,11 @@
     // pub fn spawn_on_startup(&mut self, spawner: impl FnMut());
 }
 
-pub struct SimulatedEventLoopHolder(UniquePtr<EventLoop>);
+pub struct SimulatedEventLoopHolder(UniquePtr<CppEventLoop>);
 
 impl SimulatedEventLoopHolder {
     /// SAFETY: `event_loop` must be the exclusive owner of the underlying EventLoop.
-    pub unsafe fn new(event_loop: UniquePtr<EventLoop>) -> Self {
+    pub unsafe fn new(event_loop: UniquePtr<CppEventLoop>) -> Self {
         Self(event_loop)
     }
 }