Function xsIsInstanceOf
Tests whether an instance has a particular prototype, directly or indirectly (that is, one or more levels up in the prototype hierarchy).
bool xsIsInstanceOf
(
scope xs .bindings .xsMachineRecord* the,
const(xs .bindings .xsSlotRecord) instance,
const(xs .bindings .xsSlotRecord) prototype
);
The xsIsInstanceOf
macro has no equivalent in ECMAScript; scripts test instances through constructors rather than directly through prototypes. A constructor is a function that has a prototype property that is used to test instances with isPrototypeOf
.
Examples
In ECMAScript:
if (Object .prototype .isPrototypeOf(this)) return new Object();
In D:
if (machine .xsIsInstanceOf(xsThis, xsObjectPrototype)) xsResult = machine .xsNewObject();
Returns
true
if the instance has the prototype, false
otherwise.
Parameters
Name | Description |
---|---|
the | A machine |
instance | A reference to the instance to test |
prototype | A reference to the prototype to test |