[Tickets] [Orxonox] #336: Remove Tcl library from media

Orxonox trac at orxonox.net
Sun Jul 19 03:42:45 CEST 2009


#336: Remove Tcl library from media
--------------------------+-------------------------------------------------
 Reporter:  landauf       |        Owner:  landauf                        
     Type:  enhancement   |       Status:  new                            
 Priority:  high          |    Milestone:  Version 0.2 Codename: Bellatrix
Component:  ScriptEngine  |      Version:  0.2.0                          
 Severity:  critical      |   Resolution:                                 
 Keywords:  tcl           |  
--------------------------+-------------------------------------------------
Old description:

> Tcl comes with a large library of Tcl files providing several features,
> most of them being crucial for the common use of the language (especially
> since Tcl doesn't know any keywords, just functions). Usually those files
> come together with the Tcl library and are installed somewhere on the
> system (there's a path pointing to this location which is known inside
> Tcl and can also be read and manipulated by the user when creating
> language extensions - this might be useful for future changes like #314).
>
> Now let me briefly introduce the concept of the console command execution
> in Orxonox:
>  1. It starts with the user's input (containing Orxonox and/or Tcl
> commands)
>  1. This is sent to a Tcl interpreter (to parse the Tcl commands)
>  1. Every unknown command is assumed to be an Orxonox command and is sent
> back to the [wiki:CommandExecutor Command Executor] in Orxonox (it could
> also be an unknown or misspelled Tcl command, but that doesn't matter)
>  1. The Orxonox command is executed by the Command Executor (if it really
> was an Orxonox command - otherwise an error is shown)
>
> To achieve this, we manipulate the
> [http://www.tcl.tk/man/tcl8.4/TclCmd/unknown.htm unknown] function of
> Tcl. This function gets called automatically if someone tries to execute
> an unknown command in Tcl (language feature). Usually this function would
> display an error, but we change the function to send the command back to
> the Command Executor instead.
>
> The unknown function is defined in "init.tcl" - a file that belongs to
> the Tcl library. And because of this change, we currently have to add the
> whole Tcl library to our media repository. And even worse, those files
> change with every release of Tcl and have to be updated.
>
> Therefore we should try to use the standard Tcl library and manipulate
> the unknown function in Orxonox after the Tcl interpreter was loaded,
> instead of providing our own version. Unfortunately this isn't that easy,
> because the 1-line-change in init.tcl looks somehow like this:
> {{{
>    proc unknown args {
>        ...
>        ... (almost 200 lines of code)
>        ...
> -      return -code error "invalid command name \"$name\""
> +      return [query $args]
>    }
> }}}
> Maybe we can catch the returned error code and then send the query to
> Orxonox, but there are other locations in the unknown function which
> return also an error (because the whole unknown function is basically
> just one big error handler).
>
> Task: Find a clean and fast way to send unknown commands back to Orxonox
> without manipulating init.tcl. After you succeeded, let Tcl load the
> standard library files instead of our own version. Change the Tcl library
> path so Tcl will still find our own scripts and packets (see also #314).

New description:

 Tcl comes with a large library of Tcl files providing several features,
 most of them being crucial for the common use of the language (especially
 since Tcl doesn't know any keywords, just functions). Usually those files
 come together with the Tcl library and are installed somewhere on the
 system (there's a path pointing to this location which is known inside Tcl
 and can also be read and manipulated by the user when creating language
 extensions - this might be useful for future changes like #314).

 Now let me briefly introduce the concept of the console command execution
 in Orxonox:
  1. It starts with the user's input (containing Orxonox and/or Tcl
 commands)
  1. This is sent to a Tcl interpreter (to parse the Tcl commands)
  1. Every unknown command is assumed to be an Orxonox command and is sent
 back to the [wiki:CommandExecutor Command Executor] in Orxonox (it could
 also be an unknown or misspelled Tcl command, but that doesn't matter)
  1. The Orxonox command is executed by the Command Executor (if it really
 was an Orxonox command - otherwise an error is shown)

 To achieve this, we manipulate the
 [http://www.tcl.tk/man/tcl8.4/TclCmd/unknown.htm unknown] function of Tcl.
 This function gets called automatically if someone tries to execute an
 unknown command in Tcl (language feature). Usually this function would
 display an error, but we change the function to send the command back to
 the Command Executor instead.

 The unknown function is defined in "init.tcl" - a file that belongs to the
 Tcl library. And because of this change, we currently have to add the
 whole Tcl library to our media repository. And even worse, those files
 change with every release of Tcl and have to be updated.

 Therefore we should try to use the standard Tcl library and manipulate the
 unknown function in Orxonox after the Tcl interpreter was loaded, instead
 of providing our own version. Unfortunately this isn't that easy, because
 the change in init.tcl looks more or less like this:
 {{{
    proc unknown args {
        ...
        ... (almost 200 lines of code)
        ...
 -      return -code error "invalid command name \"$name\""
 +      return [query $args]
    }
 }}}
 Maybe we can catch the returned error code and then send the query to
 Orxonox, but there are other locations in the unknown function which
 return also an error (because the whole unknown function is basically just
 one big error handler).

 Task: Find a clean and fast way to send unknown commands back to Orxonox
 without manipulating init.tcl. After you succeeded, let Tcl load the
 standard library files instead of our own version. Change the Tcl library
 path so Tcl will still find our own scripts and packets (see also #314).

-- 
Ticket URL: <http://www.orxonox.net/ticket/336#comment:1>
Orxonox <http://www.orxonox.net>
Orxonox Open Source game


More information about the Tickets mailing list