Every open device has one of these objects. The sting used to open the device is saved, along with the base address of the device object and file object.
\ if we use io_common here than the root object can abort if any of the i/o
\ methods are used against it. It really is not needed; it really is only
\ created for info reasons. It belongs to .opened
\ object
\ :construct
\ :destruct
\ :print
\ link_object
\ :list_head
\ :link_cleanup
\ :unlink_cleanup
\ :number_of_links
\ parented_object
\ :facility
\ :parent_instance
\ :!name
\ :@name
\ :@root
\ root
\ :root_!device
\ :root_!file
parented_object class
protected
public
ram_variable _%opened_devices
cell% instance_variable %%status
cell% instance_variable %%device
cell% instance_variable %%file
m: ( -- )
@u %%status !
\ if open is kind enough to tell us we know
\ Only used by :print to user can find the device object
zero %%device !
zero %%file !
zero this [parent] :construct
; overrides :construct
m: ( --)
this [parent] :destruct
; overrides :destruct
m: ( addr--)
%%device !
; method :root_!device
m: ( addr --)
%%file !
; method :root_!file
\ this gets overridden whenever a different head is used
m: ( --)
_%opened_devices
; overrides :list_head
m: ( --addr)
TRUE ABORT" Root cannot be claimed"
; overrides :facility
m: ( indent --)
CR DUP SPACES ." root | " ." Object : " this .h
." Task: " %%status @ .h
." Device: " %%device @ .h
." File: " %%file @ .h
CR DUP SPACES ." file: " this :@name TYPE
send
DROP
; overrides :print
end_class root
Prints out details of all opened devices.
: .opened
_%opened_devices BEGIN
@ ?DUP
WHILE
zero OVER link>object :print
REPEAT
;