-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch android_fn! to a proc_macro (#654)
* feat: switch android_fn! to a proc_macro * document the macros * add to CI * fix ci * again * one more
- Loading branch information
Showing
12 changed files
with
374 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,10 @@ | |
"tao": { | ||
"path": "./", | ||
"manager": "rust" | ||
}, | ||
"tao-macros": { | ||
"path": "./tao-macros", | ||
"manager": "rust" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "tao-macros" | ||
description = "Proc macros for tao" | ||
version = "0.0.0" | ||
edition = "2021" | ||
authors = ["Tauri Programme within The Commons Conservancy"] | ||
rust-version = "1.56" | ||
license = "MIT OR Apache-2.0" | ||
readme = "../README.md" | ||
repository = "https://github.com/tauri-apps/tao" | ||
documentation = "https://docs.rs/tao-macros" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
proc-macro2 = "1" | ||
quote = "1" | ||
syn = { version = "1", features = ["full"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use tao_macros::android_fn; | ||
|
||
struct JNIEnv; | ||
struct JClass; | ||
|
||
android_fn![com_example, tao_app, SomeClass, add, [i32, i32], i32]; | ||
unsafe fn add(_env: JNIEnv, _class: JClass, a: i32, b: i32) -> i32 { | ||
a + b | ||
} | ||
|
||
android_fn!(com_example, tao_app, SomeClass, add2, [i32, i32]); | ||
unsafe fn add2(_env: JNIEnv, _class: JClass, a: i32, b: i32) { | ||
let _ = a + b; | ||
} | ||
|
||
fn __store_package_name__() {} | ||
|
||
android_fn!( | ||
com_example, | ||
tao_app, | ||
SomeClass, | ||
add3, | ||
[i32, i32], | ||
__VOID__, | ||
[setup, main], | ||
__store_package_name__, | ||
); | ||
unsafe fn add3(_env: JNIEnv, _class: JClass, a: i32, b: i32, _setup: fn(), _main: fn()) { | ||
let _ = a + b; | ||
} | ||
|
||
fn setup() {} | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use tao_macros::generate_package_name; | ||
|
||
pub const PACKAGE: &str = generate_package_name!(com_example, tao_app); | ||
|
||
fn main() {} |
Oops, something went wrong.