Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some soundness bugs with RenderDoc struct #29

Merged
merged 3 commits into from
May 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Switch to Circle CI Rust 1.33.0 image.

### Fixed
* Fix erroneous doc comments (#19).
* Fix erroneous doc comments (PR #24).
* Unimplement `Clone`, `Send`, and `Sync` for `RenderDoc` (PR #29).

## [0.4.0] - 2018-09-16
### Added
Expand Down
3 changes: 2 additions & 1 deletion renderdoc-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ fn gen_from_impls(name: &Ident, apis: &[Ident], tokens: TokenStream2) -> TokenSt
quote! {
impl From<#name<#newer>> for #name<#older> {
fn from(newer: #name<#newer>) -> Self {
#name(newer.0.into())
let #name(entry, phantom) = newer;
#name(entry.into(), phantom)
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extern crate wio;

pub use self::entry::{ApiVersion, V100, V110, V111, V112, V120};

use std::marker::PhantomData;
use std::os::raw::{c_ulonglong, c_void};
use std::u32;

Expand Down Expand Up @@ -388,15 +389,15 @@ bitflags! {
pub type WindowHandle = *const c_void;

/// An instance of the RenderDoc API with baseline version `V`.
#[derive(Clone, Debug, RenderDoc)]
#[derive(Debug, RenderDoc)]
#[renderdoc_convert(V100, V110, V111, V112, V120)]
pub struct RenderDoc<V: ApiVersion>(V::Entry);
pub struct RenderDoc<V: ApiVersion>(V::Entry, PhantomData<*mut ()>);

impl<V: ApiVersion> RenderDoc<V> {
/// Initializes a new instance of the RenderDoc API.
pub fn new() -> Result<RenderDoc<V>, String> {
let api = V::load()?;
Ok(RenderDoc(api))
Ok(RenderDoc(api, PhantomData))
}

/// Returns the raw entry point of the API.
Expand Down