Garuda ([Eagle] Package for Tcl) is part of the [Eagle] project. It is a stubs-enabled native package for Tcl that allows Eagle to be loaded and used by Tcl 8.4 or higher on Windows. While Garuda can be used as a generic conduit between Tcl and the .NET Framework, it was originally designed to be used with [Eagle]. '''When Garuda is used with [Eagle], ideally the binaries should be built from the same source checkout. As of Beta 33, this is a hard requirement.''' As of 2014-07-26 (i.e. pre-Beta 31), Garuda supports loading into [TclKit] or similar statically linked Tcl environment. In order for this to work, the following snippet '''must''' be evaluated '''prior''' to evaluating "package require Garuda": ====== namespace eval ::Garuda { variable methodFlags 0x40; # METHOD_PROTOCOL_V2 } ====== Now available via the ActiveState Teapot repository, [http://teapot.activestate.com/package/name/Garuda/ver/1.0/arch/win32-ix86/details%|%here%|%]. To install the Garuda package from there, the command '''teacup install Garuda''' can be used. [MHo] 2014-07-28: The ActiveState Teapot may not (and as of this writing does not) have the most recently released version of Garuda available. The best place to obtain it from is the official [Eagle] web site. ====== C:\Windows\system32>teacup install Garuda Resolving Garuda ... Not found in the archives. Note: Names are case-sensitive. Aborting installation, was not able to locate the requested entity. C:\Windows\system32>teacup install garuda Resolving garuda ... Not found in the archives. Note: Names are case-sensitive. Aborting installation, was not able to locate the requested entity. ====== JJM (2014-07-28): Here, it shows up as listed: ====== package Garuda 1.0 win32-ix86 ====== JJM (2014-07-28): The problem might be that you are trying for a 64-bit version, which ActiveState does not build? ---- JJM (2014-11-13): ActiveState now builds the 64-bit version of Garuda. The 64-bit ActiveState build is [http://teapot.activestate.com/package/name/Garuda/ver/1.0/arch/win32-x86_64/details%|%here%|%]. The 32-bit ActiveState build is [http://teapot.activestate.com/package/name/Garuda/ver/1.0/arch/win32-ix86/details%|%here%|%]. ---- From the README: The sources may be built from inside the Microsoft Visual Studio 2005 (or higher) integrated development environment. Alternatively, they may be built using the corresponding command line build environment. Installing this package requires Tcl 8.4 or higher. To install Garuda, copy the distribution files to a directory and make sure that directory is listed in the Tcl "auto_path" variable. ---- Loading and using this package requires Tcl 8.4 or higher and the latest release of Eagle. To load Garuda, execute the following Tcl command: ====== package require Garuda ====== By default, this will load and startup the CLR, setup the bridge to Eagle, and provide the package to the Tcl interpreter. After the package has been loaded, the [[garuda]] command can be used to query and control various aspects of the bridge between Eagle and Tcl. After the bridge between Eagle and Tcl has been setup, the [[eagle]] command can be used to evaluate Eagle scripts. ---- Here is an example of how to load Garuda in verbose mode: ====== # # This will load Garuda and start the CLR in verbose mode, showing # plenty of diagnostic output useful in troubleshooting. # namespace eval Garuda {set verbose true; set logCommand tclLog} package require Garuda ====== Here is an example of how to use a CLR class: ====== # # This will load Garuda and use it to print "Hello World" to the # console. # package require Garuda eagle [list object invoke System.Console WriteLine "Hello World"] ====== Here is a more complex example, using Tk and CLR classes together: ====== package require Tk package require Garuda wm withdraw . if {![info exists i]} then { set i 0 }; incr i set toplevel [toplevel .example$i] bind $toplevel {console show} set script { # # NOTE: This script can use any of the commands provided by # Eagle (e.g. [object invoke] to invoke .NET Framework # objects). # proc handleClickEvent { sender e } { if {[tcl ready]} then { msgBox [appendArgs "Tcl version is: " \ [tcl eval [tcl master] info patchlevel] \n \ "Eagle version is: " [info engine patchlevel]] About } else { msgBox "Tcl is not ready." About } } object load -import System.Windows.Forms interp alias {} msgBox {} object invoke MessageBox Show set form [object create -alias Form] $form Text WinForm; $form Show set button [object create -alias Button] $button Left [expr {([$form ClientSize.Width] - [$button Width]) / 2}] $button Top [expr {([$form ClientSize.Height] - [$button Height]) / 2}] $button Text "Click Here" $button add_Click handleClickEvent object invoke $form.Controls Add $button } set button [button $toplevel.run -text "Click Here" \ -command [list eagle $script]] pack $button -padx 20 -pady 20 -ipadx 10 -ipady 10 ====== Here are some examples of using the Garuda meta-command itself for introspection (i.e. [garuda]): ====== package require Garuda garuda clrappdomainid; # returns "1" garuda clrversion; # returns "v2.0.50727" or "v4.0.30319" garuda clrrunning; # returns "0" or "1" # # NOTE: In the following command output the zeros should be # replaced with the actual Fossil checkout hash and # date/time. Currently, the returned output will be # something like the following (but without any # line-breaks): # # Garuda 1.0 0000000000000000000000000000000000000000 # {0000-00-00 00:00:00 UTC} # garuda packageid # # WARNING: The [garuda dumpstate] sub-command is intended for # troubleshooting purposes only and the output may # vary wildly from release to release. Currently, # the returned output will be something like the # following (but without any line-breaks): # # packageMutex 0x01464140 hPackageModule 0x558D0000 # packageFileName {C:\path\to\Garuda.dll} lTclStubs 1 # hTclModule 0x55930000 pTclStubs 0x00000000 # pClrRuntimeHost 0x00061508 bClrStarted 1 # bBridgeStarted 1 # # The actual output from the "dumpstate" sub-command # will be a valid list (actually a dictionary). # garuda dumpstate ====== Here are some examples of using the Garuda meta-command itself for CLR control operations (i.e. [garuda]): ====== # # NOTE: This example disables the automatic starting of the CLR # and managed bridge, allowing full manual control. # namespace eval Garuda {set verbose true; set logCommand tclLog} namespace eval Garuda {set startClr false; set startBridge false} package require Garuda # # NOTE: This will attempt to start the CLR in the process. # garuda clrstart # # NOTE: This will attempt to setup the managed bridge, using the # current Tcl interpreter. # garuda startup # # NOTE: This will attempt to send a "control" signal to the managed # bridge using the current Tcl interpreter. # garuda control # # NOTE: This will attempt to execute the specified managed method # (which must conform to the method prototype "public static # int MethodName(string argument)"). # garuda clrexecute {C:\path\to\Eagle.dll} Eagle._Tests.Default TestMethod 1234 # # NOTE: This will attempt to remove the current Tcl interpreter from # the managed bridge. # garuda detach # # NOTE: This will attempt to shutdown the managed bridge using the # current Tcl interpreter. # garuda shutdown # # NOTE: This will attempt to stop and unload the CLR from the current # process. This action cannot be reversed without restarting # the process. # garuda clrstop ====== ---- [kap] 2015-02-04: Given a C# object 'foo' created as such, from the class 'Foo': ====== eagle {set foo [object create -alias Foo]} ====== The class 'Foo' has a method 'Bar' which returns a List. When invoked by Eagle as so: ====== eagle {$foo Bar} ====== The string 'System.Collections.Generic.List`1[System.String]' is printed. Is there a way to easily serialize the contents of this to a string, within Eagle, such that Tcl could easily work with it? Like a Tcl list of strings? ---- [MG] Is there any documentation on using Garuda anywhere beyond the small amount of info on this page? ---- [MHo] 2015-10-01 Tcl 8.6.4: ====== % package require Garuda ICLRRuntimeHost_ExecuteInDefaultAppDomain: failure (code 0x80070002). ICLRRuntimeHost_ExecuteInDefaultAppDomain: failure (code 0x80070002). ====== [JJM] 2015-10-01: Just tried the same thing here and it works fine. Do you have an "Eagle.dll" file next to your "Garuda.dll"? If you installed from the Teapot, you should. [MHo] Sorry, I had some old beta in my search path. After removing and doing a fresh '''teacup install Garuda''' the package require works... Thank you. <>Language|Tcl Implementations|Windows|Package