Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve stringification, allow some access to events and operators
  • Loading branch information
sorear committed Sep 10, 2011
1 parent 4875297 commit 0f884ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/CLRBackend.cs
Expand Up @@ -4966,7 +4966,7 @@ public class DownCallAcceptor: CrossDomainReceiver {
if (!b.v.Fetch().mo.mro_raw_Bool.Get(b.v)) {
Variable pl = Kernel.RunInferior(
r.Fetch().InvokeMethod(Kernel.GetInferiorRoot(),
"perl", new Variable[] { r }, null));
"gist", new Variable[] { r }, null));
Console.WriteLine(pl.Fetch().mo.mro_raw_Str.Get(pl));
}
} catch (Exception ex) {
Expand Down
24 changes: 22 additions & 2 deletions lib/NieczaCLR.cs
Expand Up @@ -491,6 +491,13 @@ public class CLRWrapperProvider {
return th.caller;
}

static Frame Str_handler(Frame th) {
P6any ro = ((Variable)th.lex0).Fetch();
object o = Kernel.UnboxAny<object>(ro);
th.caller.resultSlot = Kernel.BoxAnyMO(o == null ? ro.mo.name : o.ToString(), Kernel.StrMO);
return th.caller;
}

static STable NewWrapper(Type t) {
if (CLROpts.Debug)
Console.WriteLine("Setting up wrapper for {0}", t.FullName);
Expand All @@ -513,7 +520,9 @@ public class CLRWrapperProvider {
BindingFlags.Static | BindingFlags.Instance)) {
if (CLROpts.Debug)
Console.WriteLine("Checking method : {0}", mi);
if (mi.GetBaseDefinition().DeclaringType == t && !mi.IsSpecialName)
if (mi.IsSpecialName && (Utils.StartsWithInvariant(mi.Name, "set_") || Utils.StartsWithInvariant(mi.Name, "get_")))
continue; // ignore property accessors
if (mi.GetBaseDefinition().DeclaringType == t)
needNewWrapper.Add(mi.Name);
MultiAdd(allMembers, mi.Name, mi, mi.GetParameters());
}
Expand Down Expand Up @@ -568,6 +577,14 @@ public class CLRWrapperProvider {
};
si.sig_r = new object[] { "self" };
m.AddMethod(0, "unmarshal", Kernel.MakeSub(si, null));

si = new SubInfo("KERNEL Str", Str_handler);
si.sig_i = new int[] {
SubInfo.SIG_F_RWTRANS | SubInfo.SIG_F_POSITIONAL, 0, 0,
};
si.sig_r = new object[] { "self" };
m.AddMethod(0, "Str", Kernel.MakeSub(si, null));
m.AddMethod(0, "gist", Kernel.MakeSub(si, null));
}

foreach (string n in needNewWrapper) {
Expand All @@ -576,7 +593,10 @@ public class CLRWrapperProvider {
DynBlockDelegate method = BindGroup(siname, allMembers[n]);
if (CLROpts.Debug)
Console.WriteLine("Installing {0}", siname);
m.AddMethod(0, n, Kernel.MakeSub(new SubInfo(siname, method), null));
P6any sub = Kernel.MakeSub(new SubInfo(siname, method), null);
m.AddMethod(0, n, sub);
if (n == "Invoke" && typeof(Delegate).IsAssignableFrom(t))
m.AddMethod(0, "postcircumfix:<( )>", sub);
}

m.Invalidate();
Expand Down

0 comments on commit 0f884ca

Please sign in to comment.