Skip to content

Commit

Permalink
Cargo doc auto deployment 2024-09-05 10:00:38.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigocfd committed Sep 5, 2024
1 parent 18173b7 commit 7e89f9c
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 182 deletions.
4 changes: 2 additions & 2 deletions search-index.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/winsafe/macros/com.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,16 @@
) => {
$( <span class="attr">#[<span class="macro-nonterminal">$doc</span>] </span>)*
<span class="attr">#[repr(transparent)]
</span><span class="kw">pub struct </span><span class="macro-nonterminal">$name</span>(<span class="kw-2">*mut </span><span class="macro-nonterminal">$</span><span class="kw">impl</span>);
</span><span class="kw">pub struct </span><span class="macro-nonterminal">$name</span>(<span class="kw-2">*mut </span><span class="macro-nonterminal">$</span><span class="kw">impl</span>); <span class="comment">// wrap a pointer to the heap-allocated VT struct

<span class="kw">unsafe impl </span><span class="macro-nonterminal">Send </span><span class="kw">for </span><span class="macro-nonterminal">$name </span>{}
</span><span class="kw">unsafe impl </span><span class="macro-nonterminal">Send </span><span class="kw">for </span><span class="macro-nonterminal">$name </span>{}

<span class="kw">impl </span>Drop <span class="kw">for </span><span class="macro-nonterminal">$name </span>{
<span class="kw">fn </span>drop(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="kw">if </span>!<span class="self">self</span>.<span class="number">0</span>.is_null() {
<span class="kw">let </span>ppvt = <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0 </span><span class="kw">as </span><span class="kw-2">*const *mut </span><span class="macro-nonterminal">$</span><span class="kw">impl</span>;
<span class="macro-nonterminal">$</span><span class="kw">impl</span><span class="macro-nonterminal">::Release</span>(ppvt <span class="kw">as _</span>);
}
<span class="macro-nonterminal">$</span><span class="kw">impl</span><span class="macro-nonterminal">::Release</span>(ppvt <span class="kw">as _</span>); <span class="comment">// Release() is responsible for freeing the memory
</span>}
}
}

Expand Down Expand Up @@ -415,8 +415,8 @@
/// closures to handle events.
</span><span class="attr">#[must_use]
</span><span class="kw">pub fn </span>new_impl() -&gt; <span class="self">Self </span>{
<span class="kw">let </span>box_impl = Box::new(<span class="macro-nonterminal">$</span><span class="kw">impl</span><span class="macro-nonterminal">::new</span>());
<span class="self">Self</span>(Box::into_raw(box_impl))
<span class="kw">let </span>box_impl = Box::new(<span class="macro-nonterminal">$</span><span class="kw">impl</span><span class="macro-nonterminal">::new</span>()); <span class="comment">// alloc the VT struct in the heap
</span><span class="self">Self</span>(Box::into_raw(box_impl))
}
}
};
Expand All @@ -432,17 +432,17 @@
}

<span class="kw">fn </span>AddRef(p: COMPTR) -&gt; u32 {
<span class="kw">let </span>box_impl = box_impl::&lt;<span class="self">Self</span>&gt;(p);
<span class="kw">let </span>box_impl = box_impl_of::&lt;<span class="self">Self</span>&gt;(p);
<span class="kw">let </span>cc = box_impl.counter.fetch_add(<span class="number">1</span>, std::sync::atomic::Ordering::Relaxed) + <span class="number">1</span>;
cc
}

<span class="kw">fn </span>Release(p: COMPTR) -&gt; u32 {
<span class="kw">let </span><span class="kw-2">mut </span>box_impl = box_impl::&lt;<span class="self">Self</span>&gt;(p);
<span class="kw">let </span><span class="kw-2">mut </span>box_impl = box_impl_of::&lt;<span class="self">Self</span>&gt;(p);
<span class="kw">let </span>count = box_impl.counter.fetch_sub(<span class="number">1</span>, std::sync::atomic::Ordering::Relaxed) - <span class="number">1</span>;
<span class="kw">if </span>count == <span class="number">0 </span>{
<span class="kw">unsafe </span>{ std::mem::ManuallyDrop::drop(<span class="kw-2">&amp;mut </span>box_impl); }
}
<span class="kw">unsafe </span>{ std::mem::ManuallyDrop::drop(<span class="kw-2">&amp;mut </span>box_impl); } <span class="comment">// free the memory block
</span>}
count
}
};
Expand Down
34 changes: 15 additions & 19 deletions src/winsafe/mf/com_interfaces/imfasynccallback.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@
<a href="#86" id="86">86</a>
<a href="#87" id="87">87</a>
<a href="#88" id="88">88</a>
<a href="#89" id="89">89</a>
<a href="#90" id="90">90</a>
</pre></div><pre class="rust"><code><span class="attr">#![allow(non_camel_case_types, non_snake_case)]

</span><span class="kw">use </span>std::mem::ManuallyDrop;
Expand All @@ -110,7 +108,7 @@
</span>}

<span class="kw">impl </span>IMFAsyncCallback {
<span class="macro">fn_com_userdef_closure!</span> { GetParameters: Fn() -&gt; HrResult&lt;(co::MFASYNC, u32)&gt;;
<span class="macro">fn_com_userdef_closure!</span> { GetParameters: Fn(<span class="kw-2">&amp;mut </span>co::MFASYNC, <span class="kw-2">&amp;mut </span>u32) -&gt; HrResult&lt;()&gt;;
<span class="doccomment">/// [`IMFAsyncCallback::GetParameters`](https://learn.microsoft.com/en-us/windows/win32/api/mfobjects/nf-mfobjects-imfasynccallback-getparameters)
/// method.
</span>}
Expand All @@ -125,12 +123,12 @@
</span><span class="kw">pub struct </span>IMFAsyncCallbackImpl {
vt: IMFAsyncCallbackVT,
counter: AtomicU32,
GetParameters: <span class="prelude-ty">Option</span>&lt;Box&lt;<span class="kw">dyn </span>Fn() -&gt; HrResult&lt;(co::MFASYNC, u32)&gt;&gt;&gt;,
GetParameters: <span class="prelude-ty">Option</span>&lt;Box&lt;<span class="kw">dyn </span>Fn(<span class="kw-2">&amp;mut </span>co::MFASYNC, <span class="kw-2">&amp;mut </span>u32) -&gt; HrResult&lt;()&gt;&gt;&gt;,
Invoke: <span class="prelude-ty">Option</span>&lt;Box&lt;<span class="kw">dyn </span>Fn(<span class="kw-2">&amp;</span>IMFAsyncResult) -&gt; HrResult&lt;()&gt;&gt;&gt;,
}

<span class="kw">impl </span>IMFAsyncCallbackImpl {
<span class="kw">const fn </span>new() -&gt; <span class="self">Self </span>{
<span class="kw">fn </span>new() -&gt; <span class="self">Self </span>{
<span class="self">Self </span>{
vt: IMFAsyncCallbackVT {
IUnknownVT: IUnknownVT {
Expand All @@ -150,25 +148,23 @@
<span class="macro">com_interface_userdef_iunknown_methods!</span>(<span class="self">Self</span>);

<span class="kw">fn </span>GetParameters(p: COMPTR, pdwFlags: <span class="kw-2">*mut </span>u32, pdwQueue: <span class="kw-2">*mut </span>u32) -&gt; HRES {
<span class="kw">let </span>box_impl = box_impl::&lt;<span class="self">Self</span>&gt;(p);
<span class="kw">let </span>ret = <span class="kw">match </span><span class="kw-2">&amp;</span>box_impl.GetParameters {
<span class="prelude-val">Some</span>(func) =&gt; func(),
<span class="prelude-val">None </span>=&gt; <span class="prelude-val">Ok</span>((co::MFASYNC::default(), u32::default())),
};
<span class="kw">match </span>ret {
<span class="prelude-val">Ok</span>(ret) =&gt; <span class="kw">unsafe </span>{
<span class="kw-2">*</span>pdwFlags = ret.<span class="number">0</span>.raw();
<span class="kw-2">*</span>pdwQueue = ret.<span class="number">1</span>;
co::HRESULT::S_OK.raw()
<span class="kw">let </span>box_impl = box_impl_of::&lt;<span class="self">Self</span>&gt;(p);
hrresult_to_hres(
<span class="kw">match </span><span class="kw-2">&amp;</span>box_impl.GetParameters {
<span class="prelude-val">Some</span>(func) =&gt; {
<span class="kw">let </span>pflags = <span class="kw">unsafe </span>{ <span class="kw-2">&amp;mut *</span>(pdwFlags <span class="kw">as </span><span class="kw-2">*mut </span>co::MFASYNC) };
<span class="kw">let </span>pqueue = <span class="kw">unsafe </span>{ <span class="kw-2">&amp;mut *</span>(pdwQueue) };
func(pflags, pqueue)
},
<span class="prelude-val">None </span>=&gt; <span class="prelude-val">Ok</span>(()),
},
<span class="prelude-val">Err</span>(e) =&gt; e.raw(),
}
)
}

<span class="kw">fn </span>Invoke(p: COMPTR, pAsyncResult: COMPTR) -&gt; HRES {
<span class="kw">let </span>box_impl = box_impl::&lt;<span class="self">Self</span>&gt;(p);
<span class="kw">let </span>box_impl = box_impl_of::&lt;<span class="self">Self</span>&gt;(p);
hrresult_to_hres(
<span class="kw-2">&amp;</span><span class="kw">match </span><span class="kw-2">&amp;</span>box_impl.Invoke {
<span class="kw">match </span><span class="kw-2">&amp;</span>box_impl.Invoke {
<span class="prelude-val">Some</span>(func) =&gt; {
<span class="kw">let </span>ar = ManuallyDrop::new(<span class="kw">unsafe </span>{ IMFAsyncResult::from_ptr(pAsyncResult) });
func(<span class="kw-2">&amp;</span>ar)
Expand Down
Loading

0 comments on commit 7e89f9c

Please sign in to comment.