The manakai project

Web::IDL::Processor

A Web IDL processor

SYNOPSIS

  use Web::IDL::Processor;
  $processor = Web::IDL::Processor->new;
  for $parser (...) {
    $processor->process_parsed_struct ($parser->parsed_struct);
  }
  $processor->end_processing;
  warn Dumper $processor->definitions;

DESCRIPTION

The Web::IDL::Processor module implements a processor of Web IDL, which receives a set of parsed Web IDL data structures generated from IDL fragments by Web::IDL::Parser, check the conformance of them, and outputs the assembled definitions.

METHODS

Following methods are available:

$processor = Web::IDL::Processor->new

Create a new Web IDL processor object.

$processor->onerror ($code)
$code = $processor->onerror

Get or set the error handler for the processor. Any conformance error, as well as warning and additional processing information, is reported to the handler. See <https://github.com/manakai/data-errors/blob/master/doc/onerror.txt> for details of error handling.

The value should not be set while the processor is running. If the value is changed, the result is undefined.

$processor->process_parsed_struct ($strict)

Process a parsed struct, returned by Web::IDL::Parser's parsed_struct method. This method can be invoked multiple times with different parsed structs obtained from different IDL fragments.

$processor->end_processing

Notify of the processor that all relevant parsed structs have been processed.

$defs = $processor->processed

Return the definitions obtained as a result of processing of parsed structe.

DATA STRUCTURE

The "processed" data structure is a hash reference, XXX

The idl_defs value is a hash reference with key/value pairs where keys are names of interface, callback interface, dictionary, callback, or typedef definitions and values are their descriptions.

The global_members value is a hash reference with key/value pairs where keys are names of interface objects, named constructors, and namespaces and values are their descriptions.

XXX global_names

XXX

alias

An alias to another object in the same set of members. The 1st item is a hash reference whose name value identifies the referenced member.

AllowShared

An annotated type with the [AllowShared] extended attributes. The 1st item is a type value representing the type without annotation.

Clamp

An annotated type with the [Clamp] extended attribute. The 1st item is a type value representing the type without annotation.

EnforceRange

An annotated type with the [EnforceRange] extended attribute. The 1st item is a type value representing the type without annotation.

HTMLConstructor

An interface object generated by the [HTMLConstructor] extended attribute. The 1st item is a hash reference describing the interface object.

async_iterable

An async iterable declaration. The 1st item is a hash reference describing the declaration.

interface

An interface definition. The 1st item is a hash reference describing the definition.

interface_mixin

An interface mixin definition. The 1st item is a hash reference describing the definition.

iterable

An iterable declaration. The 1st item is a hash reference describing the declaration.

legacyiterable

An legacyiterable declaration. The 1st item is a hash reference describing the declaration.

maplike

An maplike declaration. The 1st item is a hash reference describing the declaration.

namespace

A namespace definition. The 1st item is a hash reference describing the definition.

operation

An operation. The 1st item is a hash reference describing the operation.

sequence

A sequence type. The 1st item is a type value representing the inner type.

sequence_value

A sequence value. The 1st item is an array reference containing the items of the value. If it is an empty array reference, this is an empty sequence.

setlike

An setlike declaration. The 1st item is a hash reference describing the declaration.

TreatNullAsEmptyString

An annotated type with the [TreatNullAs=EmptyString] extended attribute. The 1st item is a type value representing the type without annotation.

XXX

ArrayClass (boolean)

Whether the interface is annotated with the [LegacyArrayClass] extended attribute or not.

CEReactions (boolean)

Whether the [CEReactions] extended attribute is in effect or not.

Exposed (hash reference of string => boolean)

Which globals the interface, callback interface, interface mixin, global member, interface member, interface mixin member, or namespace member is exposed to. The value is a hash reference whose keys are global interface names (not global names) and values are boolean true values.

For an interface mixin, the value might not be defined, which represents that the interface mixin has no Exposed extended attribute.

For an interface member, interface mixin member, or namespace member, the value might not be defined, which represents the exposure set is same as that of the definition the member belongs to.

getter (boolean)

Whether the attribute has a getter or not.

implements (hash reference of string => hash reference of key/value pairs)

For an interface, callback interface, or dictionary, the set of the inherited interfaces or the inherited dictionaries with included interfaces, if it is not empty.

The keys of the hash reference are the names of the interfaces or dictionaries. The interface or dictionary itself is not listed here. The corresponding value is the description of the inheritance, with following key/value pairs:

depth (integer)

The distance, i.e. the number of "inherits" or includes relationships to this interface, callback interface, interface mixin, or dictionary.

supplemental (boolean)

Whether this is an interface mixin included by an includes statement.

keys_type (type)

The first type in the maplike or iterable declaration when two types are specified.

name (string)

The referenced member's name, used with alias typed data.

overloaded (boolean)

Whether the operation is overloaded or not.

read (boolean)

Always true for maplike or setlike declaration.

required (boolean)

Whether the dictionary member is required or not.

SecureContext (boolean)

Whether the object is annotated (directly or indirectly) with the [SecureContext] extended attribute or not.

setter

If the value is 1, the attribute is not read-only.

If the value is replaceable, the setter of the attribute is the Web IDL [Replaceable] setter.

If the value is LenientSetter, the setter of the attribute is the Web IDL [LenientSetter] setter.

If no value is specified, the attribute has no setter.

TreatNonObjectAsNull (boolean)

Whether the callback is annotated with the [TreatNonObjectAsNull] extended attribute or not.

LegacyUnenumerableNamedProperties (boolean)

Whether the interface is annotated with the [LegacyUnenumerableNamedProperties] extended attribute or not.

Unscopable (boolean)

Whether the member is annotated with the [Unscopable] extended attribute or not.

values_type (type)

The last type in the maplike, setlike, iterable, or legacyiterable declaration.

write (boolean)

Whether the maplike or setlike declaration is not read-only.

XXX overload set item

Any partial definition in the Web IDL fragment sources (partial interface, partial interface mixin, partial namespace, or partial dictionary definitions) is merged into the main definition.

SPECIFICATIONS

WEBIDL

Web IDL <https://heycam.github.io/webidl/>.

HTML

HTML Standard <https://html.spec.whatwg.org/#cereactions>.

This implementation does not allow use of extended attributes not allowed by Web IDL or any other applicable specification.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

Copyright 2014-2020 Wakaba <wakaba@suikawiki.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.