Exposing CLR Types to ECMAScripts

Hi,

I can see that the ScriptEngine exposes a method ExposeType, and the documentation explains what is for. But how the script can create a new instance of the exposed type? and how the script can access the static methods of the exposed type?
Would you be so kind and give an example of that?

Hello

Unfortunately there was a bug (logged as 49206) in handling types exposed via ‘ExposeType’ method.
This bug was fixed and new Script for .NET sources are available at
http://code.remobjects.com/p/roscript2/source/tree/master/

To expose some CLR type you need to call ExposeType with 2 parameters - type itself and name that will be used in the Script to call this type (by default type name is used). After this this type can be instantiated and accessed via code like (assuming that JSType is a name (or alias) of exposed CLR type)

  var t = new JSType();
  t.SomeMethod(); // Accessing instance method
  JSType.SomeStaticMethod(); // Accessing static method

Hope this helps

Thank you tons, it is

since I don’t have any pascal compiler installed, I have to wait for the binaries

You can get the free Oxygene command lime compiler at http://remobjects.com/free.

New Script for .NET version is available at http://code.remobjects.com/p/roscript2/downloads/