Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Browser application
Commits
f2a60acb
Commit
f2a60acb
authored
4 years ago
by
Amirjanyan
Browse files
Options
Download
Email Patches
Plain Diff
MemriDictionary
parent
29a4e197
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
memri/context/MemriContext.ts
+4
-3
memri/context/MemriContext.ts
memri/cvu/views/Action.ts
+111
-110
memri/cvu/views/Action.ts
memri/cvu/views/Cascadable.ts
+5
-4
memri/cvu/views/Cascadable.ts
memri/cvu/views/CascadableDict.ts
+4
-6
memri/cvu/views/CascadableDict.ts
memri/cvu/views/Renderers.ts
+8
-5
memri/cvu/views/Renderers.ts
memri/cvu/views/SessionView.ts
+6
-4
memri/cvu/views/SessionView.ts
memri/cvu/views/UIElement.ts
+6
-5
memri/cvu/views/UIElement.ts
memri/cvu/views/Views.ts
+3
-2
memri/cvu/views/Views.ts
memri/gui/common/UIElementView.tsx
+3
-2
memri/gui/common/UIElementView.tsx
memri/gui/renderers/GeneralEditorView.tsx
+1
-1
memri/gui/renderers/GeneralEditorView.tsx
memri/model/Cache.ts
+6
-5
memri/model/Cache.ts
memri/model/MemriDictionary.ts
+10
-0
memri/model/MemriDictionary.ts
memri/model/RealmLocal.ts
+11
-3
memri/model/RealmLocal.ts
memri/parsers/cvu-parser/CVUParsedDefinition.ts
+4
-3
memri/parsers/cvu-parser/CVUParsedDefinition.ts
memri/parsers/cvu-parser/CVUParser.ts
+7
-6
memri/parsers/cvu-parser/CVUParser.ts
memri/parsers/cvu-parser/CVUToString.ts
+4
-3
memri/parsers/cvu-parser/CVUToString.ts
memri/parsers/expression-parser/Expression.ts
+2
-1
memri/parsers/expression-parser/Expression.ts
with
195 additions
and
163 deletions
+195
-163
memri/context/MemriContext.ts
+
4
-
3
View file @
f2a60acb
...
...
@@ -33,6 +33,7 @@ import {Renderers} from "../cvu/views/Renderers";
import
{
CacheMemri
}
from
"
../model/Cache
"
;
import
{
Realm
}
from
"
../model/RealmLocal
"
;
import
{
ViewArguments
}
from
"
../cvu/views/CascadableDict
"
;
import
{
MemriDictionary
}
from
"
../model/MemriDictionary
"
;
export
var
globalCache
...
...
@@ -149,7 +150,7 @@ export class MemriContext {
//this.uiUpdateSubject.send() TODO
}
scheduleCascadableViewUpdate
(
immediate
=
fals
e
)
{
scheduleCascadableViewUpdate
(
immediate
=
tru
e
)
{
if
(
immediate
)
{
// Do this straight away, usually for the sake of correct animation
try
{
this
.
currentSession
?.
setCurrentView
()
}
...
...
@@ -474,7 +475,7 @@ export class MemriContext {
.
merge
(
viewArguments
)
.
resolve
(
item
)
var
args
=
{}
var
args
=
new
MemriDictionary
()
for
(
let
[
argName
,
inputValue
]
of
Object
.
entries
(
action
.
values
))
{
if
(
action
.
argumentTypes
[
argName
]
==
undefined
)
{
continue
}
...
...
@@ -491,7 +492,7 @@ export class MemriContext {
let
dataItem
=
argValue
;
if
(
dataItem
?.
constructor
?.
name
==
"
Item
"
)
{
finalValue
=
dataItem
}
else
if
(
typeof
argValue
.
isCVUObject
===
"
fun
ction
"
)
{
}
else
if
(
argValue
?.
constructor
?.
name
===
"
MemriDi
ction
ary
"
)
{
let
dict
=
argValue
;
if
(
action
.
argumentTypes
[
argName
]
==
"
ViewArguments
"
)
{
finalValue
=
new
ViewArguments
(
dict
).
resolve
(
item
,
viewArgs
)
...
...
This diff is collapsed.
Click to expand it.
memri/cvu/views/Action.ts
+
111
-
110
View file @
f2a60acb
This diff is collapsed.
Click to expand it.
memri/cvu/views/Cascadable.ts
+
5
-
4
View file @
f2a60acb
...
...
@@ -6,21 +6,22 @@ import {ActionMultiAction} from "./Action";
import
{
debugHistory
}
from
"
./ViewDebugger
"
;
import
{
CVUParsedDefinition
}
from
"
../../parsers/cvu-parser/CVUParsedDefinition
"
;
import
{
CVUSerializer
}
from
"
../../parsers/cvu-parser/CVUToString
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
Cascadable
/* extends CustomStringConvertible*/
{
host
?:
Cascadable
cascadeStack
:
CVUParsedDefinition
[]
tail
:
CVUParsedDefinition
[]
head
:
CVUParsedDefinition
localCache
=
{}
localCache
=
new
MemriDictionary
()
get
viewArguments
()
{
return
this
.
host
?.
viewArguments
}
set
viewArguments
(
value
)
{
this
.
host
?.
viewArguments
=
value
}
get
toString
()
{
var
merged
=
{}
var
merged
=
new
MemriDictionary
()
function
recur
(
dict
:
{}
)
{
function
recur
(
dict
:
MemriDictionary
)
{
if
(
!
dict
)
{
return
}
for
(
let
[
key
,
value
]
of
Object
.
entries
(
dict
))
{
...
...
@@ -200,7 +201,7 @@ export class Cascadable/* extends CustomStringConvertible*/{
if
(
forceArray
)
{
for
(
var
def
of
this
.
cascadeStack
)
{
let
x
=
def
[
name
]
if
(
typeof
x
.
isCVUObject
===
"
fun
ction
"
)
{
if
(
x
.
constructor
.
name
===
"
MemriDi
ction
ary
"
)
{
for
(
let
[
key
,
value
]
of
Object
.
entries
(
x
))
{
if
(
value
)
{
result
[
key
]
=
value
...
...
This diff is collapsed.
Click to expand it.
memri/cvu/views/CascadableDict.ts
+
4
-
6
View file @
f2a60acb
...
...
@@ -7,6 +7,7 @@ import {Cascadable} from "./Cascadable";
import
{
ItemReference
}
from
"
../../model/DatabaseController
"
;
import
{
CVUParsedDefinition
,
CVUParsedObjectDefinition
}
from
"
../../parsers/cvu-parser/CVUParsedDefinition
"
;
import
{
Item
}
from
"
../../model/items/Item
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
CascadableDict
extends
Cascadable
/*extends Cascadable, Subscriptable*/
{
subscript
()
{
...
...
@@ -49,9 +50,6 @@ export class CascadableDict extends Cascadable/*extends Cascadable, Subscriptabl
}
}
getSubscript
(
name
)
{
return
this
.
get
(
name
)
}
//TODO get with param
setSubscript
(
name
,
value
)
{
this
.
set
(
name
,
value
)
}
constructor
(
head
?,
tail
?:
CVUParsedDefinition
[]
|
Item
,
host
?:
Cascadable
)
{
//TODO
if
(
head
instanceof
CascadableDict
||
tail
instanceof
Item
)
{
super
(
new
CVUParsedObjectDefinition
(),
head
?.
cascadeStack
)
...
...
@@ -59,9 +57,9 @@ export class CascadableDict extends Cascadable/*extends Cascadable, Subscriptabl
}
else
if
(
head
instanceof
CVUParsedDefinition
)
{
super
(
head
,
tail
,
host
)
}
else
{
var
result
=
{}
var
result
=
new
MemriDictionary
()
if
(
head
)
{
if
(
head
&&
head
.
constructor
.
name
===
"
MemriDictionary
"
)
{
for
(
let
[
key
,
value
]
of
Object
.
entries
(
head
))
{
if
(
value
instanceof
Item
)
{
result
[
key
]
=
new
ItemReference
(
value
)
...
...
@@ -103,7 +101,7 @@ export class CascadableDict extends Cascadable/*extends Cascadable, Subscriptabl
deepMerge
(
other
?:
CascadableDict
)
{
if
(
!
other
)
{
return
this
}
let
merge
=
(
parsed
?)
=>
{
let
merge
=
(
parsed
?
:
MemriDictionary
)
=>
{
if
(
!
parsed
)
{
return
}
for
(
let
[
key
,
value
]
of
Object
.
entries
(
parsed
))
{
this
.
head
.
set
(
key
,
value
)
...
...
This diff is collapsed.
Click to expand it.
memri/cvu/views/Renderers.ts
+
8
-
5
View file @
f2a60acb
...
...
@@ -20,6 +20,9 @@ import {registerThumbGridRenderer} from "../../gui/renderers/GridRenderers/Thumb
import
{
registerMessageRenderer
}
from
"
../../gui/renderers/MessageRenderer
"
;
import
{
registerPhotoViewerRenderer
}
from
"
../../gui/renderers/PhotoViewerRenderer/PhotoViewerRenderer
"
;
import
{
GeneralEditorLayoutItem
,
registerGeneralEditorRenderer
}
from
"
../../gui/renderers/GeneralEditorView
"
;
//import {registerThumbHorizontalGridRenderer} from "../../gui/renderers/GridRenderers/ThumbHorizontalGridRendererView";
//import {registerThumbWaterfallRenderer} from "../../gui/renderers/GridRenderers/ThumbWaterfallRendererView";
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
Renderers
{
all
=
{}
...
...
@@ -68,10 +71,10 @@ export var allRenderers = new Renderers();
//FilterPanelRendererButton moved to Action.ts
class
RenderGroup
{
options
=
{}
options
=
new
MemriDictionary
()
body
:
UIElement
=
null
constructor
(
dict
)
{
constructor
(
dict
:
MemriDictionary
)
{
if
(
Array
.
isArray
(
dict
[
"
children
"
])
&&
dict
[
"
children
"
][
0
]?.
constructor
?.
name
==
"
UIElement
"
)
this
.
body
=
dict
[
"
children
"
][
0
]
delete
dict
[
"
children
"
]
this
.
options
=
dict
...
...
@@ -117,7 +120,7 @@ export class CascadingRenderConfig extends Cascadable {
if
(
renderGroup
)
{
return
renderGroup
.
options
}
return
{}
return
new
MemriDictionary
()
}
getRenderGroup
(
group
)
{
...
...
@@ -128,14 +131,14 @@ export class CascadingRenderConfig extends Cascadable {
else
if
(
group
==
"
*
"
&&
this
.
cascadeProperty
(
"
*
"
)
==
null
)
{
let
list
=
this
.
cascadeProperty
(
"
children
"
)
if
(
list
)
{
var
dict
=
{
"
children
"
:
list
}
var
dict
=
new
MemriDictionary
(
{
"
children
"
:
list
}
)
let
renderGroup
=
new
RenderGroup
(
dict
)
this
.
localCache
[
group
]
=
renderGroup
return
renderGroup
}
}
else
{
var
dict
=
this
.
cascadeProperty
(
group
)
var
dict
:
MemriDictionary
=
this
.
cascadeProperty
(
group
)
if
(
dict
)
{
let
renderGroup
=
new
RenderGroup
(
dict
)
this
.
localCache
[
group
]
=
renderGroup
...
...
This diff is collapsed.
Click to expand it.
memri/cvu/views/SessionView.ts
+
6
-
4
View file @
f2a60acb
...
...
@@ -8,6 +8,8 @@
import
{
realmWriteIfAvailable
}
from
"
../../gui/util
"
;
import
{
Datasource
}
from
"
../../api/Datasource
"
;
import
{
CVUStoredDefinition
}
from
"
../../model/items/Item
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
SessionView
/*extends DataItem */
{
...
...
@@ -76,16 +78,16 @@ export class SessionView /*extends DataItem */{
args
=
parsed
[
"
viewArguments
"
].
clone
();
}
var
values
=
{
//TODO
var
values
=
new
MemriDictionary
(
{
//TODO
selector
:
parsed
?.
selector
??
stored
?.
selector
??
"
[view]
"
,
name
:
typeof
parsed
[
"
name
"
]
===
'
string
'
?
parsed
[
"
name
"
]
:
stored
?.
name
||
""
,
viewDefinition
:
stored
??
new
CVUStoredDefinition
({
//TODO
viewDefinition
:
stored
??
new
CVUStoredDefinition
(
new
MemriDictionary
(
{
//TODO
type
:
"
view
"
,
selector
:
parsed
?.
selector
,
domain
:
parsed
?.
domain
,
definition
:
parsed
?.
toCVUString
(
0
,
"
"
)
})
}
})
)
}
)
if
(
args
)
{
values
[
"
viewArguments
"
]
=
args
}
if
(
us
)
{
values
[
"
userState
"
]
=
us
}
...
...
This diff is collapsed.
Click to expand it.
memri/cvu/views/UIElement.ts
+
6
-
5
View file @
f2a60acb
...
...
@@ -16,18 +16,19 @@ import {
import
{
debugHistory
}
from
"
./ViewDebugger
"
;
import
{
dataItemListToArray
,
UUID
}
from
"
../../model/items/Item
"
;
import
{
ViewArguments
}
from
"
./CascadableDict
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
UIElement
/*extends CVUToString */
{
id
=
UUID
()
type
:
UIElementFamily
children
=
[]
properties
=
{}
// TODO: ViewParserDefinitionContext
properties
:
MemriDictionary
// TODO: ViewParserDefinitionContext
constructor
(
type
,
children
?,
properties
=
{}
)
{
constructor
(
type
,
children
?,
properties
?
)
{
//super()
this
.
type
=
type
this
.
children
=
children
??
this
.
children
this
.
properties
=
properties
this
.
properties
=
properties
??
new
MemriDictionary
()
}
has
(
propName
)
{
...
...
@@ -290,8 +291,8 @@ export var validateUIElementProperties = function (key, value) {
case
UIElementProperties
.
image
:
return
value
?.
constructor
?.
name
==
"
File
"
||
typeof
value
==
"
string
"
;
case
UIElementProperties
.
press
:
return
value
?.
constructor
?.
name
==
"
Action
"
||
Array
.
isArray
(
value
)
&&
value
[
0
]?.
constructor
?.
name
==
"
Action
"
case
UIElementProperties
.
list
:
return
Array
.
isArray
(
value
)
&&
value
[
0
]?.
constructor
?.
name
==
"
Item
"
case
UIElementProperties
.
view
:
return
value
?.
constructor
?.
name
==
"
CVUParsedDefinition
"
||
typeof
value
.
isCVUObject
===
"
fun
ction
"
case
UIElementProperties
.
arguments
:
return
typeof
value
.
isCVUObject
===
"
fun
ction
"
case
UIElementProperties
.
view
:
return
value
?.
constructor
?.
name
==
"
CVUParsedDefinition
"
||
value
.
constructor
.
name
===
"
MemriDi
ction
ary
"
case
UIElementProperties
.
arguments
:
return
value
.
constructor
.
name
===
"
MemriDi
ction
ary
"
case
UIElementProperties
.
location
:
return
value
?.
constructor
?.
name
==
"
Location
"
case
UIElementProperties
.
address
:
return
value
?.
constructor
?.
name
==
"
Address
"
case
UIElementProperties
.
value
:
return
true
...
...
This diff is collapsed.
Click to expand it.
memri/cvu/views/Views.ts
+
3
-
2
View file @
f2a60acb
...
...
@@ -17,6 +17,7 @@ import {CacheMemri} from "../../model/Cache";
import
{
CVUStateDefinition
,
dataItemListToArray
,
Item
}
from
"
../../model/items/Item
"
;
import
{
ViewArguments
}
from
"
./CascadableDict
"
;
import
{
CascadingRenderConfig
}
from
"
./Renderers
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
Views
{
///
...
...
@@ -103,10 +104,10 @@ export class Views {
DatabaseController
.
tryWriteSync
(()
=>
{
// Start write transaction outside loop for performance reasons
// Loop over lookup table with named views
for
(
let
def
of
parsedDefinitions
)
{
var
values
=
{
var
values
=
new
MemriDictionary
(
{
"
domain
"
:
"
defaults
"
,
"
definition
"
:
def
.
toString
(),
//TODO
}
}
)
if
(
def
.
selector
!=
undefined
)
{
values
[
"
selector
"
]
=
def
.
selector
}
if
(
def
.
name
!=
undefined
)
{
values
[
"
name
"
]
=
def
.
name
}
...
...
This diff is collapsed.
Click to expand it.
memri/gui/common/UIElementView.tsx
+
3
-
2
View file @
f2a60acb
...
...
@@ -35,6 +35,7 @@ import {RichTextEditor} from "../MemriTextEditor/RichTextEditor";
import
{
MessageBubbleView
}
from
"
../renderers/MessageRenderer
"
;
import
{
SubView
}
from
"
./SubView
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
UIElementView
extends
MainUI
{
context
:
MemriContext
...
...
@@ -110,10 +111,10 @@ export class UIElementView extends MainUI {
this
.
context
=
this
.
props
.
context
;
this
.
init
(
this
.
props
.
gui
,
this
.
props
.
dataItem
,
this
.
props
.
viewArguments
);
let
editorLabelAction
=
()
=>
{
let
args
=
{
let
args
=
new
MemriDictionary
(
{
"
subject
"
:
this
.
context
.
item
,
// self.item,
"
edgeType
"
:
this
.
viewArguments
.
get
(
"
name
"
)
}
}
)
let
action
=
new
ActionUnlink
(
this
.
context
,
args
)
this
.
context
.
executeAction
(
action
,
this
.
item
,
this
.
viewArguments
)
...
...
This diff is collapsed.
Click to expand it.
memri/gui/renderers/GeneralEditorView.tsx
+
1
-
1
View file @
f2a60acb
...
...
@@ -43,7 +43,7 @@ export var registerGeneralEditorRenderer = function () {
export
class
GeneralEditorLayoutItem
{
id
=
UUID
()
dict
//future
Dictionary
dict
:
Memri
Dictionary
viewArguments
constructor
(
dict
,
viewArguments
?)
{
...
...
This diff is collapsed.
Click to expand it.
memri/model/Cache.ts
+
6
-
5
View file @
f2a60acb
...
...
@@ -14,6 +14,7 @@ import {ResultSet} from "./ResultSet";
import
{
DatabaseController
}
from
"
./DatabaseController
"
;
import
{
Realm
}
from
"
./RealmLocal
"
;
import
{
Sync
}
from
"
./Sync
"
;
import
{
MemriDictionary
}
from
"
./MemriDictionary
"
;
export
var
cacheUIDCounter
:
number
=
-
1
export
class
CacheMemri
{
...
...
@@ -61,7 +62,7 @@ export class CacheMemri {
var
lut
=
{}
function
recur
(
dict
)
{
var
values
=
{}
var
values
=
new
MemriDictionary
()
let
type
=
dict
[
"
_type
"
];
let
itemType
=
getItemType
(
type
);
if
(
typeof
type
!=
"
string
"
||
!
itemType
)
{
...
...
@@ -411,7 +412,7 @@ export class CacheMemri {
let
itemType
=
item
.
getType
()
if
(
itemType
)
{
var
dict
=
{}
;
var
dict
=
new
MemriDictionary
()
;
for
(
var
prop
in
item
)
{
if
(
item
.
hasOwnProperty
(
prop
))
{
...
...
@@ -490,7 +491,7 @@ export class CacheMemri {
}
//#warning("This doesnt trigger syncToPod()")
static
createItem
(
type
,
values
=
{}
,
unique
?:
string
)
{
static
createItem
(
type
,
values
=
new
MemriDictionary
()
,
unique
?:
string
)
{
var
item
DatabaseController
.
tryWriteSync
((
realm
:
Realm
)
=>
{
var
dict
=
values
...
...
@@ -594,7 +595,7 @@ export class CacheMemri {
// TODO: find item in DB & merge
// Uniqueness based on also not primary key
let
values
=
{
let
values
=
new
MemriDictionary
(
{
"
targetItemType
"
:
target
[
0
],
"
targetItemID
"
:
target
[
1
],
"
sourceItemType
"
:
source
.
genericType
,
...
...
@@ -604,7 +605,7 @@ export class CacheMemri {
"
sequence
"
:
sequence
,
"
dateCreated
"
:
new
Date
(),
"
_action
"
:
"
create
"
}
}
)
edge
=
realm
.
create
(
"
Edge
"
,
values
)
});
...
...
This diff is collapsed.
Click to expand it.
memri/model/MemriDictionary.ts
0 → 100644
+
10
-
0
View file @
f2a60acb
export
class
MemriDictionary
{
constructor
(
properties
=
{})
{
for
(
let
key
in
properties
)
{
this
[
key
]
=
properties
[
key
];
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
memri/model/RealmLocal.ts
+
11
-
3
View file @
f2a60acb
...
...
@@ -84,9 +84,17 @@ export class RealmObjects extends Array {
sorted
(
descriptor
:
string
,
reverse
?:
boolean
)
{
//TODO:
return
this
;
/*.sort((a, b) => {
}) */
return
this
.
sort
((
a
,
b
)
=>
{
let
res
if
(
a
[
descriptor
]
>
b
[
descriptor
])
{
res
=
1
}
else
if
(
a
[
descriptor
]
<
b
[
descriptor
])
{
res
=
-
1
}
else
{
res
=
0
}
return
reverse
?
res
:
-
res
})
}
}
...
...
This diff is collapsed.
Click to expand it.
memri/parsers/cvu-parser/CVUParsedDefinition.ts
+
4
-
3
View file @
f2a60acb
import
{
CVUSerializer
}
from
"
./CVUToString
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
enum
CompileScope
{
all
=
"
all
"
,
...
...
@@ -37,7 +38,7 @@ export class CVUParsedDefinition {
}
parsed
:
{}
;
parsed
=
new
MemriDictionary
()
;
get
description
():
string
{
return
this
.
toCVUString
(
0
,
"
"
)
...
...
@@ -85,7 +86,7 @@ export class CVUParsedDefinition {
return
scope
==
CompileScope
.
all
?
notnil
.
execute
(
viewArguments
)
:
notnil
.
compile
(
viewArguments
)
}
else
if
(
typeof
notnil
.
isCVUObject
==
"
fun
ction
"
)
{
}
else
if
(
notnil
.
constructor
.
name
==
"
MemriDi
ction
ary
"
)
{
for
(
let
[
key
,
value
]
of
Object
.
entries
(
notnil
))
{
notnil
[
key
]
=
recur
(
value
)
}
...
...
@@ -200,7 +201,7 @@ export class CVUParsedViewDefinition extends CVUParsedDefinition {
query
?:
ExprNode
get
definitionType
()
{
return
"
view
"
}
constructor
(
selector
,
name
,
type
?,
query
?,
domain
:
string
=
"
user
"
,
parsed
?)
{
//TODO
constructor
(
selector
,
name
,
type
?,
query
?,
domain
:
string
=
"
user
"
,
parsed
?
:
MemriDictionary
)
{
//TODO
super
(
selector
,
name
,
domain
,
parsed
)
this
.
type
=
type
...
...
This diff is collapsed.
Click to expand it.
memri/parsers/cvu-parser/CVUParser.ts
+
7
-
6
View file @
f2a60acb
...
...
@@ -21,6 +21,7 @@ import {
}
from
"
./CVUParsedDefinition
"
import
{
ActionFamily
,
getActionType
}
from
"
../../cvu/views/Action
"
;
import
{
UIElement
,
UIElementFamily
}
from
"
../../cvu/views/UIElement
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
Color
{
value
;
...
...
@@ -315,7 +316,7 @@ export class CVUParser {
}
parseDict
(
uiElementName
?)
{
var
dict
=
{}
;
var
dict
=
new
MemriDictionary
()
;
var
stack
=
[];
let
forUIElement
=
this
.
knownUIElements
[
uiElementName
?.
toLowerCase
()
??
""
]
!=
undefined
;
//TODO:
...
...
@@ -343,7 +344,7 @@ export class CVUParser {
}
}
function
addUIElement
(
type
,
properties
)
{
//TODO:
function
addUIElement
(
type
,
properties
:
MemriDictionary
)
{
//TODO:
var
children
=
dict
[
"
children
"
]
||
[];
let
subChildren
=
Object
.
assign
([],
properties
.
children
);
delete
properties
.
children
;
...
...
@@ -447,7 +448,7 @@ export class CVUParser {
let
lvalue
=
v
.
toLowerCase
();
let
type
=
this
.
knownUIElements
[
lvalue
];
if
(
lastKey
==
null
&&
type
)
{
var
properties
=
{}
;
var
properties
=
new
MemriDictionary
()
;
if
(
CVUToken
.
CurlyBracketOpen
==
this
.
peekCurrentToken
().
constructor
)
{
this
.
popCurrentToken
();
properties
=
this
.
parseDict
(
v
);
...
...
@@ -456,7 +457,7 @@ export class CVUParser {
addUIElement
(
type
,
properties
);
//TODO
continue
;
}
else
if
(
lvalue
==
"
userstate
"
||
lvalue
==
"
viewarguments
"
||
lvalue
==
"
contextpane
"
)
{
var
properties
=
{}
;
var
properties
=
new
MemriDictionary
()
;
if
(
CVUToken
.
CurlyBracketOpen
==
this
.
peekCurrentToken
().
constructor
)
{
this
.
popCurrentToken
();
properties
=
this
.
parseDict
();
...
...
@@ -472,7 +473,7 @@ export class CVUParser {
}
else
{
let
name
=
this
.
knownActions
[
v
.
toLowerCase
()];
if
(
name
)
{
var
options
=
{}
;
var
options
=
new
MemriDictionary
()
;
outerLoop
:
while
(
true
)
{
switch
(
this
.
peekCurrentToken
().
constructor
)
{
case
CVUToken
.
Comma
:
...
...
@@ -702,7 +703,7 @@ export class CVUParser {
}
};
processCompoundProperties
(
dict
)
{
processCompoundProperties
(
dict
:
MemriDictionary
)
{
for
(
let
name
in
this
.
frameProperties
)
{
if
(
dict
[
name
])
{
...
...
This diff is collapsed.
Click to expand it.
memri/parsers/cvu-parser/CVUToString.ts
+
4
-
3
View file @
f2a60acb
...
...
@@ -4,6 +4,7 @@
// Copyright © 2020 memri. All rights reserved.
//
import
{
HorizontalAlignment
,
Alignment
,
Color
,
VerticalAlignment
,
TextAlignment
,
Font
,
CGFloat
}
from
"
./CVUParser
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
//function UIElement() {}
...
...
@@ -46,7 +47,7 @@ export class CVUSerializer {
return
`"
${
p
.
replace
(
"
\"
"
,
"
\\\"
"
)}
"`
;
}
else
if
(
Array
.
isArray
(
p
))
{
return
this
.
arrayToString
(
p
,
depth
+
1
,
tab
)
}
else
if
(
typeof
p
.
isCVUObject
===
"
fun
ction
"
)
{
//TODO:
}
else
if
(
p
.
constructor
.
name
===
"
MemriDi
ction
ary
"
)
{
//TODO:
return
this
.
dictToString
(
p
,
depth
+
1
,
tab
)
}
else
if
(
typeof
p
.
toCVUString
===
"
function
"
)
{
//TODO:
return
p
.
toCVUString
(
depth
,
tab
)
...
...
@@ -97,7 +98,7 @@ export class CVUSerializer {
:
str
.
join
((
extraNewLine
?
"
\n
"
:
""
)
+
`\n
${
tabs
}
`
)
}
static
dictToString
(
dict
,
depth
:
number
=
0
,
tab
:
string
=
"
"
,
static
dictToString
(
dict
:
MemriDictionary
,
depth
:
number
=
0
,
tab
:
string
=
"
"
,
withDef
:
boolean
=
true
,
extraNewLine
:
boolean
=
false
,
sortFunc
?):
string
{
var
keys
:
string
[];
...
...
@@ -140,7 +141,7 @@ export class CVUSerializer {
if
(
!
isDef
||
dict1
!=
undefined
&&
Object
.
entries
(
dict1
)?.
length
>
0
)
{
let
p
=
value
;
if
(
p
&&
typeof
p
.
isCVUObject
===
"
fun
ction
"
)
{
if
(
p
&&
p
.
constructor
.
name
===
"
MemriDi
ction
ary
"
)
{
str
.
push
((
extraNewLine
?
"
\n
"
+
(
withDef
?
tabs
:
tabsEnd
)
:
""
)
+
`
${
key
}
:
${
this
.
valueToString
(
p
,
depth
,
tab
)}
`
);
}
else
if
(
value
!==
undefined
)
{
...
...
This diff is collapsed.
Click to expand it.
memri/parsers/expression-parser/Expression.ts
+
2
-
1
View file @
f2a60acb
...
...
@@ -10,6 +10,7 @@ const {ExprLexer} = require("./ExprLexer");
const
{
ExprParser
}
=
require
(
"
./ExprParser
"
);
import
{
ExprInterpreter
}
from
"
./ExprInterpreter
"
;
import
{
DatabaseController
,
ItemReference
}
from
"
../../model/DatabaseController
"
;
import
{
MemriDictionary
}
from
"
../../model/MemriDictionary
"
;
export
class
Expression
{
code
:
string
;
...
...
@@ -170,7 +171,7 @@ export class Expression {
static
resolve
(
object
?,
viewArguments
?:
ViewArguments
,
dontResolveItems
:
boolean
=
false
)
{
//TODO:
var
dict
=
object
;
if
(
typeof
dict
?.
isCVUObject
==
"
fun
ction
"
)
{
if
(
dict
?.
constructor
.
name
===
"
MemriDi
ction
ary
"
)
{
for
(
let
[
key
,
value
]
of
Object
.
entries
(
dict
))
{
dict
[
key
]
=
this
.
resolve
(
value
,
viewArguments
,
dontResolveItems
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment