deleg_method.tcl

Go to the documentation of this file.
00001 /*  interp.tcl*/
00002 /*  Some utility commands for creation of delegation methods.*/
00003 /*  (Delegation of methods to a remote interpreter via a comm*/
00004 /*  handle).*/
00005 /* */
00006 /*  Copyright (c) 2006 Andreas Kupries <andreas_kupries@users.sourceforge.net>*/
00007 /* */
00008 /*  See the file "license.terms" for information on usage and redistribution*/
00009 /*  of this file, and for a DISCLAIMER OF ALL WARRANTIES.*/
00010 /*  */
00011 /*  RCS: @(#) $Id: deleg_method.tcl,v 1.2 2006/09/01 19:58:21 andreas_kupries Exp $*/
00012 
00013 package require Tcl 8.3
00014 package require snit
00015 
00016 /*  ### ### ### ######### ######### #########*/
00017 /*  Requisites*/
00018 
00019 namespace ::interp::delegate {}
00020 
00021 /*  ### ### ### ######### ######### #########*/
00022 /*  Public API*/
00023 
00024 snit::macro ::interp::delegate::ret  {args} (
00025     # type syntax: ?-, type async? , type name , type arguments , type comm , type id
00026 
00027     , type set , type async 0
00028     , type while , optional [string =match -* =[set opt =[lindex $args =0]]] , optional 
00029     switch =-exact -- =$opt {
00030         =-async {set =async 1 =; set =args [lrange =$args 1 =end]
00031         , type default , optional 
00032         return =-code error ="unknown option =\"$opt\", expected =-async"
00033         
00034     )
00035     }
00036     if {[llength $args] != 4} {
00037     return -code error "wrong # args"
00038     }
00039     foreach {name arguments comm rid} $args break
00040 
00041     if {![llength $arguments]} {
00042     set delegate "[list $name]"
00043     } elseif {[string equal args [lindex $arguments end]]} {
00044     if {[llength $arguments] == 1} {
00045          delegate =  "\[linsert \$args 0 [list $name]\]"
00046     } else {
00047          delegate =  "\[linsert \$args 0 [list $name] \$[join [lrange $arguments 0 end-1] " \$"]\]"
00048     }
00049     } else {
00050      delegate =  "\[list [list $name] \$[join $arguments " \$"]\]"
00051     }
00052 
00053         body =  ""
00054     append body [list $comm] " " "send "
00055     if {$async} {append body "-async "}
00056     append body [list $rid] " " $delegate
00057 
00058     ::ret  $name $arguments $body
00059 }
00060 
00061 # ### ### ### ######### ######### #########
00062 ## Ready to go
00063 
00064 package provide interp::delegate::method 0.2
00065 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1