[plt-scheme] Re: plt-scheme digest, Vol 1 #308 - 5 msgs

From: Pedro Pinto (ppinto at cs.cmu.edu)
Date: Tue Mar 18 07:18:34 EST 2003

Chris,


> I planned to do this with Goo too but never got around to it. The idea
> was for my quick and dirty C# program to generate wrappers for the
> reflection libraries and then write Goo code that used these wrappers
> to create an FFI that allowed dynamic loading and executing of .NET
> assemblies.

I am not sure I understand what you mean. Are you suggesting the use of
reflection on a dynamic assembly to locate and invoke the target methods?
Something like this perhaps:


(load-dotnet "MyAssembly.DLL")

(define obj
    (make-dotnet "MyClass" arg1 arg2 ...))

(call-dotnet obj "MyMethod" arg ...)


Is this what you mean? I thought about this to. While I appreciate the
simplicity of not having to bother with compiling a wrapper, I abandoned the
idea because I assumed performance would be considerably worse and I thought
the syntax was very unnatural.

> I just noticed that the distribution I have on my website does not
> include the source to the C# program that generates the wrappers. I'll
> hunt it down and make it available.

tx.

Your marshaling code is strikingly similar to mine. I used the same storage
strategy for .NET objects (did you consider pinning the .NET pointers and
passing those instead? - I have yet to explore this)

> If you are interested in an example of how a particular method is
> handled let me know and I'll show you the generated code.

I could not find this kind of method in the .NET framework but I was
thinking about this:

class MyClass
{
   int MyBuilderMethod (ref MyClass c, ref int status)
   {                    ^^^            ^^^
        c = new MyClass();
        status = 1;
        return 0;
   }
}

My difficulty was how to map the passing of a reference by reference to
scheme. This could probably be faked when using a reference to a class but I
have no idea how to do it for primitive types.


-pp



Posted on the users mailing list.