Skip to content

Commit

Permalink
$mol_view_tree2 right bind mixed args
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Dec 16, 2023
1 parent 5d7f5db commit 7296341
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 22 deletions.
4 changes: 2 additions & 2 deletions perf/jsfb/jsfb.view.tree
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $mol_perf_jsfb $mol_scroll
dom_id \swaprows
title \Swap Rows
click? <=> swap? null
<= Rows $mol_list rows <= rows /
<= Rows $mol_list rows <= rows /$mol_view
<= Row*0 $mol_perf_jsfb_row
title? => row_title*?
selected? <=> row_selected*? false
Expand All @@ -45,7 +45,7 @@ $mol_perf_jsfb_row $mol_view
<= Id $mol_view sub / <= id \
<= Title $mol_check
checked? <=> selected? false
sub / <= title
sub / <= title? \
<= Drop $mol_button_minor
sub / <= Drop_icon $mol_icon_cross
click? <=> drop? null
6 changes: 3 additions & 3 deletions view/tree2/class/props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace $.$$ {
<= Close ${d}mol_button
title \close
click?event <=> close?event null
Some ${d}mol_speech
Some* ${d}mol_speech
Text => f
g => h
plugins /
Expand All @@ -38,7 +38,7 @@ namespace $.$$ {
sub /
<= Title
<= Close
Some ${d}mol_speech
Some* ${d}mol_speech
Text => f
g => h
plugins / <= Speech
Expand All @@ -49,7 +49,7 @@ namespace $.$$ {
title \close
click?event <=> close?event
f =
Some ${d}mol_speech Text => f g => h
Some* ${d}mol_speech Text => f g => h
Text
h =
f
Expand Down
56 changes: 40 additions & 16 deletions view/tree2/to/dts/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace $ {
klass,
input.data( '[\'' ),
name_of.call(this, input ),
input.data( '\'] >' ),
input.data( `'] >`),
]
}

Expand Down Expand Up @@ -148,26 +148,50 @@ namespace $ {
const [ left, right ] = input.kids
const left_parts = this.$mol_view_tree2_prop_parts(left)
const right_parts = this.$mol_view_tree2_prop_parts(right)
const left_arg = left_parts.next || left_parts.key
const right_arg = right_parts.next || right_parts.key
const main = klass.data(klass.type)
if (left_arg && right_arg) {
this.$mol_fail(err`Parameters allowed only in ${left.span} or ${right.span}`)

let conflict: 'next' | 'key' | undefined

if (left_parts.next && right_parts.next) conflict = 'next'
if (left_parts.key && right_parts.key) conflict = 'key'

if (conflict) {
this.$mol_fail(err`Only one "${conflict}" allowed: ${
left_parts[conflict]} at ${left.span} or ${right_parts[conflict]} at ${right.span}`)
}

if (left_arg || right_arg) {
const host = ! left_arg && left.kids.length > 0
const main = klass.data(klass.type)
const prop_parts = this.$mol_view_tree2_prop_parts(prop)
const method = prop.data(`${ klass.type }_${prop_parts.name}`)

if (prop_parts.key || prop_parts.next) {
const prop_params = parameters.call(this, main, prop)

const host = left.kids.length > 0
? left.kids[0].data(left.kids[0].type)
: main
: undefined

types.push(
type_enforce.call(
if (prop_parts.key) {
const second_key = left_parts.key ? left : right
types.push( type_enforce.call(
this,
prop.data(`${ klass.type }_${prop.type.replace(/[\?\*]*/g, '')}`),
parameters.call(this, main, prop),
parameters.call(this, host, left_arg ? left : right),
)
)
method,
[ ...prop_params, prop.data('[0]') ],
[ ...parameters.call(this, right_parts.key && host ? host : main, second_key), second_key.data('[0]') ],
) )
}

if (prop_parts.next) {
const second_next = left_parts.next ? left : right
const second_parts = left_parts.next ? left_parts : right_parts

types.push( type_enforce.call(
this,
method,
[ ...prop_params, prop.data(`[${prop_parts.key ? '1' : '0'}]`) ],
[ ...parameters.call(this, right_parts.next && host ? host : main, second_next),
second_next.data(`[${second_parts.key ? '1' : '0'}]`) ],
) )
}
}

return return_type.call(
Expand Down
2 changes: 1 addition & 1 deletion view/tree2/to/js/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace $ {
] ),
],

'=': bind => [ call_of.call(this, bind, false) ],
'=': bind => [ call_of.call(this, bind, true) ],

'': ( input, belt, context )=> {

Expand Down

0 comments on commit 7296341

Please sign in to comment.