Change all fields to native getters/setters

Bug: https://github.com/dart-lang/sdk/issues/40772

Attributes are translated to native getters and setters regardless of
NNBD. Some logic was removed for fields that no longer apply due to this
change.

Change-Id: Ia1a05778ff8c6f082506a1c95a3057a7c5f7f896
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136880
Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
Srujan Gaddam 2020-02-29 01:29:35 +00:00 committed by commit-bot@chromium.org
parent 3ec6ec2a2d
commit 80f84e1942
11 changed files with 4124 additions and 2887 deletions

File diff suppressed because it is too large Load diff

View file

@ -246,19 +246,19 @@ class Cursor extends Interceptor {
throw new UnsupportedError("Not supported");
}
final String direction;
String get direction native;
@_annotation_Creates_IDBKey
@_annotation_Returns_IDBKey
final Object key;
Object get key native;
@_annotation_Creates_IDBKey
@_annotation_Returns_IDBKey
final Object primaryKey;
Object get primaryKey native;
@Creates('Null')
@Returns('ObjectStore|Index|Null')
final Object source;
Object get source native;
void advance(int count) native;
@ -291,7 +291,7 @@ class CursorWithValue extends Cursor {
@JSName('value')
@annotation_Creates_SerializedScriptValue
@annotation_Returns_SerializedScriptValue
final dynamic _get_value;
dynamic get _get_value native;
}
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -402,15 +402,15 @@ class Database extends EventTarget {
static const EventStreamProvider<VersionChangeEvent> versionChangeEvent =
const EventStreamProvider<VersionChangeEvent>('versionchange');
final String name;
String get name native;
@Returns('DomStringList|Null')
@Creates('DomStringList')
final List<String> objectStoreNames;
List<String> get objectStoreNames native;
@Creates('int|String|Null')
@Returns('int|String|Null')
final int version;
int get version native;
void close() native;
@ -656,15 +656,17 @@ class Index extends Interceptor {
}
@annotation_Creates_SerializedScriptValue
final Object keyPath;
Object get keyPath native;
final bool multiEntry;
bool get multiEntry native;
String name;
String get name native;
final ObjectStore objectStore;
set name(String value) native;
final bool unique;
ObjectStore get objectStore native;
bool get unique native;
@JSName('count')
Request _count(Object key) native;
@ -725,14 +727,14 @@ class KeyRange extends Interceptor {
}
@annotation_Creates_SerializedScriptValue
final Object lower;
Object get lower native;
final bool lowerOpen;
bool get lowerOpen native;
@annotation_Creates_SerializedScriptValue
final Object upper;
Object get upper native;
final bool upperOpen;
bool get upperOpen native;
@JSName('bound')
static KeyRange bound_(Object lower, Object upper,
@ -879,18 +881,20 @@ class ObjectStore extends Interceptor {
throw new UnsupportedError("Not supported");
}
final bool autoIncrement;
bool get autoIncrement native;
@Returns('DomStringList|Null')
@Creates('DomStringList')
final List<String> indexNames;
List<String> get indexNames native;
@annotation_Creates_SerializedScriptValue
final Object keyPath;
Object get keyPath native;
String name;
String get name native;
final Transaction transaction;
set name(String value) native;
Transaction get transaction native;
@Returns('Request')
@Creates('Request')
@ -1024,11 +1028,11 @@ class Observation extends Interceptor {
throw new UnsupportedError("Not supported");
}
final Object key;
Object get key native;
final String type;
String get type native;
final Object value;
Object get value native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -1070,11 +1074,11 @@ class ObserverChanges extends Interceptor {
throw new UnsupportedError("Not supported");
}
final Database database;
Database get database native;
final Object records;
Object get records native;
final Transaction transaction;
Transaction get transaction native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -1143,19 +1147,19 @@ class Request extends EventTarget {
static const EventStreamProvider<Event> successEvent =
const EventStreamProvider<Event>('success');
final DomException error;
DomException get error native;
final String readyState;
String get readyState native;
dynamic get result => _convertNativeToDart_IDBAny(this._get_result);
@JSName('result')
@Creates('Null')
final dynamic _get_result;
dynamic get _get_result native;
@Creates('Null')
final Object source;
Object get source native;
final Transaction transaction;
Transaction get transaction native;
/// Stream of `error` events handled by this [Request].
Stream<Event> get onError => errorEvent.forTarget(this);
@ -1230,15 +1234,15 @@ class Transaction extends EventTarget {
static const EventStreamProvider<Event> errorEvent =
const EventStreamProvider<Event>('error');
final Database db;
Database get db native;
final DomException error;
DomException get error native;
final String mode;
String get mode native;
@Returns('DomStringList|Null')
@Creates('DomStringList')
final List<String> objectStoreNames;
List<String> get objectStoreNames native;
void abort() native;
@ -1280,17 +1284,17 @@ class VersionChangeEvent extends Event {
static VersionChangeEvent _create_2(type) =>
JS('VersionChangeEvent', 'new IDBVersionChangeEvent(#)', type);
final String dataLoss;
String get dataLoss native;
final String dataLossMessage;
String get dataLossMessage native;
@Creates('int|String|Null')
@Returns('int|String|Null')
final int newVersion;
int get newVersion native;
@Creates('int|String|Null')
@Returns('int|String|Null')
final int oldVersion;
int get oldVersion native;
@JSName('target')
final OpenDBRequest target;

File diff suppressed because it is too large Load diff

View file

@ -52,15 +52,23 @@ class AnalyserNode extends AudioNode {
static AnalyserNode _create_2(context) =>
JS('AnalyserNode', 'new AnalyserNode(#)', context);
int fftSize;
int get fftSize native;
final int frequencyBinCount;
set fftSize(int value) native;
num maxDecibels;
int get frequencyBinCount native;
num minDecibels;
num get maxDecibels native;
num smoothingTimeConstant;
set maxDecibels(num value) native;
num get minDecibels native;
set minDecibels(num value) native;
num get smoothingTimeConstant native;
set smoothingTimeConstant(num value) native;
void getByteFrequencyData(Uint8List array) native;
@ -88,13 +96,13 @@ class AudioBuffer extends Interceptor {
static AudioBuffer _create_1(options) =>
JS('AudioBuffer', 'new AudioBuffer(#)', options);
final num duration;
num get duration native;
final int length;
int get length native;
final int numberOfChannels;
int get numberOfChannels native;
final num sampleRate;
num get sampleRate native;
void copyFromChannel(Float32List destination, int channelNumber,
[int startInChannel]) native;
@ -132,17 +140,25 @@ class AudioBufferSourceNode extends AudioScheduledSourceNode {
static AudioBufferSourceNode _create_2(context) =>
JS('AudioBufferSourceNode', 'new AudioBufferSourceNode(#)', context);
AudioBuffer buffer;
AudioBuffer get buffer native;
final AudioParam detune;
set buffer(AudioBuffer value) native;
bool loop;
AudioParam get detune native;
num loopEnd;
bool get loop native;
num loopStart;
set loop(bool value) native;
final AudioParam playbackRate;
num get loopEnd native;
set loopEnd(num value) native;
num get loopStart native;
set loopStart(num value) native;
AudioParam get playbackRate native;
void start([num when, num grainOffset, num grainDuration]) native;
}
@ -163,7 +179,7 @@ class AudioContext extends BaseAudioContext {
static bool get supported =>
JS('bool', '!!(window.AudioContext || window.webkitAudioContext)');
final num baseLatency;
num get baseLatency native;
Future close() => promiseToFuture(JS("", "#.close()", this));
@ -245,7 +261,7 @@ class AudioDestinationNode extends AudioNode {
throw new UnsupportedError("Not supported");
}
final int maxChannelCount;
int get maxChannelCount native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -258,23 +274,23 @@ class AudioListener extends Interceptor {
throw new UnsupportedError("Not supported");
}
final AudioParam forwardX;
AudioParam get forwardX native;
final AudioParam forwardY;
AudioParam get forwardY native;
final AudioParam forwardZ;
AudioParam get forwardZ native;
final AudioParam positionX;
AudioParam get positionX native;
final AudioParam positionY;
AudioParam get positionY native;
final AudioParam positionZ;
AudioParam get positionZ native;
final AudioParam upX;
AudioParam get upX native;
final AudioParam upY;
AudioParam get upY native;
final AudioParam upZ;
AudioParam get upZ native;
void setOrientation(num x, num y, num z, num xUp, num yUp, num zUp) native;
@ -291,17 +307,23 @@ class AudioNode extends EventTarget {
throw new UnsupportedError("Not supported");
}
int channelCount;
int get channelCount native;
String channelCountMode;
set channelCount(int value) native;
String channelInterpretation;
String get channelCountMode native;
final BaseAudioContext context;
set channelCountMode(String value) native;
final int numberOfInputs;
String get channelInterpretation native;
final int numberOfOutputs;
set channelInterpretation(String value) native;
BaseAudioContext get context native;
int get numberOfInputs native;
int get numberOfOutputs native;
@JSName('connect')
AudioNode _connect(destination, [int output, int input]) native;
@ -327,13 +349,15 @@ class AudioParam extends Interceptor {
throw new UnsupportedError("Not supported");
}
final num defaultValue;
num get defaultValue native;
final num maxValue;
num get maxValue native;
final num minValue;
num get minValue native;
num value;
num get value native;
set value(num value) native;
AudioParam cancelAndHoldAtTime(num startTime) native;
@ -439,11 +463,11 @@ class AudioProcessingEvent extends Event {
type,
eventInitDict);
final AudioBuffer inputBuffer;
AudioBuffer get inputBuffer native;
final AudioBuffer outputBuffer;
AudioBuffer get outputBuffer native;
final num playbackTime;
num get playbackTime native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -477,17 +501,19 @@ class AudioTrack extends Interceptor {
throw new UnsupportedError("Not supported");
}
bool enabled;
bool get enabled native;
final String id;
set enabled(bool value) native;
final String kind;
String get id native;
final String label;
String get kind native;
final String language;
String get label native;
final SourceBuffer sourceBuffer;
String get language native;
SourceBuffer get sourceBuffer native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -503,7 +529,7 @@ class AudioTrackList extends EventTarget {
static const EventStreamProvider<Event> changeEvent =
const EventStreamProvider<Event>('change');
final int length;
int get length native;
AudioTrack __getter__(int index) native;
@ -522,9 +548,9 @@ class AudioWorkletGlobalScope extends WorkletGlobalScope {
throw new UnsupportedError("Not supported");
}
final num currentTime;
num get currentTime native;
final num sampleRate;
num get sampleRate native;
void registerProcessor(String name, Object processorConstructor) native;
}
@ -556,7 +582,7 @@ class AudioWorkletNode extends AudioNode {
static AudioWorkletNode _create_2(context, name) =>
JS('AudioWorkletNode', 'new AudioWorkletNode(#,#)', context, name);
final AudioParamMap parameters;
AudioParamMap get parameters native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -580,15 +606,15 @@ class BaseAudioContext extends EventTarget {
throw new UnsupportedError("Not supported");
}
final num currentTime;
num get currentTime native;
final AudioDestinationNode destination;
AudioDestinationNode get destination native;
final AudioListener listener;
AudioListener get listener native;
final num sampleRate;
num get sampleRate native;
final String state;
String get state native;
AnalyserNode createAnalyser() native;
@ -684,15 +710,17 @@ class BiquadFilterNode extends AudioNode {
static BiquadFilterNode _create_2(context) =>
JS('BiquadFilterNode', 'new BiquadFilterNode(#)', context);
final AudioParam Q;
AudioParam get Q native;
final AudioParam detune;
AudioParam get detune native;
final AudioParam frequency;
AudioParam get frequency native;
final AudioParam gain;
AudioParam get gain native;
String type;
String get type native;
set type(String value) native;
void getFrequencyResponse(Float32List frequencyHz, Float32List magResponse,
Float32List phaseResponse) native;
@ -766,7 +794,7 @@ class ConstantSourceNode extends AudioScheduledSourceNode {
static ConstantSourceNode _create_2(context) =>
JS('ConstantSourceNode', 'new ConstantSourceNode(#)', context);
final AudioParam offset;
AudioParam get offset native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -791,9 +819,13 @@ class ConvolverNode extends AudioNode {
static ConvolverNode _create_2(context) =>
JS('ConvolverNode', 'new ConvolverNode(#)', context);
AudioBuffer buffer;
AudioBuffer get buffer native;
bool normalize;
set buffer(AudioBuffer value) native;
bool get normalize native;
set normalize(bool value) native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -818,7 +850,7 @@ class DelayNode extends AudioNode {
static DelayNode _create_2(context) =>
JS('DelayNode', 'new DelayNode(#)', context);
final AudioParam delayTime;
AudioParam get delayTime native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -846,17 +878,17 @@ class DynamicsCompressorNode extends AudioNode {
static DynamicsCompressorNode _create_2(context) =>
JS('DynamicsCompressorNode', 'new DynamicsCompressorNode(#)', context);
final AudioParam attack;
AudioParam get attack native;
final AudioParam knee;
AudioParam get knee native;
final AudioParam ratio;
AudioParam get ratio native;
final num reduction;
num get reduction native;
final AudioParam release;
AudioParam get release native;
final AudioParam threshold;
AudioParam get threshold native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -881,7 +913,7 @@ class GainNode extends AudioNode {
static GainNode _create_2(context) =>
JS('GainNode', 'new GainNode(#)', context);
final AudioParam gain;
AudioParam get gain native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -925,7 +957,7 @@ class MediaElementAudioSourceNode extends AudioNode {
context,
options);
final MediaElement mediaElement;
MediaElement get mediaElement native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -956,7 +988,7 @@ class MediaStreamAudioDestinationNode extends AudioNode {
'new MediaStreamAudioDestinationNode(#)',
context);
final MediaStream stream;
MediaStream get stream native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -979,7 +1011,7 @@ class MediaStreamAudioSourceNode extends AudioNode {
context,
options);
final MediaStream mediaStream;
MediaStream get mediaStream native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -1002,7 +1034,7 @@ class OfflineAudioCompletionEvent extends Event {
type,
eventInitDict);
final AudioBuffer renderedBuffer;
AudioBuffer get renderedBuffer native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -1041,7 +1073,7 @@ class OfflineAudioContext extends BaseAudioContext {
'new OfflineAudioContext(#)',
numberOfChannels_OR_options);
final int length;
int get length native;
Future<AudioBuffer> startRendering() =>
promiseToFuture<AudioBuffer>(JS("", "#.startRendering()", this));
@ -1073,11 +1105,13 @@ class OscillatorNode extends AudioScheduledSourceNode {
static OscillatorNode _create_2(context) =>
JS('OscillatorNode', 'new OscillatorNode(#)', context);
final AudioParam detune;
AudioParam get detune native;
final AudioParam frequency;
AudioParam get frequency native;
String type;
String get type native;
set type(String value) native;
void setPeriodicWave(PeriodicWave periodicWave) native;
}
@ -1104,33 +1138,49 @@ class PannerNode extends AudioNode {
static PannerNode _create_2(context) =>
JS('PannerNode', 'new PannerNode(#)', context);
num coneInnerAngle;
num get coneInnerAngle native;
num coneOuterAngle;
set coneInnerAngle(num value) native;
num coneOuterGain;
num get coneOuterAngle native;
String distanceModel;
set coneOuterAngle(num value) native;
num maxDistance;
num get coneOuterGain native;
final AudioParam orientationX;
set coneOuterGain(num value) native;
final AudioParam orientationY;
String get distanceModel native;
final AudioParam orientationZ;
set distanceModel(String value) native;
String panningModel;
num get maxDistance native;
final AudioParam positionX;
set maxDistance(num value) native;
final AudioParam positionY;
AudioParam get orientationX native;
final AudioParam positionZ;
AudioParam get orientationY native;
num refDistance;
AudioParam get orientationZ native;
num rolloffFactor;
String get panningModel native;
set panningModel(String value) native;
AudioParam get positionX native;
AudioParam get positionY native;
AudioParam get positionZ native;
num get refDistance native;
set refDistance(num value) native;
num get rolloffFactor native;
set rolloffFactor(num value) native;
void setOrientation(num x, num y, num z) native;
@ -1179,7 +1229,7 @@ class ScriptProcessorNode extends AudioNode {
static const EventStreamProvider<AudioProcessingEvent> audioProcessEvent =
const EventStreamProvider<AudioProcessingEvent>('audioprocess');
final int bufferSize;
int get bufferSize native;
void setEventListener(EventListener eventListener) native;
@ -1217,7 +1267,7 @@ class StereoPannerNode extends AudioNode {
static StereoPannerNode _create_2(context) =>
JS('StereoPannerNode', 'new StereoPannerNode(#)', context);
final AudioParam pan;
AudioParam get pan native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -1242,7 +1292,11 @@ class WaveShaperNode extends AudioNode {
static WaveShaperNode _create_2(context) =>
JS('WaveShaperNode', 'new WaveShaperNode(#)', context);
Float32List curve;
Float32List get curve native;
String oversample;
set curve(Float32List value) native;
String get oversample native;
set oversample(String value) native;
}

View file

@ -34,11 +34,11 @@ class ActiveInfo extends Interceptor {
throw new UnsupportedError("Not supported");
}
final String name;
String get name native;
final int size;
int get size native;
final int type;
int get type native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -314,7 +314,7 @@ class ContextEvent extends Event {
static ContextEvent _create_2(type) =>
JS('ContextEvent', 'new WebGLContextEvent(#)', type);
final String statusMessage;
String get statusMessage native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -725,13 +725,13 @@ class RenderingContext extends Interceptor implements CanvasRenderingContext {
/// Checks if this type is supported on the current platform.
static bool get supported => JS('bool', '!!(window.WebGLRenderingContext)');
final CanvasElement canvas;
CanvasElement get canvas native;
// From WebGLRenderingContextBase
final int drawingBufferHeight;
int get drawingBufferHeight native;
final int drawingBufferWidth;
int get drawingBufferWidth native;
void activeTexture(int texture) native;
@ -1362,7 +1362,7 @@ class RenderingContext2 extends Interceptor
throw new UnsupportedError("Not supported");
}
final Canvas canvas;
Canvas get canvas native;
// From WebGL2RenderingContextBase
@ -2301,9 +2301,9 @@ class RenderingContext2 extends Interceptor
// From WebGLRenderingContextBase
final int drawingBufferHeight;
int get drawingBufferHeight native;
final int drawingBufferWidth;
int get drawingBufferWidth native;
void activeTexture(int texture) native;
@ -2856,11 +2856,11 @@ class ShaderPrecisionFormat extends Interceptor {
throw new UnsupportedError("Not supported");
}
final int precision;
int get precision native;
final int rangeMax;
int get rangeMax native;
final int rangeMin;
int get rangeMin native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -2884,13 +2884,13 @@ class Texture extends Interceptor {
throw new UnsupportedError("Not supported");
}
final bool lastUploadedVideoFrameWasSkipped;
bool get lastUploadedVideoFrameWasSkipped native;
final int lastUploadedVideoHeight;
int get lastUploadedVideoHeight native;
final num lastUploadedVideoTimestamp;
num get lastUploadedVideoTimestamp native;
final int lastUploadedVideoWidth;
int get lastUploadedVideoWidth native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a

View file

@ -81,7 +81,7 @@ class SqlDatabase extends Interceptor {
/// Checks if this type is supported on the current platform.
static bool get supported => JS('bool', '!!(window.openDatabase)');
final String version;
String get version native;
@JSName('changeVersion')
/**
@ -187,9 +187,9 @@ class SqlError extends Interceptor {
static const int VERSION_ERR = 2;
final int code;
int get code native;
final String message;
String get message native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@ -202,11 +202,11 @@ class SqlResultSet extends Interceptor {
throw new UnsupportedError("Not supported");
}
final int insertId;
int get insertId native;
final SqlResultSetRowList rows;
SqlResultSetRowList get rows native;
final int rowsAffected;
int get rowsAffected native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a

File diff suppressed because it is too large Load diff

View file

@ -2948,7 +2948,8 @@ class StyleElement extends SvgElement {
StyleSheet? get sheet native;
// Use implementation from Element.
// final String title;
// String get title native;
// void set title(String value) native;
String get type native;
@ -3282,16 +3283,18 @@ class SvgElement extends Element implements GlobalEventHandlers, NoncedElement {
// Shadowing definition.
AnimatedString get _svgClassName => JS("AnimatedString", "#.className", this);
AnimatedString get _svgClassName native;
@JSName('ownerSVGElement')
SvgSvgElement? get ownerSvgElement native;
// Use implementation from Element.
// final CssStyleDeclaration style;
// CssStyleDeclaration get style native;
// void set style(CssStyleDeclaration value) native;
// Use implementation from Element.
// final int tabIndex;
// int get tabIndex native;
// void set tabIndex(int value) native;
SvgElement? get viewportElement native;
@ -4022,7 +4025,9 @@ abstract class ZoomAndPan extends Interceptor {
static const int SVG_ZOOMANDPAN_UNKNOWN = 0;
int zoomAndPan;
int get zoomAndPan native;
set zoomAndPan(int value) native;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a

View file

@ -138,7 +138,9 @@ class AudioBufferSourceNode extends AudioScheduledSourceNode {
static AudioBufferSourceNode _create_2(context) =>
JS('AudioBufferSourceNode', 'new AudioBufferSourceNode(#)', context);
AudioBuffer? buffer;
AudioBuffer? get buffer native;
set buffer(AudioBuffer? value) native;
AudioParam get detune native;
@ -817,7 +819,9 @@ class ConvolverNode extends AudioNode {
static ConvolverNode _create_2(context) =>
JS('ConvolverNode', 'new ConvolverNode(#)', context);
AudioBuffer? buffer;
AudioBuffer? get buffer native;
set buffer(AudioBuffer? value) native;
bool get normalize native;
@ -1288,7 +1292,9 @@ class WaveShaperNode extends AudioNode {
static WaveShaperNode _create_2(context) =>
JS('WaveShaperNode', 'new WaveShaperNode(#)', context);
Float32List? curve;
Float32List? get curve native;
set curve(Float32List? value) native;
String get oversample native;

View file

@ -839,7 +839,8 @@ class HtmlDartGenerator(object):
else:
template = '\n $TYPE get $NAME;\n'
else:
template = '\n $TYPE $NAME;\n'
template = '\n $TYPE get $NAME native;\n' \
'\n void set $NAME native;\n'
self._members_emitter.Emit(template, NAME=attr_name, TYPE=type_name)

View file

@ -20,16 +20,6 @@ HTML_LIBRARY_NAMES = [
'html', 'indexed_db', 'svg', 'web_audio', 'web_gl', 'web_sql'
]
# The following two sets let us avoid shadowing fields with properties.
# This information could be derived from the IDL files but would require
# a significant refactor to compute accurately. Instead we manually compute
# these sets based on manual triage of strong mode errors.
_force_property_members = monitored.Set('systemhtml._force_property_members', [
'Element.outerHtml',
'Element.isContentEditable',
'AudioContext.createGain',
'AudioContext.createScriptProcessor',
])
_safe_to_ignore_shadowing_members = monitored.Set(
'systemhtml._safe_to_ignore_shadowing_members', [
'SVGElement.tabIndex',
@ -1401,32 +1391,30 @@ class Dart2JSBackend(HtmlDartGenerator):
return
if IsPureInterface(self._interface.id, self._database):
self._AddInterfaceAttribute(attribute, html_name, read_only)
self._AddAttributeUsingProperties(attribute, html_name, read_only)
return
# If the attribute is shadowing, we can't generate a shadowing
# field (Issue 1633).
# getter or setter (Issue 1633).
# TODO(sra): _FindShadowedAttribute does not take into account the html
# renaming. we should be looking for another attribute that has the same
# html_name. Two attributes with the same IDL name might not match if one
# is renamed.
# renaming. We should be looking for another attribute that has the
# same html_name. Two attributes with the same IDL name might not match
# if one is renamed.
# TODO(srujzs): Determine if logic behind shadowing is still true here
# and below with the transition to natives.
(super_attribute,
super_attribute_interface) = self._FindShadowedAttribute(attribute)
if self._ForcePropertyMember(html_name):
self._members_emitter.Emit(
'\n // Using property as subclass shadows.')
self._AddAttributeUsingProperties(attribute, html_name, read_only)
return
if super_attribute:
if read_only or self._SafeToIgnoreShadowingMember(html_name):
if attribute.type.id == super_attribute.type.id:
# Compatible attribute, use the superclass property. This works
# because JavaScript will do its own dynamic dispatch.
# Compatible attribute, use the superclass property. This
# works because JavaScript will do its own dynamic dispatch.
self._members_emitter.Emit(
'\n'
' // Use implementation from $SUPER.\n'
' // final $TYPE $NAME;\n',
' // $TYPE get $NAME native;\n'
' // void set $NAME($TYPE value) native;\n',
SUPER=super_attribute_interface,
NAME=html_name,
TYPE=self.SecureOutputType(attribute.type.id,
@ -1438,9 +1426,10 @@ class Dart2JSBackend(HtmlDartGenerator):
return
# If the attribute is shadowed incompatibly in a subclass then we also
# can't just generate it as a field. In particular, this happens with
# DomMatrixReadOnly and its subclass DomMatrix. Force the superclass
# to generate getters. Hardcoding the known problem classes for now.
# can't just generate it as a getter/setter. In particular, this happens
# with DomMatrixReadOnly and its subclass DomMatrix. Force the
# superclass to generate getters. Hardcoding the known problem classes
# for now.
# TODO(alanknight): Fix this more generally.
if (self._interface.id == 'DOMMatrixReadOnly' or
self._interface.id == 'DOMPointReadOnly' or
@ -1465,24 +1454,12 @@ class Dart2JSBackend(HtmlDartGenerator):
input_type = self._NarrowInputType(attribute.type.id)
if self._nnbd and attribute.type.nullable:
input_type += '?'
static_attribute = 'static' if attribute.is_static else ''
if not read_only:
if self._nnbd and not attribute.type.nullable:
self._AddAttributeUsingProperties(attribute, html_name, read_only,
rename, metadata,
use_native=True)
return
if attribute.type.id == 'Promise':
_logger.warn('R/W member is a Promise: %s.%s' %
(self._interface.id, html_name))
template = '\n $RENAME$METADATA$STATIC $TYPE $NAME;\n'
self._members_emitter.Emit(
template,
RENAME=rename,
METADATA=metadata,
STATIC=static_attribute,
NAME=html_name,
TYPE=output_type)
self._AddAttributeUsingProperties(attribute, html_name, read_only,
rename, metadata)
else:
if attribute.type.id == 'Promise':
lookupOp = "%s.%s" % (self._interface.id, html_name)
@ -1529,71 +1506,48 @@ class Dart2JSBackend(HtmlDartGenerator):
template = (
'\n $RENAME$(ANNOTATIONS)$TYPE get $NAME => ' +
'JS("$TYPE", "#.$NAME", this);\n')
elif self._nnbd:
# Finals need to be transformed to getters/setters.
self._members_emitter.Emit(
template,
RENAME=rename,
ANNOTATIONS=metadata,
NAME=html_name,
TYPE=input_type
if output_type == 'double' else output_type)
else:
# Transform to native getters/setters.
# TODO(srujzs): Should the logic for types and doubles from
# above and before stay the same here?
self._AddAttributeUsingProperties(attribute, html_name,
read_only, rename, metadata, use_native=True)
return
self._members_emitter.Emit(
template,
RENAME=rename,
ANNOTATIONS=metadata,
STATIC=static_attribute,
NAME=html_name,
TYPE=input_type
if output_type == 'double' else output_type)
read_only, rename, metadata)
def _AddAttributeUsingProperties(self, attribute, html_name, read_only,
rename=None, metadata=None,
use_native=False):
self._AddRenamingGetter(attribute, html_name, rename, metadata,
use_native)
rename=None, metadata=None):
self._AddRenamingGetter(attribute, html_name, rename, metadata)
if not read_only:
# No metadata for setters.
self._AddRenamingSetter(attribute, html_name, rename, use_native)
self._AddRenamingSetter(attribute, html_name, rename)
def _AddInterfaceAttribute(self, attribute, html_name, read_only):
if read_only and self._nnbd:
self._AddAttributeUsingProperties(attribute, html_name, read_only,
use_native=True)
else:
self._members_emitter.Emit(
'\n $QUALIFIER$TYPE $NAME;'
'\n',
QUALIFIER='final ' if read_only else '',
NAME=html_name,
TYPE=self.SecureOutputType(attribute.type.id,
nullable=attribute.type.nullable))
def _AddRenamingGetter(self, attr, html_name, rename, metadata, use_native):
def _AddRenamingGetter(self, attr, html_name, rename, metadata):
conversion = self._OutputConversion(attr.type.id, attr.id)
if conversion:
return self._AddConvertingGetter(attr, html_name, conversion,
use_native)
return self._AddConvertingGetter(attr, html_name, conversion)
return_type = self.SecureOutputType(attr.type.id,
nullable=attr.type.nullable)
native_type = self._NarrowToImplementationType(attr.type.id)
if use_native:
getter = '\n $TYPE get $HTML_NAME native;'
else:
getter = '\n $TYPE get $HTML_NAME => JS("$NATIVE_TYPE", "#.$NAME", this);'
self._members_emitter.Emit(
'\n $RENAME'
'\n $METADATA' +
getter +
'\n $METADATA'
'\n $TYPE get $HTML_NAME native;'
'\n',
RENAME=rename if rename else '',
METADATA=metadata if metadata else '',
HTML_NAME=html_name,
NAME=attr.id,
TYPE=return_type,
NATIVE_TYPE=native_type)
TYPE=return_type)
def _AddRenamingSetter(self, attr, html_name, rename, use_native):
def _AddRenamingSetter(self, attr, html_name, rename):
conversion = self._InputConversion(attr.type.id, attr.id)
if conversion:
return self._AddConvertingSetter(attr, html_name, conversion,
use_native)
return self._AddConvertingSetter(attr, html_name, conversion)
nullable_type = attr.type.nullable
# If this attr has an output conversion, it is possible that there is a
# converting getter. We need to make sure the setter type matches the
@ -1601,27 +1555,15 @@ class Dart2JSBackend(HtmlDartGenerator):
conversion = self._OutputConversion(attr.type.id, attr.id)
if conversion and conversion.nullable_output:
nullable_type = True
if use_native:
setter = '\n set $HTML_NAME($TYPE value) native;'
else:
setter = '\n set $HTML_NAME($TYPE value) {' \
'\n JS("void", "#.$NAME = #", this, value);' \
'\n }'
self._members_emitter.Emit(
'\n $RENAME' +
setter +
'\n $RENAME'
'\n set $HTML_NAME($TYPE value) native;'
'\n',
RENAME=rename if rename else '',
HTML_NAME=html_name,
NAME=attr.id,
TYPE=self.SecureOutputType(attr.type.id, nullable=nullable_type))
def _AddConvertingGetter(self, attr, html_name, conversion, use_native):
# If using nnbd, we can't use finals, so opt for natives.
if use_native or self._nnbd:
getter = '\n $(JS_METADATA)$NATIVE_TYPE$NULLABLE_IN get _get_$HTML_NAME native;'
else:
getter = '\n $(JS_METADATA)final $NATIVE_TYPE _get_$HTML_NAME;'
def _AddConvertingGetter(self, attr, html_name, conversion):
nullable_out = conversion.nullable_output and \
not conversion.output_type == 'dynamic'
# If the attribute is nullable, the getter should be nullable.
@ -1630,8 +1572,8 @@ class Dart2JSBackend(HtmlDartGenerator):
self._members_emitter.Emit(
'\n $(METADATA)$RETURN_TYPE$NULLABLE_OUT get $HTML_NAME => '
'$CONVERT(this._get_$(HTML_NAME)$NULLASSERT);'
"\n @JSName('$NAME')" +
getter +
"\n @JSName('$NAME')"
'\n $(JS_METADATA)$NATIVE_TYPE$NULLABLE_IN get _get_$HTML_NAME native;'
'\n',
METADATA=self._metadata.GetFormattedMetadata(
self._library_name, self._interface, html_name, ' '),
@ -1648,23 +1590,20 @@ class Dart2JSBackend(HtmlDartGenerator):
NULLASSERT='!' if nullable_in and \
not conversion.nullable_input and self._nnbd else '')
def _AddConvertingSetter(self, attr, html_name, conversion, use_native):
def _AddConvertingSetter(self, attr, html_name, conversion):
# If the attribute is nullable, the setter should be nullable.
nullable_in = attr.type.nullable and \
not conversion.input_type == 'dynamic'
nullable_out = conversion.nullable_output and \
not conversion.output_type == 'dynamic'
if use_native:
setter = '\n set _set_$HTML_NAME(/*$NATIVE_TYPE$NULLABLE_OUT*/ value) native;'
else:
setter = '\n set _set_$HTML_NAME(/*$NATIVE_TYPE$NULLABLE_OUT*/ value) {' \
'\n JS("void", "#.$NAME = #", this, value);' \
'\n }'
self._members_emitter.Emit(
# TODO(sra): Use metadata to provide native name.
'\n set $HTML_NAME($INPUT_TYPE$NULLABLE_IN value) {'
'\n this._set_$HTML_NAME = $CONVERT(value$NULLASSERT);'
'\n }' +
setter +
'\n }'
'\n set _set_$HTML_NAME(/*$NATIVE_TYPE$NULLABLE_OUT*/ value) {'
'\n JS("void", "#.$NAME = #", this, value);'
'\n }'
'\n',
CONVERT=conversion.function_name,
HTML_NAME=html_name,
@ -2003,10 +1942,6 @@ class Dart2JSBackend(HtmlDartGenerator):
member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
return member_name in _js_custom_members
def _ForcePropertyMember(self, member_name):
member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
return member_name in _force_property_members
def _SafeToIgnoreShadowingMember(self, member_name):
member_name = '%s.%s' % (self._interface.doc_js_name, member_name)
return member_name in _safe_to_ignore_shadowing_members