summaryrefslogtreecommitdiffstats
path: root/third_party/rust/diplomat/src/snapshots
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/diplomat/src/snapshots')
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap23
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap24
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap22
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap20
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap26
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap20
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap23
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap23
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap20
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap25
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap45
-rw-r--r--third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap22
12 files changed, 293 insertions, 0 deletions
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap
new file mode 100644
index 0000000000..4328309170
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap
@@ -0,0 +1,23 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] #[cfg(feature = \"foo\")] struct Foo {}\n #[cfg(feature = \"foo\")] impl Foo\n { pub fn bar(s : u8) { unimplemented! () } }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[cfg(feature = "foo")]
+ struct Foo {}
+ #[cfg(feature = "foo")]
+ impl Foo {
+ pub fn bar(s: u8) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ #[cfg(feature = "foo")]
+ extern "C" fn Foo_bar(s: u8) {
+ Foo::bar(s)
+ }
+ #[no_mangle]
+ #[cfg(feature = "foo")]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap
new file mode 100644
index 0000000000..b026704b8d
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap
@@ -0,0 +1,24 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} #[cfg(feature = \"bar\")] impl Foo\n {\n #[cfg(feature = \"foo\")] pub fn bar(s : u8)\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ #[cfg(feature = "bar")]
+ impl Foo {
+ #[cfg(feature = "foo")]
+ pub fn bar(s: u8) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ #[cfg(feature = "foo")]
+ #[cfg(feature = "bar")]
+ extern "C" fn Foo_bar(s: u8) {
+ Foo::bar(s)
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap
new file mode 100644
index 0000000000..bc4adbb73f
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap
@@ -0,0 +1,22 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n #[cfg(feature = \"foo\")] pub fn bar(s : u8)\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ #[cfg(feature = "foo")]
+ pub fn bar(s: u8) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ #[cfg(feature = "foo")]
+ extern "C" fn Foo_bar(s: u8) {
+ Foo::bar(s)
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap
new file mode 100644
index 0000000000..01fea65c2e
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap
@@ -0,0 +1,20 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn fill_slice(s : & mut [f64]) { unimplemented! () } }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ pub fn fill_slice(s: &mut [f64]) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Foo_fill_slice(s_diplomat_data: *mut f64, s_diplomat_len: usize) {
+ Foo::fill_slice(unsafe { core::slice::from_raw_parts_mut(s_diplomat_data, s_diplomat_len) })
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap
new file mode 100644
index 0000000000..bebbcf8455
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap
@@ -0,0 +1,26 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn make_uppercase(s : & mut str) { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ pub fn make_uppercase(s: &mut str) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Foo_make_uppercase(s_diplomat_data: *mut u8, s_diplomat_len: usize) {
+ Foo::make_uppercase(unsafe {
+ core::str::from_utf8_mut(core::slice::from_raw_parts_mut(
+ s_diplomat_data,
+ s_diplomat_len,
+ ))
+ .unwrap()
+ })
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap
new file mode 100644
index 0000000000..94daec2af5
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap
@@ -0,0 +1,20 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn from_slice(s : & [f64]) { unimplemented! () } }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ pub fn from_slice(s: &[f64]) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Foo_from_slice(s_diplomat_data: *const f64, s_diplomat_len: usize) {
+ Foo::from_slice(unsafe { core::slice::from_raw_parts(s_diplomat_data, s_diplomat_len) })
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap
new file mode 100644
index 0000000000..7e736e5599
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap
@@ -0,0 +1,23 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn from_str(s : & str) { unimplemented! () } }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ pub fn from_str(s: &str) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Foo_from_str(s_diplomat_data: *const u8, s_diplomat_len: usize) {
+ Foo::from_str(unsafe {
+ core::str::from_utf8(core::slice::from_raw_parts(s_diplomat_data, s_diplomat_len))
+ .unwrap()
+ })
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap
new file mode 100644
index 0000000000..723e17d786
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap
@@ -0,0 +1,23 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n enum Abc { A, B = 123, } impl Abc\n { pub fn do_something(& self) { unimplemented! () } }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ enum Abc {
+ A,
+ B = 123,
+ }
+ impl Abc {
+ pub fn do_something(&self) {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Abc_do_something(this: &Abc) {
+ this.do_something()
+ }
+ #[no_mangle]
+ extern "C" fn Abc_destroy(this: Box<Abc>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap
new file mode 100644
index 0000000000..1eeb28808a
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap
@@ -0,0 +1,20 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn bar(& self) -> Result < (), () >\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ pub fn bar(&self) -> Result<(), ()> {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Foo_bar(this: &Foo) -> diplomat_runtime::DiplomatResult<(), ()> {
+ this.bar().into()
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap
new file mode 100644
index 0000000000..870193052f
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap
@@ -0,0 +1,25 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn to_string(& self, to : & mut DiplomatWriteable) ->\n Result < (), () > { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ #[repr(C)]
+ struct Foo {}
+ impl Foo {
+ pub fn to_string(&self, to: &mut DiplomatWriteable) -> Result<(), ()> {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Foo_to_string(
+ this: &Foo,
+ to: &mut diplomat_runtime::DiplomatWriteable,
+ ) -> diplomat_runtime::DiplomatResult<(), ()> {
+ let ret = this.to_string(to);
+ to.flush();
+ ret.into()
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy(this: Box<Foo>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap
new file mode 100644
index 0000000000..f662608096
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap
@@ -0,0 +1,45 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] struct Foo < 'a > (& 'a str) ;\n #[diplomat :: opaque] struct Bar < 'b, 'a : 'b >\n (& 'b Foo < 'a >) ; struct Baz < 'x, 'y >\n { foo : & 'y Foo < 'x >, } impl < 'a > Foo < 'a >\n {\n pub fn new(x : & 'a str) -> Box < Foo < 'a >>\n { unimplemented! () } pub fn get_bar < 'b > (& 'b self) ->\n Box < Bar < 'b, 'a >> { unimplemented! () } pub fn get_baz <\n 'b > (& 'b self) -> Baz < 'b, 'a > { Bax { foo : self } }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ struct Foo<'a>(&'a str);
+ struct Bar<'b, 'a: 'b>(&'b Foo<'a>);
+ #[repr(C)]
+ struct Baz<'x, 'y> {
+ foo: &'y Foo<'x>,
+ }
+ impl<'a> Foo<'a> {
+ pub fn new(x: &'a str) -> Box<Foo<'a>> {
+ unimplemented!()
+ }
+ pub fn get_bar<'b>(&'b self) -> Box<Bar<'b, 'a>> {
+ unimplemented!()
+ }
+ pub fn get_baz<'b>(&'b self) -> Baz<'b, 'a> {
+ Bax { foo: self }
+ }
+ }
+ #[no_mangle]
+ extern "C" fn Bar_destroy<'b, 'a: 'b>(this: Box<Bar<'b, 'a>>) {}
+ #[no_mangle]
+ extern "C" fn Baz_destroy<'x: 'y, 'y>(this: Box<Baz<'x, 'y>>) {}
+ #[no_mangle]
+ extern "C" fn Foo_new<'a>(x_diplomat_data: *const u8, x_diplomat_len: usize) -> Box<Foo<'a>> {
+ Foo::new(unsafe {
+ core::str::from_utf8(core::slice::from_raw_parts(x_diplomat_data, x_diplomat_len))
+ .unwrap()
+ })
+ }
+ #[no_mangle]
+ extern "C" fn Foo_get_bar<'a: 'b, 'b>(this: &'b Foo<'a>) -> Box<Bar<'b, 'a>> {
+ this.get_bar()
+ }
+ #[no_mangle]
+ extern "C" fn Foo_get_baz<'a: 'b, 'b>(this: &'b Foo<'a>) -> Baz<'b, 'a> {
+ this.get_baz()
+ }
+ #[no_mangle]
+ extern "C" fn Foo_destroy<'a>(this: Box<Foo<'a>>) {}
+}
+
diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap
new file mode 100644
index 0000000000..6b931197ab
--- /dev/null
+++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap
@@ -0,0 +1,22 @@
+---
+source: macro/src/lib.rs
+expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] struct RefList < 'a >\n { data : & 'a i32, next : Option < Box < Self >>, } impl <\n 'b > RefList < 'b >\n {\n pub fn extend(& mut self, other : & Self) -> Self\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())"
+---
+mod ffi {
+ struct RefList<'a> {
+ data: &'a i32,
+ next: Option<Box<Self>>,
+ }
+ impl<'b> RefList<'b> {
+ pub fn extend(&mut self, other: &Self) -> Self {
+ unimplemented!()
+ }
+ }
+ #[no_mangle]
+ extern "C" fn RefList_extend<'b>(this: &mut RefList<'b>, other: &RefList<'b>) -> RefList<'b> {
+ this.extend(other)
+ }
+ #[no_mangle]
+ extern "C" fn RefList_destroy<'a>(this: Box<RefList<'a>>) {}
+}
+