Separated orchid-host and orchid-extension
This is an architectural change that allows me to implment specifics first and generalize along observed symmetries in orchid-base
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::Request;
|
||||
|
||||
@@ -16,11 +18,18 @@ pub enum ParserReq {
|
||||
|
||||
pub type LexerId = u16;
|
||||
|
||||
#[derive(Clone, Debug, Coding)]
|
||||
pub struct Lexer {
|
||||
id: LexerId,
|
||||
drop: bool,
|
||||
notify_chars: Option<Vec<RangeInclusive<char>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Coding, Hierarchy)]
|
||||
#[extends(ParserReq, HostExtReq)]
|
||||
pub struct MkLexer(pub SysId, pub TStr);
|
||||
impl Request for MkLexer {
|
||||
type Response = LexerId;
|
||||
type Response = Lexer;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Coding, Hierarchy)]
|
||||
@@ -50,6 +59,7 @@ impl Request for SubLex {
|
||||
type Response = SubLex;
|
||||
}
|
||||
|
||||
pub struct ParseLine {
|
||||
#[derive(Clone, Debug, Coding)]
|
||||
pub struct LexerDrop;
|
||||
|
||||
}
|
||||
pub struct ParseLine {}
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::io::{Read, Write};
|
||||
|
||||
use derive_more::{From, TryInto};
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_api_traits::{read_exact, write_exact, Decode, Encode, MsgSet, Request};
|
||||
use orchid_api_traits::{read_exact, write_exact, Channel, Decode, Encode, MsgSet, Request};
|
||||
|
||||
use crate::{atom, expr, intern, parser, system, tree};
|
||||
|
||||
@@ -77,12 +77,18 @@ pub enum ExtHostReq {
|
||||
}
|
||||
|
||||
/// Notifications sent from the extension to the host
|
||||
#[derive(Coding, From, TryInto)]
|
||||
#[derive(Debug, Clone, Coding, From, TryInto)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum ExtHostNotif {
|
||||
Expr(expr::ExprNotif),
|
||||
}
|
||||
|
||||
pub struct ExtHostChannel;
|
||||
impl Channel for ExtHostChannel {
|
||||
type Notif = ExtHostNotif;
|
||||
type Req = ExtHostReq;
|
||||
}
|
||||
|
||||
/// Requests running from the host to the extension
|
||||
#[derive(Clone, Debug, Coding, Hierarchy)]
|
||||
#[extendable]
|
||||
@@ -101,25 +107,28 @@ pub enum HostExtReq {
|
||||
pub enum HostExtNotif {
|
||||
SystemDrop(system::SystemDrop),
|
||||
AtomDrop(atom::AtomDrop),
|
||||
LexerDrop(parser::LexerDrop),
|
||||
/// The host can assume that after this notif is sent, a correctly written
|
||||
/// extension will eventually exit.
|
||||
Exit,
|
||||
}
|
||||
|
||||
pub struct HostExtChannel;
|
||||
impl Channel for HostExtChannel {
|
||||
type Notif = HostExtNotif;
|
||||
type Req = HostExtReq;
|
||||
}
|
||||
|
||||
/// Message set viewed from the extension's perspective
|
||||
pub struct ExtMsgSet;
|
||||
impl MsgSet for ExtMsgSet {
|
||||
type InNot = HostExtNotif;
|
||||
type InReq = HostExtReq;
|
||||
type OutNot = ExtHostNotif;
|
||||
type OutReq = ExtHostReq;
|
||||
type In = HostExtChannel;
|
||||
type Out = ExtHostChannel;
|
||||
}
|
||||
|
||||
/// Message Set viewed from the host's perspective
|
||||
pub struct HostMsgSet;
|
||||
impl MsgSet for HostMsgSet {
|
||||
type InNot = ExtHostNotif;
|
||||
type InReq = ExtHostReq;
|
||||
type OutNot = HostExtNotif;
|
||||
type OutReq = HostExtReq;
|
||||
type In = ExtHostChannel;
|
||||
type Out = HostExtChannel;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ pub type SysDeclId = u16;
|
||||
pub type SysId = u16;
|
||||
|
||||
/// Details about a system provided by this library
|
||||
#[derive(Coding)]
|
||||
#[derive(Debug, Clone, Coding)]
|
||||
pub struct SystemDecl {
|
||||
/// ID of the system, unique within the library
|
||||
pub id: SysDeclId,
|
||||
|
||||
Reference in New Issue
Block a user