cmdr
Check-in [7bf67db33e]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Additional tracing of command prefix resolution
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7bf67db33e8f392a0baf8b95c85db1ba706fd70e
User & Date: aku 2017-09-02 21:21:56
Context
2017-09-12
17:24
Bump cmdr::table to v0.2. The rewrite to the (no)header logic left the header row in the output, and now even colorized. Noted with the CM website generation, where these color control sequences leaked into HTML output. Leaf check-in: 972556826b user: aku tags: trunk
2017-09-02
21:21
Additional tracing of command prefix resolution check-in: 7bf67db33e user: aku tags: trunk
2016-07-14
19:07
Removed bogus file type tags from the diagram DSL definitions used by our figures check-in: e94123d354 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to core/officer.tcl.

398
399
400
401
402
403
404


405
406
407
408
409
410
411
...
425
426
427
428
429
430
431
432



433
434
435



436
437
438



439
440
441
442
443
444
445

    method Def {name handler} {
	# Make an action known to the dispatcher.
	dict set mymap last $name
	dict set mymap a,$name $handler
	lappend mycommands $name



	# Update the map of action prefixes
	set prefix {}
	foreach c [split $name {}] {
	    append prefix $c
	    dict lappend mypmap $prefix $handler
	}
	return
................................................................................
	}
	return [dict get $mymap last]
    }

    method Known {name} {
	debug.cmdr/officer {[debug caller] | }
	# Known exact action is good
	if {[dict exists $mymap a,$name]} { return 1 }



	debug.cmdr/officer {no action, maybe prefix}
	# Unknown prefix is bad
	if {![dict exists $mypmap $name]} { return 0 }



	debug.cmdr/officer {prefix, maybe ambiguous}
	# As is an ambiguous prefix
	if {[llength [dict get $mypmap $name]] > 1} { return 0 }



	debug.cmdr/officer {unique prefix}
	# Known unique prefix is good.
	return 1
    }

    # # ## ### ##### ######## #############
    ## Command dispatcher. Choose the subordinate and delegate.







>
>







 







|
>
>
>


|
>
>
>


|
>
>
>







398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456

    method Def {name handler} {
	# Make an action known to the dispatcher.
	dict set mymap last $name
	dict set mymap a,$name $handler
	lappend mycommands $name

	#puts |Def|[my fullname]|+|$name|\t\t($handler)

	# Update the map of action prefixes
	set prefix {}
	foreach c [split $name {}] {
	    append prefix $c
	    dict lappend mypmap $prefix $handler
	}
	return
................................................................................
	}
	return [dict get $mymap last]
    }

    method Known {name} {
	debug.cmdr/officer {[debug caller] | }
	# Known exact action is good
	if {[dict exists $mymap a,$name]} {
	    debug.cmdr/officer {found action as-is}
	    return 1
	}
	debug.cmdr/officer {no action, maybe prefix}
	# Unknown prefix is bad
	if {![dict exists $mypmap $name]} {
	    debug.cmdr/officer {no prefix}
	    return 0
	}
	debug.cmdr/officer {prefix, maybe ambiguous}
	# As is an ambiguous prefix
	if {[llength [dict get $mypmap $name]] > 1} {
	    debug.cmdr/officer {ambiguous, found: [dict get $mypmap $name]}
	    return 0
	}
	debug.cmdr/officer {unique prefix}
	# Known unique prefix is good.
	return 1
    }

    # # ## ### ##### ######## #############
    ## Command dispatcher. Choose the subordinate and delegate.