Skip to content

Commit 0e6bdaf

Browse files
committed
Add multiple author support to module!
Change author into authors, allowing multiple authors of a module. Signed-off-by: wcampbell <[email protected]>
1 parent bd12347 commit 0e6bdaf

15 files changed

+48
-18
lines changed

drivers/android/rust_binder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use {context::Context, thread::Thread};
2828
module! {
2929
type: BinderModule,
3030
name: "rust_binder",
31-
author: "Wedson Almeida Filho",
31+
authors: ["Wedson Almeida Filho"],
3232
description: "Android Binder",
3333
license: "GPL",
3434
}

rust/macros/helpers.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ pub(crate) fn try_ident(it: &mut token_stream::IntoIter) -> Option<String> {
1010
}
1111
}
1212

13+
pub(crate) fn try_punct(it: &mut token_stream::IntoIter) -> Option<char> {
14+
if let Some(TokenTree::Punct(punct)) = it.next() {
15+
Some(punct.as_char())
16+
} else {
17+
None
18+
}
19+
}
20+
1321
pub(crate) fn try_literal(it: &mut token_stream::IntoIter) -> Option<String> {
1422
if let Some(TokenTree::Literal(literal)) = it.next() {
1523
Some(literal.to_string())

rust/macros/module.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct ModuleInfo {
215215
type_: String,
216216
license: String,
217217
name: String,
218-
author: Option<String>,
218+
authors: Option<Vec<String>>,
219219
description: Option<String>,
220220
alias: Option<String>,
221221
params: Option<Group>,
@@ -228,7 +228,7 @@ impl ModuleInfo {
228228
const EXPECTED_KEYS: &[&str] = &[
229229
"type",
230230
"name",
231-
"author",
231+
"authors",
232232
"description",
233233
"license",
234234
"alias",
@@ -257,7 +257,7 @@ impl ModuleInfo {
257257
match key.as_str() {
258258
"type" => info.type_ = expect_ident(it),
259259
"name" => info.name = expect_string_ascii(it),
260-
"author" => info.author = Some(expect_string(it)),
260+
"authors" => info.authors = Some(Self::parse_authors(it)),
261261
"description" => info.description = Some(expect_string(it)),
262262
"license" => info.license = expect_string_ascii(it),
263263
"alias" => info.alias = Some(expect_string_ascii(it)),
@@ -300,6 +300,26 @@ impl ModuleInfo {
300300

301301
info
302302
}
303+
304+
/// Parse ["First", "Second"] into Some(vec!["First", "Second"])
305+
fn parse_authors(it: &mut token_stream::IntoIter) -> Vec<String> {
306+
let mut authors: Vec<String> = vec![];
307+
let group = expect_group(it);
308+
assert_eq!(group.delimiter(), Delimiter::Bracket);
309+
let mut stream = group.stream().into_iter();
310+
loop {
311+
let author = expect_string(&mut stream);
312+
authors.push(author);
313+
if let Some(punct) = try_punct(&mut stream) {
314+
assert_eq!(punct, ',');
315+
} else {
316+
assert!(stream.next().is_none());
317+
break;
318+
}
319+
}
320+
321+
authors
322+
}
303323
}
304324

305325
pub(crate) fn module(ts: TokenStream) -> TokenStream {
@@ -308,8 +328,10 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
308328
let info = ModuleInfo::parse(&mut it);
309329

310330
let mut modinfo = ModInfoBuilder::new(info.name.as_ref());
311-
if let Some(author) = info.author {
312-
modinfo.emit("author", &author);
331+
if let Some(authors) = &info.authors {
332+
for author in authors {
333+
modinfo.emit("author", author);
334+
}
313335
}
314336
if let Some(description) = info.description {
315337
modinfo.emit("description", &description);

samples/rust/rust_chrdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use kernel::{chrdev, file};
88
module! {
99
type: RustChrdev,
1010
name: "rust_chrdev",
11-
author: "Rust for Linux Contributors",
11+
authors: ["Rust for Linux Contributors"],
1212
description: "Rust character device sample",
1313
license: "GPL",
1414
}

samples/rust/rust_echo_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl kernel::Module for RustEchoServer {
5454
module! {
5555
type: RustEchoServer,
5656
name: "rust_echo_server",
57-
author: "Rust for Linux Contributors",
57+
authors: ["Rust for Linux Contributors"],
5858
description: "Rust tcp echo sample",
5959
license: "GPL v2",
6060
}

samples/rust/rust_fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use kernel::{c_str, fs};
88
module_fs! {
99
type: RustFs,
1010
name: "rust_fs",
11-
author: "Rust for Linux Contributors",
11+
authors: ["Rust for Linux Contributors",
1212
license: "GPL",
1313
}
1414

samples/rust/rust_minimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use kernel::prelude::*;
77
module! {
88
type: RustMinimal,
99
name: "rust_minimal",
10-
author: "Rust for Linux Contributors",
10+
authors: ["Rust for Linux Contributors"],
1111
description: "Rust minimal sample",
1212
license: "GPL",
1313
}

samples/rust/rust_miscdev.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use kernel::{
1313
module! {
1414
type: RustMiscdev,
1515
name: "rust_miscdev",
16-
author: "Rust for Linux Contributors",
16+
authors: ["Rust for Linux Contributors"],
1717
description: "Rust miscellaneous device sample",
1818
license: "GPL",
1919
}

samples/rust/rust_module_parameters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use kernel::prelude::*;
77
module! {
88
type: RustModuleParameters,
99
name: "rust_module_parameters",
10-
author: "Rust for Linux Contributors",
10+
authors: ["Rust for Linux Contributors"],
1111
description: "Rust module parameters sample",
1212
license: "GPL",
1313
params: {

samples/rust/rust_print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use kernel::{pr_cont, str::CStr, ThisModule};
88
module! {
99
type: RustPrint,
1010
name: "rust_print",
11-
author: "Rust for Linux Contributors",
11+
authors: ["Rust for Linux Contributors"],
1212
description: "Rust printing macros sample",
1313
license: "GPL",
1414
}

samples/rust/rust_random.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use kernel::{
1414
module_misc_device! {
1515
type: RandomFile,
1616
name: "rust_random",
17-
author: "Rust for Linux Contributors",
17+
authors: ["Rust for Linux Contributors"],
1818
description: "Just use /dev/urandom: Now with early-boot safety",
1919
license: "GPL",
2020
}

samples/rust/rust_selftests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use kernel::prelude::*;
99
module! {
1010
type: RustSelftests,
1111
name: "rust_selftests",
12-
author: "Rust for Linux Contributors",
12+
authors: ["Rust for Linux Contributors"],
1313
description: "Self test cases for Rust",
1414
license: "GPL",
1515
}

samples/rust/rust_semaphore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use kernel::{
2828
module! {
2929
type: RustSemaphore,
3030
name: "rust_semaphore",
31-
author: "Rust for Linux Contributors",
31+
authors: ["Rust for Linux Contributors"],
3232
description: "Rust semaphore sample",
3333
license: "GPL",
3434
}

samples/rust/rust_stack_probing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use kernel::prelude::*;
77
module! {
88
type: RustStackProbing,
99
name: "rust_stack_probing",
10-
author: "Rust for Linux Contributors",
10+
authors: ["Rust for Linux Contributors"],
1111
description: "Rust stack probing sample",
1212
license: "GPL",
1313
}

samples/rust/rust_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use kernel::{
1111
module! {
1212
type: RustSync,
1313
name: "rust_sync",
14-
author: "Rust for Linux Contributors",
14+
authors: ["Rust for Linux Contributors"],
1515
description: "Rust synchronisation primitives sample",
1616
license: "GPL",
1717
}

0 commit comments

Comments
 (0)