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

Improve plugin system #7

Closed
hannobraun opened this issue Nov 21, 2021 · 1 comment
Closed

Improve plugin system #7

hannobraun opened this issue Nov 21, 2021 · 1 comment
Labels
type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

Convenience

The extern "C" stuff required for the dynamic library isn't great. And the way parameters are passed to the model has caused further pain. Ideally, creating a model should require little or no ceremony to satisfy the plugin system. Maybe something like this would be good:

/// Defines the model parameters
///
/// The `derive` makes the parameter parsing just work, so the user doesn't have
/// to think about it. Preferably in a way that moves the bulk of the work to
/// the host, so compile times for the model stay low.
#[derive(fj::Parameters)]
pub struct Spacer {
    pub outer: f64,
    pub inner: f64,
    pub height: f64,
}

impl fj::Model for Spacer {
    /// Defines the model itself
    /// 
    /// Has access to the parameters through `self`. Method is defined in a
    /// trait, to provide type safety.
    fn model(&self) -> fj::Shape {
        // define the model
    }
}

This is just a sketch, not to be taken too seriously. Maybe it's possible, or maybe a #[no_mangle] or something will still be required.

Technology

Aside from the convenience of defining the model, the ideal technology is also a bit of an open question. I've decided to go with dynamic linking initially, as that seemed like a good way to get started (which turned out to be correct). But WebAssembly seems like a stronger candidate long-term:

  • It provides sandboxing, which could alleviate security concerns. At some point, people might want to look at models from untrusted sources.
  • It provides a path for running on the web. I'd like to be able to integrate Fornjot models into websites, in an interactive way that allows people to change model parameters. I'm not sure how the implementation would look in detail, but if models are WASM modules, that seems like a step in the right direction.
  • On non-web platforms, something like Wasmtime or Wasmer could be used.
@hannobraun
Copy link
Owner Author

Opened two separate issues, #71 and #72, to supersede this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New features and improvements to existing features
Projects
None yet
Development

No branches or pull requests

1 participant