dart-sdk/pkg/vm/dynamic_interface.md
Alexander Markov 17e12879fc Dynamic interface yaml file
TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart

Change-Id: Ib620a98b19067c51d913b499274bfed9aaa576f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370065
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-10 16:09:54 +00:00

3.1 KiB

Dynamic interface specification

This file describes the format of dynamic_interface.yaml file. Dynamic interface specifies classes and members of the host application which can be used, extended, implemented and overridden by a dynamically loaded module.

TODO(alexmarkov) Add a link to dynamic module API.

The dynamic interface yaml file can contain the following sections:

callable:
  - item 1
  ...
  - item N

extendable:
  - item 1
  ...
  - item N

can-be-overridden:
  - item 1
  ...
  - item N

callable section specifies members which can be called from dynamic module and classes which can be referenced in types of dynamic module.

extendable section specifies classes which dynamic module can be extend, mix-in or implement.

can-be-overridden section specifies instance members which dynamic module can override.

Library

  - library: '<library-uri>'

Library item specifies all public classes and members in the given library. Public members of private classes are not included.

Library prefix

  - library: '<prefix>*'

Library prefix item specifies all public classes and members of all libraries with given prefix. Public members of private classes are not included.

Class

  - library: '<library-uri>'
    class: '<class-name>'

Class item specifies given class and all public members of this class.

Class list

  - library: '<library-uri>'
    class: ['<class-name-1>', ..., 'class-name-N']

Class list item specifies given classes and all public members of these classes.

Library member

  - library: '<library-uri>'
    member: '<member-name>'

Library member item specifies given top-level member in the given library.

Class member

  - library: '<library-uri>'
    class: '<class-name>'
    member: '<member-name>'

Class member item specifies given member of the given class.

Example

callable:
  # All public classes and members in `dart:core`.
  - library: 'dart:core'

  # All public classes and members in `package:flutter`.
  - library: 'package:flutter/*'

  # Only `foo` in `package:my_app/dyn_interface.dart`.
  - library: 'package:my_app/dyn_interface.dart'
    member: foo

  # Only `DynInterface.bar` in `package:my_app/dyn_interface.dart`.
  - library: 'package:my_app/dyn_interface.dart'
    class: DynInterface
    member: 'bar'

extendable:
  # All public classes in `dart:core`.
  - library: 'dart:core'

  # `StatefulWidget` and `StatelessWidget` classes in `package:flutter/src/widgets/framework.dart`.
  - library: 'package:flutter/src/widgets/framework.dart'
    class: ['StatefulWidget', 'StatelessWidget']

can-be-overridden:
  # All public classes and members in `dart:core`.
  - library: 'dart:core'

  # Only `StatelessWidget.build` in `package:flutter/src/widgets/framework.dart`.
  - library: 'package:flutter/src/widgets/framework.dart'
    class: 'StatelessWidget'
    member: 'build'