{-# LANGUAGE OverloadedStrings    #-}
{-# LANGUAGE LambdaCase           #-}
{- |
Copyright               : © 2021 Albert Krewinkel
SPDX-License-Identifier : MIT
Maintainer              : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>

Marshaling/unmarshaling functions of table 'Cell' values.
-}
module Text.Pandoc.Lua.Marshal.Cell
  ( peekCell
  , peekCellFuzzy
  , pushCell
  , typeCell
  , mkCell
  ) where

import Control.Applicative (optional)
import Control.Monad ((<$!>))
import Data.Maybe (fromMaybe)
import HsLua
import Text.Pandoc.Lua.Marshal.Alignment (peekAlignment, pushAlignment)
import Text.Pandoc.Lua.Marshal.Attr (peekAttr, pushAttr)
import {-# SOURCE #-} Text.Pandoc.Lua.Marshal.Block
  ( peekBlocksFuzzy, pushBlocks )
import Text.Pandoc.Lua.Marshal.Filter (peekFilter)
import Text.Pandoc.Lua.Marshal.Shared (walkBlocksAndInlines)
import Text.Pandoc.Definition

-- | Push a table cell as a table with fields @attr@, @alignment@,
-- @row_span@, @col_span@, and @contents@.
pushCell :: LuaError e => Cell -> LuaE e ()
pushCell :: Cell -> LuaE e ()
pushCell = UDTypeWithList e (DocumentedFunction e) Cell Void
-> Cell -> LuaE e ()
forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> a -> LuaE e ()
pushUD UDTypeWithList e (DocumentedFunction e) Cell Void
forall e. LuaError e => DocumentedType e Cell
typeCell

-- | Retrieves a 'Cell' object from the stack.
peekCell :: LuaError e => Peeker e Cell
peekCell :: Peeker e Cell
peekCell = UDTypeWithList e (DocumentedFunction e) Cell Void -> Peeker e Cell
forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> Peeker e a
peekUD UDTypeWithList e (DocumentedFunction e) Cell Void
forall e. LuaError e => DocumentedType e Cell
typeCell

-- | Retrieves a 'Cell' from the stack, accepting either a 'pandoc Cell'
-- userdata object or a table with fields @attr@, @alignment@, @row_span@,
-- @col_span@, and @contents@.
peekCellFuzzy :: LuaError e => Peeker e Cell
peekCellFuzzy :: Peeker e Cell
peekCellFuzzy StackIndex
idx = LuaE e Type -> Peek e Type
forall e a. LuaE e a -> Peek e a
liftLua (StackIndex -> LuaE e Type
forall e. StackIndex -> LuaE e Type
ltype StackIndex
idx) Peek e Type -> (Type -> Peek e Cell) -> Peek e Cell
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
  Type
TypeUserdata -> Peeker e Cell
forall e. LuaError e => Peeker e Cell
peekCell StackIndex
idx
  Type
TypeTable -> do
    Attr
attr <- Peeker e Attr -> Name -> Peeker e Attr
forall e a. LuaError e => Peeker e a -> Name -> Peeker e a
peekFieldRaw Peeker e Attr
forall e. LuaError e => Peeker e Attr
peekAttr Name
"attr" StackIndex
idx
    Alignment
algn <- Peeker e Alignment -> Name -> Peeker e Alignment
forall e a. LuaError e => Peeker e a -> Name -> Peeker e a
peekFieldRaw Peeker e Alignment
forall e. Peeker e Alignment
peekAlignment Name
"alignment" StackIndex
idx
    RowSpan
rs   <- Int -> RowSpan
RowSpan (Int -> RowSpan) -> Peek e Int -> Peek e RowSpan
forall (m :: * -> *) a b. Monad m => (a -> b) -> m a -> m b
<$!> Peeker e Int -> Name -> Peeker e Int
forall e a. LuaError e => Peeker e a -> Name -> Peeker e a
peekFieldRaw Peeker e Int
forall a e. (Integral a, Read a) => Peeker e a
peekIntegral Name
"row_span" StackIndex
idx
    ColSpan
cs   <- Int -> ColSpan
ColSpan (Int -> ColSpan) -> Peek e Int -> Peek e ColSpan
forall (m :: * -> *) a b. Monad m => (a -> b) -> m a -> m b
<$!> Peeker e Int -> Name -> Peeker e Int
forall e a. LuaError e => Peeker e a -> Name -> Peeker e a
peekFieldRaw Peeker e Int
forall a e. (Integral a, Read a) => Peeker e a
peekIntegral Name
"col_span" StackIndex
idx
    [Block]
blks <- Peeker e [Block] -> Name -> Peeker e [Block]
forall e a. LuaError e => Peeker e a -> Name -> Peeker e a
peekFieldRaw Peeker e [Block]
forall e. LuaError e => Peeker e [Block]
peekBlocksFuzzy Name
"contents" StackIndex
idx
    Cell -> Peek e Cell
forall (m :: * -> *) a. Monad m => a -> m a
return (Cell -> Peek e Cell) -> Cell -> Peek e Cell
forall a b. (a -> b) -> a -> b
$! Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
algn RowSpan
rs ColSpan
cs [Block]
blks
  Type
_ -> ByteString -> Peek e Cell
forall a e. ByteString -> Peek e a
failPeek (ByteString -> Peek e Cell) -> Peek e ByteString -> Peek e Cell
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Name -> StackIndex -> Peek e ByteString
forall e. Name -> StackIndex -> Peek e ByteString
typeMismatchMessage Name
"Cell or table" StackIndex
idx

-- | Cell object type.
typeCell :: LuaError e => DocumentedType e Cell
typeCell :: DocumentedType e Cell
typeCell = Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) Cell]
-> DocumentedType e Cell
forall e a.
LuaError e =>
Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> DocumentedType e a
deftype Name
"pandoc Cell"
  [ Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall e.
Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
operation Operation
Eq (DocumentedFunction e -> (Operation, DocumentedFunction e))
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall a b. (a -> b) -> a -> b
$ Name
-> (Maybe Cell -> Maybe Cell -> LuaE e Bool)
-> HsFnPrecursor e (Maybe Cell -> Maybe Cell -> LuaE e Bool)
forall a e. Name -> a -> HsFnPrecursor e a
defun Name
"__eq"
     ### liftPure2 (\a b -> fromMaybe False ((==) <$> a <*> b))
     HsFnPrecursor e (Maybe Cell -> Maybe Cell -> LuaE e Bool)
-> Parameter e (Maybe Cell)
-> HsFnPrecursor e (Maybe Cell -> LuaE e Bool)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e (Maybe Cell)
-> Text -> Text -> Text -> Parameter e (Maybe Cell)
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (Peek e Cell -> Peek e (Maybe Cell)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Peek e Cell -> Peek e (Maybe Cell))
-> (StackIndex -> Peek e Cell) -> Peeker e (Maybe Cell)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackIndex -> Peek e Cell
forall e. LuaError e => Peeker e Cell
peekCell) Text
"Cell" Text
"self" Text
""
     HsFnPrecursor e (Maybe Cell -> LuaE e Bool)
-> Parameter e (Maybe Cell) -> HsFnPrecursor e (LuaE e Bool)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e (Maybe Cell)
-> Text -> Text -> Text -> Parameter e (Maybe Cell)
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (Peek e Cell -> Peek e (Maybe Cell)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Peek e Cell -> Peek e (Maybe Cell))
-> (StackIndex -> Peek e Cell) -> Peeker e (Maybe Cell)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackIndex -> Peek e Cell
forall e. LuaError e => Peeker e Cell
peekCell) Text
"any" Text
"object" Text
""
     HsFnPrecursor e (LuaE e Bool)
-> FunctionResults e Bool -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e Bool -> Text -> Text -> FunctionResults e Bool
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e Bool
forall e. Pusher e Bool
pushBool Text
"boolean" Text
"true iff the two values are equal"
  , Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall e.
Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
operation Operation
Tostring (DocumentedFunction e -> (Operation, DocumentedFunction e))
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall a b. (a -> b) -> a -> b
$ (Cell -> LuaE e String) -> HsFnPrecursor e (Cell -> LuaE e String)
forall a e. a -> HsFnPrecursor e a
lambda
    ### liftPure show
    HsFnPrecursor e (Cell -> LuaE e String)
-> Parameter e Cell -> HsFnPrecursor e (LuaE e String)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> (StackIndex -> Peek e Cell)
-> Text -> Text -> Text -> Parameter e Cell
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter StackIndex -> Peek e Cell
forall e. LuaError e => Peeker e Cell
peekCell Text
"Cell" Text
"self" Text
""
    HsFnPrecursor e (LuaE e String)
-> FunctionResults e String -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e String -> Text -> Text -> FunctionResults e String
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e String
forall e. String -> LuaE e ()
pushString Text
"string" Text
"native Haskell representation"
  ]
  [ Name
-> Text
-> (Pusher e Attr, Cell -> Attr)
-> (Peeker e Attr, Cell -> Attr -> Cell)
-> Member e (DocumentedFunction e) Cell
forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"attr" Text
"cell attributes"
      (Pusher e Attr
forall e. LuaError e => Pusher e Attr
pushAttr, \(Cell Attr
attr Alignment
_ RowSpan
_ ColSpan
_ [Block]
_) -> Attr
attr)
      (Peeker e Attr
forall e. LuaError e => Peeker e Attr
peekAttr, \(Cell Attr
_ Alignment
align RowSpan
rs ColSpan
cs [Block]
blks) Attr
attr ->
                   Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
align RowSpan
rs ColSpan
cs [Block]
blks)
  , Name
-> Text
-> (Pusher e Alignment, Cell -> Alignment)
-> (Peeker e Alignment, Cell -> Alignment -> Cell)
-> Member e (DocumentedFunction e) Cell
forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"alignment" Text
"alignment of cell contents"
      (Pusher e Alignment
forall e. Pusher e Alignment
pushAlignment, \(Cell Attr
_ Alignment
align RowSpan
_ ColSpan
_ [Block]
_) -> Alignment
align)
      (Peeker e Alignment
forall e. Peeker e Alignment
peekAlignment, \(Cell Attr
attr Alignment
_ RowSpan
rs ColSpan
cs [Block]
blks) Alignment
align ->
                        Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
align RowSpan
rs ColSpan
cs [Block]
blks)
  , Name
-> Text
-> (Pusher e Int, Cell -> Int)
-> (Peeker e Int, Cell -> Int -> Cell)
-> Member e (DocumentedFunction e) Cell
forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"row_span" Text
"number of rows over which this cell spans"
      (Pusher e Int
forall a e. (Integral a, Show a) => a -> LuaE e ()
pushIntegral, \(Cell Attr
_ Alignment
_ (RowSpan Int
rs) ColSpan
_ [Block]
_) -> Int
rs)
      (Peeker e Int
forall a e. (Integral a, Read a) => Peeker e a
peekIntegral, \(Cell Attr
attr Alignment
align RowSpan
_ ColSpan
cs [Block]
blks) Int
rs ->
                       Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
align (Int -> RowSpan
RowSpan Int
rs) ColSpan
cs [Block]
blks)
  , Name
-> Text
-> (Pusher e Int, Cell -> Int)
-> (Peeker e Int, Cell -> Int -> Cell)
-> Member e (DocumentedFunction e) Cell
forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"col_span" Text
"number of columns over which this cell spans"
      (Pusher e Int
forall a e. (Integral a, Show a) => a -> LuaE e ()
pushIntegral, \(Cell Attr
_ Alignment
_ RowSpan
_ (ColSpan Int
rs) [Block]
_) -> Int
rs)
      (Peeker e Int
forall a e. (Integral a, Read a) => Peeker e a
peekIntegral, \(Cell Attr
attr Alignment
align RowSpan
rs ColSpan
_ [Block]
blks) Int
cs ->
                       Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
align RowSpan
rs (Int -> ColSpan
ColSpan Int
cs) [Block]
blks)
  , Name
-> Text
-> (Pusher e [Block], Cell -> [Block])
-> (Peeker e [Block], Cell -> [Block] -> Cell)
-> Member e (DocumentedFunction e) Cell
forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"contents" Text
"cell contents"
      (Pusher e [Block]
forall e. LuaError e => Pusher e [Block]
pushBlocks, \(Cell Attr
_ Alignment
_ RowSpan
_ ColSpan
_ [Block]
blks) -> [Block]
blks)
      (Peeker e [Block]
forall e. LuaError e => Peeker e [Block]
peekBlocksFuzzy, \(Cell Attr
attr Alignment
align RowSpan
rs ColSpan
cs [Block]
_) [Block]
blks ->
                          Attr -> Alignment -> RowSpan -> ColSpan -> [Block] -> Cell
Cell Attr
attr Alignment
align RowSpan
rs ColSpan
cs [Block]
blks)

  , Name
-> Text -> [AliasIndex] -> Member e (DocumentedFunction e) Cell
forall e fn a. Name -> Text -> [AliasIndex] -> Member e fn a
alias Name
"content"    Text
"alias for contents" [AliasIndex
"contents"]
  , Name
-> Text -> [AliasIndex] -> Member e (DocumentedFunction e) Cell
forall e fn a. Name -> Text -> [AliasIndex] -> Member e fn a
alias Name
"identifier" Text
"cell ID"         [AliasIndex
"attr", AliasIndex
"identifier"]
  , Name
-> Text -> [AliasIndex] -> Member e (DocumentedFunction e) Cell
forall e fn a. Name -> Text -> [AliasIndex] -> Member e fn a
alias Name
"classes"    Text
"cell classes"    [AliasIndex
"attr", AliasIndex
"classes"]
  , Name
-> Text -> [AliasIndex] -> Member e (DocumentedFunction e) Cell
forall e fn a. Name -> Text -> [AliasIndex] -> Member e fn a
alias Name
"attributes" Text
"cell attributes" [AliasIndex
"attr", AliasIndex
"attributes"]

  , DocumentedFunction e -> Member e (DocumentedFunction e) Cell
forall e a.
DocumentedFunction e -> Member e (DocumentedFunction e) a
method (DocumentedFunction e -> Member e (DocumentedFunction e) Cell)
-> DocumentedFunction e -> Member e (DocumentedFunction e) Cell
forall a b. (a -> b) -> a -> b
$ Name
-> (Cell -> Filter -> LuaE e Cell)
-> HsFnPrecursor e (Cell -> Filter -> LuaE e Cell)
forall a e. Name -> a -> HsFnPrecursor e a
defun Name
"walk"
    ### flip walkBlocksAndInlines
    HsFnPrecursor e (Cell -> Filter -> LuaE e Cell)
-> Parameter e Cell -> HsFnPrecursor e (Filter -> LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> (StackIndex -> Peek e Cell)
-> Text -> Text -> Text -> Parameter e Cell
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter StackIndex -> Peek e Cell
forall e. LuaError e => Peeker e Cell
peekCell Text
"Cell" Text
"self" Text
""
    HsFnPrecursor e (Filter -> LuaE e Cell)
-> Parameter e Filter -> HsFnPrecursor e (LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e Filter -> Text -> Text -> Text -> Parameter e Filter
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter Peeker e Filter
forall e. LuaError e => Peeker e Filter
peekFilter Text
"Filter" Text
"lua_filter" Text
"table of filter functions"
    HsFnPrecursor e (LuaE e Cell)
-> FunctionResults e Cell -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e Cell -> Text -> Text -> FunctionResults e Cell
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e Cell
forall e. LuaError e => Cell -> LuaE e ()
pushCell Text
"Cell" Text
"modified cell"
  ]

-- | Constructor function for 'Cell' values.
mkCell :: LuaError e => DocumentedFunction e
mkCell :: DocumentedFunction e
mkCell = Name
-> ([Block]
    -> Maybe Alignment
    -> Maybe Int
    -> Maybe Int
    -> Maybe Attr
    -> LuaE e Cell)
-> HsFnPrecursor
     e
     ([Block]
      -> Maybe Alignment
      -> Maybe Int
      -> Maybe Int
      -> Maybe Attr
      -> LuaE e Cell)
forall a e. Name -> a -> HsFnPrecursor e a
defun Name
"Cell"
  ### liftPure5 (\blocks mAlign mRowSpan mColSpan mAttr -> Cell
                  (fromMaybe nullAttr mAttr)
                  (fromMaybe AlignDefault mAlign)
                  (maybe 1 RowSpan mRowSpan)
                  (maybe 1 ColSpan mColSpan)
                  blocks)
  HsFnPrecursor
  e
  ([Block]
   -> Maybe Alignment
   -> Maybe Int
   -> Maybe Int
   -> Maybe Attr
   -> LuaE e Cell)
-> Parameter e [Block]
-> HsFnPrecursor
     e
     (Maybe Alignment
      -> Maybe Int -> Maybe Int -> Maybe Attr -> LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e [Block] -> Text -> Text -> Text -> Parameter e [Block]
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter Peeker e [Block]
forall e. LuaError e => Peeker e [Block]
peekBlocksFuzzy Text
"Blocks" Text
"blocks" Text
"document contents"
  HsFnPrecursor
  e
  (Maybe Alignment
   -> Maybe Int -> Maybe Int -> Maybe Attr -> LuaE e Cell)
-> Parameter e (Maybe Alignment)
-> HsFnPrecursor
     e (Maybe Int -> Maybe Int -> Maybe Attr -> LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e Alignment
-> Text -> Text -> Text -> Parameter e (Maybe Alignment)
forall e a.
Peeker e a -> Text -> Text -> Text -> Parameter e (Maybe a)
optionalParameter Peeker e Alignment
forall e. Peeker e Alignment
peekAlignment Text
"integer" Text
"align" Text
"cell alignment"
  HsFnPrecursor
  e (Maybe Int -> Maybe Int -> Maybe Attr -> LuaE e Cell)
-> Parameter e (Maybe Int)
-> HsFnPrecursor e (Maybe Int -> Maybe Attr -> LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e Int -> Text -> Text -> Text -> Parameter e (Maybe Int)
forall e a.
Peeker e a -> Text -> Text -> Text -> Parameter e (Maybe a)
optionalParameter Peeker e Int
forall a e. (Integral a, Read a) => Peeker e a
peekIntegral Text
"integer" Text
"row_span" Text
"rows to span"
  HsFnPrecursor e (Maybe Int -> Maybe Attr -> LuaE e Cell)
-> Parameter e (Maybe Int)
-> HsFnPrecursor e (Maybe Attr -> LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e Int -> Text -> Text -> Text -> Parameter e (Maybe Int)
forall e a.
Peeker e a -> Text -> Text -> Text -> Parameter e (Maybe a)
optionalParameter Peeker e Int
forall a e. (Integral a, Read a) => Peeker e a
peekIntegral Text
"integer" Text
"col_span" Text
"columns to span"
  HsFnPrecursor e (Maybe Attr -> LuaE e Cell)
-> Parameter e (Maybe Attr) -> HsFnPrecursor e (LuaE e Cell)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e Attr -> Text -> Text -> Text -> Parameter e (Maybe Attr)
forall e a.
Peeker e a -> Text -> Text -> Text -> Parameter e (Maybe a)
optionalParameter Peeker e Attr
forall e. LuaError e => Peeker e Attr
peekAttr Text
"Attr" Text
"attr" Text
"cell attributes"
  HsFnPrecursor e (LuaE e Cell)
-> FunctionResults e Cell -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e Cell -> Text -> Text -> FunctionResults e Cell
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e Cell
forall e. LuaError e => Cell -> LuaE e ()
pushCell Text
"Cell" Text
"new Cell object"