The main function of the wrapper layer is to convert the process of queuing
into a function call with a callback method as the argument.  There are some
convenient methods that wrap around the normal tcl.lang.Interp's methods.
The convenient methods are secondary.  Take your example:

synchronized (SOMETHING) {
  TclObject one = interp.getVar("one");
  TclObject two = interp.getVar("two");
}

Using the terminology of the wrapper layer in the paper, I can write
something like this:

TclInterpResult result;
TclInterp       wrappedInterp = new
TclInterp(the_real_tcl_lang_Interp_object);

result = wrappedInterp.executeCommand(
    new MyCommand implements TclInterpCommand {
        public boolean executeCommand (TclInterpEvent event, int flags,
Object userData) {
            try {
                // event.getInterp() returns the real tcl.lang.Interp object
                TclObject one = event.getInterp().getVar("one");
                TclObject two = event.getInterp().getVar("two");
                ...

            } catch (TclException e) {
                // handle error
            }
            return true;
       }
    }, null);

It is the same as the inner class method, minus the:

        interp.getNotifier().queueEvent(...);
and     getNotifier().sync();

For non-blocking call, use "wrappedInterp.asyncExecuteCommand(...)".

-- Jiang Wu
   [EMAIL PROTECTED]      
                
-----Original Message-----
From: Mo DeJong [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 15, 2000 2:20 PM
To: Scott Redman
Cc: [EMAIL PROTECTED]
Subject: [Tcl Java] Re: [Tcl Java] Thread question in TclBlend


On Mon, 15 May 2000, Scott Redman wrote:

> I was reading Jiang Wu's paper on using Java and Tcl.  I have
> a question for everyone:

Jiang's Wrapper Layer is a neat idea, but there are a couple of
problems with it. You can't really wrap individual Interp
calls because often you need to call other methods like
ReflectObject.get() or TclInteger.get(). Also, looking at
code like:

TclObject one = WrappedInterp.getVar("one");
TclObject two = WrappedInterp.getVar("two");

A user might expect that the value of two would be queried
right after the value for one, but that may not be true.
If getting the value of one calls some trace proc, then
it might do a bunch of stuff and put events into the event
loop before the wrapped call to get "Two" happens. What
is really needed is to wrap a series of generic API
calls in a block of code like so:

synchronized (SOMETHING) {
  TclObject one = interp.getVar("one");
  TclObject two = interp.getVar("two");
}

I suggested that using an inner class would be the way
to go, but that approach is still a little bit complex.
(see the current src/jacl/tcl/lang/Shell.java for an example).

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to