forked from mirrors/gecko-dev
Generate helper function for C++ to perform operations on backing objects for each observable array attribute, - ElementAt: Get the item at that index. Throw error if fail to get the element. - ReplaceElementAt: Replace the item at the index, this will also trigger OnDelete and OnSet callback. Throw error if fail to replace the element. - AppendElement: Append one element to the end of the array, this will also trigger OnSet callback. Throw error if fail to append the element. - RemoveLastElement: Remove the element at the last index, this will also trigger OnDelete callback. Throw error if fail to remove the element. - Length: Get the number of the indexd value. Throw error if fail to get the length. Depends on D113728 Differential Revision: https://phabricator.services.mozilla.com/D113862
66 lines
2.3 KiB
Text
66 lines
2.3 KiB
Text
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
callback SetDeleteObjectCallback = void (object value, unsigned long index);
|
|
callback SetDeleteBooleanCallback = void (boolean value, unsigned long index);
|
|
callback SetDeleteInterfaceCallback = void (TestInterfaceObservableArray value, unsigned long index);
|
|
|
|
dictionary ObservableArrayCallbacks {
|
|
SetDeleteObjectCallback setObjectCallback;
|
|
SetDeleteObjectCallback deleteObjectCallback;
|
|
SetDeleteBooleanCallback setBooleanCallback;
|
|
SetDeleteBooleanCallback deleteBooleanCallback;
|
|
SetDeleteInterfaceCallback setInterfaceCallback;
|
|
SetDeleteInterfaceCallback deleteInterfaceCallback;
|
|
};
|
|
|
|
[Pref="dom.expose_test_interfaces",
|
|
Exposed=Window]
|
|
interface TestInterfaceObservableArray {
|
|
[Throws]
|
|
constructor(optional ObservableArrayCallbacks callbacks = {});
|
|
|
|
// Testing for ObservableArray
|
|
attribute ObservableArray<boolean> observableArrayBoolean;
|
|
attribute ObservableArray<object> observableArrayObject;
|
|
attribute ObservableArray<TestInterfaceObservableArray> observableArrayInterface;
|
|
|
|
// Tests for C++ helper function
|
|
[Throws]
|
|
boolean booleanElementAtInternal(unsigned long index);
|
|
[Throws]
|
|
TestInterfaceObservableArray interfaceElementAtInternal(unsigned long index);
|
|
[Throws]
|
|
object objectElementAtInternal(unsigned long index);
|
|
|
|
[Throws]
|
|
void booleanReplaceElementAtInternal(unsigned long index, boolean value);
|
|
[Throws]
|
|
void interfaceReplaceElementAtInternal(unsigned long index, TestInterfaceObservableArray value);
|
|
[Throws]
|
|
void objectReplaceElementAtInternal(unsigned long index, object value);
|
|
|
|
[Throws]
|
|
void booleanAppendElementInternal(boolean value);
|
|
[Throws]
|
|
void interfaceAppendElementInternal(TestInterfaceObservableArray value);
|
|
[Throws]
|
|
void objectAppendElementInternal(object value);
|
|
|
|
[Throws]
|
|
void booleanRemoveLastElementInternal();
|
|
[Throws]
|
|
void interfaceRemoveLastElementInternal();
|
|
[Throws]
|
|
void objectRemoveLastElementInternal();
|
|
|
|
[Throws]
|
|
unsigned long booleanLengthInternal();
|
|
[Throws]
|
|
unsigned long interfaceLengthInternal();
|
|
[Throws]
|
|
unsigned long objectLengthInternal();
|
|
};
|