Using CLR Types as a Native IronJS Experience via the DLR

42 views
Skip to first unread message

Kevin Swiber

unread,
Aug 12, 2011, 8:33:16 PM8/12/11
to IronJS
Howdy.

Is there a plan to directly support CLR types in IronJS?

For example...

var d = new System.Collections.Generic.Dictionary.of(String, Number);
d["Hello"] = 1;
d["Hi"] = 2;

Taking a quick peek, it looks like there's a bit of complexity with type interop/resolution via the DLR.

Is this even on the roadmap for IronJS?

--
Kevin Swiber
Projects: https://github.com/kevinswiber
Twitter: @kevinswiber

John Gietzen

unread,
Aug 13, 2011, 12:31:43 AM8/13/11
to iro...@googlegroups.com
It is on the roadmap, yes.

Kevin Swiber

unread,
Aug 13, 2011, 8:45:22 AM8/13/11
to iro...@googlegroups.com
Awesome. Is it under active development? What's the approach you'd take given the current design?

In my light experimentation, I've taken mscorlib and walked the namespace tree to create a new CommonObject for each leaf. I assigned the root to the Globals object on the context.  That's the easy part. The types would have to be wrapped in dynamic magic.

Exposing constructors, handling properties, and working with the dynamic/meta objects are what I'm still researching. Any insight into your approach would be beneficial for my learning experience.

Thanks!

Steve_H

unread,
Aug 16, 2011, 9:49:28 AM8/16/11
to IronJS

I think the best proof of concept that IronJS is seamlessly integrated
into the CLR from a user's perspective is to have it as a development
language option in the SharpDevelop IDE. Hey, since developers have
already built Windows Form Designers for IronPython and IronRuby
there, why not IronJS? That's how you can get IronJS out there and
in the hands of a lot more interested developers.

Plus, no sane person wants to type out in Javascript full pathnames to
a CLR type. IronPython and IronRuby don't do it and IronJS shouldn't
do it either.

Tim

unread,
Sep 20, 2011, 10:59:40 PM9/20/11
to IronJS
So what is the recommended approach for exposing an existing CLR
object to IronJS today?
Do I need to create CommonObject wrappers as Kevin alludes too?

John Gietzen

unread,
Sep 21, 2011, 8:17:10 AM9/21/11
to Tim, IronJS
At this point, yes you need to build a CommonObject wrapper. JavaScript
includes the idea of "enumerable" members, and this is how we support
them.

Sent from my Windows Phone From: Tim
Sent: Tuesday, September 20, 2011 9:59 PM
To: IronJS
Subject: [IronJS:41] Re: Using CLR Types as a Native IronJS Experience
via the DLR

Reply all
Reply to author
Forward
0 new messages