IJsAdapter<TValue> Interface
The primitives of a JavaScript engine used by the WebIDL bindings (WebIdlAgent<TAdapter, TValue>). An engine exposes the DOM by implementing this interface with a struct: the bindings are generic over the adapter (where TAdapter : struct, IJsAdapter<TValue>), so the JIT specializes them for each engine (no boxing, no interface dispatch).
public interface IJsAdapter<TValue> where TValue : classType parameters
TValue- The type of the JavaScript values of the engine (e.g.
objectfor Meziantou.Framework.JavaScriptEngine).
Remarks
The operations that can run JavaScript code (IJsAdapter<TValue>.ToNumber, IJsAdapter<TValue>.Get, IJsAdapter<TValue>.Call...) throw the exceptions of the engine; IJsAdapter<TValue>.TryGetThrownValue converts them back to JavaScript values.
Realms are represented by opaque objects (IJsAdapter<TValue>.CurrentRealm). The objects and functions created by the adapter belong to the current realm: the bindings use IJsAdapter<TValue>.RunInRealm to create them in the realm of a window.
Identity: the bindings compare the JavaScript objects by reference and cache data per object (the wrappers of the callbacks, the custom element constructors...), so the adapter must return the same TValue instance for the same JavaScript object. TValue may be Object (e.g. when the values of the engine are .NET strings and numbers).
Versioning: new primitives are added to this interface as default interface members implemented with the existing primitives, so that the existing adapters keep compiling; an engine overrides them for performance.
Properties
| Name | Description |
|---|---|
| CurrentRealm | Gets the realm of the running execution context. |
| Null | Gets the null value. |
| Undefined | Gets the undefined value. |
CurrentRealm
Null
Gets the null value.
TValue Null { get; }Property value
TValue
Undefined
Gets the undefined value.
TValue Undefined { get; }Property value
TValue
Methods
| Name | Description |
|---|---|
| AsBoolean(TValue) | Returns the value of a boolean. |
| AsDate(TValue) | Returns the time value of a Date object (milliseconds since the Unix epoch, or NaN). |
| AsNumber(TValue) | Returns the value of a number. |
| AsString(TValue) | Returns the value of a string. |
| Call(TValue, TValue, ReadOnlySpan<TValue>) | [[Call]] (https://tc39.es/ecma262/#sec-call). |
| Construct(TValue, ReadOnlySpan<TValue>, TValue) | [[Construct]] (https://tc39.es/ecma262/#sec-construct). |
| CreateArray(ReadOnlySpan<TValue>) | Creates an array in the current realm. |
| CreateArrayBuffer(ReadOnlySpan<byte>) | Creates an ArrayBuffer containing a copy of bytes in the current realm. The default implementation constructs it with the ArrayBuffer and Uint8Array constructors of the global object. |
| CreateArrayBufferView(JsBufferKind, TValue, int, int) | Creates a typed array or a DataView (kind) of length elements viewing buffer from byteOffset, in the current realm. The default implementation calls the constructor of the global object. |
| CreateArrayBufferWithData(byte[], string) | Creates an ArrayBuffer in the current realm whose data block is data (the bytes are shared, not copied), and whose [[ArrayBufferDetachKey]] is detachKey: it cannot be transferred or detached by scripts (e.g. the buffer of a WebAssembly.Memory). Returns null when the engine does not support it. The default implementation returns null. |
| CreateConstructor(string, int, JsHostConstructor<TValue>) | Creates a built-in function object that is a constructor in the current realm (e.g. an interface object, https://webidl.spec.whatwg.org/#interface-object): its name and length properties are set, it has no prototype property, and Function.prototype.toString returns its NativeFunction representation (function name() { [native code] }). [[Call]] and [[Construct]] call constructor; NewTarget is undefined for [[Call]]. The default implementation returns a Proxy of a script function. |
| CreateCrossOriginPlatformObject(TValue, object, IJsCrossOriginObjectHandler<TValue>) | Creates the JavaScript object of a cross-origin platform object (a Location object, https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-location-interface) in the current realm: its prototype cannot be changed, it cannot be made non-extensible, and its internal methods are the cross-origin ones of handler when the current realm is not same origin-domain with the object. Returns null when the engine does not support it (the object is then created by IJsAdapter<TValue>.CreatePlatformObject, and only its members check the origin of their caller). The default implementation returns null. |
| CreateDate(double) | Creates a Date object in the current realm. |
| CreateException(TValue) | Returns the .NET exception that throws value in the engine. |
| CreateFunction(string, int, JsHostFunction<TValue>) | Creates a built-in function object in the current realm (https://tc39.es/ecma262/#sec-createbuiltinfunction): its name and length properties are set, it is not a constructor, and it has no prototype property. |
| CreateHtmlDdaPlatformObject(TValue, object, IJsHostObjectHandler<TValue>, JsHostFunction<TValue>) | Creates the JavaScript object of a .NET platform object in the current realm, as IJsAdapter<TValue>.CreatePlatformObject with a handler, that also has a [[Call]] internal method (call) and an [[IsHTMLDDA]] internal slot (https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot): document.all, whose typeof is "undefined", that is falsy and loosely equal to null and undefined. The default implementation returns a Proxy of a function whose target is a platform object: it is not an [[IsHTMLDDA]] object, and IJsAdapter<TValue>.TryGetPlatformObject does not return its .NET object. |
| CreateObject(TValue) | Creates an ordinary object in the current realm, whose prototype is prototype (an object or null). |
| CreatePlatformObject(TValue, object, IJsHostObjectHandler<TValue>?) | Creates the JavaScript object of a .NET platform object in the current realm. When handler is not null, the object is a host exotic object whose internal methods call the handler first (the legacy platform objects). |
| CreateSharedArrayBuffer(object) | Creates a SharedArrayBuffer in the current realm whose data block is a data block returned by IJsAdapter<TValue>.GetSharedDataBlock (of any engine instance of the adapter), so that the buffers share their memory. Returns null when it is not supported (the bindings then use IJsAdapter<TValue>.SetSharedDataBlock). The default implementation returns null. |
| CreateWindowProxy(IJsWindowProxyHandler<TValue>) | Creates a WindowProxy exotic object (https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-windowproxy-exotic-object) whose internal methods are implemented with handler. It belongs to no realm. Returns null when the engine does not support it: a window is then exposed by its global object. The default implementation returns null. |
| DefineLazyAccessorProperty(TValue, TValue, IJsLazyAccessor<TValue>, bool, bool, bool) | Defines an accessor property whose functions are created on first access by factory (one object per property instead of closures: the attributes of the interfaces are defined this way). The default implementation calls IJsAdapter<TValue>.DefineLazyAccessorProperty. |
| DefineLazyAccessorProperty(TValue, TValue, Func<TValue>, Func<TValue>?, bool, bool) | Defines an accessor property whose functions are created on first access (e.g. the attributes of the interfaces, most of which are never used). setterFactory is null when the property has no setter. The default implementation creates the functions immediately. |
| DefineLazyDataProperty(TValue, TValue, IJsLazyValue<TValue>, bool, bool, bool) | Defines a data property whose value is created on first access by factory (one object per property instead of a closure: the interface objects of a realm are defined this way). The default implementation calls IJsAdapter<TValue>.DefineLazyDataProperty. |
| DefineLazyDataProperty(TValue, TValue, Func<TValue>, bool, bool, bool) | Defines a data property whose value is created on first access (e.g. the interface objects of the global object, most of which are never used). The default implementation creates the value immediately. |
| DefineOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>) | [[DefineOwnProperty]] (https://tc39.es/ecma262/#sec-definepropertyorthrow). Returns false on failure. |
| Delete(TValue, TValue) | [[Delete]]. |
| DetachArrayBuffer(TValue) | Detaches an ArrayBuffer created by IJsAdapter<TValue>.CreateArrayBufferWithData (DetachArrayBuffer with its detach key). |
| Evaluate(object, string) | Evaluates code in a realm, as an indirect eval (https://tc39.es/ecma262/#sec-performeval). It does not run the jobs. |
| EvaluateBuiltIn(object, string) | Evaluates a script of the implementation (a constant source text, e.g. Fetch.js) in a realm, as IJsAdapter<TValue>.Evaluate: the adapter may parse it once for all the realms. It does not run the jobs. The default implementation calls IJsAdapter<TValue>.Evaluate. |
| FromBigInt(BigInteger) | Creates a BigInt value. |
| FromBoolean(bool) | Creates a boolean value. |
| FromNumber(double) | Creates a number value. |
| FromString(string) | Creates a string value. |
| Get(TValue, TValue) | [[Get]] (https://tc39.es/ecma262/#sec-get-o-p). key is a string or a symbol. |
| GetAbstractModuleSource() | Returns %AbstractModuleSource% of the current realm (https://tc39.es/proposal-source-phase-imports/#sec-abstractmodulesource-objects), which the interface object of WebAssembly.Module extends (https://webassembly.github.io/esm-integration/js-api/index.html#webassembly-module-objects), or null when the engine does not implement the source phase imports: the interface then extends nothing. The default implementation returns null. |
| GetErrorInformation(TValue) | Returns the information of an error value: its message, file name, line and column. |
| GetGlobalObject(object) | Gets the global object of a realm. |
| GetOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>) | [[GetOwnProperty]]. Returns false when the property does not exist. |
| GetPropertyCount(TValue) | Gets the number of own properties of an object, without running code: the bindings remember the sizes of the objects they create, and call IJsAdapter<TValue>.ReserveProperties with them in the next realms. The default implementation returns 0 (unknown). |
| GetPrototypeOf(TValue) | [[GetPrototypeOf]]. |
| GetSharedDataBlock(TValue) | Returns the shared data block of a SharedArrayBuffer ([[ArrayBufferData]]), an opaque object that IJsAdapter<TValue>.SetSharedDataBlock can give to another SharedArrayBuffer of any engine instance of the adapter (possibly on another thread), so that they share their memory (the structured serialization of the SharedArrayBuffer objects). Returns null for other values, or when the engine cannot share the memory of its buffers. The default implementation returns null. |
| GetWellKnownSymbol(JsWellKnownSymbol) | Returns a well-known symbol (https://tc39.es/ecma262/#sec-well-known-symbols). |
| HasInternalSlot(TValue, JsInternalSlot) | Returns whether a value is an object that has an internal slot, or null when the adapter cannot tell: the structured serialization then calls the intrinsic function that reads the slot, which throws when the slot is missing (a thrown exception is slow, and most objects are ordinary objects). The default implementation returns null. |
| HasProperty(TValue, TValue) | [[HasProperty]]. |
| IsArray(TValue) | Gets whether the value is an Array exotic object (https://tc39.es/ecma262/#sec-array-exotic-objects), not a Proxy of an array. |
| IsBigInt(TValue) | Gets whether the value is a BigInt. |
| IsBoolean(TValue) | Gets whether the value is a boolean. |
| IsCallable(TValue) | Gets whether the value is callable (https://tc39.es/ecma262/#sec-iscallable). |
| IsConstructor(TValue) | Gets whether the value is a constructor (https://tc39.es/ecma262/#sec-isconstructor). |
| IsCurrentRealm(object) | Returns whether realm is the realm of the running execution context. |
| IsDate(TValue) | Gets whether the value is a Date object. |
| IsNull(TValue) | Gets whether the value is null. |
| IsNumber(TValue) | Gets whether the value is a number. |
| IsObject(TValue) | Gets whether the value is an object (including functions). |
| IsResizableBuffer(TValue) | Gets whether a buffer source is backed by a resizable ArrayBuffer or a growable SharedArrayBuffer (the buffer itself, or the buffer that a view views), which the buffer source types reject unless they have the [AllowResizable] extended attribute (https://webidl.spec.whatwg.org/#AllowResizable). The default implementation returns false: the resizable buffers are accepted. |
| IsRevokedProxy(TValue, TValue?) | Whether the value is a revoked proxy (its [[GetPrototypeOf]] throws). objectPrototype is the %Object.prototype% of the realm in which the proxy was created, or null when the engine does not track it. |
| IsString(TValue) | Gets whether the value is a string. |
| IsSymbol(TValue) | Gets whether the value is a symbol. |
| IsTerminationException(Exception) | Returns whether an exception aborts the running script (e.g. the termination of a worker): it is not a JavaScript exception, and is not converted by the DOM. The default implementation returns false. |
| IsUndefined(TValue) | Gets whether the value is undefined. |
| IsValue(object) | Returns whether a .NET object is a value of the engine, and not another .NET object given to the bindings (e.g. a platform object or a list, which the bindings convert). The default implementation tests whether it is a TValue: an adapter whose values have no specific type (e.g. TValue is Object) overrides it. |
| OrdinaryDefineOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>) | OrdinaryDefineOwnProperty (https://tc39.es/ecma262/#sec-ordinarydefineownproperty) of a host exotic object. |
| OrdinaryDelete(TValue, TValue) | OrdinaryDelete (https://tc39.es/ecma262/#sec-ordinarydelete) of a host exotic object. |
| OrdinaryGetOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>) | Performs an ordinary internal method of a host exotic object, bypassing its IJsHostObjectHandler<TValue> (e.g. OrdinaryGetOwnProperty, https://tc39.es/ecma262/#sec-ordinarygetownproperty). |
| OrdinaryOwnKeys(TValue) | OrdinaryOwnPropertyKeys (https://tc39.es/ecma262/#sec-ordinaryownpropertykeys) of a host exotic object. |
| OwnKeys(TValue) | [[OwnPropertyKeys]]: the strings and symbols. |
| ReserveProperties(TValue, int) | Prepares an object for count more properties (e.g. the interface objects of a global object), so that an engine can allocate their storage once. It does not change the behavior of the object. The default implementation does nothing. |
| RunInRealm<TResult>(object, Func<TResult>) | Runs action with realm as the current realm. |
| Set(TValue, TValue, TValue) | [[Set]] (https://tc39.es/ecma262/#sec-set-o-p-v-throw), throwing a TypeError on failure. |
| SetModuleSourceClassName(TValue, string) | Sets the [[ModuleSourceClassName]] internal slot of a platform object created by IJsAdapter<TValue>.CreatePlatformObject (e.g. WebAssembly.Module), read by the %AbstractModuleSource%.prototype[@@toStringTag] getter. The default implementation does nothing. |
| SetPrototypeOf(TValue, TValue) | [[SetPrototypeOf]]. |
| SetSharedDataBlock(TValue, object) | Replaces the data block of a new SharedArrayBuffer of the same byte length by a data block returned by IJsAdapter<TValue>.GetSharedDataBlock. Returns false when it is not supported. The default implementation returns false. |
| ToBigInt(TValue) | https://tc39.es/ecma262/#sec-tobigint |
| ToBoolean(TValue) | https://tc39.es/ecma262/#sec-toboolean |
| ToNumber(TValue) | https://tc39.es/ecma262/#sec-tonumber |
| ToString(TValue) | https://tc39.es/ecma262/#sec-tostring (throws a TypeError for a symbol). |
| TryGetBufferSource(TValue, JsBufferKind, bool, Memory<byte>) | Gets the kind and the bytes of an ArrayBuffer, a SharedArrayBuffer, a typed array or a DataView (the objects with an [[ArrayBufferData]], [[TypedArrayName]] or [[DataView]] internal slot), without running JavaScript code. bytes is a view of the data block of the buffer, so that the writes are visible to JavaScript; it is empty when the buffer is detached. isShared is true when the buffer (or the viewed buffer) is a SharedArrayBuffer. Returns false for other values. The default implementation returns false: the buffer source types cannot be converted. |
| TryGetPlatformObject(TValue, object?) | Returns the .NET object of a JavaScript platform object created by IJsAdapter<TValue>.CreatePlatformObject. |
| TryGetThrownValue(Exception, TValue?) | Returns the JavaScript value thrown by an exception of the engine, or false for another exception. |
| TryInitializeErrorData(TValue, string) | Gives a platform object created by IJsAdapter<TValue>.CreatePlatformObject an [[ErrorData]] internal slot: a DOMException (https://webidl.spec.whatwg.org/#es-DOMException-specialness), for which Error.isError returns true. The engine also sets its stack trace to the one of the running code, whose first line is stackHeader, read by the Error.prototype.stack accessor (https://tc39.es/proposal-error-stack-accessor/). Returns false when the engine does not support it: the object then gets an own stack data property. The default implementation returns false. |
| TryMakePrototypeImmutable(TValue) | Makes an object an immutable prototype exotic object (https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects), if the engine supports it: its [[SetPrototypeOf]] only accepts its current prototype. A proxy is left unchanged (its handler defines its [[SetPrototypeOf]]). Returns false when the engine does not support it: the bindings then replace the built-in functions that change prototypes (see WebIdlRealm<TAdapter, TValue>). The default implementation returns false. |
| TrySetErrorStack(TValue, string) | Sets the [[Stack]] internal slot of an error (https://tc39.es/proposal-error-stack-accessor/), read by the Error.prototype.stack accessor: the stack of a deserialized error (https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize). Returns false when the engine has no such slot (the stack is then an own data property of the error). The default implementation returns false. |
| TrySetGlobalThis(object, TValue) | Sets the this value of the global code of a realm (its [[GlobalThisValue]], also the value of globalThis): the WindowProxy of a window. Returns false when the engine does not support it (the this value is then the global object). The default implementation returns false. |
AsBoolean(TValue)
AsDate(TValue)
AsNumber(TValue)
AsString(TValue)
Call(TValue, TValue, ReadOnlySpan<TValue>)
[[Call]] (https://tc39.es/ecma262/#sec-call).
TValue Call(TValue function, TValue thisValue, ReadOnlySpan<TValue> arguments)Construct(TValue, ReadOnlySpan<TValue>, TValue)
[[Construct]] (https://tc39.es/ecma262/#sec-construct).
TValue Construct(TValue constructor, ReadOnlySpan<TValue> arguments, TValue newTarget)CreateArray(ReadOnlySpan<TValue>)
Creates an array in the current realm.
TValue CreateArray(ReadOnlySpan<TValue> items)CreateArrayBuffer(ReadOnlySpan<byte>)
IJsAdapter.csCreates an ArrayBuffer containing a copy of bytes in the current realm. The default implementation constructs it with the ArrayBuffer and Uint8Array constructors of the global object.
public TValue CreateArrayBuffer(ReadOnlySpan<byte> bytes)CreateArrayBufferView(JsBufferKind, TValue, int, int)
IJsAdapter.csCreates a typed array or a DataView (kind) of length elements viewing buffer from byteOffset, in the current realm. The default implementation calls the constructor of the global object.
public TValue CreateArrayBufferView(JsBufferKind kind, TValue buffer, int byteOffset, int length)CreateArrayBufferWithData(byte[], string)
IJsAdapter.csCreates an ArrayBuffer in the current realm whose data block is data (the bytes are shared, not copied), and whose [[ArrayBufferDetachKey]] is detachKey: it cannot be transferred or detached by scripts (e.g. the buffer of a WebAssembly.Memory). Returns null when the engine does not support it. The default implementation returns null.
CreateConstructor(string, int, JsHostConstructor<TValue>)
IJsAdapter.csCreates a built-in function object that is a constructor in the current realm (e.g. an interface object, https://webidl.spec.whatwg.org/#interface-object): its name and length properties are set, it has no prototype property, and Function.prototype.toString returns its NativeFunction representation (function name() { [native code] }). [[Call]] and [[Construct]] call constructor; NewTarget is undefined for [[Call]]. The default implementation returns a Proxy of a script function.
public TValue CreateConstructor(string name, int length, JsHostConstructor<TValue> constructor)CreateCrossOriginPlatformObject(TValue, object, IJsCrossOriginObjectHandler<TValue>)
IJsAdapter.csCreates the JavaScript object of a cross-origin platform object (a Location object, https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-location-interface) in the current realm: its prototype cannot be changed, it cannot be made non-extensible, and its internal methods are the cross-origin ones of handler when the current realm is not same origin-domain with the object. Returns null when the engine does not support it (the object is then created by IJsAdapter<TValue>.CreatePlatformObject, and only its members check the origin of their caller). The default implementation returns null.
public TValue? CreateCrossOriginPlatformObject(TValue prototype, object target, IJsCrossOriginObjectHandler<TValue> handler)CreateDate(double)
CreateException(TValue)
CreateFunction(string, int, JsHostFunction<TValue>)
Creates a built-in function object in the current realm (https://tc39.es/ecma262/#sec-createbuiltinfunction): its name and length properties are set, it is not a constructor, and it has no prototype property.
TValue CreateFunction(string name, int length, JsHostFunction<TValue> function)CreateHtmlDdaPlatformObject(TValue, object, IJsHostObjectHandler<TValue>, JsHostFunction<TValue>)
IJsAdapter.csCreates the JavaScript object of a .NET platform object in the current realm, as IJsAdapter<TValue>.CreatePlatformObject with a handler, that also has a [[Call]] internal method (call) and an [[IsHTMLDDA]] internal slot (https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot): document.all, whose typeof is "undefined", that is falsy and loosely equal to null and undefined. The default implementation returns a Proxy of a function whose target is a platform object: it is not an [[IsHTMLDDA]] object, and IJsAdapter<TValue>.TryGetPlatformObject does not return its .NET object.
public TValue CreateHtmlDdaPlatformObject(TValue prototype, object target, IJsHostObjectHandler<TValue> handler, JsHostFunction<TValue> call)Parameters
prototypeTValuetargetobjecthandlerIJsHostObjectHandler<TValue>callJsHostFunction<TValue>
Returns
TValue
CreateObject(TValue)
Creates an ordinary object in the current realm, whose prototype is prototype (an object or null).
TValue CreateObject(TValue prototype)Parameters
prototypeTValue
Returns
TValue
CreatePlatformObject(TValue, object, IJsHostObjectHandler<TValue>?)
Creates the JavaScript object of a .NET platform object in the current realm. When handler is not null, the object is a host exotic object whose internal methods call the handler first (the legacy platform objects).
TValue CreatePlatformObject(TValue prototype, object target, IJsHostObjectHandler<TValue>? handler)CreateWindowProxy(IJsWindowProxyHandler<TValue>)
IJsAdapter.csCreates a WindowProxy exotic object (https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-windowproxy-exotic-object) whose internal methods are implemented with handler. It belongs to no realm. Returns null when the engine does not support it: a window is then exposed by its global object. The default implementation returns null.
public TValue? CreateWindowProxy(IJsWindowProxyHandler<TValue> handler)DefineLazyAccessorProperty overloads
DefineLazyAccessorProperty(TValue, TValue, IJsLazyAccessor<TValue>, bool, bool, bool)
IJsAdapter.csDefines an accessor property whose functions are created on first access by factory (one object per property instead of closures: the attributes of the interfaces are defined this way). The default implementation calls IJsAdapter<TValue>.DefineLazyAccessorProperty.
public void DefineLazyAccessorProperty(TValue obj, TValue key, IJsLazyAccessor<TValue> factory, bool hasSetter, bool enumerable, bool configurable)Parameters
objTValuekeyTValuefactoryIJsLazyAccessor<TValue>hasSetterboolenumerableboolconfigurablebool
DefineLazyAccessorProperty(TValue, TValue, Func<TValue>, Func<TValue>?, bool, bool)
IJsAdapter.csDefines an accessor property whose functions are created on first access (e.g. the attributes of the interfaces, most of which are never used). setterFactory is null when the property has no setter. The default implementation creates the functions immediately.
public void DefineLazyAccessorProperty(TValue obj, TValue key, Func<TValue> getterFactory, Func<TValue>? setterFactory, bool enumerable, bool configurable)Parameters
objTValuekeyTValuegetterFactoryFunc<TValue>setterFactoryFunc<TValue>?enumerableboolconfigurablebool
DefineLazyDataProperty overloads
DefineLazyDataProperty(TValue, TValue, IJsLazyValue<TValue>, bool, bool, bool)
IJsAdapter.csDefines a data property whose value is created on first access by factory (one object per property instead of a closure: the interface objects of a realm are defined this way). The default implementation calls IJsAdapter<TValue>.DefineLazyDataProperty.
public void DefineLazyDataProperty(TValue obj, TValue key, IJsLazyValue<TValue> factory, bool writable, bool enumerable, bool configurable)Parameters
objTValuekeyTValuefactoryIJsLazyValue<TValue>writableboolenumerableboolconfigurablebool
DefineLazyDataProperty(TValue, TValue, Func<TValue>, bool, bool, bool)
IJsAdapter.csDefines a data property whose value is created on first access (e.g. the interface objects of the global object, most of which are never used). The default implementation creates the value immediately.
public void DefineLazyDataProperty(TValue obj, TValue key, Func<TValue> factory, bool writable, bool enumerable, bool configurable)Parameters
objTValuekeyTValuefactoryFunc<TValue>writableboolenumerableboolconfigurablebool
DefineOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>)
[[DefineOwnProperty]] (https://tc39.es/ecma262/#sec-definepropertyorthrow). Returns false on failure.
bool DefineOwnProperty(TValue obj, TValue key, in JsPropertyDescriptor<TValue> descriptor)Delete(TValue, TValue)
DetachArrayBuffer(TValue)
IJsAdapter.csDetaches an ArrayBuffer created by IJsAdapter<TValue>.CreateArrayBufferWithData (DetachArrayBuffer with its detach key).
public void DetachArrayBuffer(TValue arrayBuffer)Parameters
arrayBufferTValue
Evaluate(object, string)
EvaluateBuiltIn(object, string)
IJsAdapter.csEvaluates a script of the implementation (a constant source text, e.g. Fetch.js) in a realm, as IJsAdapter<TValue>.Evaluate: the adapter may parse it once for all the realms. It does not run the jobs. The default implementation calls IJsAdapter<TValue>.Evaluate.
FromBigInt(BigInteger)
FromBoolean(bool)
FromNumber(double)
FromString(string)
Get(TValue, TValue)
[[Get]] (https://tc39.es/ecma262/#sec-get-o-p). key is a string or a symbol.
TValue Get(TValue obj, TValue key)Parameters
objTValuekeyTValue
Returns
TValue
GetAbstractModuleSource()
IJsAdapter.cs- Experimental (WEBPLATEXP0014)
Returns %AbstractModuleSource% of the current realm (https://tc39.es/proposal-source-phase-imports/#sec-abstractmodulesource-objects), which the interface object of WebAssembly.Module extends (https://webassembly.github.io/esm-integration/js-api/index.html#webassembly-module-objects), or null when the engine does not implement the source phase imports: the interface then extends nothing. The default implementation returns null.
[Experimental("WEBPLATEXP0014", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public TValue? GetAbstractModuleSource()Returns
TValue?
GetErrorInformation(TValue)
Returns the information of an error value: its message, file name, line and column.
JsErrorInformation GetErrorInformation(TValue error)GetGlobalObject(object)
GetOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>)
[[GetOwnProperty]]. Returns false when the property does not exist.
bool GetOwnProperty(TValue obj, TValue key, out JsPropertyDescriptor<TValue> descriptor)GetPropertyCount(TValue)
IJsAdapter.csGets the number of own properties of an object, without running code: the bindings remember the sizes of the objects they create, and call IJsAdapter<TValue>.ReserveProperties with them in the next realms. The default implementation returns 0 (unknown).
public int GetPropertyCount(TValue obj)GetPrototypeOf(TValue)
[[GetPrototypeOf]].
TValue GetPrototypeOf(TValue obj)Parameters
objTValue
Returns
TValue
GetWellKnownSymbol(JsWellKnownSymbol)
Returns a well-known symbol (https://tc39.es/ecma262/#sec-well-known-symbols).
TValue GetWellKnownSymbol(JsWellKnownSymbol symbol)HasInternalSlot(TValue, JsInternalSlot)
IJsAdapter.csReturns whether a value is an object that has an internal slot, or null when the adapter cannot tell: the structured serialization then calls the intrinsic function that reads the slot, which throws when the slot is missing (a thrown exception is slow, and most objects are ordinary objects). The default implementation returns null.
public bool? HasInternalSlot(TValue value, JsInternalSlot slot)HasProperty(TValue, TValue)
IsArray(TValue)
IsBigInt(TValue)
IsBoolean(TValue)
IsCallable(TValue)
IsConstructor(TValue)
IsCurrentRealm(object)
IJsAdapter.csIsDate(TValue)
IsNull(TValue)
IsNumber(TValue)
IsObject(TValue)
IsResizableBuffer(TValue)
IJsAdapter.csGets whether a buffer source is backed by a resizable ArrayBuffer or a growable SharedArrayBuffer (the buffer itself, or the buffer that a view views), which the buffer source types reject unless they have the [AllowResizable] extended attribute (https://webidl.spec.whatwg.org/#AllowResizable). The default implementation returns false: the resizable buffers are accepted.
public bool IsResizableBuffer(TValue value)IsRevokedProxy(TValue, TValue?)
IJsAdapter.csWhether the value is a revoked proxy (its [[GetPrototypeOf]] throws). objectPrototype is the %Object.prototype% of the realm in which the proxy was created, or null when the engine does not track it.
public bool IsRevokedProxy(TValue value, out TValue? objectPrototype)IsString(TValue)
IsSymbol(TValue)
IsTerminationException(Exception)
IJsAdapter.csIsUndefined(TValue)
IsValue(object)
IJsAdapter.csReturns whether a .NET object is a value of the engine, and not another .NET object given to the bindings (e.g. a platform object or a list, which the bindings convert). The default implementation tests whether it is a TValue: an adapter whose values have no specific type (e.g. TValue is Object) overrides it.
OrdinaryDefineOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>)
OrdinaryDefineOwnProperty (https://tc39.es/ecma262/#sec-ordinarydefineownproperty) of a host exotic object.
bool OrdinaryDefineOwnProperty(TValue obj, TValue key, in JsPropertyDescriptor<TValue> descriptor)OrdinaryDelete(TValue, TValue)
OrdinaryGetOwnProperty(TValue, TValue, JsPropertyDescriptor<TValue>)
Performs an ordinary internal method of a host exotic object, bypassing its IJsHostObjectHandler<TValue> (e.g. OrdinaryGetOwnProperty, https://tc39.es/ecma262/#sec-ordinarygetownproperty).
bool OrdinaryGetOwnProperty(TValue obj, TValue key, out JsPropertyDescriptor<TValue> descriptor)OrdinaryOwnKeys(TValue)
OrdinaryOwnPropertyKeys (https://tc39.es/ecma262/#sec-ordinaryownpropertykeys) of a host exotic object.
IReadOnlyList<TValue> OrdinaryOwnKeys(TValue obj)OwnKeys(TValue)
[[OwnPropertyKeys]]: the strings and symbols.
IReadOnlyList<TValue> OwnKeys(TValue obj)ReserveProperties(TValue, int)
IJsAdapter.csPrepares an object for count more properties (e.g. the interface objects of a global object), so that an engine can allocate their storage once. It does not change the behavior of the object. The default implementation does nothing.
Parameters
objTValuecountint
RunInRealm<TResult>(object, Func<TResult>)
Runs action with realm as the current realm.
Set(TValue, TValue, TValue)
[[Set]] (https://tc39.es/ecma262/#sec-set-o-p-v-throw), throwing a TypeError on failure.
void Set(TValue obj, TValue key, TValue value)Parameters
objTValuekeyTValuevalueTValue
SetModuleSourceClassName(TValue, string)
IJsAdapter.cs- Experimental (WEBPLATEXP0014)
Sets the [[ModuleSourceClassName]] internal slot of a platform object created by IJsAdapter<TValue>.CreatePlatformObject (e.g. WebAssembly.Module), read by the %AbstractModuleSource%.prototype[@@toStringTag] getter. The default implementation does nothing.
[Experimental("WEBPLATEXP0014", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void SetModuleSourceClassName(TValue obj, string className)Parameters
objTValueclassNamestring
SetPrototypeOf(TValue, TValue)
ToBigInt(TValue)
https://tc39.es/ecma262/#sec-tobigint
BigInteger ToBigInt(TValue value)ToBoolean(TValue)
ToNumber(TValue)
ToString(TValue)
TryGetBufferSource(TValue, JsBufferKind, bool, Memory<byte>)
IJsAdapter.csGets the kind and the bytes of an ArrayBuffer, a SharedArrayBuffer, a typed array or a DataView (the objects with an [[ArrayBufferData]], [[TypedArrayName]] or [[DataView]] internal slot), without running JavaScript code. bytes is a view of the data block of the buffer, so that the writes are visible to JavaScript; it is empty when the buffer is detached. isShared is true when the buffer (or the viewed buffer) is a SharedArrayBuffer. Returns false for other values. The default implementation returns false: the buffer source types cannot be converted.
public bool TryGetBufferSource(TValue value, out JsBufferKind kind, out bool isShared, out Memory<byte> bytes)TryGetPlatformObject(TValue, object?)
Returns the .NET object of a JavaScript platform object created by IJsAdapter<TValue>.CreatePlatformObject.
TryGetThrownValue(Exception, TValue?)
TryInitializeErrorData(TValue, string)
IJsAdapter.csGives a platform object created by IJsAdapter<TValue>.CreatePlatformObject an [[ErrorData]] internal slot: a DOMException (https://webidl.spec.whatwg.org/#es-DOMException-specialness), for which Error.isError returns true. The engine also sets its stack trace to the one of the running code, whose first line is stackHeader, read by the Error.prototype.stack accessor (https://tc39.es/proposal-error-stack-accessor/). Returns false when the engine does not support it: the object then gets an own stack data property. The default implementation returns false.
TryMakePrototypeImmutable(TValue)
IJsAdapter.csMakes an object an immutable prototype exotic object (https://tc39.es/ecma262/#sec-immutable-prototype-exotic-objects), if the engine supports it: its [[SetPrototypeOf]] only accepts its current prototype. A proxy is left unchanged (its handler defines its [[SetPrototypeOf]]). Returns false when the engine does not support it: the bindings then replace the built-in functions that change prototypes (see WebIdlRealm<TAdapter, TValue>). The default implementation returns false.
public bool TryMakePrototypeImmutable(TValue obj)TrySetErrorStack(TValue, string)
IJsAdapter.cs- Experimental (WEBPLATEXP0011)
Sets the [[Stack]] internal slot of an error (https://tc39.es/proposal-error-stack-accessor/), read by the Error.prototype.stack accessor: the stack of a deserialized error (https://html.spec.whatwg.org/multipage/structured-data.html#structureddeserialize). Returns false when the engine has no such slot (the stack is then an own data property of the error). The default implementation returns false.
[Experimental("WEBPLATEXP0011", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public bool TrySetErrorStack(TValue error, string stack)TrySetGlobalThis(object, TValue)
IJsAdapter.csSets the this value of the global code of a realm (its [[GlobalThisValue]], also the value of globalThis): the WindowProxy of a window. Returns false when the engine does not support it (the this value is then the global object). The default implementation returns false.