ycl

Artifact [9ea1a7a23b]
Login

Artifact [9ea1a7a23b]

Artifact 9ea1a7a23b1deb4fe2d126a8723c62d7942f5f37:


#! /bin/env tclsh

package require {ycl iter}
package require {ycl ns}
namespace import [yclprefix]::ns
package require {ycl proc}
package require {ycl shelf shelf}
namespace import [yclprefix]::shelf::shelf
package require {ycl vso}
namespace import [yclprefix]::route

shelf .spawn [namespace current]

[yclprefix]::vso::universe class chan {}
[yclprefix]::vso::universe class chan iter 
[yclprefix]::vso::universe class vsochan {}
[yclprefix]::vso::universe class vsochan chan 

apply [list {} {
	foreach name {~ close configure eof iter more open read seek write} {
		[yclprefix]::vso::universe route $name vsochan [namespace current]::$name
	}
} [namespace current]]

proc init {_ args} {
	foreach proc {~ close configure eof iter more open read seek write} {
		[yclprefix]::vso::universe router ${_}::$proc
	}
	[yclprefix]::vso::universe datum $_ vsochan
	return $_
}
[namespace current] .method init

apply [list {} {
	proc ~ {*}[[yclprefix]::chan::methods::~ _ {close $_}]

	proc close {*}[[yclprefix]::chan::methods::close _ {::close [$_ $ chan]}]

	proc configure {*}[[yclprefix]::chan::methods::configure _ {::chan configure [$_ $ chan]}]

	proc eof {*}[[yclprefix]::chan::methods::eof _ {::eof [$_ $ chan]}]

	namespace upvar [yclprefix]::chan::methods::doc iter doc::iter
	dict set doc::iter args _ {
		description {
			the channel object
		}
	}
	proc iter {*}[[yclprefix]::chan::methods::iter _ {more $_} {eof $_}]

	proc more {*}[[yclprefix]::chan::methods::more _ {::gets [$_ $ chan]}]

	proc open {*}[[yclprefix]::chan::methods::open _ {::open $fname} {$_ $ chan $chan}]

	proc read {*}[[yclprefix]::chan::methods::read _ {::read [$_ $ chan]}]

	proc seek {*}[[yclprefix]::chan::methods::seek _ {::seek [$_ $ chan]}]

} [namespace current]]