Debian Codegraph @

third_party/rust/uniffi_bindgen/src/bindings/swift/gen_swift/object.rs

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 use super::CodeType;
6 use crate::interface::ObjectImpl;
7
8 #[derive(Debug)]
9 pub struct ObjectCodeType {
10 name: String,
11 imp: ObjectImpl,
12 }
13
14 impl ObjectCodeType {
15 pub fn new(name: String, imp: ObjectImpl) -> Self {
16 Self { name, imp }
17 }
18 }
19
20 impl CodeType for ObjectCodeType {
21 fn type_label(&self) -> String {
22 super::SwiftCodeOracle.class_name(&self.name)
23 }
24
25 fn canonical_name(&self) -> String {
26 format!("Type{}", self.name)
27 }
28
29 fn initialization_fn(&self) -> Option<String> {
30 self.imp
31 .has_callback_interface()
32 .then(|| format!("uniffiCallbackInit{}", self.name))
33 }
34 }