From b3734bbc046fe7b14cff54e2dae7014a71014777 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 24 May 2019 12:24:10 +0200 Subject: =?UTF-8?q?Restructure=20engine=20into=20modular=20layouter=20?= =?UTF-8?q?=F0=9F=8D=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/func.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/func.rs') diff --git a/src/func.rs b/src/func.rs index c90e87ad..ef5120df 100644 --- a/src/func.rs +++ b/src/func.rs @@ -6,7 +6,7 @@ use std::fmt::{self, Debug, Formatter}; use crate::syntax::FuncHeader; use crate::parsing::{ParseContext, ParseResult}; -use crate::engine::{TypesetContext, TypesetResult}; +use crate::layout::{Layout, LayoutContext, LayoutResult}; /// Types that act as functions. @@ -17,12 +17,16 @@ use crate::engine::{TypesetContext, TypesetResult}; /// The trait `FunctionBounds` is automatically implemented for types which can be /// used as functions, that is they fulfill the bounds `Debug + PartialEq + 'static`. pub trait Function: FunctionBounds { - /// Parse the tokens of the context with the given header and scope into self. + /// Parse the header and body into this function given this context. fn parse(header: &FuncHeader, body: Option<&str>, ctx: &ParseContext) -> ParseResult where Self: Sized; - /// Execute the function and optionally yield a return value. - fn typeset(&self, ctx: &TypesetContext) -> TypesetResult<()>; + /// Layout this function given a context. + /// + /// Returns optionally the resulting layout and a if changes to the context + /// should be made new context. + fn layout(&self, ctx: &LayoutContext) + -> LayoutResult<(Option, Option)>; } impl PartialEq for dyn Function { -- cgit v1.2.3