Skip to content

Commit

Permalink
Built artifacts of a47508d [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
bendk committed May 1, 2024
1 parent 1fc2251 commit d9b474e
Show file tree
Hide file tree
Showing 154 changed files with 662 additions and 351 deletions.
2 changes: 1 addition & 1 deletion internals/api/search-index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internals/api/src-files.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 29 additions & 7 deletions internals/api/src/uniffi_macros/custom.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,25 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#84" id="84">84</a>
<a href="#85" id="85">85</a>
<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>
<a href="#91" id="91">91</a>
<a href="#92" id="92">92</a>
<a href="#93" id="93">93</a>
<a href="#94" id="94">94</a>
<a href="#95" id="95">95</a>
<a href="#96" id="96">96</a>
<a href="#97" id="97">97</a>
</pre></div><pre class="rust"><code><span class="comment">/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

</span><span class="kw">use </span><span class="kw">crate</span>::util::{derive_all_ffi_traits, ident_to_string, mod_path, tagged_impl_header};
</span><span class="kw">use crate</span>::{
ffiops,
util::{derive_all_ffi_traits, ident_to_string, mod_path, tagged_impl_header},
};
<span class="kw">use </span>proc_macro2::{Ident, TokenStream};
<span class="kw">use </span>quote::quote;
<span class="kw">use </span>syn::Path;
Expand All @@ -106,34 +120,42 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="kw">let </span>derive_ffi_traits = derive_all_ffi_traits(ident, udl_mode);
<span class="kw">let </span>name = ident_to_string(ident);
<span class="kw">let </span>mod_path = mod_path()<span class="question-mark">?</span>;
<span class="kw">let </span>from_custom = <span class="macro">quote! </span>{ &lt;#ident <span class="kw">as </span><span class="kw">crate</span>::UniffiCustomTypeConverter&gt;::from_custom };
<span class="kw">let </span>into_custom = <span class="macro">quote! </span>{ &lt;#ident <span class="kw">as </span><span class="kw">crate</span>::UniffiCustomTypeConverter&gt;::into_custom };
<span class="kw">let </span>lower_type = ffiops::lower_type(builtin);
<span class="kw">let </span>lower = ffiops::lower(builtin);
<span class="kw">let </span>write = ffiops::write(builtin);
<span class="kw">let </span>try_lift = ffiops::try_lift(builtin);
<span class="kw">let </span>try_read = ffiops::try_read(builtin);
<span class="kw">let </span>type_id_meta = ffiops::type_id_meta(builtin);

<span class="prelude-val">Ok</span>(<span class="macro">quote! </span>{
<span class="attr">#[automatically_derived]
</span><span class="kw">unsafe </span>#impl_spec {
<span class="comment">// Note: the builtin type needs to implement both `Lower` and `Lift'. We use the
// `Lower` trait to get the associated type `FfiType` and const `TYPE_ID_META`. These
// can't differ between `Lower` and `Lift`.
</span><span class="kw">type </span>FfiType = &lt;#builtin <span class="kw">as </span>::uniffi::Lower&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::FfiType;
</span><span class="kw">type </span>FfiType = #lower_type;
<span class="kw">fn </span>lower(obj: #ident ) -&gt; <span class="self">Self</span>::FfiType {
&lt;#builtin <span class="kw">as </span>::uniffi::Lower&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::lower(&lt;#ident <span class="kw">as </span><span class="kw">crate</span>::UniffiCustomTypeConverter&gt;::from_custom(obj))
#lower(#from_custom(obj))
}

<span class="kw">fn </span>try_lift(v: <span class="self">Self</span>::FfiType) -&gt; uniffi::Result&lt;#ident&gt; {
&lt;#ident <span class="kw">as </span><span class="kw">crate</span>::UniffiCustomTypeConverter&gt;::into_custom(&lt;#builtin <span class="kw">as </span>::uniffi::Lift&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::try_lift(v)<span class="question-mark">?</span>)
#into_custom(#try_lift(v)<span class="question-mark">?</span>)
}

<span class="kw">fn </span>write(obj: #ident, buf: <span class="kw-2">&amp;mut </span>Vec&lt;u8&gt;) {
&lt;#builtin <span class="kw">as </span>::uniffi::Lower&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::write(&lt;#ident <span class="kw">as </span><span class="kw">crate</span>::UniffiCustomTypeConverter&gt;::from_custom(obj), buf);
#write(#from_custom(obj), buf);
}

<span class="kw">fn </span>try_read(buf: <span class="kw-2">&amp;mut &amp;</span>[u8]) -&gt; uniffi::Result&lt;#ident&gt; {
&lt;#ident <span class="kw">as </span><span class="kw">crate</span>::UniffiCustomTypeConverter&gt;::into_custom(&lt;#builtin <span class="kw">as </span>::uniffi::Lift&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::try_read(buf)<span class="question-mark">?</span>)
#into_custom(#try_read(buf)<span class="question-mark">?</span>)
}

<span class="kw">const </span>TYPE_ID_META: ::uniffi::MetadataBuffer = ::uniffi::MetadataBuffer::from_code(::uniffi::metadata::codes::TYPE_CUSTOM)
.concat_str(#mod_path)
.concat_str(#name)
.concat(&lt;#builtin <span class="kw">as </span>::uniffi::TypeId&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::TYPE_ID_META);
.concat(#type_id_meta);
}

#derive_ffi_traits
Expand Down
30 changes: 19 additions & 11 deletions internals/api/src/uniffi_macros/enum_.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#369" id="369">369</a>
<a href="#370" id="370">370</a>
<a href="#371" id="371">371</a>
<a href="#372" id="372">372</a>
<a href="#373" id="373">373</a>
<a href="#374" id="374">374</a>
<a href="#375" id="375">375</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>proc_macro2::{Ident, Span, TokenStream};
<span class="kw">use </span>quote::quote;
<span class="kw">use </span>syn::{
Expand All @@ -379,10 +383,13 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
Attribute, Data, DataEnum, DeriveInput, Expr, Index, Lit, Variant,
};

<span class="kw">use </span><span class="kw">crate</span>::util::{
create_metadata_items, derive_all_ffi_traits, either_attribute_arg, extract_docstring,
ident_to_string, kw, mod_path, parse_comma_separated, tagged_impl_header,
try_metadata_value_from_usize, try_read_field, AttributeSliceExt, UniffiAttributeArgs,
<span class="kw">use crate</span>::{
ffiops,
util::{
create_metadata_items, derive_all_ffi_traits, either_attribute_arg, extract_docstring,
ident_to_string, kw, mod_path, parse_comma_separated, tagged_impl_header,
try_metadata_value_from_usize, try_read_field, AttributeSliceExt, UniffiAttributeArgs,
},
};

<span class="kw">fn </span>extract_repr(attrs: <span class="kw-2">&amp;</span>[Attribute]) -&gt; syn::Result&lt;<span class="prelude-ty">Option</span>&lt;Ident&gt;&gt; {
Expand Down Expand Up @@ -507,10 +514,8 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="kw">let </span>idx = Index::from(i + <span class="number">1</span>);
<span class="kw">let </span>write_fields =
std::iter::zip(v.fields.iter(), field_idents.iter()).map(|(f, ident)| {
<span class="kw">let </span>ty = <span class="kw-2">&amp;</span>f.ty;
<span class="macro">quote! </span>{
&lt;#ty <span class="kw">as </span>::uniffi::Lower&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::write(#ident, buf);
}
<span class="kw">let </span>write = ffiops::write(<span class="kw-2">&amp;</span>f.ty);
<span class="macro">quote! </span>{ #write(#ident, buf); }
});
<span class="kw">let </span>is_tuple = v.fields.iter().any(|f| f.ident.is_none());
<span class="kw">let </span>fields = <span class="kw">if </span>is_tuple {
Expand Down Expand Up @@ -603,7 +608,10 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
</span>};
metadata_expr.extend(<span class="kw">match </span>discr_type {
<span class="prelude-val">None </span>=&gt; <span class="macro">quote! </span>{ .concat_bool(<span class="bool-val">false</span>) },
<span class="prelude-val">Some</span>(t) =&gt; <span class="macro">quote! </span>{ .concat_bool(<span class="bool-val">true</span>).concat(&lt;#t <span class="kw">as </span>::uniffi::TypeId&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::TYPE_ID_META) }
<span class="prelude-val">Some</span>(t) =&gt; {
<span class="kw">let </span>type_id_meta = ffiops::type_id_meta(t);
<span class="macro">quote! </span>{ .concat_bool(<span class="bool-val">true</span>).concat(#type_id_meta) }
}
});
metadata_expr.extend(variant_metadata(enum_)<span class="question-mark">?</span>);
metadata_expr.extend(<span class="macro">quote! </span>{
Expand Down Expand Up @@ -688,20 +696,20 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="kw">let </span>name = ident_to_string(<span class="kw-2">&amp;</span>v.ident);
<span class="kw">let </span>value_tokens = variant_value(v)<span class="question-mark">?</span>;
<span class="kw">let </span>docstring = extract_docstring(<span class="kw-2">&amp;</span>v.attrs)<span class="question-mark">?</span>;
<span class="kw">let </span>field_types = v.fields.iter().map(|f| <span class="kw-2">&amp;</span>f.ty);
<span class="kw">let </span>field_docstrings = v
.fields
.iter()
.map(|f| extract_docstring(<span class="kw-2">&amp;</span>f.attrs))
.collect::&lt;syn::Result&lt;Vec&lt;<span class="kw">_</span>&gt;&gt;&gt;()<span class="question-mark">?</span>;
<span class="kw">let </span>field_type_id_metas = v.fields.iter().map(|f| ffiops::type_id_meta(<span class="kw-2">&amp;</span>f.ty));

<span class="prelude-val">Ok</span>(<span class="macro">quote! </span>{
.concat_str(#name)
#value_tokens
.concat_value(#fields_len)
#(
.concat_str(#field_names)
.concat(&lt;#field_types <span class="kw">as </span>::uniffi::TypeId&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::TYPE_ID_META)
.concat(#field_type_id_metas)
<span class="comment">// field defaults not yet supported for enums
</span>.concat_bool(<span class="bool-val">false</span>)
.concat_long_str(#field_docstrings)
Expand Down
42 changes: 31 additions & 11 deletions internals/api/src/uniffi_macros/error.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#310" id="310">310</a>
<a href="#311" id="311">311</a>
<a href="#312" id="312">312</a>
<a href="#313" id="313">313</a>
<a href="#314" id="314">314</a>
<a href="#315" id="315">315</a>
<a href="#316" id="316">316</a>
<a href="#317" id="317">317</a>
<a href="#318" id="318">318</a>
<a href="#319" id="319">319</a>
<a href="#320" id="320">320</a>
<a href="#321" id="321">321</a>
<a href="#322" id="322">322</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>proc_macro2::{Ident, Span, TokenStream};
<span class="kw">use </span>quote::quote;
<span class="kw">use </span>syn::{
Expand All @@ -321,6 +331,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>

<span class="kw">use crate</span>::{
enum_::{rich_error_ffi_converter_impl, variant_metadata, EnumAttr},
ffiops,
util::{
chain, create_metadata_items, derive_ffi_traits, either_attribute_arg, extract_docstring,
ident_to_string, kw, mod_path, parse_comma_separated, tagged_impl_header,
Expand Down Expand Up @@ -411,23 +422,31 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
};

<span class="kw">let </span>lower_impl = {
<span class="kw">let </span><span class="kw-2">mut </span>match_arms: Vec&lt;<span class="kw">_</span>&gt; = enum_.variants.iter().enumerate().map(|(i, v)| {
<span class="kw">let </span>v_ident = <span class="kw-2">&amp;</span>v.ident;
<span class="kw">let </span>idx = Index::from(i + <span class="number">1</span>);
<span class="kw">let </span><span class="kw-2">mut </span>match_arms: Vec&lt;<span class="kw">_</span>&gt; = enum_
.variants
.iter()
.enumerate()
.map(|(i, v)| {
<span class="kw">let </span>v_ident = <span class="kw-2">&amp;</span>v.ident;
<span class="kw">let </span>idx = Index::from(i + <span class="number">1</span>);
<span class="kw">let </span>write_string = ffiops::write(<span class="macro">quote! </span>{ ::std::string::String });

<span class="macro">quote! </span>{
<span class="self">Self</span>::#v_ident { .. } =&gt; {
::uniffi::deps::bytes::BufMut::put_i32(buf, #idx);
&lt;::std::string::String <span class="kw">as </span>::uniffi::Lower&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::write(error_msg, buf);
<span class="macro">quote! </span>{
<span class="self">Self</span>::#v_ident { .. } =&gt; {
::uniffi::deps::bytes::BufMut::put_i32(buf, #idx);
#write_string(error_msg, buf);
}
}
}
}).collect();
})
.collect();
<span class="kw">if </span>attr.non_exhaustive.is_some() {
match_arms.push(<span class="macro">quote! </span>{
<span class="kw">_ </span>=&gt; <span class="macro">panic!</span>(<span class="string">"Unexpected variant in non-exhaustive enum"</span>),
})
}

<span class="kw">let </span>lower = ffiops::lower_into_rust_buffer(<span class="macro">quote! </span>{ <span class="self">Self </span>});

<span class="macro">quote! </span>{
<span class="attr">#[automatically_derived]
</span><span class="kw">unsafe </span>#lower_impl_spec {
Expand All @@ -439,7 +458,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}

<span class="kw">fn </span>lower(obj: <span class="self">Self</span>) -&gt; ::uniffi::RustBuffer {
&lt;<span class="self">Self </span><span class="kw">as </span>::uniffi::Lower&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::lower_into_rust_buffer(obj)
#lower(obj)
}
}
}
Expand All @@ -454,6 +473,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
#idx =&gt; <span class="self">Self</span>::#v_ident,
}
});
<span class="kw">let </span>try_lift = ffiops::try_lift_from_rust_buffer(<span class="macro">quote! </span>{ <span class="self">Self </span>});
<span class="macro">quote! </span>{
<span class="attr">#[automatically_derived]
</span><span class="kw">unsafe </span>#lift_impl_spec {
Expand All @@ -467,7 +487,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}

<span class="kw">fn </span>try_lift(v: ::uniffi::RustBuffer) -&gt; ::uniffi::deps::anyhow::Result&lt;<span class="self">Self</span>&gt; {
&lt;<span class="self">Self </span><span class="kw">as </span>::uniffi::Lift&lt;<span class="kw">crate</span>::UniFfiTag&gt;&gt;::try_lift_from_rust_buffer(v)
#try_lift(v)
}
}
}
Expand Down
Loading

0 comments on commit d9b474e

Please sign in to comment.