Context.registerClass

Class registerClass(alias DClass, RegisterClassMode Mode = RegisterClassMode.UdaOnly)(string className = null) nothrow

Register a D class to a JSC Context.

If the Mode is RegisterClassMode.UdaOnly then a constructor must be marked with the @JsCtor attribute and all methods and properties which are to be exposed must be marked with the @JsExpose attribute.

The @JsName attribute is used to set the name (string) of a method or property. The @JsReadOnly attribute is used to mark a member variable property as read-only.

Parameters

DClassThe D class to register
ModeThe registration mode (defaults to RegisterClassMode.UdaOnly)
classNameClass name to use or empty/null to use D class name (default)

Returns

The registered Class (returns the existing instance if it was already registered)
javascriptcore.class_.Class registerClass(string name, javascriptcore.class_.Class parentClass, javascriptcore.types.ClassVTable vtable, glib.types.DestroyNotify destroyNotify = null) nothrow

Register a custom class in context using the given name. If the new class inherits from another #JSCClass, the parent should be passed as parent_class, otherwise null should be used. The optional vtable parameter allows to provide a custom implementation for handling the class, for example, to handle external properties not added to the prototype. When an instance of the #JSCClass is cleared in the context, destroy_notify is called with the instance as parameter.

Parameters

namethe class name
parentClassa #JSCClass or null
vtablean optional #JSCClassVTable or null
destroyNotifya destroy notifier for class instances

Returns

a #JSCClass