Example foogen

This example exercises some Modula-3 capabilities of ILU.  It includes four suites of ISL interface file, M3 server app, and M3 client app.  The suites are: Foo, Bar, Baz, and Goo.  In each suite, the interface file is named <Suite>.isl, the server <Suite>M3Server, and the client <Suite>M3Client, for <Suite> being one of Foo, Bar, Baz, and Goo.  Foo provides a basic test of some data types.  Bar and Baz test cross-interface subtyping.  Goo tests the relation between subtyping and GCness (but within one interface, which doesn't make for the strongest test).

To build, issue the commands
	% ilumkmf
	% sunrpc-register-interface Foo.isl
	% sunrpc-register-interface Bar.isl
	% sunrpc-register-interface Baz.isl
	% sunrpc-register-interface Goo.isl
	% make

To build only some of the apps, say the Foo and Goo server and client, give them as arguments to make:
	% make FooM3Server FooM3Client GooM3Server GooM3Client

Following is a description of each of the four suites.


Foo

The server exports two instances of Foo.O, using either UDP or TCP.  It takes one optional command line argument, either "-t" or "-u"; TCP is the default.  The server prints out the String Binding Handle and Most Specific Type Id of each of the two instances:

% ./FooM3Server
SBH1&mstid is '1@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea'
SBH2&mstid is '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea'

The client imports and instance of Foo.O and calls its U-CSS-to-U method, using a U and CSS constructed from the command line arguments.  The first two arguments are the SBH and MSTID of the Foo.O instance; the remainder form the "css: CSS" argument of the U-CSS-to-U method.  The "u: U" is the CSS case, with the same value as "css".  The result of the method call is printed; if that result is itself a Foo.O, U_CSS_to_U is invoked on that result, and the result of *that* invocation is also printed.

The server implements U-CSS-to-U by a case analysis on the length of "css".  For length 0, it returns u; for length 1, it raises Foo.E1(u); for length 2, it raises Foo.E2; for length 3 it returns css; for length 4 it returns the Foo.O; for greater lengths, it returns a new Foo.O.  Here are examples showing all the cases:

% ./FooM3Client '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea'
Got <>

% ./FooM3Client '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea' x
Foo.E1(<`x'>)

% ./FooM3Client '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea' x y
Foo.E2(200)

% ./FooM3Client '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea' x y z
Got <`x', `y', `z'>

% ./FooM3Client '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea' x y z z
Got O 2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719 => O 2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719

% ./FooM3Client '2@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719' 'ilu:f3yfcWZXNcktexvPdmFOeq980Ea' x y z z y
Got OO 3@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719 => OO 4@6175677573742db7162b.0@sunrpc_2_0x310001ee_1|tcp_13.2.116.14_3719


Bar

This exists simply to provide an independent interface for Baz to inherit from.  The server takes no command line arguments, exports one instance of Bar.P, and reports its SBH and MSTID:

% ./BarM3Server
SBH1&mstid is '1@6175677573742db718e1.0@sunrpc_2_0x310001dc_1|tcp_13.2.116.14_3748' 'ilu:kHXdMLy2gxs8YxT5uQE4cShJ4Ce'

The client takes three command line arguments, SBH MSTID N, and calls the P1 method of the indicated Bar.P:

% ./BarM3Client '1@6175677573742db718e1.0@sunrpc_2_0x310001dc_1|tcp_13.2.116.14_3748' 'ilu:kHXdMLy2gxs8YxT5uQE4cShJ4Ce' 42
Got 89


Baz

This interface is for testing multiple supertyping: Baz.O is a direct subclass of both Foo.O and Bar.P.  The server takes no command line arguments, and exports two instances of Baz.O:

% ./BazM3Server
Foo.O tid is ilu:f3yfcWZXNcktexvPdmFOeq980Ea
Bar.P tid is ilu:kHXdMLy2gxs8YxT5uQE4cShJ4Ce
SBH2&mstid is '1@6175677573742db719fd.2@sunrpc_2_0x310001dd_1|tcp_13.2.116.14_3756' 'ilu:itKbHTnVijxp7QnKovxwhx2C09O'
SBH1&mstid is '2@6175677573742db719fd.2@sunrpc_2_0x310001dd_1|tcp_13.2.116.14_3756' 'ilu:itKbHTnVijxp7QnKovxwhx2C09O'

The client imports one instance of Baz.O, using the first two arguments on the command line, and calls either Foo.O's U-CSS-to-U method, Bar.P's P1 method, or Baz.O's M1 method, depending on the third command line argument, which should be either "M1", "P1", or "U-CSS-to-U"; the method arguments follow, in the usual way.  Here are examples:

% ./BazM3Client '1@6175677573742db719fd.2@sunrpc_2_0x310001dd_1|tcp_13.2.116.14_3756' 'ilu:itKbHTnVijxp7QnKovxwhx2C09O' U-CSS-to-U a b c
Got <`a', `b', `c'>

% ./BazM3Client '1@6175677573742db719fd.2@sunrpc_2_0x310001dd_1|tcp_13.2.116.14_3756' 'ilu:itKbHTnVijxp7QnKovxwhx2C09O' P1 11
Got 31

% ./BazM3Client '1@6175677573742db719fd.2@sunrpc_2_0x310001dd_1|tcp_13.2.116.14_3756' 'ilu:itKbHTnVijxp7QnKovxwhx2C09O' M1 13
Got <`from a Baz.O', `13', `260'>


Goo

This interface has a collectible type O with a non-collectible subtype P.  The server takes no command line arguments and exports one O and one P.  The server frees the O (locally) 60 seconds after exporting it; the P is freed locally another 30 seconds later.  The program continues to hang around indefinitely.  If not used by a client, it will look like this:

% ./GooM3Server
Goo.O tid is ilu:priHy-Ixbn=Ysj5d=lIYc3AK732
Goo.P tid is ilu:g8a1D9DtEKdXs2R8blIJJ5-ZH7Y
SBH1&mstid is '1@6175677573742db71c5c.2@sunrpc_2_0x310001de_1|tcp_13.2.116.14_3780' 'ilu:priHy-Ixbn=Ysj5d=lIYc3AK732'
SBH2&mstid is '2@6175677573742db71c5c.2@sunrpc_2_0x310001ef_1|tcp_13.2.116.14_3780' 'ilu:g8a1D9DtEKdXs2R8blIJJ5-ZH7Y'
Closing obj 1.
Closing obj 2.
^C
% 

The client imports either an O or a P, and calls either m1 or m2 (respectively).  60 seconds after the call, it closes the imported object locally.  Here's a successful importation of an O and call on m1:

% ./GooM3Client '1@6175677573742db71d23.2@sunrpc_2_0x310001de_1|tcp_13.2.116.14_3786' 'ilu:priHy-Ixbn=Ysj5d=lIYc3AK732' m1 1
Got <`10', `11'>

Here's an unsuccessful importation due to the object already being freed:

% ./GooM3Client '2@6175677573742db71d23.2@sunrpc_2_0x310001ef_1|tcp_13.2.116.14_3786' 'ilu:g8a1D9DtEKdXs2R8blIJJ5-ZH7Y' m1 1
_ilu_CommunicationsError:  Permission denied (errno 13) on call 1
                              input from server 6175677573742db71d23.2 (fd 6).
Failure in worker thread for server 6175677573742db71d23.2: ilu_InputObjectID failed --- quitting worker!
IluBasics.Failed(reply problem - Unknown)
