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

Remove the CodeOracle #1591

Merged
merged 2 commits into from
Jun 13, 2023
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
31 changes: 0 additions & 31 deletions uniffi_bindgen/src/backend/declarations.rs

This file was deleted.

7 changes: 1 addition & 6 deletions uniffi_bindgen/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

mod config;
mod declarations;
mod oracle;
mod types;

pub use crate::interface::{Literal, Type};
pub use config::TemplateExpression;
pub use declarations::CodeDeclaration;
pub use oracle::CodeOracle;
pub use types::CodeType;

pub use crate::interface::{Literal, Type};
29 changes: 0 additions & 29 deletions uniffi_bindgen/src/backend/oracle.rs

This file was deleted.

23 changes: 3 additions & 20 deletions uniffi_bindgen/src/backend/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,12 @@

//! # Backend traits
//!
//! This module provides a number of traits useful for implementing a backend for Uniffi.
//! A trait to help format items.
//!
//! A `CodeType` is needed for each type that will cross the FFI. It should provide helper machinery
//! in the target language to lift from and lower into a value of that type into a primitive type
//! (the FfiType), and foreign language expressions that call into the machinery. This helper code
//! can be provided by a template file.
//!
//! The `CodeOracle` provides methods to map the `Type` values found in the `ComponentInterface` to the `CodeType`s specified
//! by the backend. It also provides methods for transforming identifiers into the coding standard for the target language.
//!
//! There's also a CodeTypeDispatch trait, implemented for every type, which allows a CodeType to be created
//! by the specified `CodeOracle`. This means backends are able to provide a custom CodeType for each type
//! via that backend's CodeOracle.
//!
//! Each backend will have its own `filter` module, which is used by the askama templates used in all `CodeType`s and `CodeDeclaration`s.
//! This filter provides methods to generate expressions and identifiers in the target language. These are all forwarded to the oracle.

//! Each backend will have its own `filter` module, which is used by the askama templates.
use super::Literal;
use std::fmt::Debug;

use crate::interface::*;

/// A Trait to help render types in a language specific format.
pub trait CodeType: Debug {
/// The language specific label used to reference this type. This will be used in
Expand All @@ -40,8 +25,6 @@ pub trait CodeType: Debug {
self.type_label()
}

/// A representation of the given literal for this type.
/// N.B. `Literal` is aliased from `interface::Literal`, so may not be whole suited to this task.
fn literal(&self, _literal: &Literal) -> String {
unimplemented!("Unimplemented for {}", self.type_label())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 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/. */

use crate::backend::{CodeOracle, CodeType, Literal};
use crate::backend::{CodeType, Literal};

#[derive(Debug)]
pub struct CallbackInterfaceCodeType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 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/. */

use crate::backend::{CodeOracle, CodeType, Literal, Type};
use crate::backend::{CodeType, Literal, Type};
use paste::paste;

fn render_literal(literal: &Literal, inner: &Type) -> String {
Expand Down
2 changes: 1 addition & 1 deletion uniffi_bindgen/src/bindings/kotlin/gen_kotlin/enum_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 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/. */

use crate::backend::{CodeOracle, CodeType, Literal};
use crate::backend::{CodeType, Literal};

#[derive(Debug)]
pub struct EnumCodeType {
Expand Down
2 changes: 1 addition & 1 deletion uniffi_bindgen/src/bindings/kotlin/gen_kotlin/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 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/. */

use crate::backend::{CodeOracle, CodeType, Literal};
use crate::backend::{CodeType, Literal};

#[derive(Debug)]
pub struct ErrorCodeType {
Expand Down
Loading