PreviousUpNext

15.4.1389  src/lib/x-kit/widget/edit/bool-millout.pkg

## bool-millout.pkg
#

# Compiled by:
#     src/lib/x-kit/widget/xkit-widget.sublib


stipulate
    include package   threadkit;                                                        # threadkit                     is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
    package mt  =  millboss_types;                                                      # millboss_types                is from   src/lib/x-kit/widget/edit/millboss-types.pkg

    nb = log::note_on_stderr;                                                           # log                           is from   src/lib/std/src/log.pkg
herein

    package bool_millout                                                                # 
    {
        Bool_Millout
          =     
          { note_watcher:       (mt::Inport, Null_Or(mt::Millin), (mt::Outport, Bool) -> Void) -> Void,         # Second arg will be NULL if watcher is not another mill (e.g. a pane).
            drop_watcher:        mt::Inport -> Void                                                             # The mt::Inport must match that given to note_watcher.
          };                             

        exception  BOOL_MILLOUT  Bool_Millout;                                          # We'll never 'raise' this exception:  It is purely a datastructure to hide the Bool_Millout type from millboss-imp.pkg, in the interests of good modularity.
        #
        #
        fun maybe_unwrap__bool_millout  (watchable:  mt::Millout):  Fail_Or( Bool_Millout )
            =
            case watchable.crypt
                #
                BOOL_MILLOUT
                bool_millout
                    =>
                    WORK bool_millout;

                _   =>  FAIL (sprintf "maybe_unwrap__bool_millout:  Unknown Millout value, port_type='%s', data_type='%s' info='%s'  --bool-millout.pkg"
                                        watchable.port_type 
                                        watchable.data_type 
                                        watchable.info
                             );
            esac;       

        fun unwrap__bool_millout  (watchable:  mt::Millout):   Bool_Millout
            =
            case watchable.crypt
                #
                BOOL_MILLOUT
                bool_millout
                    =>
                    bool_millout;

                _   =>  {   msg = (sprintf "maybe_unwrap__bool_millout:  Unknown Millout value, port_type='%s', data_type='%s' info='%s'  --bool-millout.pkg"
                                        watchable.port_type 
                                        watchable.data_type 
                                        watchable.info
                                  );
                            log::fatal msg;                                                     # Won't return.
                            raise exception DIE msg;                                            # Just to keep compiler happy.
                        };
            esac;       


        port_type =  "bool_millout::Bool_Millout";                                              # Export so clients can use this value by reference instead of duplication (with attendant maintenance issues).

        fun wrap__bool_millout
              (
                outport:        mt::Outport,
                bool_millout:   Bool_Millout
              )
            :                   mt::Millout
            =
            { outport,
              port_type,
              data_type =>  "Bool",
              info      =>  "Wrapped by bool_millout::wrap__bool_millout.",
              crypt     =>  BOOL_MILLOUT bool_millout,
              counter   =>  REF 0       
            };           
    };

end;





Comments and suggestions to: bugs@mythryl.org

PreviousUpNext