This project is read-only.

V8.NET Beta Release v1.3.0.16

Rating: No reviews yet
Downloads: 54
Change Set: 28993
Released: Aug 26, 2013
Updated: Aug 27, 2013 by jamesnw
Dev status: Beta Help Icon

Recommended Download

Application V8.NET Binaries (v1.3.0.16)
application, 22736K, uploaded Aug 26, 2013 - 54 downloads

Release Notes

Ladies, gentleman, and others - the DLR integration and object binding is here! This release comes with new methods for binding types and object instances with the JavaScript environment. See the console source (program.cs) for a good example (the "Console" static type is bound to JavaScript now).

UPDATE: I changed the in-script generic invocation signature. I didn't like how the generic method names looked, so I created a shorthand instead: {GenericMethodName}${# of types}({...types...})(); so for example, "Enumerable.Max$1(Int32)()". Also, you can call "dump()" on any bound CLR method to see the available signatures. 8)

Completed updates included in this release (some carried over):
  • Very easy to deal with accessing nested properties/objects on the managed side (DLR).
  • Added methods to make it easier to bind existing .NET object instances and types to the V8 JS environment.
  • Created a new function '{V8Engine}.LoadScript(string scriptFile)' to make it more convenient to load JS files.
  • Breaking change 1: Some handle property names were refactored, and some added so that handles can have full access to the native objects without having to create V8NativeObject instances (too much extra overhead I wanted to avoid). In fact, V8NativeObject now wraps a Handle and redirects dynamic requests to it, and both Handle and InternalHandle implement the same methods for working on the native JavaScript objects (so that's all you need to access/update in-script objects!). This was done to allow dynamic property access on the handles without having to create another object to do it. This change slightly affects the members and functionality of the V8NativeObject - but mostly behind the scenes. This allows accessing objects easily using a chain of property names, such as '((dynamic){someHandle}).a.b.c.d...' or '{object}.AsDynamic.a.b.c.d...'.
  • Breaking change 2: V8NativeObject will now have a generic object (V8NativeObject<T>) version to allow injecting your own objects into it instead of deriving from it (deriving is recommended however). I wanted to get rid of the internal "_ObjectInfo' objects that were holding member data that really should be in the object itself. This will mainly affect only those who need to implement the interface (IV8NativeObject) instead of inheriting from V8NativeObject. Under the new system, when the "Initialize()" virtual method is called, you just cache a pointer to the 'V8NativeObject' instance wrapping your object and use that instead.
  • Refactoring the files to better support the coming Mono port. 8) Special thanks to rryk for getting the ball rolling. To this end, I'll also be converting the source repository to Git! :) You're welcome.
  • Breaking change: (already!? yes. ;) ) After some retrospecting, I think it's better to update an ObjectTemplate to spit out objects for a given types more quickly than having the type binder set accessors for each new bound instance. This is a small change, and simply requires to call "RegisterType()" on the engine instance instead.
  • Added "Prototype" to InternalHandle and ObjectHandle.
  • Added 'SetProperty()' and 'SetAccessor()' to 'ObjectTemplate' to call the corresponding "Set()" and "SetAccessor()" functions on the native ObjectTemplate instance. This allows setting up your own properties on the template without needing to implement a custom 'V8ManagedObject' instance.
  • Static types are now supported when binding CLR objects to JavaScript.
  • Spaces removed from paths and file names to better support cross-platform compatibility with IDEs such as MonoDevelop. The test project was also removed (was never used anyhow - testing is done in script form via V8).
  • More Bug fixes.

Some quick start notes:
  • Use "{V8engine}.RegisterType()" to register your types in V8.NET (this has nothing to do with JavaScript - this only creates a cached binder for the type). This is not required, but does give you more control.
  • There's two new "SetProperty()" methods: one for binding an object instance, and another to store a type as a function property (to use with "new").
  • There are two attributes to use on your custom objects: 'ScriptObject' and 'ScriptMember'.

Generic Types:
Here is a contrived example of calling and passing CLR methods/types ...
  • r = Enumerable.Range(1,Int32('10'));
Output: (System.Linq.Enumerable+<RangeIterator>db8)

1. The string '10' is strong-typed (and converted) to Int32 for the specified parameter.
2. An iterator object gets auto-bound and returned.
  • a = CLRString.Join$1(Int32)(', ', r);
Output: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

1. "Joint$1" is a GENERIC signature that takes one type, and since types are not inferred, calling the method only returns another strong-typed function to call. The first call above returns a "typed" generic function, and the second invokes it.
2. The returned function is called with a string, and the iterater we just created.

Cool tip: If you call an overloaded method and get an error, such as "Enumerable.Min()", the system will show an error, but dump the whole overload list. ;) In fact, ANY error calling a method, include generics, such as "CLRString.Join$1()()", will give method signature details. 8) This is a big help in testing/debugging.

Known limitation: Extension methods are not applied to in-script objects. For now, you'll have to use the methods directly on the static type - such as those on the "Enumerable" static type.

Reviews for this release

No reviews yet for this release.