Verified Commit a0e7c779 authored by Camil Staps's avatar Camil Staps 🚀

Remove JSON print/parse cycle for doEditEvent

parent b9785f09
......@@ -3,9 +3,12 @@ Global
ProjectRoot: .
Target: iTasks
Exec: {Project}/LeafletMapExample
ByteCode: {Project}/LeafletMapExample.bc
CodeGen
CheckStacks: False
CheckIndexes: True
OptimiseABC: True
GenerateByteCode: True
Application
HeapSize: 167772160
StackSize: 1048576
......@@ -25,7 +28,7 @@ Global
Stack: False
Dynamics: True
GenericFusion: False
DescExL: False
DescExL: True
Output
Output: ShowConstructors
Font: Courier
......@@ -40,6 +43,9 @@ Global
ResourceSource:
GenerateDLL: False
ExportedNames:
StripByteCode: True
KeepByteCodeSymbols: True
PrelinkByteCode: True
Paths
Path: {Project}
Precompile:
......
......@@ -156,7 +156,7 @@ where
# (taskId,world) = me .# "attributes.taskId" .? world
# (editorId,world) = me .# "attributes.editorId" .? world
# (bounds,world) = getMapBounds mapObj world
# edit = toString (toJSON [LDSetBounds bounds])
# edit = toJSON [LDSetBounds bounds]
# world = (me .# "doEditEvent" .$! (taskId,editorId,edit)) world
= world
//Add initial objects
......@@ -202,7 +202,7 @@ where
# (mapObj,world) = args.[0] .# "target" .? world
# (center,world) = getMapCenter mapObj world
# (bounds,world) = getMapBounds mapObj world
# edit = toString (toJSON [LDSetCenter center,LDSetBounds bounds])
# edit = toJSON [LDSetCenter center,LDSetBounds bounds]
# world = (me .# "doEditEvent" .$! (taskId,editorId,edit)) world
= world
......@@ -212,7 +212,7 @@ where
# (mapObj,world) = args.[0] .# "target" .? world
# (zoom,world) = getMapZoom mapObj world
# (bounds,world) = getMapBounds mapObj world
# edit = toString (toJSON [LDSetZoom zoom,LDSetBounds bounds])
# edit = toJSON [LDSetZoom zoom,LDSetBounds bounds]
# world = (me .# "doEditEvent" .$! (taskId,editorId,edit)) world
= world
......@@ -222,7 +222,7 @@ where
# (mapObj,world) = args.[0] .# "target" .? world
# (clickPos,world) = args.[0] .# "latlng" .? world
# (cursor,world) = toLatLng clickPos world
# edit = toString (toJSON [LDSetCursor cursor])
# edit = toJSON [LDSetCursor cursor]
# world = (me .# "doEditEvent" .$! (taskId,editorId,edit)) world
//Update cursor position on the map
//# world = setMapCursor me mapObj (toJSVal cursor) world // TODO
......@@ -232,7 +232,7 @@ where
onMarkerClick me markerId args world
# (taskId,world) = me .# "attributes.taskId" .? world
# (editorId,world) = me .# "attributes.editorId" .? world
# edit = toString (toJSON [LDSelectMarker markerId])
# edit = toJSON [LDSelectMarker markerId]
# world = (me .# "doEditEvent" .$! (taskId,editorId,edit)) world
= world
......@@ -269,7 +269,7 @@ where
// send edit event to server
# (taskId,world) = me .# "attributes.taskId" .? world
# (editorId,world) = me .# "attributes.editorId" .? world
# edit = toString (toJSON [LDRemoveWindow windowId])
# edit = toJSON [LDRemoveWindow windowId]
# world = (me .# "doEditEvent" .$! (taskId,editorId,edit)) world
= world
where
......@@ -512,7 +512,7 @@ where
onEditing layer _ world
# (update, world) = getUpdate layer world
# (objectId, world) = object .# "attributes." +++ idFieldName .? world
# edit = toString (toJSON [LDUpdateObject (LeafletObjectID (jsValToString` "" objectId)) update])
# edit = toJSON [LDUpdateObject (LeafletObjectID (jsValToString` "" objectId)) update]
# (taskId, world) = me .# "attributes.taskId" .? world
# (editorId, world) = me .# "attributes.editorId" .? world
# (_, world) = (me .# "doEditEvent" .$ (taskId, editorId, edit)) world
......
......@@ -346,10 +346,9 @@ doImageEvent me svglet svg elemId sttf local _ world
// Don't trigger an event, just re-render
= onNewState me svglet model world
// Send edit event
#! (json, world) = (jsWindow .# "JSON.parse" .$ (toString (toJSON model))) world //TODO: Should not really print+parse here
#! (taskId, world) = me .# "attributes.taskId" .? world
#! (editorId,world) = me .# "attributes.editorId" .? world
#! (_, world) = (me .# "doEditEvent" .$ (taskId,editorId,json)) world
#! (_, world) = (me .# "doEditEvent" .$ (taskId,editorId,toJSON model)) world
// Re-render
= onNewState me svglet model world
......
......@@ -3,6 +3,7 @@ definition module iTasks.UI.JS.Interface
import StdGeneric
from StdMaybe import :: Maybe
from StdOverloaded import class toString
from Text.GenJSON import :: JSONNode
:: *JSWorld
......@@ -11,7 +12,7 @@ from StdOverloaded import class toString
:: JSObj :== JSVal
generic gToJS a :: !a -> JSVal
derive gToJS Int, Bool, String, Real, JSVal, Maybe, ()
derive gToJS Int, Bool, String, Real, JSVal, Maybe, (), JSONNode
derive gToJS PAIR, FIELD of {gfd_name}, RECORD
toJS x :== gToJS{|*|} x
......
......@@ -6,6 +6,7 @@ import StdOverloadedList
import Data.Maybe
import Text
import Text.GenJSON
:: *JSWorld = JSWorld
......@@ -140,6 +141,15 @@ gToJS{|Maybe|} fx v = case v of
Nothing -> JSNull
Just x -> fx x
gToJS{|()|} _ = abort "gToJS{|()|} should not be called!"
gToJS{|JSONNode|} n = case n of
JSONNull -> JSNull
JSONBool b -> JSBool b
JSONInt i -> JSInt i
JSONReal r -> JSReal r
JSONString s -> JSString s
JSONArray xs -> JSArray {toJS x \\ x <- xs}
JSONObject xs -> JSObject {{key=k,val=toJS v} \\ (k,v) <- xs}
_ -> abort "missing case in gToJS{|JSONNode|}"
gToJS{|PAIR|} fx fy (PAIR x y) = JSTempPair (fx x) (fy y)
gToJS{|FIELD of {gfd_name}|} fx (FIELD x) = JSTempField gfd_name (fx x)
......
......@@ -169,6 +169,8 @@ const ABC={
ABC.memory_array[hp/4+1]=0;
ABC.memory_array[hp/4+2]=(values[i].shared_clean_value_index<<1)+1;
ABC.memory_array[hp/4+3]=0;
hp+=16;
hp_free-=2;
} else if (typeof values[i]=='object') {
// TODO: check if garbage collection is needed
ABC.memory_array[store_ptrs/4]=hp;
......@@ -261,8 +263,6 @@ ABC.loading_promise=fetch('js/app.pbc').then(function(resp){
memory: ABC.memory,
debug_instr: function (addr, instr) {
if (MAX_INSTRUCTIONS-- == 0)
throw 'MAX_INSTRUCTIONS ran out';
if (ABC_DEBUG)
console.log(addr/8-ABC.code_offset,abc_instructions[instr]);
},
......
......@@ -521,7 +521,6 @@ itasks.Viewport = {
},
doEditEvent: function (taskId, editorId, value) {
var me = this, taskNo = taskId.split("-")[1];
value = JSON.parse(value);
if(editorId) {
me.connection.sendEditEvent(me.attributes.instanceNo, taskNo, editorId, value);
} else {
......
Markdown is supported
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