-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify how extension code for
windows
crate works (#3110)
- Loading branch information
1 parent
139ca3c
commit d33dcf7
Showing
45 changed files
with
150 additions
and
1,818 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 |
---|---|---|
@@ -1,55 +1,34 @@ | ||
use super::*; | ||
|
||
pub fn gen_mod(writer: &Writer, namespace: &str) -> TokenStream { | ||
if namespace == "Windows.Win32.UI.WindowsAndMessaging" { | ||
return include_str!("mod/Win32/UI/WindowsAndMessaging/WindowLong.rs").into(); | ||
} | ||
|
||
if writer.sys { | ||
return "".into(); | ||
/// Helper function for `gen_mod` and `gen_impl`. | ||
/// | ||
/// This function generates an `include!(...)` that points into the `src/includes` directory for | ||
/// the `windows` and `windows-sys` crates. This makes it easy to inject code into WinMD namespaces. | ||
#[allow(dead_code)] | ||
fn include_ext(relative_path: &str) -> TokenStream { | ||
quote! { | ||
core::include!( | ||
core::concat!( | ||
core::env!("CARGO_MANIFEST_DIR"), | ||
"/src/includes/", | ||
#relative_path | ||
) | ||
); | ||
} | ||
} | ||
|
||
/// Generates extension code for a specific namespace | ||
pub fn gen_mod(_writer: &Writer, namespace: &str) -> TokenStream { | ||
match namespace { | ||
"Windows.Foundation.Numerics" => concat!( | ||
include_str!("mod/Foundation/Numerics/Matrix3x2.rs"), | ||
include_str!("mod/Foundation/Numerics/Matrix4x4.rs"), | ||
include_str!("mod/Foundation/Numerics/Vector2.rs"), | ||
include_str!("mod/Foundation/Numerics/Vector3.rs"), | ||
include_str!("mod/Foundation/Numerics/Vector4.rs"), | ||
), | ||
"Windows.Foundation" => concat!(include_str!("mod/Foundation/TimeSpan.rs"),), | ||
"Windows.Win32.Foundation" => concat!( | ||
include_str!("mod/Win32/Foundation/BOOL.rs"), | ||
include_str!("mod/Win32/Foundation/BOOLEAN.rs"), | ||
include_str!("mod/Win32/Foundation/NTSTATUS.rs"), | ||
include_str!("mod/Win32/Foundation/VARIANT_BOOL.rs"), | ||
include_str!("mod/Win32/Foundation/WIN32_ERROR.rs"), | ||
), | ||
"Windows.Win32.Networking.WinSock" => concat!( | ||
include_str!("mod/Win32/Networking/WinSock/IN_ADDR.rs"), | ||
include_str!("mod/Win32/Networking/WinSock/IN6_ADDR.rs"), | ||
include_str!("mod/Win32/Networking/WinSock/SOCKADDR_IN.rs"), | ||
include_str!("mod/Win32/Networking/WinSock/SOCKADDR_IN6.rs"), | ||
include_str!("mod/Win32/Networking/WinSock/SOCKADDR_INET.rs"), | ||
), | ||
"Windows.Win32.System.Rpc" => include_str!("mod/Win32/System/Rpc/RPC_STATUS.rs"), | ||
"Windows.Win32.System.Com" => include_str!("mod/Win32/System/Com/IDispatch.rs"), | ||
"Windows.Win32.UI.WindowsAndMessaging" => { | ||
include_str!("mod/Win32/UI/WindowsAndMessaging/WindowLong.rs") | ||
include_ext("Win32/UI/WindowsAndMessaging/WindowLong.rs") | ||
} | ||
_ => "", | ||
|
||
_ => quote!(), | ||
} | ||
.into() | ||
} | ||
|
||
pub fn gen_impl(namespace: &str) -> TokenStream { | ||
match namespace { | ||
"Windows.Foundation.Collections" => concat!( | ||
include_str!("impl/Foundation/Collections/Iterable.rs"), | ||
include_str!("impl/Foundation/Collections/MapView.rs"), | ||
include_str!("impl/Foundation/Collections/VectorView.rs"), | ||
), | ||
_ => "", | ||
} | ||
.into() | ||
/// Generates extension code that is subject to the `implement` feature for a specific namespace | ||
pub fn gen_impl(_namespace: &str) -> TokenStream { | ||
TokenStream::new() | ||
} |
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.
Oops, something went wrong.