Problem using JsObject

Jan 17, 2011 at 7:35 PM

Hi, I'm just beginning to use Jint and have a question to you. I want to create a dynamic object that can be used just like a native javascript object in scripts. But the effect is unexpected for me:

 

 

var eng = new JintEngine();
            eng.DisableSecurity();
            Jint.Native.JsObject job = new Native.JsObject();
            job["ala"] = new Native.JsString("ma kota", null);
            job["kot"] = new Native.JsNumber(399, null);
            eng.SetParameter("cos", job);
            var ret = eng.Run("return cos.kot + cos.kot;");
            Console.WriteLine("cos: {0}", ret);

 

The output is "cos: 0" - shouldn't the return value be 798? 

Next test 

 ret = eng.Run("return cos.ala;");
 Console.WriteLine("cos: {0}", ret);

Prints 'cos: ala' - ret is a string "ala" but IMHO should be "ma kota"

Can you help me understand what's happening here? And how should I go about passing some pre-initialized dynamic object to javascript that can be then modified by the script and returned back? 

Best regards

RG