fougerite/Fougerite — pull request #34 by mikecrews (2014-07-21 15:38:40+00:00)
Title: Jint 2.2.0 merge PR

I have integrated Jint 2.2.0 with Fougerite, replacing the old Jint 0.9.
I have added Util.TryFindReturnType method, which returns a type directly.
Jint2 doesn't support out vars in Javascript, so Util.TryFindType can't be used from scripts.
In Jint2, the System namespace is available automatically. Other namespace are not.
I configured CLR access to Assembly-CSharp, uLink and UnityEngine.
To use these namespaces in a script, use the new global method importNamespace(string name)
var Rust = importNamespace("Rust");
Rust.Notice.Inventory(pp, txt);

Use .length for all arrays, Javascript, or C#.
Use .toString() for Javascript objects, .ToString() for C#. Most of the time, this happens automatically as it does in Javascript. But sometimes a C# object won't autocast to a string when used in string context. Adding .ToString() fixes that.

I am not sure if it is because of our exception catching throughout Fougerite, but I am unable to catch C# exceptions in Javascript. Some Javascript errors produce no error or exception at all. The script simply stops at that point. Needing .ToString is one of these times. Util.Log("the type is " + sometype) is an example, if sometype is a var holding a C# type. That call is likely to fail silently. Util.Log("the type is " + sometype.ToString()) succeeds and prints the type name.

Other known issues:
World.Time throws an exception in my timer callback.
System.NullReferenceException: Object reference not set to an instance of an object
at Fougerite.World.get_Time () [0x00000] in :0

I build with Xamarin 5 for .Net 3.5 and the mono compiler and mono runtime. I need fewer dependencies in References as a result.