nrk (owner)

Revisions

gist: 105928 Download_button fork
public
Public Clone URL: git://gist.github.com/105928.git
Embed All Files: show embed
repl_session.txt #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
IronRuby 0.4.0.0 on .NET 2.0.50727.4918
Copyright (c) Microsoft Corporation. All rights reserved.
 
>>> load_assembly "test"
=> true
>>> source = open("data.xml")
=> #<File:data.xml>
>>> Test::Nrk.read(source)
C:\Development\ironruby\working-nrk\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:87:in `Bind': The result type 'System.Object' of the binder 'read(C,0)' is not compatible with the result type 'IronRuby.Builtins.MutableString' expected by the call site. (TypeError)
        from C:\Development\ironruby\working-nrk\ndp\fx\src\Core\Microsoft\Scripting\Actions\C
allSiteBinder.cs:79:in `BindDelegate'
        from :0:in `read'
        from :0
 
test.cs #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Runtime.CompilerServices;
using IronRuby.Builtins;
using IronRuby.Runtime;
using IronRuby.Runtime.Calls;
using Microsoft.Scripting;
using Microsoft.Scripting.Runtime;
 
namespace Test {
    using RubyIOReadCallSite = CallSite<Func<CallSite, RubyIO, MutableString>>;
 
[RubyModule("Nrk")]
    public static class Nrk {
[RubyMethod("read")]
        public static MutableString Read(RubyIO/*!*/ source) {
            RubyCallSignature callSignature = RubyCallSignature.Simple(0);
            RubyCallAction callAction = RubyCallAction.MakeShared("read", callSignature);
            var readCallSite = RubyIOReadCallSite.Create(callAction);
            return readCallSite.Target(readCallSite, source);
        }
    }
}