Commit 2891b6c5 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

*** empty log message ***

parent c0b30020
......@@ -3,10 +3,11 @@ implementation module EncodeDecode
// encoding and decoding of information
// (c) 2005 MJP
import StdArray, StdInt, StdList, StdString, ArgEnv, StdMaybe, Directory
import StdArray, StdBool, StdInt, StdList, StdOrdList, StdString, StdTuple, ArgEnv, StdMaybe, Directory
import htmlTrivial, htmlFormData
import GenPrint, GenParse
import dynamic_string
import EstherBackend
// Serializing Html states...
......@@ -124,22 +125,36 @@ traceHtmlInput :: !ServerKind !(Maybe String) -> BodyTag
traceHtmlInput serverkind args=:(Just string)
= BodyTag [ Br, B [] "State values received from client when application started:", Br,
STable [] [ [B [] "Triplet:", Txt triplet]
,[B [] "Update:", Txt update]
,[B [] "Update:", Txt updates]
,[B [] "Id:", B [] "Lifespan:", B [] "Format:", B [] "Value:"]
: [ [Txt id, Txt (showl life), Txt (showf storage), Txt (shows storage state)]
\\ (id,life,storage,state) <- htmlState
]
]
, Br
, Txt string
// , Txt string
]
where
(htmlState,triplet,update) = DecodeHtmlStatesAndUpdate serverkind args
(htmlState,triplet,updates) = DecodeHtmlStatesAndUpdate serverkind args
showl life = toString life
showf storage = case storage of PlainString -> "String"; _ -> "S_Dynamic"
shows PlainString s = s
shows _ d = d // "cannot show dynamic value"
shows StaticDynamic d = toStr (string_to_dynamic` d) // "cannot show dynamic value"
toStr dyn = ShowValueDynamic dyn <+++ " :: " <+++ ShowTypeDynamic dyn
string_to_dynamic` :: {#Char} -> Dynamic // just to make a unique copy as requested by string_to_dynamic
string_to_dynamic` s = string_to_dynamic {s` \\ s` <-: s}
strip s = { ns \\ ns <-: s | ns >= '\020' && ns <= '\0200'}
ShowValueDynamic :: Dynamic -> String
ShowValueDynamic d = strip (foldr (+++) "" (fst (toStringDynamic d)) +++ " ")
ShowTypeDynamic :: Dynamic -> String
ShowTypeDynamic d = strip (snd (toStringDynamic d) +++ " ")
// global names setting depending on kind of server used
......
......@@ -5,7 +5,7 @@ import StdEnv,StdTCP
from httpUtil import unlines, cSplit, endWith, splitAfter, wordsWith, unwords, readFile
DEBUGSERVER
:== True
:== False
(<<?) file s
= case DEBUGSERVER of
......@@ -28,7 +28,9 @@ getArgValue a arguments
StartServer :: Int [(String,(String String Arguments *World-> ([String],String,*World)))] *World -> *World
StartServer poortNr linktofunctionlist world
// open console voor debuggen:
# (console,world) = stdio world
# (console,world) = stdio world
# console = fwrites "Open your favorite browser and surf to http://localhost/clean\n" console
//luister op de opgegeven poort:
# (listen,world) = listenOnPort poortNr world
......
......@@ -46,7 +46,7 @@ callClean :: Script // script that takes care of sending the required
// tracing all states ...
traceStates :: !*FormStates -> !(BodyTag,!*FormStates)
traceStates :: !*FormStates -> (BodyTag,!*FormStates)
// fstate handling used for testing only
......
......@@ -7,6 +7,9 @@ import StdArray, StdList, StdOrdList, StdString, StdTuple, ArgEnv, StdMaybe, Dir
import htmlDataDef, htmlTrivial, htmlFormData, EncodeDecode
import GenPrint, GenParse
import dynamic_string
import EstherBackend
//import Debug // TEMP
derive gParse UpdValue, (,,)
derive gPrint UpdValue, (,,)
......@@ -77,7 +80,7 @@ findState formid formstates=:{fstates,server} world
# (bool,ma,fstates,world) = findState` formid fstates world
= (bool,ma,{formstates & fstates = fstates},world)
where
findState` :: !(FormId a) *FStates *NWorld -> (Bool,Maybe a,*FStates,*NWorld)| iDataSerAndDeSerialize a
findState` :: !(FormId a) *FStates *NWorld -> (Bool,Maybe a,*FStates,*NWorld)| gPrint{|*|}, gerda{|*|}, TC, gParse{|*|} a //iDataSerAndDeSerialize a
findState` formid formstate=:(Node_ left (fid,info) right) world
| formid.id == fid = case info of
(OldState state) = (True, fetchFState state,formstate,world)
......@@ -140,6 +143,8 @@ where
_ = case string_to_dynamic` string of
dyn=:(dynval::a^) = (True, Just dynval,Node_ Leaf_ (id,OldState {format = StatDyn dyn, life = Persistent}) Leaf_,world)
else = (False,Nothing, Leaf_,world)
// with
// mydebug s dyn = ["\n" <+++ s <+++ ShowValueDynamic dyn <+++ " :: " <+++ ShowTypeDynamic dyn]
findState` {id,lifespan = PersistentRO,storage = StaticDynamic} Leaf_ world
# (string,world) = readState (MyDir server) id world
......@@ -309,9 +314,7 @@ where
// trace States
import EstherBackend
traceStates :: !*FormStates -> !(BodyTag,!*FormStates)
traceStates :: !*FormStates -> (BodyTag,!*FormStates)
traceStates formstates=:{fstates}
# (bodytags,fstates) = traceStates` fstates
= (BodyTag [Br, B [] "State values when application ended:",Br,
......@@ -333,13 +336,13 @@ where
toStr (StatDyn dyn) = [Txt "S_Dynamic", Txt (ShowValueDynamic dyn <+++ " :: " <+++ ShowTypeDynamic dyn )]
toStr (DBStr str _) = [Txt "Database", Txt str]
strip s = { ns \\ ns <-: s | ns >= '\020' && ns <= '\0200'}
ShowValueDynamic :: Dynamic -> String
ShowValueDynamic d = strip (foldr (+++) "" (fst (toStringDynamic d)) +++ " ")
ShowTypeDynamic :: Dynamic -> String
ShowTypeDynamic d = strip (snd (toStringDynamic d) +++ " ")
strip s = { ns \\ ns <-: s | ns >= '\020' && ns <= '\0200'}
ShowValueDynamic :: Dynamic -> String
ShowValueDynamic d = strip (foldr (+++) "" (fst (toStringDynamic d)) +++ " ")
ShowTypeDynamic :: Dynamic -> String
ShowTypeDynamic d = strip (snd (toStringDynamic d) +++ " ")
// debugging code
print_graph :: !a -> Bool;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment