## template-imp.api
#
# This file is intended purely for clone-and-mutate
# construction of new X imps ("ximps").
#
# For the big picture see the imp dataflow diagrams in
#
#
src/lib/x-kit/xclient/src/window/xclient-ximps.pkg#
# Use protocol is:
#
# { (make_run_gun ()) -> { run_gun', fire_run_gun }; # When we fire the run gun the impnet will start running.
# (make_end_gun ()) -> { end_gun', fire_end_gun }; # When we fire the end gun the impnet will stop running.
#
#
# (teg::make_template_egg []) -> template_egg; # Construct the states for all the individual imps in the impnet.
# (foo::make_foo_egg []) -> foo_egg;
# (bar::make_bar_egg []) -> bar_egg;
# ...
# (zot::make_zot_egg []) -> zot_egg;
#
#
# (template_egg ()) -> (template_exports, template_egg'); # Get the exported ports from all the individual imps in the impnet.
# (foo_egg ()) -> ( foo_exports, foo_egg');
# (bar_egg ()) -> ( bar_exports, bar_egg');
# ...
# (zot_egg ()) -> ( zot_exports, zot_egg');
#
# template_exports -> { template }; # Break out all the sets of exported ports.
# foo_exports -> { foo };
# bar_exports -> { bar, bar_control };
# ...
# zot_exports -> { zot };
#
#
# template_imports -> { int_sink => \\ (i: Int) = (); }; # Construct the sets of imported ports for each imp in the impnet.
# foo_imports -> { template, zot };
# bar_imports -> { foo, zot };
# ...
# zot_imports -> { foo, bar };
#
#
# template_egg' (template_imports, run_gun', end_gun'); # Pass to each imp the ports it imports.
# foo_egg' ( foo_imports, run_gun', end_gun');
# bar_egg' ( bar_imports, run_gun', end_gun');
# ...
# zot_egg' ( zot_imports, run_gun', end_gun');
#
#
# fire_run_gun (); # Start the impnet running.
#
# template.do_something 12; # Many calls like this over lifetime of impnet.
#
# ... # Similar calls to other app imps.
#
# fire_end_gun (); # Shut the impnet down cleanly.
# };
#
#
# The point of the multiphase protocol is to support creating a spec
# datastructure holding everything needed to create or recreate a
# running impnet (microthread graph), retaining the ability to
# shut it down, modify the spec, and then start up the modified graph,
# without losing any state. (Think interactive editing of a GUI, say.)
# Compiled by:
#
src/lib/x-kit/xclient/xclient-internals.sublibstipulate
include package threadkit; # threadkit is from
src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg package tem = template; # template is from
src/lib/x-kit/xclient/src/wire/template.pkgherein
# This api is implemented in:
#
#
src/lib/x-kit/xclient/src/wire/template-imp.pkg #
api Template_Imp # Template to help in constructing new ximps via clone-and-mutate.
{
Exports = { # Ports we provide for use by other imps.
template: tem::Template
};
Imports = { # Ports we use, provided by other imps.
int_sink: Int -> Void
};
Option = MICROTHREAD_NAME String; #
Template_Egg = Void -> (Exports, (Imports, Run_Gun, End_Gun) -> Void);
make_template_egg: List(Option) -> Template_Egg; # A prime point here is to promote software re-use by not exposing
# the type of our internal state to clients: This makes different
# implementations of the interface interchangable to our clients.
}; # api Template
end;