-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
142 additions
and
124 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use super::*; | ||
|
||
use std::sync::atomic::{AtomicPtr, Ordering}; | ||
|
||
static CONFIG: AtomicPtr<Config> = AtomicPtr::new(std::ptr::null_mut()); | ||
|
||
pub fn config() -> &'static Config { | ||
let ptr = CONFIG.load(Ordering::Relaxed); | ||
|
||
if ptr.is_null() { | ||
panic!(); | ||
} else { | ||
unsafe { &*ptr } | ||
} | ||
} | ||
|
||
pub struct Config { | ||
pub types: TypeMap, | ||
pub references: References, | ||
pub output: String, | ||
pub flat: bool, | ||
pub no_allow: bool, | ||
pub no_comment: bool, | ||
pub no_core: bool, | ||
pub no_toml: bool, | ||
pub package: bool, | ||
pub rustfmt: String, | ||
pub sys: bool, | ||
pub implement: bool, | ||
pub derive: Derive, | ||
} | ||
|
||
impl Config { | ||
pub fn init(value: Self) { | ||
let config = Box::leak(Box::new(value)); | ||
CONFIG.store(config, Ordering::Relaxed); | ||
} | ||
} |
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
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
Oops, something went wrong.