[Info-vax] BridgeWorks -> TIG

Arne Vajhøj arne at vajhoej.dk
Thu Sep 5 13:30:55 EDT 2024


On 8/11/2024 7:03 PM, Arne Vajhøj wrote:
> Not much feedback, but I did some of the outstanding tasks and
> packed it up.
> 
> Start here:
> 
> https://www.vajhoej.dk/arne/opensource/vms/doc/tig/doc/
> 
> Download links:
> 
> https://www.vajhoej.dk/arne/opensource/vms/vmstig-bin-v0_1.zip
> https://www.vajhoej.dk/arne/opensource/vms/vmstig-client-v0_1.zip
> https://www.vajhoej.dk/arne/opensource/vms/vmstig-src-v0_1.zip

I have updated.

Despite the native languages on VMS being non-OO then it
bothered me that the client side API was really non-OO
(classes were used but without any data in the class
it is not much OO).

So I came up with a hack.

VMS code (C in this case):

struct ooctx
{
     int counter;
};

static int counter = 0;

long increment(struct ooctx *ctx)
{
     counter++;
     ctx->counter++;
     return 1;
}

long get(struct ooctx *ctx, long *c1, long *c2)
{
     *c1 = counter;
     *c2 = ctx->counter;
     return 1;
}

Silly example, but it should illustrate the difference
between a global variable and a client specific context.

XML to describe API:

<config>
     <image>demoo</image>
     <port>12350</port>
     <mt>false</mt>
     <oocontext>o</oocontext> <!-- <=============== this is the trick -->
     <server>
         <language>dk.vajhoej.vms.tig.server.JavaServerGen</language>
     </server>
     <client>
         <language>dk.vajhoej.vms.tig.client.JavaClientGen</language>
         <language>dk.vajhoej.vms.tig.client.CSharpClientGen</language>
         <language>dk.vajhoej.vms.tig.client.PyClientGen</language>
         <language>dk.vajhoej.vms.tig.client.CppClientGen</language>
     </client>
     <methods>
         <method>
             <name>increment</name>
             <args/>
         </method>
         <method>
             <name>get</name>
             <args>
                 <arg>
                     <name>c1</name>
                     <type>LongWord</type>
                     <pass>Reference</pass>
                     <use>Out</use>
                 </arg>
                 <arg>
                     <name>c2</name>
                     <type>LongWord</type>
                     <pass>Reference</pass>
                     <use>Out</use>
                 </arg>
             </args>
         </method>
     </methods>
</config>

And let us take client in Python.

First O.py for client access to context:

import struct

class O:
     def __init__(self, counter = 0):
         self.counter = counter
     def pack(self):
         return struct.pack('<l', self.counter)
     def unpack(self, blk):
         self.counter = struct.unpack('<l', blk)[0]

Test:

from sys import argv

from DemooClient import *

for i in range(3):
     cli = DemooClient(argv[1])
     for j in range(3):
         stat = cli.increment()
         stat, c1, c2 = cli.get()
         print('%d %d (%d)' % (c1, c2, cli.oocontext().counter))

Output:

C:\Code\VMS\tig\examples>python testo.py 192.168.68.40
1 1 (1)
2 2 (2)
3 3 (3)
4 1 (1)
5 2 (2)
6 3 (3)
7 1 (1)
8 2 (2)
9 3 (3)

If one is not interested in the context client side (private context
in OO world), then one can just specify the size of the context instead
of the type.

<oocontext>o</oocontext>

->

<oocontext>4</oocontext>

and drop O.py implementation and do not try to access context
from client.

Python client:

from sys import argv

from DemoqClient import *

for i in range(3):
     cli = DemoqClient(argv[1])
     for j in range(3):
         stat = cli.increment()
         stat, c1, c2 = cli.get()
         print('%d %d' % (c1, c2))

https://www.vajhoej.dk/arne/opensource/vms/vmstig-bin-v0_2.zip
https://www.vajhoej.dk/arne/opensource/vms/vmstig-client-v0_2.zip
https://www.vajhoej.dk/arne/opensource/vms/vmstig-src-v0_2.zip

Arne





More information about the Info-vax mailing list