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

Wednesday, May 22, 2002

And finally today, on Goo .NET, look at the genproxies.bat file in goo/c/g2c for examples of how to generate wrappers for .NET framework classes. This batch file generates a number of the ones used in the examples posted previously. Once generated, edit grt.h to include the generated .h file and run goodotnet.exe. Evaluate the following to generate the Goo C code:

(use eval/g2c)
(g2c-goo)

Now you can build the system by running build.bat. You can then use the code from Goo. Note how slow and painful this approach is. Also note that I've already generated wrappers files for loading Assemblies, Types, etc. You should be able to create Goo code that uses reflection to generate Goo wrappers that use the reflection API. Then you wouldn't need to rebuild using the 'GenProxies' approach I've taken. Something for someone to work on if interested...


12:48:46 AM      

Although there is a 'dotnet-start-thread' function available, don't use it as it will usually crash Goo .NET. This is because the current incarnation of Goo is not thread safe. An example of code that uses it is:

(dotnet-start-thread 
  (fun () (system-windows-forms-messagebox-show-string "Hello World!")))

12:44:41 AM      

Here's another Goo .NET test. Evaluating the following forms demonstates how to download a web page using the .NET class framework:
(use double/dotnet/base)
(use double/dotnet/system_net_webrequest)
(use double/dotnet/system_net_httpwebrequest)
(use double/dotnet/system_net_webproxy)
(use double/dotnet/system_net_credentialcache)
(use double/dotnet/system_net_webresponse)
(use double/dotnet/system_net_httpwebresponse)
(use double/dotnet/system_io_stream)
(use double/dotnet/system_text_encoding)
(dv request (system-net-webrequest-create-string "../../index.html"))
(dv response (system-net-webrequest-getresponse request))
(dv stream (system-net-webresponse-getresponsestream response))
(dv buf (fab  8192))
(fill buf #space)
(dv count (system-io-stream-read-byteaa-int32-int32 stream buf 0 (len buf)))
(dv s (as  (sub buf 0 count)))
(msg out "%s\n" s)
(system-io-stream-close stream)

12:43:05 AM      

Want to know if Goo .NET is working? Try this:

(use double/dotnet/system_windows_forms_messagebox)
(system-windows-forms-messagebox-show-string "Hello World!")

12:37:40 AM      

© 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.