Lines Matching defs:webidl
6 /** @type {import('../../types/webidl').Webidl} */
7 const webidl = {}
8 webidl.converters = {}
9 webidl.util = {}
10 webidl.errors = {}
12 webidl.errors.exception = function (message) {
16 webidl.errors.conversionFailed = function (context) {
22 return webidl.errors.exception({
28 webidl.errors.invalidArgument = function (context) {
29 return webidl.errors.exception({
35 // https://webidl.spec.whatwg.org/#implements
36 webidl.brandCheck = function (V, I, opts = undefined) {
44 webidl.argumentLengthCheck = function ({ length }, min, ctx) {
46 throw webidl.errors.exception({
54 webidl.illegalConstructor = function () {
55 throw webidl.errors.exception({
62 webidl.util.Type = function (V) {
81 // https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
82 webidl.util.ConvertToInt = function (V, bitLength, signedness, opts = {}) {
133 throw webidl.errors.exception({
140 x = webidl.util.IntegerPart(x)
145 throw webidl.errors.exception({
186 x = webidl.util.IntegerPart(x)
201 // https://webidl.spec.whatwg.org/#abstract-opdef-integerpart
202 webidl.util.IntegerPart = function (n) {
215 // https://webidl.spec.whatwg.org/#es-sequence
216 webidl.sequenceConverter = function (converter) {
219 if (webidl.util.Type(V) !== 'Object') {
220 throw webidl.errors.exception({
222 message: `Value of type ${webidl.util.Type(V)} is not an Object.`
236 throw webidl.errors.exception({
242 // https://webidl.spec.whatwg.org/#create-sequence-from-iterable
257 // https://webidl.spec.whatwg.org/#es-to-record
258 webidl.recordConverter = function (keyConverter, valueConverter) {
261 if (webidl.util.Type(O) !== 'Object') {
262 throw webidl.errors.exception({
264 message: `Value of type ${webidl.util.Type(O)} is not an Object.`
318 webidl.interfaceConverter = function (i) {
321 throw webidl.errors.exception({
331 webidl.dictionaryConverter = function (converters) {
333 const type = webidl.util.Type(dictionary)
339 throw webidl.errors.exception({
350 throw webidl.errors.exception({
376 throw webidl.errors.exception({
390 webidl.nullableConverter = function (converter) {
400 // https://webidl.spec.whatwg.org/#es-DOMString
401 webidl.converters.DOMString = function (V, opts = {}) {
421 // https://webidl.spec.whatwg.org/#es-ByteString
422 webidl.converters.ByteString = function (V) {
425 const x = webidl.converters.DOMString(V)
444 // https://webidl.spec.whatwg.org/#es-USVString
445 webidl.converters.USVString = toUSVString
447 // https://webidl.spec.whatwg.org/#es-boolean
448 webidl.converters.boolean = function (V) {
457 // https://webidl.spec.whatwg.org/#es-any
458 webidl.converters.any = function (V) {
462 // https://webidl.spec.whatwg.org/#es-long-long
463 webidl.converters['long long'] = function (V) {
465 const x = webidl.util.ConvertToInt(V, 64, 'signed')
472 // https://webidl.spec.whatwg.org/#es-unsigned-long-long
473 webidl.converters['unsigned long long'] = function (V) {
475 const x = webidl.util.ConvertToInt(V, 64, 'unsigned')
482 // https://webidl.spec.whatwg.org/#es-unsigned-long
483 webidl.converters['unsigned long'] = function (V) {
485 const x = webidl.util.ConvertToInt(V, 32, 'unsigned')
492 // https://webidl.spec.whatwg.org/#es-unsigned-short
493 webidl.converters['unsigned short'] = function (V, opts) {
495 const x = webidl.util.ConvertToInt(V, 16, 'unsigned', opts)
502 // https://webidl.spec.whatwg.org/#idl-ArrayBuffer
503 webidl.converters.ArrayBuffer = function (V, opts = {}) {
510 webidl.util.Type(V) !== 'Object' ||
513 throw webidl.errors.conversionFailed({
525 throw webidl.errors.exception({
542 webidl.converters.TypedArray = function (V, T, opts = {}) {
549 webidl.util.Type(V) !== 'Object' ||
553 throw webidl.errors.conversionFailed({
565 throw webidl.errors.exception({
582 webidl.converters.DataView = function (V, opts = {}) {
585 if (webidl.util.Type(V) !== 'Object' || !types.isDataView(V)) {
586 throw webidl.errors.exception({
597 throw webidl.errors.exception({
614 // https://webidl.spec.whatwg.org/#BufferSource
615 webidl.converters.BufferSource = function (V, opts = {}) {
617 return webidl.converters.ArrayBuffer(V, opts)
621 return webidl.converters.TypedArray(V, V.constructor)
625 return webidl.converters.DataView(V, opts)
631 webidl.converters['sequence<ByteString>'] = webidl.sequenceConverter(
632 webidl.converters.ByteString
635 webidl.converters['sequence<sequence<ByteString>>'] = webidl.sequenceConverter(
636 webidl.converters['sequence<ByteString>']
639 webidl.converters['record<ByteString, ByteString>'] = webidl.recordConverter(
640 webidl.converters.ByteString,
641 webidl.converters.ByteString
645 webidl