Rename app_init to android_init
This commit is contained in:
1 parent
aa33d55a70
commit
0ead062379
12 files changed
+16
-16
No files matched your search
+1
-1
@@ -794,7 +794,7 @@ ssh case are one implementation.
|
|||||||
|
|
||||||
**An Iris Android application supplies an initialization function and its own
|
**An Iris Android application supplies an initialization function and its own
|
||||||
state/resources; Iris supplies the JNI host and APK packager.**
|
state/resources; Iris supplies the JNI host and APK packager.**
|
||||||
`#[iris::app_init]` marks the initializer Android calls when it creates the Iris
|
`#[iris::android_init]` marks the initializer Android calls when it creates the Iris
|
||||||
view. The macro target-gates the initializer and generates the single exported
|
view. The macro target-gates the initializer and generates the single exported
|
||||||
`JNI_OnLoad` plus the concrete `android-view` registration callback. The
|
`JNI_OnLoad` plus the concrete `android-view` registration callback. The
|
||||||
simple form mutates `AndroidUiState` through a reference. An application with
|
simple form mutates `AndroidUiState` through a reference. An application with
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ impl AndroidAppState for State {
|
|||||||
type Resources = Resources;
|
type Resources = Resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(mut ui_state: AndroidUiState, rsc: &mut Resources) -> State {
|
fn create(mut ui_state: AndroidUiState, rsc: &mut Resources) -> State {
|
||||||
rsc.launches += 1;
|
rsc.launches += 1;
|
||||||
rect(PaintId::RED)
|
rect(PaintId::RED)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use iris::prelude::*;
|
|||||||
#[path = "lib.rs"]
|
#[path = "lib.rs"]
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use iris::prelude::*;
|
|||||||
#[path = "lib.rs"]
|
#[path = "lib.rs"]
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use iris::prelude::*;
|
|||||||
#[path = "lib.rs"]
|
#[path = "lib.rs"]
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl AndroidAppState for Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(mut ui_state: AndroidUiState, rsc: &mut StdRsc<Client>) -> Client {
|
fn create(mut ui_state: AndroidUiState, rsc: &mut StdRsc<Client>) -> Client {
|
||||||
let widgets = app::build(rsc, &mut ui_state);
|
let widgets = app::build(rsc, &mut ui_state);
|
||||||
app::update_info(rsc, widgets.info, 0);
|
app::update_info(rsc, widgets.info, 0);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use iris::prelude::*;
|
|||||||
#[path = "lib.rs"]
|
#[path = "lib.rs"]
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use iris::prelude::*;
|
|||||||
#[path = "lib.rs"]
|
#[path = "lib.rs"]
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ use syn::{
|
|||||||
/// JNI glue is Android-gated; the annotated function therefore does not need
|
/// JNI glue is Android-gated; the annotated function therefore does not need
|
||||||
/// its own `cfg` attribute.
|
/// its own `cfg` attribute.
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn app_init(args: TokenStream, item: TokenStream) -> TokenStream {
|
pub fn android_init(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
return Error::new(
|
return Error::new(
|
||||||
proc_macro2::Span::call_site(),
|
proc_macro2::Span::call_site(),
|
||||||
"app_init takes no arguments",
|
"android_init takes no arguments",
|
||||||
)
|
)
|
||||||
.into_compile_error()
|
.into_compile_error()
|
||||||
.into();
|
.into();
|
||||||
@@ -44,7 +44,7 @@ pub fn app_init(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
{
|
{
|
||||||
return Error::new(
|
return Error::new(
|
||||||
function.sig.inputs.span(),
|
function.sig.inputs.span(),
|
||||||
"an app_init function takes UI state and resources",
|
"an android_init function takes UI state and resources",
|
||||||
)
|
)
|
||||||
.into_compile_error()
|
.into_compile_error()
|
||||||
.into();
|
.into();
|
||||||
@@ -56,7 +56,7 @@ pub fn app_init(args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
{
|
{
|
||||||
return Error::new(
|
return Error::new(
|
||||||
function.sig.span(),
|
function.sig.span(),
|
||||||
"an app_init function must be a plain, non-generic synchronous function",
|
"an android_init function must be a plain, non-generic synchronous function",
|
||||||
)
|
)
|
||||||
.into_compile_error()
|
.into_compile_error()
|
||||||
.into();
|
.into();
|
||||||
|
|||||||
+2
-2
@@ -25,7 +25,7 @@ application-id = "com.example.myapp"
|
|||||||
label = "My app"
|
label = "My app"
|
||||||
```
|
```
|
||||||
|
|
||||||
`#[iris::app_init]` marks the initializer called when Android creates the Iris
|
`#[iris::android_init]` marks the initializer called when Android creates the Iris
|
||||||
view. The attribute supplies its own Android target gate and generates the JNI
|
view. The attribute supplies its own Android target gate and generates the JNI
|
||||||
loader glue. An application with no state beyond the UI state receives
|
loader glue. An application with no state beyond the UI state receives
|
||||||
`AndroidUiState` directly by mutable reference:
|
`AndroidUiState` directly by mutable reference:
|
||||||
@@ -37,7 +37,7 @@ fn build<Rsc: UiRsc>(rsc: &mut Rsc, ui_state: &mut impl HasRoot<Rsc>) {
|
|||||||
rect(PaintId::RED).set_root(rsc, ui_state);
|
rect(PaintId::RED).set_root(rsc, ui_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[iris::app_init]
|
#[iris::android_init]
|
||||||
fn create(
|
fn create(
|
||||||
ui_state: &mut AndroidUiState,
|
ui_state: &mut AndroidUiState,
|
||||||
rsc: &mut StdRsc<AndroidUiState>,
|
rsc: &mut StdRsc<AndroidUiState>,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub use view::{
|
|||||||
WindowInsets, new_peer,
|
WindowInsets, new_peer,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Types used by `#[iris::app_init]`'s generated JNI boundary.
|
/// Types used by `#[iris::android_init]`'s generated JNI boundary.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod __private {
|
pub mod __private {
|
||||||
pub use android_view::{Context, View, jni::JNIEnv};
|
pub use android_view::{Context, View, jni::JNIEnv};
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ mod layout_tests;
|
|||||||
pub use image;
|
pub use image;
|
||||||
pub use iris_core as core;
|
pub use iris_core as core;
|
||||||
pub use iris_macro as macros;
|
pub use iris_macro as macros;
|
||||||
pub use iris_macro::app_init;
|
pub use iris_macro::android_init;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
Reference in new issue
Block a user