1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests a variety of basic API definition features, ensuring things are parsed
// and processed as expected.
namespace idl_basics {
// Enum description
enum EnumType {
// comment1
name1,
name2
};
[nodoc] enum EnumTypeWithNoDoc {
name1,
name2
};
enum EnumTypeWithNoDocValue {
name1,
// comment2
[nodoc] name2,
// comment3
name3
};
dictionary MyType1 {
// This comment tests "double-quotes".
long x;
DOMString y;
DOMString z;
DOMString a;
DOMString b;
DOMString c;
};
dictionary MyType2 {
DOMString x;
};
dictionary ChoiceWithArraysType {
(DOMString or DOMString[]) entries;
};
dictionary ChoiceWithOptionalType {
(DOMString or DOMString[])? entries;
};
dictionary UnionType {
(EnumType or DOMString)? x;
(DOMString or EnumType) y;
};
[ignoreAdditionalProperties] dictionary IgnoreAdditionalPropertiesType {
DOMString x;
};
dictionary ManifestKeys {
// String manifest key.
DOMString key_str;
MyType2 key_ref;
(DOMString or long) inline_choice;
ChoiceWithArraysType choice_with_arrays;
ChoiceWithOptionalType choice_with_optional;
};
callback Callback1 = void();
callback Callback2 = void(long x);
callback Callback3 = void(MyType1 arg);
callback Callback4 = void(MyType2[] arg);
callback Callback5 = void(EnumType type);
callback OptionalArgCallback = void(optional DOMString arg0);
// A comment on a callback.
// |x|: A parameter.
callback Callback6 = void(long x);
// |x|: Just a parameter comment, with no comment on the callback.
callback Callback7 = void(long x);
interface Functions {
static void function1();
static void function2(long x);
// This comment should appear in the documentation,
// despite occupying multiple lines.
//
// |arg|: So should this comment
// about the argument.
// <em>HTML</em> is fine too.
static void function3(MyType1 arg);
// This tests if "double-quotes" are escaped correctly.
//
// It also tests a comment with two newlines.
static void function4(Callback1 cb);
static void function5(Callback2 cb);
static void function6(Callback3 cb);
static void function7(optional long arg);
static void function8(long arg1, optional DOMString arg2);
static void function9(optional MyType1 arg);
static void function10(long x, long[] y);
static void function11(MyType1[] arg);
static void function12(Callback4 cb);
static void function13(EnumType type, Callback5 cb);
static void function14(EnumType[] types);
// "switch" is a reserved word and should cause a C++ compile error if we
// emit code for this declaration.
[nocompile] static void function15(long switch);
static void function16(Callback6 cb);
static void function17(Callback7 cb);
// |cb|: Override callback comment.
static void function18(Callback7 cb);
static void function20(idl_other_namespace.SomeType value);
static void function21(idl_other_namespace.SomeType[] values);
static void function22(
idl_other_namespace.sub_namespace.AnotherType value);
static void function23(
idl_other_namespace.sub_namespace.AnotherType[] values);
static long function24();
static MyType1 function25();
static MyType1[] function26();
static EnumType function27();
static EnumType[] function28();
static idl_other_namespace.SomeType function29();
static idl_other_namespace.SomeType[] function30();
static void funcAsync(Callback4 cb);
[doesNotSupportPromises]
static void funcOptionalArgAndNotPromiseBased(OptionalArgCallback cb);
static void funcOptionalArgCallback(OptionalArgCallback cb);
[doesNotSupportPromises]
static void funcOptionalCallbackNotPromiseBased(optional Callback2 cb);
static void funcOptionalCallback(optional Callback2 cb);
static void funcWithEntry([instanceOf=Entry] object[] entries);
static void funcWithArrayObj(object[] entries);
};
interface Events {
static void onFoo1();
static void onFoo2(long x);
static void onFoo2(MyType1 arg);
static void onFoo3(EnumType type);
};
};
|