-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basics of metadata generation (#1633)
- Loading branch information
Showing
75 changed files
with
856 additions
and
59 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
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 |
---|---|---|
@@ -1,43 +1,2 @@ | ||
mod array_info; | ||
mod async_kind; | ||
mod blob; | ||
mod cfg; | ||
mod codes; | ||
mod constant_value; | ||
mod file; | ||
mod guid; | ||
mod interface_kind; | ||
mod param_flags; | ||
mod row; | ||
mod signature; | ||
mod signature_kind; | ||
mod tables; | ||
mod traits; | ||
mod r#type; | ||
mod type_kind; | ||
mod type_name; | ||
mod type_reader; | ||
mod type_tree; | ||
mod workspace; | ||
|
||
pub use array_info::*; | ||
pub use async_kind::*; | ||
pub use blob::*; | ||
pub use cfg::*; | ||
pub use codes::*; | ||
pub use constant_value::*; | ||
pub use file::*; | ||
pub use guid::*; | ||
pub use interface_kind::*; | ||
pub use param_flags::*; | ||
pub use r#type::*; | ||
pub use row::*; | ||
pub use signature::*; | ||
pub use signature_kind::*; | ||
pub use tables::*; | ||
pub use traits::*; | ||
pub use type_kind::*; | ||
pub use type_name::*; | ||
pub use type_reader::*; | ||
pub use type_tree::*; | ||
pub use workspace::*; | ||
pub mod reader; | ||
pub mod writer; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,43 @@ | ||
mod array_info; | ||
mod async_kind; | ||
mod blob; | ||
mod cfg; | ||
mod codes; | ||
mod constant_value; | ||
mod file; | ||
mod guid; | ||
mod interface_kind; | ||
mod param_flags; | ||
mod row; | ||
mod signature; | ||
mod signature_kind; | ||
mod tables; | ||
mod traits; | ||
mod r#type; | ||
mod type_kind; | ||
mod type_name; | ||
mod type_reader; | ||
mod type_tree; | ||
mod workspace; | ||
|
||
pub use array_info::*; | ||
pub use async_kind::*; | ||
pub use blob::*; | ||
pub use cfg::*; | ||
pub use codes::*; | ||
pub use constant_value::*; | ||
pub use file::*; | ||
pub use guid::*; | ||
pub use interface_kind::*; | ||
pub use param_flags::*; | ||
pub use r#type::*; | ||
pub use row::*; | ||
pub use signature::*; | ||
pub use signature_kind::*; | ||
pub use tables::*; | ||
pub use traits::*; | ||
pub use type_kind::*; | ||
pub use type_name::*; | ||
pub use type_reader::*; | ||
pub use type_tree::*; | ||
pub use workspace::*; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,37 @@ | ||
use super::*; | ||
|
||
pub(crate) struct Blobs { | ||
set: BTreeMap<Vec<u8>, usize>, | ||
stream: Vec<u8>, | ||
} | ||
|
||
impl Blobs { | ||
pub fn new() -> Self { | ||
Self { set: BTreeMap::new(), stream: vec![0] } | ||
} | ||
|
||
pub fn insert(&mut self, value: &[u8]) -> u32 { | ||
if value.is_empty() { | ||
return 0; | ||
} | ||
|
||
let pos = self.stream.len(); | ||
let mut insert = false; | ||
|
||
let pos = *self.set.entry(value.to_vec()).or_insert_with(|| { | ||
insert = true; | ||
pos | ||
}); | ||
|
||
if insert { | ||
self.stream.extend_from_slice(value); | ||
} | ||
|
||
pos as _ | ||
} | ||
|
||
pub fn into_stream(mut self) -> Vec<u8> { | ||
self.stream.resize(round(self.stream.len(), 4), 0); | ||
self.stream | ||
} | ||
} |
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,24 @@ | ||
#[derive(Default)] | ||
pub struct Gen { | ||
// Source files to include. | ||
pub sources: Vec<String>, | ||
|
||
// Winmd files to include. | ||
pub inputs: Vec<String>, | ||
|
||
// Winmd files to reference. | ||
pub references: Vec<String>, | ||
|
||
// Name of resulting winmd file. | ||
pub output: String, | ||
} | ||
|
||
impl Gen { | ||
pub fn new() -> Self { | ||
Self::default() | ||
} | ||
} | ||
|
||
pub fn gen(_gen: &Gen) -> std::io::Result<()> { | ||
Ok(()) | ||
} |
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 @@ | ||
use std::mem::*; | ||
use std::slice::*; | ||
|
||
pub fn round(size: usize, round: usize) -> usize { | ||
let round = round - 1; | ||
(size + round) & !round | ||
} | ||
|
||
pub trait Write { | ||
fn write<T: Sized>(&mut self, value: &T); | ||
} | ||
|
||
impl Write for Vec<u8> { | ||
fn write<T: Sized>(&mut self, value: &T) { | ||
unsafe { | ||
self.extend_from_slice(from_raw_parts(value as *const _ as _, size_of::<T>())); | ||
} | ||
} | ||
} |
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,29 @@ | ||
mod blobs; | ||
mod gen; | ||
mod helpers; | ||
mod pe; | ||
mod strings; | ||
mod tables; | ||
use blobs::*; | ||
|
||
pub use gen::*; | ||
use helpers::*; | ||
use std::collections::*; | ||
use strings::*; | ||
use tables::*; | ||
|
||
pub fn test() { | ||
let mut tables = Tables::new(); | ||
tables.module.push(Module::new("test.winmd")); | ||
tables.type_def.push(TypeDef::module()); | ||
|
||
let mut stringable = TypeDef::winrt_interface("IStringable", "Windows.Foundation"); | ||
stringable.method_list.push(MethodDef::new("ToString")); | ||
tables.type_def.push(stringable); | ||
|
||
let mut closable = TypeDef::winrt_interface("IClosable", "Windows.Foundation"); | ||
closable.method_list.push(MethodDef::new("Close")); | ||
tables.type_def.push(closable); | ||
|
||
pe::write("/git/test.winmd", tables); | ||
} |
Oops, something went wrong.