Updated: 11/5/2005; 6:01:57 PM.
Chris Double's Radio Weblog
        

Saturday, May 04, 2002

I'm behind the times, having just enabled support for comments...


8:47:50 PM      

[ Goo .NET support has been updated. See the latest for details ].

I've updated the .NET support for the Goo Programming Language. Download the goodotnet2.zip file and place the files in the relevant directories from the original Goo distribution.

In the c/g2c directory, run the build.bat command. This will compile all the Goo sources as a .NET application and create a goodotnet.exe file. Running this will give you a Goo read-eval-print system running under .NET that allows you to call the .NET framework libraries.

There are some caveats. The first is that this is only initial support. Lots more still needs to be done. An update over the previous release is that the garbage collector works and there are examples of calling .NET libraries. Much more still needs to be done to make it stable and usable.

Examples of calling .NET classes are the support for using Assembly, Type, Activator and MethodInfo. Using these you can load and call .NET assemblies from the read-eval-print loop. For example:

(use double/dotnet/system_reflection_assembly)
(use double/dotnet/system_reflection_methodinfo)
(use double/dotnet/system_type)
(use double/dotnet/system_activator)

(dv a (system_reflection_assembly-load-assemblystring "test"))
(dv type (system_reflection_assembly-gettype-name a "MyClass"))
(dv meth (system_type-getmethod-name type "doit"))
(dv obj (system_activator-createinstance-type type))
(system_reflection_methodinfo-invoke-obj-parameters meth obj (list "test " "one"))

This uses a Test.dll written in Managed C++ I included in the distribution where the doit method just concatenates the two strings passed and prints the result to the console.

The support for these .NET libraries was created automatically by a C# program I wrote that used reflection to generate the Goo and C++ interfaces. The generated code is very ugly as you can see above but it works. Two approaches I may take from here:

  1. Work on the automatic code generation to produce better and easier to use code.
  2. Write some Goo routines that use the ugly generated code above to allow generating nice Goo code.

Basically the generated code takes the method names and appends the parameter names to it. This was to allow for overloaded names. The result is long, ugly names though.

I'm very open to feedback on better ways of doing things, especially in the area of the generated code. I will release the C# program that generates the interfaces when I've tidied it up and improved it a bit.

When calling .NET functions that return Objects, they are represented in Goo as type <int>. This is an index into an array held on the C++ side that holds onto the object pointer to prevent garbage collection. Note that I've no facility to remove this held object pointer yet - coming in the next release. I'll probably also change the use of <int> to hold the result to an actual Goo type to allow better method dispatch.


8:19:59 PM      

© Copyright 2005 Chris Double.
 
May 2002
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Apr   Jun



Click here to visit the Radio UserLand website.

Listed on BlogShares

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.