index.html
817 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Web IDL</title>
<meta name="revision" content="$Id: Overview.html,v 1.4 2011/09/27 12:55:09 schepers Exp $" />
<link rel="stylesheet" href="WebIDL.css" type="text/css" />
<script src="section-links.js" type="application/ecmascript"></script>
<script src="dfn.js" type="application/ecmascript"></script>
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-WD" type="text/css" /></head>
<body>
<div class="head"><div><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" width="72" height="48" alt="W3C" /></a></div><h1>Web IDL</h1><h2>W3C Working Draft <em>27 September 2011</em></h2><dl><dt>This Version:</dt><dd><a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/">http://www.w3.org/TR/2011/WD-WebIDL-20110927/</a></dd><dt>Latest Stable Version:</dt><dd><a href="http://www.w3.org/TR/WebIDL/">http://www.w3.org/TR/WebIDL/</a></dd><dt>Previous Version:</dt><dd><a href="http://www.w3.org/TR/2011/WD-WebIDL-20110712/">http://www.w3.org/TR/2011/WD-WebIDL-20110712/</a></dd><dt>Latest Editor’s Draft:</dt><dd><a href="http://dev.w3.org/2006/webapi/WebIDL/">http://dev.w3.org/2006/webapi/WebIDL/</a></dd><dt>Editor:</dt><dd><a href="http://mcc.id.au/">Cameron McCormack</a>, Mozilla Corporation <cam@mcc.id.au></dd></dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2011 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p></div><hr />
<div class="section">
<h2>Abstract</h2>
<p>
This document defines an interface definition language, Web IDL,
that can be used to describe interfaces that are intended to be
implemented in web browsers. Web IDL is an IDL variant with a
number of features that allow the behavior of common script objects in
the web platform to be specified more readily. How interfaces
described with Web IDL correspond to constructs within ECMAScript and
Java execution environments is also detailed in this document.
It is expected that this document acts
as a guide to implementors of already-published specifications,
and that newly published specifications reference this
document to ensure conforming implementations of interfaces
are interoperable.
</p>
<!-- XXX
Things to consider that aren't in ednotes:
* Consistent linking to term definitions.
* Consistent capitalisation and naming of algorithm variables.
Potential V2 features:
* Parameterized interface types, for BlahLists
http://www.w3.org/mid/op.vr2r6waf64w2qv@anne-van-kesterens-macbook-pro.local
-->
<!--
<?revision-note http://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=WebAppsWG&component=WebIDL&longdesc_type=allwordssubstr&longdesc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailtype1=substring&email1=&emailtype2=substring&email2=&bug_id_type=anyexact&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Importance&field0-0-0=noop&type0-0-0=noop&value0-0-0=?>
-->
</div>
<div class="section">
<h2>Status of This Document</h2>
<p><em>
This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list
of current W3C publications and the latest revision of this technical
report can be found in the <a href="http://www.w3.org/TR/">W3C technical
reports index</a> at http://www.w3.org/TR/.
</em></p><p>
This document is the 27 September 2011 <b>Last Call Working Draft</b> of the
<cite>Web IDL</cite> specification.
Please send comments about this document to
<a href="mailto:public-script-coord@w3.org">public-script-coord@w3.org</a>
(<a href="http://lists.w3.org/Archives/Public/public-script-coord/">archived</a>).
</p>
<p>
Comments on this Last Call Working Draft are welcome. This Last Call ends on
18 October 2011. The Working Group intends to progress this document to
Candidate Recommendation, but in the event of non-editorial changes being
made in response to Last Call comments,
another Last Call Working Draft will be published before
doing so. Despite this, the Working Group believes the document is ready
for wider review at this point.
</p>
<p>
This document is produced by the
<a href="http://www.w3.org/2008/webapps/">Web Applications Working Group</a>, part of the
<a href="http://www.w3.org/2006/rwc/Activity">Rich Web Clients Activity</a>
in the W3C <a href="http://www.w3.org/Interaction/">Interaction Domain</a>.
Changes made to this document can be found in the
<a href="http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml">W3C
public CVS server</a>.
</p>
<p>
In addition to the issues marked by editorial notes in this document,
there is a <a href="http://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=WebAppsWG&component=WebIDL&longdesc_type=allwordssubstr&longdesc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailtype1=substring&email1=&emailtype2=substring&email2=&bug_id_type=anyexact&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">list of open bugs</a>
on the specification. Comments from the <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110712/">12 July 2011 Last Call Working Draft</a> are tracked in the <a href="http://dev.w3.org/2006/webapi/WebIDL/lc1.txt">Web IDL LC#1 comment document</a>.
</p>
<p>
Publication as a Working Draft does not imply endorsement by the
W3C Membership. This is a draft document and may be updated, replaced
or obsoleted by other documents at any time. It is inappropriate to cite
this document as other than work in progress.
</p><p>
This document was produced by a group operating under the
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a
<a href="http://www.w3.org/2004/01/pp-impl/42538/status">public list of
any patent disclosures</a> made in connection with the deliverables of
the group; that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual
believes contains
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with
<a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.
</p>
</div>
<div id="toc">
<h2>Table of Contents</h2>
<div class="toc"><ul><li><a href="#introduction">1. Introduction</a><ul><li><a href="#conventions">1.1. Typographic conventions</a></li></ul></li><li><a href="#conformance">2. Conformance</a></li><li><a href="#idl">3. Interface definition language</a><ul><li><a href="#idl-names">3.1. Names</a></li><li><a href="#idl-modules">3.2. Modules</a></li><li><a href="#idl-interfaces">3.3. Interfaces</a><ul><li><a href="#idl-constants">3.3.1. Constants</a></li><li><a href="#idl-attributes">3.3.2. Attributes</a></li><li><a href="#idl-operations">3.3.3. Operations</a></li><li><a href="#idl-special-operations">3.3.4. Special operations</a><ul><li><a href="#idl-legacy-callers">3.3.4.1. Legacy callers</a></li><li><a href="#idl-stringifiers">3.3.4.2. Stringifiers</a></li><li><a href="#idl-indexed-properties">3.3.4.3. Indexed properties</a></li><li><a href="#idl-named-properties">3.3.4.4. Named properties</a></li></ul></li><li><a href="#idl-static-operations">3.3.5. Static operations</a></li><li><a href="#idl-overloading">3.3.6. Overloading</a></li></ul></li><li><a href="#idl-dictionaries">3.4. Dictionaries</a></li><li><a href="#idl-exceptions">3.5. Exceptions</a></li><li><a href="#idl-typedefs">3.6. Typedefs</a></li><li><a href="#idl-implements-statements">3.7. Implements statements</a></li><li><a href="#idl-objects">3.8. Objects implementing interfaces</a></li><li><a href="#idl-types">3.9. Types</a><ul><li><a href="#idl-any">3.9.1. any</a></li><li><a href="#idl-boolean">3.9.2. boolean</a></li><li><a href="#idl-byte">3.9.3. byte</a></li><li><a href="#idl-octet">3.9.4. octet</a></li><li><a href="#idl-short">3.9.5. short</a></li><li><a href="#idl-unsigned-short">3.9.6. unsigned short</a></li><li><a href="#idl-long">3.9.7. long</a></li><li><a href="#idl-unsigned-long">3.9.8. unsigned long</a></li><li><a href="#idl-long-long">3.9.9. long long</a></li><li><a href="#idl-unsigned-long-long">3.9.10. unsigned long long</a></li><li><a href="#idl-float">3.9.11. float</a></li><li><a href="#idl-double">3.9.12. double</a></li><li><a href="#idl-DOMString">3.9.13. DOMString</a></li><li><a href="#idl-object">3.9.14. object</a></li><li><a href="#idl-interface">3.9.15. Interface types</a></li><li><a href="#idl-dictionary">3.9.16. Dictionary types</a></li><li><a href="#idl-nullable-type">3.9.17. Nullable types — <var>T</var>?</a></li><li><a href="#idl-sequence">3.9.18. Sequences — sequence<<var>T</var>></a></li><li><a href="#idl-array">3.9.19. Arrays — <var>T</var>[]</a></li><li><a href="#idl-Date">3.9.20. Date</a></li></ul></li><li><a href="#idl-extended-attributes">3.10. Extended attributes</a><ul><li><a href="#Callback">3.10.1. [Callback]</a></li><li><a href="#Prefix">3.10.2. [Prefix]</a></li></ul></li></ul></li><li><a href="#ecmascript-binding">4. ECMAScript binding</a><ul><li><a href="#es-environment">4.1. ECMAScript environment</a></li><li><a href="#es-type-mapping">4.2. ECMAScript type mapping</a><ul><li><a href="#es-any">4.2.1. any</a></li><li><a href="#es-void">4.2.2. void</a></li><li><a href="#es-boolean">4.2.3. boolean</a></li><li><a href="#es-byte">4.2.4. byte</a></li><li><a href="#es-octet">4.2.5. octet</a></li><li><a href="#es-short">4.2.6. short</a></li><li><a href="#es-unsigned-short">4.2.7. unsigned short</a></li><li><a href="#es-long">4.2.8. long</a></li><li><a href="#es-unsigned-long">4.2.9. unsigned long</a></li><li><a href="#es-long-long">4.2.10. long long</a></li><li><a href="#es-unsigned-long-long">4.2.11. unsigned long long</a></li><li><a href="#es-float">4.2.12. float</a></li><li><a href="#es-double">4.2.13. double</a></li><li><a href="#es-DOMString">4.2.14. DOMString</a></li><li><a href="#es-object">4.2.15. object</a></li><li><a href="#es-interface">4.2.16. Interface types</a></li><li><a href="#es-dictionary">4.2.17. Dictionary types</a></li><li><a href="#es-nullable-type">4.2.18. Nullable types — <var>T</var>?</a></li><li><a href="#es-sequence">4.2.19. Sequences — sequence<<var>T</var>></a></li><li><a href="#es-array">4.2.20. Arrays — <var>T</var>[]</a><ul><li><a href="#platform-array-object-getownproperty">4.2.20.1. Platform array object [[GetOwnProperty]] method</a></li><li><a href="#platform-array-object-defineownproperty">4.2.20.2. Platform array object [[DefineOwnProperty]] method</a></li><li><a href="#platform-array-object-delete">4.2.20.3. Platform array object [[Delete]] method</a></li></ul></li><li><a href="#es-Date">4.2.21. Date</a></li></ul></li><li><a href="#es-extended-attributes">4.3. ECMAScript-specific extended attributes</a><ul><li><a href="#AllowAny">4.3.1. [AllowAny]</a></li><li><a href="#ArrayClass">4.3.2. [ArrayClass]</a></li><li><a href="#es-Callback">4.3.3. [Callback]</a></li><li><a href="#Clamp">4.3.4. [Clamp]</a></li><li><a href="#Constructor">4.3.5. [Constructor]</a></li><li><a href="#EnforceRange">4.3.6. [EnforceRange]</a></li><li><a href="#ImplicitThis">4.3.7. [ImplicitThis]</a></li><li><a href="#NamedConstructor">4.3.8. [NamedConstructor]</a></li><li><a href="#NamespaceObject">4.3.9. [NamespaceObject]</a></li><li><a href="#NoInterfaceObject">4.3.10. [NoInterfaceObject]</a></li><li><a href="#OverrideBuiltins">4.3.11. [OverrideBuiltins]</a></li><li><a href="#PutForwards">4.3.12. [PutForwards]</a></li><li><a href="#Replaceable">4.3.13. [Replaceable]</a></li><li><a href="#ReplaceableNamedProperties">4.3.14. [ReplaceableNamedProperties]</a></li><li><a href="#TreatNonCallableAsNull">4.3.15. [TreatNonCallableAsNull]</a></li><li><a href="#TreatNullAs">4.3.16. [TreatNullAs]</a></li><li><a href="#TreatUndefinedAs">4.3.17. [TreatUndefinedAs]</a></li><li><a href="#Unforgeable">4.3.18. [Unforgeable]</a></li></ul></li><li><a href="#es-modules">4.4. Modules</a></li><li><a href="#es-interfaces">4.5. Interfaces</a><ul><li><a href="#interface-object">4.5.1. Interface object</a><ul><li><a href="#es-interface-call">4.5.1.1. Interface object [[Call]] method</a></li></ul></li><li><a href="#named-constructors">4.5.2. Named constructors</a></li><li><a href="#interface-prototype-object">4.5.3. Interface prototype object</a></li><li><a href="#es-constants">4.5.4. Constants</a></li><li><a href="#es-attributes">4.5.5. Attributes</a></li><li><a href="#es-operations">4.5.6. Operations</a></li></ul></li><li><a href="#es-implements-statements">4.6. Implements statements</a></li><li><a href="#es-platform-objects">4.7. Platform objects implementing interfaces</a><ul><li><a href="#indexed-and-named-properties">4.7.1. Indexed and named properties</a></li><li><a href="#getownproperty">4.7.2. Platform object [[GetOwnProperty]] method</a></li><li><a href="#defineownproperty">4.7.3. Platform object [[DefineOwnProperty]] method</a></li><li><a href="#delete">4.7.4. Platform object [[Delete]] method</a></li><li><a href="#call">4.7.5. Platform object [[Call]] method</a></li><li><a href="#property-enumeration">4.7.6. Property enumeration</a></li></ul></li><li><a href="#es-user-objects">4.8. User objects implementing interfaces</a></li><li><a href="#es-exceptions">4.9. Exceptions</a><ul><li><a href="#es-exception-interface-object">4.9.1. Exception interface object</a><ul><li><a href="#es-exception-call">4.9.1.1. Exception interface object [[Call]] method</a></li></ul></li><li><a href="#es-exception-interface-prototype-object">4.9.2. Exception interface prototype object</a></li><li><a href="#es-exception-constants">4.9.3. Constants</a></li><li><a href="#es-exception-fields">4.9.4. Exception fields</a></li></ul></li><li><a href="#es-exception-objects">4.10. Exception objects</a></li><li><a href="#es-throwing-exceptions">4.11. Throwing exceptions</a></li><li><a href="#es-handling-exceptions">4.12. Handling exceptions</a></li></ul></li><li><a href="#java-binding">5. Java binding</a><ul><li><a href="#java-names">5.1. Names</a></li><li><a href="#java-type-mapping">5.2. Java type mapping</a><ul><li><a href="#java-any">5.2.1. any</a></li><li><a href="#java-void">5.2.2. void</a></li><li><a href="#java-boolean">5.2.3. boolean</a></li><li><a href="#java-byte">5.2.4. byte</a></li><li><a href="#java-octet">5.2.5. octet</a></li><li><a href="#java-short">5.2.6. short</a></li><li><a href="#java-unsigned-short">5.2.7. unsigned short</a></li><li><a href="#java-long">5.2.8. long</a></li><li><a href="#java-unsigned-long">5.2.9. unsigned long</a></li><li><a href="#java-long-long">5.2.10. long long</a></li><li><a href="#java-unsigned-long-long">5.2.11. unsigned long long</a></li><li><a href="#java-float">5.2.12. float</a></li><li><a href="#java-double">5.2.13. double</a></li><li><a href="#java-DOMString">5.2.14. DOMString</a></li><li><a href="#java-object">5.2.15. object</a></li><li><a href="#java-interface">5.2.16. Interface types</a></li><li><a href="#java-dictionary">5.2.17. Dictionary types</a></li><li><a href="#java-nullable-type">5.2.18. Nullable types — <var>T</var>?</a></li><li><a href="#java-sequence">5.2.19. Sequences — sequence<<var>T</var>></a></li><li><a href="#java-array">5.2.20. Arrays — <var>T</var>[]</a></li><li><a href="#java-Date">5.2.21. Date</a></li></ul></li><li><a href="#java-modules">5.3. Modules</a></li><li><a href="#java-interfaces">5.4. Interfaces</a><ul><li><a href="#java-constants">5.4.1. Constants</a></li><li><a href="#java-operations">5.4.2. Operations</a></li><li><a href="#java-attributes">5.4.3. Attributes</a></li></ul></li><li><a href="#java-platform-objects">5.5. Platform objects implementing interfaces</a></li><li><a href="#java-user-objects">5.6. User objects implementing interfaces</a></li><li><a href="#java-exceptions">5.7. Exceptions</a><ul><li><a href="#java-exception-constants">5.7.1. Constants</a></li><li><a href="#java-exception-fields">5.7.2. Exception fields</a></li></ul></li><li><a href="#java-exception-throwing">5.8. Throwing exceptions</a></li></ul></li><li><a href="#common">6. Common definitions</a><ul><li><a href="#common-DOMTimeStamp">6.1. DOMTimeStamp</a></li></ul></li><li><a href="#extensibility">7. Extensibility</a></li><li><a href="#referencing">8. Referencing this specification</a></li><li><a href="#acknowledgements">9. Acknowledgements</a></li></ul><ul><li><a href="#idl-grammar">A. IDL grammar</a></li><li><a href="#references">B. References</a><ul><li><a href="#normative-references">B.1. Normative references</a></li><li><a href="#informative-references">B.2. Informative references</a></li></ul></li><li><a href="#changes">C. Changes</a></li></ul></div>
</div>
<div id="sections">
<div id="introduction" class="section">
<h2>1. Introduction</h2>
<p class="norm">This section is informative.</p>
<p>
Technical reports published by the W3C that include programming
language interfaces have typically been described using the
Object Management Group’s Interface Definition Language (IDL)
<a href="#ref-OMGIDL">[OMGIDL]</a>. The IDL provides a means to
describe these interfaces in a language independent manner. Usually,
additional language binding appendices are included in such
documents which detail how the interfaces described with the IDL
correspond to constructs in the given language.
</p>
<p>
However, the bindings in these specifications for the language most
commonly used on the web, ECMAScript, are consistently specified with
low enough precision as to result in interoperability issues. In
addition, each specification must describe the same basic information,
such as DOM interfaces described in IDL corresponding to properties
on the ECMAScript global object, or the <a class="idltype" href="#idl-unsigned-long">unsigned
long</a> IDL type mapping to the <span class="estype">Number</span>
type in ECMAScript.
</p>
<p>
This specification defines an IDL language similar to OMG IDL
for use by specifications that define interfaces for Web APIs. A number of extensions are
given to the IDL to support common functionality that previously must
have been written in prose. In addition, precise language bindings
for ECMAScript 5th Edition and Java 5 are given.
</p>
<div id="conventions" class="section">
<h3>1.1. Typographic conventions</h3>
<p>
The following typographic conventions are used in this document:
</p>
<ul>
<li>Defining instances of terms: <dfn id="dfn-example-term">example term</dfn></li>
<li>Grammar symbols: <span class="sym">ExampleGrammarSymbol</span></li>
<li>IDL, ECMAScript and Java types: <span class="idltype">ExampleType</span></li>
<li>Code snippets: <code>a = b + obj.f()</code></li>
<li>Unicode characters: <span class="char">U+0030 DIGIT ZERO ("0")</span></li>
<li>Extended attributes: <span class="xattr">[ExampleExtendedAttribute]</span></li>
<li>Variable names in prose and algorithms: <var>exampleVariableName</var>.</li>
<li>IDL informal syntax examples:
<pre class="syntax">interface <i>identifier</i> {
<em>interface-members…</em>
};</pre>
(Red text is used to highlight specific parts of the syntax discussed in surrounding prose.)</li>
<li>IDL grammar snippets:
<table class="grammar">
<tr><td><span class="prod-number">[5]</span></td><td><span class="sym">ExampleGrammarSymbol</span></td><td class="prod-mid">→</td><td><span class="prod-lines">OtherSymbol "sometoken"<br /> | AnotherSymbol<br /> | ε <span class="comment">// nothing</span></span></td></tr>
</table>
(Each grammar rule is assigned a number for reference, shown on the left.)</li>
<li>Non-normative notes: <div class="note"><div class="noteHeader">Note</div><p>This is a note.</p></div></li>
<li>Non-normative examples: <div class="example"><div class="exampleHeader">Example</div><p>This is an example.</p></div></li>
<li>Code blocks: <div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code"><span class="comment">// This is an IDL code block.</span>
interface Example {
attribute long something;
};</code></pre></div></div>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code"><span class="comment">// This is an ECMAScript code block.</span>
window.onload = function() { window.alert("loaded"); };</code></pre></div></div></li>
</ul>
</div>
</div>
<div id="conformance" class="section">
<h2>2. Conformance</h2>
<p>
Everything in this specification is normative except for diagrams,
examples, notes and sections marked as being informative.
</p>
<p>
The keywords “<span class="rfc2119">MUST</span>”,
“<span class="rfc2119">MUST NOT</span>”,
“<span class="rfc2119">REQUIRED</span>”,
“<span class="rfc2119">SHALL</span>”,
“<span class="rfc2119">SHALL NOT</span>”,
“<span class="rfc2119">SHOULD</span>”,
“<span class="rfc2119">SHOULD NOT</span>”,
“<span class="rfc2119">RECOMMENDED</span>”,
“<span class="rfc2119">MAY</span>” and
“<span class="rfc2119">OPTIONAL</span>” in this document are to be
interpreted as described in
<cite><a href="http://tools.ietf.org/html/rfc2119">Key words for use in RFCs to
Indicate Requirement Levels</a></cite>
<a href="#ref-RFC2119">[RFC2119]</a>.
</p>
<p>
The following conformance classes are defined by this specification:
</p>
<dl>
<dt><dfn id="dfn-conforming-idl-fragment">conforming IDL fragment</dfn></dt>
<dd>
<p>
An <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> is considered
to be a <a class="dfnref" href="#dfn-conforming-idl-fragment">conforming
IDL fragment</a> if it satisfies all of the
<span class="rfc2119">MUST</span>-,
<span class="rfc2119">REQUIRED</span>- and <span class="rfc2119">SHALL</span>-level
criteria in this specification that apply to IDL fragments.
</p>
</dd>
<dt><dfn id="dfn-conforming-implementation">conforming implementation</dfn></dt>
<dd>
<p>
A user agent is considered to be a
<a class="dfnref" href="#dfn-conforming-implementation">conforming implementation</a>
relative to a <a class="dfnref" href="#dfn-conforming-idl-fragment">conforming
IDL fragment</a> if it satisfies all of the <span class="rfc2119">MUST</span>-,
<span class="rfc2119">REQUIRED</span>- and <span class="rfc2119">SHALL</span>-level
criteria in this specification that apply to implementations for all language
bindings that the user agent supports.
</p>
</dd>
<dt><dfn id="dfn-conforming-ecmascript-implementation">conforming ECMAScript implementation</dfn></dt>
<dd>
<p>
A user agent is considered to be a
<a class="dfnref" href="#dfn-conforming-ecmascript-implementation">conforming ECMAScript implementation</a>
relative to a <a class="dfnref" href="#dfn-conforming-idl-fragment">conforming
IDL fragment</a> if it satisfies all of the <span class="rfc2119">MUST</span>-,
<span class="rfc2119">REQUIRED</span>- and <span class="rfc2119">SHALL</span>-level
criteria in this specification that apply to implementations for the ECMAScript
language binding.
</p>
</dd>
<dt><dfn id="dfn-conforming-java-implementation">conforming Java implementation</dfn></dt>
<dd>
<p>
A user agent is considered to be a
<a class="dfnref" href="#dfn-conforming-java-implementation">conforming Java implementation</a>
relative to a <a class="dfnref" href="#dfn-conforming-idl-fragment">conforming
IDL fragment</a> if it satisfies all of the <span class="rfc2119">MUST</span>-,
<span class="rfc2119">REQUIRED</span>- and <span class="rfc2119">SHALL</span>-level
criteria in this specification that apply to implementations for the Java
language binding.
</p>
</dd>
</dl>
</div>
<div id="idl" class="section">
<h2>3. Interface definition language</h2>
<p>
This section describes a language, <em>Web IDL</em>, which can be used to define
interfaces for APIs in the Web platform. A specification that defines Web APIs
can include one or more <dfn id="dfn-idl-fragment">IDL fragments</dfn> that
describe the interfaces (the state and behavior that objects can exhibit)
for the APIs defined by that specification.
An <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> is
a sequence of definitions that matches the <a class="sym" href="#prod-Definitions">Definitions</a> grammar symbol.
The set of <a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a> that
an implementation supports is not ordered.
See <a href="#idl-grammar">Appendix A</a> for the complete grammar and an explanation of the notation used.
</p>
<p>
The different kinds of <dfn id="dfn-definition">definitions</dfn> that can appear in an
<a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> are:
<a class="dfnref" href="#dfn-module">modules</a>,
<a class="dfnref" href="#dfn-interface">interfaces</a>,
<a class="dfnref" href="#dfn-partial-interface">partial interface declarations</a>,
<a class="dfnref" href="#dfn-dictionary">dictionaries</a>,
<a class="dfnref" href="#dfn-exception">exceptions</a>,
<a class="dfnref" href="#dfn-typedef">typedefs</a> and
<a class="dfnref" href="#dfn-implements-statement">implements statements</a>.
These are all defined in the following sections.
</p>
<p>
Each <a class="dfnref" href="#dfn-definition">definition</a>
(matching <a class="sym" href="#prod-Definition">Definition</a>)
can be preceded by a list of <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a> (matching
<a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a>),
which can control how the definition will be handled in language bindings.
The extended attributes defined by this specification that are language binding
agnostic are discussed in <a href="#idl-extended-attributes">section 3.10</a>,
while those specific to the ECMAScript language binding are discussed
in <a href="#es-extended-attributes">section 4.3</a>.
</p>
<pre class="syntax">[<em>extended-attributes</em>]
interface <i>identifier</i> {
<i>interface-members…</i>
};</pre>
<p>
<a class="dfnref" href="#dfn-module">Modules</a>, described further in
<a href="#idl-modules">section 3.2</a> below,
are used to group related <a class="dfnref" href="#dfn-definition">definitions</a>
together in a single namespace. Definitions need not be placed in a module;
those that are not are said to be <dfn id="dfn-outermost-scope">declared at the outermost scope</dfn>.
</p>
<table class="grammar"><tr id="proddef-Definitions"><td><span class="prod-number">[1]</span></td><td><a class="sym" href="#prod-Definitions">Definitions</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Definition">Definition</a> <a class="sym" href="#prod-Definitions">Definitions</a> <br /> |
ε</span></td></tr><tr id="proddef-Definition"><td><span class="prod-number">[2]</span></td><td><a class="sym" href="#prod-Definition">Definition</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-NormalDefinition">NormalDefinition</a> <br /> |
<a class="sym" href="#prod-PartialInterface">PartialInterface</a></span></td></tr><tr id="proddef-NormalDefinition"><td><span class="prod-number">[3]</span></td><td><a class="sym" href="#prod-NormalDefinition">NormalDefinition</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Module">Module</a> <br /> |
<a class="sym" href="#prod-Interface">Interface</a> <br /> |
<a class="sym" href="#prod-Dictionary">Dictionary</a> <br /> |
<a class="sym" href="#prod-Exception">Exception</a> <br /> |
<a class="sym" href="#prod-Typedef">Typedef</a> <br /> |
<a class="sym" href="#prod-ImplementsStatement">ImplementsStatement</a></span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following is an example of an <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">module gfx {
exception GraphicsException {
DOMString reason;
};
interface Paint { };
interface SolidColor : Paint {
attribute float red;
attribute float green;
attribute float blue;
};
interface Pattern : Paint {
attribute DOMString imageURL;
};
[Constructor]
interface GraphicalWindow {
readonly attribute unsigned long width;
readonly attribute unsigned long height;
attribute Paint currentPaint;
void drawRectangle(float x, float y, float width, float height)<!--
raises(GraphicsException)-->;
void drawText(float x, float y, DOMString text)<!--
raises(GraphicsException)-->;
};
};</code></pre></div></div>
<p>
Here, four <a class="dfnref" href="#dfn-interface">interfaces</a> and one
<a class="dfnref" href="#dfn-exception">exception</a> are being defined.
The <span class="idltype">GraphicalWindow</span> interface has two
<a class="dfnref" href="#dfn-read-only">read only</a> <a class="dfnref" href="#dfn-attribute">attributes</a>,
one writable attribute, and two <a class="dfnref" href="#dfn-operation">operations</a>
defined on it. Objects that implement the <span class="idltype">GraphicalWindow</span> interface
will expose these attributes and operations in a manner appropriate to the
particular language being used.
</p>
<p>
Since the interfaces and the exception all appear inside a <a class="dfnref" href="#dfn-module">module</a>,
they are not <a class="dfnref" href="#dfn-outermost-scope">declared at the outermost scope</a>.
The module itself, however, is.
</p>
<p>
In ECMAScript, the attributes on the IDL interfaces will be exposed as accessor
properties and the operations as <span class="estype">Function</span>-valued
data properties on a prototype object for all <span class="idltype">GraphicalWindow</span>
objects; each ECMAScript object that implements <span class="idltype">GraphicalWindow</span>
will have that prototype object in its prototype chain.
</p>
<p>
In Java, there will exist a Java interface that corresponds to the IDL
<span class="idltype">GraphicalWindow</span> interface. This Java interface
will have methods that correspond to the operations, and getter and setter
methods that correspond to the attributes. Java objects that are considered
to implement the IDL <span class="idltype">GraphicalWindow</span> interface
will implement the corresponding Java interface.
</p>
<p>
The <a class="xattr" href="#Constructor">[Constructor]</a> that appears on <span class="idltype">GraphicalWindow</span>
is an <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
This extended attribute causes a constructor to exist in ECMAScript implementations,
so that calling <code>new GraphicalWindow()</code> would return a new object
that implemented the interface. The <a class="xattr" href="#Constructor">[Constructor]</a>
extended attribute has no effect in the Java language binding, however.
</p>
</div>
<div id="idl-names" class="section">
<h3>3.1. Names</h3>
<p>
Every <a class="dfnref" href="#dfn-module">module</a>,
<a class="dfnref" href="#dfn-interface">interface</a>,
<a class="dfnref" href="#dfn-partial-interface">partial interface definition</a>,
<a class="dfnref" href="#dfn-dictionary">dictionary</a>,
<a class="dfnref" href="#dfn-exception">exception</a> and
<a class="dfnref" href="#dfn-typedef">typedef</a> (together called <dfn id="dfn-named-definition">named definitions</dfn>)
and every <a class="dfnref" href="#dfn-constant">constant</a>,
<a class="dfnref" href="#dfn-attribute">attribute</a>,
<a class="dfnref" href="#dfn-exception-field">exception field</a>
and <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> has an
<dfn id="dfn-identifier">identifier</dfn>, as do some
<a class="dfnref" href="#dfn-operation">operations</a>.
The identifier is determined by an
<a class="sym" href="#prod-identifier">identifier</a> token somewhere
in the declaration:
</p>
<ul>
<li>
For <a class="dfnref" href="#dfn-named-definition">named definitions</a>,
the <a class="sym" href="#prod-identifier">identifier</a> token that appears
directly after the <code>module</code>, <code>interface</code>,
<code>dictionary</code> or <code>exception</code> keyword
determines the identifier of that definition.
<pre class="syntax">module <em>module-identifier</em> { <i>definitions…</i> };
interface <em>interface-identifier</em> { <i>interface-members…</i> };
partial interface <em>interface-identifier</em> { <i>interface-members…</i> };
exception <em>exception-identifier</em> { <i>exception-members…</i> };
dictionary <em>dictionary-identifier</em> { <i>dictionary-members…</i> };</pre>
</li>
<li>
For <a class="dfnref" href="#dfn-constant">constants</a>, <a class="dfnref" href="#dfn-attribute">attributes</a>,
<a class="dfnref" href="#dfn-typedef">typedefs</a>, <a class="dfnref" href="#dfn-exception-field">exception fields</a>
and <a class="dfnref" href="#dfn-dictionary-member">dictionary members</a>,
the final <a class="sym" href="#prod-identifier">identifier</a> token before the
semicolon at the end of the declaration determines the identifier.
<pre class="syntax">interface <i>identifier</i> {
const <i>type</i> <em>constant-identifier</em> = <i>value</i>;
attribute <i>type</i> <em>attribute-identifier</em>;
};
typedef <i>type</i> <em>typedef-identifier</em>;
exception <i>identifier</i> {
<i>type</i> <em>exception-member-identifier</em>;
};
dictionary <i>identifier</i> {
<i>type</i> <em>dictionary-member-identifier</em>;
};</pre>
</li>
<li>
For <a class="dfnref" href="#dfn-operation">operations</a>, the
<a class="sym" href="#prod-identifier">identifier</a> token that appears
after the return type but before the opening parenthesis (that is,
one that is matched as part of the <a class="sym" href="#prod-OptionalIdentifier">OptionalIdentifier</a>
grammar symbol in an <a class="sym" href="#prod-Operation">Operation</a>) determines the identifier of the operation. If
there is no such <a class="sym" href="#prod-identifier">identifier</a> token,
then the operation does not have an identifier.
<pre class="syntax"><i>return-type</i> <em>operation-identifier</em>(<i>arguments…</i>);</pre>
</li>
</ul>
<div class="note"><div class="noteHeader">Note</div>
<p>
Operations can have no identifier when they are being used to declare a
<a href="#idl-special-operations">special kind of operation</a>, such as a getter or setter.
</p>
</div>
<p>
For all of these constructs, the <a class="dfnref" href="#dfn-identifier">identifier</a>
is the value of the <a class="sym" href="#prod-identifier">identifier</a> token with any single leading
<span class="char">U+005F LOW LINE ("_")</span> character (underscore) removed.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
A leading <span class="char">"_"</span> is used to escape an identifier from looking
like a reserved word so that, for example, an interface named “interface” can be
defined. The leading <span class="char">"_"</span> is dropped to unescape the
identifier.
</p>
</div>
<p>
The <a class="dfnref" href="#dfn-identifier">identifier</a> of any of the abovementioned
IDL constructs <a class="rfc2119">MUST NOT</a>
be one of the <a id="dfn-reserved-identifier" class="sym">reserved identifiers</a>
“prototype”, “constructor”, “toString”
or begin with a <span class="char">U+005F LOW LINE ("_")</span> character.
</p>
<p>
Every <a class="dfnref" href="#dfn-named-definition">named definition</a>
also has a <dfn id="dfn-qualified-name">qualified name</dfn>, determined as follows:
</p>
<ul>
<li>
If the definition is
<a class="dfnref" href="#dfn-outermost-scope">declared at the outermost scope</a>,
then the qualified name
of the definition is two consecutive <span class="char">U+003A COLON (":")</span>
characters followed by the <a class="dfnref" href="#dfn-identifier">identifier</a>
of the definition. (Hereafter, two consecutive <span class="char">U+003A COLON (":")</span>
characters are referred to as a <dfn id="dfn-double-colon">double colon</dfn>.)
</li>
<li>
Otherwise, the definition is not declared at the outermost scope. The qualified name
of the definition is the qualified name
of the definition’s <a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>
followed by a <a class="dfnref" href="#dfn-double-colon">double colon</a>
followed by the identifier of the definition.
</li>
</ul>
<p>
Within the set of <a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a>
that a given implementation supports,
the <a class="dfnref" href="#dfn-qualified-name">qualified name</a> of every
<a class="dfnref" href="#dfn-module">module</a>,
<a class="dfnref" href="#dfn-interface">interface</a>,
<a class="dfnref" href="#dfn-dictionary">dictionary</a>,
<a class="dfnref" href="#dfn-exception">exception</a> and
<a class="dfnref" href="#dfn-typedef">typedef</a>
<span class="rfc2119">MUST NOT</span>
be the same as the qualified name of any other
<a class="dfnref" href="#dfn-interface">interface</a>,
<a class="dfnref" href="#dfn-dictionary">dictionary</a>,
<a class="dfnref" href="#dfn-exception">exception</a> or
<a class="dfnref" href="#dfn-typedef">typedef</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
Multiple <a class="dfnref" href="#dfn-module">module</a> declarations can
have the same <a class="dfnref" href="#dfn-qualified-name">qualified name</a>.
When a subsequent module declaration for the same qualified name
is encountered, this effectively re-opens the module for definitions.
See <a href="#idl-modules">section 3.2</a> below
for details.
</p>
</div>
<p>
A <dfn id="dfn-scoped-name">scoped name</dfn> (matching <a class="sym" href="#prod-ScopedName">ScopedName</a>)
is a string formed by concatenating a sequence of one or more identifiers with a
<a class="dfnref" href="#dfn-double-colon">double colon</a> between each pair of
adjacent identifiers, and is used in IDL to refer to definitions in other scopes.
A scoped name is an <dfn id="dfn-absolute-scoped-name">absolute scoped name</dfn>
if it begins with a <a class="dfnref" href="#dfn-double-colon">double colon</a>,
or a <dfn id="dfn-relative-scoped-name">relative scoped name</dfn> if it does not.
</p>
<p>
A scoped name can be <dfn id="dfn-resolve">resolved</dfn> (relative to a <a class="dfnref" href="#dfn-module">module</a>
or to the outermost scope) to a <a class="dfnref" href="#dfn-named-definition">named definition</a> as follows:
</p>
<ul>
<li>
If the scoped name is a
<a class="dfnref" href="#dfn-relative-scoped-name">relative scoped name</a>, then
the following steps gives the definition it resolves to:
<ol class="algorithm">
<li>
Let <var>name</var> be the <a class="dfnref" href="#dfn-qualified-name">qualified name</a>
of the <a class="dfnref" href="#dfn-module">module</a>, or the empty string if resolving
relative to the outermost scope.
</li>
<li>
Loop:
<ol>
<li>
If there is a <a class="dfnref" href="#dfn-definition">definition</a> whose
<a class="dfnref" href="#dfn-qualified-name">qualified name</a> is
equal to the concatenation of <var>name</var>, a
<a class="dfnref" href="#dfn-double-colon">double colon</a> and
the scoped name, then the scoped name resolves to that definition;
end these steps.
</li>
<li>
Remove the last name component from <var>name</var> (that is, from
the last <a class="dfnref" href="#dfn-double-colon">double colon</a>
to the end of the string, inclusive).
</li>
</ol>
until <var>name</var> is the empty string.
</li>
<li>
The scoped name does not resolve to a definition.
</li>
</ol>
</li>
<li>
Otherwise, the scoped name is an
<a href="#dfn-absolute-scoped-name">absolute scoped name</a>:
<ul>
<li>
If there exists a definition whose qualified name is
equal to the scoped name, then the scoped name resolves to that definition.
</li>
<li>
Otherwise, the scoped name does not resolve to a definition.
</li>
</ul>
</li>
</ul>
<p>
Unless otherwise stated, the <a class="dfnref" href="#dfn-module">module</a>
being used to <a class="dfnref" href="#dfn-resolve">resolve</a> a
<a class="dfnref" href="#dfn-scoped-name">scoped name</a> is the
<a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>
of the <a class="dfnref" href="#dfn-definition">definition</a>
on which the scoped name appears, or the outermost scope if it appears
on a definition <a class="dfnref" href="#dfn-outermost-scope">declared at the outermost scope</a>.
</p>
<p>
Within an <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>, a reference
to a <a class="dfnref" href="#dfn-definition">definition</a> need not appear after
the declaration of the referenced definition. References can also be made
across <a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a>.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>Therefore, the following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> is valid:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface B : A {
void f(ArrayOfLongs x);
};
interface A {
};
typedef long[] ArrayOfLongs;</code></pre></div></div>
</div>
<table class="grammar"><tr id="proddef-ScopedName"><td><span class="prod-number">[58]</span></td><td><a class="sym" href="#prod-ScopedName">ScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-AbsoluteScopedName">AbsoluteScopedName</a> <br /> |
<a class="sym" href="#prod-RelativeScopedName">RelativeScopedName</a></span></td></tr><tr id="proddef-AbsoluteScopedName"><td><span class="prod-number">[59]</span></td><td><a class="sym" href="#prod-AbsoluteScopedName">AbsoluteScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"::" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a></span></td></tr><tr id="proddef-RelativeScopedName"><td><span class="prod-number">[60]</span></td><td><a class="sym" href="#prod-RelativeScopedName">RelativeScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a></span></td></tr><tr id="proddef-ScopedNameParts"><td><span class="prod-number">[61]</span></td><td><a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"::" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a> <br /> |
ε</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
demonstrates how <a class="dfnref" href="#dfn-identifier">identifiers</a>
and <a class="dfnref" href="#dfn-qualified-name">qualified names</a> are given
to definitions, <a class="dfnref" href="#dfn-interface-member">interface members</a>
and <a class="dfnref" href="#dfn-exception-member">exception members</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code"><span class="comment">// Module identifier: "framework"</span>
<span class="comment">// Qualified name: "::framework"</span>
module framework {
<span class="comment">// Typedef identifier: "number"</span>
<span class="comment">// Qualified name: "::framework::number"</span>
typedef float number;
<span class="comment">// Exception identifier: "FrameworkException"</span>
<span class="comment">// Qualified name: "::framework::FrameworkException"</span>
exception FrameworkException {
<span class="comment">// Constant identifier: "ERR_NOT_FOUND"</span>
<span class="comment">// Qualified name: "::framework::FrameworkException::ERR_NOT_FOUND"</span>
const long ERR_NOT_FOUND = 1;
<span class="comment">// Exception field identifier: "code"</span>
long code;
};
<span class="comment">// Interface identifier: "System"</span>
<span class="comment">// Qualified name: "::framework::System"</span>
interface System {
<span class="comment">// Operation identifier: "createObject"</span>
<span class="comment">// Operation argument identifier: "interface"</span>
object createObject(DOMString _interface);
<span class="comment">// Operation has no identifier; it declares a getter.</span>
getter DOMString (DOMString keyName);
};
<span class="comment">// Module identifier: "gui"</span>
<span class="comment">// Qualified name: "::framework::gui"</span>
module gui {
<span class="comment">// Interface identifier: "TextField"</span>
<span class="comment">// Qualified name: "::framework::gui::TextField"</span>
interface TextField {
<span class="comment">// Attribute identifier: "const"</span>
attribute boolean _const;
<span class="comment">// Attribute identifier: "value"</span>
attribute DOMString? _value;
};
};
};</code></pre></div></div>
<p>
Note that while the second <a class="dfnref" href="#dfn-attribute">attribute</a>
on the <span class="idltype">TextField</span> <a class="dfnref" href="#dfn-interface">interface</a>
need not have been escaped with an underscore (because “value” is
not a keyword in the IDL grammar), it is still unescaped
to obtain the attribute’s <a class="dfnref" href="#dfn-identifier">identifier</a>.
</p>
<p>
Also note that the <a class="dfnref" href="#dfn-exception-field">exception fields</a>,
<a class="dfnref" href="#dfn-operation">operations</a> and
<a class="dfnref" href="#dfn-attribute">attributes</a> above do not have
<a class="dfnref" href="#dfn-qualified-name">qualified names</a>, simply because
there is no need to be able to reference them from other scopes.
</p>
</div>
</div>
<div id="idl-modules" class="section">
<h3>3.2. Modules</h3>
<div class="ednote"><div class="ednoteHeader">Editorial note</div>
<p>Should W3C specs use modules at all? And if not, should we just remove them?
<a href="http://lists.w3.org/Archives/Public/public-webapps/2009JulSep/0282.html">(Mail.)</a></p>
</div>
<p>
A <dfn id="dfn-module">module</dfn> is a <a class="dfnref" href="#dfn-definition">definition</a>
(matching <a class="sym" href="#prod-Module">Module</a>) that serves
as a container for grouping together related definitions in a single namespace.
</p>
<pre class="syntax">module <i>identifier</i> {
<i>definitions…</i>
};</pre>
<p>
Definitions have as their <dfn id="dfn-enclosing-module">enclosing module</dfn>
the module inside which they appear in the IDL.
If <a class="dfnref" href="#dfn-outermost-scope">declared at the outermost scope</a>,
a definition has no enclosing module.
</p>
<p>
The relevant language binding determines how modules affect the naming
of constructs that correspond to definitions in the language. If the language
supports some form of namespacing mechanism, then a module will correspond
to a namespace. The name of that namespace can be based on the module’s
<dfn id="dfn-prefixed-name">prefixed name</dfn>, which is defined as
follows:
</p>
<ul>
<li>
If the <a class="dfnref" href="#dfn-module">module</a> has a
<a class="xattr" href="#Prefix">[Prefix]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
whose argument starts with a <a class="dfnref" href="#dfn-double-colon">double colon</a>, then the
<a class="dfnref" href="#dfn-prefixed-name">prefixed name</a> of
the module is a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>
constructed by concatenating the <a class="xattr" href="#Prefix">[Prefix]</a>
argument, a <a class="dfnref" href="#dfn-double-colon">double colon</a>
and the module’s <a class="dfnref" href="#dfn-identifier">identifier</a>.
</li>
<li>
Otherwise, if the <a class="dfnref" href="#dfn-module">module</a> has a
<a class="xattr" href="#Prefix">[Prefix]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
whose argument does not start with a <a class="dfnref" href="#dfn-double-colon">double colon</a>, then the
<a class="dfnref" href="#dfn-prefixed-name">prefixed name</a> of
the module is a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>
constructed by concatenating:
<ol>
<li>the <a class="dfnref" href="#dfn-prefixed-name">prefixed name</a>
of the module’s <a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>
followed by a <a class="dfnref" href="#dfn-double-colon">double colon</a>, or
simply a <a class="dfnref" href="#dfn-double-colon">double colon</a> if there
is no enclosing module,</li>
<li>the <a class="xattr" href="#Prefix">[Prefix]</a> argument,</li>
<li>a <a class="dfnref" href="#dfn-double-colon">double colon</a>,</li>
<li>and the module’s <a class="dfnref" href="#dfn-identifier">identifier</a>.</li>
</ol>
</li>
<li>
Otherwise, if the <a class="dfnref" href="#dfn-qualified-name">qualified name</a>
of the <a class="dfnref" href="#dfn-module">module</a> is “::dom”, then
the <a class="dfnref" href="#dfn-prefixed-name">prefixed name</a> of the
module is the <a class="dfnref" href="#dfn-scoped-name">scoped name</a>
“::org::w3c::dom”.
</li>
<li>
Otherwise, if the <a class="dfnref" href="#dfn-module">module</a> has
no <a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>,
then the <a class="dfnref" href="#dfn-prefixed-name">prefixed name</a> of the
module is a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>
constructed by concatenating the string “::org::w3c::dom::” and the
module’s <a class="dfnref" href="#dfn-identifier">identifier</a>.
</li>
<li>
Otherwise, the <a class="dfnref" href="#dfn-prefixed-name">prefixed name</a>
of the module is a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>
constructed by concatenating the prefixed name of the module’s
<a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>,
a <a class="dfnref" href="#dfn-double-colon">double colon</a>
and the module’s <a class="dfnref" href="#dfn-identifier">identifier</a>.
</li>
</ul>
<p>
In the Java language binding, the name of the Java package is
derived by taking the <a class="dfnref" href="#dfn-prefixed-name">prefixed name</a>
and replacing all <a class="dfnref" href="#dfn-double-colon">double colons</a>
with “.” (see <a href="#java-modules">section 5.3</a>).
It is expected that bindings for other languages that typically
use reversed domain names for namespacing will also use the prefixed
name of a module to determine namespace names.
</p>
<p>
The ECMAScript language binding allows a namespacing mechanism based
on the <a class="dfnref" href="#dfn-scoped-name">scoped name</a>
of a module by using the <a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
</p>
<p>
The following <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
are applicable to <a class="dfnref" href="#dfn-module">modules</a>:
<a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>,
<a class="xattr" href="#Prefix">[Prefix]</a>.
</p>
<table class="grammar"><tr id="proddef-Module"><td><span class="prod-number">[4]</span></td><td><a class="sym" href="#prod-Module">Module</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"module" <a class="sym" href="#prod-identifier">identifier</a> "{" <a class="sym" href="#prod-Definitions">Definitions</a> "}" ";"</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
illustrates how related <a class="dfnref" href="#dfn-interface">interfaces</a>
can be grouped together in <a class="dfnref" href="#dfn-module">modules</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">module gfx {
module geom {
interface Shape { <span class="comment">/* ... */</span> };
interface Rectangle : Shape { <span class="comment">/* ... */</span> };
interface Path : Shape { <span class="comment">/* ... */</span> };
};
interface GraphicsContext {
void fillShape(geom::Shape s);
void strokeShape(geom::Shape s);
};
};
module gui {
interface Widget { <span class="comment">/* ... */</span> };
interface Window : Widget {
gfx::GraphicsContext getGraphicsContext();
};
interface Button : Widget { <span class="comment">/* ... */</span> };
};</code></pre></div></div>
</div>
</div>
<div id="idl-interfaces" class="section">
<h3>3.3. Interfaces</h3>
<p>
<a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a> are used to
describe object oriented systems. In such systems, objects are entities
that have identity and which are encapsulations of state and behavior.
An <dfn id="dfn-interface">interface</dfn> is a definition (matching
<a class="sym" href="#prod-Interface">Interface</a>) that declares some
state and behavior that an object implementing that interface will expose.
</p>
<pre class="syntax">interface <i>identifier</i> {
<i>interface-members…</i>
};</pre>
<p>
An interface is a specification of a set of
<dfn id="dfn-interface-member">interface members</dfn>
(matching <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a>),
which are the <a class="dfnref" href="#dfn-constant">constants</a>,
<a class="dfnref" href="#dfn-attribute">attributes</a> and
<a class="dfnref" href="#dfn-operation">operations</a>
that appear between the braces in the interface declaration.
Attributes describe the state that an object
implementing the interface will expose, and operations describe the
behaviors that can be invoked on the object. Constants declare
named constant values that are exposed as a convenience to users
of objects in the system.
</p>
<p>
Interfaces in Web IDL describe how objects that implement the
interface behave. In bindings for object oriented languages, it is
expected that an object that implements a particular IDL interface
provides ways to inspect and modify the object's state and to
invoke the behavior described by the interface.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
In the Java language binding, for example, this is achieved by having the
object implement a Java interface that has methods for reading and
writing attribute values and to invoke an operation.
</p>
</div>
<p>
An interface can be defined to <dfn id="dfn-inherit">inherit</dfn> from another interface.
If the identifier of the interface is followed by a
<span class="char">U+003A COLON (":")</span> character
and a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>,
then that scoped name identifies the inherited interface. The scoped name
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-resolve">resolve</a> to
a different interface. An object that implements an interface that inherits from another
also implements that inherited interface. The object therefore will also
have members that correspond to the interface members from the inherited interface.
</p>
<pre class="syntax">interface <i>identifier</i> : <em>scoped-name-of-inherited-interface</em> {
<i>interface-members…</i>
};</pre>
<p>
The order that members appear in has no significance.
</p>
<p>
Interfaces may specify an interface member that has the same name as
one from an inherited interface. Objects that implement the derived
interface will expose the member on the derived interface. It is
language binding specific whether the overridden member can be
accessed on the object.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
Consider the following two interfaces.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
void f();
void g();
};
interface B : A {
void f();
void g(DOMString x);
};</code></pre></div></div>
<p>
In the ECMAScript language binding, an instance of <span class="idltype">B</span>
will have a prototype chain that looks like the following:
</p>
<pre> [Object.prototype: the Object prototype object]
↑
[A.prototype: interface prototype object for A]
↑
[B.prototype: interface prototype object for B]
↑
[instanceOfB]</pre>
<p>
Calling <code>instanceOfB.f()</code> in ECMAScript will invoke the f defined
on <span class="idltype">B</span>. However, the f from <span class="idltype">A</span>
can still be invoked on an object that implements <span class="idltype">B</span> by
calling <code>A.prototype.f.call(instanceOfB)</code>.
</p>
<p>
In the Java language binding, the two IDL interfaces will correspond to
the following Java interfaces:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">public interface A {
void f();
void g();
}
public interface B extends A {
void f();
void g(String x);
}</code></pre></div></div>
<p>
Calling <code>instanceOfB.f()</code> in Java will invoke
the f defined on <span class="idltype">B</span>. Due to
the way method overriding is defined in Java, there is no
way to call the f defined on <span class="idltype">A</span>
on an object that implements <span class="idltype">B</span>.
Since the signature of g is different in <span class="idltype">A</span>
and <span class="idltype">B</span>, however, both can be called
with, for example, <code>instanceOfB.g()</code> and
<code>instanceOfB.g("")</code>.
</p>
<p>
In both languages, the f and g from the derived interface
<span class="idltype">B</span> are always accessible.
</p>
</div>
<p>
The <dfn id="dfn-inherited-interfaces">inherited interfaces</dfn> of
a given interface <var>A</var> is the set of all interfaces that <var>A</var>
inherits from, directly or indirectly. If <var>A</var> does not <a class="dfnref" href="#dfn-inherit">inherit</a>
from another interface, then the set is empty. Otherwise, the set
includes the interface <var>B</var> that <var>A</var> <a class="dfnref" href="#dfn-inherit-dictionary">inherits</a>
from and all of <var>B</var>’s <a class="dfnref" href="#dfn-inherited-interfaces">inherited interfaces</a>.
</p>
<p>
An interface <span class="rfc2119">MUST NOT</span> be declared such that
its inheritance hierarchy has a cycle. That is, an interface
<var>A</var> cannot inherit from itself, nor can it inherit from another
interface <var>B</var> that inherits from <var>A</var>, and so on.
</p>
<p>
Note that general multiple inheritance of interfaces is not supported, and
objects also cannot implement arbitrary sets of interfaces.
Objects can be defined to implement a single given interface <var>A</var>,
which means that it also implements all of <var>A</var>’s
<a class="dfnref" href="#dfn-inherited-interfaces">inherited interfaces</a>. In addition,
an <a href="#idl-implements-statements">implements statement</a> can be
used to define that objects implementing an interface will always
also implement another interface.
</p>
<p>
Each interface member can be preceded by a list of <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a> (matching
<a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a>),
which can control how the interface member will be handled in language bindings.
</p>
<pre class="syntax">interface <i>identifier</i> {
[<em>extended-attributes</em>]
const <i>type</i> <i>identifier</i> = <i>value</i>;
[<em>extended-attributes</em>]
attribute <i>type</i> <i>identifier</i>;
[<em>extended-attributes</em>]
<i>return-type</i> <i>identifier</i>(<i>arguments…</i>);
};</pre>
<p>
The IDL for interfaces can be split into multiple parts by using
<dfn id="dfn-partial-interface">partial interface</dfn> definitions
(matching <a class="sym" href="#prod-PartialInterface">PartialInterface</a>).
The <a class="dfnref" href="#dfn-identifier">identifier</a> of a partial
interface definition <span class="rfc2119">MUST</span> be the same
as the identifier of an interface definition in the same module. All of
the members that appear on each of the partial interfaces are considered to be
members of the interface itself.
</p>
<pre class="syntax">interface <em>SomeInterface</em> {
<i>interface-members…</i>
};
partial interface <em>SomeInterface</em> {
<i>interface-members…</i>
};</pre>
<p>
The order of apperance of an <a class="dfnref" href="#dfn-interface">interface</a>
definition and any of its <a class="dfnref" href="#dfn-partial-interface">partial interface</a>
definitions within a single <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
does not matter.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>Partial interface definitions are intended for use as a specification
editorial aide, allowing the definition of an interface to be separated
over more than one section of the document, and sometimes multiple documents.</p>
</div>
<p>
The relevant language binding determines how interfaces correspond to constructs
in the language.
</p>
<!--
<p>
An <dfn id='dfn-interface-forward-declaration'>interface forward declaration</dfn>
is a definition that matches the <a class='sym' href='#prod-Interface'>Interface</a> non-terminal
whose <a class='sym' href='#prod-InterfaceBody'>InterfaceBody</a> is empty
(that is, <a class='sym' href='#prod-InterfaceBody'>InterfaceBody</a> ⇒ ε). A forward declaration
is used to introduce an interface name to allow for the definition of mutually
recursive interfaces, since scoped names
need to resolve to types that have been
<a class='dfnref' href='#dfn-declared-previously'>declared previously</a>.
</p>
-->
<p>
The following extended attributes are applicable to interfaces:
<a class="xattr" href="#ArrayClass">[ArrayClass]</a>,
<a class="xattr" href="#Callback">[Callback]</a>,
<a class="xattr" href="#Constructor">[Constructor]</a>,
<a class="xattr" href="#ImplicitThis">[ImplicitThis]</a>,
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>,
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>,
<a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>,
<a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a>.
</p>
<!--
<?productions grammar Interface PartialInterface Inheritance InterfaceMembers InterfaceMember ScopedNameList ScopedNames?>
-->
<table class="grammar"><tr id="proddef-Interface"><td><span class="prod-number">[5]</span></td><td><a class="sym" href="#prod-Interface">Interface</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"interface" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-Inheritance">Inheritance</a> "{" <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a> "}" ";"</span></td></tr><tr id="proddef-PartialInterface"><td><span class="prod-number">[6]</span></td><td><a class="sym" href="#prod-PartialInterface">PartialInterface</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"partial" "interface" <a class="sym" href="#prod-identifier">identifier</a> "{" <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a> "}" ";"</span></td></tr><tr id="proddef-Inheritance"><td><span class="prod-number">[7]</span></td><td><a class="sym" href="#prod-Inheritance">Inheritance</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">":" <a class="sym" href="#prod-ScopedName">ScopedName</a> <br /> |
ε</span></td></tr><tr id="proddef-InterfaceMembers"><td><span class="prod-number">[8]</span></td><td><a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-InterfaceMember">InterfaceMember</a> <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a> <br /> |
ε</span></td></tr><tr id="proddef-InterfaceMember"><td><span class="prod-number">[9]</span></td><td><a class="sym" href="#prod-InterfaceMember">InterfaceMember</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Const">Const</a> <br /> |
<a class="sym" href="#prod-AttributeOrOperation">AttributeOrOperation</a></span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<!--
<p>
The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a>
demonstrates the use of an
<a class='dfnref' href='#dfn-interface-forward-declaration'>interface forward declaration</a>
to allow the definition of mutually referential <a class='dfnref' href='#dfn-interface'>interfaces</a>.
Both <span class='idltype'>Human</span> and <span class='idltype'>Dog</span>
inherit from <span class='idltype'>Animal</span>. Objects that implement
either of those two interfaces will thus have a <code>name</code> attribute.
</p>
-->
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
demonstrates the definition of two mutually referential <a class="dfnref" href="#dfn-interface">interfaces</a>.
Both <span class="idltype">Human</span> and <span class="idltype">Dog</span>
inherit from <span class="idltype">Animal</span>. Objects that implement
either of those two interfaces will thus have a <code>name</code> attribute.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Animal {
attribute DOMString name;
};
interface Human : Animal {
attribute Dog? pet;
};
interface Dog : Animal {
attribute Human? owner;
};</code></pre></div></div>
</div>
<div id="idl-constants" class="section">
<h4>3.3.1. Constants</h4>
<p>
A <dfn id="dfn-constant">constant</dfn> is a declaration (matching
<a class="sym" href="#prod-Const">Const</a>) used to bind a constant value to a name.
Constants can appear on <a class="dfnref" href="#dfn-interface">interfaces</a> and
<a class="dfnref" href="#dfn-exception">exceptions</a>.
</p>
<pre class="syntax">const <i>type</i> <i>identifier</i> = <i>value</i>;</pre>
<p>
The <a class="dfnref" href="#dfn-identifier">identifier</a> of a
<a class="dfnref" href="#dfn-constant">constant</a>
<span class="rfc2119">MUST NOT</span> be the same as the identifier
of another <a class="dfnref" href="#dfn-interface-member">interface member</a>
defined on the same interface
or another <a class="dfnref" href="#dfn-exception-member">exception member</a>
defined on the same exception.
</p>
<p>
The <a class="sym" href="#prod-ConstValue">ConstValue</a> part of a
constant declaration (or <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a>
declaration) gives the value of the constant (or the default value of the dictionary member), which can be
one of the two boolean literal tokens (<code>true</code>
and <code>false</code>),
the <code>null</code> token, an
<a class="sym" href="#prod-integer">integer</a> token, a
<a class="sym" href="#prod-float">float</a> token or a
<a class="sym" href="#prod-string">string</a> token.
</p>
<p>
The value of the boolean literal tokens <code>true</code> and
<code>false</code> are the IDL <a class="idltype" href="#idl-boolean">boolean</a> values
<span class="idlvalue">true</span> and <span class="idlvalue">false</span>.
</p>
<p>
The value of an <a class="sym" href="#prod-integer">integer</a> token is an integer
whose value is determined as follows:
</p>
<ol class="algorithm">
<li>Let <var>S</var> be the sequence of characters matched by the <a class="sym" href="#prod-integer">integer</a> token.</li>
<li>Let <var>sign</var> be −1 if <var>S</var> begins with <span class="char">U+002D HYPHEN-MINUS ("-")</span>, and 1 otherwise.</li>
<li>Let <var>base</var> be the base of the number based on the characters that follow the optional leading <span class="char">U+002D HYPHEN-MINUS ("-")</span> character:
<dl class="switch">
<dt><span class="char">U+0030 DIGIT ZERO ("0")</span>, <span class="char">U+0058 LATIN CAPITAL LETTER X ("X")</span></dt>
<dt><span class="char">U+0030 DIGIT ZERO ("0")</span>, <span class="char">U+0078 LATIN SMALL LETTER X ("x")</span></dt>
<dd>The base is 16.</dd>
<dt><span class="char">U+0030 DIGIT ZERO ("0")</span></dt>
<dd>The base is 8.</dd>
<dt><span class="char">Otherwise</span></dt>
<dd>The base is 10.</dd>
</dl>
</li>
<li>Let <var>number</var> be the result of interpreting all remaining characters following the optional leading <span class="char">U+002D HYPHEN-MINUS ("-")</span>
character and any characters indicating the base as an integer specified in base <var>base</var>.</li>
<li>Return <var>sign</var> × <var>number</var>.</li>
</ol>
<p>
The type of an <a class="sym" href="#prod-integer">integer</a> token is the same
as the type of the constant or dictionary member it is being used as the value of.
The value of the <a class="sym" href="#prod-integer">integer</a> token <span class="rfc2119">MUST NOT</span>
lie outside the valid range of values for its type, as given in
<a href="#idl-types">section 3.9</a> below.
</p>
<p id="float-token-value">
The value of a <a class="sym" href="#prod-float">float</a> token is
either an IEEE 754 single-precision floating point number or an IEEE 754
double-precision floating point number, depending on the type of the
constant or dictionary member it is being used as the value for, determined as follows:
</p>
<ol class="algorithm">
<li>Let <var>S</var> be the sequence of characters matched by the <a class="sym" href="#prod-float">float</a> token.</li>
<li>Let <var>value</var> be the Mathematical Value that would be obtained if <var>S</var> were
parsed as an ECMAScript <em>NumericLiteral</em> (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 7.8.3).</li>
<li>
If the <a class="sym" href="#prod-float">float</a> token is being
used as the value for a <a class="idltype" href="#idl-float">float</a>, then
the value of the <a class="sym" href="#prod-float">float</a> token
is the IEEE 754 single-precision floating point number closest to
<var>result</var>. Otherwise, the <a class="sym" href="#prod-float">float</a> token is being
used as the value for a <a class="idltype" href="#idl-double">double</a>, and
the value of the <a class="sym" href="#prod-float">float</a> token
is the IEEE 754 double-precision floating point number closest to
<var>result</var>.
<a href="#ref-IEEE-754">[IEEE-754]</a>
</li>
</ol>
<p>
It is not possible to specify an infinite or Not-a-Number
<a class="idltype" href="#idl-float">float</a> constant or dictionary member default value.
</p>
<p>
The type of a <a class="sym" href="#prod-float">float</a> token is the same
as the type of the constant or dictionary member it is being used as the value of. The value of the
<a class="sym" href="#prod-float">float</a> token <span class="rfc2119">MUST NOT</span>
lie outside the valid range of values for its type, as given in
<a href="#idl-types">section 3.9</a> below.
</p>
<p>
The value of a <a class="sym" href="#prod-string">string</a> token
is a <a class="idltype" href="#idl-DOMString">DOMString</a>, determined as follows:
</p>
<ol class="algorithm">
<li>Let <var>S</var> be the sequest of characters matched by the <a class="sym" href="#prod-string">string</a>
token with its leading and trailing <span class="char">U+0022 QUOTATION MARK ('"')</span>
characters removed.</li>
<li>The value of the <a class="sym" href="#prod-string">string</a> token is the
sequence of 16 bit unsigned integer code units (hereafter referred to just as
<dfn id="dfn-code-unit">code units</dfn>) corresponding to the UTF-16 encoding
of <var>S</var>.</li>
</ol>
<p>
The value of the <code>null</code> token is the special
<span class="idlvalue">null</span> value that is a member of the
<a class="dfnref" href="#dfn-nullable-type">nullable types</a>. The type of
the <code>null</code> token is the same as the
type of the constant or dictionary member it is being used as the value of.
</p>
<p>
If <var>VT</var> is the type of the value assigned to a constant, and <var>DT</var>
is the type of the constant or dictionary member itself, then these types <span class="rfc2119">MUST</span>
be compatible, which is the case if <var>DT</var> and <var>VT</var> are identical,
or <var>DT</var> is a <a class="dfnref" href="#dfn-nullable-type">nullable type</a>
whose <a class="dfnref" href="#dfn-inner-type">inner type</a> is <var>VT</var>.
</p>
<p>
<a class="dfnref" href="#dfn-constant">Constants</a> are not associated with
particular instances of the <a class="dfnref" href="#dfn-interface">interface</a>
on which they appear. It is language binding specific whether
<a class="dfnref" href="#dfn-constant">constants</a> are exposed on instances.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
Both the ECMAScript and the Java language binding do however
allow <a class="dfnref" href="#dfn-constant">constants</a> to be accessed
through objects implementing the IDL <a class="dfnref" href="#dfn-interface">interfaces</a>
on which the <a class="dfnref" href="#dfn-constant">constants</a> are declared.
For example, with the following IDL:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
const DOMString greeting = "hi";
};</code></pre></div></div>
<p>
the constant value can be accessed in ECMAScript and in Java either as
<code>A.greeting</code> or <code>instanceOfA.greeting</code>.
</p>
</div>
<p>
No <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this specification are applicable to constants.
</p>
<table class="grammar"><tr id="proddef-Const"><td><span class="prod-number">[18]</span></td><td><a class="sym" href="#prod-Const">Const</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"const" <a class="sym" href="#prod-ConstType">ConstType</a> <a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-ConstValue">ConstValue</a> ";"</span></td></tr><tr id="proddef-ConstValue"><td><span class="prod-number">[19]</span></td><td><a class="sym" href="#prod-ConstValue">ConstValue</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-BooleanLiteral">BooleanLiteral</a> <br /> |
<a class="sym" href="#prod-integer">integer</a> <br /> |
<a class="sym" href="#prod-float">float</a> <br /> |
<a class="sym" href="#prod-string">string</a> <br /> |
"null"</span></td></tr><tr id="proddef-BooleanLiteral"><td><span class="prod-number">[20]</span></td><td><a class="sym" href="#prod-BooleanLiteral">BooleanLiteral</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"true" <br /> |
"false"</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
demonstrates how <a class="dfnref" href="#dfn-constant">constants</a>
of the above types can be defined.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Util {
const boolean DEBUG = false;
const octet LF = 10;
const unsigned long BIT_MASK = 0x0000fc00;
const float AVOGADRO = 6.022e23;
};
exception Error {
const short ERR_UNKNOWN = 0;
const short ERR_OUT_OF_MEMORY = 1;
short errorCode;
};</code></pre></div></div>
</div>
</div>
<div id="idl-attributes" class="section">
<h4>3.3.2. Attributes</h4>
<p>
An <dfn id="dfn-attribute">attribute</dfn> is an <a class="dfnref" href="#dfn-interface-member">interface member</a>
(matching <span class="sym">"stringifier"</span> <a class="sym" href="#prod-Attribute">Attribute</a> or <a class="sym" href="#prod-Attribute">Attribute</a>)
that is used to declare that objects implementing the <a class="dfnref" href="#dfn-interface">interface</a> will have a member with the given
<a class="dfnref" href="#dfn-identifier">identifier</a> whose value can
be retrieved and (in some cases) changed.
</p>
<pre class="syntax">attribute <i>type</i> <i>identifier</i>;</pre>
<p>
The <a class="dfnref" href="#dfn-identifier">identifier</a> of an
<a class="dfnref" href="#dfn-attribute">attribute</a>
<span class="rfc2119">MUST NOT</span> be the same as the identifier
of another <a class="dfnref" href="#dfn-interface-member">interface member</a>
defined on the same <a class="dfnref" href="#dfn-interface">interface</a>.
</p>
<p>
The type of the attribute is given by the type (matching <a class="sym" href="#prod-AttributeType">AttributeType</a>)
that appears after the <code>attribute</code> keyword. This allows for
any type except <a href="#idl-sequence">sequence types</a>.
If the <a class="sym" href="#prod-AttributeType">AttributeType</a> is a
<a class="dfnref" href="#dfn-scoped-name">scoped name</a>, then it <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-resolve">resolve</a> to an interface or <a class="dfnref" href="#dfn-typedef">typedef</a>.
</p>
<p>
The attribute is <dfn id="dfn-read-only">read only</dfn> if the
<code>readonly</code> keyword is used before the <code>attribute</code> keyword.
An object that implements the interface on which a read only attribute
is defined will not allow assignment to that attribute. It is language
binding specific whether assignment is simply disallowed by the language,
ignored or an exception is thrown.
</p>
<pre class="syntax">readonly attribute <i>type</i> <i>identifier</i>;</pre>
<p>
An attribute that is not <a class="dfnref" href="#dfn-read-only">read only</a>
can be declared to <dfn id="dfn-inherit-getter">inherit its getter</dfn>
from an ancestor interface. This can be used to make a read only attribute
in an ancestor interface be writable on a derived interface. An attribute
<a class="dfnref" href="#dfn-inherit-getter">inherits its getter</a> if
its declaration includes <code>inherit</code> in the declaration.
The read only attribute from which the attribute inherits its getter
is the attribute with the same identifier on the closest ancestor interface
of the one on which the inheriting attribute is defined. The attribute
whose getter is being inherited <span class="rfc2119">MUST</span> be
of the same type as the inheriting attribute, and <code>inherit</code>
<span class="rfc2119">MUST NOT</span> appear on a read only attribute.
</p>
<pre class="syntax">interface <i>Ancestor</i> {
readonly attribute <i>TheType</i> <i>theIdentifier</i>;
};
interface <i>Derived</i> : <i>Ancestor</i> {
inherit attribute <i>TheType</i> <i>theIdentifier</i>;
};</pre>
<!--
<p>
The <a class='sym' href='#prod-GetRaises'>GetRaises</a> and
<a class='sym' href='#prod-SetRaises'>SetRaises</a> clauses are used
to declare the possible exceptions that can be thrown when retrieving
the value of and assigning a value to the attribute, respectively.
Each scoped name in the
<a class='sym' href='#prod-GetRaises'>GetRaises</a> and
<a class='sym' href='#prod-SetRaises'>SetRaises</a> clauses
<span class='rfc2119'>MUST</span> resolve to an <a class='dfnref' href='#dfn-exception'>exception</a>.
</p>
<pre class='syntax'>attribute <i>type</i> <i>identifier</i> getraises(<i>scoped-name</i>, <i>…</i>);
attribute <i>type</i> <i>identifier</i> setraises(<i>scoped-name</i>, <i>…</i>);
attribute <i>type</i> <i>identifier</i> getraises(<i>scoped-name</i>, <i>…</i>) setraises(<i>scoped-name</i>, <i>…</i>);
attribute <i>type</i> <i>identifier</i> inherits getter setraises(<i>scoped-name</i>, <i>…</i>);</pre>
-->
<p>
When the <code>stringifier</code> keyword is used
in an attribute declaration, it indicates that objects implementing the
interface will be stringified to the value of the attribute. See
<a href="#idl-stringifiers">section 3.3.4.2</a>
below for details.
</p>
<pre class="syntax">stringifier attribute DOMString <i>identifier</i>;</pre>
<p id="callback-attribute-exceptions">
If an implementation attempts to get or set the value of an
<a class="dfnref" href="#dfn-attribute">attribute</a> on a
<a class="dfnref" href="#dfn-user-object">user object</a>
(for example, when a callback object has been supplied to the implementation),
and that attempt results in an exception being thrown, then, unless otherwise specified, that
exception will be propagated to the user code that caused the
implementation to access the attribute. Similarly, if a value
returned from getting the attribute cannot be converted to
an IDL type, then any exception resulting from this will also
be propagated to the user code that resulted in the implementation
attempting to get the value of the attribute.
</p>
<p>
The following <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
are applicable to attributes:
<a class="xattr" href="#Clamp">[Clamp]</a>,
<a class="xattr" href="#EnforceRange">[EnforceRange]</a>,
<a class="xattr" href="#PutForwards">[PutForwards]</a>,
<a class="xattr" href="#Replaceable">[Replaceable]</a>,
<a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>,
<a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>,
<a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>,
<a class="xattr" href="#Unforgeable">[Unforgeable]</a>.
</p>
<!--
<?productions grammar AttributeOrOperation StringifierAttributeOrOperation Attribute ReadOnly Get GetRaises SetRaises ExceptionList?>
-->
<table class="grammar"><tr id="proddef-AttributeOrOperation"><td><span class="prod-number">[21]</span></td><td><a class="sym" href="#prod-AttributeOrOperation">AttributeOrOperation</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"stringifier" <a class="sym" href="#prod-StringifierAttributeOrOperation">StringifierAttributeOrOperation</a> <br /> |
<a class="sym" href="#prod-Attribute">Attribute</a> <br /> |
<a class="sym" href="#prod-Operation">Operation</a></span></td></tr><tr id="proddef-StringifierAttributeOrOperation"><td><span class="prod-number">[22]</span></td><td><a class="sym" href="#prod-StringifierAttributeOrOperation">StringifierAttributeOrOperation</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Attribute">Attribute</a> <br /> |
<a class="sym" href="#prod-OperationRest">OperationRest</a> <br /> |
";"</span></td></tr><tr id="proddef-Attribute"><td><span class="prod-number">[23]</span></td><td><a class="sym" href="#prod-Attribute">Attribute</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Inherit">Inherit</a> <a class="sym" href="#prod-ReadOnly">ReadOnly</a> "attribute" <a class="sym" href="#prod-AttributeType">AttributeType</a> <a class="sym" href="#prod-identifier">identifier</a> ";"</span></td></tr><tr id="proddef-ReadOnly"><td><span class="prod-number">[24]</span></td><td><a class="sym" href="#prod-ReadOnly">ReadOnly</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"readonly" <br /> |
ε</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
demonstrates how <a class="dfnref" href="#dfn-attribute">attributes</a>
can be declared on an <a class="dfnref" href="#dfn-interface">interface</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code"><!--exception InvalidName {
DOMString reason;
};
exception NoSuchPet { };
-->interface Animal {
<span class="comment">// A simple attribute that can be set to any string value.</span>
readonly attribute DOMString name;
<span class="comment">// An attribute whose value can be assigned to.</span>
attribute unsigned short age;
};
interface Person : Animal {
<span class="comment">// An attribute whose getter behavior is inherited from Animal, and need not be</span>
<span class="comment">// specified in the description of Person.</span>
inherit attribute DOMString name<!-- setraises (InvalidName)-->;
<!--
<span class='comment'>// An attribute whose value cannot be assigned to, and which can raise an</span>
<span class='comment'>// exception in some circumstances.</span>
readonly attribute DOMString petName getraises (NoSuchPet);
-->};</code></pre></div></div>
</div>
</div>
<div id="idl-operations" class="section">
<h4>3.3.3. Operations</h4>
<p>
An <dfn id="dfn-operation">operation</dfn> is an <a class="dfnref" href="#dfn-interface-member">interface member</a>
(matching <span class="sym">"stringifier"</span> <a class="sym" href="#prod-OperationRest">OperationRest</a> or <a class="sym" href="#prod-Operation">Operation</a>)
that defines a behavior that can be invoked on objects implementing the interface.
There are three kinds of operation:
</p>
<ol>
<li><a class="dfnref" href="#dfn-regular-operation">regular operations</a>, which
are those used to declare that objects implementing the
<a class="dfnref" href="#dfn-interface">interface</a> will have a method with
the given <a class="dfnref" href="#dfn-identifier">identifier</a>
<pre class="syntax"><i>return-type</i> <i>identifier</i>(<i>arguments…</i>);</pre></li>
<li><a class="dfnref" href="#dfn-special-operation">special operations</a>,
which are used to declare special behavior on objects
implementing the interface, such as object indexing and stringification
<pre class="syntax"><i>special-keywords…</i> <i>return-type</i> <i>identifier</i>(<i>arguments…</i>);
<i>special-keywords…</i> <i>return-type</i> (<i>arguments…</i>);</pre></li>
<li><a class="dfnref" href="#dfn-static-operation">static operations</a>,
which are used to declare operations that are not associated with
a particular object implementing the interface
<pre class="syntax">static <i>return-type</i> <i>identifier</i>(<i>arguments…</i>);</pre></li>
</ol>
<p>
If an operation has an identifier but no <span class="sym">static</span>
keyword, then it declares a <dfn id="dfn-regular-operation">regular operation</dfn>.
If the operation has one or more
<a class="dfnref" href="#dfn-special-keyword">special keywords</a>
used in its declaration (that is, any keyword matching
<a class="sym" href="#prod-Special">Special</a>, or
the <code>stringifier</code> keyword),
then it declares a special operation. A single operation can declare
both a regular operation and a special operation; see
<a href="#idl-special-operations">section 3.3.4</a> below
for details on special operations.
</p>
<p>
If an operation has no identifier,
then it <span class="rfc2119">MUST</span>
be declared to be a special operation using one of the
special keywords.
</p>
<p>
The identifier of a
<a class="dfnref" href="#dfn-regular-operation">regular operation</a>
or <a class="dfnref" href="#dfn-static-operation">static operation</a>
<span class="rfc2119">MUST NOT</span> be the same as the identifier
of a <a class="dfnref" href="#dfn-constant">constant</a> or
<a class="dfnref" href="#dfn-attribute">attribute</a>
defined on the same <a class="dfnref" href="#dfn-interface">interface</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
The identifier can be the same as that of another operation on the
interface, however. This is how operation overloading is specified.
</p>
</div>
<p>
The <dfn id="dfn-return-type">return type</dfn> of the operation is given
by the type (matching <a class="sym" href="#prod-ReturnType">ReturnType</a>)
that appears before the operation’s optional <a class="dfnref" href="#dfn-identifier">identifier</a>.
A return type of <code id="idl-void">void</code> indicates that the operation returns no value.
If the return type is a
<a class="dfnref" href="#dfn-scoped-name">scoped name</a>, then it <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-resolve">resolve</a> to an interface, dictionary or <a class="dfnref" href="#dfn-typedef">typedef</a>.
</p>
<p>
An operation’s arguments (matching <a class="sym" href="#prod-ArgumentList">ArgumentList</a>)
are given between the parentheses in the declaration. Each individual argument is specified
as a type (matching <a class="sym" href="#prod-Type">Type</a>) followed by an <a class="dfnref" href="#dfn-identifier">identifier</a>
(given by an <a class="sym" href="#prod-identifier">identifier</a> token).
If the <a class="sym" href="#prod-Type">Type</a> is a scoped name,
then it <span class="rfc2119">MUST</span> resolve to an interface, <a class="dfnref" href="#dfn-dictionary">dictionary</a>
or <a class="dfnref" href="#dfn-typedef">typedef</a>.
</p>
<pre class="syntax"><i>return-type</i> <i>identifier</i>(<i>type</i> <i>identifier</i>, <i>type</i> <i>identifier</i>, …);</pre>
<p>
Each argument can be preceded by a list of
<a class="dfnref" href="#dfn-extended-attribute">extended attributes</a> (matching
<a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a>),
which can control how a value passed as the argument will be handled in
language bindings.
</p>
<pre class="syntax"><i>return-type</i> <i>identifier</i>([<em>extended-attributes</em>] <i>type</i> <i>identifier</i>, [<em>extended-attributes</em>] <i>type</i> <i>identifier</i>, …);</pre>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
demonstrates how <a class="dfnref" href="#dfn-regular-operation">regular operations</a>
can be declared on an <a class="dfnref" href="#dfn-interface">interface</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Dimensions {
attribute unsigned long width;
attribute unsigned long height;
};
exception NoPointerDevice { };
interface Button {
<span class="comment">// An operation that takes no arguments and returns a boolean<!--, and could possibly</span>
<span class='comment'>// raise an exception-->.</span>
boolean isMouseOver()<!-- raises (NoPointerDevice)-->;
<span class="comment">// Overloaded operations.</span>
void setDimensions(Dimensions size);
void setDimensions(unsigned long width, unsigned long height);
};</code></pre></div></div>
</div>
<p>
An operation is considered to be a <dfn id="dfn-variadic-operation">variadic operation</dfn>
if the final argument uses the <code>...</code> token just
after the argument type. Declaring an operation to be variadic indicates that
the operation can be invoked with any number of arguments after that final argument.
Those extra implied formal arguments are of the same type as the final explicit
argument in the operation declaration. The final argument can also be omitted
when invoking the operation. An argument <span class="rfc2119">MUST NOT</span>
be declared with the <code>...</code> token unless it
is the final argument in the operation’s argument list.
</p>
<pre class="syntax"><i>return-type</i> <i>identifier</i>(<i>type</i><em>...</em> <i>identifier</i>);
<i>return-type</i> <i>identifier</i>(<i>type</i> <i>identifier</i>, <i>type</i><em>...</em> <i>identifier</i>);</pre>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines an interface that has
two variadic operations:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface IntegerSet {
readonly attribute unsigned long cardinality;
void union(long... ints);
void intersection(long... ints);
};</code></pre></div></div>
<p>
In the ECMAScript binding, variadic operations are implemented by
functions that can accept the subsequent arguments:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var s = getIntegerSet(); <span class="comment">// Obtain an instance of IntegerSet.</span>
s.union(); <span class="comment">// Passing no arguments corresponding to 'ints'.</span>
s.union(1, 4, 7); <span class="comment">// Passing three arguments corresponding to 'ints'.</span></code></pre></div></div>
<p>
A binding for a language that does not support variadic functions
might specify that an explicit array or list of integers be passed
to such an operation.
</p>
</div>
<p>
An argument is considered to be an <dfn id="dfn-optional-argument">optional argument</dfn>
if it is declared with the <code>optional</code> keyword.
The final argument of a <a class="dfnref" href="#dfn-variadic-operation">variadic operation</a>
is also considered to be an optional argument. Declaring an argument
to be optional indicates that the argument value can be omitted
when the operation is invoked. An argument <span class="rfc2119">MUST NOT</span>
be declared to be optional unless all subsequent arguments to the
operation are also optional.
</p>
<pre class="syntax"><i>return-type</i> <i>identifier</i>(<i>type</i> <i>identifier</i>, optional <i>type</i> <i>identifier</i>);</pre>
<p>
Web IDL operations do not support being called with omitted optional arguments
unless all subsequent optional arguments are also omitted. Bindings for
languages that do support function calling in this way will fail such
calls in a language binding specific manner.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
ECMAScript and Java, the two language for which bindings are specified
in this document, do not support function calling like this.
</p>
</div>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines an <a class="dfnref" href="#dfn-interface">interface</a>
with a single <a class="dfnref" href="#dfn-operation">operation</a>
that can be invoked with two different argument list lengths:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface ColorCreator {
object createColor(float v1, float v2, float v3, optional float alpha);
};</code></pre></div></div>
<p>
It is equivalent to an <a class="dfnref" href="#dfn-interface">interface</a>
that has two <a class="dfnref" href="#dfn-overloaded">overloaded</a>
<a class="dfnref" href="#dfn-operation">operations</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface ColorCreator {
object createColor(float v1, float v2, float v3);
object createColor(float v1, float v2, float v3, float alpha);
};</code></pre></div></div>
</div>
<!--
<p>
A <code>raises</code> clause (matching <a class='sym' href='#prod-Raises'>Raises</a>) is used
to declare the possible <a class='dfnref' href='#dfn-exception'>exceptions</a>
that can be thrown when invoking the operation.
Each scoped name in the <code>Raises</code> clause
<span class='rfc2119'>MUST</span> resolve to an exception.
</p>
<pre class='syntax'><i>return-type</i> <i>identifier</i>(<i>arguments</i>…) raises(<i>scoped-name</i>, …);</pre>
-->
<p id="callback-operation-exceptions">
If an implementation attempts to invoke an
<a class="dfnref" href="#dfn-operation">operation</a> on a
<a class="dfnref" href="#dfn-user-object">user object</a> (for example, when a callback object
has been supplied to the implementation), and that attempt results in an
exception being thrown, then, unless otherwise specified, that
exception will be propagated to the user code that caused the
implementation to invoke the operation. Similarly, if a value
returned from invoking the operation cannot be converted to
an IDL type, then any exception resulting from this will also
be propagated to the user code that resulted in the implementation
attempting to invoke the operation.
</p>
<p>
The following extended attributes
are applicable to operations:
<a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>,
<a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>.
</p>
<p>
The following extended attributes are applicable to operation arguments:
<a class="xattr" href="#AllowAny">[AllowAny]</a>,
<a class="xattr" href="#Clamp">[Clamp]</a>,
<a class="xattr" href="#EnforceRange">[EnforceRange]</a>,
<a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>,
<a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>,
<a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>.
</p>
<!--
<?productions grammar Operation OperationRest Qualifiers Specials Special ReturnType OptionalIdentifier ArgumentList Arguments Argument In Optional Ellipsis Raises?>
-->
<table class="grammar"><tr id="proddef-Operation"><td><span class="prod-number">[26]</span></td><td><a class="sym" href="#prod-Operation">Operation</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Qualifiers">Qualifiers</a> <a class="sym" href="#prod-OperationRest">OperationRest</a></span></td></tr><tr id="proddef-Qualifiers"><td><span class="prod-number">[27]</span></td><td><a class="sym" href="#prod-Qualifiers">Qualifiers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"static" <br /> |
<a class="sym" href="#prod-Specials">Specials</a></span></td></tr><tr id="proddef-Specials"><td><span class="prod-number">[28]</span></td><td><a class="sym" href="#prod-Specials">Specials</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Special">Special</a> <a class="sym" href="#prod-Specials">Specials</a> <br /> |
ε</span></td></tr><tr id="proddef-Special"><td><span class="prod-number">[29]</span></td><td><a class="sym" href="#prod-Special">Special</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"getter" <br /> |
"setter" <br /> |
"creator" <br /> |
"deleter" <br /> |
"legacycaller"</span></td></tr><tr id="proddef-OperationRest"><td><span class="prod-number">[30]</span></td><td><a class="sym" href="#prod-OperationRest">OperationRest</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ReturnType">ReturnType</a> <a class="sym" href="#prod-OptionalIdentifier">OptionalIdentifier</a> "(" <a class="sym" href="#prod-ArgumentList">ArgumentList</a> ")" ";"</span></td></tr><tr id="proddef-OptionalIdentifier"><td><span class="prod-number">[31]</span></td><td><a class="sym" href="#prod-OptionalIdentifier">OptionalIdentifier</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> <br /> |
ε</span></td></tr><tr id="proddef-ArgumentList"><td><span class="prod-number">[32]</span></td><td><a class="sym" href="#prod-ArgumentList">ArgumentList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Argument">Argument</a> <a class="sym" href="#prod-Arguments">Arguments</a> <br /> |
ε</span></td></tr><tr id="proddef-Arguments"><td><span class="prod-number">[33]</span></td><td><a class="sym" href="#prod-Arguments">Arguments</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"," <a class="sym" href="#prod-Argument">Argument</a> <a class="sym" href="#prod-Arguments">Arguments</a> <br /> |
ε</span></td></tr><tr id="proddef-Argument"><td><span class="prod-number">[34]</span></td><td><a class="sym" href="#prod-Argument">Argument</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-Optional">Optional</a> <a class="sym" href="#prod-Type">Type</a> <a class="sym" href="#prod-Ellipsis">Ellipsis</a> <a class="sym" href="#prod-identifier">identifier</a></span></td></tr><tr id="proddef-Optional"><td><span class="prod-number">[35]</span></td><td><a class="sym" href="#prod-Optional">Optional</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"optional" <br /> |
ε</span></td></tr><tr id="proddef-Ellipsis"><td><span class="prod-number">[36]</span></td><td><a class="sym" href="#prod-Ellipsis">Ellipsis</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"..." <br /> |
ε</span></td></tr><tr id="proddef-ReturnType"><td><span class="prod-number">[57]</span></td><td><a class="sym" href="#prod-ReturnType">ReturnType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Type">Type</a> <br /> |
"void"</span></td></tr></table>
</div>
<div id="idl-special-operations" class="section">
<h4>3.3.4. Special operations</h4>
<p>
A <dfn id="dfn-special-operation">special operation</dfn> is a
declaration of a certain kind of special behavior on objects implementing
the interface on which the special operation declarations appear.
Special operations are declared by using one or more
<dfn id="dfn-special-keyword">special keywords</dfn>
in an operation declaration.
</p>
<p>
There are six kinds of special operations. The table below indicates
for a given kind of special operation what special keyword
is used to declare it and what the purpose of the special operation is:
</p>
<table class="vert">
<tr>
<th>Special operation</th>
<th>Keyword</th>
<th>Purpose</th>
</tr>
<tr>
<td><dfn id="dfn-getter">Getters</dfn></td>
<td><code>getter</code></td>
<td>Defines behavior for when an object is indexed for property retrieval.</td>
</tr>
<tr>
<td><dfn id="dfn-setter">Setters</dfn></td>
<td><code>setter</code></td>
<td>Defines behavior for when an object is indexed for property assignment.</td>
</tr>
<tr>
<td><dfn id="dfn-creator">Creators</dfn></td>
<td><code>creator</code></td>
<td>Defines behavior for when an object is indexed for property creation.</td>
</tr>
<tr>
<td><dfn id="dfn-deleter">Deleters</dfn></td>
<td><code>deleter</code></td>
<td>Defines behavior for when an object is indexed for property deletion.</td>
</tr>
<tr>
<td><dfn id="dfn-legacy-caller">Legacy callers</dfn></td>
<td><code>legacycaller</code></td>
<td>Defines behavior for when an object is called as if it were a function.</td>
</tr>
<tr>
<td><dfn id="dfn-stringifier">Stringifiers</dfn></td>
<td><code>stringifier</code></td>
<td>Defines how an object is converted into a <a class="idltype" href="#idl-DOMString">DOMString</a>.</td>
</tr>
</table>
<p>
Not all language bindings support all of the six kinds of special
object behavior. When special operations are declared using
operations with no identifier, then in language bindings that do
not support the particular kind of special operations there simply
will not be such functionality.
</p>
<p>
Some language bindings, such as ECMAScript, do not distinguish
assignment to an existing indexed or named property and the creation
of a new one. Regardless, it is the creator that is invoked when
an attempt is made to create a new indexed or named property, and
the setter when the property already exists.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>The following IDL fragment defines an interface with a getter and a setter:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Dictionary {
readonly attribute unsigned long propertyCount;
getter float (DOMString propertyName);
setter void (DOMString propertyName, float propertyValue);
};</code></pre></div></div>
<p>In language bindings that do not support property getters and setters,
objects implementing <span class="idltype">Dictionary</span> will not
have that special behavior. For example, in the Java language binding,
the corresponding Java interface will have only a single method,
<code>long getPropertyCount()</code>.</p>
</div>
<!--
<p>
<a class='dfnref' href='#dfn-special-operation'>Special operations</a>
can be declared using an <a class='dfnref' href='#dfn-operation'>operation</a>
that has an <a class='dfnref' href='#dfn-identifier'>identifier</a>
and the <code>omittable</code> keyword to indicate that
in language bindings that do not support that kind of special operation,
the <a class='dfnref' href='#dfn-regular-operation'>regular operation</a>
is to be available on the object for use instead. Such operations are
known as <dfn id='dfn-omittable'>omittable</dfn>.
</p>
<div class='example'>
<p>The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a>
declares <a class='dfnref' href='#dfn-special-operation'>special operations</a>
with <a class='dfnref' href='#dfn-identifier'>identifiers</a>
and using the <code>omittable</code> keyword:</p>
<x:codeblock language='idl'>interface Dictionary {
readonly attribute unsigned long propertyCount;
omittable getter float getProperty(DOMString propertyName);
omittable setter void setProperty(DOMString propertyName, float propertyValue);
};</x:codeblock>
<p>In language bindings that do not support property getters and setters,
such as Java,
objects implementing <span class='idltype'>Dictionary</span> will have
<span class='idlident'>getProperty</span> and <span class='idlident'>setProperty</span>
operations available. The corresponding Java interface would be:</p>
<x:codeblock language='java'>public interface Dictionary {
long getPropertyCount();
float getProperty(String propertyName);
void setProperty(String propertyName, float propertyValue);
}</x:codeblock>
<p>
These operations will be omitted in language
bindings that do support property getters and setters, such as
ECMAScript, however.
</p>
<x:codeblock language='es'>var dictionary = getDictionary(); <span class='comment'>// Get an instance of Dictionary.</span>
dictionary.getProperty; <span class='comment'>// Actually invokes the property getter with property name "getProperty".</span>
dictionary.x = 1; <span class='comment'>// Invokes the property setter with property name "x" and value 1.</span></x:codeblock>
</div>
-->
<p>
Defining a special operation <!--without using the <code>omittable</code> keyword
on an operation but giving the operation an--> with an <a class="dfnref" href="#dfn-identifier">identifier</a>
is equivalent to separating the special operation out into its own
declaration without an identifier. This approach is allowed to
simplify prose descriptions of an interface’s operations.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>The following two interfaces are equivalent:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Dictionary {
readonly attribute unsigned long propertyCount;
getter float getProperty(DOMString propertyName);
setter void setProperty(DOMString propertyName, float propertyValue);
};</code></pre></div></div>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Dictionary {
readonly attribute unsigned long propertyCount;
float getProperty(DOMString propertyName);
void setProperty(DOMString propertyName, float propertyValue);
getter float (DOMString propertyName);
setter void (DOMString propertyName, float propertyValue);
};</code></pre></div></div>
</div>
<!--
<p>
The <code>omittable</code> keyword <span class='rfc2119'>MUST NOT</span>
appear on an operation that has no identifier.
</p>
-->
<p>
A given <a class="dfnref" href="#dfn-special-keyword">special keyword</a> <span class="rfc2119">MUST NOT</span>
appear twice on an operation.
</p>
<p>
Getters, setters, creators and deleters come in two varieties: ones that
take a <a class="idltype" href="#idl-DOMString">DOMString</a> as a property name,
known as
<dfn id="dfn-named-property-getter">named property getters</dfn>,
<dfn id="dfn-named-property-setter">named property setters</dfn>,
<dfn id="dfn-named-property-creator">named property creators</dfn> and
<dfn id="dfn-named-property-deleter">named property deleters</dfn>,
and ones that take an <a class="idltype" href="#idl-unsigned-long">unsigned long</a>
as a property index, known as
<dfn id="dfn-indexed-property-getter">indexed property getters</dfn>,
<dfn id="dfn-indexed-property-setter">indexed property setters</dfn>,
<dfn id="dfn-indexed-property-creator">indexed property creators</dfn> and
<dfn id="dfn-indexed-property-deleter">indexed property deleters</dfn>.
See <a href="#idl-indexed-properties">section 3.3.4.3</a>
and <a href="#idl-named-properties">section 3.3.4.4</a>
for details.
</p>
<p>
On a given <a class="dfnref" href="#dfn-interface">interface</a>,
there <span class="rfc2119">MUST</span> exist at most one
stringifier and at most one of each variety of getter, setter,
creator and deleter. Multiple legacy callers can exist on an interface
to specify overloaded calling behavior.
</p>
<p>
Special operations declared using operations <span class="rfc2119">MUST NOT</span>
be <a class="dfnref" href="#dfn-variadic-operation">variadic</a> nor have any
<a class="dfnref" href="#dfn-optional-argument">optional arguments</a>.
</p>
<p>
If an object implements more than one <a class="dfnref" href="#dfn-interface">interface</a>
that defines a given special operation, then it is undefined which (if any)
special operation is invoked for that operation.
</p>
<div id="idl-legacy-callers" class="section">
<h5>3.3.4.1. Legacy callers</h5>
<p>
When an <a class="dfnref" href="#dfn-interface">interface</a> has one or more
<a class="dfnref" href="#dfn-legacy-caller">legacy callers</a>, it indicates that objects that implement
the interface can be called as if they were functions. As mentioned above,
legacy callers can be specified using an <a class="dfnref" href="#dfn-operation">operation</a>
declared with the <code>legacycaller</code> keyword.
</p>
<pre class="syntax">legacycaller <i>return-type</i> <i>identifier</i>(<i>arguments…</i>);
legacycaller <i>return-type</i> (<i>arguments…</i>);<!--
omittable legacycaller <i>return-type</i> <i>identifier</i>(<i>arguments…</i>);--></pre>
<p>
If multiple legacy callers are specified on an interface, overload resolution
is used to determine which legacy caller is invoked when the object is called
as if it were a function.
</p>
<p>
Specifications <span class="rfc2119">SHOULD NOT</span> use legacy callers unless
required to specify the behavior of legacy APIs.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines an <a class="dfnref" href="#dfn-interface">interface</a>
with a <a class="dfnref" href="#dfn-legacy-caller">legacy caller</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface NumberQuadrupler {
<span class="comment">// This operation simply returns four times the given number x.</span>
legacycaller float compute(float x);
};</code></pre></div></div>
<p>
An ECMAScript implementation supporting this interface would
allow a <a class="dfnref" href="#dfn-platform-object">platform object</a>
that implements <span class="idltype">NumberQuadrupler</span>
to be called as a function:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var f = getNumberQuadrupler(); <span class="comment">// Obtain an instance of NumberQuadrupler.</span>
f.compute(3); <span class="comment">// This evaluates to 12.</span>
f(3); <span class="comment">// This also evaluates to 12.</span></code></pre></div></div>
</div>
</div>
<div id="idl-stringifiers" class="section">
<h5>3.3.4.2. Stringifiers</h5>
<p>
When an <a class="dfnref" href="#dfn-interface">interface</a> has a
<a class="dfnref" href="#dfn-stringifier">stringifier</a>, it indicates that objects that implement
the interface have a non-default conversion to a string. As mentioned above,
stringifiers can be specified using an <a class="dfnref" href="#dfn-operation">operation</a>
declared with the <code>stringifier</code> keyword.
</p>
<pre class="syntax">stringifier DOMString <i>identifier</i>();
stringifier DOMString ();<!--
omittable stringifier DOMString <i>identifier</i>();--></pre>
<p>
If an operation used to declare a stringifier does not have an
<a class="dfnref" href="#dfn-identifier">identifier</a>, then prose
accompanying the interface <span class="rfc2119">MUST</span> define
the <dfn id="dfn-stringification-behavior">stringification behavior</dfn>
of the interface. If the operation does have an identifier,
then the object is converted to a string by invoking the
operation to obtain the string.
</p>
<p>
Stringifiers declared with operations <span class="rfc2119">MUST</span>
be declared to take zero arguments and return a <a class="idltype" href="#idl-DOMString">DOMString</a>.
</p>
<p>
As a shorthand, if the <code>stringifier</code> keyword
is declared using an operation with no identifier, then the
operation’s <a class="dfnref" href="#dfn-return-type">return type</a> and
argument list can be omitted.
</p>
<pre class="syntax">stringifier;</pre>
<div class="example"><div class="exampleHeader">Example</div>
<p>The following two interfaces are equivalent:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
stringifier DOMString ();
};</code></pre></div></div>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
stringifier;
};</code></pre></div></div>
</div>
<p>
The <code>stringifier</code> keyword
can also be placed on an <a class="dfnref" href="#dfn-attribute">attribute</a>.
In this case, the string to convert the object to is the
value of the attribute. The <code>stringifier</code> keyword
<span class="rfc2119">MUST NOT</span> be placed on an attribute unless
it is declared to be of type <a class="idltype" href="#idl-DOMString">DOMString</a>.
</p>
<pre class="syntax">stringifier attribute DOMString <i>identifier</i>;</pre>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines an interface that will stringify to the value of its
<a class="idlattr">name</a> attribute:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Constructor]
interface Student {
attribute unsigned long id;
stringifier attribute DOMString name;
};</code></pre></div></div>
<p>
In the ECMAScript binding, using a <span class="idltype">Student</span>
object in a context where a string is expected will result in the
value of the object’s “name” property being
used:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var s = new Student();
s.id = 12345678;
s.name = '周杰倫';
var greeting = 'Hello, ' + s + '!'; <span class="comment">// Now greeting == 'Hello, 周杰倫!'.</span></code></pre></div></div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines an interface that has custom stringification behavior that is
not specified in the IDL itself.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Constructor]
interface Student {
attribute unsigned long id;
attribute DOMString? familyName;
attribute DOMString givenName;
stringifier DOMString ();
};</code></pre></div></div>
<p>
Thus, prose is required to explain the stringification behavior, such
as the following paragraph:
</p>
<blockquote>
<p>
Objects that implement the <span class="idltype">Student</span>
interface must stringify as follows. If the value of the
<span class="idlattr">familyName</span> attribute is
<span class="idlvalue">null</span>, the stringification of the
object is the value of the <span class="idlattr">givenName</span>
attribute. Otherwise, if the value of the
<span class="idlattr">familyName</span> attribute is not <span class="idlvalue">null</span>,
the stringification of the object is the concatenation of the
value of the <span class="idlattr">givenName</span> attribute,
a single space character, and the value of
the <span class="idlattr">familyName</span> attribute.
</p>
</blockquote>
<p>
An ECMAScript implementation of the IDL would behave as follows:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var s = new Student();
s.id = 12345679;
s.familyName = 'Smithee';
s.givenName = 'Alan';
var greeting = 'Hi ' + s; <span class="comment">// Now greeting == 'Hi Alan Smithee'.</span></code></pre></div></div>
</div>
</div>
<div id="idl-indexed-properties" class="section">
<h5>3.3.4.3. Indexed properties</h5>
<p>
An <a class="dfnref" href="#dfn-interface">interface</a> that defines
an <a class="dfnref" href="#dfn-indexed-property-getter">indexed property getter</a>,
<a class="dfnref" href="#dfn-indexed-property-setter">indexed property setter</a>,
<a class="dfnref" href="#dfn-indexed-property-creator">indexed property creator</a>
and/or an <a class="dfnref" href="#dfn-indexed-property-deleter">indexed property deleter</a>
is said to <dfn id="dfn-support-indexed-properties">support indexed properties</dfn>.
</p>
<p>
If an interface <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed properties</a>,
then the interface definition <span class="rfc2119">MUST</span> be accompanied by
a description of what indices the object can be indexed with at
any given time. These indices are called the <dfn id="dfn-supported-property-indices">supported property indices</dfn>.
</p>
<p>
Indexed property getters and deleters <span class="rfc2119">MUST</span>
be declared to take a single <a class="idltype" href="#idl-unsigned-long">unsigned long</a> argument.
Indexed property setters and creators <span class="rfc2119">MUST</span>
be declared to take two arguments, where the first is an <a class="idltype" href="#idl-unsigned-long">unsigned long</a>.
</p>
<pre class="syntax">getter <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>);
setter <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>, <i>type</i> <i>identifier</i>);
creator <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>, <i>type</i> <i>identifier</i>);
deleter <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>);
getter <i>type</i> (unsigned long <i>identifier</i>);
setter <i>type</i> (unsigned long <i>identifier</i>, <i>type</i> <i>identifier</i>);
creator <i>type</i> (unsigned long <i>identifier</i>, <i>type</i> <i>identifier</i>);
deleter <i>type</i> (unsigned long <i>identifier</i>);<!--
omittable getter <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>);
omittable setter <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>, <i>type</i> <i>identifier</i>);
omittable creator <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>, <i>type</i> <i>identifier</i>);
omittable deleter <i>type</i> <i>identifier</i>(unsigned long <i>identifier</i>);--></pre>
<p>
The following requirements apply to the definitions of indexed property getters, setters, creators and deleters:
</p>
<ul>
<li>
If an <a class="dfnref" href="#dfn-indexed-property-getter">indexed property getter</a> was specified using an <a class="dfnref" href="#dfn-operation">operation</a>
with an <a class="dfnref" href="#dfn-identifier">identifier</a>,
then the value returned when indexing the object with a given index
is the value that would be returned by invoking the operation, passing
the index as its only argument. If the operation used to declare the indexed property getter
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-determine-the-value-of-an-indexed-property">determine the value of an indexed property</dfn>
for a given index.
</li>
<li>
If an <a class="dfnref" href="#dfn-indexed-property-setter">indexed property setter</a> was specified using an operation
with an identifier,
then the behavior that occurs when indexing the object for property assignment with a given property index and value
is the same as if the operation is invoked, passing
the index as the first argument and the value as the second argument. If the operation used to declare the indexed property setter
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-set-the-value-of-an-existing-indexed-property">set the value of an existing indexed property</dfn>
for a given property index and value.
</li>
<li>
If an <a class="dfnref" href="#dfn-indexed-property-creator">indexed property creator</a> was specified using an operation
with an identifier,
then the behavior that occurs when indexing the object for property creation with a given property index and value
is the same as if the operation is invoked, passing
the index as the first argument and the value as the second argument. If the operation used to declare the indexed property creator
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-set-the-value-of-a-new-indexed-property">set the value of a new indexed property</dfn>
for a given property index and value.
</li>
<li>
If an <a class="dfnref" href="#dfn-indexed-property-deleter">indexed property deleter</a> was specified using an operation
with an identifier,
then the behavior that occurs when indexing the object for property deletion with a given property index
is the same as if the operation is invoked, passing
the index as the only argument. If the operation used to declare the indexed property deleter
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-delete-an-existing-indexed-property">delete an existing indexed property</dfn>
for a given property index.
</li>
</ul>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines an interface
<span class="idltype">OrderedMap</span> which allows
retrieving and setting values by name or by index number:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface OrderedMap {
readonly attribute unsigned long size;
getter any getByIndex(unsigned long index);
setter void setByIndex(unsigned long index, any value);
deleter void removeByIndex(unsigned long index);
getter any get(DOMString name);
setter creator void set(DOMString name, any value);
deleter void remove(DOMString name);
};</code></pre></div></div>
<p>
Since all of the special operations are declared using
operations with identifiers, the only additional prose
that is necessary is that which describes what keys those sets
have. Assuming that the <code>get()</code> operation is
defined to return <span class="idlvalue">null</span> if an
attempt is made to look up a non-existing entry in the
<span class="idltype">OrderedMap</span>, then the following
two sentences would suffice:
</p>
<blockquote>
<p>
An object <var>map</var> implementing <span class="idltype">OrderedMap</span>
supports indexed properties with indices in the range
0 ≤ <var>index</var> < <code>map.size</code>.
</p>
<p>
Such objects also support a named property for every name that,
if passed to <code>get()</code>, would return a non-null value.
</p>
</blockquote>
<p>
As described in <a href="#es-platform-objects">section 4.7</a>,
an ECMAScript implementation would create
properties on a <a class="dfnref" href="#dfn-platform-object">platform object</a> implementing
<span class="idltype">OrderedMap</span> that correspond to
entries in both the named and indexed property sets.
These properties can then be used to interact
with the object in the same way as invoking the object’s
methods, as demonstrated below:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code"><span class="comment">// Assume map is a platform object implementing the OrderedMap interface.</span>
var map = getOrderedMap();
var x, y;
x = map[0]; <span class="comment">// If map.length > 0, then this is equivalent to:
//
// x = map.getByIndex(0)
//
// since a property named "0" will have been placed on map.
// Otherwise, x will be set to undefined, since there will be
// no property named "0" on map.</span>
map[1] = false; <span class="comment">// If map.length > 1, then this will set the property named
// "1" on map to false, and then will do the equivalent of:
//
// map.setByIndex(1, false)
//
// Otherwise, if map.length ≤ 1, then it will set the
// property but have no other effect (since an indexed property creator
// was not specified).</span>
y = map.apple; <span class="comment">// If there exists a named property named "apple", then this
// will be equivalent to:
//
// y = map.get('apple')
//
// since a property named "apple" will have been placed on
// map. Otherwise, y will be set to undefined, since there
// will be no property named "apple" on map.</span>
map.berry = 123; <span class="comment">// Regardless of whether there exists a named property named
// "berry", this will set the "berry" property to 123, and
// then do the equivalent of:
//
// map.set('berry', 123)</span>
delete map.cake; <span class="comment">// If a named property named "cake" exists, then the "cake"
// property will be deleted, and then the equivalent to the
// following will be performed:
//
// map.remove("cake")</span>
</code></pre></div></div></div>
</div>
<div id="idl-named-properties" class="section">
<h5>3.3.4.4. Named properties</h5>
<p>
An <a class="dfnref" href="#dfn-interface">interface</a> that defines
a <a class="dfnref" href="#dfn-named-property-getter">named property getter</a>,
<a class="dfnref" href="#dfn-named-property-setter">named property setter</a>,
<a class="dfnref" href="#dfn-named-property-creator">named property creator</a>
and/or a <a class="dfnref" href="#dfn-named-property-deleter">named property deleter</a>
is said to <dfn id="dfn-support-named-properties">support named properties</dfn>.
</p>
<p>
If an interface <a class="dfnref" href="#dfn-support-named-properties">supports named properties</a>,
then the interface definition <span class="rfc2119">MUST</span> be accompanied by
a description of the ordered set of names that can be used to index the object
at any given time. These names are called the
<dfn id="dfn-supported-property-names">supported property names</dfn>.
</p>
<p>
Named property getters and deleters <span class="rfc2119">MUST</span>
be declared to take a single <a class="idltype" href="#idl-DOMString">DOMString</a> argument.
Named property setters and creators <span class="rfc2119">MUST</span>
be declared to take two arguments, where the first is a <a class="idltype" href="#idl-DOMString">DOMString</a>.
</p>
<pre class="syntax">getter <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>);
setter <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>, <i>type</i> <i>identifier</i>);
creator <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>, <i>type</i> <i>identifier</i>);
deleter <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>);
getter <i>type</i> (DOMString <i>identifier</i>);
setter <i>type</i> (DOMString <i>identifier</i>, <i>type</i> <i>identifier</i>);
creator <i>type</i> (DOMString <i>identifier</i>, <i>type</i> <i>identifier</i>);
deleter <i>type</i> (DOMString <i>identifier</i>);<!--
omittable getter <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>);
omittable setter <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>, <i>type</i> <i>identifier</i>);
omittable creator <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>, <i>type</i> <i>identifier</i>);
omittable deleter <i>type</i> <i>identifier</i>(DOMString <i>identifier</i>);--></pre>
<p>
The following requirements apply to the definitions of named property getters, setters, creators and deleters:
</p>
<ul>
<li>
If a <a class="dfnref" href="#dfn-named-property-getter">named property getter</a> was specified using an <a class="dfnref" href="#dfn-operation">operation</a>
with an <a class="dfnref" href="#dfn-identifier">identifier</a>,
then the value returned when indexing the object with a given name
is the value that would be returned by invoking the operation, passing
the name as its only argument. If the operation used to declare the named property getter
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-determine-the-value-of-a-named-property">determine the value of a named property</dfn>
for a given property name.
</li>
<li>
If a <a class="dfnref" href="#dfn-named-property-setter">named property setter</a> was specified using an operation
with an identifier,
then the behavior that occurs when indexing the object for property assignment with a given property name and value
is the same as if the operation is invoked, passing
the name as the first argument and the value as the second argument. If the operation used to declare the named property setter
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-set-the-value-of-an-existing-named-property">set the value of an existing named property</dfn>
for a given property name and value.
</li>
<li>
If a <a class="dfnref" href="#dfn-named-property-creator">named property creator</a> was specified using an operation
with an identifier,
then the behavior that occurs when indexing the object for property creation with a given property name and value
is the same as if the operation is invoked, passing
the name as the first argument and the value as the second argument. If the operation used to declare the named property creator
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-set-the-value-of-a-new-named-property">set the value of a new named property</dfn>
for a given property name and value.
</li>
<li>
If a <a class="dfnref" href="#dfn-named-property-deleter">named property deleter</a> was specified using an operation
with an identifier,
then the behavior that occurs when indexing the object for property deletion with a given property name
is the same as if the operation is invoked, passing
the name as the only argument. If the operation used to declare the named property deleter
did not have an identifier, then the interface definition must be accompanied
by a description of how to <dfn id="dfn-delete-an-existing-named-property">delete an existing named property</dfn>
for a given property name.
</li>
</ul>
</div>
</div>
<div id="idl-static-operations" class="section">
<h4>3.3.5. Static operations</h4>
<p>
A <dfn id="dfn-static-operation">static operation</dfn> is one that is
not called on a particular instance of the <a class="dfnref" href="#dfn-interface">interface</a>
on which it is declared, and is instead associated with the interface
itself. Static operations are declared by using the
<code>static</code> keyword in an operation
declaration.
</p>
<p>
It is language binding specific whether it is possible to invoke
a static operation through a reference to an instance of the
interface.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines an interface
<span class="idltype">Circle</span> that has a static
operation declared on it:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Point { /* ... */ };
interface Circle {
attribute float cx;
attribute float cy;
attribute float radius;
static Point triangulate(Circle c1, Circle c2, Circle c3);
};</code></pre></div></div>
<p>
In the ECMAScript language binding, the <span class="estype">Function</span> object for
<code>triangulate</code> will exist on the <a class="dfnref" href="#dfn-interface-object">interface object</a>
for <span class="idltype">Circle</span>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var circles = getCircles(); <span class="comment">// an Array of Circle objects</span>
typeof Circle.triangulate; <span class="comment">// Evaluates to "function"</span>
Circle.prototype.triangulate; <span class="comment">// Evaluates to undefined</span>
circles[0].triangulate; <span class="comment">// Also evaluates to undefined</span>
<span class="comment">// Call the static operation</span>
var triangulationPoint = Circle.triangulate(circles[0], circles[1], circles[2]);</code></pre></div></div>
<p>
In the Java language binding, however, the <code>triangulate</code> method
will exist on an abstract class:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">Circle[] circles = getCircles(); <span class="comment">// an array of Circle objects</span>
<span class="comment">// Call the static operation</span>
Point triangulationPoint = CircleUtils.triangulate(circles[0], circles[1], circles[2]);</code></pre></div></div>
</div>
</div>
<div id="idl-overloading" class="section">
<h4>3.3.6. Overloading</h4>
<p>
If a <a class="dfnref" href="#dfn-regular-operation">regular operation</a>
or <a class="dfnref" href="#dfn-static-operation">static operation</a>
defined on an <a class="dfnref" href="#dfn-interface">interface</a>
has an <a class="dfnref" href="#dfn-identifier">identifier</a>
that is the same as the identifier of another operation on that
interface of the same kind (regular or static), then the operation is said to be
<dfn id="dfn-overloaded">overloaded</dfn>. When the identifier
of an overloaded operation is used to invoke one of the
operations on an object that implements the interface, the
number and types of the arguments passed to the operation
determine which of the overloaded operations is actually
invoked. If an interface has multiple
<a class="dfnref" href="#dfn-legacy-caller">legacy callers</a> defined on it,
then those legacy callers are also said to be overloaded.
In the ECMAScript language binding, <a href="#Constructor">constructors</a>
can be overloaded too. There are some restrictions on the arguments
that overloaded operations, legacy callers and constructors can be
specified to take, and in order to describe these restrictions,
the notion of an <em>effective overload set</em> is used.
</p>
<p>
An <dfn id="dfn-effective-overload-set">effective overload set</dfn>
for a given
<a class="dfnref" href="#dfn-identifier">identifier</a>,
argument count,
<a class="dfnref" href="#dfn-interface">interface</a> and
target language binding represents
the allowable invocations in that language binding
of operations or constructors
(specified with <a class="xattr" href="#Constructor">[Constructor]</a>
and <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>)
that have the specified identifier on that interface. The
set is used to determine whether there are ambiguities in the
overloaded operations or constructors specified on the interface.
The effective overload set is stated to be
“for regular operations”, “for static operations”, “for constructors” or “for legacy callers”,
to distinguish between these four uses. Effective overload sets for
legacy callers do not use an identifier; only an argument count,
interface and target language binding are needed.
</p>
<p>
The elements of an effective overload set are triples of the form
<<var>f</var>, <var>types</var>, <var>any</var>>. If the effective overload
set is for regular operations, static operations or legacy callers, then <var>f</var> is an operation,
and if it is for constructors, then <var>f</var> is an
extended attribute. In either case, <var>types</var> is a list
of IDL types and <var>any</var> is a list of boolean values.
Each triple represents an allowable invocation of the operation,
constructor or legacy caller with an argument value list of the given types.
<var>any</var> specifies whether a particular argument has been
annotated with the <a class="xattr" href="#AllowAny">[AllowAny]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
Due to the use of <a class="dfnref" href="#dfn-optional-argument">optional arguments</a>
and <a class="dfnref" href="#dfn-variadic-operation">variadic operations</a>
and constructors, there may
be multiple entries in an effective overload set identifying
the same operation or constructor.
</p>
<p>
The effective overload set for identifier <var>A</var>,
argument count <var>N</var>,
interface <var>I</var> and a given target language binding
is derived as follows. Whenever an argument of an extended
attribute is mentioned, it is referring to an argument of the
extended attribute’s <a class="dfnref" href="#dfn-xattr-named-argument-list">named argument list</a>.
</p>
<ol class="algorithm">
<li>Initialize <var>S</var> to ∅.</li>
<li>Let <var>F</var> be a set with elements as follows, according to the kind of effective overload set:
<dl class="switch">
<dt>For regular operations</dt>
<dd>
The elements of <var>F</var> are the <a class="dfnref" href="#dfn-regular-operation">regular operations</a> with
identifier <var>A</var> defined on interface <var>I</var>.
</dd>
<dt>For static operations</dt>
<dd>
The elements of <var>F</var> are the <a class="dfnref" href="#dfn-static-operation">static operations</a> with
identifier <var>A</var> defined on interface <var>I</var>.
</dd>
<dt>For constructors</dt>
<dd>
The elements of <var>F</var> are the
<a class="sym" href="#NamedConstructor">[NamedConstructor]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attributes</a> on interface <var>I</var> whose
<a class="dfnref" href="#dfn-xattr-named-argument-list">named argument lists’</a>
identifiers are <var>A</var>. If <var>A</var> is the same as the identifier of
interface <var>I</var>, then <var>F</var> also includes the
<a class="sym" href="#Constructor">[Constructor]</a> extended
attributes on <var>I</var>.
</dd>
<dt>For legacy callers</dt>
<dd>
The elements of <var>F</var> are the <a class="dfnref" href="#dfn-legacy-caller">callers</a>
defined on interface <var>I</var>.
</dd>
</dl>
</li>
<!--
<li>If the effective overload set is for regular operations, then:
<ol>
<li>
If the target language binding supports object indexing,
then remove from <var>F</var> any operation that is declared
to be an <a class='dfnref' href='#dfn-omittable'>omittable</a>
<a class='dfnref' href='#dfn-getter'>getter</a>,
<a class='dfnref' href='#dfn-setter'>setter</a>,
<a class='dfnref' href='#dfn-creator'>creator</a> or
<a class='dfnref' href='#dfn-deleter'>deleter</a>.
</li>
<li>
If the target language binding supports object calling,
then remove from <var>F</var> any operation that is declared
to be an omittable <a class='dfnref' href='#dfn-legacy-caller'>caller</a>.
</li>
<li>
If the target language binding supports object stringification,
then remove from <var>F</var> any operation that is declared
to be an omittable <a class='dfnref' href='#dfn-stringifier'>stringifier</a>.
</li>
</ol>
</li>
-->
<li>Let <var>maxarg</var> be the maximum number of arguments the operations or constructor extended attributes in <var>F</var> are declared to take.</li>
<li>Let <var>m</var> be the maximum of <var>maxarg</var> and <var>N</var>.</li>
<li>For each operation or extended attribute <var>X</var> in <var>F</var>:
<ol class="algorithm">
<li>Let <var>n</var> be the number of arguments <var>X</var> is declared to take.</li>
<li>Let <var>t</var><sub>0..<var>n</var>−1</sub> be the types of the arguments <var>X</var> is defined to take.</li>
<li>Let <var>a</var><sub>0..<var>n</var>−1</sub> be boolean values indicating whether each argument <var>X</var> is defined to take is declared with the <a class="xattr" href="#AllowAny">[AllowAny]</a> extended attribute.</li>
<li>Add to <var>S</var> the triple <<var>X</var>, <var>t</var><sub>0..<var>n</var>−1</sub>, <var>a</var><sub>0..<var>n</var>−1</sub>>.</li>
<li>If <var>n</var> > 0 and <var>X</var> is declared to be <a class="dfnref" href="#dfn-variadic-operation">variadic</a>, then:
<ol class="algorithm">
<li>Add to <var>S</var> the triple <<var>X</var>, <var>t</var><sub>0..<var>n</var>−2</sub>, <var>a</var><sub>0..<var>n</var>−2</sub>>.</li>
<li>For every integer <var>i</var>, such that <var>n</var> ≤ <var>i</var> ≤ <var>m</var>−1:
<ol class="algorithm">
<li>Let <var>u</var><sub>0..<var>i</var></sub> be a list of types, where <var>u</var><sub>j</sub> = <var>t</var><sub>j</sub> (for <var>j</var> < <var>n</var>) and <var>u</var><sub>j</sub> = <var>t</var><sub><var>n</var>−1</sub> (for <var>j</var> ≥ <var>n</var>).</li>
<li>Let <var>b</var><sub>0..<var>i</var></sub> be a list of booleans, where <var>b</var><sub>j</sub> = <var>a</var><sub>j</sub> (for <var>j</var> < <var>n</var>) and <var>b</var><sub>j</sub> = <var>a</var><sub><var>n</var>−1</sub> (for <var>j</var> ≥ <var>n</var>).</li>
<li>Add to <var>S</var> the triple <<var>X</var>, <var>u</var><sub>0..<var>i</var></sub>, <var>b</var><sub>0..<var>i</var></sub>>.</li>
</ol>
</li>
</ol>
</li>
<li>For every integer <var>i</var>, such that 0 < <var>i</var> < <var>n</var>:
<ol class="algorithm">
<li>If argument <var>i</var> of <var>X</var> is <a class="dfnref" href="#dfn-optional-argument">optional</a>, then add to <var>S</var> the triple <<var>X</var>, <var>t</var><sub>0..<var>i−1</var></sub>, <var>a</var><sub>0..<var>i−1</var></sub>>.</li>
</ol>
</li>
<li>If <var>n</var> > 0 and the first argument of <var>X</var> is optional, then add to <var>S</var> the triple <<var>X</var>, (), ()> (where “()” represents the empty list).</li>
</ol>
</li>
<li>
The effective overload set for identifier <var>A</var> and interface <var>X</var> is <var>S</var>.
</li>
</ol>
<p>
For each pair of entries in an
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
at least one of the following <span class="rfc2119">MUST</span> be true:
</p>
<ul>
<li>the type list lengths of the two entries are different, or</li>
<li>there is an index <var>i</var> such that the types in the two type lists at index <var>i</var> are <a class="dfnref" href="#dfn-distinguishable">distinguishable</a>.</li>
</ul>
<p>
Two types are
<dfn id="dfn-distinguishable">distinguishable</dfn> if there is
a “●” mark in the corresponding entry in the following table:
</p>
<table id="distinguishable-table" class="matrix">
<tr>
<th class="corner"></th>
<th>primitive</th>
<th>primitive?</th>
<th>DOMString</th>
<th>DOMString?</th>
<th>interface</th>
<th>interface?</th>
<th>object</th>
<th>object?</th>
<th>dictionary</th>
<th>dictionary?</th>
<th>sequence<<var>T</var>></th>
<th>sequence<<var>T</var>>?</th>
<th><var>T</var>[]</th>
<th><var>T</var>[]?</th>
<th>Date</th>
<th>Date?</th>
</tr>
<tr>
<th>primitive</th>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<th>primitive?</th>
<td class="belowdiagonal"></td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<th>DOMString</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<th>DOMString?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td>●</td>
<td></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<th>interface</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td>● <a class="note-link" href="#distinguishable-interface-note">[1]</a></td>
<td>● <a class="note-link" href="#distinguishable-interface-note">[1]</a></td>
<td></td>
<td></td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
<td>●</td>
</tr>
<tr>
<th>interface?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td>● <a class="note-link" href="#distinguishable-interface-note">[1]</a></td>
<td></td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
<td>●</td>
<td></td>
</tr>
<tr>
<th>object</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>object?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>dictionary</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>dictionary?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>sequence<<var>T</var>></th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>sequence<<var>T</var>>?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th><var>T</var>[]</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th><var>T</var>[]?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>Date</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
<td></td>
</tr>
<tr>
<th>Date?</th>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td class="belowdiagonal"></td>
<td></td>
</tr>
</table>
<ul class="notes">
<li id="distinguishable-interface-note"><a class="note-link">[1]</a> Two <a href="#idl-interface">interface types</a> are distinguishable only if two different <a class="dfnref" href="#dfn-interface">interfaces</a> are identified.</li>
</ul>
<div class="note"><div class="noteHeader">Note</div>
<p>
These restrictions on argument types reduce
the possibility of resolution ambiguity in
<a class="dfnref" href="#dfn-overloaded">overloaded</a> operations
and constructors, but do not completely
eliminate it. In the ECMAScript language binding, the
restrictions still can result in overloaded operation and constructor invocations
that cannot be distinguished solely based on the values passed to
the corresponding function. For example, with the following
<a class="dfnref" href="#dfn-interface">interfaces</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
<span class="comment">// ...</span>
};
interface B {
<span class="comment">// ...</span>
};
interface C {
void f(A? x);
void f(B? x);
};</code></pre></div></div>
<p>
it is possible to pass an object that implements both <span class="idltype">A</span>
and <span class="idltype">B</span> to <code>f</code>. Similarly,
passing <span class="esvalue">null</span> to <code>f</code>
would also be ambiguous. Since the ECMAScript
language binding provides no way to disambiguate such calls,
the interface description will need to
describe which operation is invoked in these cases. (It is
acceptable not to describe this if there is no observable
difference in behavior for a particular choice of operation
or constructor to disambiguate the call, or if no object will
actually implement the two interfaces, for example.)
</p>
</div>
<div class="example"><div class="exampleHeader">Example</div>
<p>
For the following interface:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
/* f1 */ void f(DOMString a);
/* f2 */ void f([AllowAny] DOMString a, DOMString b, float... c);
/* f3 */ void f();
/* f4 */ void f(long a, DOMString b, optional DOMString c, float... d);
};</code></pre></div></div>
<p>
the <a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for identifier <code>f</code> with argument count 4 (for the
ECMAScript language binding) is:
</p>
<div class="set">
{ <f1, (DOMString), (false)>,<br />
<f2, (DOMString, DOMString), (true, false)>,<br />
<f2, (DOMString, DOMString, float), (true, false, false)>,<br />
<f2, (DOMString, DOMString, float, float), (true, false, false, false)>,<br />
<f3, (), ()>,<br />
<f4, (long, DOMString), (false, false)>,<br />
<f4, (long, DOMString, DOMString), (false, false)>,<br />
<f4, (long, DOMString, DOMString, float), (false, false, false, false)> }
</div>
<p>
There are thus no overloaded operation resolution ambiguities
for the interface.
</p>
</div>
</div>
</div>
<div id="idl-dictionaries" class="section">
<h3>3.4. Dictionaries</h3>
<p>
A <dfn id="dfn-dictionary">dictionary</dfn> is a definition (matching
<a class="sym" href="#prod-Dictionary">Dictionary</a>)
used to define an associative array data type with a fixed, ordered set of key–value pairs,
termed <dfn id="dfn-dictionary-member">dictionary members</dfn>,
where keys are strings and values are of a particular type specified in the definition.
</p>
<pre class="syntax">dictionary <i>identifier</i> {
<i>dictionary-members…</i>
};</pre>
<p>
A dictionary can be defined to <dfn id="dfn-inherit-dictionary">inherit</dfn> from another dictionary.
If the identifier of the dictionary is followed by a colon and a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>,
then that scoped name identifies the inherited dictionary. The scoped name
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-resolve">resolve</a> to
a dictionary.
</p>
<p>
A dictionary <span class="rfc2119">MUST NOT</span> be declared such that
its inheritance hierarchy has a cycle. That is, an interface
<var>A</var> cannot inherit from itself, nor can it inherit from another
interface <var>B</var> that inherits from <var>A</var>, and so on.
</p>
<pre class="syntax">dictionary <em>Base</em> {
<i>dictionary-members…</i>
};
dictionary <i>Derived</i> : <em>Base</em> {
<i>dictionary-members…</i>
};</pre>
<p>
The <dfn id="dfn-inherited-dictionaries">inherited dictionaries</dfn> of
a given dictionary <var>D</var> is the set of all dictionaries that <var>D</var>
inherits from, directly or indirectly. If <var>D</var> does not <a class="dfnref" href="#dfn-inherit-dictionary">inherit</a>
from another dictionary, then the set is empty. Otherwise, the set
includes the dictionary <var>E</var> that <var>D</var> <a class="dfnref" href="#dfn-inherit-dictionary">inherits</a>
from and all of <var>E</var>’s <a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>.
</p>
<p>
A dictionary value of type <var>D</var> can have key–value pairs corresponding
to the dictionary members defined on <var>D</var> and on any of <var>D</var>’s
<a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>.
On a given dictionary value, the presence of each dictionary member is optional.
When specified in the dictionary value, a dictionary member is said to be
<dfn id="dfn-present">present</dfn>, otherwise it is <a class="dfnref" href="#dfn-present">not present</a>.
Dictionary members can also optionally have a <dfn id="dfn-default-value">default value</dfn>, which is
the value the dictionary member is to be considered to have when not present.
</p>
<p>
Each <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> (matching
<a class="sym" href="#prod-DictionaryMember">DictionaryMember</a>) is specified
as a type (matching <a class="sym" href="#prod-Type">Type</a>) followed by an
<a class="dfnref" href="#dfn-identifier">identifier</a>
(given by an <a class="sym" href="#prod-identifier">identifier</a> token following
the type). The identifier is the key name of the key–value pair.
If the <a class="sym" href="#prod-Type">Type</a>
is a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>, then it
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-resolve">resolve</a> to an
interface, dictionary or <a class="dfnref" href="#dfn-typedef">typedef</a>.
</p>
<pre class="syntax">dictionary <i>identifier</i> {
<i>type</i> <i>identifier</i>;
};</pre>
<p>
If the identifier is followed by a <span class="char">U+003D EQUALS SIGN ("=")</span>
and a value (matching <a class="sym" href="#prod-ConstValue">ConstValue</a>),
then that gives the dictionary member its <a class="dfnref" href="#dfn-default-value">default value</a>,
in the same way that a <a class="dfnref" href="#dfn-constant">constant</a> is
given its value.
</p>
<pre class="syntax">dictionary <i>identifier</i> {
<i>type</i> <i>identifier</i> = <i>value</i>;
};</pre>
<p>
The order of the <a class="dfnref" href="#dfn-dictionary-member">dictionary members</a>
on a given dictionary is the order in which they appear in the dictionary
<a class="dfnref" href="#dfn-definition">definition</a>, and
with inherited dictionary members ordered before non-inherited members.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>For example, with the following definitions:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">dictionary B : A {
long a;
long b;
};
dictionary A {
long c;
long d;
};
dictionary C : B {
long e;
long f;
};</code></pre></div></div>
<p>
the order of the <a class="dfnref" href="#dfn-dictionary-member">dictionary members</a>
of a dictionary value of type <span class="idltype">C</span> is
c, d, a, b, e, f.
</p>
<p>
Dictionaries are required to have their members ordered because
in some language bindings the behavior observed when passing
a dictionary value to a platform object depends on the order
the dictionary members are fetched. For example, consider the
following additional interface:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Something {
void f(A a);
};</code></pre></div></div>
<p>
and this ECMAScript code:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var something = getSomething(); <span class="comment">// Get an instance of Something.</span>
var x = 0;
var dict = { };
Object.defineProperty(dict, "d", { get: function() { return ++x; } });
Object.defineProperty(dict, "c", { get: function() { return ++x; } });
something.f(dict);</code></pre></div></div>
<p>
The order that the dictionary members are fetched in determines
what values they will be taken to have. Since the order for
<span class="idltype">A</span> is defined to be c then d,
the value for c will be 1 and the value for d will be 2.
</p>
</div>
<p>
The identifier of a dictionary member <span class="rfc2119">MUST NOT</span> be
the same as that of another dictionary member defined on the dictionary or
on that dictionary’s <a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>.
</p>
<p>
Dictionaries <span class="rfc2119">MUST NOT</span> be used as the type of an
<a class="dfnref" href="#dfn-attribute">attribute</a>,
<a class="dfnref" href="#dfn-constant">constant</a> or
<a class="dfnref" href="#dfn-exception-field">exception field</a>.
</p>
<p>
No <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this specification are applicable to dictionaries.
</p>
<p>
The following extended attributes are applicable to dictionary members:
<a class="xattr" href="#Clamp">[Clamp]</a>,
<a class="xattr" href="#EnforceRange">[EnforceRange]</a>.
</p>
<table class="grammar"><tr id="proddef-Dictionary"><td><span class="prod-number">[10]</span></td><td><a class="sym" href="#prod-Dictionary">Dictionary</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"dictionary" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-Inheritance">Inheritance</a> "{" <a class="sym" href="#prod-DictionaryMembers">DictionaryMembers</a> "}" ";"</span></td></tr><tr id="proddef-DictionaryMembers"><td><span class="prod-number">[11]</span></td><td><a class="sym" href="#prod-DictionaryMembers">DictionaryMembers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-DictionaryMember">DictionaryMember</a> <a class="sym" href="#prod-DictionaryMembers">DictionaryMembers</a> <br /> |
ε</span></td></tr><tr id="proddef-DictionaryMember"><td><span class="prod-number">[12]</span></td><td><a class="sym" href="#prod-DictionaryMember">DictionaryMember</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Type">Type</a> <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-DefaultValue">DefaultValue</a> ";"</span></td></tr><tr id="proddef-DefaultValue"><td><span class="prod-number">[13]</span></td><td><a class="sym" href="#prod-DefaultValue">DefaultValue</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"=" <a class="sym" href="#prod-ConstValue">ConstValue</a> <br /> |
ε</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
One use of dictionary types is to allow a number of optional arguments to
an <a class="dfnref" href="#dfn-operation">operation</a> without being
constrained as to the order they are specified at the call site. For example,
consider the following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Constructor]
interface Point {
attribute float x;
attribute float y;
};
dictionary PaintOptions {
DOMString? fillPattern = "black";
DOMString? strokePattern = null;
Point position;
};
interface GraphicsContext {
void drawRectangle(float width, float height, optional PaintOptions options);
};</code></pre></div></div>
<p>
In an ECMAScript implementation of the IDL, an <span class="estype">Object</span>
can be passed in for the optional <span class="idltype">PaintOptions</span> dictionary:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code"><span class="comment">// Get an instance of GraphicsContext.</span>
var ctx = getGraphicsContext();
<span class="comment">// Draw a rectangle.</span>
ctx.drawRectangle(300, 200, { fillPattern: "red", position: new Point(10, 10) });</code></pre></div></div>
<p>
Both fillPattern and strokePattern are given <a class="dfnref" href="#dfn-default-value">default values</a>,
so if they are omitted, the definition of drawRectangle can assume that they
have the given default values and not include explicit wording to handle
their non-presence.
</p>
</div>
</div>
<div id="idl-exceptions" class="section">
<h3>3.5. Exceptions</h3>
<p>
An <dfn id="dfn-exception">exception</dfn> is a definition (matching
<a class="sym" href="#prod-Exception">Exception</a>) used
to declare a class of exceptions that can be thrown by implementations.
</p>
<pre class="syntax">exception <i>identifier</i> {
<i>exception-members…</i>
};</pre>
<p>
Exceptions are different from <a class="dfnref" href="#dfn-interface">interfaces</a>
in that they can have only <a class="dfnref" href="#dfn-constant">constants</a>
and <a class="dfnref" href="#dfn-exception-field">exception fields</a>
declared on them (together known as <dfn id="dfn-exception-member">exception members</dfn>),
rather than the three types of <a class="dfnref" href="#dfn-interface-member">interface members</a>.
</p>
<p>
An exception can be defined to <dfn id="dfn-inherit-exception">inherit</dfn> from another exception.
If the identifier of the exception is followed by a <span class="char">U+003A COLON (":")</span>
character and a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>,
then that scoped name identifies the inherited exception. The scoped name
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-resolve">resolve</a> to
an exception.
</p>
<p>
An exception <span class="rfc2119">MUST NOT</span> be declared such that
its inheritance hierarchy has a cycle. That is, an interface
<var>A</var> cannot inherit from itself, nor can it inherit from another
interface <var>B</var> that inherits from <var>A</var>, and so on.
</p>
<p>
An object that implements an exception that inherits from another
also implements that inherited exception. The object therefore will also
have members that correspond to the
exception members from the inherited exception.
</p>
<pre class="syntax">exception <em>Base</em> {
<i>exception-members…</i>
};
exception <i>Derived</i> : <em>Base</em> {
<i>exception-members…</i>
};</pre>
<p>
Exceptions have an associated <dfn id="dfn-exception-message">message</dfn>, a
<a class="idltype" href="#idl-DOMString">DOMString</a>, which is
exposed on an exception object in a language binding-specific manner.
</p>
<p>
Exceptions also have an associated <dfn id="dfn-exception-type">type</dfn>, also
a <a class="idltype" href="#idl-DOMString">DOMString</a>, which is
exposed on an exception object in a language binding-specific manner.
The <a class="dfnref" href="#dfn-exception-type">type</a> of an exception
is intended to be used to distinguish between the different kinds of
exceptions that can be represented by the given IDL exception.
</p>
<p>
Exceptions can be <dfn id="dfn-throw">thrown</dfn>, optionally with a specific
<a class="dfnref" href="#dfn-exception-message">message</a> and
<a class="dfnref" href="#dfn-exception-type">type</a>,
the behavior of which again is language binding-specific.
</p>
<p>
Each <dfn id="dfn-exception-field">exception field</dfn> (matching
<a class="sym" href="#prod-ExceptionField">ExceptionField</a>) is specified
as a type (matching <a class="sym" href="#prod-Type">Type</a>) followed by an
<a class="dfnref" href="#dfn-identifier">identifier</a>
(given by an <a class="sym" href="#prod-identifier">identifier</a> token following
the type). If the <a class="sym" href="#prod-Type">Type</a>
is a <a class="dfnref" href="#dfn-scoped-name">scoped name</a>, then it
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-resolve">resolve</a> to an
interface or <a class="dfnref" href="#dfn-typedef">typedef</a>.
Exception fields are
similar to <a class="dfnref" href="#dfn-attribute">attributes</a> in that they
will correspond to attributes of the same name and type on exception objects
that are thrown by implementations.
</p>
<pre class="syntax">exception <i>identifier</i> {
<i>type</i> <i>identifier</i>;
};</pre>
<p>
The identifier of an exception field <span class="rfc2119">MUST NOT</span> be
the same as that of another <a class="dfnref" href="#dfn-exception-member">exception member</a>,
and it <span class="rfc2119">MUST NOT</span> be “name” or “message”.
</p>
<p>
Each exception member can be preceded by a list of <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a> (matching
<a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a>),
which can control how the exception member will be handled in language bindings.
</p>
<pre class="syntax">exception <i>identifier</i> {
[<em>extended-attributes</em>]
const <i>type</i> <i>identifier</i> = <i>value</i>;
[<em>extended-attributes</em>]
<i>type</i> <i>identifier</i>;
};</pre>
<div class="note"><div class="noteHeader">Note</div>
<p>
It is recommended that future Web platform specifications not
mint new IDL <a class="dfnref" href="#dfn-exception">exceptions</a> but instead just use <span class="estype">DOMException</span>
and distinguish different kinds of exceptions by their
<a class="dfnref" href="#dfn-exception-type">type</a> and
not by an integer code. The type will be exposed in ECMAScript using a “name” property on the
exception object. (It may however be useful to mint new IDL exceptions
if additional <a class="dfnref" href="#dfn-exception-field">exception fields</a>
are required.)
</p>
<p>
It is recommended that exception names be chosen that use a similar
naming scheme as the built-in ECMAScript error objects. For example,
“HierarchyRequestError” or “NotFoundError”, if names are being given
to the DOM Core exceptions. Any new IDL exceptions should also be named similarly.
</p>
<p>
There is no IDL syntax for declaring exception types. In prose, an
exception of a particular type can be thrown by using wording like the
following:
</p>
<blockquote>Throw a <span class="estype">DOMException</span> of type
<a class="dfnref" href="#dfn-exception-type">type</a>
HierarchyRequestError with <a class="dfnref" href="#dfn-exception-message">message</a>
“Cannot append that Node here”.</blockquote>
</div>
<p>
The following extended attributes are applicable to exceptions:
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>.
</p>
<p>
No <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this specification are applicable to exception fields.
</p>
<table class="grammar"><tr id="proddef-Exception"><td><span class="prod-number">[14]</span></td><td><a class="sym" href="#prod-Exception">Exception</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"exception" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-Inheritance">Inheritance</a> "{" <a class="sym" href="#prod-ExceptionMembers">ExceptionMembers</a> "}" ";"</span></td></tr><tr id="proddef-ExceptionMembers"><td><span class="prod-number">[15]</span></td><td><a class="sym" href="#prod-ExceptionMembers">ExceptionMembers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-ExceptionMember">ExceptionMember</a> <a class="sym" href="#prod-ExceptionMembers">ExceptionMembers</a> <br /> |
ε</span></td></tr><tr id="proddef-ExceptionMember"><td><span class="prod-number">[37]</span></td><td><a class="sym" href="#prod-ExceptionMember">ExceptionMember</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Const">Const</a> <br /> |
<a class="sym" href="#prod-ExceptionField">ExceptionField</a></span></td></tr><tr id="proddef-ExceptionField"><td><span class="prod-number">[38]</span></td><td><a class="sym" href="#prod-ExceptionField">ExceptionField</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-AttributeType">AttributeType</a> <a class="sym" href="#prod-identifier">identifier</a> ";"</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following example demonstrates how a reduced version of DOM Core’s
<span class="idltype">DOMException</span> might be defined for three
of the existing exception types and one new type. Exception types
have historically been distinguished only by an integer code. The new
exception type here is not.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">exception DOMException {
const unsigned short INDEX_SIZE_ERR = 1;
const unsigned short DOMSTRING_SIZE_ERR = 2;
const unsigned short HIERARCHY_REQUEST_ERR = 3;
unsigned short code;
};</code></pre></div></div>
<p>
Assume that the specification defines that throwing a <span class="estype">DOMException</span>
of a particular type uses a corresponding value for the
code field, as follows:
</p>
<table>
<tr><th>Type</th><th>Value of code</th></tr>
<tr><td>IndexSizeError</td><td>INDEX_SIZE_ERR</td></tr>
<tr><td>DOMStringSizeError</td><td>DOMSTRING_SIZE_ERR</td></tr>
<tr><td>HierarchyRequestError</td><td>HIERARCHY_REQUEST_ERR</td></tr>
<tr><td>InsufficientBlingError</td><td>0</td></tr>
</table>
<p>
In an ECMAScript implementation, the types of <span class="idltype">DOMException</span>s
could be distinguished by code, and the existing ones and the new ones could
be distinguished by type:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">try {
document.appendChild(document);
} catch (e) {
<span class="comment">// The traditional way, by looking at the code.</span>
if (e.code == DOMException.HIERARCHY_REQUEST_ERR) {
...
}
<span class="comment">// By looking at the name.</span>
if (e.name == "HierarchyRequestError") {
...
}
if (e.name == "InsufficientBlingError") {
e.code; <span class="comment">// This would evaluate to 0.</span>
...
}
}</code></pre></div></div>
<!--
<p>
The advantage of looking at the name rather than code is that exception
names are much less likely to conflict across specifications. Exception
codes do conflict already. For example, if a
<span class='idltype'>DOMException</span> or an <span class='idltype'>SVGException</span>
could be thrown inside the one <code>try</code> block, authors would
need to check both the code and the interface of the exception object
to be sure of what kind of exception was thrown.
</p>
-->
<p>
Note that using <code>e instanceof <var>ExceptionClass</var></code>
can return <code>false</code> if the exception object comes from a
different document than the global scope of the running script, even if
the exception is an instance of the <var>ExceptionClass</var> in
its own document. For this reason, authors are suggested not to use
<code>instanceof</code> to perform exception type testing.
</p>
</div>
</div>
<div id="idl-typedefs" class="section">
<h3>3.6. Typedefs</h3>
<p>
A <dfn id="dfn-typedef">typedef</dfn> is a definition (matching
<a class="sym" href="#prod-Typedef">Typedef</a>)
used to declare a new name for a type. This new name is not exposed
by language bindings; it is purely used as a shorthand for referencing
the type in the IDL.
</p>
<pre class="syntax">typedef <i>type</i> <i>identifier</i>;</pre>
<p>
The type being given a new name is specified after the <code>typedef</code>
keyword (matching <a class="sym" href="#prod-Type">Type</a>), and the
<a class="sym" href="#prod-identifier">identifier</a> token following the
type gives the name.
</p>
<p>
The <a class="sym" href="#prod-Type">Type</a> <span class="rfc2119">MUST NOT</span>
be a <a class="dfnref" href="#dfn-scoped-name">scoped name</a> that
<a class="dfnref" href="#dfn-resolve">resolves</a> to an
<a class="dfnref" href="#dfn-interface">interface</a> or
<a class="dfnref" href="#dfn-dictionary">dictionary</a>.
</p>
<p>
No <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this specification are applicable to <a class="dfnref" href="#dfn-typedef">typedefs</a>.
</p>
<table class="grammar"><tr id="proddef-Typedef"><td><span class="prod-number">[16]</span></td><td><a class="sym" href="#prod-Typedef">Typedef</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"typedef" <a class="sym" href="#prod-Type">Type</a> <a class="sym" href="#prod-identifier">identifier</a> ";"</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
demonstrates the use of <a class="dfnref" href="#dfn-typedef">typedefs</a>
to allow the use of a short
<a class="dfnref" href="#dfn-identifier">identifier</a> instead of a long
<a class="dfnref" href="#dfn-scoped-name">scoped name</a> or
<a href="#idl-sequence">sequence type</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">module gfx {
module geom {
module geom2d {
interface Point {
attribute float x;
attribute float y;
};
typedef sequence<Point> PointSequence;
interface Rect {
attribute Point topleft;
attribute Point bottomright;
};
};
};
};
module gui {
typedef gfx::geom::geom2d::Point Point;
typedef gfx::geom::geom2d::PointSequence PointSequence;
typedef gfx::geom::geom2d::Rect Rect;
interface Widget {
readonly attribute Rect bounds;
boolean pointWithinBounds(Point p);
boolean allPointsWithinBounds(PointSequence ps);
};
};</code></pre></div></div>
</div>
</div>
<div id="idl-implements-statements" class="section">
<h3>3.7. Implements statements</h3>
<p>
An <dfn id="dfn-implements-statement">implements statement</dfn> is a definition
(matching <a class="sym" href="#prod-ImplementsStatement">ImplementsStatement</a>)
used to declare that all objects implementing an interface <var>A</var>
(identified by the first <a class="dfnref" href="#dfn-scoped-name">scoped name</a>)
<span class="rfc2119">MUST</span> additionally implement interface <var>B</var>
(identified by the second scoped name), including all other interfaces that
<var>B</var> inherits from.
</p>
<pre class="syntax"><i>scoped-name-A</i> implements <i>scoped-name-B</i>;</pre>
<p>
Transitively, if objects implementing <var>B</var>
are declared with an <a class="dfnref" href="#dfn-implements-statement">implements statement</a>
to additionally implement interface <var>C</var>, then all objects implementing
<var>A</var> do additionally implement interface <var>C</var>.
</p>
<p>
<a class="dfnref" href="#dfn-implements-statement">Implements statements</a>
can appear in a <a class="dfnref" href="#dfn-module">module</a>
or at the <a class="dfnref" href="#dfn-outermost-scope">outermost scope</a>.
</p>
<p>
The two <a class="dfnref" href="#dfn-scoped-name">scoped names</a> <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-resolve">resolve</a> to two different interfaces.
</p>
<p>
The interface identified on the left-hand side of an implements statement
<span class="rfc2119">MUST NOT</span> <a class="dfnref" href="#dfn-inherit">inherit</a>
from the interface identifier on the right-hand side, and vice versa.
</p>
<p>
If each <a class="dfnref" href="#dfn-implements-statement">implements statement</a> is
considered to be an edge in a directed graph, from a node representing the interface
on the left-hand side of the statement to a node representing the interface on the
right-hand side, then this graph <span class="rfc2119">MUST NOT</span> have any cycles.
</p>
<p>
Interfaces that a given object implements are partitioned into those that are considered
<dfn id="dfn-supplemental-interface">supplemental interfaces</dfn> and those that are not.
An interface <var>A</var> is considered to be a
<a class="dfnref" href="#dfn-supplemental-interface">supplemental interface</a> of an object
<var>O</var> if:
</p>
<ul>
<li><var>O</var> implements a different interface <var>B</var>, and the IDL states that
<code>B implements A</code>; or</li>
<li><var>O</var> implements a different <a class="dfnref" href="#dfn-supplemental-interface">supplemental interface</a>
<var>C</var>, and <var>C</var> <a class="dfnref" href="#dfn-inherit">inherits</a> from <var>A</var>.</li>
</ul>
<div class="note"><div class="noteHeader">Note</div>
<p>
Specification authors are discouraged from writing <a class="dfnref" href="#dfn-implements-statement">implements statements</a>
where the <a class="dfnref" href="#dfn-interface">interface</a> on the left-hand side
is a <a class="dfnref" href="#dfn-supplemental-interface">supplemental interface</a>.
For example, if author 1 writes:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Window { ... };
interface SomeFunctionality { ... };
Window implements SomeFunctionality;</code></pre></div></div>
<p>
and author 2 later writes:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Gizmo { ... };
interface MoreFunctionality { ... };
SomeFunctionality implements MoreFunctionality;
Gizmo implements SomeFunctionality;</code></pre></div></div>
<p>
then it might be the case that author 2 is unaware of exactly which
interfaces already are used on the left-hand side of an
<code>implements SomeFunctionality</code> statement, and so has
required more object implement <span class="idltype">MoreFunctionality</span>
than he or she expected.
</p>
<p>
Better in this case would be for author 2 to write:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Gizmo { ... };
interface MoreFunctionality { ... };
Gizmo implements SomeFunctionality;
Gizmo implements MoreFunctionality;</code></pre></div></div>
</div>
<p>
The <dfn id="dfn-consequential-interfaces">consequential interfaces</dfn> of an interface
<var>A</var> are:
</p>
<ul>
<li>each interface <var>B</var> where the IDL states <code>A implements B</code>;</li>
<li>each interface that a consequential interface of <var>A</var> inherits from; and</li>
<li>each interface <var>D</var> where the IDL states that <code>C implements D</code>,
where <var>C</var> is a consequential interface of <var>A</var>.</li>
</ul>
<p>
For a given interface, there <span class="rfc2119">MUST NOT</span>
be any member defined on any of its consequential interfaces
whose identifier is the same as any other member defined on any
of those consequential interfaces or on the original interface itself.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>For example, that precludes the following:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A { attribute long x; };
interface B { attribute long x; };
A implements B; <span class="comment">// B::x would clash with A::x</span>
interface C { attribute long y; };
interface D { attribute long y; };
interface E : D { };
C implements E; <span class="comment">// D::y would clash with C::y</span>
interface F { };
interface H { attribute long z; };
interface I { attribute long z; };
F implements H;
F implements I; <span class="comment">// H::z and I::z would clash when mixed in to F</span></code></pre></div></div>
</div>
<p>
No <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this specification are applicable to
<a class="dfnref" href="#dfn-implements-statement">implements statements</a>.
</p>
<table class="grammar"><tr id="proddef-ImplementsStatement"><td><span class="prod-number">[17]</span></td><td><a class="sym" href="#prod-ImplementsStatement">ImplementsStatement</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ScopedName">ScopedName</a> "implements" <a class="sym" href="#prod-ScopedName">ScopedName</a> ";"</span></td></tr></table>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines two <a class="dfnref" href="#dfn-interface">interfaces</a>, stating
that one interface is always implemented on objects implementing the other.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">module dom {
interface Node {
readonly attribute unsigned short nodeType;
<span class="comment">// ...</span>
};
};
module events {
interface EventTarget {
void addEventListener(DOMString type,
EventListener listener,
boolean useCapture);
<span class="comment">// ...</span>
};
dom::Node implements EventTarget;
};</code></pre></div></div>
<p>
An ECMAScript implementation would thus have an “addEventListener”
property in the prototype chain of every <span class="idltype">Node</span>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var n = getNode(); <span class="comment">// Obtain an instance of Node.</span>
typeof n.addEventListener; <span class="comment">// Evaluates to "function".</span></code></pre></div></div>
<p>
Similarly, in Java, any <span class="javatype">Node</span>
object could be cast to <span class="javatype">EventTarget</span>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">Node n = getNode(); <span class="comment">// Obtain an instance of Node.</span>
EventTarget et = (EventTarget) n; <span class="comment">// This should never throw ClassCastException.</span></code></pre></div></div>
<p>
Note that it is not the case that all <span class="idltype">EventTarget</span>
objects implement <span class="idltype">Node</span>.
</p>
</div>
</div>
<div id="idl-objects" class="section">
<h3>3.8. Objects implementing interfaces</h3>
<p>
In systems described by <a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a>,
each object that implements one or more <a class="dfnref" href="#dfn-interface">interfaces</a>
is considered to be either a <dfn id="dfn-platform-object">platform object</dfn> or a
<dfn id="dfn-user-object">user object</dfn>. Platform objects are those which are
created and supplied by an implementation of those IDL fragments. In a browser, for example,
the browser-implemented DOM objects (implementing interfaces such as <span class="idltype">Node</span> and
<span class="idltype">Document</span>) that provide access to a web page’s contents
to ECMAScript running in the page would be platform objects. An ECMAScript library
that adds support for some Web API that is not natively supported by a browser
would also be considered to expose platform objects. Exception objects too are
considered to be platform objects.
</p>
<p>
On the other hand, user objects are those that authors would create, implementing
particular interfaces that the Web APIs use to be able to invoke author-defined
operations or to send and receive values to the author’s program through
manipulating the object’s attributes. In a web page, an ECMAScript object
that implements the <span class="idltype">EventListener</span> interface, which is
used to register a callback that the DOM Events implementation invokes, would be considered
to be a user object. There is no way for a user object to represent an exception.
</p>
<p>
In IDL, the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
is used to annotate <a class="dfnref" href="#dfn-interface">interfaces</a> that
can be implemented as user objects. These interfaces may or may not also be
implemented as platform objects.
</p>
<p>
Only interfaces with all of the following characteristics can be implemented
as user objects:
</p>
<ul>
<li>
The interface has a
<a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
on it.
</li>
<li>
The interface does not <a class="dfnref" href="#dfn-inherit">inherit</a>
from any non-<a class="xattr" href="#Callback">[Callback]</a>-annotated interface.
</li>
<li>
The interface and all of its <a class="dfnref" href="#dfn-inherited-interfaces">inherited interfaces</a>
do not have any <a class="dfnref" href="#dfn-consequential-interfaces">consequential interfaces</a>.
</li>
<li>
The interface does not have a
<a class="xattr" href="#Constructor">[Constructor]</a> or
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
extended attribute on it.
</li>
<li>
The interface has no <a class="dfnref" href="#dfn-special-operation">special operations</a>.
</li>
<li>
No <a class="dfnref" href="#dfn-attribute">attribute</a> on the interface has a
<a class="xattr" href="#PutForwards">[PutForwards]</a>,
<a class="xattr" href="#Replaceable">[Replaceable]</a>,
<a class="xattr" href="#TreatNullAs">[TreatNullAs]</a> or
<a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
extended attribute on it.
</li>
</ul>
<p>
When a user object is passed to a platform object expecting an object of a
particular interface, be it as an argument value in an operation invocation,
by assignment to an attribute, or through a dictionary member, and that
interface was not declared using the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>, then
the object will not be considered to be one that implements that interface.
Language bindings define when this check is made and what happens
in response in such a case (such as throwing an exception).
</p>
</div>
<!--
<div id='idl-valuetypes' class='section'>
<h3>Valuetypes</h3>
<p>
Valuetypes in OMG IDL are used to define types similar to structs in C.
That is, they define composite types that can have zero or more
member variables that are passed by value. OMG IDL valuetypes have the
additional feature of allowing <span class='idlvalue'>null</span> to
be passed in place of an object with those member variables. An
OMG IDL boxed valuetype is a special case, where the valuetype has
a single member.
</p>
<p>
The IDL defined in this specification supports only
<dfn id='dfn-boxed-valuetype'>boxed valuetypes</dfn>, which are definitions
that match the <a class='sym' href='#prod-Valuetype'>Valuetype</a> non-terminal.
The <a class='dfnref' href='#dfn-identifier'>identifier</a> of the valuetype
is given by the <a class='sym' href='#prod-identifier'>identifier</a> terminal,
and the type being boxed is given by the
<a class='sym' href='#prod-BoxedType'>BoxedType</a> non-terminal. If the
<a class='sym' href='#prod-BoxedType'>BoxedType</a> is a
<a class='sym' href='#prod-ScopedName'>ScopedName</a>, then it
<span class='rfc2119'>MUST</span> refer to a type that does not allow
<span class='idlvalue'>null</span> as a value (i.e.,
<a class='idltype' href='#idl-boolean'>boolean</a>,
<a class='idltype' href='#idl-octet'>octet</a>,
<a class='idltype' href='#idl-short'>short</a>,
<a class='idltype' href='#idl-unsigned-short'>unsigned short</a>,
<a class='idltype' href='#idl-unsigned-long'>unsigned long</a>,
<a class='idltype' href='#idl-long-long'>long long</a>,
<a class='idltype' href='#idl-unsigned-long-long'>unsigned long long</a>,
<a class='idltype' href='#idl-float'>float</a>,
<a class='idltype' href='#idl-double'>double</a> or
<a class='idltype' href='#idl-sequence'>sequence<<var>T</var>></a>.
</p>
<p>
Boxed valuetypes are essentially used just for allowing a <span class='idlvalue'>null</span>
value to be used where normally a non-null value could only be used.
</p>
<div class='example'>
<p>
The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a>
demonstrates the use of <a class='dfnref' href='#dfn-boxed-valuetype'>boxed valuetypes</a>:
</p>
<x:codeblock language='idl'>valuetype OptionalFloat float;
interface Person {
<span class='comment'>// This attribute can be a float or null. In this case, null might be used</span>
<span class='comment'>// to represent the case where the height of the person is unknown.</span>
readonly attribute OptionalFloat height;
};</x:codeblock>
</div>
<?productions grammar Valuetype ValuetypeRest?>
</div>
-->
<div id="idl-types" class="section">
<h3>3.9. Types</h3>
<p>
This section lists the types supported by Web IDL, the set of values
corresponding to each type, and how <a class="dfnref" href="#dfn-constant">constants</a>
of that type are represented.
</p>
<p>
The following types are known as <dfn id="dfn-integer-type">integer types</dfn>:
<a class="idltype" href="#idl-byte">byte</a>,
<a class="idltype" href="#idl-octet">octet</a>,
<a class="idltype" href="#idl-short">short</a>,
<a class="idltype" href="#idl-unsigned-short">unsigned short</a>,
<a class="idltype" href="#idl-long">long</a>,
<a class="idltype" href="#idl-unsigned-long">unsigned long</a>,
<a class="idltype" href="#idl-long-long">long long</a> and
<a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a>.
</p>
<p>
The following types are known as <dfn id="dfn-primitive-type">primitive types</dfn>:
<a class="idltype" href="#idl-boolean">boolean</a>,
the <a class="dfnref" href="#dfn-integer-type">integer types</a>,
<a class="idltype" href="#idl-float">float</a> and
<a class="idltype" href="#idl-float">double</a>.
</p>
<p>
The <a class="idltype" href="#idl-object">object</a> type and
all <a class="dfnref" href="#idl-interface">interface types</a>
are known as <dfn id="dfn-object-type">object types</dfn>.
</p>
<p>
Every type has a <dfn id="dfn-type-name">type name</dfn>, which
is a string, not necessarily unique, that identifies the type.
Each sub-section below defines what the type name is for each
type.
</p>
<p id="type-conversion-exceptions">
When conversions are made from language binding specific types to
IDL types in order to invoke an <a class="dfnref" href="#dfn-operation">operation</a>
or assign a value to an <a class="dfnref" href="#dfn-attribute">attribute</a>,
all conversions necessary will be performed before the
specified functionality of the operation or attribute assignment
is carried out. If the conversion cannot
be performed, then the operation will not run or
the attribute will not be updated. In some language bindings,
type conversions could result in an exception being thrown.
In such cases, these exceptions will be propagated to the
code that made the attempt to invoke the operation or
assign to the attribute.
</p>
<table class="grammar"><tr id="proddef-Type"><td><span class="prod-number">[46]</span></td><td><a class="sym" href="#prod-Type">Type</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-AttributeType">AttributeType</a> <br /> |
<a class="sym" href="#prod-SequenceType">SequenceType</a></span></td></tr><tr id="proddef-SequenceType"><td><span class="prod-number">[47]</span></td><td><a class="sym" href="#prod-SequenceType">SequenceType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"sequence" "<" <a class="sym" href="#prod-Type">Type</a> ">" <a class="sym" href="#prod-Null">Null</a></span></td></tr><tr id="proddef-AttributeType"><td><span class="prod-number">[48]</span></td><td><a class="sym" href="#prod-AttributeType">AttributeType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-PrimitiveOrStringType">PrimitiveOrStringType</a> <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
<a class="sym" href="#prod-ScopedName">ScopedName</a> <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"object" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"Date" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"any" <a class="sym" href="#prod-TypeSuffixStartingWithArray">TypeSuffixStartingWithArray</a></span></td></tr><tr id="proddef-ConstType"><td><span class="prod-number">[49]</span></td><td><a class="sym" href="#prod-ConstType">ConstType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-PrimitiveOrStringType">PrimitiveOrStringType</a> <a class="sym" href="#prod-Null">Null</a></span></td></tr><tr id="proddef-PrimitiveOrStringType"><td><span class="prod-number">[50]</span></td><td><a class="sym" href="#prod-PrimitiveOrStringType">PrimitiveOrStringType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-UnsignedIntegerType">UnsignedIntegerType</a> <br /> |
"boolean" <br /> |
"byte" <br /> |
"octet" <br /> |
"float" <br /> |
"double" <br /> |
"DOMString"</span></td></tr><tr id="proddef-UnsignedIntegerType"><td><span class="prod-number">[51]</span></td><td><a class="sym" href="#prod-UnsignedIntegerType">UnsignedIntegerType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"unsigned" <a class="sym" href="#prod-IntegerType">IntegerType</a> <br /> |
<a class="sym" href="#prod-IntegerType">IntegerType</a></span></td></tr><tr id="proddef-IntegerType"><td><span class="prod-number">[52]</span></td><td><a class="sym" href="#prod-IntegerType">IntegerType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"short" <br /> |
"long" <a class="sym" href="#prod-OptionalLong">OptionalLong</a></span></td></tr><tr id="proddef-OptionalLong"><td><span class="prod-number">[53]</span></td><td><a class="sym" href="#prod-OptionalLong">OptionalLong</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"long" <br /> |
ε</span></td></tr><tr id="proddef-TypeSuffix"><td><span class="prod-number">[54]</span></td><td><a class="sym" href="#prod-TypeSuffix">TypeSuffix</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"[" "]" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"?" <a class="sym" href="#prod-TypeSuffixStartingWithArray">TypeSuffixStartingWithArray</a> <br /> |
ε</span></td></tr><tr id="proddef-TypeSuffixStartingWithArray"><td><span class="prod-number">[55]</span></td><td><a class="sym" href="#prod-TypeSuffixStartingWithArray">TypeSuffixStartingWithArray</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"[" "]" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
ε</span></td></tr><tr id="proddef-Null"><td><span class="prod-number">[56]</span></td><td><a class="sym" href="#prod-Null">Null</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"?" <br /> |
ε</span></td></tr></table>
<div id="idl-any" class="section">
<h4>3.9.1. any</h4>
<p>
The <a class="idltype" href="#idl-any">any</a> type is the union of all other possible types.
Its <a class="dfnref" href="#dfn-type-name">type name</a> is “Any”.
</p>
<p>
The <a class="idltype" href="#idl-any">any</a> type is like
a discriminated union type, in that each of its values has a
specific non-<a class="idltype" href="#idl-any">any</a> type
associated with it. For example, one value of the
<a class="idltype" href="#idl-any">any</a> type is the
<a class="idltype" href="#idl-unsigned-long">unsigned long</a>
150, while another is the <a class="idltype" href="#idl-long">long</a> 150.
These are distinct values.
</p>
<p>
The particular type of an <a class="idltype" href="#idl-any">any</a>
value is known as its <dfn id="dfn-specific-type">specific type</dfn>.
</p>
</div>
<div id="idl-boolean" class="section">
<h4>3.9.2. boolean</h4>
<p>
The <a class="idltype" href="#idl-boolean">boolean</a> type has two values:
<span class="idlvalue">true</span> and <span class="idlvalue">false</span>.
</p>
<p>
<a class="idltype" href="#idl-boolean">boolean</a> constant values in IDL are
represented with the <code>true</code> and
<code>false</code> tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-boolean">boolean</a> type is “Boolean”.
</p>
</div>
<div id="idl-byte" class="section">
<h4>3.9.3. byte</h4>
<p>
The <a class="idltype" href="#idl-byte">byte</a> type is a signed integer
type that has values in the range [−128, 127].
</p>
<p>
<a class="idltype" href="#idl-byte">byte</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-byte">byte</a> type is “Byte”.
</p>
</div>
<div id="idl-octet" class="section">
<h4>3.9.4. octet</h4>
<p>
The <a class="idltype" href="#idl-octet">octet</a> type is an unsigned integer
type that has values in the range [0, 255].
</p>
<p>
<a class="idltype" href="#idl-octet">octet</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-octet">octet</a> type is “Octet”.
</p>
</div>
<div id="idl-short" class="section">
<h4>3.9.5. short</h4>
<p>
The <a class="idltype" href="#idl-short">short</a> type is a signed integer
type that has values in the range [−32768, 32767].
</p>
<p>
<a class="idltype" href="#idl-short">short</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-short">short</a> type is “Short”.
</p>
</div>
<div id="idl-unsigned-short" class="section">
<h4>3.9.6. unsigned short</h4>
<p>
The <a class="idltype" href="#idl-unsigned-short">unsigned short</a> type is an unsigned integer
type that has values in the range [0, 65535].
</p>
<p>
<a class="idltype" href="#idl-unsigned-short">unsigned short</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-unsigned-short">unsigned short</a> type is “UnsignedShort”.
</p>
</div>
<div id="idl-long" class="section">
<h4>3.9.7. long</h4>
<p>
The <a class="idltype" href="#idl-long">long</a> type is a signed integer
type that has values in the range [−2147483648, 2147483647].
</p>
<p>
<a class="idltype" href="#idl-long">long</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-long">long</a> type is “Long”.
</p>
</div>
<div id="idl-unsigned-long" class="section">
<h4>3.9.8. unsigned long</h4>
<p>
The <a class="idltype" href="#idl-unsigned-long">unsigned long</a> type is an unsigned integer
type that has values in the range [0, 4294967295].
</p>
<p>
<a class="idltype" href="#idl-unsigned-long">unsigned long</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-unsigned-long">unsigned long</a> type is “UnsignedLong”.
</p>
</div>
<div id="idl-long-long" class="section">
<h4>3.9.9. long long</h4>
<p>
The <a class="idltype" href="#idl-long-long">long long</a> type is a signed integer
type that has values in the range [−9223372036854775808, 9223372036854775807].
</p>
<p>
<a class="idltype" href="#idl-long-long">long long</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-long-long">long long</a> type is “LongLong”.
</p>
</div>
<div id="idl-unsigned-long-long" class="section">
<h4>3.9.10. unsigned long long</h4>
<p>
The <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> type is an unsigned integer
type that has values in the range [0, 18446744073709551615].
</p>
<p>
<a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> constant values in IDL are
represented with <a class="sym" href="#prod-integer">integer</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> type is “UnsignedLongLong”.
</p>
</div>
<div id="idl-float" class="section">
<h4>3.9.11. float</h4>
<p>
The <a class="idltype" href="#idl-float">float</a> type is a floating point numeric
type that corresponds to the set of possible single-precision 32 bit
IEEE 754 floating point numbers. <a href="#ref-IEEE-754">[IEEE-754]</a>
</p>
<p>
<a class="idltype" href="#idl-float">float</a> constant values in IDL are
represented with <a class="sym" href="#prod-float">float</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-float">float</a> type is “Float”.
</p>
</div>
<div id="idl-double" class="section">
<h4>3.9.12. double</h4>
<p>
The <a class="idltype" href="#idl-double">double</a> type is a floating point numeric
type that corresponds to the set of possible double-precision 64 bit
IEEE 754 floating point numbers. <a href="#ref-IEEE-754">[IEEE-754]</a>
</p>
<p>
<a class="idltype" href="#idl-double">double</a> constant values in IDL are
represented with <a class="sym" href="#prod-float">float</a>
tokens.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-double">double</a> type is “Double”.
</p>
</div>
<div id="idl-DOMString" class="section">
<h4>3.9.13. DOMString</h4>
<p>
The <a class="idltype" href="#idl-DOMString">DOMString</a> type
corresponds to the set of all possible sequences of
16 bit unsigned integer <a class="dfnref" href="#dfn-code-unit">code units</a>.
Such sequences are commonly interpreted as UTF-16 encoded strings <a href="#ref-RFC2781">[RFC2781]</a>
although this is not required.
While <a class="idltype" href="#idl-DOMString">DOMString</a> is defined to be an OMG IDL boxed
<a class="idltype" href="#idl-sequence">sequence<unsigned short></a>
valuetype in <cite><a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-C74D1578">DOM Level 3 Core</a></cite>
(<a href="#ref-DOM3CORE">[DOM3CORE]</a>, section 1.2.1),
this document defines <a class="idltype" href="#idl-DOMString">DOMString</a> to be an intrinsic type so as to avoid
special casing that sequence type in various situations where a
string is required.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
Note also that <span class="idlvalue">null</span>
is not a value of type <a class="idltype" href="#idl-DOMString">DOMString</a>.
To allow <span class="idlvalue">null</span>, a
<a href="#idl-nullable-type">nullable</a> <a class="idltype" href="#idl-DOMString">DOMString</a>,
written as <code>DOMString?</code> in IDL, needs to be used.
</p>
</div>
<p>
Nothing in this specification requires a <a class="idltype" href="#idl-DOMString">DOMString</a>
value to be a valid UTF-16 string. For example, a <a class="idltype" href="#idl-DOMString">DOMString</a>
value might include unmatched surrogate pair characters. However, authors
of specifications using Web IDL might want to obtain a sequence of
Unicode characters given a particular sequence of <a class="dfnref" href="#dfn-code-unit">code units</a>.
The following algorithm defines a way to
<dfn id="dfn-obtain-unicode">convert a DOMString to a sequence of Unicode characters</dfn>:
</p>
<ol class="algorithm">
<li>Let <var>S</var> be the <a class="idltype" href="#idl-DOMString">DOMString</a> value.</li>
<li>Let <var>n</var> be the length of <var>S</var>.</li>
<li>Initialize <var>i</var> to 0.</li>
<li>Initialize <var>U</var> to be an empty sequence of Unicode characters.</li>
<li>While <var>i</var> < <var>n</var>:
<ol>
<li>Let <var>c</var> be the <a class="dfnref" href="#dfn-code-unit">code unit</a> in <var>S</var> at index <var>i</var>.</li>
<li>Depending on the value of <var>c</var>:
<dl class="switch">
<dt><var>c</var> < 0xD800 or <var>c</var> > 0xDFFF</dt>
<dd>Append to <var>U</var> the Unicode character with code point <var>c</var>. </dd>
<dt>0xDC00 ≤ <var>c</var> ≤ 0xDFFF</dt>
<dd>Append to <var>U</var> a <span class="char">U+FFFD REPLACEMENT CHARACTER</span>.</dd>
<dt>0xD800 ≤ <var>c</var> ≤ 0xDBFF</dt>
<dd>
<ol class="only">
<li>If <var>i</var> = <var>n</var>−1, then append to <var>U</var> a <span class="char">U+FFFD REPLACEMENT CHARACTER</span>.</li>
<li>Otherwise, <var>i</var> < <var>n</var>−1:
<ol>
<li>Let <var>d</var> be the code unit in <var>S</var> at index
<var>i</var>+1.</li>
<li>If 0xDC00 ≤ <var>d</var> ≤ 0xDFFF, then:
<ol>
<li>Let <var>a</var> be <var>c</var> & 0x3FF.</li>
<li>Let <var>b</var> be <var>d</var> & 0x3FF.</li>
<li>Append to <var>U</var> the Unicode character with
code point 2<sup>16</sup>+2<sup>10</sup><var>a</var>+<var>b</var>.</li>
<li>Set <var>i</var> to <var>i</var>+1.</li>
</ol>
</li>
<li>Otherwise, <var>d</var> < 0xDC00 or <var>d</var> > 0xDFFF.
Append to <var>U</var> a <span class="char">U+FFFD REPLACEMENT CHARACTER</span>.</li>
</ol>
</li>
</ol>
</dd>
</dl>
</li>
<li>Set <var>i</var> to <var>i</var>+1.</li>
</ol>
</li>
<li>Return <var>U</var>.</li>
</ol>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-DOMString">DOMString</a> type is “String”.
</p>
</div>
<div id="idl-object" class="section">
<h4>3.9.14. object</h4>
<p>
The <a class="idltype" href="#idl-object">object</a> type corresponds to the set of
all possible non-null object references.
</p>
<p>
There is no way to represent a constant <a class="idltype" href="#idl-object">object</a>
value in IDL.
</p>
<p>
To denote a type that includes all possible object references plus the
<span class="idlvalue">null</span> value, use the <a href="#dfn-nullable-type">nullable type</a>
<span class="idltype">object?</span>.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-object">object</a> type is “Object”.
</p>
</div>
<div id="idl-interface" class="section">
<h4>3.9.15. Interface types</h4>
<p>
A <a class="dfnref" href="#dfn-scoped-name">scoped name</a> that
<a class="dfnref" href="#dfn-resolve">resolves</a> to an
<a class="dfnref" href="#dfn-interface">interface</a> is used to refer to
a type that corresponds to the set of all possible non-null references to objects that
implement that interface.
</p>
<p>
There is no way to represent a constant object reference value for
a particular interface type in IDL.
</p>
<p>
To denote a type that includes all possible references to objects implementing
the given interface plus the <span class="idlvalue">null</span> value,
use a <a href="#dfn-nullable-type">nullable type</a>.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of an interface type
is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the interface.
</p>
</div>
<div id="idl-dictionary" class="section">
<h4>3.9.16. Dictionary types</h4>
<p>
A <a class="dfnref" href="#dfn-scoped-name">scoped name</a> that
<a class="dfnref" href="#dfn-resolve">resolves</a> to a
<a class="dfnref" href="#dfn-dictionary">dictionary</a> is used to refer to
a type that corresponds to the set of all dictionaries that adhere to
the dictionary definition.
</p>
<p>
There is no way to represent a constant dictionary value in IDL.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of a dictionary type
is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the dictionary.
</p>
</div>
<div id="idl-nullable-type" class="section">
<h4>3.9.17. Nullable types — <var>T</var>?</h4>
<p>
A <dfn id="dfn-nullable-type">nullable type</dfn> is an IDL type constructed
from an existing type (called the <dfn id="dfn-inner-type">inner type</dfn>),
which just allows the additional value <span class="idlvalue">null</span>
to be a member of its set of values. <a class="dfnref" href="#dfn-nullable-type">Nullable types</a>
are represented in IDL by placing a <span class="char">U+003F QUESTION MARK ("?")</span>
character after an existing type. The inner type <span class="rfc2119">MUST NOT</span>
be <a class="idltype" href="#idl-any">any</a> or another nullable type, as they already
allow the <span class="idlvalue">null</span> value.
</p>
<p>
Nullable type constant values in IDL are represented in the same way that
constant values of their <a class="dfnref" href="#dfn-inner-type">inner type</a>
would be represented, or with the <code>null</code> token.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of a nullable type
is the concatenation of the type name of the inner type <var>T</var> and
the string “OrNull”.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
For example, a type that allows the values <span class="idlvalue">true</span>,
<span class="idlvalue">false</span> and <span class="idlvalue">null</span>
is written as <span class="idltype">boolean?</span>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface MyConstants {
const boolean? ARE_WE_THERE_YET = false;
};</code></pre></div></div>
<p>
The following <a class="dfnref" href="#dfn-interface">interface</a> has two
<a class="dfnref" href="#dfn-attribute">attributes</a>: one whose value can
be a <a class="idltype" href="#idl-DOMString">DOMString</a> or the <span class="idlvalue">null</span>
value, and another whose value can be a reference to a <span class="idltype">Node</span>
object or the <span class="idlvalue">null</span> value:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Node {
readonly attribute DOMString? namespaceURI;
readonly attribute Node? parentNode;
<span class="comment">// ...</span>
};</code></pre></div></div>
</div>
</div>
<div id="idl-sequence" class="section">
<h4>3.9.18. Sequences — sequence<<var>T</var>></h4>
<p>
The <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a>
type is a parameterized type whose values are (possibly zero-length) sequences of
values of type <var>T</var>. Sequences are always passed by value. In
language bindings where a sequence is represented by an object of
some kind, passing a sequence to a user agent implemented object
will not result in a reference to the sequence being kept by that object.
Similarly, any sequence returned from a user agent implemented object
will be a copy and modifications made to it will not be visible to the object.
</p>
<p>
There is no way to represent a constant sequence value in IDL.
</p>
<p>
Sequences <span class="rfc2119">MUST NOT</span> be used as the
type of an <a class="dfnref" href="#dfn-attribute">attribute</a>,
<a class="dfnref" href="#dfn-constant">constant</a>
or <a class="dfnref" href="#dfn-exception-field">exception field</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
This restriction exists so that it is clear to specification writers
and API users that <a href="#idl-sequence">sequences</a>
are copied rather than having references
to them passed around. Instead of a writable <a class="dfnref" href="#dfn-attribute">attribute</a> of a sequence
type, it is suggested that a pair of <a class="dfnref" href="#dfn-operation">operations</a> to get and set the
sequence is used. Another option is to use an <a href="#idl-array">array type</a>,
which can be used as the type of an attribute.
</p>
</div>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of a sequence type
is the concatenation of the type name for <var>T</var> and
the string “Sequence”.
</p>
</div>
<div id="idl-array" class="section">
<h4>3.9.19. Arrays — <var>T</var>[]</h4>
<p>
The <a class="idltype" href="#idl-array"><var>T</var>[]</a> type
is a parameterized type whose values are non-null references to (possibly zero-length) arrays
of values of type <var>T</var>.
Unlike <a class="dfnref" href="#idl-sequence">sequences</a>,
arrays are passed by reference. Passing an array to a <a class="dfnref" href="#dfn-platform-object">platform object</a>
could result in that array being modified by the object.
An array returned from a platform object might also be modified by the object,
and any modifications to the array performed by user code might be acted upon by the
platform object.
</p>
<p>
The element type of an array <span class="rfc2119">MUST NOT</span> be
a <a href="#idl-sequence">sequence</a> or <a href="#idl-dictionary">dictionary</a> type.
</p>
<p>
Arrays can either be <dfn id="dfn-fixed-length">fixed length</dfn> or
<dfn id="dfn-variable-length">variable length</dfn>. Fixed length
arrays cannot have their length changed by user code after they have been
created, while variable length arrays can. Unless otherwise
specified, arrays are fixed length.
</p>
<p>
Arrays can also be designated as being <dfn id="dfn-read-only-array">read only</dfn>.
User code cannot modify the values of read only array elements.
If an array is read only, then it is also implicitly <a class="dfnref" href="#dfn-fixed-length">fixed length</a>.
</p>
<p>
There is no way to represent a constant array value in IDL.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of an array type
is the concatenation of the type name for <var>T</var> and
the string “Array”.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>See <a href="#es-array">section 4.2.20</a> for an example using array types.</p>
</div>
</div>
<div id="idl-Date" class="section">
<h4>3.9.20. Date</h4>
<p>
The <a class="idltype" href="#idl-Date">Date</a> type is a type that
represents an instant in time with millisecond accuracy. The instants
in time that this type can represent are the same that can be represented
with ECMAScript <span class="estype">Date</span> objects (<a href="#ref-ECMA-262">[ECMA-262]</a>,
section 15.9.1.1) – namely, every millisecond in the 200,000,000 days centered
around midnight of 1 January, 1970 UTC, except for any millisecond that is part
of an inserted leap second, because they cannot be represented by this type.
</p>
<p>
An additional value that this type can represent is one that indicates
an indeterminate or undefined time, which we write as
<span class="idlvalue">undefined</span>.
</p>
<p>
There is no way to represent a constant <a class="idltype" href="#idl-Date">Date</a>
value in IDL.
</p>
<p>
The <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a class="idltype" href="#idl-Date">Date</a> type is “Date”.
</p>
</div>
</div>
<div id="idl-extended-attributes" class="section">
<h3>3.10. Extended attributes</h3>
<p>
An <dfn id="dfn-extended-attribute">extended attribute</dfn> is an annotation
that can appear on
<!--a class='dfnref' href='#dfn-definition'-->definitions<!--/a-->,
<a class="dfnref" href="#dfn-interface-member">interface members</a>,
<a class="dfnref" href="#dfn-exception-member">exception members</a>,
<a class="dfnref" href="#dfn-dictionary-member">dictionary members</a>,
and <a class="dfnref" href="#dfn-operation">operation</a> arguments, and
is used to control how language bindings will handle those constructs.
Extended attributes are specified with an
<a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a>,
which is a square bracket enclosed, comma separated list of
<a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a>s.
</p>
<p>
The <a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a>
grammar symbol matches nearly any sequence of tokens, however the
<a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this document only accept a more restricted syntax.
Any extended attribute encountered in an
<a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> is
matched against the following five grammar symbols to determine
which form (or forms) it is in:
</p>
<table class="vert">
<tr>
<th>Grammar symbol</th>
<th>Form</th>
<th>Example</th>
</tr>
<tr>
<td>
<a class="sym" href="#prod-ExtendedAttributeNoArgs">ExtendedAttributeNoArgs</a>
</td>
<td>
<dfn id="dfn-xattr-no-arguments">takes no arguments</dfn>
</td>
<td>
<code>[Replaceable]</code>
</td>
</tr>
<tr>
<td>
<a class="sym" href="#prod-ExtendedAttributeArgList">ExtendedAttributeArgList</a>
</td>
<td>
<dfn id="dfn-xattr-argument-list">takes an argument list</dfn>
</td>
<td>
<code>[Constructor(float x, float y)]</code>
</td>
</tr>
<tr>
<td>
<a class="sym" href="#prod-ExtendedAttributeNamedArgList">ExtendedAttributeNamedArgList</a>
</td>
<td>
<dfn id="dfn-xattr-named-argument-list">takes a named argument list</dfn>
</td>
<td>
<code>[NamedConstructor=Image(DOMString src)]</code>
</td>
</tr>
<tr>
<td>
<a class="sym" href="#prod-ExtendedAttributeIdent">ExtendedAttributeIdent</a>
</td>
<td>
<dfn id="dfn-xattr-identifier">takes an identifier</dfn>
</td>
<td>
<code>[PutForwards=name]</code>
</td>
</tr>
<tr>
<td>
<a class="sym" href="#prod-ExtendedAttributeScopedName">ExtendedAttributeScopedName</a>
</td>
<td>
<dfn id="dfn-xattr-scoped-name">takes a scoped name</dfn>
</td>
<td>
<code>[Prefix=org::example]</code>
</td>
</tr>
</table>
<p>
This specification defines a number of extended attributes that
are applicable to all language bindings, which are described in the
sub-sections below. In addition, ECMAScript language binding
specific extended attributes are defined in
<a href="#es-extended-attributes">section 4.3</a>.
Each extended attribute definition will state which of the above
five forms are allowed. Although
<a class="sym" href="#prod-ExtendedAttributeIdent">ExtendedAttributeIdent</a> and
<a class="sym" href="#prod-ExtendedAttributeScopedName">ExtendedAttributeScopedName</a>
are ambiguous, no extended attribute defined in this document
takes both of those forms.
</p>
<table class="grammar"><tr id="proddef-ExtendedAttributeList"><td><span class="prod-number">[39]</span></td><td><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"[" <a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a> <a class="sym" href="#prod-ExtendedAttributes">ExtendedAttributes</a> "]" <br /> |
ε</span></td></tr><tr id="proddef-ExtendedAttributes"><td><span class="prod-number">[40]</span></td><td><a class="sym" href="#prod-ExtendedAttributes">ExtendedAttributes</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"," <a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a> <a class="sym" href="#prod-ExtendedAttributes">ExtendedAttributes</a> <br /> |
ε</span></td></tr><tr id="proddef-ExtendedAttribute"><td><span class="prod-number">[41]</span></td><td><a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">
"(" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> ")" <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
<br /> |
"[" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "]" <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
<br /> |
"{" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "}" <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
<br /> |
<a class="sym" href="#prod-Other">Other</a> <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
</span></td></tr><tr id="proddef-ExtendedAttributeRest"><td><span class="prod-number">[42]</span></td><td><a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a> <br /> |
ε</span></td></tr><tr id="proddef-ExtendedAttributeInner"><td><span class="prod-number">[43]</span></td><td><a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">
"(" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> ")" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
"[" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "]" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
"{" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "}" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
<a class="sym" href="#prod-OtherOrComma">OtherOrComma</a> <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
ε
</span></td></tr><tr id="proddef-Other"><td><span class="prod-number">[44]</span></td><td><a class="sym" href="#prod-Other">Other</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">
<a class="sym" href="#prod-integer">integer</a> <br /> |
<a class="sym" href="#prod-float">float</a> <br /> |
<a class="sym" href="#prod-identifier">identifier</a> <br /> |
<a class="sym" href="#prod-string">string</a> <br /> |
<a class="sym" href="#prod-other">other</a>
<br /> |
"..." <br /> |
":" <br /> |
"::" <br /> |
";" <br /> |
"<" <br /> |
"=" <br /> |
">" <br /> |
"?"
<br /> |
"Date" <br /> |
"DOMString" <br /> |
"any" <br /> |
"attribute" <br /> |
"boolean" <br /> |
"byte"
<br /> |
"legacycaller" <br /> |
"const" <br /> |
"creator" <br /> |
"deleter" <br /> |
"double"
<br /> |
"exception" <br /> |
"false" <br /> |
"float" <br /> |
"getter" <br /> |
"implements"
<br /> |
"inherit" <br /> |
"interface" <br /> |
"long" <br /> |
"module" <br /> |
"null" <br /> |
"object" <br /> |
"octet"
<br /> |
"optional" <br /> |
"sequence"
<br /> |
"setter" <br /> |
"short" <br /> |
"static" <br /> |
"stringifier" <br /> |
"true" <br /> |
"typedef"
<br /> |
"unsigned" <br /> |
"void"
</span></td></tr><tr id="proddef-OtherOrComma"><td><span class="prod-number">[45]</span></td><td><a class="sym" href="#prod-OtherOrComma">OtherOrComma</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Other">Other</a> <br /> |
","</span></td></tr><tr id="proddef-ExtendedAttributeNoArgs"><td><span class="prod-number">[62]</span></td><td><a class="sym" href="#prod-ExtendedAttributeNoArgs">ExtendedAttributeNoArgs</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a></span></td></tr><tr id="proddef-ExtendedAttributeArgList"><td><span class="prod-number">[63]</span></td><td><a class="sym" href="#prod-ExtendedAttributeArgList">ExtendedAttributeArgList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "(" <a class="sym" href="#prod-ArgumentList">ArgumentList</a> ")"</span></td></tr><tr id="proddef-ExtendedAttributeIdent"><td><span class="prod-number">[64]</span></td><td><a class="sym" href="#prod-ExtendedAttributeIdent">ExtendedAttributeIdent</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-identifier">identifier</a></span></td></tr><tr id="proddef-ExtendedAttributeScopedName"><td><span class="prod-number">[65]</span></td><td><a class="sym" href="#prod-ExtendedAttributeScopedName">ExtendedAttributeScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-ScopedName">ScopedName</a></span></td></tr><tr id="proddef-ExtendedAttributeNamedArgList"><td><span class="prod-number">[66]</span></td><td><a class="sym" href="#prod-ExtendedAttributeNamedArgList">ExtendedAttributeNamedArgList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-identifier">identifier</a> "(" <a class="sym" href="#prod-ArgumentList">ArgumentList</a> ")"</span></td></tr></table>
<!--
<div id='ExceptionConsts' class='section'>
<h4>[ExceptionConsts]</h4>
<p>
If the <a class='xattr' href='#ExceptionConsts'>[ExceptionConsts]</a>
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>
appears on a <a class='dfnref' href='#dfn-module'>module</a>, it indicates that any
<a class='dfnref' href='#dfn-constant'>constants</a> declared on that module are intended to
exist on the language construct that corresponds to the <a class='dfnref' href='#dfn-exception'>exception</a>
given by the extended attribute’s argument (for languages that
support constants on exceptions). Exactly how these constants
are exposed is language binding specific.
</p>
<p>
The <a class='xattr' href='#ExceptionConsts'>[ExceptionConsts]</a> extended attribute
<span class='rfc2119'>MUST</span> <a class='dfnref' href='#dfn-xattr-identifier'>take an identifier</a>
that is the <a class='dfnref' href='#dfn-identifier'>identifier</a>
of an exception defined in that module, on which the constants declared at the
module scope should live.
</p>
<div class='example'>
<p>
The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a> declares an exception and a number of constants
at the module scope:
</p>
<x:codeblock language='idl'>[ExceptionConsts=FileIOException]
module fileio {
exception FileIOException {
unsigned short code;
};
const unsigned short FILE_NOT_FOUND = 1;
const unsigned short READ_ERROR = 2;
const unsigned short WRITE_ERROR = 3;
};</x:codeblock>
<p>
In the ECMAScript binding, this will result in properties on the
<a class='dfnref' href='#dfn-exception-interface-object'>exception interface object</a> for each of the constants:
</p>
<x:codeblock language='es'>typeof FileIOException; <span class='comment'>// evaluates to "object"</span>
FileIOException.FILE_NOT_FOUND; <span class='comment'>// evaluates to 1</x:codeblock></span>
</div>
</div>
-->
<!--
<div id='NoNull' class='section'>
<h4>[NoNull]</h4>
<p>
If the <a class='xattr' href='#NoNull'>[NoNull]</a>
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>
appears on an <a class='dfnref' href='#dfn-attribute'>attribute</a>,
an <a class='dfnref' href='#dfn-operation'>operation</a> or an operation
argument, whose type is a
<a class='dfnref' href='#dfn-boxed-valuetype'>boxed valuetype</a>,
it indicates that a <span class='idlvalue'>null</span> value is not
expected and will never be returned. How
implementations treat the assignment of a <span class='idlvalue'>null</span>
value to an attribute with the <a class='xattr' href='#NoNull'>[NoNull]</a>
extended attribute, or passing a <span class='idlvalue'>null</span> value as a
<a class='xattr' href='#NoNull'>[NoNull]</a> operation argument,
is specific to the language binding.
</p>
<p>
The <a class='xattr' href='#NoNull'>[NoNull]</a>
extended attribute <span class='rfc2119'>MUST</span> take no argument.
</p>
<div class='example'>
<p>
The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a> defines an interface that has one
attribute with the <a class='xattr' href='#NoNull'>[NoNull]</a>
extended attribute, and one operation with an argument that has
the extended attribute:
</p>
<x:codeblock language='idl'>interface Dog {
[NoNull] attribute DOMString name;
attribute DOMString shortName;
boolean isMemberOfBreed([NoNull] DOMString breedName);
};</x:codeblock>
<p>
An ECMAScript implementation implementing the <span class='idltype'>Dog</span>
interface would not allow the <span class='esvalue'>null</span> value to
be assigned to the <span class='prop'>name</span> property or passed as the
argument to the <span class='prop'>isMemberOfBreed</span> function:
</p>
<x:codeblock language='es'>var d = getDog(); <span class='comment'>// Assume d is a platform object implementing the Dog interface.</span>
d.name = null; <span class='comment'>// This assigns the string "null" to the .name property.</span>
d.isMemberOfBreed(null); <span class='comment'>// This passes the string "null" to the isMemberOfBreed function.</x:codeblock></span>
</div>
</div>
-->
<!--
<div id='Overloads' class='section'>
<h4>[Overloads]</h4>
<p>
If the <a class='xattr' href='#Overloads'>[Overloads]</a>
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>
appears on an <a class='dfnref' href='#dfn-operation'>operation</a>, it indicates that
the operation is to be considered to overload the operation
with the <a class='sym' href='#prod-identifier'>identifier</a>
given as the extended attribute argument.
The extent to which a language supports method overloading
determines whether an object implementing an interface with
overloaded operations must implement the operation using the
overloaded name or the original name, and is specific to the
language binding.
</p>
<p>
The <a class='xattr' href='#Overloads'>[Overloads]</a>
extended attribute <span class='rfc2119'>MUST</span> take a single argument,
an <a class='sym' href='#prod-identifier'>identifier</a>,
which <span class='rfc2119'>MUST</span> be the <a class='sym' href='#prod-identifier'>identifier</a>
of another operation defined on the <a class='dfnref' href='#dfn-interface'>interface</a>,
which this operation overloads. The
<a class='sym' href='#prod-identifier'>identifier</a> <span class='rfc2119'>MUST NOT</span>
identify an operation that itself is declared with an
<a class='xattr' href='#Overloads'>[Overloads]</a> extended
attribute.
</p>
<div class='example'>
<p>
The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a> defines an interface with
overloaded operations:
</p>
<x:codeblock language='idl'>interface Person;
interface PersonFactory {
Person createPerson();
[Overloads=createPerson] Person createPersonWithAge(short age);
};</x:codeblock>
<p>
Since the ECMAScript binding allows overloading, a platform object
implementing the <span class='idltype'>PersonFactory</span>
interface will have a single property <span class='prop'>createPerson</span>:
</p>
<x:codeblock language='es'>var f = getFactory(); <span class='comment'>// Assume f is a platform object implementing the PersonFactory interface.</span>
typeof f.createPerson; <span class='comment'>// Evaluates to "function".</span>
typeof f.createPersonWithAge; <span class='comment'>// Evaluates to "undefined".</span>
var p1 = f.createPerson(); <span class='comment'>// Corresponds to the createPerson operation.</span>
var p2 = f.createPerson(26); <span class='comment'>// Corresponds to the createPersonWithAge operation.</x:codeblock></span>
<p>
However, a hypothetical C language binding would not, since
C does not support overloading. Separate functions would likely
be used for the two operations:
</p>
<x:codeblock language='c'>PersonFactory* f = getFactory();
Person* p1 = PersonFactory_createPerson(f); <span class='comment'>// Corresponds to the createPerson operation.</span>
Person* p2 = PersonFactory_createPersonWithAge(f, 26); <span class='comment'>// Corresponds to the createPersonWithAge operation.</x:codeblock></span>
</div>
</div>
-->
<div id="Callback" class="section">
<h4>3.10.1. [Callback]</h4>
<div class="ednote"><div class="ednoteHeader">Editorial note</div>
<p>
Since the <a class="xattr" href="#Callback">[Callback]</a> extended attribute
is now important at the IDL level to indicate whether user objects can
implement a given interface, does it make sense to hoist it up into
proper syntax (i.e., not be an extended attribute)?
</p>
<p>
It may be that <a class="xattr" href="#Callback">[Callback]</a>
is not the best name for the extended attribute anyway, although
it does capture many uses of interfaces that user objects can
implement. Maybe <span class="xattr">[UserObject]</span> is better.
</p>
</div>
<p>
If the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>,
it indicates that <a class="dfnref" href="#dfn-user-object">user objects</a>
can implement the interface. As described in <a href="#idl-objects">section 3.8 above</a>,
user objects will only be considered to implement a given interface if
the interface is annotated with <a class="xattr" href="#Callback">[Callback]</a>.
User objects implementing an interface are most often
used to provide callback methods to a <a class="dfnref" href="#dfn-platform-object">platform object</a>,
hence the name of this extended attribute.
</p>
<p>
The <a class="xattr" href="#Callback">[Callback]</a> extended attribute
<span class="rfc2119">MUST</span> either <a class="dfnref" href="#dfn-xattr-identifier">take an identifier</a>
or <a class="dfnref" href="#dfn-xattr-no-arguments">no argument</a>.
The identifier, if present, is used only by the ECMAScript language binding,
to control exactly which kinds of objects can be considered to
implement a <a class="xattr" href="#Callback">[Callback]</a>-annotated
interface. See <a href="#es-Callback">section 4.3.3 below</a> for
details and an example of this.
</p>
<p>
The <a class="xattr" href="#Callback">[Callback]</a> extended attribute
<span class="rfc2119">MUST NOT</span> be used on an interface that
does not meet the criteria for an interface that can implemented by
user objects, as described in <a href="#idl-objects">section 3.8 above</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
Specification authors wanting to APIs that take ECMAScript objects
as “property bag” like function arguments are suggested to use
<a href="#idl-dictionaries">dictionary types</a> rather than
<a class="dfnref" href="#dfn-interface">interfaces</a> annotated
with <code>[Callback,NoInterfaceObject]</code>.
</p>
<p>
For example, instead of this:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Callback,NoInterfaceObject]
interface Options {
attribute DOMString? option1;
attribute DOMString? option2;
attribute long? option3;
};
interface A {
void doTask(DOMString type, Options options);
};</code></pre></div></div>
<p>
to be used like this:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var a = getA(); <span class="comment">// Get an instance of A.</span>
a.doTask("something", { option1: "banana", option3: 100 });</code></pre></div></div>
<p>
instead write the following:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">dictionary Options {
DOMString? option1;
DOMString? option2;
long? option3;
};
interface A {
void doTask(DOMString type, Options options);
};</code></pre></div></div>
</div>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines
simplified versions of a few DOM <a class="dfnref" href="#dfn-interface">interfaces</a>, one of which
is annotated with the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Node {
readonly attribute DOMString nodeName;
readonly attribute Node? parentNode;
Node appendChild(Node newChild);
void addEventListener(DOMString type, EventListener listener);
};
[Callback]
interface EventListener {
void handleEvent(Event event);
};</code></pre></div></div>
<p>
Since the <span class="idltype">EventListener</span> interface is annotated
with <a class="xattr" href="#Callback">[Callback]</a>, <a class="dfnref" href="#dfn-user-object">user objects</a>
can implement it:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var node = getNode(); <span class="comment">// Obtain an instance of Node.</span>
var listener = {
handleEvent: function(event) {
...
}
};
node.addEventListener("click", listener);</code></pre></div></div>
<p>
It is not possible for a user object to implement <span class="idltype">Node</span>, however:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var node = getNode(); <span class="comment">// Obtain an instance of Node.</span>
var newNode = {
nodeName: "span",
parentNode: null,
appendChild: function(newchild) {
...
},
addEventListener: function(type, listener) {
...
}
};
node.appendChild(newNode); <span class="comment">// This will throw a TypeError exception.</span></code></pre></div></div>
</div>
</div>
<div id="Prefix" class="section">
<h4>3.10.2. [Prefix]</h4>
<p>
If the <a class="xattr" href="#Prefix">[Prefix]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on a <a class="dfnref" href="#dfn-module">module</a>,
it affects the name of the language binding specific namespacing
construct the module will correspond to. See the definition of a module’s
<a class="dfnref" href="#dfn-prefixed-name">prefixed name</a> for
details.
</p>
<p>
The <a class="xattr" href="#Prefix">[Prefix]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-scoped-name">take a scoped name</a>.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
See <a href="#java-modules">section 5.3</a> for an
example of the use of <a class="xattr" href="#Prefix">[Prefix]</a>.
</p>
</div>
</div>
</div>
</div>
<div id="ecmascript-binding" class="section">
<h2>4. ECMAScript binding</h2>
<p>
This section describes how definitions written with the IDL defined in
<a href="#idl">section 3</a> correspond to particular constructs
in ECMAScript, as defined by the <cite>ECMAScript Language Specification, 5th edition</cite>
<a href="#ref-ECMA-262">[ECMA-262]</a>.
</p>
<p>
Objects defined in this section have internal properties as described in
ECMA-262 sections 8.12 and 13.2 unless otherwise specified, in which case one or
more of the following are redefined in accordance with the rules for host objects:
<span class="prop">[[Call]]</span>,
<span class="prop">[[DefineOwnProperty]]</span>,
<span class="prop">[[GetOwnProperty]]</span> and
<span class="prop">[[Delete]]</span><!-- and
<span class="prop">[[HasInstance]]</span>-->.
</p>
<p>
If a value for the internal property
<span class="prop">[[Class]]</span> is not given for a particular
object, its value is implementation specific.
</p>
<p>
Unless otherwise specified, the <span class="prop">[[Extensible]]</span> internal property
of objects defined in this section has the value <span class="esvalue">true</span>.
</p>
<p>
Unless otherwise specified, the <span class="prop">[[Prototype]]</span> internal property
of objects defined in this section is the <span class="esvalue">Object</span> prototype object.
</p>
<p>
If an object is defined to be a <dfn id="dfn-function-object">function object</dfn>, then
it has characteristics as follows:
</p>
<ul>
<li>Its <span class="prop">[[Prototype]]</span> internal property is the <span class="esvalue">Function</span> prototype object.</li>
<li>Its <span class="prop">[[Get]]</span> internal property is set as described in ECMA-262 section 15.3.5.4.</li>
<li>Its <span class="prop">[[Construct]]</span> internal property is set as described in ECMA-262 section 13.2.2.</li>
<li>Its <span class="prop">[[HasInstance]]</span> internal property is set as described in ECMA-262 section 15.3.5.3, unless otherwise specified.</li>
<li>Its <span class="prop">[[Class]]</span> internal property is “Function”, unless otherwise specified.</li>
</ul>
<p>
Algorithms in this section use the conventions described in ECMA-262
section 5.2, such as the use of steps and substeps, the use of mathematical
operations, and so on. The ToBoolean, ToNumber, ToUint16, ToInt32, ToUint32, ToString,
ToObject, IsAccessorDescriptor and IsDataDescriptor abstract operations and the
Type(<var>x</var>) notation referenced in this section are defined in ECMA-262 sections 8 and 9.
</p>
<div id="es-environment" class="section">
<h3>4.1. ECMAScript environment</h3>
<p>
In an ECMAScript implementation of a given set of
<a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a>,
there will exist a number of ECMAScript objects that correspond to
definitions in those <a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a>.
These objects are termed the <dfn id="dfn-initial-object">initial objects</dfn>,
and comprise the following:
</p>
<ul>
<li><a class="dfnref" href="#dfn-namespace-object">namespace objects</a></li>
<li><a class="dfnref" href="#dfn-interface-object">interface objects</a></li>
<li><a class="dfnref" href="#dfn-named-constructor">named constructors</a></li>
<li><a class="dfnref" href="#dfn-interface-prototype-object">interface prototype objects</a></li>
<!--
<li><a class='dfnref' href='#dfn-mixin-prototype-object'>mixin prototype objects</a></li>
-->
<li><a class="dfnref" href="#dfn-attribute-getter">attribute getters</a></li>
<li><a class="dfnref" href="#dfn-attribute-setter">attribute setters</a></li>
<li><a href="#es-operations">the <span class="estype">Function</span> objects that correspond to operations</a></li>
<li><a href="#es-stringifier">the <span class="estype">Function</span> objects that correspond to stringifiers</a></li>
<li><a class="dfnref" href="#dfn-exception-interface-object">exception interface objects</a></li>
<li><a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype objects</a></li>
<li><a class="dfnref" href="#dfn-exception-field-getter">exception field getters</a></li>
</ul>
<p>
Each ECMAScript global environment (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 10.2.3)
<span class="rfc2119">MUST</span> have its own unique set of each of
the <a class="dfnref" href="#dfn-initial-object">initial objects</a>, created
before control enters any ECMAScript execution context associated with the
environment, but after the global object for that environment is created. The <span class="prop">[[Prototype]]</span>s
of all initial objects in a given global environment <span class="rfc2119">MUST</span> come from the
that same global environment.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
In an HTML user agent, multiple global environments can exist when
multiple frames or windows are created. Each frame or window will have
its own set of <a class="dfnref" href="#dfn-initial-object">initial objects</a>,
which the following HTML document demonstrates:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">HTML</span></div><div class="blockContent"><pre class="code"><code class="html-code"><!DOCTYPE html>
<title>Different global environments</title>
<iframe id=a></iframe>
<script>
var iframe = document.getElementById("a");
var w = iframe.contentWindow; <span class="comment">// The global object in the frame</span>
Object == w.Object; <span class="comment">// Evaluates to false, per ECMA-262</span>
Node == w.Node; <span class="comment">// Evaluates to false</span>
iframe instanceof w.Node; <span class="comment">// Evaluates to false</span>
iframe instanceof w.Object; <span class="comment">// Evaluates to false</span>
iframe.appendChild instanceof Function; <span class="comment">// Evaluates to true</span>
iframe.appendChild instanceof w.Function; <span class="comment">// Evaluates to false</span>
</script></code></pre></div></div>
</div>
</div>
<div id="es-type-mapping" class="section">
<h3>4.2. ECMAScript type mapping</h3>
<p>
This section describes how types in the IDL map to types in ECMAScript.
</p>
<p>
Each sub-section below describes how values of a given IDL type are represented
in ECMAScript. For each IDL type, it is described how ECMAScript values are
<dfn id="dfn-convert-ecmascript-to-idl-value">converted to an IDL value</dfn>
when passed to a <a class="dfnref" href="#dfn-platform-object">platform object</a> expecting that type, and how IDL values
of that type are <dfn id="dfn-convert-idl-to-ecmascript-value">converted to ECMAScript values</dfn>
when returned from a platform object.
</p>
<div id="es-any" class="section">
<h4>4.2.1. any</h4>
<p>
Since the IDL <a class="idltype" href="#idl-any">any</a> type
is the union of all other IDL types, it can correspond to any
ECMAScript value type.
</p>
<p>
How to <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">convert an ECMAScript value</a> to an IDL <a class="idltype" href="#idl-any">any</a> value depends on the type of the
ECMAScript value:
</p>
<dl class="switch">
<dt>The <span class="esvalue">undefined</span> value</dt>
<dd>
The IDL value is an
<a class="idltype" href="#idl-object">object</a> reference
to a special object that represents the ECMAScript
<span class="esvalue">undefined</span> value.
</dd>
<dt>The <span class="esvalue">null</span> value</dt>
<dd>
The IDL value is the <span class="idlvalue">null</span>
<a class="idltype" href="#idl-object">object?</a> reference.
</dd>
<dt>A <span class="estype">Boolean</span> value</dt>
<dd>
The IDL value is the
<a class="idltype" href="#idl-boolean">boolean</a>
value that represents the same truth value.
</dd>
<dt>A <span class="estype">Number</span> value</dt>
<dd>
The IDL value is that which is obtained
by following the rules for converting the
<span class="estype">Number</span> to an IDL
<a class="idltype" href="#idl-double">double</a> value,
as described in <a href="#es-double">section 4.2.13</a>,
below.
</dd>
<dt>A <span class="estype">String</span> value</dt>
<dd>
The IDL value is that which is obtained
by following the rules for converting the
<span class="estype">String</span> to an IDL
<a class="idltype" href="#idl-DOMString">DOMString</a> value,
as described in <a href="#es-DOMString">section 4.2.14</a>,
below.
</dd>
<dt>An <span class="estype">object</span> value</dt>
<dd>
The IDL value is an
<a class="idltype" href="#idl-object">object</a> value that
references the same object.
</dd>
</dl>
<p>
An IDL <a class="idltype" href="#idl-any">any</a> value is
<a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converted to an ECMAScript value</a>
as follows. If the value is an <a class="idltype" href="#idl-object">object</a>
reference to a special object that represents an ECMAScript <span class="esvalue">undefined</span>
value, then it is converted to the ECMAScript
<span class="esvalue">undefined</span> value. Otherwise,
the rules for converting the <a class="dfnref" href="#dfn-specific-type">specific type</a>
of the IDL <a class="idltype" href="#idl-any">any</a> value
as described in the remainder of this section are performed.
</p>
</div>
<div id="es-void" class="section">
<h4>4.2.2. void</h4>
<p>
The only place that the <a class="idltype" href="#idl-void">void</a> type may appear
in IDL is as the <a class="dfnref" href="#dfn-return-type">return type</a> of an
<a class="dfnref" href="#dfn-operation">operation</a>. Functions on <a class="dfnref" href="#dfn-platform-object">platform objects</a>
that implement an operation whose IDL specifies a
<a class="idltype" href="#idl-void">void</a> return type <span class="rfc2119">MUST</span> return the
<span class="esvalue">undefined</span> value.
</p>
<p>
ECMAScript functions that implement an operation whose IDL
specifies a <a class="idltype" href="#idl-void">void</a> return type
<span class="rfc2119">MAY</span> return any value, which will be discarded.
</p>
</div>
<div id="es-boolean" class="section">
<h4>4.2.3. boolean</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-boolean">boolean</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the result of computing ToBoolean(<var>V</var>).</li>
<li>Return the IDL <a class="idltype" href="#idl-boolean">boolean</a> value that is the one that represents the same truth value as the ECMAScript <span class="estype">Boolean</span> value <var>x</var>.</li>
</ol>
<p>
The IDL <a class="idltype" href="#idl-boolean">boolean</a> value <span class="idlvalue">true</span>
is <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converted</a> to
the ECMAScript <span class="esvalue">true</span> value and the IDL <a class="idltype" href="#idl-boolean">boolean</a>
value <span class="idlvalue">false</span> is converted to the ECMAScript
<span class="esvalue">false</span> value.
</p>
</div>
<div id="es-byte" class="section">
<h4>4.2.4. byte</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-byte">byte</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < −2<sup>7</sup> or <var>x</var> > 2<sup>7</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-byte">byte</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, −2<sup>7</sup>), 2<sup>7</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-byte">byte</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +0, −0, +∞, or −∞, then return the IDL <a class="idltype" href="#idl-byte">byte</a> value that represents 0.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>Set <var>x</var> to <var>x</var> modulo 2<sup>8</sup>.</li>
<li>If <var>x</var> ≥ 2<sup>7</sup>, return the IDL <a class="idltype" href="#idl-byte">byte</a> value that represents the same numeric value as <var>x</var> − 2<sup>8</sup>.
Otherwise, return the IDL <a class="idltype" href="#idl-byte">byte</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-byte">byte</a> value to an ECMAScript
value is a <span class="estype">Number</span> that represents
the same numeric value as the IDL <a class="idltype" href="#idl-byte">byte</a> value.
The <span class="estype">Number</span> value will be an integer in the range [−128, 127].
</p>
</div>
<div id="es-octet" class="section">
<h4>4.2.5. octet</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-octet">octet</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < 0 or <var>x</var> > 2<sup>8</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-octet">octet</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, 0), 2<sup>8</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-octet">octet</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +0, −0, +∞, or −∞, then return the IDL <a class="idltype" href="#idl-octet">octet</a> value that represents 0.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>Set <var>x</var> to <var>x</var> modulo 2<sup>8</sup>.</li>
<li>Return the IDL <a class="idltype" href="#idl-octet">octet</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-octet">octet</a> value to an ECMAScript
value is a <span class="estype">Number</span> that represents
the same numeric value as the IDL
<a class="idltype" href="#idl-octet">octet</a> value.
The <span class="estype">Number</span> value will be an integer in the range [0, 255].
</p>
</div>
<div id="es-short" class="section">
<h4>4.2.6. short</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-short">short</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < −2<sup>15</sup> or <var>x</var> > 2<sup>15</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-short">short</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, −2<sup>15</sup>), 2<sup>15</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-short">short</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +0, −0, +∞, or −∞, then return the IDL <a class="idltype" href="#idl-short">short</a> value that represents 0.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>Set <var>x</var> to <var>x</var> modulo 2<sup>16</sup>.</li>
<li>If <var>x</var> ≥ 2<sup>15</sup>, return the IDL <a class="idltype" href="#idl-short">short</a> value that represents the same numeric value as <var>x</var> − 2<sup>16</sup>.
Otherwise, return the IDL <a class="idltype" href="#idl-short">short</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-short">short</a> value to an ECMAScript
value is a <span class="estype">Number</span> that represents the
same numeric value as the IDL
<a class="idltype" href="#idl-short">short</a> value.
The <span class="estype">Number</span> value will be an integer in the range [−32768, 32767].
</p>
</div>
<div id="es-unsigned-short" class="section">
<h4>4.2.7. unsigned short</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < 0 or <var>x</var> > 2<sup>16</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, 0), 2<sup>16</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>Set <var>x</var> to ToUint16(<var>x</var>).</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value to an ECMAScript
value is a <span class="estype">Number</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-unsigned-short">unsigned short</a> value.
The <span class="estype">Number</span> value will be an integer in the range [0, 65535].
</p>
</div>
<div id="es-long" class="section">
<h4>4.2.8. long</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-long">long</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < −2<sup>31</sup> or <var>x</var> > 2<sup>31</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-long">long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, −2<sup>31</sup>), 2<sup>31</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-long">long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>Set <var>x</var> to ToInt32(<var>x</var>).</li>
<li>Return the IDL <a class="idltype" href="#idl-long">long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-long">long</a> value to an ECMAScript
value is a <span class="estype">Number</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-long">long</a> value.
The <span class="estype">Number</span> value will be an integer in the range [−2147483648, 2147483647].
</p>
</div>
<div id="es-unsigned-long" class="section">
<h4>4.2.9. unsigned long</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < 0 or <var>x</var> > 2<sup>32</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, 0), 2<sup>32</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>Set <var>x</var> to ToUint32(<var>x</var>).</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value to an ECMAScript
value is a <span class="estype">Number</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-unsigned-long">unsigned long</a> value.
The <span class="estype">Number</span> value will be an integer in the range [0, 4294967295].
</p>
</div>
<div id="es-long-long" class="section">
<h4>4.2.10. long long</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-long-long">long long</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < −2<sup>63</sup> or <var>x</var> > 2<sup>63</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-long-long">long long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, −2<sup>63</sup>), 2<sup>63</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-long-long">long long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +0, −0, +∞, or −∞, then return the IDL <a class="idltype" href="#idl-long-long">long long</a> value that represents 0.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>Set <var>x</var> to <var>x</var> modulo 2<sup>64</sup>.</li>
<li>If <var>x</var> is greater than or equal to 2<sup>63</sup>, return the IDL <a class="idltype" href="#idl-long-long">long long</a> value that represents the same numeric value as <var>x</var> − 2<sup>64</sup>.
Otherwise, return the IDL <a class="idltype" href="#idl-long-long">long long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-long-long">long long</a> value to an ECMAScript
value is a <span class="estype">Number</span> value that
represents the closest numeric value to the <a class="idltype" href="#idl-long-long">long long</a>,
choosing the numeric value with an <em>even significand</em> if there are
two equally close values (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.5).
If the <a class="idltype" href="#idl-long-long">long long</a> is in the range
(−(2<sup>53</sup> − 1), 2<sup>53</sup> − 1), then the <span class="estype">Number</span>
will be able to represent exactly the same value as the
<a class="idltype" href="#idl-long-long">long long</a>.
</p>
</div>
<div id="es-unsigned-long-long" class="section">
<h4>4.2.11. unsigned long long</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Initialize <var>x</var> to ToNumber(<var>V</var>).</li>
<li>If the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +∞, or −∞, then throw a <span class="estype">TypeError</span>.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>If <var>x</var> < 0 or <var>x</var> > 2<sup>64</sup> − 1, then throw a <span class="estype">TypeError</span>.</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is not <span class="esvalue">NaN</span> and the conversion to an IDL value is being performed due to any of the following:
<ul>
<li><var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,</li>
<li><var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a> argument annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute, or</li>
<li><var>V</var> is being used as the value of <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> annotated with the <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute,</li>
</ul>
then:
<ol>
<li>Round <var>x</var> to the nearest integer, choosing the even integer if it lies halfway between two.</li>
<li>Set <var>x</var> to min(max(<var>x</var>, 0), 2<sup>64</sup> − 1).</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, +0, −0, +∞, or −∞, then return the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value that represents 0.</li>
<li>Set <var>x</var> to sign(<var>x</var>) * floor(abs(<var>x</var>)).</li>
<li>Set <var>x</var> to <var>x</var> modulo 2<sup>64</sup>.</li>
<li>Return the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value that represents the same numeric value as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value to an ECMAScript
value is a <span class="estype">Number</span> value that
represents the closest numeric value to the <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a>,
choosing the numeric value with an <em>even significand</em> if there are
two equally close values (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.5).
If the <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> is less than or equal to 2<sup>53</sup> − 1,
then the <span class="estype">Number</span> will be able to
represent exactly the same value as the
<a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a>.
</p>
</div>
<div id="es-float" class="section">
<h4>4.2.12. float</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-float">float</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be ToNumber(<var>V</var>).</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, then return the IDL <a class="idltype" href="#idl-float">float</a> value that represents the IEEE 754 NaN value with the bit pattern 0x7fc00000 <a href="#ref-IEEE-754">[IEEE-754]</a>.</li>
<li>
Let <var>S</var> be the set of finite IEEE 754 single-precision floating
point values except −0, but with two special values added: 2<sup>128</sup> and
−2<sup>128</sup>.
</li>
<li>
Let <var>y</var> be the number in <var>S</var> that is closest
to <var>x</var>, selecting the number with an
<em>even significand</em> if there are two equally close values
(<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.5).
(The two special values 2<sup>128</sup> and −2<sup>128</sup>
are considered to have even significands for this purpose.)
</li>
<li>
If <var>y</var> is 2<sup>128</sup>, return +∞.
</li>
<li>
If <var>y</var> is −2<sup>128</sup>, return −∞.
</li>
<li>
If <var>y</var> is +0 and <var>x</var> is negative, return −0.
</li>
<li>
Return <var>y</var>.
</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
Since there is only a single ECMAScript <span class="esvalue">NaN</span> value,
it must be canonicalized to a particular single precision IEEE 754 NaN value. The NaN value
mentioned above is chosen simply because it is the quiet NaN with the lowest
value when its bit pattern is interpreted as an unsigned 32 bit integer.
</p>
</div>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-float">float</a> value to an ECMAScript
value is a <span class="estype">Number</span>:
</p>
<ul>
<li>
If the IDL <a class="idltype" href="#idl-float">float</a> value is a NaN,
then the <span class="estype">Number</span> value is <span class="esvalue">NaN</span>.
</li>
<li>
Otherwise, the <span class="estype">Number</span> value is
the one that represents the same numeric value as the IDL
<a class="idltype" href="#idl-float">float</a> value.
</li>
</ul>
</div>
<div id="es-double" class="section">
<h4>4.2.13. double</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-double">double</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be ToNumber(<var>V</var>).</li>
<li>If <var>x</var> is <span class="esvalue">NaN</span>, then return the IDL <a class="idltype" href="#idl-double">double</a> value that represents the IEEE 754 NaN value with the bit pattern 0x7ff8000000000000 <a href="#ref-IEEE-754">[IEEE-754]</a>.</li>
<li>
Return the IDL <a class="idltype" href="#idl-double">double</a> value
that has the same numeric value as <var>x</var>.
</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
Since there is only a single ECMAScript <span class="esvalue">NaN</span> value,
it must be canonicalized to a particular double precision IEEE 754 NaN value. The NaN value
mentioned above is chosen simply because it is the quiet NaN with the lowest
value when its bit pattern is interpreted as an unsigned 64 bit integer.
</p>
</div>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-double">double</a> value to an ECMAScript
value is a <span class="estype">Number</span>:
</p>
<ul>
<li>
If the IDL <a class="idltype" href="#idl-double">double</a> value is a NaN,
then the <span class="estype">Number</span> value is <span class="esvalue">NaN</span>.
</li>
<li>
Otherwise, the <span class="estype">Number</span> value is
the one that represents the same numeric value as the IDL
<a class="idltype" href="#idl-double">double</a> value.
</li>
</ul>
</div>
<div id="es-DOMString" class="section">
<h4>4.2.14. DOMString</h4>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-DOMString">DOMString</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>If <var>V</var> is <span class="esvalue">null</span>
and the conversion to an IDL value is being performed due
to any of the following:
<ul>
<li>
<var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a>
argument that is annotated with the <a class="xattr" href="#TreatNullAs">[TreatNullAs=EmptyString]</a>,
</li>
<li>
<var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a>
annotated with <a class="xattr" href="#TreatNullAs">[TreatNullAs=EmptyString]</a>,
</li>
<li>
<var>V</var> is being returned from a <a class="dfnref" href="#dfn-user-object">user object</a> implementation of an
operation annotated with <a class="xattr" href="#TreatNullAs">[TreatNullAs=EmptyString]</a>, or
</li>
<li>
<var>V</var> is being returned from a <a class="dfnref" href="#dfn-user-object">user object</a> implementation of an
attribute annotated with <a class="xattr" href="#TreatNullAs">[TreatNullAs=EmptyString]</a>,
</li>
</ul>
then return the <a class="idltype" href="#idl-DOMString">DOMString</a>
value that represents the empty string.
</li>
<li>If <var>V</var> is <span class="esvalue">undefined</span>
and the conversion to an IDL value is being performed due
to any of the following:
<ul>
<li>
<var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a>
argument that is annotated with the <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs=EmptyString]</a>,
</li>
<li>
<var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a>
annotated with <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs=EmptyString]</a>,
</li>
<li>
<var>V</var> is being returned from a <a class="dfnref" href="#dfn-user-object">user object</a> implementation of an
operation annotated with <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs=EmptyString]</a>, or
</li>
<li>
<var>V</var> is being returned from a <a class="dfnref" href="#dfn-user-object">user object</a> implementation of an
attribute annotated with <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs=EmptyString]</a>,
</li>
</ul>
then return the <a class="idltype" href="#idl-DOMString">DOMString</a>
value that represents the empty string.
</li>
<li>Let <var>x</var> be ToString(<var>V</var>).</li>
<li>Return the IDL <a class="idltype" href="#idl-DOMString">DOMString</a> value that represents the same sequence of code units as the one the ECMAScript <span class="estype">String</span> value <var>x</var> represents.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-DOMString">DOMString</a> value to an ECMAScript
value is the <span class="estype">String</span>
value that represents the same sequence of <a class="dfnref" href="#dfn-code-unit">code units</a> that the
IDL <a class="idltype" href="#idl-DOMString">DOMString</a> represents.
</p>
</div>
<div id="es-object" class="section">
<h4>4.2.15. object</h4>
<p>
IDL <a class="idltype" href="#idl-object">object</a>
values are represented by ECMAScript <span class="estype">Object</span> values.
</p>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-object">object</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the result of calling ToObject(<var>V</var>).</li>
<li>Return the IDL <a class="idltype" href="#idl-object">object</a> value that is a reference to the same object as <var>x</var>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="idltype" href="#idl-object">object</a> value to an ECMAScript
value is the <span class="estype">Object</span> value that represents a reference to the same object that the
IDL <a class="idltype" href="#idl-object">object</a> represents.
</p>
</div>
<div id="es-interface" class="section">
<h4>4.2.16. Interface types</h4>
<p>
IDL <a href="#idl-interface">interface type</a>
values are represented by ECMAScript <span class="estype">Object</span> values.
</p>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a href="#idl-interface">interface type</a> value
by running the following algorithm (where <var>I</var> is the <a class="dfnref" href="#dfn-interface">interface</a>):
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the result of calling ToObject(<var>V</var>).</li>
<li>If <var>x</var> is a <a class="dfnref" href="#dfn-platform-object">platform object</a> that implements <var>I</var>, then return the IDL <a href="#idl-interface">interface type</a> value that represents a reference to that platform object.</li>
<li>If <var>x</var> is a <a class="dfnref" href="#dfn-user-object">user object</a> that is considered to implement <var>I</var> according to the rules in <a href="#es-user-objects">section 4.8</a>, then return the IDL <a href="#idl-interface">interface type</a> value that represents a reference to that user object.</li>
<li>Throw a <span class="esvalue">TypeError</span>.</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a href="#idl-interface">interface type</a>
value to an ECMAScript value is the <span class="estype">Object</span>
value that represents a reference to the same object that the IDL
<a href="#idl-interface">interface type</a> value represents.
</p>
</div>
<div id="es-dictionary" class="section">
<h4>4.2.17. Dictionary types</h4>
<p>
IDL <a href="#idl-dictionary">dictionary type</a> values are represented
by ECMAScript <span class="estype">Object</span> values. Properties on
the object (or its prototype chain) correspond to <a class="dfnref" href="#dfn-dictionary-member">dictionary members</a>.
</p>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a href="#idl-dictionary">dictionary type</a> value
by running the following algorithm (where <var>D</var> is the <a class="dfnref" href="#dfn-dictionary">dictionary</a>):
</p>
<ol class="algorithm">
<li>If Type(<var>V</var>) is not Object, then throw a <span class="estype">TypeError</span>.</li>
<li>Let <var>dict</var> be an empty dictionary value of type <var>D</var>;
every <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a>
is initially considered to be <a class="dfnref" href="#dfn-present">not present</a>.</li>
<li>Let <var>dictionaries</var> be a list consisting of <var>D</var> and all of <var>D</var>’s <a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>,
in order from least to most derived.</li>
<li>For each dictionary <var>dictionary</var> in <var>dictionaries</var>, in order:
<ol>
<li>For each dictionary member <var>member</var> declared on <var>D</var>, in order:
<ol>
<li>Let <var>key</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of <var>member</var>.</li>
<li>Let <var>present</var> be the result of calling the <span class="prop">[[HasProperty]]</span> internal method on <var>V</var> with property name <var>key</var>.</li>
<li>If <var>present</var> is true, then:
<ol>
<li>Let <var>value</var> be the result of calling the <span class="prop">[[Get]]</span> internal method on <var>V</var> with property name <var>key</var>.</li>
<li>Let <var>idlValue</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a> <var>value</var> to an IDL value whose type is the type <var>member</var> is declared to be of.</li>
<li>Set the dictionary member on <var>dict</var> with key name <var>key</var> to the value <var>idlValue</var>. This dictionary member is considered to be <a class="dfnref" href="#dfn-present">present</a>.</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
<li>Return <var>dict</var>.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
The order that <a class="dfnref" href="#dfn-dictionary-member">dictionary members</a> are looked
up on the ECMAScript object are not necessarily the same as the object’s property enumeration order.
</p>
</div>
<p>
An IDL dictionary value <var>V</var> is
<a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converted</a>
to an ECMAScript <span class="estype">Object</span> value
by running the following algorithm (where <var>D</var> is the <a class="dfnref" href="#dfn-dictionary">dictionary</a>):
</p>
<ol class="algorithm">
<li>Let <var>O</var> be a new <span class="estype">Object</span> value created as if by the expression <code>({})</code>.</li>
<li>Let <var>dictionaries</var> be a list consisting of <var>D</var> and all of <var>D</var>’s <a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>,
in order from least to most derived.</li>
<li>For each dictionary <var>dictionary</var> in <var>dictionaries</var>, in order:
<ol>
<li>For each dictionary member <var>member</var> declared on <var>dictionary</var>, in order:
<ol>
<li>Let <var>key</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of <var>member</var>.</li>
<li>If the dictionary member named <var>key</var> is <a class="dfnref" href="#dfn-present">present</a> on <var>V</var>, then:
<ol>
<li>Let <var>idlValue</var> be the value of <var>member</var> on <var>V</var>.</li>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a> <var>idlValue</var> to an ECMAScript value.</li>
<li>Call the <span class="prop">[[DefineOwnProperty]]</span> internal method on <var>O</var> with property name <var>key</var>,
descriptor <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span>, [[Value]]: <var>value</var> }</span>
and Boolean flag <span class="esvalue">false</span>.</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
<li>Return <var>O</var>.</li>
</ol>
</div>
<div id="es-nullable-type" class="section">
<h4>4.2.18. Nullable types — <var>T</var>?</h4>
<p>
IDL <a class="dfnref" href="#dfn-nullable-type">nullable type</a> values are represented
by values of either the ECMAScript type corresponding to the <a class="dfnref" href="#dfn-inner-type">inner IDL type</a>, or
the ECMAScript <span class="esvalue">null</span> value.
</p>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="dfnref" href="#dfn-nullable-type">nullable type</a> <span class="idltype"><var>T</var>?</span>
value (where <var>T</var> is the <a class="dfnref" href="#dfn-inner-type">inner type</a>) as follows:
</p>
<ol class="algorithm">
<li>
If <var>V</var> is <span class="esvalue">undefined</span> and the
IDL type being converted to is <span class="idltype">DOMString?</span>, then:
<ol>
<li>
If the conversion to an IDL value is being performed due
to any of the following:
<ul>
<li>
<var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a>
argument that is annotated with the <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>,
</li>
<li>
<var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a>
annotated with <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>,
</li>
<li>
<var>V</var> is being returned from a <a class="dfnref" href="#dfn-user-object">user object</a> implementation of an
operation annotated with <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>, or
</li>
<li>
<var>V</var> is being returned from a <a class="dfnref" href="#dfn-user-object">user object</a> implementation of an
attribute annotated with <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>,
</li>
</ul>
then:
<ol>
<li>
If the argument given to <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
is <code>EmptyString</code>, then return the <span class="idltype">DOMString?</span>
value that represents the empty string.
</li>
<li>
Otherwise, the argument given to <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
is <code>Null</code>. Return the <span class="idlvalue">null</span>
<span class="idltype">DOMString?</span> value.
</li>
</ol>
</li>
</ol>
</li>
<li>
Otherwise, if the result of calling IsCallable(<var>V</var>) is <span class="esvalue">true</span>, then:
<ol>
<li>
If the conversion to an IDL value is being performed due
to any of the following:
<ul>
<li>
<var>V</var> is being passed as an <a class="dfnref" href="#dfn-operation">operation</a>
argument that is annotated with the <a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>,
</li>
<li>
<var>V</var> is being assigned to an <a class="dfnref" href="#dfn-attribute">attribute</a>
annotated with <a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>,
</li>
</ul>
then return the IDL
<a class="dfnref" href="#dfn-nullable-type">nullable type</a> <span class="idltype"><var>T</var>?</span>
value <span class="idlvalue">null</span>.
</li>
</ol>
</li>
<li>
Otherwise, if <var>V</var> is <span class="esvalue">null</span> or <span class="esvalue">undefined</span>, then return the IDL
<a class="dfnref" href="#dfn-nullable-type">nullable type</a> <span class="idltype"><var>T</var>?</span>
value <span class="idlvalue">null</span>.
</li>
<li>
Otherwise, return the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a> <var>V</var>
to the <a class="dfnref" href="#dfn-inner-type">inner IDL type</a> <span class="idltype"><var>T</var></span>.
</li>
</ol>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
an IDL <a class="dfnref" href="#dfn-nullable-type">nullable type</a> value to an ECMAScript value is:
</p>
<ul>
<li>
If the IDL <a class="dfnref" href="#dfn-nullable-type">nullable type</a> <span class="idltype"><var>T</var>?</span>
value is <span class="idlvalue">null</span>,
then the ECMAScript value is <span class="esvalue">null</span>.
</li>
<li>
Otherwise, the IDL <a class="dfnref" href="#dfn-nullable-type">nullable type</a> value is the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
the ECMAScript value to the <a class="dfnref" href="#dfn-inner-type">inner IDL type</a> <span class="idltype"><var>T</var></span>.
</li>
</ul>
</div>
<div id="es-sequence" class="section">
<h4>4.2.19. Sequences — sequence<<var>T</var>></h4>
<p>
IDL <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> values are represented by
ECMAScript <span class="estype">Array</span> values.
</p>
<p>
An ECMAScript value <var>V</var> is <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> value as follows:
</p>
<ol class="algorithm">
<li>If <var>V</var> is <span class="esvalue">null</span> or <span class="esvalue">undefined</span>,
then return a sequence of length zero.</li>
<li>Let <var>A</var> be the result of calling ToObject(<var>V</var>).</li>
<li>Let <var>length</var> be the result of calling <span class="prop">[[Get]]</span> on <var>A</var> with property name “length”.</li>
<li>Let <var>n</var> be the result of calling ToUint32(<var>length</var>).</li>
<li>Initialize <var>S</var><sub>0..<var>n</var>−1</sub> to be an IDL sequence with elements of type <var>T</var>, where each element is uninitialized.</li>
<li>Initialize <var>i</var> to be 0.</li>
<li>While <var>i</var> < <var>n</var>:
<ol>
<li>Let <var>P</var> be the result of calling ToString(<var>i</var>).</li>
<li>Let <var>E</var> be the result of calling <span class="prop">[[Get]]</span> on <var>A</var> with property name <var>P</var>.</li>
<li>Set <var>S</var><sub><var>i</var></sub> to the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>E</var> to an IDL value of type <var>T</var>.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
<li>Return <var>S</var>.</li>
</ol>
<p>
An IDL sequence value <var>S</var><sub>0..<var>n</var>−1</sub> of type
<a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> is
<a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converted</a>
to an ECMAScript <span class="estype">Array</span> object as follows:
</p>
<ol class="algorithm">
<li>Let <var>A</var> be a new <span class="estype">Array</span> object created as if by the expression <code>[]</code>.</li>
<li>Initialize <var>i</var> to be 0.</li>
<li>While <var>i</var> < <var>n</var>:
<ol>
<li>Let <var>E</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>S</var><sub><var>i</var></sub> to an ECMAScript value.</li>
<li>Let <var>P</var> be the result of calling ToString(<var>i</var>).</li>
<li>Call the <span class="prop">[[DefineOwnProperty]]</span> internal method on <var>A</var> with property name <var>P</var>,
descriptor <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span>, [[Value]]: <var>E</var> }</span>
and Boolean flag <span class="esvalue">false</span>.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
<li>Return <var>A</var>.</li>
</ol>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-interface">interface</a> defines
an <a class="dfnref" href="#dfn-attribute">attribute</a> of a sequence
type as well as an <a class="dfnref" href="#dfn-operation">operation</a>
with an argument of a sequence type.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Canvas {
sequence<DOMString> getSupportedImageCodecs();
void drawPolygon(sequence<float> coordinates);
sequence<float> getLastDrawnPolygon();
<span class="comment">// ...</span>
};</code></pre></div></div>
<p>
In an ECMAScript implementation of this interface, an <span class="estype">Array</span>
object with elements of type <span class="estype">String</span> is used to
represent a <span class="idltype">sequence<DOMString></span>, while an
<span class="estype">Array</span> with elements of type <span class="estype">Number</span>
represents a <span class="idltype">sequence<float></span>. The
<span class="estype">Array</span> objects are effectively passed by
value; every time the <code>getSupportedImageCodecs()</code>
function is called a new <span class="estype">Array</span> is
returned, and whenever an <span class="estype">Array</span> is
passed to <code>drawPolygon</code> no reference
will be kept after the call completes.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">
<span class="comment">// Obtain an instance of Canvas. Assume that getSupportedImageCodecs()</span>
<span class="comment">// returns a sequence with two DOMString values: "image/png" and "image/svg+xml".</span>
var canvas = getCanvas();
<span class="comment">// An Array object of length 2.</span>
var supportedImageCodecs = canvas.getSupportedImageCodecs();
<span class="comment">// Evaluates to "image/png".</span>
supportedImageCodecs[0];
<span class="comment">// Each time canvas.getSupportedImageCodecs() is called, it returns a</span>
<span class="comment">// new Array object. Thus modifying the returned Array will not</span>
<span class="comment">// affect the value returned from a subsequent call to the function.</span>
supportedImageCodecs[0] = "image/jpeg";
<span class="comment">// Evaluates to "image/png".</span>
canvas.getSupportedImageCodecs()[0];
<span class="comment">// This evaluates to false.</span>
canvas.getSupportedImageCodecs() == canvas.getSupportedImageCodecs();
<span class="comment">// An Array of Numbers...</span>
var a = [0, 0, 100, 0, 50, 62.5];
<span class="comment">// ...can be passed to a platform object expecting a sequence<float>.</span>
canvas.drawPolygon(a);
<span class="comment">// Each element will be converted to a float by first calling ToNumber().</span>
<span class="comment">// So the following call is equivalent to the previous one, except that</span>
<span class="comment">// "hi" will be alerted before drawPolygon() returns.</span>
a = [false, '',
{ valueOf: function() { alert('hi'); return 100; } }, 0,
'50', new Number(62.5)];
canvas.drawPolygon(s);
<span class="comment">// Modifying an Array that was passed to drawPolygon() is guaranteed not to</span>
<span class="comment">// have an effect on the Canvas, since the Array is effectively passed by value.</span>
a[4] = 20;
var b = canvas.getLastDrawnPolygon();
alert(b[4]); <span class="comment">// This would alert "50".</span></code></pre></div></div>
</div>
<!--
<div class='ignore'>
<p>
IDL <a class='idltype' href='#idl-sequence'>sequence<<var>T</var>></a> values are represented by
ECMAScript <span class='estype'>Object</span> values with special properties.
</p>
<p>
Values <a class='dfnref' href='#dfn-pass-to-host-object'>passed to a host object</a> expecting a
<a class='idltype' href='#idl-sequence'>sequence<<var>T</var>></a>
<span class='rfc2119'>MUST</span> be objects with a <span class='prop'>length</span> property whose
value, after being converted to a <span class='estype'>Number</span> by the
ToUint32 operator, is a non-negative integer that specifies the number
of elements in the sequence. This number <span class='rfc2119'>MUST</span> also be equal
to the result of passing the original <span class='prop'>length</span> property value to the ToNumber algorithm.
Assigning to the <span class='prop'>length</span> property a non-negative
integer <span class='estype'>Number</span> <span class='rfc2119'>MUST</span> change the length of the sequence
to be the given number. If the sequence is lengthened, new elements <span class='rfc2119'>MUST</span> be given
the value that the <span class='esvalue'>undefined</span> value is converted to
when handling it according to the rules in this section for the type <var>T</var>.
If the sequence is shortened, the values beyond the new length of the sequence
are lost.
The object representing the sequence <span class='rfc2119'>MUST</span> return the element in
the sequence at position <var>n</var> when its
<span class='prop'>[[Get]]</span> internal method is invoked with
<var>n</var> as its argument.
</p>
<p>
Note that an ECMAScript <span class='estype'>Array</span>
is an object that matches this description. Implementations are free,
however, to use a host object to implement the sequence in the
interests of efficiency.
</p>
<p>
When the host object
gets an element of the sequence using the <span class='prop'>[[Get]]</span> method,
the returned value <span class='rfc2119'>MUST</span> first be handled according to
the rules in this section for the type <var>T</var>.
</p>
<p>
If a host object expecting a
<a class='idltype' href='#idl-sequence'>sequence<<var>T</var>></a>
is passed a value which is not an object that conforms to the above rules
(for example, it does not have a <span class='prop'>length</span> property), then
a <span class='estype'>TypeError</span> exception <span class='rfc2119'>MUST</span> be thrown.
</p>
<p>
While sequences are passed by reference (being objects), it is
of course up to the interface designer whether, for example,
after assigning a sequence to a property on a host object
that same seqence object is returned when getting the property.
The behavior of storing sequences in the host object in this
manner should be made clear in prose describing the interface.
</p>
<!- p>
Sequences are passed by reference. If a reference to a sequence
passed to a host object is kept (whether internally or as the
value of an attribute), and the passed sequence is not an ECMAScript
<span class='estype'>Array</span> object, the kept reference must
be a newly created ECMAScript <span class='estype'>Array</span> object
whose contents is the elements of the sequence.
</p>
<div class='ednote'>
<p>Change the above para according to comments in
<a href='http://www.w3.org/mid/op.tumn9hy664w2qv@annevk-t60.oslo.opera.com'>this thread</a>.</p>
</div ->
<div class='ednote'>
<p>
Should there be a way to declare a sequence whose length cannot be changed
from script?
</p>
</div>
</div>
-->
</div>
<div id="es-array" class="section">
<h4>4.2.20. Arrays — <var>T</var>[]</h4>
<p>
IDL array values are represented by references to objects known
as <dfn id="dfn-platform-array-object">platform array objects</dfn>, with particular
characteristics that allow them to behave similarly to native <span class="estype">Array</span>
objects. All <a class="dfnref" href="#dfn-platform-array-object">platform array objects</a>
are <a class="dfnref" href="#dfn-platform-object">platform objects</a>, and
thus each is associated with a particular global environment.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
<a class="dfnref" href="#dfn-platform-array-object">Platform array objects</a> differ
from <span class="estype">Array</span> objects in the following ways:
</p>
<ul>
<li>they are never sparse</li>
<li>their elements are always data properties</li>
<li>an ECMAScript-to-IDL value conversion is always performed when storing an element</li>
<li>their internal <span class="prop">[[Class]]</span> property value is different</li>
<li>their internal <span class="prop">[[Extensible]]</span> property value is always <span class="esvalue">true</span></li>
</ul>
</div>
<p>
The value of the internal <span class="prop">[[Prototype]]</span> property of a
<a class="dfnref" href="#dfn-platform-array-object">platform array object</a>
<span class="rfc2119">MUST</span> be the
<span class="estype">Array</span> prototype object
(<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.4.4)
from its associated global environment.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
Note that some of the functions from the <span class="estype">Array</span> prototype object
will not behave on a <a class="dfnref" href="#dfn-fixed-length">fixed length</a>
platform array object as they do on an <span class="estype">Array</span> object, since
attempting to assign to the “length” property will fail.
Similarly, some of the functions from the <span class="estype">Array</span>
prototype object will not perform any useful operation on
<a class="dfnref" href="#dfn-read-only-array">read only arrays</a>.
</p>
</div>
<p>
The value of the internal <span class="prop">[[Class]]</span> property of a
platform array object <span class="rfc2119">MUST</span> be
the <a class="dfnref" href="#dfn-type-name">type name</a> of the
<a href="#idl-array">array type</a>.
</p>
<!--
<p>
Platform array objects <span class='rfc2119'>MUST</span> have a property named “length”
whose value is a <span class='estype'>Number</span> that is the length
of the array. If the array is <a class='dfnref' href='#dfn-fixed-length'>fixed length</a>,
then this property has attributes <span class='descriptor'>{ [[Writable]]: <span class='esvalue'>false</span>, [[Enumerable]]: <span class='esvalue'>false</span>, [[Configurable]]: <span class='esvalue'>false</span> }</span>.
Otherwise, the array is <a class='dfnref' href='#dfn-variable-length'>variable length</a>,
and the property has attributes <span class='descriptor'>{ [[Writable]]: <span class='esvalue'>true</span>, [[Enumerable]]: <span class='esvalue'>false</span>, [[Configurable]]: <span class='esvalue'>false</span> }</span>.
</p>
<p>
Platform array objects <span class='rfc2119'>MUST</span> always have a property named
ToString(<var>i</var>) for every integer index 0 ≤ <var>i</var> < <var>n</var>,
where <var>n</var> is the length of the array. These properties have attributes
<span class='descriptor'>{ [[Writable]]: <span class='esvalue'>false</span>, [[Enumerable]]: <span class='esvalue'>true</span>, [[Configurable]]: <span class='esvalue'>false</span> }</span> if the array is
<a class='dfnref' href='#dfn-read-only-array'>read only</a> and
<span class='descriptor'>{ [[Writable]]: <span class='esvalue'>true</span>, [[Enumerable]]: <span class='esvalue'>true</span>, [[Configurable]]: <span class='esvalue'>false</span> }</span> otherwise. The values of these properties
<span class='rfc2119'>MUST</span> be the result of <a class='dfnref' href='#dfn-convert-idl-to-ecmascript-value'>converting</a>
the value of the array element at the corresponding index to an ECMAScript value.
</p>
-->
<p>
Platform array objects appear to have a “length” property and a property
for each element of the array. The values and behaviors of these properties are
implemented by the internal <span class="prop">[[GetOwnProperty]]</span>,
<span class="prop">[[DefineOwnProperty]]</span> and <span class="prop">[[Delete]]</span>
methods, which are also defined below.
</p>
<p>
Platform array objects cannot be fixed; if <code>Object.freeze</code>, <code>Object.seal</code>
or <code>Object.preventExtensions</code> is called on one, the function
<span class="rfc2119">MUST</span> throw a <span class="estype">TypeError</span>.
</p>
<p>
An ECMAScript value <var>V</var> is <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL array value of type <span class="idltype"><var>T</var>[]</span> as follows:
</p>
<ul>
<li>Let <var>O</var> be the result of calling ToObject(<var>V</var>).</li>
<li>If <var>O</var> is a <a class="dfnref" href="#dfn-platform-array-object">platform array object</a>,
then the IDL array value is the array value that the platform array object represents.</li>
<li>Otherwise, the IDL array value is determined as follows:
<ol class="algorithm">
<li>Initialize <var>n</var> to be the result of calling <span class="prop">[[Get]]</span> on <var>V</var> with property name “length”.</li>
<li>Set <var>n</var> to ToUint32(<var>n</var>).</li>
<li>Initialize <var>values</var><sub>0..<var>n</var>−1</sub> to be a list of IDL values.</li>
<li>Initialize <var>i</var> to be 0.</li>
<li>While <var>i</var> < <var>n</var>:
<ol>
<li>Let <var>x</var> be the result of calling <span class="prop">[[Get]]</span> on <var>V</var> with
property name ToString(<var>i</var>).</li>
<li>Set <var>values</var><sub><var>i</var></sub> to be the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>x</var> to an IDL value of type <var>T</var>.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
<li>The IDL array value is a <a class="dfnref" href="#dfn-fixed-length">fixed length</a>
array of length <var>n</var> whose values are <var>values</var><sub>0..<var>n</var>−1</sub>.</li>
</ol>
</li>
</ul>
<p>
An IDL array value <var>V</var> of type <span class="idltype"><var>T</var>[]</span> is
<a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converted</a> to an
ECMAScript value as follows:
</p>
<ul>
<li>If <var>V</var> is already represented by a <a class="dfnref" href="#dfn-platform-array-object">platform array object</a>,
then the ECMAScript value is that platform array object.</li>
<li>Otherwise, the ECMAScript value is a newly created platform array object that represents <var>V</var>.</li>
</ul>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following IDL defines an interface that has an
<span class="idltype">unsigned short[]</span> attribute.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Constructor]
interface LotteryResults {
readonly attribute unsigned short[] numbers;
};</code></pre></div></div>
<p>
Assuming that the array has a <a class="dfnref" href="#dfn-fixed-length">fixed length</a>
of 6, the following ECMAScript code illustrates how the array
attribute in the above interface would behave:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var results = new LotteryResults(); <span class="comment">// results is a new platform object</span>
<span class="comment">// implementing the LotteryResults interface.</span>
var a = [4, 8, 15, 16, 23, 42]; <span class="comment">// Numbers will be assigned into the array.</span>
for (var i = 0; i < 6; i++) {
results.numbers[i] = a[i];
}
results.numbers = a; <span class="comment">// This has no effect, since numbers is</span>
<span class="comment">// read only.</span>
a[0] = 5; <span class="comment">// Change the array.</span>
results.numbers[0]; <span class="comment">// Evaluates to 4, since results.numbers is</span>
<span class="comment">// not a reference to 'a'.</span>
results.numbers[0] = 5; <span class="comment">// Modifies the array stored in the platform</span>
<span class="comment">// object.</span>
results.numbers[0]; <span class="comment">// Now evaluates to 5.</span>
results.numbers[0] = 6.25; <span class="comment">// Assigns 6 to the first element of the array</span>
<span class="comment">// since that is how 6.5 is converted to an</span>
<span class="comment">// unsigned short.</span>
results.numbers.length = 7; <span class="comment">// Has no effect, since numbers is</span>
<span class="comment">// fixed length.</span>
results.numbers[6]; <span class="comment">// Evaluates to undefined.</span>
results.numbers.slice(0, 2); <span class="comment">// Evaluates to an Array [6, 8].</span>
results.numbers.push(108); <span class="comment">// Has no effect, since the definition of</span>
<span class="comment">// push() relies on calling [[Put]] on a</span>
<span class="comment">// non-existent array index property</span>
<span class="comment">// and on "length", both of which will</span>
<span class="comment">// be silently ignored.</span>
delete results.numbers[3]; <span class="comment">// Has no effect and evaluates to false,</span>
<span class="comment">// since the array index properties are</span>
<span class="comment">// non-configurable.</span></code></pre></div></div>
<p>
If passing an <span class="estype">Array</span> object to a <a class="dfnref" href="#dfn-platform-object">platform object</a>
expecting an IDL array value, a new <a class="dfnref" href="#dfn-platform-array-object">platform array object</a>
will be created to represent an IDL array value determined from that <span class="estype">Array</span>.
If the <span class="idltype">LotteryResults</span> interface is instead defined as:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Constructor]
interface LotteryResults {
attribute unsigned short[] numbers;
};</code></pre></div></div>
<p>
then an <span class="estype">Array</span> object can be assigned to the
“numbers” property. Unless the prose accompanying
the interface said otherwise, this would result in a
<a class="dfnref" href="#dfn-fixed-length">fixed length</a>
array of whatever length the <span class="estype">Array</span>
has being assigned to the IDL attribute.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var results = new LotteryResults();
results.numbers.length; <span class="comment">// Evaluates to 6.</span>
var a = [1, 3, 5];
results.numbers = a; <span class="comment">// Assigns a fixed length IDL array of length 3 to</span>
<span class="comment">// the numbers attribute.</span>
results.numbers; <span class="comment">// This now evaluates to a platform array object</span>
<span class="comment">// that represents the fixed length IDL array,</span>
<span class="comment">// not the Array object assigned in the previous</span>
<span class="comment">// statement.</span>
results.numbers == a; <span class="comment">// Evaluates to false.</span>
results.numbers.length; <span class="comment">// Evaluates to 3.</span>
results.numbers.push(7); <span class="comment">// Silently ignored in non-strict mode.</span>
results.numbers.length; <span class="comment">// So this still evaluates to 3.</span></code></pre></div></div>
</div>
<div id="platform-array-object-getownproperty" class="section">
<h5>4.2.20.1. Platform array object [[GetOwnProperty]] method</h5>
<p>
The internal <span class="prop">[[GetOwnProperty]]</span> method of every
<a class="dfnref" href="#dfn-platform-array-object">platform array object</a>
<var>A</var> with element type <var>T</var>
<span class="rfc2119">MUST</span> behave as follows when
called with property name <var>P</var>:
</p>
<ol class="algorithm">
<li>Let <var>length</var> be the length of the IDL array that <var>A</var> represents.</li>
<li>If <var>P</var> is “length”, then:
<ol>
<li>Let <var>desc</var> be a newly created property descriptor (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.10) with no fields.</li>
<li>Set <var>desc</var>.<span class="prop">[[Value]]</span> to the <span class="estype">Number</span> value for <var>length</var>.</li>
<li>Set <var>desc</var>.<span class="prop">[[Writable]]</span> to <span class="esvalue">false</span> if <var>A</var> represents a
<a class="dfnref" href="#dfn-read-only-array">read only</a> or <a class="dfnref" href="#dfn-fixed-length">fixed length</a> array, and <span class="esvalue">true</span> otherwise.</li>
<li>Set <var>desc</var>.<span class="prop">[[Enumerable]]</span> to <span class="esvalue">false</span>.</li>
<li>Set <var>desc</var>.<span class="prop">[[Configurable]]</span> to <span class="esvalue">false</span>.</li>
<li>Return <var>desc</var>.</li>
</ol>
</li>
<li>Otherwise, if <var>P</var> is an array index (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.4), then:
<ol>
<li>Let <var>index</var> be ToUint32(<var>P</var>).</li>
<li>If <var>index</var> ≥ <var>length</var>, then return <span class="esvalue">undefined</span>.</li>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a> the <var>index</var>th element of
the IDL array that <var>A</var> represents to an IDL value of type <var>T</var>.</li>
<li>Let <var>desc</var> be a newly created property descriptor (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.10) with no fields.</li>
<li>Set <var>desc</var>.<span class="prop">[[Value]]</span> to <var>value</var>.</li>
<li>Set <var>desc</var>.<span class="prop">[[Writable]]</span> to <span class="esvalue">false</span> if <var>A</var> represents a <a class="dfnref" href="#dfn-read-only-array">read only array</a>,
and <span class="esvalue">true</span> otherwise.</li>
<li>Set <var>desc</var>.<span class="prop">[[Enumerable]]</span> and <var>desc</var>.<span class="prop">[[Configurable]]</span> to <span class="esvalue">true</span>.</li>
<li>Return <var>desc</var>.</li>
</ol>
</li>
<li>Return the result of calling the default <span class="prop">[[GetOwnProperty]]</span> internal method (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.12.1) on <var>A</var> passing <var>P</var> as the argument.</li>
</ol>
</div>
<div id="platform-array-object-defineownproperty" class="section">
<h5>4.2.20.2. Platform array object [[DefineOwnProperty]] method</h5>
<p>
The internal <span class="prop">[[DefineOwnProperty]]</span> method of every
<a class="dfnref" href="#dfn-platform-array-object">platform array object</a>
<var>A</var> with element type <var>T</var>
<span class="rfc2119">MUST</span> behave as follows when passed
property name <var>P</var>, property descriptor <var>Desc</var> and
boolean flag <var>Throw</var>.
The term “Reject”
is used in the same sense as that defined in ECMA-262, namely, to mean “If <var>Throw</var> is
<span class="esvalue">true</span>, then throw a <span class="esvalue">TypeError</span> exception,
otherwise return <span class="esvalue">false</span>”.
</p>
<ol class="algorithm">
<li>Initialize <var>oldLen</var> to be the length of the IDL array that <var>A</var> represents.</li>
<li>If <var>P</var> is “length”, then:
<ol>
<li>If the result of calling IsDataDescriptor(<var>Desc</var>) is <span class="esvalue">false</span>, then Reject.</li>
<li>Let <var>newLen</var> be ToUint32(<var>Desc</var>.<span class="prop">[[Value]]</span>).</li>
<li>If <var>newLen</var> is not equal to ToNumber(<var>Desc</var>.<span class="prop">[[Value]]</span>), then throw a <span class="estype">RangeError</span> exception.</li>
<li>If <var>A</var> represents a <a class="dfnref" href="#dfn-read-only-array">read only</a> or <a class="dfnref" href="#dfn-fixed-length">fixed length</a> IDL array, then Reject.</li>
<li>If <var>newLen</var> > <var>oldLen</var>:
<ol>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<span class="esvalue">undefined</span> to type <var>T</var>.</li>
<li>Update the IDL array that <var>A</var> represents to have a length of <var>newLen</var>, and set every
value of the IDL array at indices in the range [<var>oldLen</var>, <var>newLen</var>) to <var>value</var>.</li>
</ol>
</li>
<li>Otherwise, if <var>newLen</var> < <var>oldLen</var>, then update the IDL array that <var>A</var> represents to have a length of <var>newLen</var>, discarding elements
at indices in the range [<var>newLen</var>, <var>oldLen</var>).</li>
<li>Return <b>true</b>.</li>
</ol>
</li>
<li>Otherwise, if <var>P</var> is an array index (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.4), then:
<ol>
<li>If the result of calling IsDataDescriptor(<var>Desc</var>) is <span class="esvalue">false</span>, then Reject.</li>
<li>Let <var>index</var> be ToUint32(<var>P</var>).</li>
<li>If <var>index</var> ≥ <var>oldLen</var>, then:
<ol>
<li>If <var>A</var> represents a <a class="dfnref" href="#dfn-read-only-array">read only</a> or <a class="dfnref" href="#dfn-fixed-length">fixed length</a>
IDL array, then Reject.</li>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<span class="esvalue">undefined</span> to type <var>T</var>.</li>
<li>Update the IDL array that <var>A</var> represents to have a length of <var>index</var> + 1, and set every
value of the IDL array at indices in the range [<var>oldLen</var>, <var>index</var>) to <var>value</var>.</li>
</ol>
</li>
<li>If <var>A</var> represents a <a class="dfnref" href="#dfn-read-only-array">read only</a> IDL array, then Reject.</li>
<li>Let <var>newValue</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>Desc</var>.<span class="prop">[[Value]]</span> to an IDL value of type <var>T</var>.</li>
<li>Set the <var>index</var>th element of the IDL array that <var>A</var> represents to <var>newValue</var>.</li>
<li>Return <b>true</b>.</li>
</ol>
</li>
<li>Set <var>Desc</var>.<span class="prop">[[Configurable]]</span> to <span class="esvalue">true</span>.</li>
<li>Return the result of calling the default <span class="prop">[[DefineOwnProperty]]</span> internal method (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.12.9) on <var>A</var> passing <var>P</var>, <var>Desc</var>, and <var>Throw</var> as arguments.</li>
</ol>
</div>
<div id="platform-array-object-delete" class="section">
<h5>4.2.20.3. Platform array object [[Delete]] method</h5>
<p>
The internal <span class="prop">[[Delete]]</span> method of every
<a class="dfnref" href="#dfn-platform-array-object">platform array object</a>
<var>A</var> with element type <var>T</var>
<span class="rfc2119">MUST</span> behave as follows when passed
property name <var>P</var> and boolean flag <var>Throw</var>.
The term “Reject” is used as defined in
<a href="#platform-array-object-defineownproperty">section 4.2.20.2</a> above.
</p>
<ol class="algorithm">
<li>If <var>P</var> is “length”, then Reject.</li>
<li>Let <var>length</var> be the length of the IDL array that <var>A</var> represents.</li>
<li>If <var>P</var> is an array index (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.4), then:
<ol>
<li>Let <var>index</var> be ToUint32(<var>P</var>).</li>
<li>If <var>index</var> < <var>length</var>, then Reject.</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</li>
<li>If <var>P</var> has an own property with name <var>P</var>, then remove it.</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</div>
</div>
<div id="es-Date" class="section">
<h4>4.2.21. Date</h4>
<p>
IDL <a class="idltype" href="#idl-Date">Date</a> values are represented by
ECMAScript <span class="estype">Date</span> objects.
</p>
<p>
An ECMAScript value <var>V</var> is
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-Date">Date</a> value
by running the following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>D</var> be the result of calling ToObject(<var>V</var>).</li>
<li>If <var>D</var> is not an ECMAScript <span class="estype">Date</span> object, then throw a <span class="estype">TypeError</span>.</li>
<li>If the time value of <var>D</var> is <span class="esvalue">NaN</span>, then return the <span class="idlvalue">undefined</span> IDL <a class="idltype" href="#idl-Date">Date</a> value.</li>
<li>Return the IDL <a class="idltype" href="#idl-Date">Date</a> value that represents the same time value as <var>D</var>.</li>
</ol>
<p>
An IDL <a class="idltype" href="#idl-Date">Date</a> value <var>V</var> is <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converted</a>
to an ECMAScript value by running the following the algorithm:
</p>
<ol class="algorithm">
<li>If <var>V</var> is the <span class="idlvalue">undefined</span> <a class="idltype" href="#idl-Date">Date</a> value,
then return a newly constructed ECMAScript <span class="estype">Date</span> object whose time value is
<span class="esvalue">NaN</span>.</li>
<li>Otherwise, return a newly constructed ECMAScript <span class="estype">Date</span> object that represents
the same millisecond as <var>V</var>.</li>
</ol>
<p>
<a class="dfnref" href="#dfn-platform-object">Platform objects</a> returning an ECMAScript <span class="estype">Date</span> object from <a class="dfnref" href="#dfn-attribute">attributes</a>,
<a class="dfnref" href="#dfn-operation">operations</a> or <a class="dfnref" href="#dfn-exception-field">exception field</a>
do not hold on to a reference to the <span class="estype">Date</span> object. A script that modifies a <span class="estype">Date</span> object
so retrieved cannot affect the platform object it was retrieved from.
</p>
</div>
</div>
<div id="es-extended-attributes" class="section">
<h3>4.3. ECMAScript-specific extended attributes</h3>
<p>
This section defines a number of
<a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
whose presence affects only the ECMAScript binding.
</p>
<div id="AllowAny" class="section">
<h4>4.3.1. [AllowAny]</h4>
<div class="ednote"><div class="ednoteHeader">Editorial note</div>
<p>We perhaps should drop <span class="xattr">[AllowAny]</span>, and just make the overload resolution algorithm
treat <a class="idltype" href="#idl-DOMString">DOMString</a> like “all remaining types”.</p>
</div>
<p>
If the <a class="xattr" href="#AllowAny">[AllowAny]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-operation">operation argument</a>,
it indicates that any ECMAScript value will be accepted as that
argument’s value. Normally, as part of the <a class="dfnref" href="#dfn-overload-resolution-algorithm">overload resolution algorithm</a>,
a non-<a class="idltype" href="#idl-DOMString">DOMString</a> value will disqualify
a given overloaded operation that is declared to take a
<a class="idltype" href="#idl-DOMString">DOMString</a> for a given argument. When
the <a class="xattr" href="#AllowAny">[AllowAny]</a> extended
attribute is present on the argument, that disqualification is
not performed.
</p>
<p>
The <a class="xattr" href="#AllowAny">[AllowAny]</a> extended attribute
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
See <a href="#idl-overloading">section 3.3.6</a> for the
specific requirements that the use of <a class="xattr" href="#AllowAny">[AllowAny]</a>
entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines two <a class="dfnref" href="#dfn-interface">interfaces</a>,
each with two overloaded <a class="dfnref" href="#dfn-operation">operations</a>.
One uses <a class="xattr" href="#AllowAny">[AllowAny]</a> and one does not.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
void f();
void f(A a);
void f(DOMString s);
};
interface B {
void g();
void g(B b);
void g([AllowAny] DOMString s);
};</code></pre></div></div>
<p>
In an ECMAScript implementation of the above two interfaces,
an <span class="idltype">A</span> object will not allow a
<span class="estype">float</span> value to be passed in as
an argument, while a <span class="idltype">B</span> object
will:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var a = getA(); <span class="comment">// Obtain an instance of A.</span>
var b = getB(); <span class="comment">// Obtain an instance of B.</span>
try {
a.f(1.23); <span class="comment">// Throws a TypeError.</span>
} catch (e) {
}
b.g(1.23); <span class="comment">// Equivalent to b.g("1.23").</span>
b.g(a); <span class="comment">// Equivalent to calling b.g with ToString(a).</span></code></pre></div></div>
</div>
</div>
<div id="ArrayClass" class="section">
<h4>4.3.2. [ArrayClass]</h4>
<p>
If the <a class="xattr" href="#ArrayClass">[ArrayClass]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>
that is not defined to <a class="dfnref" href="#dfn-inherit">inherit</a>
from another, it indicates that the internal <span class="prop">[[Prototype]]</span>
property of its <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
will be the <span class="estype">Array</span> prototype object rather than
the <span class="estype">Object</span> prototype object. This allows
<span class="estype">Array</span> methods to be used more easily
with objects implementing the interface.
</p>
<p>
The <a class="xattr" href="#ArrayClass">[ArrayClass]</a> extended attribute
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
It <span class="rfc2119">MUST NOT</span> be used on an interface that
has any <a class="dfnref" href="#dfn-inherited-interfaces">inherited interfaces</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>
Interfaces using <a class="xattr" href="#ArrayClass">[ArrayClass]</a> will
need to define a “length” <a class="dfnref" href="#dfn-attribute">attribute</a>
of type <span class="estype">unsigned long</span> that exposes the length
of the array-like object, in order for the inherited <span class="estype">Array</span>
methods to operate correctly. Such interfaces would typically also
<a class="dfnref" href="#dfn-support-indexed-properties">support indexed properties</a>,
which would provide access to the array elements.
</p>
</div>
<p>
See <a href="#interface-prototype-object">section 4.5.3</a> for the
specific requirements that the use of <a class="xattr" href="#ArrayClass">[ArrayClass]</a>
entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines two <a class="dfnref" href="#dfn-interface">interfaces</a>
that use <a class="xattr" href="#ArrayClass">[ArrayClass]</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[ArrayClass]
interface ItemList {
attribute unsigned long length;
getter object getItem(unsigned long index);
creator setter object setItem(unsigned long index, object item);
deleter void removeItem(unsigned long index);
};
[ArrayClass]
interface ImmutableItemList {
readonly attribute unsigned long length;
getter object getItem(unsigned long index);
};</code></pre></div></div>
<p>
In an ECMAScript implementation of the above two interfaces,
with appropriate definitions for getItem, setItem and removeItem,
<span class="estype">Array</span> methods to inspect and
modify the array-like object can be used.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var list = getItemList(); <span class="comment">// Obtain an instance of ItemList.</span>
list.concat(); <span class="comment">// Clone the ItemList into an Array.</span>
list.pop(); <span class="comment">// Remove an item from the ItemList.</span>
list.unshift({ }); <span class="comment">// Insert an item at index 0.</span></code></pre></div></div>
<p>
<span class="idltype">ImmutableItemList</span> has a read only
length <a class="dfnref" href="#dfn-attribute">attribute</a>
and no indexed property <a class="dfnref" href="#dfn-indexed-property-setter">setter</a>,
<a class="dfnref" href="#dfn-indexed-property-creator">creator</a> or
<a class="dfnref" href="#dfn-indexed-property-deleter">deleter</a>. The
mutating <span class="estype">Array</span> methods will generally not
succeed on objects implementing <span class="idltype">ImmutableItemList</span>.
The exact behavior depends on the definition of the <span class="estype">Array</span> methods
themselves (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.4.4).
</p>
</div>
</div>
<div id="es-Callback" class="section">
<h4>4.3.3. [Callback]</h4>
<p>
As described in <a href="#Callback">section 3.10.1 above</a>,
the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a> is used to
indicate that an <a class="dfnref" href="#dfn-interface">interface</a>
can be implemented by a <a class="dfnref" href="#dfn-user-object">user object</a>.
In the ECMAScript language binding, the <a class="dfnref" href="#dfn-xattr-identifier">identifier argument</a>
of <a class="xattr" href="#Callback">[Callback]</a>, or the lack of one,
is used to control which kinds of ECMAScript objects can be used as user object implementations of
the interface, as follows:
</p>
<ul>
<li>If the <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a> was specified
as <code>[Callback]</code> (with no identifier argument) or as <code>[Callback=PropertyOnly]</code>,
then any native ECMAScript object is considered to be a <a class="dfnref" href="#dfn-user-object">user object</a>
implementation of the <a class="dfnref" href="#dfn-interface">interface</a>.</li>
<li>Otherwise, if it was specified as <code>[Callback=FunctionOnly]</code>, then only <span class="estype">Function</span>
objects are considered to be user object implementations of the interface.</li>
</ul>
<p>
<code>[Callback=FunctionOnly]</code> <span class="rfc2119">MUST NOT</span> be specified on
an <a class="dfnref" href="#dfn-interface">interface</a> that is not a
<dfn id="dfn-single-operation-interface">single operation interface</dfn>, which is an
interface that:
</p>
<ul>
<li>is not declared to <a class="dfnref" href="#dfn-inherit">inherit</a> from another interface,</li>
<li>has no <a class="dfnref" href="#dfn-consequential-interfaces">consequential interfaces</a>,</li>
<li>has no <a class="dfnref" href="#dfn-attribute">attributes</a>, and</li>
<li>has one or more <a class="dfnref" href="#dfn-regular-operation">regular operations</a>
that all have the same <a class="dfnref" href="#dfn-identifier">identifier</a>,
and no others.</li>
</ul>
<p>
<a href="#es-user-objects">Section 4.8 below</a> details how
native ECMAScript objects are used as <a class="dfnref" href="#dfn-user-object">user objects</a>
implementing an interface and exactly how <a class="xattr" href="#Callback">[Callback]</a>
influences this.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines a simple callback interface and an
interface for an object that expects an object that
implements that callback:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Callback]
interface Listener {
void eventOccurred();
};
interface Thing {
void addListener(Listener listener);
};</code></pre></div></div>
<p>
An ECMAScript implementation of the above two interfaces
allows any native object to be passed to <code>addListener</code>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code"><span class="comment">// Obtain an instance of Thing.</span>
var t = getThing();
<span class="comment">// The function is the implementation of the eventOccurred operation on the</span>
<span class="comment">// Listener interface. If Listener had been declared with</span>
<span class="comment">// [Callback=PropertyOnly] this addListener() call would still succeed, but</span>
<span class="comment">// a TypeError would be thrown when the user agent attempts to invoke the</span>
<span class="comment">// callback.</span>
t.addListener(function() { });
<span class="comment">// This also works, but it is the function with /* 1 */ in it that is the</span>
<span class="comment">// implementation of eventOccurred.</span>
var x = function() { <span class="comment">/* 1 */</span> };
x.eventOccurred = function() { <span class="comment">/* 2 */</span> };
t.addListener(x);
<span class="comment">// This works too, and the value of the eventOccurred property is the</span>
<span class="comment">// implementation of the operation. If Listener had been declared with</span>
<span class="comment">// [Callback=FunctionOnly] however, this would have thrown a TypeError.</span>
t.addListener({ eventOccurred: function() { } });</code></pre></div></div>
</div>
</div>
<div id="Clamp" class="section">
<h4>4.3.4. [Clamp]</h4>
<p>
If the <a class="xattr" href="#Clamp">[Clamp]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-operation">operation</a> argument,
writable <a class="dfnref" href="#dfn-attribute">attribute</a> or
<a class="dfnref" href="#dfn-dictionary-member">dictionary member</a>
whose type is one of the <a class="dfnref" href="#dfn-integer-type">integer types</a>,
it indicates that when an ECMAScript <span class="estype">Number</span> is
converted to the IDL type, out of range values will be clamped to the range
of valid values, rather than using the operators that use a modulo operation
(ToInt16, ToInt32, ToUint32, etc.).
</p>
<p>
The <a class="xattr" href="#Clamp">[Clamp]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
The <a class="xattr" href="#Clamp">[Clamp]</a> extended attribute
<span class="rfc2119">MUST NOT</span> appear on a <a class="dfnref" href="#dfn-read-only">read only</a>
attribute, or an attribute, operation argument or dictionary member
that is not of an integer type. It also <span class="rfc2119">MUST NOT</span>
be used in conjunction with the <a class="xattr" href="#EnforceRange">[EnforceRange]</a>
extended attribute.
</p>
<p>
See the rules for converting ECMAScript values to the various IDL integer
types in <a href="#es-type-mapping">section 4.2</a>
for the specific requirements that the use of
<a class="xattr" href="#Clamp">[Clamp]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
In the following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>,
two <a class="dfnref" href="#dfn-operation">operations</a> are declared that
take three <a class="idltype" href="#idl-octet">octet</a> arguments; one uses
the <a class="xattr" href="#Clamp">[Clamp]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
on all three arguments, while the other does not:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface GraphicsContext {
void setColor(octet red, octet green, octet blue);
void setColorClamped([Clamp] octet red, [Clamp] octet green, [Clamp] octet blue);
};</code></pre></div></div>
<p>
In an ECMAScript implementation of the IDL, a call to setColorClamped with
<span class="estype">Number</span> values that are out of range for an
<a class="idltype" href="#idl-octet">octet</a> are clamped to the range [0, 255].
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">// Get an instance of GraphicsContext.
var context = getGraphicsContext();
// Calling the non-[Clamp] version uses ToUint8 to coerce the Numbers to octets.
// This is equivalent to calling setColor(255, 255, 1).
context.setColor(-1, 255, 257);
// Call setColorClamped with some out of range values.
// This is equivalent to calling setColorClamped(0, 255, 255).
context.setColorClamped(-1, 255, 257);</code></pre></div></div>
</div>
</div>
<div id="Constructor" class="section">
<h4>4.3.5. [Constructor]</h4>
<p>
If the <a class="xattr" href="#Constructor">[Constructor]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>, it indicates that
the <a class="dfnref" href="#dfn-interface-object">interface object</a> for this interface
will have an <span class="prop">[[Construct]]</span> internal method,
allowing objects implementing the interface to be constructed.
Multiple <a class="xattr" href="#Constructor">[Constructor]</a> extended
attributes may appear on a given interface.
</p>
<p>
The <a class="xattr" href="#Constructor">[Constructor]</a>
extended attribute <span class="rfc2119">MUST</span> either
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a> or
<a class="dfnref" href="#dfn-xattr-argument-list">take an argument list</a>.
The bare form, <code>[Constructor]</code>, has the same meaning as
using an empty argument list, <code>[Constructor()]</code>. For each
<a class="xattr" href="#Constructor">[Constructor]</a> extended attribute
on the interface, there will be a way to construct an object that implements
the interface by passing the specified arguments.
</p>
<p>
If the <a class="xattr" href="#Constructor">[Constructor]</a> extended attribute
is specified on an interface, then the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
extended attribute <span class="rfc2119">MUST NOT</span> also be specified on that interface.
</p>
<p>
See <a href="#es-interface-call">section 4.5.1.1</a>
below for details on how a constructor
is to be implemented.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following IDL defines two interfaces. The second has the
<a class="xattr" href="#Constructor">[Constructor]</a> extended
attribute, while the first does not.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface NodeList {
Node item(unsigned long index);
readonly attribute unsigned long length;
};
[Constructor,
Constructor(float radius)]
interface Circle {
attribute float r;
attribute float cx;
attribute float cy;
readonly attribute float circumference;
};</code></pre></div></div>
<p>
An ECMAScript implementation supporting these interfaces would
have a <span class="prop">[[Construct]]</span> property on the
<span class="idltype">Circle</span> interface object which would
return a new object that implements the interface. It would take
either zero or one argument. The
<span class="idltype">NodeList</span> interface object would not
have a <span class="prop">[[Construct]]</span> property.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var x = new Circle(); <span class="comment">// The uses the zero-argument constructor to create a</span>
<span class="comment">// reference to a platform object that implements the</span>
<span class="comment">// Circle interface.</span>
var y = new Circle(1.25); <span class="comment">// This also creates a Circle object, this time using</span>
<span class="comment">// the one-argument constructor.</span>
var z = new NodeList(); <span class="comment">// This would throw a TypeError, since no</span>
<span class="comment">// [Constructor] is declared.</span></code></pre></div></div>
</div>
</div>
<div id="EnforceRange" class="section">
<h4>4.3.6. [EnforceRange]</h4>
<p>
If the <a class="xattr" href="#EnforceRange">[EnforceRange]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-operation">operation</a> argument,
writable <a class="dfnref" href="#dfn-attribute">attribute</a> or
<a class="dfnref" href="#dfn-dictionary-member">dictionary member</a>
whose type is one of the <a class="dfnref" href="#dfn-integer-type">integer types</a>,
it indicates that when an ECMAScript <span class="estype">Number</span> is
converted to the IDL type, out of range values will cause an exception to
be thrown, rather than converted to being a valid value using the operators that use a modulo operation
(ToInt16, ToInt32, ToUint32, etc.). The <span class="estype">Number</span>
will be rounded towards zero before being checked against its range.
</p>
<p>
The <a class="xattr" href="#EnforceRange">[EnforceRange]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
The <a class="xattr" href="#EnforceRange">[EnforceRange]</a> extended attribute
<span class="rfc2119">MUST NOT</span> appear on a <a class="dfnref" href="#dfn-read-only">read only</a>
attribute, or an attribute, operation argument or dictionary member
that is not of an integer type. It also <span class="rfc2119">MUST NOT</span>
be used in conjunction with the <a class="xattr" href="#Clamp">[Clamp]</a>
extended attribute.
</p>
<p>
See the rules for converting ECMAScript values to the various IDL integer
types in <a href="#es-type-mapping">section 4.2</a>
for the specific requirements that the use of
<a class="xattr" href="#EnforceRange">[EnforceRange]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
In the following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>,
two <a class="dfnref" href="#dfn-operation">operations</a> are declared that
take three <a class="idltype" href="#idl-octet">octet</a> arguments; one uses
the <a class="xattr" href="#EnforceRange">[EnforceRange]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
on all three arguments, while the other does not:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface GraphicsContext {
void setColor(octet red, octet green, octet blue);
void setColorEnforcedRange([EnforceRange] octet red, [EnforceRange] octet green, [EnforceRange] octet blue);
};</code></pre></div></div>
<p>
In an ECMAScript implementation of the IDL, a call to setColorEnforcedRange with
<span class="estype">Number</span> values that are out of range for an
<a class="idltype" href="#idl-octet">octet</a> will result in an exception being
thrown.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">// Get an instance of GraphicsContext.
var context = getGraphicsContext();
// Calling the non-[EnforceRange] version uses ToUint8 to coerce the Numbers to octets.
// This is equivalent to calling setColor(255, 255, 1).
context.setColor(-1, 255, 257);
// When setColorEnforcedRange is called, Numbers are rounded towards zero.
// This is equivalent to calling setColor(0, 255, 255).
context.setColorEnforcedRange(-0.9, 255, 255.2);
// The following will cause a TypeError to be thrown, since even after
// rounding the first and third argument values are out of range.
context.setColorEnforcedRange(-1, 255, 256);</code></pre></div></div>
</div>
</div>
<div id="ImplicitThis" class="section">
<h4>4.3.7. [ImplicitThis]</h4>
<p>
If the <a class="xattr" href="#ImplicitThis">[ImplicitThis]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>,
it indicates that when a <span class="estype">Function</span> corresponding
to one of the interface’s <a class="dfnref" href="#dfn-operation">operations</a>
is invoked with the <span class="esvalue">null</span> or <span class="esvalue">undefined</span>
value as the <span class="esvalue">this</span> value, that the ECMAScript global
object will be used as the <span class="esvalue">this</span> value instead.
This is regardless of whether the calling code is in strict mode.
</p>
<p>
The <a class="xattr" href="#ImplicitThis">[ImplicitThis]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
See <a href="#es-operations">section 4.5.6</a>
for the specific requirements that the use of
<a class="xattr" href="#ImplicitThis">[ImplicitThis]</a> entails.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>The <a class="xattr" href="#ImplicitThis">[ImplicitThis]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
is intended for use on the <span class="idltype">Window</span>
<a class="dfnref" href="#dfn-interface">interface</a> as defined
in HTML5 (<a href="#ref-HTML5">[HTML5]</a>, section 5.2).</p>
</div>
<div class="example"><div class="exampleHeader">Example</div>
<p>In the following example, the <span class="idltype">Window</span>
<a class="dfnref" href="#dfn-interface">interface</a> is defined
with the <a class="xattr" href="#ImplicitThis">[ImplicitThis]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[ImplicitThis]
interface Window {
...
attribute DOMString name;
void alert(DOMString message);
};</code></pre></div></div>
<p>Since the <span class="idltype">Window</span> object is used as
the ECMAScript global object, calls to its functions can be made
without an explicit object, even in strict mode:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">"use strict";
window.alert("hello"); <span class="comment">// Calling alert with an explicit window object works.</span>
alert("hello"); <span class="comment">// This also works, even though we are in strict mode.</span>
alert.call(null, "hello"); <span class="comment">// As does passing null explicitly as the this value.</span>
<span class="comment">// This does not apply to getters for attributes on the interface, though.</span>
<span class="comment">// The following will throw a TypeError.</span>
Object.getOwnPropertyDescriptor(Window.prototype, "name").get.call(null);</code></pre></div></div>
</div>
</div>
<div id="NamedConstructor" class="section">
<h4>4.3.8. [NamedConstructor]</h4>
<p>
If the <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>,
it indicates that the <a class="dfnref" href="#dfn-relevant-namespace-object">relevant namespace object</a>
for the interface (often, the ECMAScript global object) will have a property with the
specified name whose value is a constructor function that can
create objects that implement the interface.
Multiple <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a> extended
attributes may appear on a given interface.
</p>
<p>
The <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
extended attribute <span class="rfc2119">MUST</span> either
<a class="dfnref" href="#dfn-xattr-identifier">take an identifier</a> or
<a class="dfnref" href="#dfn-xattr-named-argument-list">take a named argument list</a>.
The first form, <code>[NamedConstructor=<a class="sym" href="#prod-identifier">identifier</a>]</code>, has the same meaning as
using an empty argument list, <code>[NamedConstructor=<a class="sym" href="#prod-identifier">identifier</a>()]</code>. For each
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a> extended attribute
on the interface, there will be a way to construct an object that implements
the interface by passing the specified arguments to the constructor function
that is the value of the aforementioned property.
</p>
<p>
The identifier used for the named constructor <span class="rfc2119">MUST NOT</span>
be the same as that used by an <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
extended attribute on another interface, <span class="rfc2119">MUST NOT</span>
be the same as an identifier of an interface (or <a class="dfnref" href="#dfn-exception">exception</a>)
that has an <a class="dfnref" href="#dfn-interface-object">interface object</a>
(or <a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>),
and <span class="rfc2119">MUST NOT</span> be one of the
<a class="dfnref" href="#dfn-reserved-identifier">reserved identifiers</a>.
</p>
<p>
See <a href="#named-constructors">section 4.5.2</a>
below for details on how named constructors
are to be implemented.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following IDL defines an interface that uses the
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a> extended
attribute.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[NamedConstructor=Audio,
NamedConstructor=Audio(DOMString src)]
interface HTMLAudioElement : HTMLMediaElement {
<span class="comment">// ...</span>
};</code></pre></div></div>
<p>
An ECMAScript implementation that supports this interface will
allow the construction of <span class="estype">HTMLAudioElement</span>
objects using the <span class="estype">Audio</span> constructor.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">typeof Audio; <span class="comment">// Evaluates to 'function'.</span>
var a1 = new Audio(); <span class="comment">// Creates a new object that implements</span>
<span class="comment">// HTMLAudioElement, using the zero-argument</span>
<span class="comment">// constructor.</span>
var a2 = new Audio('a.flac'); <span class="comment">// Creates an HTMLAudioElement using the</span>
<span class="comment">// one-argument constructor.</span></code></pre></div></div>
</div>
</div>
<div id="NamespaceObject" class="section">
<h4>4.3.9. [NamespaceObject]</h4>
<p>
If the <a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on a <a class="dfnref" href="#dfn-module">module</a>,
it indicates that the hierarchy of that module and its descendant
modules will be reflected as <a class="dfnref" href="#dfn-namespace-object">namespace objects</a>.
<a class="dfnref" href="#dfn-interface-object">Interface objects</a> and
<a class="dfnref" href="#dfn-exception-interface-object">exception interface objects</a>
for <a class="dfnref" href="#dfn-interface">interfaces</a> and
<a class="dfnref" href="#dfn-exception">exceptions</a> defined in
a module annotated with <a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
(or in a descendant of such a module) will be placed on
a namespace object instead of the ECMAScript global object.
</p>
<p>
The <a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
The <a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
extended attribute <span class="rfc2119">MUST NOT</span> be
specified on a module if is specified on one of its ancestor modules.
</p>
<p>
See <a href="#es-modules">section 4.4</a>
for the specific requirements that the use of
<a class="xattr" href="#NamespaceObject">[NamespaceObject]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines a <a class="dfnref" href="#dfn-module">module</a> hierarchy
where one of the modules is declared with the
<a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[NamespaceObject]
module acme {
exception DeviceException { };
module pim {
[Constructor]
interface Contact { };
[Constructor,
NamedConstructor=RecurringEvent(long freq)]
interface CalendarEvent { };
};
};</code></pre></div></div>
<p>
In an ECMAScript implementation, there would exist
<a class="dfnref" href="#dfn-namespace-object">namespace objects</a>
for the <span class="idltype">acme</span> and <span class="idltype">pim</span>
<a class="dfnref" href="#dfn-module">modules</a>. The property
for the <span class="idltype">Device</span>
<a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>
would be on the <span class="idltype">acme</span> namespace object
and the properties for the <span class="idltype">Contact</span>
and <span class="idltype">CalendarEvent</span>
<a class="dfnref" href="#dfn-interface-object">interface objects</a>
would be on the <span class="idltype">pim</span> namespace object.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">acme; <span class="comment">// A namespace object.</span>
acme.pim; <span class="comment">// Another namespace object.</span>
acme.DeviceException; <span class="comment">// An exception interface object.</span>
acme.pim.Contact; <span class="comment">// An interface object.</span>
new acme.pim.Contact(); <span class="comment">// Creates an object implementing acme::pim::Contact.</span>
new acme.pim.RecurringEvent(10); <span class="comment">// Creates an object implementing acme::pim::CalendarEvent.</span></code></pre></div></div>
</div>
</div>
<div id="NoInterfaceObject" class="section">
<h4>4.3.10. [NoInterfaceObject]</h4>
<p>
If the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>,
it indicates that an
<a class="dfnref" href="#dfn-interface-object">interface object</a>
will not exist for the interface in the ECMAScript binding. Similarly,
if it appears on an <a class="dfnref" href="#dfn-exception">exception</a>
it indicates that an
<a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>
will not exist for the exception in the ECMAScript binding.
</p>
<p>
The <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a> extended attribute
<span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
If the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a> extended attribute
is specified on an interface, then the <a class="xattr" href="#Constructor">[Constructor]</a>
extended attribute <span class="rfc2119">MUST NOT</span> also be specified on that interface.
A <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a> extended attribute is fine,
however.
</p>
<p>
The <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a> extended attribute
<span class="rfc2119">MUST NOT</span> be specified on an interface that has any
<a class="dfnref" href="#dfn-static-operation">static operations</a> defined on it.
</p>
<p>
The <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a> extended attribute
<span class="rfc2119">SHOULD NOT</span> be used on interfaces that are not
solely used as <a class="dfnref" href="#dfn-supplemental-interface">supplemental</a> or
<a href="#Callback">callback</a> interfaces,
unless there are clear Web compatibility reasons for doing so.
</p>
<p>
See <a href="#es-interfaces">section 4.2.16</a>
and <a href="#es-exceptions">section 4.9</a>
for the specific requirements that the use of
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL
fragment</a> defines two interfaces, one whose interface object
is exposed on the ECMAScript global object, and one whose isn’t:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Storage {
void addEntry(unsigned long key, any value);
};
[NoInterfaceObject]
interface Query {
any lookupEntry(unsigned long key);
};</code></pre></div></div>
<p>
An ECMAScript implementation of the above IDL would allow
manipulation of <span class="idltype">Storage</span>’s
prototype, but not <span class="idltype">Query</span>’s.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">typeof Storage; <span class="comment">// evaluates to "object"</span>
<span class="comment">// Add some tracing alert() call to Storage.addEntry.</span>
var fn = Storage.prototype.addEntry;
Storage.prototype.addEntry = function(key, value) {
alert('Calling addEntry()');
return fn.call(this, key, value);
};
typeof Query; <span class="comment">// evaluates to "undefined"</span>
var fn = Query.prototype.lookupEntry; <span class="comment">// exception, Query isn’t defined</span>
</code></pre></div></div>
</div>
</div>
<div id="OverrideBuiltins" class="section">
<h4>4.3.11. [OverrideBuiltins]</h4>
<p>
If the <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>,
it indicates that for a <a class="dfnref" href="#dfn-platform-object">platform object</a> implementing the interface,
properties corresponding to all of
the object’s <a class="dfnref" href="#dfn-supported-property-names">supported property names</a>
will appear to be on the object,
regardless of what other properties exist on the object or its
prototype chain. This means that named properties will always shadow
any properties that would otherwise appear on the object.
This is in contrast to the usual behavior, which is for named properties
to be exposed only if there is no property with the
same name on the object itself or somewhere on its prototype chain.
</p>
<p>
The <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>
and <span class="rfc2119">MUST NOT</span> appear on an interface
that does not define a <a class="dfnref" href="#dfn-named-property-getter">named property getter</a>
or that also is declared with the <a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a>
extended attribute.
</p>
<p>
See <a href="#indexed-and-named-properties">section 4.7.1</a>
and <a href="#defineownproperty">section 4.7.3</a>
for the specific requirements that the use of
<a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines two <a class="dfnref" href="#dfn-interface">interfaces</a>,
one that has a <a class="dfnref" href="#dfn-named-property-getter">named property getter</a>
and one that does not.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface StringMap {
readonly attribute unsigned long length;
getter DOMString lookup(DOMString key);
};
[OverrideBuiltins]
interface StringMap2 {
readonly attribute unsigned long length;
getter DOMString lookup(DOMString key);
};</code></pre></div></div>
<p>
In an ECMAScript implementation of these two interfaces,
getting certain properties on objects implementing
the interfaces will result in different values:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code"><span class="comment">// Obtain an instance of StringMap. Assume that it has "abc", "length" and</span>
<span class="comment">// "toString" as supported property names.</span>
var map1 = getStringMap();
<span class="comment">// This invokes the named property getter.</span>
map1.abc;
<span class="comment">// This fetches the "length" property on the object that corresponds to the</span>
<span class="comment">// length attribute.</span>
map1.length;
<span class="comment">// This fetches the "toString" property from the object's prototype chain.</span>
map1.toString;
<span class="comment">// Obtain an instance of StringMap2. Assume that it also has "abc", "length"</span>
<span class="comment">// and "toString" as supported property names.</span>
var map2 = getStringMap2();
<span class="comment">// This invokes the named property getter.</span>
map2.abc;
<span class="comment">// This also invokes the named property getter, despite the fact that the "length"</span>
<span class="comment">// property on the object corresponds to the length attribute.</span>
map2.length;
<span class="comment">// This too invokes the named property getter, despite the fact that "toString" is</span>
<span class="comment">// a property in map2's prototype chain.</span>
map2.toString;</code></pre></div></div>
</div>
</div>
<!--
<div id='PrototypeRoot' class='section'>
<h4>[PrototypeRoot]</h4>
<div class='ednote'>
<p>Ian suggests that <span class='xattr'>[PrototypeRoot]</span> might not need to exist.
<a href='http://www.w3.org/mid/Pine.LNX.4.62.0906200730520.16244@hixie.dreamhostps.com'>(Mail.)</a></p>
</div>
<p>
If the <a class='xattr' href='#PrototypeRoot'>[PrototypeRoot]</a>
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>
appears on an <a class='dfnref' href='#dfn-interface'>interface</a>
<var>A</var>, it indicates that it serves as the root of a prototype
ancestor hierarchy. For any interface <var>B</var> that has
<var>A</var> as an ancestor, each interface in the inheritance
tree starting with an interface that <var>B</var> inherits from and
ending with <var>A</var> will be a
<a class='dfnref' href='#dfn-prototype-ancestor'>prototype ancestor</a>
of <var>B</var>. It also plays a role in determining the value
of a host object’s internal <span class='prop'>[[Prototype]]</span>
property value when the object implements more than one interface.
See <a href='#interface-prototype-object'>section <?sref interface-prototype-object?></a>
and <a href='#host-objects'>section <?sref host-objects?></a> for details.
</p>
<p>
The <a class='xattr' href='#PrototypeRoot'>[PrototypeRoot]</a>
extended attribute <span class='rfc2119'>MUST</span> <a class='dfnref' href='#dfn-xattr-no-arguments'>take no arguments</a>,
and <span class='rfc2119'>MUST NOT</span> appear on an
<a class='dfnref' href='#dfn-interface'>interface</a> that
<a class='dfnref' href='#dfn-inherit'>inherits</a> from another
interface. An interface inheritance hierarchy
<span class='rfc2119'>MUST NOT</span> have multiple paths from
one interface to another that has the
<a class='xattr' href='#PrototypeRoot'>[PrototypeRoot]</a>
extended attribute.
</p>
<div class='example'>
<p>
The following <a class='dfnref' href='#dfn-idl-fragment'>IDL fragment</a>
defines a hierarchy of <a class='dfnref' href='#dfn-interface'>interfaces</a>
whose rootmost interface is annotated with the
<a class='xattr' href='#PrototypeRoot'>[PrototypeRoot]</a>
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>.
Other interfaces are defined to be implemented on objects that
implement this prototype root interface, but properties for
these other interfaces will be made available in the prototype
chain through a <a class='dfnref' href='#dfn-mixin-prototype-object'>mixin prototype object</a>.
</p>
<x:codeblock language='idl'>[PrototypeRoot]
interface Node {
readonly attribute unsigned short nodeType;
};
interface Element : Node {
void appendChild(Node n);
<span class='comment'>// ...</span>
};
interface HTMLElement : Element {
void focus();
<span class='comment'>// ...</span>
};
interface EventTarget {
void addEventListener(/* ... */);
<span class='comment'>// ...</span>
};
Node implements EventTarget;</x:codeblock>
<p>
An ECMAScript implementation implementing these interfaces would
have a prototype chain as follows, where <var>E</var> is an
instance of <span class='idltype'>HTMLElement</span>:
</p>
<div class='diagram'>
<object data='PrototypeRoot-example.svg' type='image/svg+xml' style='width: 37em; height: 45em' width='1' height='1'>
<img src='PrototypeRoot-example.png' width='500' height='608' alt='The prototype of E is the mixin prototype object for E. This mixin prototype object has an "addEventListener" property. The prototype of the mixin prototype object is the HTMLElement prototype object, whose prototype is the Element prototype object, whose prototype is the Node prototype object, whose prototype is the Object prototype object.'/>
</object>
</div>
</div>
</div>
-->
<div id="PutForwards" class="section">
<h4>4.3.12. [PutForwards]</h4>
<p>
If the <a class="xattr" href="#PutForwards">[PutForwards]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on a <a class="dfnref" href="#dfn-read-only">read only</a>
<a class="dfnref" href="#dfn-attribute">attribute</a> declaration whose type is
an <a href="#idl-interface">interface type</a>,
it indicates that assigning to the attribute will have specific behavior.
Namely, the assignment is “forwarded” to the attribute (specified by
the extended attribute argument) on the object that is currently
referenced by the attribute being assigned to.
</p>
<p>
The <a class="xattr" href="#PutForwards">[PutForwards]</a> extended
attribute <span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-identifier">take an identifier</a>.
Assuming that:
</p>
<ul>
<li>
<var>A</var> is the <a class="dfnref" href="#dfn-attribute">attribute</a>
on which the <a class="xattr" href="#PutForwards">[PutForwards]</a>
extended attribute appears,
</li>
<li>
<var>I</var> is the <a class="dfnref" href="#dfn-interface">interface</a>
on which <var>A</var> is declared,
</li>
<li>
<var>J</var> is the <a href="#idl-interface">interface type</a>
that <var>A</var> is declared to be of, and
</li>
<li>
<var>N</var> is the <a class="dfnref" href="#dfn-identifier">identifier</a>
argument of the extended attribute,
</li>
</ul>
<p>
then there <span class="rfc2119">MUST</span> be another
<a class="dfnref" href="#dfn-attribute">attribute</a> <var>B</var>
declared on <var>J</var> whose <a class="dfnref" href="#dfn-identifier">identifier</a>
is <var>N</var>. Assignment of a value to the attribute <var>A</var>
on an object implementing <var>I</var> will result in that value
being assigned to attribute <var>B</var> of the object that <var>A</var>
references, instead.
</p>
<p>
Note that <a class="xattr" href="#PutForwards">[PutForwards]</a>-annotated
<a class="dfnref" href="#dfn-attribute">attributes</a> can be
chained. That is, an attribute with the <a class="xattr" href="#PutForwards">[PutForwards]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
can refer to an attribute that itself has that extended attribute.
There <span class="rfc2119">MUST NOT</span> exist a cycle in a
chain of forwarded assignments. A cycle exists if, when following
the chain of forwarded assignments, a particular attribute on
an <a class="dfnref" href="#dfn-interface">interface</a> is
encountered more than once.
</p>
<p>
An attribute with the <a class="xattr" href="#PutForwards">[PutForwards]</a>
extended attribute <span class="rfc2119">MUST NOT</span> also be declared
with the <a class="xattr" href="#Replaceable">[Replaceable]</a>
extended attribute.
</p>
<p>
See the <a href="#es-attributes">Attributes</a> section below for how
<a class="xattr" href="#PutForwards">[PutForwards]</a>
is to be implemented.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines interfaces for names and people.
The <a class="xattr" href="#PutForwards">[PutForwards]</a> extended
attribute is used on the <span class="idlattr">name</span> attribute
of the <span class="idltype">Person</span> interface to indicate
that assignments to that attribute result in assignments to the
<span class="idlattr">full</span> attribute of the
<span class="idltype">Person</span> object:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Name {
attribute DOMString full;
attribute DOMString family;
attribute DOMString given;
};
interface Person {
[PutForwards=full] readonly attribute Name name;
attribute unsigned short age;
};</code></pre></div></div>
<p>
In the ECMAScript binding, this would allow assignments to the
“name” property:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var p = getPerson(); <span class="comment">// Obtain an instance of Person.</span>
p.name = 'John Citizen'; <span class="comment">// This statement...</span>
p.name.full = 'John Citizen'; <span class="comment">// ...has the same behavior as this one.</span></code></pre></div></div>
</div>
</div>
<div id="Replaceable" class="section">
<h4>4.3.13. [Replaceable]</h4>
<p>
If the <a class="xattr" href="#Replaceable">[Replaceable]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on a <a class="dfnref" href="#dfn-read-only">read only</a>
<a class="dfnref" href="#dfn-attribute">attribute</a>,
it indicates that setting the corresponding property on the
<a class="dfnref" href="#dfn-platform-object">platform object</a> will result in
an own property with the same name being created on the object
which has the value being assigned. This property will shadow
the accessor property corresponding to the attribute, which
exists on the <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>.
</p>
<p>
The <a class="xattr" href="#Replaceable">[Replaceable]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
An attribute with the <a class="xattr" href="#Replaceable">[Replaceable]</a>
extended attribute <span class="rfc2119">MUST NOT</span> also be declared
with the <a class="xattr" href="#PutForwards">[PutForwards]</a>
extended attribute.
</p>
<p>
See <a href="#es-attributes">section 4.5.5</a>
for the specific requirements that the use of
<a class="xattr" href="#Replaceable">[Replaceable]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines an <a class="dfnref" href="#dfn-interface">interface</a>
with an <a class="dfnref" href="#dfn-operation">operation</a>
that increments a counter, and an <a class="dfnref" href="#dfn-attribute">attribute</a>
that exposes the counter’s value, which is initially 0:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Counter {
[Replaceable] readonly attribute unsigned long value;
void increment();
};</code></pre></div></div>
<p>
Assigning to the “value” property
on a <a class="dfnref" href="#dfn-platform-object">platform object</a> implementing <span class="idltype">Counter</span>
will shadow the property that corresponds to the
<a class="dfnref" href="#dfn-attribute">attribute</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var counter = getCounter(); <span class="comment">// Obtain an instance of Counter.</span>
counter.value; <span class="comment">// Evaluates to 0.</span>
counter.hasOwnProperty("value"); <span class="comment">// Evaluates to false.</span>
Object.getPrototypeOf(counter).hasOwnProperty("value"); <span class="comment">// Evaluates to true.</span>
counter.increment();
counter.increment();
counter.value; <span class="comment">// Evaluates to 2.</span>
counter.value = 'a'; <span class="comment">// Shadows the property with one that is unrelated</span>
<span class="comment">// to Counter::value.</span>
counter.hasOwnProperty("value"); <span class="comment">// Evaluates to true.</span>
counter.increment();
counter.value; <span class="comment">// Evaluates to 'a'.</span>
delete counter.value; <span class="comment">// Reveals the original property.</span>
counter.value; <span class="comment">// Evaluates to 3.</span></code></pre></div></div>
</div>
</div>
<div id="ReplaceableNamedProperties" class="section">
<h4>4.3.14. [ReplaceableNamedProperties]</h4>
<p>
If the <a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-interface">interface</a>,
then for objects that
<a class="dfnref" href="#dfn-support-named-properties">support named properties</a>
but which do not have a <a class="dfnref" href="#dfn-named-property-setter">named property setter</a>,
attempting to set a property that corresponds to a named property will result in an
own property being defined on the object, rather than in the assignment failing,
which is the normal behavior.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>The assignment will normally fail because the <a href="#getownproperty">platform object
[[GetOwnProperty]] internal method</a> will expose named properties as
non-writable data properties.</p>
</div>
<p>
The <a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
The <a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a> extended attribute
<span class="rfc2119">MUST NOT</span> be declared on an <a class="dfnref" href="#dfn-interface">interface</a>
that does not define a <a class="dfnref" href="#dfn-named-property-getter">named property getter</a>,
that does define a <a class="dfnref" href="#dfn-named-property-setter">named property setter</a> or
that also is declared with the <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>
extended attribute.
</p>
<p>
See <a href="#getownproperty">section 4.7.2</a>
and <a href="#defineownproperty">section 4.7.3</a>
for the specific requirements that the use of
<a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
This <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a> is intended
to be used by the <span class="idltype">Window</span> interface as defined in
HTML5 (<a href="#ref-HTML5">[HTML5]</a>, section 5.2). The interface exposes frames as properties on the <span class="idltype">Window</span>
object. Since the <span class="idltype">Window</span> object also serves as the
ECMAScript global object, variable declarations or assignments to the named properties
will result in them being replaced by the new value.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[ReplaceableNamedProperties]
interface Window {
getter any (DOMString name);
// ...
};</code></pre></div></div>
<p>
The following HTML document illustrates how the named properties on the
<span class="idltype">Window</span> object can be replaced:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">HTML</span></div><div class="blockContent"><pre class="code"><code class="html-code"><!DOCTYPE html>
<title>Replaceable named properties on Window</title>
<iframe name=abc></iframe>
<script>
window.abc; <span class="comment">// Evaluates to the iframe's Window object.</span>
abc = 1; <span class="comment">// Replaces the named property.</span>
window.abc; <span class="comment">// Evaluates to 1.</span>
</script></code></pre></div></div>
</div>
</div>
<div id="TreatNonCallableAsNull" class="section">
<h4>4.3.15. [TreatNonCallableAsNull]</h4>
<p>
If the <a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-attribute">attribute</a>
or <a class="dfnref" href="#dfn-operation">operation</a> argument whose type is
a <a class="dfnref" href="#dfn-nullable-type">nullable</a>
<a class="xattr" href="#Callback">[Callback]</a>-annotated
<a href="#idl-interface">interface type</a>, it indicates that any value
assigned to the attribute or passed as the operation argument
that is not a callable object will be converted to
the <span class="idlvalue">null</span> value.
</p>
<p>
The <a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>
extended attribute <span class="rfc2119">MUST NOT</span> be specified
on an attribute or operation argument whose type is not an
interface that is annotated with <code>[Callback]</code> or
<code>[Callback=FunctionOnly]</code>.
</p>
<p>
Specifications <span class="rfc2119">SHOULD NOT</span> use <a href="#TreatNonCallableAsNull" class="xattr">[TreatNonCallableAsNull]</a>
unless required to specify the behavior of legacy APIs.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>The <a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
is intended for use on <a href="http://www.w3.org/TR/2011/WD-html5-20110525/webappapis.html#event-handler-attributes">event handler IDL attributes</a>
defined in HTML5 (<a href="#ref-HTML5">[HTML5]</a>, section 6.1.6.1).</p>
</div>
<p>
See <a href="#es-nullable-type">section 4.2.18</a>
for the specific requirements that the use of
<a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines an interface that has one
attribute with the <a class="xattr" href="#TreatNonCallableAsNull">[TreatNonCallableAsNull]</a>
extended attribute and one without:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Callback=FunctionOnly]
interface EventHandler {
void eventOccurred(DOMString details);
};
interface Manager {
attribute EventHandler? handler1;
[TreatNonCallableAsNull] attribute EventHandler? handler2;
};</code></pre></div></div>
<p>
In an ECMAScript implementation, assigning a value that is not
callable (such as a <span class="estype">Number</span> value)
to handler1 will have different behavior from that when assigning
to handler2:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var manager = getManager(); <span class="comment">// Get an instance of Manager.</span>
manager.handler1 = function() { };
manager.handler1; <span class="comment">// Evaluates to the function.</span>
try {
manager.handler1 = 123; <span class="comment">// Throws a TypeError.</span>
} catch (e) {
}
manager.handler2 = function() { };
manager.handler2; <span class="comment">// Evaluates to the function.</span>
manager.handler2 = 123;
manager.handler2; <span class="comment">// Evaluates to null.</span></code></pre></div></div>
</div>
</div>
<div id="TreatNullAs" class="section">
<h4>4.3.16. [TreatNullAs]</h4>
<p>
If the <a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-attribute">attribute</a>
or <a class="dfnref" href="#dfn-operation">operation</a> argument whose type is
<a class="idltype" href="#idl-DOMString">DOMString</a>,
it indicates that a <span class="esvalue">null</span> value
assigned to the attribute or passed as the operation argument will be
handled differently from its default handling. Instead of being stringified
to “null”, which is the default,
it will be converted to the empty string “”.
</p>
<p>
If <a class="xattr" href="#TreatNullAs">[TreatNullAs]</a> is specified on
an operation itself, then it indicates that a <a href="#es-user-objects">user object
implementing the interface</a> will have the return
value of the function that implements the operation
handled in the same way as for operation arguments
and attributes, as above.
</p>
<p>
The <a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>
extended attribute <span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-identifier">take the identifier</a>
<code>EmptyString</code>.
</p>
<p>
The <a class="xattr" href="#TreatNullAs">[TreatNullAs]</a> extended attribute
<span class="rfc2119">MUST NOT</span> be specified on an operation argument,
attribute or operation return value whose type is not <a class="idltype" href="#idl-DOMString">DOMString</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>This means that even an attribute of type <span class="idltype">DOMString?</span> must not
use <a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>, since <span class="idlvalue">null</span>
is a valid value of that type.</p>
</div>
<p>
See <a href="#es-DOMString">section 4.2.14</a>
for the specific requirements that the use of
<a class="xattr" href="#TreatNullAs">[TreatNullAs]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines an interface that has one
attribute with the <a class="xattr" href="#TreatNullAs">[TreatNullAs]</a>
extended attribute, and one operation with an argument that has
the extended attribute:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Dog {
attribute DOMString name;
[TreatNullAs=EmptyString] attribute DOMString owner;
boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName);
};</code></pre></div></div>
<p>
An ECMAScript implementation implementing the <span class="idltype">Dog</span>
interface would convert a <span class="esvalue">null</span> value
assigned to the “name” property or passed as the
argument to the <code>isMemberOfBreed</code> function
to the empty string rather than <code>"null"</code>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var d = getDog(); <span class="comment">// Assume d is a platform object implementing the Dog</span>
<span class="comment">// interface.</span>
d.name = null; <span class="comment">// This assigns the string "null" to the .name</span>
<span class="comment">// property.</span>
d.owner = null; <span class="comment">// This assigns the string "" to the .owner property.</span>
d.isMemberOfBreed(null); <span class="comment">// This passes the string "" to the isMemberOfBreed</span>
<span class="comment">// function.</span></code></pre></div></div>
</div>
</div>
<div id="TreatUndefinedAs" class="section">
<h4>4.3.17. [TreatUndefinedAs]</h4>
<p>
If the <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on an <a class="dfnref" href="#dfn-attribute">attribute</a>
or <a class="dfnref" href="#dfn-operation">operation</a> argument whose type is
<a class="idltype" href="#idl-DOMString">DOMString</a> or <span class="idltype">DOMString?</span>,
it indicates that an <span class="esvalue">undefined</span> value
assigned to the corresponding property or passed as an argument to
the corresponding function will be handled differently from its
default handling, which is to stringify to
“undefined”:
</p>
<ul>
<li>
If the argument to <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
is <code>EmptyString</code>, then the value assigned to the
attribute or passed as the operation argument will be the empty string,
“”.
</li>
<li>
Otherwise, if the argument to <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
is <code>Null</code>, then the value assigned to the
attribute or passed as the operation argument will be the
<span class="idlvalue">null</span> value.
</li>
</ul>
<p>
If <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a> is specified on
an operation itself, then it indicates that a <a href="#es-user-objects">user object
implementing the interface</a> will have the return
value of the function that implements the operation
handled in the same way as for operation arguments
and attributes, as above.
</p>
<p>
The <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
extended attribute <span class="rfc2119">MUST</span> <a class="dfnref" href="#dfn-xattr-identifier">take an identifier</a>:
either <code>EmptyString</code> or <code>Null</code>.
</p>
<p>
<a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs=Null]</a>
<span class="rfc2119">MUST NOT</span> be specified on operation argument,
attribute or operation return value whose type is not <span class="idltype">DOMString?</span>,
and <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs=EmptyString]</a>
<span class="rfc2119">MUST NOT</span> be specified on operation argument,
attribute or operation return value whose type is neither
<a class="idltype" href="#idl-DOMString">DOMString</a> nor <span class="idltype">DOMString?</span>.
</p>
<p>
See <a href="#es-DOMString">section 4.2.14</a>
and <a href="#es-nullable-type">section 4.2.18</a>
for the specific requirements that the use of
<a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines an interface that has one
attribute with the <a class="xattr" href="#TreatUndefinedAs">[TreatUndefinedAs]</a>
extended attribute, and one operation with an argument that has
the extended attribute:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Cat {
attribute DOMString name;
[TreatUndefinedAs=Null] attribute DOMString? owner;
boolean isMemberOfBreed([TreatUndefinedAs=EmptyString] DOMString breedName);
};</code></pre></div></div>
<p>
An ECMAScript implementation implementing the <span class="idltype">Cat</span>
interface would convert an <span class="esvalue">undefined</span> value
assigned to the “name” and “owner”
properties and passed as the argument to the <code>isMemberOfBreed</code> function
all differently; the value would be converted to the string
“undefined”, the <span class="idlvalue">null</span>
value, and the empty string “”, respectively:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var c = getCat(); <span class="comment">// Obtain an instance of Cat.</span>
c.name = undefined; <span class="comment">// This assigns the string "undefined" to the</span>
<span class="comment">// .name property.</span>
c.owner = undefined; <span class="comment">// This assigns the null value to the</span>
<span class="comment">// .owner property.</span>
c.isMemberOfBreed(undefined); <span class="comment">// This passes the string "" to the</span>
<span class="comment">// isMemberOfBreed function.</span></code></pre></div></div>
</div>
</div>
<div id="Unforgeable" class="section">
<h4>4.3.18. [Unforgeable]</h4>
<p>
If the <a class="xattr" href="#Unforgeable">[Unforgeable]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on a <a class="dfnref" href="#dfn-read-only">read only</a>
<a class="dfnref" href="#dfn-attribute">attribute</a>, it indicates
that the attribute will be reflected as an ECMAScript property in
a way that means its behavior cannot be modified and that performing
a property lookup on the object will always result in the attribute’s
property value being returned. In particular, the property will be
non-configurable and will exist as an own property on the object
itself rather than on its prototype.
</p>
<p>
The <a class="xattr" href="#Unforgeable">[Unforgeable]</a>
extended attribute <span class="rfc2119">MUST</span>
<a class="dfnref" href="#dfn-xattr-no-arguments">take no arguments</a>.
</p>
<p>
The <a class="xattr" href="#Unforgeable">[Unforgeable]</a>
extended attribute <span class="rfc2119">MUST NOT</span> appear on
anything other than a read only attribute. It also <span class="rfc2119">MUST NOT</span>
appear on an attribute on interface <var>A</var> if there exists
another interface <var>B</var> that
has <var>A</var> as an <a class="dfnref" href="#dfn-inherited-interfaces">inherited interface</a>.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>For example, the following IDL would be invalid:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface A {
[Unforgeable] readonly attribute DOMString key;
};
interface B : A { };</code></pre></div></div>
</div>
<p>
See <a href="#es-attributes">section 4.5.5</a>,
<a href="#indexed-and-named-properties">section 4.7.1</a> and
<a href="#defineownproperty">section 4.7.3</a>
for the specific requirements that the use of
<a class="xattr" href="#Unforgeable">[Unforgeable]</a> entails.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> defines
an interface that has two <a class="dfnref" href="#dfn-attribute">attributes</a>,
one of which is designated as <a class="xattr" href="#Unforgeable">[Unforgeable]</a>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface System {
[Unforgeable] readonly attribute DOMString username;
readonly attribute Date loginTime;
};</code></pre></div></div>
<p>
In an ECMAScript implementation of the interface, the username attribute will be exposed as a non-configurable property on the
object itself:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var system = getSystem(); <span class="comment">// Get an instance of System.</span>
system.hasOwnProperty("username"); <span class="comment">// Evaluates to true.</span>
system.hasOwnProperty("loginTime"); <span class="comment">// Evaluates to false.</span>
System.prototype.hasOwnProperty("username"); <span class="comment">// Evaluates to false.</span>
System.prototype.hasOwnProperty("loginTime"); <span class="comment">// Evaluates to true.</span>
try {
<span class="comment">// This call would fail, since the property is non-configurable.</span>
Object.defineProperty(system, "username", { value: "administrator" });
} catch (e) { }
<span class="comment">// This defineProperty call would succeed, because System.prototype.loginTime</span>
<span class="comment">// is configurable.</span>
var forgedLoginTime = new Date(new Date() - 3600000);
Object.defineProperty(System.prototype, "loginTime", { value: forgedLoginTime });
system.loginTime; <span class="comment">// So this now evaluates to forgedLoginTime.</span></code></pre></div></div>
</div>
</div>
</div>
<div id="es-modules" class="section">
<h3>4.4. Modules</h3>
<p>
The hierarchy of <a class="dfnref" href="#dfn-module">modules</a> in
an <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a> can,
but need not be, reflected in an ECMAScript implementation. Whether
a module hierarchy is reflected or not depends on the use of the
<a class="xattr" href="#NamespaceObject">[NamespaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
</p>
<p>
For every module that is declared with the
<a class="xattr" href="#NamespaceObject">[NamespaceObject]</a> extended attribute,
and for every module that has an ancestor module declared with the
<a class="xattr" href="#NamespaceObject">[NamespaceObject]</a> extended attribute,
there exists a unique <dfn id="dfn-namespace-object">namespace object</dfn>, which
provides access to the <a class="dfnref" href="#dfn-interface-object">interface objects</a>
and <a class="dfnref" href="#dfn-exception-interface-object">exception interface objects</a>
for the <a class="dfnref" href="#dfn-interface">interfaces</a> and
<a class="dfnref" href="#dfn-exception">exceptions</a> declared in
the module.
</p>
<p>
The <dfn id="dfn-relevant-namespace-object">relevant namespace object</dfn>
for a module, interface or exception <var>A</var> is determined as follows:
</p>
<ul>
<li>
If <var>A</var> has an <a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>
and that module has a <a class="dfnref" href="#dfn-namespace-object">namespace object</a>,
than that namespace object is <var>A</var>’s
<a class="dfnref" href="#dfn-relevant-namespace-object">relevant namespace object</a>.
</li>
<li>
Otherwise, <var>A</var>’s relevant namespace object is the ECMAScript global object.
</li>
</ul>
<p>
For every <a class="dfnref" href="#dfn-module">module</a> that has a
<a class="dfnref" href="#dfn-namespace-object">namespace object</a>,
a corresponding property <span class="rfc2119">MUST</span> exist on
the <a class="dfnref" href="#dfn-relevant-namespace-object">relevant namespace object</a> for
the module. The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a>
of the module, its value is the <a class="dfnref" href="#dfn-namespace-object">namespace object</a> for the module,
and the property has the attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>.
</p>
</div>
<div id="es-interfaces" class="section">
<h3>4.5. Interfaces</h3>
<p>
For every <a class="dfnref" href="#dfn-interface">interface</a> that is not declared with the
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,
a corresponding property <span class="rfc2119">MUST</span> exist on the
interface’s <a class="dfnref" href="#dfn-relevant-namespace-object">relevant namespace object</a>.
The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the interface,
and its value is an object called the
<dfn id="dfn-interface-object">interface object</dfn>.
The property has the attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>.
The characteristics of an interface object are described in <a href="#interface-object">section 4.5.1</a>
below.
</p>
<p>
In addition, for every <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
extended attribute on an interface, a corresponding property <span class="rfc2119">MUST</span>
exist on the interface’s <a class="dfnref" href="#dfn-relevant-namespace-object">relevant namespace object</a>.
The name of the property is the
<a class="sym" href="#prod-identifier">identifier</a> that occurs directly after the
“<span class="sym">=</span>”, and its value is an object called a
<dfn id="dfn-named-constructor">named constructor</dfn>, which allows
construction of objects that implement the interface. The property has the
attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>.
The characteristics of a named constructor are described in
<a href="#named-constructors">section 4.5.2</a>
below.
</p>
<div id="interface-object" class="section">
<h4>4.5.1. Interface object</h4>
<p>
There exists an interface object for every <a class="dfnref" href="#dfn-interface">interface</a>
not declared with the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>. Interface objects
are always <a class="dfnref" href="#dfn-function-object">function objects</a>.
</p>
<p>
The <span class="prop">[[Class]]</span> property of the interface object <span class="rfc2119">MUST</span>
be the <a class="dfnref" href="#dfn-identifier">identifier</a> of the interface.
</p>
<p>
The interface object also has properties that correspond to
the <a class="dfnref" href="#dfn-constant">constants</a> and
<a class="dfnref" href="#dfn-static-operation">static operations</a>
defined on that interface, as described in sections
<a href="#es-constants">4.5.4</a> and
<a href="#es-operations">4.5.6</a>
below.
</p>
<p>
The interface object <span class="rfc2119">MUST</span> also have a property named
“prototype” with attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>
whose value is an object called the <dfn id="dfn-interface-prototype-object">interface prototype
object</dfn>. This object has properties
that correspond to the <a class="dfnref" href="#dfn-attribute">attributes</a> and
<a class="dfnref" href="#dfn-operation">operations</a> defined on the interface,
and is described in more detail in
<a href="#interface-prototype-object">section 4.5.3</a>
below.
</p>
<div id="es-interface-call" class="section">
<h5>4.5.1.1. Interface object [[Call]] method</h5>
<p>
If the <a class="dfnref" href="#dfn-interface">interface</a> is declared with a
<a class="xattr" href="#Constructor">[Constructor]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,
then the <a class="dfnref" href="#dfn-interface-object">interface object</a>
can be called as a function to create an object that implements that
interface. Interfaces that do not have a constructor will throw
an exception when called as a function.
</p>
<!--
<p>
then the interface object <span class='rfc2119'>MUST</span> have a
<span class='prop'>[[Call]]</span> internal property, which allows
construction of objects that implement the given interface.
-->
<!-- The behavior
of this <span class='prop'>[[Construct]]</span> method is not
necessarily the same as that described for <span class='estype'>Function</span> objects in
section 13.2.2 of the
<cite>ECMAScript Language Specification, 5th Edition</cite>
<a href='#ref-ECMA-262'>[ECMA-262]</a>, but it
<span class='rfc2119'>MUST</span> return an object that implements
the given interface if it returns normally (that is, if it does not
throw an exception).
</p>-->
<p>
In order to define how overloaded constructor invocations are resolved, the
<dfn id="dfn-overload-resolution-algorithm">overload resolution algorithm</dfn>
is defined. Its input is an <a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>,
<var>S</var>, and a list of ECMAScript values, <var>arg</var><sub>0..<var>n</var>−1</sub>.
The algorithm behaves as follows:
</p>
<ol class="algorithm">
<li>Initialize <var>entries</var> to a set with the same values as <var>S</var>.</li>
<li>Initialize <var>candidates</var> also to a set with the same values as <var>S</var>.</li>
<li>Let <var>maxarg</var> be the length of the longest type list of the entries in <var>S</var>.</li>
<li>Initialize <var>argcount</var> to be min(<var>maxarg</var>, <var>n</var>).</li>
<li>Let <var>undefcount</var> be the number of trailing <span class="estype">undefined</span> values in <var>arg</var><sub>0..<var>n</var>−1</sub>.</li>
<li>Initialize <var>j</var> to <var>undefcount</var>.</li>
<li>While <var>j</var> > 0:
<ol>
<li>If <var>candidates</var> has any entries whose type list is of length <var>n</var>−<var>j</var>,
then set <var>argcount</var> to <var>j</var> and break this while loop.</li>
<li>Set <var>j</var> to <var>j</var>−1.</li>
</ol>
</li>
<li>Remove from <var>candidates</var> all entries whose type list is not of length <var>argcount</var>.</li>
<li>Initialize <var>i</var> to 0.</li>
<li>While <var>i</var> < <var>argcount</var>:
<ol>
<li>If not all entries in <var>entries</var> have identical types at position <var>i</var> in their type lists, then:
<ol>
<li>Initialize <var>types</var> to the set of IDL types { <a class="idltype" href="#idl-any">any</a> }.</li>
<li>Depending on the value of <var>arg</var><sub><var>i</var></sub>:
<dl class="switch">
<dt>An <span class="estype">Undefined</span>,
<span class="estype">Boolean</span> or
<span class="estype">Number</span> value</dt>
<dd>
Add to <var>types</var> the <a class="dfnref" href="#dfn-primitive-type">primitive types</a> and
<a class="dfnref" href="#dfn-nullable-type">nullable</a> primitive types.
</dd>
<dt>A <span class="estype">String</span> value</dt>
<dd>
Add to <var>types</var> the <a class="idltype" href="#idl-DOMString">DOMString</a> and <span class="idltype">DOMString?</span> types.
</dd>
<dt><span class="esvalue">null</span></dt>
<dd>
Add to <var>types</var> all nullable types.
</dd>
<dt>A <a class="dfnref" href="#dfn-platform-array-object">platform array object</a></dt>
<dd>
Add to <var>types</var> the <a class="idltype" href="#idl-object">object</a> type
and an <a href="#idl-array">array type</a> that corresponds to
the type of the IDL array that the platform array object represents.
</dd>
<dt>Any other <a class="dfnref" href="#dfn-platform-object">platform object</a></dt>
<dd>
Add to <var>types</var> the <a class="idltype" href="#idl-object">object</a> type
and an <a href="#idl-interface">interface type</a>
for each <a class="dfnref" href="#dfn-interface">interface</a>
that is equal to, or is an <a class="dfnref" href="#dfn-inherited-interfaces">inherited interface</a> of, at least one
of the interfaces that the <a class="dfnref" href="#dfn-platform-object">platform object</a> implements.
</dd>
<dt>A native <span class="estype">Array</span> object</dt>
<dd>
(That is, a native object whose <span class="prop">[[Class]]</span> is “Array”.)
Add to <var>types</var> the <a class="idltype" href="#idl-object">object</a> type,
an <a href="#idl-interface">interface type</a>
for each interface annotated with the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
and all <a href="#idl-array">array</a> and <a href="#idl-sequence">sequence types</a>.
</dd>
<dt>A native <span class="estype">Date</span> object</dt>
<dd>
(That is, a native object whose <span class="prop">[[Class]]</span> is “Date”.)
Add to <var>types</var> the <a class="idltype" href="#idl-object">object</a> type,
an <a href="#idl-interface">interface type</a>
for each interface annotated with the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
and the <a href="#idl-Date">Date</a> type.
</dd>
<dt>Any other object</dt>
<dd>
Add to <var>types</var> the <a class="idltype" href="#idl-object">object</a> type
and an <a href="#idl-interface">interface type</a>
for each interface annotated with the <a class="xattr" href="#Callback">[Callback]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
</dd>
</dl>
</li>
<li>
Remove from <var>candidates</var> all entries with type list
<var>t</var> and boolean list <var>a</var> where
<var>a</var><sub><var>i</var></sub> is <span class="idlvalue">false</span>
and <var>t</var><sub><var>i</var></sub> ∉ <var>types</var>.
</li>
<li>
If there exists an entry in <var>candidates</var>
with type list <var>t</var> where
<var>t</var><sub><var>i</var></sub> ∈ <var>types</var>,
then remove from <var>R</var> all entries with type list
<var>t</var> where
<var>t</var><sub><var>i</var></sub> ∉ <var>types</var>.
</li>
</ol>
</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
<li>Return <var>R</var>.</li>
</ol>
<p>
The internal <span class="prop">[[Call]]</span> method
of the interface object behaves as follows, assuming
<var>arg</var><sub>0..<var>n</var>−1</sub> is the list
of argument values passed to the constructor, and <var>I</var>
is the <a class="dfnref" href="#dfn-interface">interface</a>:
</p>
<ol class="algorithm">
<li>
If <var>I</var> was not declared with a <a class="xattr" href="#Constructor">[Constructor]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>, then
throw a <span class="estype">TypeError</span>.
</li>
<li>
Let <var>id</var> be the identifier of interface <var>I</var>.
</li>
<li>
Initialize <var>S</var> to the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for constructors with <a class="dfnref" href="#dfn-identifier">identifier</a>
<var>id</var> on <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> and with argument count <var>n</var> (for the ECMAScript language binding).
</li>
<li>
Set <var>S</var> to the result of passing <var>S</var> and
<var>arg</var><sub>0..<var>n</var>−1</sub> to the
<a class="dfnref" href="#dfn-overload-resolution-algorithm">overload resolution algorithm</a>.
</li>
<li>
If <var>S</var> is empty, throw a <span class="estype">TypeError</span>.
</li>
<li>
If <var>S</var> contains more than one entry, then the
constructor call is ambiguous. Remove all but one entry from
<var>S</var> according to rules specified in the description
of <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var>. If these rules do not sufficiently disambiguate the
call, then the behavior of the function call (including whether
it selects a particular overload or simply throws an exception)
is undefined.
</li>
<li>
Let <var>x</var> be the <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
that represents the constructor and <var>t</var><sub>0..<var>m</var>−1</sub> be the type
list of the single entry in <var>S</var>.
</li>
<li>
Let <var>idlarg</var><sub>0..<var>m</var>−1</sub> be a list
of IDL values, where <var>idlarg</var><sub><var>i</var></sub>
is the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>arg</var><sub><var>i</var></sub> to an IDL value. These conversions
<span class="rfc2119">MUST</span> be done in order from
<var>arg</var><sub><var>0</var></sub> to <var>arg</var><sub><var>m</var>−1</sub>.
</li>
<li>
Let <var>R</var> be the result of performing the actions listed in the description of
the constructor represented by <var>x</var>
with <var>idlarg</var><sub>0..<var>m</var>−1</sub>
as the argument values.
</li>
<li>
Return the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>R</var> to an ECMAScript <a href="#idl-interface">interface type</a> value
<var>I</var>.
</li>
</ol>
<p>
If the internal <span class="prop">[[Call]]</span> method
of the <a class="dfnref" href="#dfn-interface-object">interface object</a>
returns normally, then it <span class="rfc2119">MUST</span>
return an object that implements interface <var>I</var>.
</p>
<p>
Interface objects for interfaces declared with a <a class="xattr" href="#Constructor">[Constructor]</a>
extended attribute <span class="rfc2119">MUST</span> have a property named “length”
with attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>
whose value is a <span class="estype">Number</span> determined as follows:
</p>
<ol class="algorithm">
<li>
Let <var>id</var> be the identifier of interface <var>I</var>.
</li>
<li>
Initialize <var>S</var> to the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for constructors with
<a class="dfnref" href="#dfn-identifier">identifier</a>
<var>id</var> on <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> and with argument count 0 (for the ECMAScript language binding).
</li>
<li>
Return the maximum argument list length of the constructors in the entries of <var>S</var>.
</li>
</ol>
</div>
<!--
<div id='es-interface-hasinstance' class='section'>
<h5>Interface object [[HasInstance]] method</h5>
<p>
The internal <span class='prop'>[[HasInstance]]</span> method of every
<a class='dfnref' href='#dfn-interface-object'>interface object</a>
<var>A</var> <span class='rfc2119'>MUST</span> behave as follows,
assuming <var>V</var> is the object
argument passed to <span class='prop'>[[HasInstance]]</span>:
</p>
<ol class='algorithm'>
<li>If <var>V</var> is not an object, return <span class='esvalue'>false</span>.</li>
<li>Let <var>O</var> be the result of calling the <span class='prop'>[[Get]]</span> method of <var>A</var> with property name “prototype”.</li>
<li>If <var>O</var> is not an object, throw a <span class='estype'>TypeError</span> exception.</li>
<li>If <var>V</var> is a host object that implements the
interface for which <var>O</var> is the <a class='dfnref' href='#dfn-interface-prototype-object'>interface prototype object</a>,
return <span class='esvalue'>true</span>.</li>
<li>Repeat:
<ol>
<li>Set <var>V</var> to the value of the <span class='prop'>[[Prototype]]</span> internal property of <var>V</var>.</li>
<li>If <var>V</var> is <span class='esvalue'>null</span>, return <span class='esvalue'>false</span>.</li>
<li>If <var>O</var> and <var>V</var> refer to the same object,
return <span class='esvalue'>true</span>.</li>
</ol>
</li>
</ol>
</div>
-->
</div>
<div id="named-constructors" class="section">
<h4>4.5.2. Named constructors</h4>
<p>
A <a class="dfnref" href="#dfn-named-constructor">named constructor</a>
that exists due to one or more
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
with a given <a class="dfnref" href="#dfn-identifier">identifier</a>
is a <a class="dfnref" href="#dfn-function-object">function object</a>.
It <span class="rfc2119">MUST</span> have a <span class="prop">[[Call]]</span>
internal property, which allows construction of objects that
implement the interface on which the
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
extended attributes appear. It behaves as follows, assuming
<var>arg</var><sub>0..<var>n</var>−1</sub> is the list
of argument values passed to the constructor, <var>id</var>
is the identifier of the constructor specified in the
extended attribute <a class="dfnref" href="#dfn-xattr-named-argument-list">named argument list</a>,
and <var>I</var> is the <a class="dfnref" href="#dfn-interface">interface</a>
on which the <a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
extended attribute appears:
</p>
<ol class="algorithm">
<li>
Initialize <var>S</var> to the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for constructors with <a class="dfnref" href="#dfn-identifier">identifier</a>
<var>id</var> on <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> and with argument count <var>n</var> (for the ECMAScript language binding).
</li>
<li>
Set <var>S</var> to the result of passing <var>S</var> and
<var>arg</var><sub>0..<var>n</var>−1</sub> to the
<a class="dfnref" href="#dfn-overload-resolution-algorithm">overload resolution algorithm</a>.
</li>
<li>
If <var>S</var> is empty, throw a <span class="estype">TypeError</span>.
</li>
<li>
If <var>S</var> contains more than one entry, then the
constructor call is ambiguous. Remove all but one entry from
<var>S</var> according to rules specified in the description
of <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var>, or arbitrarily if no such rules exist.
</li>
<li>
Let <var>x</var> be the <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
that represents the constructor, and <var>t</var><sub>0..<var>m</var>−1</sub> be the type
list, of the single entry in <var>S</var>.
</li>
<li>
Let <var>idlarg</var><sub>0..<var>m</var>−1</sub> be a list
of IDL values, where <var>idlarg</var><sub><var>i</var></sub>
is the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>arg</var><sub><var>i</var></sub> to an IDL value of type
<var>t</var><sub><var>i</var></sub>. These conversions
<span class="rfc2119">MUST</span> be done in order from
<var>arg</var><sub><var>0</var></sub> to <var>arg</var><sub><var>m</var>−1</sub>.
</li>
<li>
Let <var>R</var> be the result of performing the actions listed in the description of
the constructor represented by <var>x</var>
with <var>idlarg</var><sub>0..<var>m</var>−1</sub>
as the argument values.
</li>
<li>
Return the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>R</var> to an ECMAScript
<a href="#idl-interface">interface type</a> value
<var>I</var>.
</li>
</ol>
<p>
If the internal <span class="prop">[[Call]]</span> method
of the <a class="dfnref" href="#dfn-named-constructor">named constructor</a>
returns normally, then it <span class="rfc2119">MUST</span>
return an object that implements interface <var>I</var>.
</p>
<p>
A named constructor <span class="rfc2119">MUST</span> have a property named “length”
with attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>
whose value is a <span class="estype">Number</span> determined as follows:
</p>
<ol class="algorithm">
<li>
Initialize <var>S</var> to the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for constructors with
<a class="dfnref" href="#dfn-identifier">identifier</a>
<var>id</var> on <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> and with argument count 0 (for the ECMAScript language binding).
</li>
<li>
Return the maximum argument list length of the constructors in the entries of <var>S</var>.
</li>
</ol>
<p>
A named constructor <span class="rfc2119">MUST</span> also have a property named
“prototype” with attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>
whose value is the <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
for the <a class="dfnref" href="#dfn-interface">interface</a> on which the
<a class="xattr" href="#NamedConstructor">[NamedConstructor]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears.
</p>
</div>
<div id="interface-prototype-object" class="section">
<h4>4.5.3. Interface prototype object</h4>
<p>
There <span class="rfc2119">MUST</span> exist an
<a class="dfnref" href="#dfn-interface-prototype-object">interface prototype
object</a> for every <a class="dfnref" href="#dfn-interface">interface</a>
defined, regardless of whether the interface was declared with the
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
The interface prototype object for a particular interface has
properties that correspond to the <a class="dfnref" href="#dfn-attribute">attributes</a>
and <a class="dfnref" href="#dfn-operation">operations</a>
defined on that interface. These properties are described in more detail in
sections <a href="#es-attributes">4.5.5</a> and
<a href="#es-operations">4.5.6</a> below.
</p>
<p>
As with the <a class="dfnref" href="#dfn-interface-object">interface object</a>,
the interface prototype object also has properties that correspond to the
<a class="dfnref" href="#dfn-constant">constants</a> defined on that
interface, described in <a href="#es-operations">section
4.5.4</a> below.
</p>
<p>
If the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
extended attribute was not specified on the interface, then
the interface prototype object <span class="rfc2119">MUST</span>
also have a property named “constructor” with attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">true</span> }</span> whose value
is a reference to the interface object for the interface.
</p>
<p>
The <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
for a given interface <var>A</var> <span class="rfc2119">MUST</span> have an internal
<span class="prop">[[Prototype]]</span> property whose value is as follows:
</p>
<ol class="algorithm">
<li>If <var>A</var> is not declared to inherit from another interface, then the
value of the internal <span class="prop">[[Prototype]]</span> property
of <var>A</var> is the <span class="estype">Array</span> prototype object
(<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.4.4) if the interface
was declared with <a class="xattr" href="#ArrayClass">ArrayClass</a>,
or the <span class="estype">Object</span> prototype object otherwise
(<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.2.4).</li>
<li>Otherwise, <var>A</var> does <a class="dfnref" href="#dfn-inherit">inherit</a> from another
interface.
The value of the internal <span class="prop">[[Prototype]]</span> property of <var>A</var> is the
<a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
for the inherited interface.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
The <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
of an <a class="dfnref" href="#dfn-interface">interface</a> that is defined with
the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
will be accessible if the interface is used as a
<a class="dfnref" href="#dfn-supplemental-interface">non-supplemental interface</a>.
For example, with the following IDL:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[NoInterfaceObject]
interface Foo {
};
partial interface Window {
attribute Foo foo;
};</code></pre></div></div>
<p>
it is not possible to access the interface prototype object through
the <a class="dfnref" href="#dfn-interface-object">interface object</a>
(since it does not exist as <code>window.Foo</code>). However, an instance
of <span class="idltype">Foo</span> can expose the interface prototype
object by gettings its internal <span class="prop">[[Prototype]]</span>
property value – <code>Object.getPrototypeOf(window.foo)</code> in
this example.
</p>
<p>
If the interface is used solely as a
<a class="dfnref" href="#dfn-supplemental-interface">supplemental interface</a>,
then there will be no way to access its interface prototype object, since no
object will have the interface prototype object as its internal
<span class="prop">[[Prototype]]</span> property value. In such cases,
it is an acceptable optimization for this object not to exist.
</p>
</div>
</div>
<!--
<div id='mixin-prototype' class='section'>
<h4>Mixin prototype objects</h4>
<p>
If an object implements any interfaces other than those as declared in the IDL,
then these interfaces are called <dfn id='dfn-mixin-interface'>mixin interfaces</dfn>
for the object. The <dfn id='dfn-mixin-prototype-object'>mixin prototype object</dfn>
for a given object <var>O</var> is an object as follows:
</p>
<ul>
<li>
The object has properties that are the union of all properties that initially exist on <var>O</var>’s
<a class='dfnref' href='#dfn-mixin-interface'>mixin interfaces</a>’
<a class='dfnref' href='#dfn-interface-prototype-object'>interface prototype objects</a>.
If there are multiple properties with the same name,
then it is undefined which of those properties ends up on
the mixin prototype object.
</li>
<li>
The object’s internal <span class='prop'>[[Prototype]]</span> property
value is a reference to the <a class='dfnref' href='#dfn-interface-prototype-object'>interface prototype object</a>
for the most derived non-mixin interface that <var>O</var> implements,
or, if the object implements no non-mixin interfaces, a reference to the
<span class='estype'>Object</span> prototype object
(<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.2.4).</li>
</ul>
<p>
If two objects have the same set of <a class='dfnref' href='#dfn-mixin-interface'>mixin interfaces</a>,
then their <a class='dfnref' href='#dfn-mixin-prototype-object'>mixin prototype objects</a>
<span class='rfc2119'>MUST</span> be the same object.
</p>
XXX unfinished example
<div class='example'>
<p>
The following example illustrates a case when a <a class='dfnref' href='#dfn-mixin-protoype-object'>mixin prototype object</a>
will exist. Consider the following IDL:
</p>
<x:codeblock language='idl'>interface Animal {
DOMString latinName;
};
interface Human {
DOMString name;
};
interface LivingHuman {
unsigned short age;
};
interface
</div>
</div>
-->
<div id="es-constants" class="section">
<h4>4.5.4. Constants</h4>
<p>
For each <a class="dfnref" href="#dfn-constant">constant</a> defined on
an <a class="dfnref" href="#dfn-interface">interface</a> <var>A</var>, there
<span class="rfc2119">MUST</span> be a corresponding property on
the <a class="dfnref" href="#dfn-interface-object">interface object</a>,
if it exists. The property has the following characteristics:
</p>
<ul>
<li>The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the <a class="dfnref" href="#dfn-constant">constant</a>.</li>
<li>The value of the property is that which is obtained by <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a> the <a class="dfnref" href="#dfn-constant">constant</a>’s IDL value to an ECMAScript value.</li>
<li>The property has attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>.</li>
</ul>
<p>
In addition, a property with the same characteristics <span class="rfc2119">MUST</span>
exist on the <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>.
</p>
</div>
<div id="es-attributes" class="section">
<h4>4.5.5. Attributes</h4>
<p>
For each <a class="dfnref" href="#dfn-attribute">attribute</a> defined on
the <a class="dfnref" href="#dfn-interface">interface</a>, there
<span class="rfc2119">MUST</span> exist a corresponding property.
If the attribute was declared with the <a class="xattr" href="#Unforgeable">[Unforgeable]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,
then the property exists on every object that implements the
interface. Otherwise, it exists on the interface’s
<a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>.
</p>
<p>
The characteristics of these properties are as follows:
</p>
<ul>
<li>
The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the <a class="dfnref" href="#dfn-attribute">attribute</a>.
</li>
<li>
The property has attributes <span class="descriptor">{ [[Get]]: <var>G</var>, [[Set]]: <var>S</var>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <var>configurable</var> }</span>,
where:
<ul>
<li><var>configurable</var> is <span class="esvalue">false</span> if the attribute was
declared with the <a class="xattr" href="#Unforgeable">[Unforgeable]</a> extended attribute and <span class="esvalue">true</span> otherwise;</li>
<li><var>G</var> is the <a class="dfnref" href="#dfn-attribute-getter">attribute getter</a>, defined below; and</li>
<li><var>S</var> is the <a class="dfnref" href="#dfn-attribute-setter">attribute setter</a>, also defined below.</li>
</ul>
</li>
<li>
The <dfn id="dfn-attribute-getter">attribute getter</dfn> is a <span class="estype">Function</span>
object whose behavior when invoked is as follows:
<ol class="algorithm">
<li>Let <var>O</var> be the result of calling ToObject on the <span class="esvalue">this</span> value.</li>
<li>If <var>O</var> is not a <a class="dfnref" href="#dfn-platform-object">platform object</a> that implements the <a class="dfnref" href="#dfn-interface">interface</a>
on which the attribute was declared, then throw a <span class="estype">TypeError</span>.</li>
<li>
Let <var>idlValue</var> be the result of performing the actions listed in the description of the attribute that occur when getting
(or those listed in the description of the inherited attribute, if this attribute is declared to
<a class="dfnref" href="#dfn-inherit-getter">inherit its getter</a>),
with <var>O</var> as the object.
</li>
<li>
Let <var>V</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
the <var>idlValue</var> for this attribute to an ECMAScript value.
</li>
<li>
Return <var>V</var>.
</li>
</ol>
The value of the <span class="estype">Function</span> object’s “length”
property is the <span class="estype">Number</span> value <span class="esvalue">0</span>.
</li>
<li>
The <dfn id="dfn-attribute-setter">attribute setter</dfn> is <span class="esvalue">undefined</span>
if the attribute is declared <code>readonly</code> and has neither a
<a class="xattr" href="#PutForwards">[PutForwards]</a> nor a <a class="xattr" href="#Replaceable">[Replaceable]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a> declared on it.
Otherwise, it is a <span class="estype">Function</span> object whose behavior when invoked is as follows:
<ol class="algorithm">
<li>Let <var>O</var> be the result of calling ToObject on the <span class="esvalue">this</span> value.</li>
<li>If <var>O</var> is not a <a class="dfnref" href="#dfn-platform-object">platform object</a> that implements the <a class="dfnref" href="#dfn-interface">interface</a>
on which the attribute was declared, then throw a <span class="estype">TypeError</span>.</li>
<li>Let <var>V</var> be the value of the first argument passed to the <span class="estype">Function</span>,
or <span class="esvalue">undefined</span> is no arguments were passed.</li>
<li>If the attribute is declared with a <a class="xattr" href="#PutForwards">[PutForwards]</a>
extended attribute, then:
<ol>
<li>Let <var>Q</var> be the result of calling the <span class="prop">[[Get]]</span> method
on <var>O</var> using the identifier of the attribute as the property name.</li>
<li>If <var>Q</var> is not an object, then throw a <span class="estype">TypeError</span>.</li>
<li>Let <var>A</var> be the attribute identified by the <a class="xattr" href="#PutForwards">[PutForwards]</a> extended attribute.</li>
<li>Call the <span class="prop">[[Put]]</span> method on <var>Q</var>
using the identifier of <var>A</var> as the property name and <var>V</var> as the value.</li>
<li>Return.</li>
</ol>
</li>
<li>If the attribute is declared with a <a class="xattr" href="#Replaceable">[Replaceable]</a>
extended attribute, then:
<ol>
<li>Let <var>O</var> be the result of calling ToObject on the <span class="esvalue">this</span> value.</li>
<li>If <var>O</var> is not an instance of the interface on which the attribute was declared,
then throw a <span class="estype">TypeError</span>.</li>
<li>Let <var>P</var> be the identifier of the attribute.</li>
<li>Call the <span class="prop">[[DefineOwnProperty]]</span> method of <var>O</var>
passing property name <var>P</var>, Property Descriptor
<span class="desc">{ [[Value]]: <var>V</var>, [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>,
and <b>false</b>.</li>
<li>Return <span class="esvalue">undefined</span>.</li>
</ol>
</li>
<li>Let <var>idlValue</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>V</var> to an IDL value.</li>
<li>Perform the actions listed in the description of the attribute that occur when setting,
with <var>O</var> as the object and <var>idlValue</var> as the value.</li>
<li>Return <span class="esvalue">undefined</span>.</li>
</ol>
The value of the <span class="estype">Function</span> object’s “length”
property is the <span class="estype">Number</span> value <span class="esvalue">1</span>.
</li>
</ul>
<p>
Note that attempting to assign to a property corresponding to a
<a class="dfnref" href="#dfn-read-only">read only</a> <a class="dfnref" href="#dfn-attribute">attribute</a>
results in different behavior depending on whether the script doing so is in strict mode.
When in strict mode, such an assignment will result in a <span class="estype">TypeError</span>
being thrown. When not in strict mode, the assignment attempt will be ignored.
</p>
</div>
<div id="es-operations" class="section">
<h4>4.5.6. Operations</h4>
<p>
For each unique <a class="dfnref" href="#dfn-identifier">identifier</a>
of an <!--non-<a class='dfnref' href='#dfn-omittable'>omittable</a>-->
<a class="dfnref" href="#dfn-operation">operation</a>
defined on the <a class="dfnref" href="#dfn-interface">interface</a>, there
<span class="rfc2119">MUST</span> be a corresponding property on
the <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
(if it is a <a class="dfnref" href="#dfn-regular-operation">regular operation</a>)
or the <a class="dfnref" href="#dfn-interface-object">interface object</a>
(if it is a <a class="dfnref" href="#dfn-static-operation">static operation</a>),
unless the <a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for that <a class="dfnref" href="#dfn-identifier">identifier</a> and <a class="dfnref" href="#dfn-operation">operation</a>
and with an argument count of 0 (for the ECMAScript language binding) has no
entries.
</p>
<p>
The characteristics of such a corresponding property are as follows:
</p>
<ul>
<li>The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a>.</li>
<li>
The property has attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>.
</li>
<li>
The value of the property is a <span class="estype">Function</span> object whose
behavior is as follows,
assuming <var>id</var> is the
<a class="dfnref" href="#dfn-identifier">identifier</a>,
<var>arg</var><sub>0..<var>n</var>−1</sub> is the list
of argument values passed to the function
and <var>I</var> is the <a class="dfnref" href="#dfn-interface">interface</a>:
<ol class="algorithm">
<li>
Let <var>O</var> be an object as follows:
<ul>
<li>
If the <a class="dfnref" href="#dfn-interface">interface</a> on which the
<a class="dfnref" href="#dfn-operation">operation</a> appears has an
<a class="xattr" href="#ImplicitThis">[ImplicitThis]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,
and the <span class="esvalue">this</span> value is <span class="esvalue">null</span>
or <span class="esvalue">undefined</span>, then <var>O</var> is
the ECMAScript global object associated with the <span class="estype">Function</span> object.
</li>
<li>
Otherwise, <var>O</var> is the result of calling ToObject on the
<span class="esvalue">this</span> value.
</li>
</ul>
</li>
<li>
If <var>O</var> is not a <a class="dfnref" href="#dfn-platform-object">platform object</a>
that implements interface <var>I</var>, throw a <span class="estype">TypeError</span>.
</li>
<li>
Initialize <var>S</var> to the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for <a class="dfnref" href="#dfn-regular-operation">regular operations</a>
(if the operation is a regular operation) or for
<a class="dfnref" href="#dfn-static-operation">static operations</a>
(if the operation is a static operation) with
<a class="dfnref" href="#dfn-identifier">identifier</a>
<var>id</var> on <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> and with argument count <var>n</var> (for the ECMAScript language binding).
</li>
<li>
Set <var>S</var> to the result of passing <var>S</var> and
<var>arg</var><sub>0..<var>n</var>−1</sub> to the
<a class="dfnref" href="#dfn-overload-resolution-algorithm">overload resolution algorithm</a>.
</li>
<li>
If <var>S</var> is empty, throw a <span class="estype">TypeError</span>.
</li>
<li>
If <var>S</var> contains more than one entry, then the
operation call is ambiguous. Remove all but one entry from
<var>S</var> according to rules specified in the description
of <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var>, or arbitrarily if no such rules exist.
</li>
<li>
Let <var>op</var> be the operation and <var>t</var><sub>0..<var>m</var>−1</sub>
be the type list of the single entry in <var>S</var>.
</li>
<li>
Let <var>idlarg</var><sub>0..<var>m</var>−1</sub> be a list
of IDL values, where <var>idlarg</var><sub><var>i</var></sub>
is the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>arg</var><sub><var>i</var></sub> to an IDL value. These conversions
<span class="rfc2119">MUST</span> be done in order from
<var>arg</var><sub><var>0</var></sub> to <var>arg</var><sub><var>m</var>−1</sub>.
</li>
<li>
Let <var>R</var> be the result of performing the actions listed in the description of
operation <var>op</var> with <var>idlarg</var><sub>0..<var>m</var>−1</sub>
as the argument values.
</li>
<li>
Return the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>R</var> to an ECMAScript value of
the type <var>op</var> is declared to return.
</li>
</ol>
</li>
<li>
The value of the <span class="estype">Function</span> object’s “length”
property is a <span class="estype">Number</span> determined as follows:
<ol class="algorithm">
<li>
Let <var>S</var> be the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for <a class="dfnref" href="#dfn-regular-operation">regular operations</a>
(if the operation is a regular operation) or for
<a class="dfnref" href="#dfn-static-operation">static operations</a>
(if the operation is a static operation) with
<a class="dfnref" href="#dfn-identifier">identifier</a>
<var>id</var> on <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> and with argument count 0 (for the ECMAScript language binding).
</li>
<li>
Return the maximum argument list length of the functions in the entries of <var>S</var>.
</li>
</ol>
</li>
</ul>
<p id="es-stringifier">
In addition, if the <a class="dfnref" href="#dfn-interface">interface</a>
has a <a class="dfnref" href="#dfn-stringifier">stringifier</a>, then
a property <span class="rfc2119">MUST</span> exist on
the <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
whose name is “toString”,
with attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>
and whose value is a
<span class="estype">Function</span> object. If <code>stringifier</code>
was specified on an <a class="dfnref" href="#dfn-attribute">attribute</a> <var>A</var>, then the
function, when invoked,
<span class="rfc2119">MUST</span> behave as follows:
</p>
<ol class="algorithm">
<li>Let <var>O</var> be the result of calling ToObject on the <span class="esvalue">this</span> value.</li>
<li>If <var>O</var> is not an object that implements the <a class="dfnref" href="#dfn-interface">interface</a>
on which <var>A</var> was declared, then throw a <span class="estype">TypeError</span>.</li>
<li>
Let <var>V</var> be the result of invoking the <span class="prop">[[Get]]</span> method of <var>O</var>
with <var>P</var> as the argument.
</li>
<li>Return ToString(<var>V</var>).</li>
</ol>
<p>
If <code>stringifier</code>
was specified on an <a class="dfnref" href="#dfn-operation">operation</a>
with an identifier <var>P</var>, then
the function, when invoked,
<span class="rfc2119">MUST</span> behave as follows:
</p>
<ol class="algorithm">
<li>Let <var>O</var> be the result of calling ToObject on the <span class="esvalue">this</span> value.</li>
<li>
Let <var>F</var> be the result of invoking the <span class="prop">[[Get]]</span> method of object
<var>O</var> with <var>P</var> as the argument.
</li>
<li>If <var>F</var> is not callable, throw a <span class="estype">TypeError</span>.</li>
<li>Let <var>V</var> be the result of invoking the <span class="prop">[[Call]]</span> method of <var>F</var>,
using <var>O</var> as the <span class="esvalue">this</span> value
and passing no arguments.</li>
<li>Return ToString(<var>V</var>).</li>
</ol>
<p>
If <code>stringifier</code>
was specified on an <a class="dfnref" href="#dfn-operation">operation</a>
with no identifier,
then the behavior of the function
is the <a class="dfnref" href="#dfn-stringification-behavior">stringification behavior</a>
of the interface, as described in the prose for the interface.
</p>
</div>
</div>
<div id="es-implements-statements" class="section">
<h3>4.6. Implements statements</h3>
<p>
The <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
of an interface <var>A</var> <span class="rfc2119">MUST</span> have a copy of
each property that corresponds to one of the
<a class="dfnref" href="#dfn-constant">constants</a>,
<a class="dfnref" href="#dfn-attribute">attributes</a> or
<a class="dfnref" href="#dfn-operation">operations</a> that exist on
all of the interface prototype objects of <var>A</var>’s
<a class="dfnref" href="#dfn-consequential-interfaces">consequential interfaces</a>.
</p>
</div>
<div id="es-platform-objects" class="section">
<h3>4.7. Platform objects implementing interfaces</h3>
<p>
Every <a class="dfnref" href="#dfn-platform-object">platform object</a> is associated with a global environment, just
as the <a class="dfnref" href="#dfn-initial-object">initial objects</a> are.
It is the responsibility of specifications using Web IDL to state
which global environment (or, by proxy, which global object) each platform
object is associated with.
</p>
<p>
The <dfn id="dfn-primary-interface">primary interface</dfn> of a platform object
that implements one or more interfaces is the most-derived <a class="dfnref" href="#dfn-supplemental-interface">non-supplemental interface</a>
that it implements. The value of the internal <span class="prop">[[Prototype]]</span>
property of the platform object is the <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype object</a>
of the <a class="dfnref" href="#dfn-primary-interface">primary interface</a>
from the <a class="dfnref" href="#dfn-platform-object">platform object</a>’s associated global environment.
</p>
<!--
<p>
The value of the host object’s internal <span class='prop'>[[Prototype]]</span>
property is determined as follows:
</p>
<ul>
<li>
If the host object implements no <a class='dfnref' href='#dfn-interface'>interfaces</a>,
then its internal <span class='prop'>[[Prototype]]</span> property
value is a reference to the <span class='estype'>Object</span>
prototype object from the object’s associated global environment.
</li>
<li>
If the host object implements a single
<a class='dfnref' href='#dfn-interface'>interface</a>, then its
internal <span class='prop'>[[Prototype]]</span> property is a
reference to the
<a class='dfnref' href='#dfn-interface-prototype-object'>interface prototype object</a>
from the object’s associated global environment for that interface.
</li>
<li>
Otherwise, if the host object has a <a class='dfnref' href='#dfn-primary-prototype-interface'>primary prototype interface</a>
and implements no interfaces other than its primary
prototype interface and all of its ancestors, then the value of
the internal <span class='prop'>[[Prototype]]</span> property is
a reference to the
<a class='dfnref' href='#dfn-interface-prototype-object'>interface prototype object</a>
from the host object’s associated global environment
for the host object’s primary prototype interface.
</li>
<li>
Otherwise, the host object implements at least two
<a class='dfnref' href='#dfn-interface'>interfaces</a>, and has no
<a class='dfnref' href='#dfn-primary-prototype-interface'>primary prototype interface</a>
or implements some interfaces other than its primary prototype
interface and all of its ancestors. The value of the
internal <span class='prop'>[[Prototype]]</span> property is
a reference to the <a class='dfnref' href='#dfn-host-object-mixin-prototype-object'>host object mixin prototype object</a>
for the host object (defined below).
</li>
</ul>
-->
<p>
The value of the internal <span class="prop">[[Class]]</span>
property of a platform object that implements one or more interfaces
<span class="rfc2119">MUST</span> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of
the <a class="dfnref" href="#dfn-primary-interface">primary interface</a>
of the platform object.
</p>
<!--
of that interface.
determined as follows:
</p>
<ul>
<li>
If the host object implements a single
<a class='dfnref' href='#dfn-interface'>interface</a>, then the
value of the internal <span class='prop'>[[Class]]</span>
property <span class='rfc2119'>MUST</span> be the
<a class='dfnref' href='#dfn-identifier'>identifier</a>
of that interface.
</li>
<li>
Otherwise, if the host object has a
<a class='dfnref' href='#dfn-primary-prototype-interface'>primary prototype interface</a>,
then the value of the internal <span class='prop'>[[Class]]</span>
property <span class='rfc2119'>MUST</span> be the
identifier of that interface.
</li>
<li>
Otherwise, no particular value is required to be used for the
value of the internal <span class='prop'>[[Class]]</span>
property.
</li>
</ul>
<div class='ednote'>
<p>Should there be more restrictions on the <span class='prop'>[[Class]]</span>?
<a href='http://www.w3.org/mid/Pine.LNX.4.62.0903072358030.2690@hixie.dreamhostps.com'>(Mail.)</a></p>
</div>
<div id='host-object-mixin-prototype' class='section'>
<h4>Host object mixin prototype object</h4>
<p>
The <dfn id='dfn-host-object-mixin-prototype-object'>host object mixin prototype object</dfn>
for a given host object is an object as follows:
</p>
<ul>
<li>The object has properties that are the union of all
properties that exist on the <a class='dfnref' href='#dfn-interface'>interfaces</a>
that the host object implements and which are not the host object’s
<a class='dfnref' href='#dfn-primary-prototype-interface'>primary prototype interface</a>
or one of its ancestors.</li>
<li>The object’s internal <span class='prop'>[[Prototype]]</span> property value
is a reference to the <a class='dfnref' href='#dfn-interface-prototype-object'>interface prototype object</a>
for the host object’s <a class='dfnref' href='#dfn-primary-prototype-interface'>primary prototype interface</a>,
or, if the host object has no primary prototype interface, a reference to the
<span class='estype'>Object</span> prototype object. The
prototype object chosen for the <span class='prop'>[[Prototype]]</span> property
value is the one from the host object’s associated global environment.</li>
</ul>
<p>
If two host objects implement the same set of
<a class='dfnref' href='#dfn-interface'>interfaces</a>,
have references to <a class='dfnref' href='#dfn-host-object-mixin-prototype-object'>host object mixin prototype objects</a>
as their internal <span class='prop'>[[Prototype]]</span> property values,
and are both associated with the same global environment,
then these host object mixin prototype objects
<span class='rfc2119'>MUST</span> be the same object.
</p>
</div>
-->
<div id="indexed-and-named-properties" class="section">
<h4>4.7.1. Indexed and named properties</h4>
<p>
If a <a class="dfnref" href="#dfn-platform-object">platform object</a> implements an <a class="dfnref" href="#dfn-interface">interface</a> that
<a class="dfnref" href="#dfn-support-indexed-properties">supports indexed</a> or
<a class="dfnref" href="#dfn-support-named-properties">named properties</a>,
the object will appear to have additional properties that correspond to the
object’s indexed and named properties. These properties are not “real” own
properties on the object, but are made to look like they are by being exposed
by the <span class="prop">[[GetOwnProperty]]</span> internal method.
</p>
<p>
It is permissible for an object to implement multiple interfaces that support indexed properties.
However, if so, and there are conflicting definitions as to the object’s
<a class="dfnref" href="#dfn-supported-property-indices">supported property indices</a>,
or if one of the interfaces is a <a class="dfnref" href="#dfn-supplemental-interface">supplemental interface</a> for the
platform object, then it is undefined what additional properties the object will appear to
have, or what its exact behavior will be with regard to its indexed properties.
The same applies for named properties.
</p>
<p>
The <a class="dfnref" href="#dfn-indexed-property-getter">indexed property getter</a>
that is defined on the derived-most interface that the
platform object implements is the one that defines the behavior
when indexing the object with an array index. Similarly for
<a class="dfnref" href="#dfn-indexed-property-setter">indexed property setters</a>,
<a class="dfnref" href="#dfn-indexed-property-deleter">deleters</a> and
<a class="dfnref" href="#dfn-indexed-property-creator">creators</a>.
This way, the definitions of these special operations from
ancestor interfaces can be overridden.
</p>
<p>
Platform objects implementing an interface that supports indexed or named properties cannot be fixed; if <code>Object.freeze</code>, <code>Object.seal</code>
or <code>Object.preventExtensions</code> is called on one of these objects, these the function
<span class="rfc2119">MUST</span> throw a <span class="estype">TypeError</span>.
</p>
<p>
The name of each property that appears to exist due to an object supporting indexed properties
is an <dfn id="dfn-array-index-property-name">array index property name</dfn>, which is a property
name <var>P</var> for which the following algorithm returns <span class="esvalue">true</span>:
</p>
<ol class="algorithm">
<li>Let <var>i</var> be ToUint32(<var>P</var>).</li>
<li>Let <var>s</var> be ToString(<var>i</var>).</li>
<li>If <var>s</var> ≠ <var>P</var> or <var>i</var> = 2<sup>32</sup> − 1, then return <span class="esvalue">false</span>.</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
<!--
<p>
Specifications can state that certain named properties are <dfn id='dfn-resolved-before-prototype-properties'>resolved
before prototype properties</dfn>. This means that such named properties will be resolved after real own
properties on the object (as with all non-<a class='xattr' href='#OverrideBuiltins'>[OverrideBuiltins]</a> named
properties), but before properties from the prototype chain. Specifications <span class='rfc2119'>SHOULD NOT</span>
declare any named properties to be <a href='#dfn-resolved-before-prototype-properties'>resolved before prototype properties</a>
unless this is required to specify the behavior of legacy APIs.
</p>
<div class='note'>
<p>At the time of writing, the only known justifiable use of named properties that are
<a href='#dfn-resolved-before-prototype-properties'>resolved before prototype properties</a>
is the <span class='esvalue'>Window</span> interface defined in HTML5 (<a href='#ref-HTML5'>[HTML5]</a>, section 5.2).</p>
</div>
-->
<p>
The <dfn id="dfn-named-property-visibility">named property visibility algorithm</dfn> is used to determine if
a given named property is exposed on an object. Some named properties are not exposed on an object
depending on whether the <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a> was used. The algorithm
operates as follows, with property name <var>P</var> and object <var>O</var>:
</p>
<ol class="algorithm">
<li>If <var>O</var> implements an <a class="dfnref" href="#dfn-interface">interface</a> with
an <a class="xattr" href="#Unforgeable">[Unforgeable]</a>-annotated <a class="dfnref" href="#dfn-attribute">attribute</a>
whose <a class="dfnref" href="#dfn-identifier">identifier</a> is <var>P</var>, then return false.</li>
<li>If <var>P</var> is not a <a class="dfnref" href="#dfn-supported-property-names">supported property name</a>
of <var>O</var>, then return false.</li>
<li>If <var>O</var> implements an interface that has the <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>, then return true.</li>
<li>If <var>O</var> has an own property named <var>P</var>, then return false.</li>
<!--
<li>If <var>P</var> is to be <a class='dfnref' href='#dfn-resolved-before-prototype-properties'>resolved before prototype properties</a>, then return true.</li>
-->
<li>Let <var>prototype</var> be the value of the internal <span class="prop">[[Prototype]]</span> property of <var>O</var>.</li>
<li>If <var>prototype</var> is <span class="esvalue">null</span>, then return true.</li>
<li>If the result of calling the <span class="prop">[[HasProperty]]</span> internal method on <var>prototype</var> with property name <var>P</var> is <span class="esvalue">true</span>, then return false.</li>
<li>Return true.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>This should ensure that for objects with named properties, property resolution is done in the following order:</p>
<ol>
<li>Indexed properties.</li>
<li>Unforgeable attributes.</li>
<li>Then, if <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>:
<ol>
<li>Named properties.</li>
<li>Own properties.</li>
<li>Properties from the prototype chain.</li>
</ol>
</li>
<li>Otherwise, if not <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>:
<ol>
<li>Own properties.</li>
<!--
<li>Any named properties to be <a class='dfnref' href='#dfn-resolved-before-prototype-properties'>resolved before prototype properties</a>.</li>
-->
<li>Properties from the prototype chain.</li>
<!--
<li>Any other named properties.</li>
-->
<li>Named properties.</li>
</ol>
</li>
</ol>
</div>
<p>
Support for <a class="dfnref" href="#dfn-getter">getters</a> is
handled by the <a href="#defineownproperty">platform object [[GetOwnProperty]] method</a>
defined in section 4.7.2,
for <a class="dfnref" href="#dfn-creator">creators</a> and
<a class="dfnref" href="#dfn-setter">setters</a>
by the <a href="#defineownproperty">platform object [[DefineOwnProperty]] method</a>
defined in section 4.7.3, and
for <a class="dfnref" href="#dfn-deleter">deleters</a>
by the <a href="#delete">platform object [[Delete]] method</a>
defined in section 4.7.4.
</p>
</div>
<div id="getownproperty" class="section">
<h4>4.7.2. Platform object [[GetOwnProperty]] method</h4>
<p>
The internal <span class="prop">[[GetOwnProperty]]</span> method of every
<a class="dfnref" href="#dfn-platform-object">platform object</a> <var>O</var> that implements an <a class="dfnref" href="#dfn-interface">interface</a>
which <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed</a> or
<a class="dfnref" href="#dfn-support-named-properties">named properties</a>
<span class="rfc2119">MUST</span> behave as follows when called with property name <var>P</var>:
</p>
<ol class="algorithm">
<li>
If <var>O</var> <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed properties</a>
and <var>P</var> is an <a class="dfnref" href="#dfn-array-index-property-name">array index property name</a>, then:
<ol>
<li>Let <var>index</var> be the result of calling ToUint32(<var>P</var>).</li>
<li>If <var>index</var> is a <a class="dfnref" href="#dfn-supported-property-indices">supported property index</a>, then:
<ol>
<li>Let <var>operation</var> be the operation used to declare the indexed property getter.</li>
<li>Let <var>value</var> be an uninitialized variable.</li>
<li>If <var>operation</var> was defined without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then
set <var>value</var> to the result of performing the steps listed in the interface description to
<a class="dfnref" href="#dfn-determine-the-value-of-an-indexed-property">determine the value of an indexed property</a>
with <var>index</var> as the index.</li>
<li>Otherwise, <var>operation</var> was defined with an identifier. Set <var>value</var> to the result
of performing the steps listed in the description of <var>operation</var> with <var>index</var> as the only argument value.</li>
<li>Let <var>desc</var> be a newly created property descriptor (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.10) with no fields.</li>
<li>Set <var>desc</var>.<span class="prop">[[Value]]</span> to the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>value</var> to an ECMAScript value.</li>
<li>If <var>O</var> implements an interface with an <a class="dfnref" href="#dfn-indexed-property-setter">indexed property setter</a>, then set
<var>desc</var>.<span class="prop">[[Writable]]</span> to <span class="esvalue">true</span>, otherwise set it to
<span class="esvalue">false</span>.</li>
<li>Set <var>desc</var>.<span class="prop">[[Enumerable]]</span> and <var>desc</var>.<span class="prop">[[Configurable]]</span> to <span class="esvalue">true</span>.</li>
<li>Return <var>desc</var>.</li>
</ol>
</li>
</ol>
</li>
<li>If <var>O</var> <a class="dfnref" href="#dfn-support-named-properties">supports named properties</a>, then:
<ol>
<li>If the result of running the <a class="dfnref" href="#dfn-named-property-visibility">named property visibility algorithm</a> with
property name <var>P</var> and object <var>O</var> is true, then:
<ol>
<li>Let <var>operation</var> be the operation used to declare the named property getter.</li>
<li>Let <var>value</var> be an uninitialized variable.</li>
<li>If <var>operation</var> was defined without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then
set <var>value</var> to the result of performing the steps listed in the interface description to
<a class="dfnref" href="#dfn-determine-the-value-of-a-named-property">determine the value of a named property</a>
with <var>P</var> as the name.</li>
<li>Otherwise, <var>operation</var> was defined with an identifier. Set <var>value</var> to the result
of performing the steps listed in the description of <var>operation</var> with <var>P</var> as the only argument value.</li>
<li>Let <var>desc</var> be a newly created property descriptor (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.10) with no fields.</li>
<li>Set <var>desc</var>.<span class="prop">[[Value]]</span> to the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>value</var> to an ECMAScript value.</li>
<li>If <var>O</var> implements an interface with a <a class="dfnref" href="#dfn-named-property-setter">named property setter</a> and
<var>O</var> does not implement an interface with the <a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>, then set
<var>desc</var>.<span class="prop">[[Writable]]</span> to <span class="esvalue">true</span>, otherwise set it to
<span class="esvalue">false</span>.</li>
<li>Set <var>desc</var>.<span class="prop">[[Enumerable]]</span> and <var>desc</var>.<span class="prop">[[Configurable]]</span> to <span class="esvalue">true</span>.</li>
<li>Return <var>desc</var>.</li>
</ol>
</li>
</ol>
</li>
<li>Return the result of calling the default <span class="prop">[[GetOwnProperty]]</span> internal method (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.12.1) on <var>O</var> passing <var>P</var> as the argument.</li>
</ol>
</div>
<div id="defineownproperty" class="section">
<h4>4.7.3. Platform object [[DefineOwnProperty]] method</h4>
<p>
The internal <span class="prop">[[DefineOwnProperty]]</span> method of every
<a class="dfnref" href="#dfn-platform-object">platform object</a> <var>O</var> that implements an <a class="dfnref" href="#dfn-interface">interface</a>
which <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed</a> or
<a class="dfnref" href="#dfn-support-named-properties">named properties</a>
<span class="rfc2119">MUST</span> behave as follows when called with property name <var>P</var>,
property descriptor <var>Desc</var> and boolean flag <var>Throw</var>.
The term “Reject” is used as defined in
<a href="#platform-array-object-defineownproperty">section 4.2.20.2</a> above.
</p>
<ol class="algorithm">
<li>Set <var>Desc</var>.<span class="prop">[[Configurable]]</span> to <span class="esvalue">true</span>.</li>
<li>
If <var>O</var> <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed properties</a> and
<var>P</var> is an <a class="dfnref" href="#dfn-array-index-property-name">array index property name</a>, then:
<ol>
<li>If the result of calling IsDataDescriptor(<var>Desc</var>) is <span class="esvalue">false</span>, then Reject.</li>
<li>Let <var>index</var> be the result of calling ToUint32(<var>P</var>).</li>
<li>Let <var>creating</var> be true if <var>index</var> is not a <a class="dfnref" href="#dfn-supported-property-indices">supported property index</a>, and false otherwise.</li>
<li>If <var>creating</var> is true and <var>O</var> does not implement an interface with an <a class="dfnref" href="#dfn-indexed-property-creator">indexed property creator</a>, then Reject.</li>
<li>If <var>creating</var> is false and <var>O</var> does not implement an interface with an <a class="dfnref" href="#dfn-indexed-property-setter">indexed property setter</a>, then Reject.</li>
<li>Let <var>operation</var> be the operation used to declare the indexed property creator if <var>creating</var> is true,
or the indexed property setter if <var>creating</var> is false.</li>
<li>Let <var>T</var> be the type of the second argument of <var>operation</var>.</li>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a> <var>Desc</var>.<span class="prop">[[Value]]</span> to an IDL value of type <var>T</var>.</li>
<li>If <var>operation</var> was defined without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then:
<ol>
<li>If <var>creating</var> is true, then perform the steps listed in the interface description to
<a class="dfnref" href="#dfn-set-the-value-of-a-new-indexed-property">set the value of a new indexed property</a>
with <var>index</var> as the index and <var>value</var> as the value.</li>
<li>Otherwise, <var>creating</var> is false. Perform the steps listed in the interface description to
<a class="dfnref" href="#dfn-set-the-value-of-an-existing-indexed-property">set the value of an existing indexed property</a>
with <var>index</var> as the index and <var>value</var> as the value.</li>
</ol>
</li>
<li>Otherwise, <var>operation</var> was defined with an identifier. Perform the steps listed in the description of
<var>operation</var> with <var>index</var> and <var>value</var> as the two argument values.</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</li>
<li>
If <var>O</var> <a class="dfnref" href="#dfn-support-named-properties">supports named properties</a> and <var>P</var>
is not the <a class="dfnref" href="#dfn-identifier">identifier</a> of an <a class="xattr" href="#Unforgeable">[Unforgeable]</a>-annotated <a class="dfnref" href="#dfn-attribute">attribute</a>
on an interface that <var>O</var> implements, then:
<ol>
<li>Let <var>creating</var> be true if <var>P</var> is not a <a class="dfnref" href="#dfn-supported-property-names">supported property name</a>, and false otherwise.</li>
<li>If <var>creating</var> is false and <var>O</var> implements an interface with the <a class="xattr" href="#ReplaceableNamedProperties">[ReplaceableNamedProperties]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>, then:
<ol>
<li>If the result of calling IsAccessorDescriptor(<var>Desc</var>) is <span class="esvalue">true</span>, then:
<ol>
<li>Create an own accessor property named <var>P</var> on <var>O</var> whose <span class="prop">[[Get]]</span>,
<span class="prop">[[Set]]</span>, <span class="prop">[[Enumerable]]</span> and <span class="prop">[[Configurable]]</span>
attribute values are described by <var>Desc</var>. If the value of an attribute field of <var>Desc</var> is absent,
the attribute of the newly created property is set to its default value (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.6.1).</li>
</ol>
</li>
<li>Otherwise:
<ol>
<li>Create an own data property named <var>P</var> on <var>O</var> whose <span class="prop">[[Value]]</span>,
<span class="prop">[[Writable]]</span>, <span class="prop">[[Enumerable]]</span> and <span class="prop">[[Configurable]]</span>
attribute values are described by <var>Desc</var>. If the value of an attribute field of <var>Desc</var> is absent,
the attribute of the newly created property is set to its default value (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.6.1).</li>
</ol>
</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</li>
<li>Otherwise, if <var>O</var> implements an interface with the <a class="xattr" href="#OverrideBuiltins">[OverrideBuiltins]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a> or <var>O</var> does not have an own property
named <var>P</var>, then:
<ol>
<li>If <var>creating</var> is false and <var>O</var> does not implement an interface with a <a class="dfnref" href="#dfn-named-property-setter">named property setter</a>, then Reject.</li>
<li>If <var>creating</var> is false or <var>O</var> implements an interface with a <a class="dfnref" href="#dfn-named-property-creator">named property creator</a>, then:
<ol>
<li>If the result of calling IsDataDescriptor(<var>Desc</var>) is <span class="esvalue">false</span>, then Reject.</li>
<li>Let <var>operation</var> be the operation used to declare the named property creator if <var>creating</var> is true,
or the named property setter if <var>creating</var> is false.</li>
<li>Let <var>T</var> be the type of the second argument of <var>operation</var>.</li>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a> <var>Desc</var>.<span class="prop">[[Value]]</span> to an IDL value of type <var>T</var>.</li>
<li>If <var>operation</var> was defined without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then:
<ol>
<li>If <var>creating</var> is true, then perform the steps listed in the interface description to
<a class="dfnref" href="#dfn-set-the-value-of-a-new-named-property">set the value of a new named property</a>
with <var>P</var> as the name and <var>value</var> as the value.</li>
<li>Otherwise, <var>creating</var> is false. Perform the steps listed in the interface description to
<a class="dfnref" href="#dfn-set-the-value-of-an-existing-named-property">set the value of an existing named property</a>
with <var>P</var> as the name and <var>value</var> as the value.</li>
</ol>
</li>
<li>Otherwise, <var>operation</var> was defined with an identifier. Perform the steps listed in the description of
<var>operation</var> with <var>index</var> and <var>value</var> as the two argument values.</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
<li>Call the default <span class="prop">[[DefineOwnProperty]]</span> internal method (<a href="#ref-ECMA-262">[ECMA-262]</a>, section 8.12.9) on <var>O</var> passing <var>P</var>, <var>Desc</var>, and <var>Throw</var> as arguments.</li>
</ol>
</div>
<div id="delete" class="section">
<h4>4.7.4. Platform object [[Delete]] method</h4>
<p>
The internal <span class="prop">[[Delete]]</span> method of every
<a class="dfnref" href="#dfn-platform-object">platform object</a> <var>O</var> that implements an <a class="dfnref" href="#dfn-interface">interface</a>
which <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed</a> or
<a class="dfnref" href="#dfn-support-named-properties">named properties</a>
<span class="rfc2119">MUST</span> behave as follows when called with property name <var>P</var>
and boolean flag <var>Throw</var>. The term “Reject” is used as defined in
<a href="#platform-array-object-defineownproperty">section 4.2.20.2</a> above.
</p>
<ol class="algorithm">
<li>
If <var>O</var> <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed properties</a> and
<var>P</var> is an <a class="dfnref" href="#dfn-array-index-property-name">array index property name</a>, then:
<ol>
<li>Let <var>index</var> be the result of calling ToUint32(<var>P</var>).</li>
<li>If <var>index</var> is not a <a class="dfnref" href="#dfn-supported-property-indices">supported property index</a>, then return <span class="esvalue">true</span>.</li>
<li>If <var>O</var> does not implement an interface with an <a class="dfnref" href="#dfn-indexed-property-deleter">indexed property deleter</a>, then Reject.</li>
<li>Let <var>operation</var> be the operation used to declare the indexed property deleter.</li>
<li>If <var>operation</var> was defined without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then:
<ol>
<li>Perform the steps listed in the interface description to
<a class="dfnref" href="#dfn-delete-an-existing-indexed-property">delete an existing indexed property</a>
with <var>index</var> as the index.</li>
<li>If the steps indicated that the deletion failed, then Reject.</li>
</ol>
</li>
<li>Otherwise, <var>operation</var> was defined with an identifier:
<ol>
<li>Perform the steps listed in description of <var>operation</var> with <var>index</var> as the only argument value.</li>
<li>If <var>operation</var> was declared with a <a class="dfnref" href="#dfn-return-type">return type</a> of <a class="idltype" href="#idl-boolean">boolean</a>
and the steps returned <span class="idlvalue">false</span>, then Reject.</li>
</ol>
</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</li>
<li>
If <var>O</var> <a class="dfnref" href="#dfn-support-named-properties">supports named properties</a> and
the result of calling the <a class="dfnref" href="#dfn-named-property-visibility">named property visibility algorithm</a>
with property name <var>P</var> and object <var>O</var> is true, then:
<ol>
<li>If <var>O</var> does not to implement an interface with a <a class="dfnref" href="#dfn-named-property-deleter">named property deleter</a>, then Reject.</li>
<li>Let <var>operation</var> be the operation used to declare the named property deleter.</li>
<li>If <var>operation</var> was defined without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then:
<ol>
<li>Perform the steps listed in the interface description to
<a class="dfnref" href="#dfn-delete-an-existing-named-property">delete an existing named property</a>
with <var>P</var> as the name.</li>
<li>If the steps indicated that the deletion failed, then Reject.</li>
</ol>
</li>
<li>Otherwise, <var>operation</var> was defined with an identifier:
<ol>
<li>Perform the steps listed in description of <var>operation</var> with <var>P</var> as the only argument value.</li>
<li>If <var>operation</var> was declared with a <a class="dfnref" href="#dfn-return-type">return type</a> of <a class="idltype" href="#idl-boolean">boolean</a>
and the steps returned <span class="idlvalue">false</span>, then Reject.</li>
</ol>
</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</li>
<li>If <var>O</var> has an own property with name <var>P</var>, then:
<ol>
<li>If the property is not configurable, then Reject.</li>
<li>Otherwise, remove the property from <var>O</var>.</li>
</ol>
</li>
<li>Return <span class="esvalue">true</span>.</li>
</ol>
</div>
<div id="call" class="section">
<h4>4.7.5. Platform object [[Call]] method</h4>
<p>
The internal <span class="prop">[[Call]]</span> method of every
<a class="dfnref" href="#dfn-platform-object">platform object</a> <var>O</var> that implements an <a class="dfnref" href="#dfn-interface">interface</a>
<var>I</var> with at least one <a class="dfnref" href="#dfn-legacy-caller">legacy caller</a>
<span class="rfc2119">MUST</span> behave as follows, assuming
<var>arg</var><sub>0..<var>n</var>−1</sub> is the list of argument
values passed to <span class="prop">[[Call]]</span>:
</p>
<ol class="algorithm">
<li>Initialize <var>S</var> to the <a class="dfnref" href="#dfn-effective-overload-set">effective overload</a>
for legacy callers on <var>I</var> and with argument count <var>n</var> (for the
ECMAScript language binding).</li>
<li>Set <var>S</var> to be the result of passing <var>S</var> and
<var>arg</var><sub>0..<var>n</var>−1</sub> to the
<a class="dfnref" href="#dfn-overload-resolution-algorithm">overload resolution algorithm</a>.</li>
<li>If <var>S</var> is empty, throw a <span class="estype">TypeError</span>.</li>
<li>If <var>S</var> contains more than one entry, then the call is ambiguous. Remove all but
one entry from <var>S</var> according to the rules specified in the description of
<a class="dfnref" href="#dfn-interface">interface</a> <var>I</var>, or arbitrarily
if no such rules exist.</li>
<li>Let <var>op</var> be the operation and <var>t</var><sub>0..<var>m</var>−1</sub> be the type list
of the single entry in <var>S</var>.</li>
<li>Let <var>idlarg</var><sub>0..<var>m</var>−1</sub> be a list of IDL values,
where <var>idlarg</var><sub><var>i</var></sub> is the result of
<a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>arg</var><sub><var>i</var></sub> to an IDL value.</li>
<li>Perform the actions listed in the description of legacy caller <var>op</var> with
<var>idlarg</var><sub>0..<var>m</var>−1</sub> as the argument values. These conversions
<span class="rfc2119">MUST</span> be done in order from
<var>arg</var><sub><var>0</var></sub> to <var>arg</var><sub><var>m</var>−1</sub>.</li>
<li>Return the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
the return value from those actions to an ECMAScript value of the type
<var>op</var> is declared to return (or <span class="esvalue">undefined</span>
if <var>op</var> is declared to return <a class="idltype" href="#idl-void">void</a>).</li>
</ol>
</div>
<div id="property-enumeration" class="section">
<h4>4.7.6. Property enumeration</h4>
<p>
This document does not define a complete property enumeration order
for all <a class="dfnref" href="#dfn-platform-object">platform objects</a> implementing <a class="dfnref" href="#dfn-interface">interfaces</a>
(or for <a href="#es-exception-objects">platform objects representing exceptions</a>).
However, if a platform object implements an interface that
<a class="dfnref" href="#dfn-support-indexed-properties">supports indexed</a> or
<a class="dfnref" href="#dfn-support-named-properties">named properties</a>, then
properties on the object <span class="rfc2119">MUST</span> be
enumerated in the following order:
</p>
<ol>
<li>If the object <a class="dfnref" href="#dfn-support-indexed-properties">supports indexed properties</a>, then
the object’s <a class="dfnref" href="#dfn-supported-property-indices">supported property indices</a> are
enumerated first, in numerical order.</li>
<li>If the object <a class="dfnref" href="#dfn-support-named-properties">supports named properties</a>, then
the object’s <a class="dfnref" href="#dfn-supported-property-names">supported property names</a> are
enumerated next, in the order given in the definition of the set of supported property names.</li>
<li>Finally, any enumerable own properties or properties from the object’s prototype chain are then enumerated,
in no defined order.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>Future versions of the ECMAScript specification may define a total order for property enumeration.</p>
</div>
</div>
</div>
<div id="es-user-objects" class="section">
<h3>4.8. User objects implementing interfaces</h3>
<p>
As described in <a href="#idl-objects">section 3.8 above</a>,
some <a class="dfnref" href="#dfn-interface">interfaces</a> can be
implemented in script by an ECMAScript native object.
The following cases determine whether a given native object
is considered to be a user object implementing an interface with
the required characteristics:
</p>
<ul>
<li>
If the <code>[Callback=FunctionOnly]</code> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
appears on the interface, then the native object is considered to
implement that interface only if it is a <span class="estype">Function</span>
object. The <span class="estype">Function</span> object itself is the
implementation of the <a class="dfnref" href="#dfn-operation">operation</a>
(or set of overloaded operations, if multiple operations with the same
<a class="dfnref" href="#dfn-identifier">identifier</a> are defined on
the interface).
</li>
<li>
Otherwise, if the interface is a <a class="dfnref" href="#dfn-single-operation-interface">single operation interface</a>
but the <a class="xattr" href="#Callback">[Callback]</a>
extended attribute on the interface does not have the <code>FunctionOnly</code>
argument, then any native object is considered to implement that interface.
The implementation of the operation (or set of overloaded operations) is
as follows:
<ul>
<li>If the native object is a <span class="estype">Function</span> object and the
<a class="xattr" href="#Callback">[Callback]</a> extended attribute
does not have the <code>PropertyOnly</code> argument, then the
implementation of the operation (or set of overloaded operations) is
the <span class="estype">Function</span> object itself.</li>
<li>Otherwise, the native object is not a <span class="estype">Function</span> object
or the interface did have <code>[Callback=PropertyOnly]</code> specified on it.
The implementation of the operation (or set of overloaded operations) is
the result of invoking the internal <span class="prop">[[Get]]</span> method
on the native object with a property name that is the <a class="dfnref" href="#dfn-identifier">identifier</a>
of the operation.</li>
</ul>
</li>
<li>
Otherwise, the interface is not a <a class="dfnref" href="#dfn-single-operation-interface">single operation interface</a>.
Any native object is considered to implement the interface.
For each operation declared on the interface with a given <a class="dfnref" href="#dfn-identifier">identifier</a>, the implementation
is the result of invoking <span class="prop">[[Get]]</span> on the native object with a
property name that is that identifier.
</li>
</ul>
<p>
A <a class="dfnref" href="#dfn-user-object">user object</a>’s
<a class="dfnref" href="#dfn-operation">operation</a> is called
with a list of IDL argument values <var>idlarg</var><sub>0..<var>n</var>−1</sub> by
following the algorithm below. The <dfn id="dfn-callback-this-value">callback this value</dfn>
is the value to use as the <span class="esvalue">this</span> value
when calling the native object’s operation implementation internal
<span class="prop">[[Call]]</span> method. By default, the native object
itself is used as the <a class="dfnref" href="#dfn-callback-this-value">callback this value</a>,
however this <span class="rfc2119">MAY</span> be overridden by other
specifications.
</p>
<ol class="algorithm">
<li>Let <var>O</var> be the native object that is the <a class="dfnref" href="#dfn-user-object">user object</a> implementing the <a class="dfnref" href="#dfn-interface">interface</a>.</li>
<li>Let <var>X</var> be the implementation of the operation. If <var>O</var> is a <span class="estype">Function</span> object that itself is
considered to be the implementation of the operation, then <var>X</var> is <var>O</var>. Otherwise, <var>X</var> is the result of calling
the internal <span class="prop">[[Get]]</span> method of <var>O</var> with the identifier of the operation as the property name.</li>
<li>If Type(<var>X</var>) is not Object, throw a <span class="estype">TypeError</span> exception.</li>
<li>If <var>X</var> does not implement the internal <span class="prop">[[Call]]</span> method, throw a <span class="estype">TypeError</span> exception.</li>
<li>
Let <var>arg</var><sub>0..<var>n</var>−1</sub> be a list of
ECMAScript values, where <var>arg</var><sub><var>i</var></sub> is the result
of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>idlarg</var><sub><var>i</var></sub> to an ECMAScript value.
</li>
<li>Let <var>R</var> be the result of invoking the <span class="prop">[[Call]]</span> method of <var>X</var>, providing the <a class="dfnref" href="#dfn-callback-this-value">callback this value</a> as the <span class="esvalue">this</span> value and <var>arg</var><sub>0..<var>n</var>−1</sub> as the argument values.</li>
<li>
If the operation’s return type is <a class="idltype" href="#idl-void">void</a>, return.
</li>
<li>
Return the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a>
<var>R</var> to an IDL value of the same type as the operation’s return type.
</li>
</ol>
<p>
Note that native ECMAScript objects need not have
properties corresponding to <a class="dfnref" href="#dfn-constant">constants</a>
on them to be considered as <a class="dfnref" href="#dfn-user-object">user objects</a>
implementing <a class="dfnref" href="#dfn-interface">interfaces</a> that happen
to have constants declared on them.
</p>
<p>
The value of a <a class="dfnref" href="#dfn-user-object">user object</a>’s
<a class="dfnref" href="#dfn-attribute">attribute</a> is retrieved using the
following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>O</var> be the native object that is the <a class="dfnref" href="#dfn-user-object">user object</a> implementing the <a class="dfnref" href="#dfn-interface">interface</a>.</li>
<li>Let <var>P</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of the attribute.</li>
<li>Let <var>R</var> be the result of invoking the <span class="prop">[[Get]]</span> method of <var>O</var> with property name <var>P</var>.</li>
<li>Return the result of <a class="dfnref" href="#dfn-convert-ecmascript-to-idl-value">converting</a> <var>R</var> to an IDL value of the same type as the attribute’s type.</li>
</ol>
<p>
The value of a <a class="dfnref" href="#dfn-user-object">user object</a>’s
<a class="dfnref" href="#dfn-attribute">attribute</a> is set using the
following algorithm:
</p>
<ol class="algorithm">
<li>Let <var>O</var> be the native object that is the <a class="dfnref" href="#dfn-user-object">user object</a> implementing the <a class="dfnref" href="#dfn-interface">interface</a>.</li>
<li>Let <var>P</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of the attribute.</li>
<li>Let <var>V</var> be the IDL value to be assigned to the attribute.</li>
<li>Let <var>W</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a> <var>V</var> to an ECMAScript value.</li>
<li>Invoke the <span class="prop">[[Put]]</span> method of <var>O</var> with property name <var>P</var> and value <var>W</var>.</li>
</ol>
</div>
<div id="es-exceptions" class="section">
<h3>4.9. Exceptions</h3>
<p>
For every <a class="dfnref" href="#dfn-exception">exception</a> that is not declared with the
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>,
a corresponding property <span class="rfc2119">MUST</span> exist on the
exception’s <a class="dfnref" href="#dfn-relevant-namespace-object">relevant namespace object</a>.
The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the exception,
and its value is an object called the
<dfn id="dfn-exception-interface-object">exception interface object</dfn>,
which provides access to any <a class="dfnref" href="#dfn-constant">constants</a> that
have been associated with the exception. The property has the
attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>.
</p>
<div id="es-exception-interface-object" class="section">
<h4>4.9.1. Exception interface object</h4>
<p>
The exception interface object for a given <a class="dfnref" href="#dfn-exception">exception</a>
<span class="rfc2119">MUST</span> be a <a class="dfnref" href="#dfn-function-object">function object</a>.
</p>
<p>
If any <a class="dfnref" href="#dfn-constant">constants</a> have been declared
on the exception, then the exception interface object will have
properties corresponding to these constants as described in
<a href="#es-exception-constants">section 4.9.3</a>
below.
</p>
<p>
The exception interface object <span class="rfc2119">MUST</span> also have a property named
“prototype” with attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>
whose value is an object called the <dfn id="dfn-exception-interface-prototype-object">exception interface prototype
object</dfn>. This object also provides access to the constants
that are declared on the exception.
</p>
<div id="es-exception-call" class="section">
<h5>4.9.1.1. Exception interface object [[Call]] method</h5>
<p>
The internal <span class="prop">[[Call]]</span> method of an
<a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>
<span class="rfc2119">MUST</span> behave as follows, assuming
<var>arg</var><sub>0..<var>n</var>−1</sub> is the list
of argument values passed to the function, and <var>E</var>
is the <a class="dfnref" href="#dfn-interface">exception</a>
corresponding to the exception interface object:
</p>
<ol class="algorithm">
<li>Let <var>O</var> be a new object whose <span class="prop">[[Prototype]]</span>
internal property is set to the <a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>
and whose <span class="prop">[[Class]]</span> internal property
is set to the <a class="dfnref" href="#dfn-identifier">identifier</a>
of <var>E</var>.</li>
<li>If <var>n</var> > 0, then:
<ol>
<li>Let <var>S</var> be the result of calling ToString(<var>arg</var><sub>0</sub>).</li>
<li>Call the <span class="prop">[[DefineOwnProperty]]</span> internal method of <var>O</var> passing
“message”, Property Descriptor <span class="descriptor">{ [[Value]]: <var>S</var>,
[[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>,
[[Configurable]]: <span class="esvalue">true</span> }</span>, and <span class="esvalue">false</span>
as arguments.</li>
</ol></li>
<li>Return <var>O</var>.</li>
</ol>
</div>
</div>
<div id="es-exception-interface-prototype-object" class="section">
<h4>4.9.2. Exception interface prototype object</h4>
<p>
There <span class="rfc2119">MUST</span> exist an
<a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype object</a>
for every <a class="dfnref" href="#dfn-exception">exception</a>
defined, regardless of whether the exception was declared with the
<a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
The exception interface prototype object for a particular exception has
properties that correspond to the <a class="dfnref" href="#dfn-constant">constants</a>
and <a class="dfnref" href="#dfn-exception-field">exception fields</a>
defined on the exception. These properties are described in more detail in
sections <a href="#es-exception-constants">4.9.3</a>
and <a href="#es-exception-fields">4.9.4</a>,
below.
</p>
<p>
The exception interface prototype object for a given exception <span class="rfc2119">MUST</span>
have an internal <span class="prop">[[Prototype]]</span> property whose value is as follows:
</p>
<ul>
<li>If the <a class="dfnref" href="#dfn-exception">exception</a> is declared to
<a class="dfnref" href="#dfn-inherit-exception">inherit</a> from another
exception, then the value of the internal <span class="prop">[[Prototype]]</span> property is the
<a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype object</a>
for the inherited exception.</li>
<li>Otherwise, the exception is not declared to inherit from another exception. The
value of the internal <span class="prop">[[Prototype]]</span> property
is the <span class="estype">Error</span> prototype object
(<a href="#ref-ECMA-262">[ECMA-262]</a>, section 15.11.3.1).</li>
</ul>
<div class="note"><div class="noteHeader">Note</div>
<p>
As with <a class="dfnref" href="#dfn-interface-prototype-object">interface prototype objects</a>,
<a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype objects</a>
can be accessible even if declared with <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
since it is possible to get the internal <span class="prop">[[Prototype]]</span> property
of an exception object.
</p>
</div>
<p>
There <span class="rfc2119">MUST</span> be a property named “name”
on the exception interface prototype object with attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>
and whose value is the <a class="dfnref" href="#dfn-identifier">identifier</a> of
the exception.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>If an exception is thrown with a specific <a class="dfnref" href="#dfn-exception-type">type</a>,
then the rules in <a href="#es-throwing-exceptions">section 4.11</a>
below will create a shadowing “name” property on the
exception object itself.</p>
</div>
<p>
If the <a class="xattr" href="#NoInterfaceObject">[NoInterfaceObject]</a>
extended attribute was not specified on the exception, then
there <span class="rfc2119">MUST</span> also be a property named “constructor”
on the exception interface prototype object with attributes
<span class="descriptor">{ [[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">false</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>
and whose value is a reference to the exception interface object for the exception.
</p>
</div>
<div id="es-exception-constants" class="section">
<h4>4.9.3. Constants</h4>
<p>
For each <a class="dfnref" href="#dfn-constant">constant</a> defined on
the <a class="dfnref" href="#dfn-exception">exception</a>, there
<span class="rfc2119">MUST</span> be a corresponding property on
the <a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>,
if it exists, if the <a class="dfnref" href="#dfn-identifier">identifier</a>
of the constant is not “prototype”. The property has the following characteristics:
</p>
<ul>
<li>The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the constant.</li>
<li>The value of the property is the ECMAScript value that is equivalent to the constant’s IDL value, according
to the rules in <a href="#es-type-mapping">section 4.2</a> above.</li>
<li>The property has attributes <span class="descriptor">{ [[Writable]]: <span class="esvalue">false</span>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">false</span> }</span>.</li>
</ul>
<p>
In addition, a property with the same characteristics <span class="rfc2119">MUST</span>
exist on the <a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype object</a>.
</p>
</div>
<div id="es-exception-fields" class="section">
<h4>4.9.4. Exception fields</h4>
<p>
For each <a class="dfnref" href="#dfn-exception-field">exception field</a>, there
<span class="rfc2119">MUST</span> be a corresponding property on
the <a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype object</a>,
whose characteristics are as follows:
</p>
<ul>
<li>
The name of the property is the <a class="dfnref" href="#dfn-identifier">identifier</a> of the <a class="dfnref" href="#dfn-exception-field">exception field</a>.
</li>
<li>
The property has attributes <span class="descriptor">{ [[Get]]: <var>G</var>, [[Enumerable]]: <span class="esvalue">true</span>, [[Configurable]]: <span class="esvalue">true</span> }</span>,
where <var>G</var> is the <a class="dfnref" href="#dfn-exception-field-getter">exception field getter</a>,
defined below.
</li>
<li>
The <dfn id="dfn-exception-field-getter">exception field getter</dfn> is a <span class="estype">Function</span>
object whose behavior when invoked is as follows:
<ol class="algorithm">
<li>Let <var>O</var> be the result of calling ToObject on the <span class="esvalue">this</span> value.</li>
<li>If <var>O</var> is not a <a href="#es-exception-objects">platform object representing an exception</a>
for the <a class="dfnref" href="#dfn-exception">exception</a>
on which the exception field was declared, then throw a <span class="estype">TypeError</span>.</li>
<li>
Let <var>idlValue</var> be the IDL value of <var>O</var>’s exception field.
</li>
<li>
Let <var>V</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
the <var>idlValue</var> to an ECMAScript value.
</li>
<li>
Return <var>V</var>.
</li>
</ol>
The value of the <span class="estype">Function</span> object’s “length”
property is the <span class="estype">Number</span> value <span class="esvalue">0</span>.
</li>
</ul>
</div>
</div>
<div id="es-exception-objects" class="section">
<h3>4.10. Exception objects</h3>
<p>
Objects representing particular IDL <a class="dfnref" href="#dfn-exception">exceptions</a>
are <a class="dfnref" href="#dfn-platform-object">platform objects</a>. Such objects
can only represent a single exception, and also cannot simultaneously
represent an exception and implement an <a class="dfnref" href="#dfn-interface">interface</a>.
</p>
<p>
Every platform object representing an exception in ECMAScript is associated with a global environment, just
as the <a class="dfnref" href="#dfn-initial-object">initial objects</a> are.
When an exception object is created by calling an <a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>,
either normally or as part of a <code>new</code> expression, then the global environment
of the newly created object is associated with <span class="rfc2119">MUST</span> be the same as for the
interface object itself.
</p>
<p>
The value of the internal <span class="prop">[[Prototype]]</span>
property of the exception object <span class="rfc2119">MUST</span> be the <a class="dfnref" href="#dfn-exception-interface-prototype-object">exception interface prototype object</a>
from the global environment the exception object is associated with.
</p>
<p>
The value of the internal <span class="prop">[[Class]]</span>
property of the exception object <span class="rfc2119">MUST</span>
be the <a class="dfnref" href="#dfn-identifier">identifier</a>
of the <a class="dfnref" href="#dfn-exception">exception</a>.
</p>
</div>
<div id="es-throwing-exceptions" class="section">
<h3>4.11. Throwing exceptions</h3>
<p>
First, we define the <dfn id="dfn-current-global-environment">current global environment</dfn>
as the result of running the following algorithm:
</p>
<ol class="algorithm">
<li>
Let <var>F</var> be the <span class="estype">Function</span> object used
as the <span class="esvalue">this</span> value in the top-most call
on the ECMAScript call stack where <var>F</var> corresponds to an IDL
<a class="dfnref" href="#dfn-attribute">attribute</a>,
<a class="dfnref" href="#dfn-operation">operation</a>,
<a href="#idl-indexed-properties">indexed property</a>,
<a href="#idl-named-properties">named property</a>,
<a href="#Constructor">constructor</a>,
<a class="dfnref" href="#dfn-named-constructor">named constructor</a>,
<a class="dfnref" href="#dfn-stringifier">stringifier</a>,
<a href="#es-exception-call">exception constructor</a> or
<a class="dfnref" href="#dfn-exception-field-getter">exception field getter</a>.
</li>
<li>
If <var>F</var> corresponds to an attribute, operation or stringifier, then return
the global environment associated with the
<a class="dfnref" href="#dfn-interface">interface</a> that definition appears on.
</li>
<li>
Otherwise, if <var>F</var> corresponds to an indexed or named property, then return
the global environment associated with the interface that
the index or named property getter, setter, creator or deleter was defined on.
</li>
<li>
Otherwise, if <var>F</var> is a named constructor for an interface, or is
an <a class="dfnref" href="#dfn-interface-object">interface object</a> for an
interface that is a constructor, then return the global environment
associated with that interface.
</li>
<li>
Otherwise, if <var>F</var> is an exception field getter, then return
the global environment associated with the exception on which the
exception field was defined.
</li>
<li>
Otherwise, <var>F</var> is an exception interface object that is a constructor.
Return the global environment associated with that exception.
</li>
</ol>
<p>
When an IDL <a class="dfnref" href="#dfn-exception">exception</a> <var>E</var>
<var>E</var> is to be <a class="dfnref" href="#dfn-throw">thrown</a>,
with optional type <var>T</var> and optional message <var>M</var>, the following steps
<span class="rfc2119">MUST</span> be followed:
</p>
<ol class="algorithm">
<li>Let <var>G</var> be the <a class="dfnref" href="#dfn-current-global-environment">current global environment</a>.</li>
<li>Let <var>X</var> be the <a class="dfnref" href="#dfn-exception-interface-object">exception interface object</a>
for <var>E</var> from the global environment <var>G</var>.</li>
<li>Let <var>args</var> be a list of ECMAScript
values. If the optional message <var>M</var> was specified, then this list
has a single element whose value is the result of
<a class="dfnref" href="#dfn-convert-idl-to-ecmascript-value">converting</a>
<var>M</var> to a <span class="estype">String</span> value.
Otherwise, the list is empty.</li>
<li>Let <var>O</var> be the result of running the steps in
<a href="#es-exception-call">section 4.9.1.1</a>
above with <var>X</var> as the exception and
<var>args</var> as the argument list.</li>
<li>If the optional type <var>T</var> was specified, then
call the <span class="prop">[[DefineOwnProperty]]</span> internal method of <var>O</var> passing
“name”, Property Descriptor <span class="descriptor">{ [[Value]]: <var>T</var>,
[[Writable]]: <span class="esvalue">true</span>, [[Enumerable]]: <span class="esvalue">true</span>,
[[Configurable]]: <span class="esvalue">true</span> }</span>, and <span class="esvalue">false</span>
as arguments.</li>
<li>Throw <var>O</var>.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
The above algorithm does not restrict <a class="dfnref" href="#es-exception-objects">platform objects representing exceptions</a>
propagating out of a <span class="estype">Function</span> to be
ones that are associated with the global environment
where that <span class="estype">Function</span> object originated.
For example, consider the IDL:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">exception NumberError { };
interface A {
<span class="comment">/**
* Calls computeSquareRoot on m, passing x as its argument.
*/</span>
float doComputation(MathUtils m, float x);
};
interface MathUtils {
<span class="comment">/**
* If x is negative, throws a NumberError exception. Otherwise, returns
* the square root of x.
*/</span>
float computeSquareRoot(float x);
};</code></pre></div></div>
<p>
If we pass a <span class="idltype">MathUtils</span> object from
a different global environment to doComputation, then the exception
thrown will be from that global environment:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">
var a = getA(); // An A object from this global environment.
var m = otherWindow.getMathUtils(); // A MathUtils object from a different global environment.
a instanceof Object; // Evaluates to true.
m instanceof Object; // Evaluates to false.
m instanceof otherWindow.Object; // Evaluates to true.
try {
a.doComputation(m, -1);
} catch (e) {
e instanceof NumberError; // Evaluates to false.
e instanceof otherWindow.NumberError; // Evaluates to true.
}</code></pre></div></div>
</div>
<p>
Any requirements in this document to throw an instance of an ECMAScript built-in
<span class="estype">Error</span> <span class="rfc2119">MUST</span> use
the built-in from the <a class="dfnref" href="#dfn-current-global-environment">current global environment</a>.
</p>
</div>
<div id="es-handling-exceptions" class="section">
<h3>4.12. Handling exceptions</h3>
<p>
None of the algorithms or processing requirements in the
ECMAScript language binding catch ECMAScript exceptions. Whenever
an ECMAScript <span class="esvalue">Function</span> is invoked due
to requirements in this section and that <span class="esvalue">Function</span>
ends due to an exception being thrown, that exception
<span class="rfc2119">MUST</span> propagate to the caller, and if
not caught there, to its caller, and so on.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
defines two <a class="dfnref" href="#dfn-interface">interfaces</a>
and an <a class="dfnref" href="#dfn-exception">exception</a>.
The <code>valueOf</code> attribute on <span class="idltype">ExceptionThrower</span>
is defined to throw an exception whenever an attempt is made
to get its value.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">interface Dahut {
attribute DOMString type;
};
exception SomeException {
};
interface ExceptionThrower {
<span class="comment">// This attribute always throws a SomeException and never returns a value.</span>
attribute long valueOf<!-- getraises(SomeException)-->;
};</code></pre></div></div>
<p>
Assuming an ECMAScript implementation supporting this interface,
the following code demonstrates how exceptions are handled:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">ECMAScript</span></div><div class="blockContent"><pre class="code"><code class="es-code">var d = getDahut(); <span class="comment">// Obtain an instance of Dahut.</span>
var et = getExceptionThrower(); <span class="comment">// Obtain an instance of ExceptionThrower.</span>
try {
d.type = { toString: function() { throw "abc"; } };
} catch (e) {
<span class="comment">// The string "abc" is caught here, since as part of the conversion</span>
<span class="comment">// from the native object to a string, the anonymous function</span>
<span class="comment">// was invoked, and none of the [[DefaultValue]], ToPrimitive or</span>
<span class="comment">// ToString algorithms are defined to catch the exception.</span>
}
try {
d.type = { toString: { } };
} catch (e) {
<span class="comment">// An exception is caught here, since an attempt is made to invoke</span>
<span class="comment">// [[Call]] on the native object that is the value of toString</span>
<span class="comment">// property.</span>
}
d.type = et;
<span class="comment">// An uncaught SomeException exception is thrown here, since the</span>
<span class="comment">// [[DefaultValue]] algorithm attempts to get the value of the</span>
<span class="comment">// "valueOf" property on the ExceptionThrower object. The exception</span>
<span class="comment">// propagates out of this block of code.</span></code></pre></div></div>
</div>
</div>
</div>
<div id="java-binding" class="section">
<h2>5. Java binding</h2>
<p>
This section describes how definitions written with the IDL defined in
<a href="#idl">section 3</a> correspond to particular constructs
in Java 5 <a href="#ref-JLS3">[JLS3]</a>.
</p>
<div id="java-names" class="section">
<h3>5.1. Names</h3>
<p>
Since Java has a number of reserved words in the language, some identifiers
of Java constructs corresponding to IDL definitions need to be escaped
to avoid conflicts. A name is <dfn id="dfn-java-escaped">Java escaped</dfn>
as follows:
</p>
<ul>
<li>
If the name is a Java reserved word, then the Java escaped name is the
name prefixed with a <span class="char">U+005F LOW LINE ("_")</span>
character.
</li>
<li>
Otherwise, the name is not a Java reserved word. The Java escaped name
is simply the name.
</li>
</ul>
</div>
<div class="note"><div class="noteHeader">Note</div>
<p>
At the time of publication, the list of Java reserved words is the following:
<code>abstract</code>,
<code>assert</code>,
<code>boolean</code>,
<code>break</code>,
<code>byte</code>,
<code>case</code>,
<code>catch</code>,
<code>char</code>,
<code>class</code>,
<code>const</code>,
<code>continue</code>,
<code>default</code>,
<code>do</code>,
<code>double</code>,
<code>else</code>,
<code>enum</code>,
<code>extends</code>,
<code>final</code>,
<code>finally</code>,
<code>float</code>,
<code>for</code>,
<code>goto</code>,
<code>if</code>,
<code>implements</code>,
<code>import</code>,
<code>instanceof</code>,
<code>int</code>,
<code>interface</code>,
<code>long</code>,
<code>native</code>,
<code>new</code>,
<code>package</code>,
<code>private</code>,
<code>protected</code>,
<code>public</code>,
<code>return</code>,
<code>short</code>,
<code>static</code>,
<code>strictfp</code>,
<code>super</code>,
<code>switch</code>,
<code>synchronized</code>,
<code>this</code>,
<code>throw</code>,
<code>throws</code>,
<code>transient</code>,
<code>try</code>,
<code>void</code>,
<code>volatile</code>,
<code>while</code>.
</p>
</div>
<div id="java-type-mapping" class="section">
<h3>5.2. Java type mapping</h3>
<p>
This section describes how types in the IDL map to types
in Java.
</p>
<p>
Each sub-section below describes how values of a given IDL type
are represented in Java. For each IDL type, it is described how
Java values are <dfn id="dfn-convert-java-to-idl-value">converted to an IDL value</dfn>
when passed as an argument to a Java method (corresponding
to an <a class="dfnref" href="#dfn-operation">operation</a> or
<a class="dfnref" href="#dfn-attribute">attribute</a>). Conversely,
it is described how IDL values of that type are
<dfn id="dfn-convert-idl-to-java-value">converted to Java values</dfn>
when being used as the value of a Java final variable (corresponding
to a <a class="dfnref" href="#dfn-constant">constant</a>) or when
returned from a Java method (corresponding to an operation,
attribute or <a class="dfnref" href="#dfn-exception-field">exception field</a>).
</p>
<div id="java-any" class="section">
<h4>5.2.1. any</h4>
<p>
The <a class="idltype" href="#idl-any">any</a> IDL type corresponds to a
Java <span class="javatype">java.lang.Object</span> value.
</p>
<p>
How to <a class="dfnref" href="#dfn-convert-java-to-idl-value">convert a Java value</a>
to an IDL <a class="idltype" href="#idl-any">any</a> value depends on the
type of the Java value:
</p>
<dl class="switch">
<dt>A <span class="javatype">java.lang.Boolean</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>booleanValue()</code> method on the
<span class="javatype">java.lang.Boolean</span> object to an IDL
<a class="idltype" href="#idl-boolean">boolean</a> value.
</dd>
<dt>A <span class="javatype">java.lang.Byte</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>byteValue()</code> method on the
<span class="javatype">java.lang.Byte</span> object to an IDL
<a class="idltype" href="#idl-byte">byte</a> value.
</dd>
<dt>A <span class="javatype">java.lang.Short</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>shortValue()</code> method on the
<span class="javatype">java.lang.Short</span> object to an IDL
<a class="idltype" href="#idl-short">short</a> value.
</dd>
<dt>A <span class="javatype">java.lang.Integer</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>intValue()</code> method on the
<span class="javatype">java.lang.Integer</span> object to an IDL
<a class="idltype" href="#idl-long">long</a> value.
</dd>
<dt>A <span class="javatype">java.lang.Long</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>longValue()</code> method on the
<span class="javatype">java.lang.Long</span> object to an IDL
<a class="idltype" href="#idl-long-long">long long</a> value.
</dd>
<dt>A <span class="javatype">java.lang.Float</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>floatValue()</code> method on the
<span class="javatype">java.lang.Float</span> object to an IDL
<a class="idltype" href="#idl-float">float</a> value.
</dd>
<dt>A <span class="javatype">java.lang.Double</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling the <code>doubleValue()</code> method on the
<span class="javatype">java.lang.Double</span> object to an IDL
<a class="idltype" href="#idl-float">float</a> value.
</dd>
<dt>A <span class="javatype">java.lang.String</span> object</dt>
<dd>
The IDL value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the <span class="javatype">java.lang.String</span> object to an IDL
<a class="idltype" href="#idl-DOMString">DOMString</a> value.
</dd>
<dt>An array object</dt>
<dd>
The IDL value is the <a href="#idl-sequence">IDL sequence</a> obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the Java array object to a sequence, as described in
<a href="#java-sequence">section 5.2.19</a> below.
</dd>
<dt>An object that implements a <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a></dt>
<dd>
The IDL value is the <a href="#idl-array">IDL array</a> obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the Java object to an array, as described in
<a href="#java-array">section 5.2.20</a> below.
</dd>
<dt>An object of any other class</dt>
<dd>
The IDL value is an <a class="idltype" href="#idl-object">object</a> value
that references the same object.
</dd>
<dt><span class="javavalue">null</span></dt>
<dd>
The IDL value is the <span class="idlvalue">null</span>
<span class="idltype">object?</span> value.
</dd>
</dl>
<p>
How to <a class="dfnref" href="#dfn-convert-idl-to-java-value">convert</a>
an IDL <a class="idltype" href="#idl-any">any</a> value to a Java
<span class="javatype">java.lang.Object</span> value depends on the
<a class="dfnref" href="#dfn-specific-type">specific type</a> of the IDL value:
</p>
<dl class="switch">
<dt>A value of a <a class="dfnref" href="#dfn-primitive-type">primitive type</a></dt>
<dd>
<p>
The Java value is the result of
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the IDL value of the given type to a Java value, and then passing
that value to the static method according to the following table:
</p>
<table class="vert">
<tr>
<th>IDL type</th>
<th>Method</th>
</tr>
<tr>
<td><a class="idltype" href="#idl-boolean">boolean</a></td>
<td><code>java.lang.Boolean.valueOf(boolean)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-byte">byte</a></td>
<td><code>java.lang.Byte.valueOf(byte)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-octet">octet</a></td>
<td><code>java.lang.Byte.valueOf(byte)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-short">short</a></td>
<td><code>java.lang.Short.valueOf(short)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-unsigned-short">unsigned short</a></td>
<td><code>java.lang.Short.valueOf(short)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-long">long</a></td>
<td><code>java.lang.Integer.valueOf(int)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-unsigned-long">unsigned long</a></td>
<td><code>java.lang.Integer.valueOf(int)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-long-long">long long</a></td>
<td><code>java.lang.Long.valueOf(long)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a></td>
<td><code>java.lang.Long.valueOf(long)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-float">float</a></td>
<td><code>java.lang.Float.valueOf(float)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-double">double</a></td>
<td><code>java.lang.Double.valueOf(double)</code></td>
</tr>
</table>
</dd>
<dt>An IDL value of any other type</dt>
<dd>
To obtain a Java value, the rules for converting the <a class="dfnref" href="#dfn-specific-type">specific type</a>
of the IDL <a class="idltype" href="#idl-any">any</a> value as described
in the remainder of this section are performed.
</dd>
</dl>
</div>
<div id="java-void" class="section">
<h4>5.2.2. void</h4>
<p>
The only place that the <a class="idltype" href="#idl-void">void</a> type may appear
in IDL is as the <a class="dfnref" href="#dfn-return-type">return type</a>
of an <a class="dfnref" href="#dfn-operation">operation</a>. Methods on Java objects
that implement an operation whose IDL specifies a <a class="idltype" href="#idl-void">void</a>
return type <span class="rfc2119">MUST</span> be declared to have a return type of <span class="javatype">void</span>.
</p>
</div>
<div id="java-boolean" class="section">
<h4>5.2.3. boolean</h4>
<p>
IDL <a class="idltype" href="#idl-boolean">boolean</a> values are represented by
Java <span class="javatype">boolean</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">boolean</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-boolean">boolean</a>
that represents the same truth value as the Java
<span class="javatype">boolean</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-boolean">boolean</a> value to a Java
value is the Java <span class="javatype">boolean</span> that
represents the same truth value as the IDL
<a class="idltype" href="#idl-boolean">boolean</a>.
</p>
</div>
<div id="java-byte" class="section">
<h4>5.2.4. byte</h4>
<p>
IDL <a class="idltype" href="#idl-byte">byte</a> values are
represented by Java <span class="javatype">byte</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">byte</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-byte">byte</a>
that represents the same numeric value as the Java
<span class="javatype">byte</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-byte">byte</a> value to a Java
value is the Java <span class="javatype">byte</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-byte">byte</a>.
</p>
</div>
<div id="java-octet" class="section">
<h4>5.2.5. octet</h4>
<p>
IDL <a class="idltype" href="#idl-octet">octet</a> values are represented by
Java <span class="javatype">byte</span> values. Note that while
the IDL <a class="idltype" href="#idl-octet">octet</a> type is unsigned, with a
range of [0, 255], the Java <span class="javatype">byte</span> type
is signed, with a range of [−128, 127].
</p>
<p>
<a class="dfnref" href="#dfn-convert-idl-to-java-value">Conversion</a>
of an <a class="idltype" href="#idl-octet">octet</a> value to a
<span class="javatype">byte</span> is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the <a class="idltype" href="#idl-octet">octet</a> value to convert.</li>
<li>If <var>x</var> < 128, return the <span class="javatype">byte</span> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> ≥ 128. Return the <span class="javatype">byte</span> whose value is <var>x</var> − 256.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
In Java this is the same as having the
<a class="idltype" href="#idl-octet">octet</a> value stored in
an <span class="javatype">int</span> and casting it to a
<span class="javatype">byte</span>.
</p>
</div>
<p>
<a class="dfnref" href="#dfn-convert-java-to-idl-value">Conversion</a>
of a <span class="javatype">byte</span> to an
<a class="idltype" href="#idl-octet">octet</a> is performed as
follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the <span class="javatype">byte</span> value to decode.</li>
<li>If <var>x</var> ≥ 0, return the <a class="idltype" href="#idl-octet">octet</a> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> < 0. Return the <a class="idltype" href="#idl-octet">octet</a> whose value is <var>x</var> + 256.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
In Java this is the same as performing a bit-wise AND of the
<span class="javatype">byte</span> value with the
<span class="javatype">int</span> constant
<span class="javavalue">0xff</span>.
</p>
</div>
</div>
<div id="java-short" class="section">
<h4>5.2.6. short</h4>
<p>
IDL <a class="idltype" href="#idl-short">short</a> values are
represented by Java <span class="javatype">short</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">short</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-short">short</a>
that represents the same numeric value as the Java
<span class="javatype">short</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-short">short</a> value to a Java
value is the Java <span class="javatype">short</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-short">short</a>.
</p>
</div>
<div id="java-unsigned-short" class="section">
<h4>5.2.7. unsigned short</h4>
<p>
IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> values are
represented by Java <span class="javatype">short</span> values. Note that while
the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> type is unsigned, with a
range of [0, 65535], the Java <span class="javatype">short</span> type
is signed, with a range of [−32768, 32767].
</p>
<p>
<a class="dfnref" href="#dfn-convert-idl-to-java-value">Conversion</a>
of an IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value to a
Java <span class="javatype">short</span> is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value to convert.</li>
<li>If <var>x</var> < 32768, return the Java <span class="javatype">short</span> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> ≥ 32768. Return the Java <span class="javatype">short</span> whose value is <var>x</var> − 65536.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
In Java this is the same as having the <a class="idltype" href="#idl-unsigned-short">unsigned short</a> value stored in
an <span class="javatype">int</span> and casting it to a <span class="javatype">short</span>.
</p>
</div>
<p>
<a class="dfnref" href="#dfn-convert-java-to-idl-value">Conversion</a>
of a Java <span class="javatype">short</span> to an IDL
<a class="idltype" href="#idl-unsigned-short">unsigned short</a> value
is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the Java <span class="javatype">short</span> value to decode.</li>
<li>If <var>x</var> ≥ 0, return the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> < 0. Return the IDL <a class="idltype" href="#idl-unsigned-short">unsigned short</a> whose value is <var>x</var> + 65536.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
In Java this is the same as performing a bit-wise AND of the <span class="javatype">short</span> value
with the <span class="javatype">int</span> constant <span class="javavalue">0xffff</span>.
</p>
</div>
</div>
<div id="java-long" class="section">
<h4>5.2.8. long</h4>
<p>
IDL <a class="idltype" href="#idl-long">long</a> values are
represented by Java <span class="javatype">int</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">int</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-long">long</a>
that represents the same numeric value as the Java
<span class="javatype">int</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-long">long</a> value to a Java
value is the Java <span class="javatype">int</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-short">short</a>.
</p>
</div>
<div id="java-unsigned-long" class="section">
<h4>5.2.9. unsigned long</h4>
<p>
IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> values are
represented by Java <span class="javatype">int</span> values. Note that while
the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> type is unsigned, with a
range of [0, 4294967295], the Java <span class="javatype">int</span> type
is signed, with a range of [−2147483648, 2147483647].
</p>
<p>
<a class="dfnref" href="#dfn-convert-idl-to-java-value">Conversion</a>
of an IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value to a
Java <span class="javatype">int</span> is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value to convert.</li>
<li>If <var>x</var> < 2147483648, return the Java <span class="javatype">int</span> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> ≥ 2147483648. Return the Java <span class="javatype">int</span> whose value is <var>x</var> − 4294967296.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
In Java this is the same as having the <a class="idltype" href="#idl-unsigned-long">unsigned long</a> value stored in
a Java <span class="javatype">long</span> and casting it to an <span class="javatype">int</span>.
</p>
</div>
<p>
<a class="dfnref" href="#dfn-convert-java-to-idl-value">Conversion</a>
of a Java <span class="javatype">int</span> to an IDL
<a class="idltype" href="#idl-unsigned-long">unsigned long</a> value
is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the Java <span class="javatype">int</span> value to decode.</li>
<li>If <var>x</var> ≥ 0, return the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> < 0. Return the IDL <a class="idltype" href="#idl-unsigned-long">unsigned long</a> whose value is <var>x</var> + 4294967296.</li>
</ol>
<div class="note"><div class="noteHeader">Note</div>
<p>
In Java this is the same as performing a bit-wise AND of the <span class="javatype">int</span> value
with the <span class="javatype">long</span> constant <span class="javavalue">0xffffffffL</span>.
</p>
</div>
</div>
<div id="java-long-long" class="section">
<h4>5.2.10. long long</h4>
<p>
IDL <a class="idltype" href="#idl-long-long">long long</a> values are
represented by Java <span class="javatype">long</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">long</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-long-long">long long</a>
that represents the same numeric value as the Java
<span class="javatype">long</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-long-long">long long</a> value to a Java
value is the Java <span class="javatype">long</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-long-long">long long</a>.
</p>
</div>
<div id="java-unsigned-long-long" class="section">
<h4>5.2.11. unsigned long long</h4>
<p>
IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> values are
represented by Java <span class="javatype">long</span> values. Note that while
the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> type is unsigned, with a
range of [0, 18446744073709551615], the Java <span class="javatype">long</span> type
is signed, with a range of [−9223372036854775808, 9223372036854775807].
</p>
<p>
<a class="dfnref" href="#dfn-convert-idl-to-java-value">Conversion</a>
of an IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value to a
Java <span class="javatype">long</span> is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value to convert.</li>
<li>If <var>x</var> < 18446744073709551616, return the Java <span class="javatype">long</span> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> ≥ 18446744073709551616. Return the Java <span class="javatype">long</span> whose value is <var>x</var> − 18446744073709551615.</li>
</ol>
<p>
<a class="dfnref" href="#dfn-convert-java-to-idl-value">Conversion</a>
of a Java <span class="javatype">long</span> to an IDL
<a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> value
is performed as follows:
</p>
<ol class="algorithm">
<li>Let <var>x</var> be the Java <span class="javatype">long</span> value to decode.</li>
<li>If <var>x</var> ≥ 0, return the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> whose value is <var>x</var>.</li>
<li>Otherwise <var>x</var> < 0. Return the IDL <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> whose value is <var>x</var> + 18446744073709551615.</li>
</ol>
</div>
<div id="java-float" class="section">
<h4>5.2.12. float</h4>
<p>
IDL <a class="idltype" href="#idl-float">float</a> values are
represented by Java <span class="javatype">float</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">float</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-float">float</a>
that represents the same numeric value as the Java
<span class="javatype">float</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-float">float</a> value to a Java
value is the Java <span class="javatype">float</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-float">float</a>.
</p>
</div>
<div id="java-double" class="section">
<h4>5.2.13. double</h4>
<p>
IDL <a class="idltype" href="#idl-double">double</a> values are
represented by Java <span class="javatype">double</span> values.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
a Java <span class="javatype">double</span> value to an IDL value
is the IDL <a class="idltype" href="#idl-double">double</a>
that represents the same numeric value as the Java
<span class="javatype">double</span>.
</p>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-double">double</a> value to a Java
value is the Java <span class="javatype">double</span> that
represents the same numeric value as the IDL
<a class="idltype" href="#idl-double">double</a>.
</p>
</div>
<div id="java-DOMString" class="section">
<h4>5.2.14. DOMString</h4>
<p>
IDL <a class="idltype" href="#idl-DOMString">DOMString</a> values are
represented by Java <span class="estype">java.lang.String</span> reference
values.
</p>
<p>
A Java <span class="javatype">java.lang.String</span> reference value is
<a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-DOMString">DOMString</a> value as follows:
</p>
<ul>
<li>If the value is <span class="javavalue">null</span>, then throw a <span class="javatype">java.lang.NullPointerException</span>.</li>
<li>
Otherwise, return the IDL <a class="idltype" href="#idl-DOMString">DOMString</a>
value that represents the same sequence of <a class="dfnref" href="#dfn-code-unit">code units</a> as the one
the Java <span class="javatype">java.lang.String</span> value
represents.
</li>
</ul>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-DOMString">DOMString</a> value to a Java
<span class="javatype">java.lang.String</span> value is a
<span class="javatype">java.lang.String</span>
object that represents the same sequence of characters that the
IDL <a class="idltype" href="#idl-DOMString">DOMString</a> represents.
</p>
</div>
<div id="java-object" class="section">
<h4>5.2.15. object</h4>
<p>
IDL <a class="idltype" href="#idl-object">object</a> values are
represented by Java <span class="estype">java.lang.Object</span> reference
values.
</p>
<p>
A Java <span class="javatype">java.lang.Object</span> reference value is
<a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-object">object</a> value as follows:
</p>
<ul>
<li>If the value is <span class="javavalue">null</span>, then throw a <span class="javatype">java.lang.NullPointerException</span>.</li>
<li>
Otherwise, return the IDL <a class="idltype" href="#idl-object">object</a> value that
is a reference to the same object.
</li>
</ul>
<p>
The result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
an IDL <a class="idltype" href="#idl-object">object</a> value to a Java
value is a Java <span class="javatype">java.lang.Object</span> value
that is a reference to the same object.
</p>
</div>
<div id="java-interface" class="section">
<h4>5.2.16. Interface types</h4>
<p>
IDL <a href="#idl-interface">interface type</a> values are
represented by Java references of the corresponding Java interface type.
(See <a href="#java-interfaces">section 5.4</a> below
for how IDL <a class="dfnref" href="#dfn-interface">interfaces</a> have
corresponding Java interfaces.)
</p>
<p>
A Java value <var>V</var> is
<a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a>
to an IDL <a href="#idl-interface">interface type</a> value
by running the following algorithm (where <var>I</var> is the <a class="dfnref" href="#dfn-interface">interface</a>):
</p>
<ol class="algorithm">
<li>If <var>V</var> is a <a class="dfnref" href="#dfn-platform-object">platform object</a> that implements <var>I</var>,
then return the IDL <a href="#idl-interface">interface type</a> value that represents a reference to that platform object.</li>
<li>If <var>V</var> is a <a class="dfnref" href="#dfn-user-object">user object</a> that is considered to implement <var>I</var>
according to the rules in <a href="#java-user-objects">section 5.6</a>,
then return the IDL <a href="#idl-interface">interface type</a> value that represents a reference to that user object.</li>
<li>Otherwise, <var>V</var> is an object that implements the Java interface for <var>I</var> but <var>I</var> is
not annotated with the <a class="xattr" href="#Callback">[Callback]</a> <a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>.
Throw a <span class="javatype">java.lang.IllegalArgumentException</span>.</li>
</ol>
<p>
<a class="dfnref" href="#dfn-convert-idl-to-java-value">Conversions from</a> IDL
<a href="#idl-interface">interface type</a> values to Java values
are performed in the same way as that for the IDL
<a class="idltype" href="#idl-object">object</a> type.
</p>
</div>
<div id="java-dictionary" class="section">
<h4>5.2.17. Dictionary types</h4>
<p>
IDL <a href="#idl-dictionary">dictionary type</a> values are
represented by Java references to objects of the
<span class="javatype">java.util.HashMap<java.lang.String,java.lang.Object></span> class.
Each <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a> that is
<a class="dfnref" href="#dfn-present">present</a>
corresponds to an entry in the <span class="javatype">HashMap</span>.
</p>
<p>
A Java <span class="javatype">java.util.HashMap<java.lang.String,java.lang.Object></span> reference value
<var>O</var> is
<a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a>
to an IDL <a href="#idl-dictionary">dictionary type</a> value
by running the following algorithm (where <var>D</var> is the <a class="dfnref" href="#dfn-dictionary">dictionary</a>):
</p>
<ol class="algorithm">
<li>If <var>O</var> is <span class="javavalue">null</span>, then throw a <span class="javatype">java.lang.NullPointerException</span>.</li>
<li>Let <var>dict</var> be an empty dictionary value of type <var>D</var>;
every <a class="dfnref" href="#dfn-dictionary-member">dictionary member</a>
is initially considered to be <a class="dfnref" href="#dfn-present">not present</a>.</li>
<li>Let <var>dictionaries</var> be a list consisting of <var>D</var> and all of <var>D</var>’s <a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>,
in order from least to most derived.</li>
<li>For each dictionary <var>dictionary</var> in <var>dictionaries</var>, in order:
<ol>
<li>For each dictionary member <var>member</var> declared on <var>dictionary</var>, in order:
<ol>
<li>Let <var>key</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of <var>member</var>.</li>
<li>Let <var>javaKey</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a> <var>key</var> to a <span class="javatype">java.lang.String</span>.</li>
<li>Let <var>present</var> be the result of calling the <code>containsKey</code> method on <var>O</var> with <var>javaKey</var> as the only argument.</li>
<li>If <var>present</var> is true, then:
<ol>
<li>Let <var>value</var> be the result of calling the <code>get</code> method on <var>O</var> <var>javaKey</var> as the only argument.</li>
<li>Let <var>idlValue</var> be the result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a> <var>value</var> to an IDL value whose type is the type <var>member</var> is declared to be of.</li>
<li>Set the dictionary member on <var>dict</var> with key name <var>key</var> to the value <var>idlValue</var>. This dictionary member is considered to be <a class="dfnref" href="#dfn-present">present</a>.</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
<li>Return <var>dict</var>.</li>
</ol>
<p>
An IDL <a href="#idl-dictionary">dictionary type</a> value <var>V</var> is
<a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a> to a Java
<span class="javatype">java.util.HashMap<java.lang.String,java.lang.Object></span> reference value
by running the following algorithm (where <var>D</var> is the <a class="dfnref" href="#dfn-dictionary">dictionary</a>):
</p>
<ol class="algorithm">
<li>Let <var>O</var> be a new <span class="javatype">java.util.HashMap<java.lang.String,java.lang.Object></span> object.</li>
<li>Let <var>dictionaries</var> be a list consisting of <var>D</var> and all of <var>D</var>’s <a class="dfnref" href="#dfn-inherited-dictionaries">inherited dictionaries</a>,
in order from least to most derived.</li>
<li>For each dictionary <var>dictionary</var> in <var>dictionaries</var>, in order:
<ol>
<li>For each dictionary member <var>member</var> declared on <var>dictionaries</var>, in order:
<ol>
<li>Let <var>key</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of <var>member</var>.</li>
<li>Let <var>javaKey</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a> <var>key</var> to a <span class="javatype">java.lang.String</span>.</li>
<li>If the dictionary member named <var>key</var> is <a class="dfnref" href="#dfn-present">present</a> on <var>V</var>, then:
<ol>
<li>Let <var>idlValue</var> be the value of <var>member</var> on <var>V</var>.</li>
<li>Let <var>value</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a> <var>idlValue</var> to a Java value
as if <var>value</var> were an IDL <a class="idltype" href="#idl-any">any</a> value.</li>
<li>Call the <code>put</code> method on <var>O</var> with arguments <var>javaKey</var> and <var>value</var>.</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
<li>Return <var>O</var>.</li>
</ol>
</div>
<div id="java-nullable-type" class="section">
<h4>5.2.18. Nullable types — <var>T</var>?</h4>
<p>
IDL <a class="dfnref" href="#dfn-nullable-type">nullable type</a>
values are represented with Java object references of a particular
class, as determined by the table below:
</p>
<table class="vert">
<tr>
<th>Nullable type</th>
<th>Java class</th>
<th>Method to get value</th>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-boolean">boolean</a>?</span></td>
<td><span class="javatype">java.lang.Boolean</span></td>
<td><code>booleanValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-byte">byte</a>?</span></td>
<td><span class="javatype">java.lang.Byte</span></td>
<td><code>byteValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-octet">octet</a>?</span></td>
<td><span class="javatype">java.lang.Byte</span></td>
<td><code>byteValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-short">short</a>?</span></td>
<td><span class="javatype">java.lang.Short</span></td>
<td><code>shortValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-unsigned-short">unsigned short</a>?</span></td>
<td><span class="javatype">java.lang.Short</span></td>
<td><code>shortValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-long">long</a>?</span></td>
<td><span class="javatype">java.lang.Integer</span></td>
<td><code>intValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-unsigned-long">unsigned long</a>?</span></td>
<td><span class="javatype">java.lang.Integer</span></td>
<td><code>intValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-long-long">long long</a>?</span></td>
<td><span class="javatype">java.lang.Long</span></td>
<td><code>longValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-unsigned-long-long">unsigned long long</a>?</span></td>
<td><span class="javatype">java.lang.Long</span></td>
<td><code>longValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-float">float</a>?</span></td>
<td><span class="javatype">java.lang.Float</span></td>
<td><code>floatValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-double">double</a>?</span></td>
<td><span class="javatype">java.lang.Double</span></td>
<td><code>doubleValue()</code></td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-DOMString">DOMString</a>?</span></td>
<td><span class="javatype">java.lang.String</span></td>
<td>–</td>
</tr>
<tr>
<td>Interface type <span class="idltype"><var>T</var>?</span></td>
<td>The Java interface corresponding to IDL type <var>T</var></td>
<td>–</td>
</tr>
<tr>
<td>Dictionary type <span class="idltype"><var>T</var>?</span></td>
<td><span class="javatype">java.util.HashMap<java.lang.String,java.lang.Object></span></td>
<td>–</td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-sequence">sequence<<var>T</var>></a>?</span></td>
<td><span class="javatype"><var>U</var>[]</span>, where <var>U</var> is the Java type used to represent the IDL type <var>T</var></td>
<td>–</td>
</tr>
<tr>
<td><span class="idltype"><a href="#idl-array"><var>T</var>[]</a>?</span></td>
<td>The <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a> for IDL type <var>T</var></td>
<td>–</td>
</tr>
</table>
<p>
How to <a class="dfnref" href="#dfn-convert-java-to-idl-value">convert a Java value</a>
of one of the above classes to an IDL nullable type <span class="idltype"><var>T</var>?</span>
depends on the object reference value and the type <var>T</var>:
</p>
<dl class="switch">
<dt>If the object reference value is <span class="javavalue">null</span></dt>
<dd>
The IDL value is the <span class="idlvalue">null</span> <span class="idltype"><var>T</var>?</span> value.
</dd>
<dt>If the value is not an object of the right type for <var>T</var> according to the table above</dt>
<dd>
Throw a <span class="javatype">java.lang.IllegalArgumentException</span>.
</dd>
<dt>If <var>T</var> is a <a class="dfnref" href="#dfn-primitive-type">primitive type</a></dt>
<dd>
Let <var>method</var> be the method indicated in the table above for type <var>T</var>.
The IDL value is a <span class="idltype"><var>T</var>?</span> whose value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the result of calling <var>method</var> on the object to type <var>T</var>.
</dd>
<dt>Anything else</dt>
<dd>
The IDL value is a <span class="idltype"><var>T</var>?</span> whose value is obtained
by <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
the object reference value to type <var>T</var>.
</dd>
</dl>
<p>
How to <a class="dfnref" href="#dfn-convert-idl-to-java-value">convert</a>
an IDL nullable type value to a Java value depends on
its value and the <a class="dfnref" href="#dfn-inner-type">inner type</a>:
</p>
<dl class="switch">
<dt>If the IDL value is <span class="idlvalue">null</span></dt>
<dd>
The Java value is <span class="javavalue">null</span>.
</dd>
<dt>If the IDL value is a non-<span class="idlvalue">null</span> nullable <a class="dfnref" href="#dfn-primitive-type">primitive</a> value</dt>
<dd>
<p>
The Java value is the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the IDL <a class="dfnref" href="#dfn-inner-type">inner type</a> to a Java value, and then passing
that value to the static method according to the following table,
where <var>T</var> is the IDL <a class="dfnref" href="#dfn-inner-type">inner type</a>:
</p>
<table class="vert">
<tr>
<th><var>T</var></th>
<th>Method</th>
</tr>
<tr>
<td><a class="idltype" href="#idl-boolean">boolean</a></td>
<td><code>java.lang.Boolean.valueOf(boolean)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-byte">byte</a></td>
<td><code>java.lang.Byte.valueOf(byte)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-octet">octet</a></td>
<td><code>java.lang.Byte.valueOf(byte)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-short">short</a></td>
<td><code>java.lang.Short.valueOf(short)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-unsigned-short">unsigned short</a></td>
<td><code>java.lang.Short.valueOf(short)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-long">long</a></td>
<td><code>java.lang.Integer.valueOf(int)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-unsigned-long">unsigned long</a></td>
<td><code>java.lang.Integer.valueOf(int)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-long-long">long long</a></td>
<td><code>java.lang.Long.valueOf(long)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a></td>
<td><code>java.lang.Long.valueOf(long)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-float">float</a></td>
<td><code>java.lang.Float.valueOf(float)</code></td>
</tr>
<tr>
<td><a class="idltype" href="#idl-double">double</a></td>
<td><code>java.lang.Double.valueOf(double)</code></td>
</tr>
</table>
</dd>
<dt>If the IDL value is a non-<span class="idlvalue">null</span> <span class="idltype">DOMString?</span> value</dt>
<dd>
The Java value is a <span class="javatype">java.lang.String</span> object representing
the same sequence of <a class="dfnref" href="#dfn-code-unit">code units</a> as the <span class="idltype">DOMString?</span> value.
</dd>
<dt>If the IDL value is a non-<span class="idlvalue">null</span> <span class="idltype">sequence<<var>T</var>>?</span> value</dt>
<dd>
The Java value is the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the IDL sequence value to a Java array object, as described in
<a href="#java-sequence">section 5.2.19</a> below.
</dd>
<dt>If the IDL value is a non-<span class="idlvalue">null</span> <span class="idltype"><var>T</var>[]?</span> value</dt>
<dd>
The Java value is the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the IDL array value to a Java object implementing the <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
for <var>T</var>, as described in <a href="#java-sequence">section 5.2.20</a> below.
</dd>
<dt>If the IDL value is a non-<span class="idlvalue">null</span> nullable <a href="#idl-interfaces">dictionary type</a> value</dt>
<dd>
The Java value is the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the IDL dictionary value to a Java <span class="javatype">java.util.HashMap<java.lang.String,java.lang.Object></span>
object, as described in
<a href="#java-sequence">section 5.2.17</a> above.
</dd>
<dt>If the IDL value is a non-<span class="idlvalue">null</span> nullable <a href="#idl-interfaces">interface type</a> or <span class="idltype">object?</span> value</dt>
<dd>
The Java value is a reference to the same object.
</dd>
</dl>
</div>
<div id="java-sequence" class="section">
<h4>5.2.19. Sequences — sequence<<var>T</var>></h4>
<p>
IDL <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> values are
represented by Java arrays of type <var>U</var>, where <var>U</var> is the Java type used to
represent the IDL type <var>T</var>.
</p>
<p>
A Java array <var>A</var> of type <var>U</var> is <a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> as follows:
</p>
<ol class="algorithm">
<li>If <var>A</var> is <span class="javavalue">null</span>, then throw a <span class="javatype">java.lang.NullPointerException</span>.</li>
<li>Let <var>n</var> be the length of the array <var>A</var>.</li>
<li>Initialize <var>S</var><sub>0..<var>n</var>−1</sub> to be an IDL sequence with elements of type <var>T</var>, where each element is uninitialized.</li>
<li>Initialize <var>i</var> to be 0.</li>
<li>While <var>i</var> < <var>n</var>:
<ol>
<li>Let <var>E</var> be the value value of <var>A</var> at index <var>i</var>.</li>
<li>Set <var>S</var><sub><var>i</var></sub> to the result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
<var>E</var> to an IDL value of type <var>T</var>.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
<li>Return <var>S</var>.</li>
</ol>
<p>
An IDL sequence value <var>S</var><sub>0..<var>n</var>−1</sub> of type
<a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> is
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converted</a>
to a Java array of type <var>U</var> object as follows:
</p>
<ol class="algorithm">
<li>Let <var>A</var> be a new Java array object with element type <var>U</var> and length <var>n</var>.</li>
<li>Initialize <var>i</var> to be 0.</li>
<li>While <var>i</var> < <var>n</var>:
<ol>
<li>Let <var>E</var> be the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
<var>S</var><sub><var>i</var></sub> to a Java value of type <var>U</var>.</li>
<li>Set element <var>i</var> of the array <var>A</var> to the value <var>E</var>.</li>
<li>Set <var>i</var> to <var>i</var> + 1.</li>
</ol>
</li>
<li>Return <var>A</var>.</li>
</ol>
<p>
A Java object implementing an <a class="dfnref" href="#dfn-interface">interface</a>
with an <a class="dfnref" href="#dfn-operation">operation</a> declared to return
a <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a> value
<span class="rfc2119">MUST NOT</span> return <span class="javavalue">null</span> from the corresponding method.
Similarly, a <a class="dfnref" href="#dfn-getter-method">getter method</a> for an IDL
<a class="dfnref" href="#dfn-attribute">attribute</a> <span class="rfc2119">MUST NOT</span>
return <span class="javavalue">null</span> if the attribute
is declared to be of type <a class="idltype" href="#idl-sequence">sequence<<var>T</var>></a>.
</p>
</div>
<div id="java-array" class="section">
<h4>5.2.20. Arrays — <var>T</var>[]</h4>
<p>
IDL <a class="idltype" href="#idl-array"><var>T</var>[]</a> values are
represented by Java objects implementing a particular interface,
known as the <dfn id="dfn-java-array-interface">Java array interface</dfn>,
depending on the type <var>T</var>.
</p>
<p>
For each of the <a class="dfnref" href="#dfn-primitive-type">primitive types</a>
there <span class="rfc2119">MUST</span> exist a corresponding
<a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
of the following form:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">package org.w3c.dom;
public interface <var>PrimitiveName</var>Array {
int getLength();
void setLength(int length);
<var>PrimitiveType</var> getElement(int index);
void setElement(int index, <var>PrimitiveType</var> value);
}</code></pre></div></div>
<p>
where <var>PrimitiveName</var> is the <a class="dfnref" href="#dfn-type-name">type name</a>
of the primitive type and <var>PrimitiveType</var> is the Java type used
to represent it.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
For example, the <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
for the <span class="idltype">octet[]</span> type is:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">package org.w3c.dom;
public interface OctetArray {
int getLength();
void setLength(int length);
byte getElement(int index);
void setElement(int index, byte value);
}</code></pre></div></div>
</div>
<p>
There <span class="rfc2119">MUST</span> also exist the following interface, <span class="javatype">org.w3c.dom.ObjectArray<<var>E</var>></span>:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">package org.w3c.dom;
public interface ObjectArray<E> {
int getLength();
void setLength(int length);
E getElement(int index);
void setElement(int index, E value);
}</code></pre></div></div>
<p>
This interface, parameterized by the Java type used to represent array element
type <var>T</var>, is the corresponding <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
for <var>T</var>.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
For example, the <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
for the <span class="idltype">DOMString[]?[]</span> type is
<span class="javatype">org.w3c.dom.ObjectArray<java.lang.ObjectArray<java.lang.String>></span>.
</p>
</div>
<p>
A Java object that implements a <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
represents a given <a href="#idl-array">IDL array</a> value of type <span class="idltype"><var>T</var>[]</span>.
The methods on the object that implement that interface <span class="rfc2119">MUST</span> behave as follows:
</p>
<dl>
<dt><code>getLength()</code></dt>
<dd>
<p>This method returns the current length of the <a href="#idl-array">IDL array</a> value.</p>
</dd>
<dt><code>setLength(<var>length</var>)</code></dt>
<dd>
<p>When called on an object representing a <a class="dfnref" href="#dfn-fixed-length">variable length</a>
array, this method sets the length of the array to <var>length</var>. When the array is lengthened, the new
elements are set to the IDL value that results from <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting to an IDL value</a> the
<a href="http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#96595">default value</a>
of the Java type that <var>T</var> corresponds to (<a href="#ref-JLS3">[JLS3]</a>, section 4.12.5).</p>
<p>When called on an object representing a <a class="dfnref" href="#dfn-fixed-length">fixed length</a>
array, this method throws a <span class="javatype">java.lang.UnsupportedOperationException</span>.</p>
</dd>
<dt><code>getElement(<var>index</var>)</code></dt>
<dd>
<p>This method returns the IDL value of type <var>T</var> at the represented array’s index <var>index</var>
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converted to a Java value</a>.</p>
</dd>
<dt><code>setElement(<var>index</var>, <var>value</var>)</code></dt>
<dd>
<p>When called on an object representing an array that is not <a class="dfnref" href="#dfn-read-only-array">read only</a>,
this method sets the IDL value at the represented array’s index <var>index</var> to
the result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
<var>value</var> to an IDL value of type <var>T</var>.</p>
<p>When called on an object representing an array that is <a class="dfnref" href="#dfn-read-only-array">read only</a>,
this method throws a <span class="javatype">java.lang.UnsupportedOperationException</span>.</p>
</dd>
</dl>
<p>
A Java reference value <var>O</var> for an object implementing a
<a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
is <a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a> to an
<a href="#idl-array">IDL array</a> value as follows:
</p>
<ul>
<li>If <var>O</var> is <span class="javavalue">null</span>, then throw a <span class="javatype">java.lang.NullPointerException</span>.</li>
<li>Otherwise, if <var>O</var> is an object implementing a <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
corresponding to a <a class="dfnref" href="#dfn-primitive-type">primitive type</a>, then the IDL array value
is the array value that <var>O</var> represents. The type of the IDL array value is
<span class="idltype"><var>T</var>[]</span>, where <var>T</var> is the primitive type.</li>
<li>Otherwise, if <var>O</var> is an object implementing <span class="javatype">org.w3c.dom.ObjectArray<<var>E</var>></span>,
then the IDL array value is the array value that <var>O</var> represents. The type of
the IDL array value is the IDL type that <var>E</var> corresponds to.</li>
</ul>
<p>
An <a href="#idl-array">IDL array</a> value <var>A</var> of type <span class="idltype"><var>T</var>[]</span>
is <a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a> to a
Java value whose type is an object implementing the <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
corresponding to <var>T</var>, as follows:
</p>
<ul>
<li>If <var>A</var> is already represented by an object implementing a <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>,
then the Java value is that object.</li>
<li>Otherwise, the Java value is newly created object implementing the <a class="dfnref" href="#dfn-java-array-interface">Java array interface</a>
that corresponds to <var>T</var>.</li>
</ul>
</div>
<div id="java-Date" class="section">
<h3>5.2.21. Date</h3>
<p>
IDL <a class="idltype" href="#idl-Date">Date</a> values are
represented by Java <span class="estype">java.util.Date</span> reference
values.
</p>
<p>
A Java <span class="javatype">java.lang.Date</span> reference value is
<a class="dfnref" href="#dfn-convert-java-to-idl-value">converted</a>
to an IDL <a class="idltype" href="#idl-Date">Date</a> value as follows:
</p>
<ul>
<li>If the value is <span class="javavalue">null</span>, then throw a <span class="javatype">java.lang.NullPointerException</span>.</li>
<li>Let <var>m</var> be the millisecond that the <span class="javatype">java.util.Date</span> object represents.</li>
<li>If <var>m</var> cannot be represented by an IDL <a class="idltype" href="#idl-Date">Date</a> value, then return the <span class="idlvalue">undefined</span> IDL <a class="idltype" href="#idl-Date">Date</a> value.</li>
<li>Return the IDL <a class="idltype" href="#idl-Date">Date</a> value that represents <var>m</var>.</li>
</ul>
<p>
An IDL <a class="idltype" href="#idl-Date">Date</a> value is
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converted</a>
to a <span class="javatype">java.lang.Date</span> reference value as follows:
</p>
<ul>
<li>If the value is the <span class="idlvalue">undefined</span> IDL <a class="idltype" href="#idl-Date">Date</a> value, then return
a newly created <span class="javatype">java.util.Date</span> object as if by calling <code>new java.util.Date(Long.MIN_VALUE)</code>.</li>
<li>Otherwise, return a newly created <span class="javatype">java.util.Date</span>
object that represents the same millisecond that the IDL <span class="idlvalue">Date</span> value does.</li>
</ul>
</div>
</div>
<div id="java-modules" class="section">
<h3>5.3. Modules</h3>
<p>
Every IDL <a class="dfnref" href="#dfn-module">module</a> corresponds to a Java package,
whose name is the result of taking the module’s
<a class="dfnref" href="#dfn-prefixed-name">prefixed name</a>, replacing every
<a class="dfnref" href="#dfn-double-colon">double colon</a> with “.”, and then removing the leading “.”.
</p>
<p>
Definitions inside an IDL <a class="dfnref" href="#dfn-module">module</a>
correspond to Java constructs declared to be in the package for
that module.
</p>
<div class="example"><div class="exampleHeader">Example</div>
<p>
The following <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>
will result in four Java interfaces existing:
<span class="javatype">org.w3c.dom.Document</span>,
<span class="javatype">org.w3c.dom.html.HTMLDocument</span>,
<span class="javatype">org.foo.FooDocument</span> and
<span class="javatype">org.foo.ext.ExtendedFooDocument</span>.
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">module dom {
interface Document {
<span class="comment">// ...</span>
};
};
module html {
interface HTMLDocument {
<span class="comment">// ...</span>
};
};
[Prefix=org]
module foo {
interface FooDocument {
<span class="comment">// ...</span>
};
module ext {
interface ExtendedFooDocument {
<span class="comment">// ...</span>
};
};
};</code></pre></div></div>
</div>
</div>
<!--
<div id='java-extended-attributes' class='section'>
<h3>Java-specific extended attributes</h3>
<p>
This section defines a single
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>
whose presence affects only the Java binding.
</p>
</div>
-->
<div id="java-interfaces" class="section">
<h3>5.4. Interfaces</h3>
<p>
For every supported IDL <a class="dfnref" href="#dfn-interface">interface</a>,
there <span class="rfc2119">MUST</span> exist a corresponding public Java interface
whose name is the <a class="dfnref" href="#dfn-java-escaped">Java escaped</a>
<a class="dfnref" href="#dfn-identifier">identifier</a> of the IDL interface
and which resides in the Java package corresponding to the interface’s
<a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>
(or the default package, if there is no enclosing module).
</p>
<p>
The Java interface for an interface <var>A</var> <span class="rfc2119">MUST</span> be declared to extend the following
Java interfaces:
</p>
<ul>
<li>the Java interface that corresponds to the interface from which <var>A</var>
<a class="dfnref" href="#dfn-inherit">inherits</a>, if it does inherit from one, and</li>
<li>the Java interfaces that correspond to each interface on the right-hand side of
an <a class="dfnref" href="#dfn-implements-statement">implements statement</a> where <var>A</var>
is on the left-hand side.</li>
</ul>
<p>
If the IDL interface has one or more <a class="dfnref" href="#dfn-static-operation">static operations</a>
declared on it, then there <span class="rfc2119">MUST</span> also exist
a public, abstract Java class, which also resides in the Java
package corresponding to the interface’s enclosing module
(or the default package, if there is no enclosing module).
This class is known as the <dfn id="dfn-utility-class">utility class</dfn>
for the IDL interface, and provides access to the static operations.
The name of the Java class is the concatenation
of the <a class="dfnref" href="#dfn-identifier">identifier</a> of the IDL interface
and the string “Utils”. If this name is already
the name of a Java class or interface, due to IDL definitions, then
the name of the Java class is prefixed with a single
<span class="char">U+005F LOW LINE ("_")</span> character
so as not to conflict.
</p>
<div id="java-constants" class="section">
<h4>5.4.1. Constants</h4>
<p>
For each <a class="dfnref" href="#dfn-constant">constant</a> defined on
the IDL <a class="dfnref" href="#dfn-interface">interface</a>, there
<span class="rfc2119">MUST</span> be a corresponding constant declared on the Java interface
with the following characteristics:
</p>
<ul>
<li>The constant has no modifiers.</li>
<li>
The type of the constant is the Java type that corresponds to the type of
the IDL constant, according to the rules in <a href="#java-type-mapping">section 5.2</a>
above.
</li>
<li>
The name of the constant is the <a class="dfnref" href="#dfn-java-escaped">Java escaped</a>
<a class="dfnref" href="#dfn-identifier">identifier</a> of the constant.
</li>
<li>
The value of the constant is the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the constant’s IDL value to a Java value, according to the rules
in <a href="#java-type-mapping">section 5.2</a>
above.
</li>
</ul>
</div>
<div id="java-operations" class="section">
<h4>5.4.2. Operations</h4>
<p>
The <a class="dfnref" href="#dfn-operation">operations</a> defined on
an IDL <a class="dfnref" href="#dfn-interface">interface</a>
will result in one or more methods being declared on the Java interface (for
<a class="dfnref" href="#dfn-regular-operation">regular operations</a>)
or on a Java utility class (for <a class="dfnref" href="#dfn-static-operation">static operations</a>).
</p>
<p>
For each unique identifier <var>id</var> of the
<a class="dfnref" href="#dfn-regular-operation">regular operations</a>
declared on the IDL interface:
</p>
<ul>
<li>
For each entry <<var>op</var>, <var>types</var>, <var>any</var>> in the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for <a class="dfnref" href="#dfn-regular-operation">regular operations</a>
with identifier <var>id</var> on the IDL interface and with argument
count <var>0</var> (for the Java language binding), there <span class="rfc2119">MUST</span>
exist a method on the Java interface whose name, its <dfn id="dfn-java-method-name">Java method name</dfn>,
is determined as follows:
<ol class="algorithm">
<li>Let <var>identifier</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of the <a class="dfnref" href="#dfn-operation">operation</a>.</li>
<li>Initialize <var>name</var> to be <var>identifier</var> <a class="dfnref" href="#dfn-java-escaped">Java escaped</a>.</li>
<li>If <var>name</var> is the same as the name of
one of the methods defined on <span class="javatype">java.lang.Object</span>,
then prepend a single <span class="char">U+005F LOW LINE ("_")</span> character to <var>name</var>.</li>
<li>The name of the method is <var>name</var>.</li>
</ol>
</li>
</ul>
<p>
For each unique identifier <var>id</var> of the
<a class="dfnref" href="#dfn-static-operation">static operations</a>
declared on the IDL interface:
</p>
<ul>
<li>
For each entry <<var>op</var>, <var>types</var>, <var>any</var>> in the
<a class="dfnref" href="#dfn-effective-overload-set">effective overload set</a>
for <a class="dfnref" href="#dfn-static-operation">static operations</a>
with identifier <var>id</var> on the IDL interface and with argument
count <var>0</var> (for the Java language binding), there <span class="rfc2119">MUST</span>
exist a method on the <a class="dfnref" href="#dfn-utility-class">utility class</a>
whose name is its <a class="dfnref" href="#dfn-java-method-name">Java method name</a>
and which is declared with modifiers <code>public static final</code>.
</li>
</ul>
<p>
For each identifierless <a class="dfnref" href="#dfn-special-operation">special operation</a>
declared on the IDL interface of the following types,
</p>
<ul>
<li><a href="#dfn-indexed-property-getter">indexed property getter</a></li>
<li><a href="#dfn-indexed-property-setter">indexed property setter</a></li>
<li><a href="#dfn-indexed-property-creator">indexed property creator</a></li>
<li><a href="#dfn-indexed-property-deleter">indexed property deleter</a></li>
<li><a href="#dfn-named-property-getter">named property getter</a></li>
<li><a href="#dfn-named-property-setter">named property setter</a></li>
<li><a href="#dfn-named-property-creator">named property creator</a></li>
<li><a href="#dfn-named-property-deleter">named property deleter</a></li>
<li><a href="#dfn-legacy-caller">legacy caller</a></li>
</ul>
<p>
there <span class="rfc2119">MUST</span> exist a method on the Java interface whose
name is determined based on the type of special operation:
</p>
<table class="vert">
<tr><th>Type</th><th>Name</th></tr>
<tr><td>indexed or named property getter</td><td>“_get”</td></tr>
<tr><td>indexed or named property setter</td><td>“_set”</td></tr>
<tr><td>indexed or named property creator</td><td>“_create”</td></tr>
<tr><td>indexed or named property deleter</td><td>“_delete”</td></tr>
<tr><td>caller</td><td>“_call”</td></tr>
</table>
<p>
For all of the above operations – regular, static, and the abovementioned
special operations – their corresponding Java methods have the following
characteristics:
</p>
<ul>
<li>
The return type of the method is the Java type that corresponds to the operation
<a class="dfnref" href="#dfn-return-type">return type</a>, according to the rules in
<a href="#java-type-mapping">section 5.2</a> above.
</li>
<li>
The method has an argument for each type, in order, that is in <var>types</var>. The type of
method argument <var>j</var> is the Java type that corresponds to the IDL type <var>types</var><sub><var>j</var></sub>,
according to the rules in <a href="#java-type-mapping">section 5.2</a>
above. If the length of <var>types</var> is the length of the
argument list <var>op</var> is declared with, and <var>op</var> is a
<a class="dfnref" href="#dfn-variadic-operation">variadic operation</a>,
then the method is a <em>variable arity method</em> (<a href="#ref-JLS3">[JLS3]</a>,
section 8.4.1).
</li>
<!--
<li>
If <var>op</var> has IDL <a class='dfnref' href='#dfn-exception'>exceptions</a>
listed in the <a class='sym' href='#prod-Raises'>Raises</a> clause, then the
method <span class='rfc2119'>SHOULD</span> have a <code>throws</code>
clause specifying all of the Java exception classes that correspond
to those IDL exceptions, and no others. Otherwise, if <var>op</var> has no
exceptions listed in the <a class='sym' href='#prod-Raises'>Raises</a> clause,
then the method <span class='rfc2119'>SHOULD NOT</span> have a <code>throws</code>
clause.
</li>
-->
<li>
An implementation of this method <span class="rfc2119">MUST</span>
perform the following steps:
<ol class="algorithm">
<li>
Let <var>arg</var><sub>0..<var>n</var>−1</sub> be the list
of Java argument values passed to the method.
</li>
<li>
Let <var>idlarg</var><sub>0..<var>n</var>−1</sub> be
a list of IDL values, where <var>idlarg</var><sub><var>i</var></sub>
is the result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
<var>arg</var><sub><var>i</var></sub> to an IDL value
of the type that the <var>i</var>th argument is declared to be.
</li>
<li>
Let <var>R</var> be the result of performing the actions listed in the description of the operation
<var>op</var> with <var>idlarg</var><sub>0..<var>n</var>−1</sub>
as the argument values.
</li>
<li>
If the actions performed in the previous step resulted in an
exception being thrown, then allow that exception to propagate
out from this algorithm. Otherwise, return the result of
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
<var>R</var> to a Java value of the type <var>op</var>
is declared to return.
</li>
</ol>
</li>
</ul>
</div>
<div id="java-attributes" class="section">
<h4>5.4.3. Attributes</h4>
<p>
For each <a class="dfnref" href="#dfn-attribute">attribute</a> defined on
the IDL <a class="dfnref" href="#dfn-interface">interface</a> that does not
<a class="dfnref" href="#dfn-inherit-getter">inherit its getter</a>, there
<span class="rfc2119">MUST</span> be a corresponding <dfn id="dfn-getter-method">getter method</dfn>
declared on the Java interface with the following characteristics:
</p>
<ul>
<li>The method has no modifiers.</li>
<li>
The return type of the method is the Java type that corresponds to the attribute type,
according to the rules in <a href="#java-type-mapping">section 5.2</a>
above.
</li>
<li>
The name of the method is determined as follows:
<ol class="algorithm">
<li>Let <var>identifier</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of the <a class="dfnref" href="#dfn-attribute">attribute</a>.</li>
<li>Initialize <var>name</var> to be the string “get”.</li>
<li>Let <var>ucIdentifier</var> be <var>identifier</var> with first character uppercased,
as if passed to the <code>java.lang.Character.toUpperCase()</code> method.</li>
<li>If there exists another attribute on the <a class="dfnref" href="#dfn-interface">interface</a>
with identifier <var>ucIdentifier</var>, then append a single <span class="char">U+005F LOW LINE ("_")</span>
character to <var>name</var>.</li>
<li>Append <var>ucIdentifier</var> to <var>name</var>.</li>
<li>If there exists a <a class="dfnref" href="#dfn-constant">constant</a> or
<a class="dfnref" href="#dfn-operation">operation</a> on the interface with
identifier <var>name</var>, or if <var>name</var> is the same as the name of
one of the methods defined on <span class="javatype">java.lang.Object</span>,
then prepend a single <span class="char">U+005F LOW LINE ("_")</span> character to <var>name</var>.</li>
<li>The name of the method is <var>name</var>.</li>
</ol>
</li>
<li>
The method has no arguments.
</li>
<li>
An implementation of this method <span class="rfc2119">MUST</span>
perform the following steps:
<ol class="algorithm">
<li>
Let <var>V</var> be the IDL value that results from
performing the actions listed for getting the corresponding attribute
in the description of the interface.
</li>
<li>
If the actions performed in the previous step resulted in an
exception being thrown, then allow that exception to propagate
out from this algorithm. Otherwise, return the result of
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
<var>V</var> to a Java value of the type <var>op</var>
is declared to return.
</li>
</ol>
</li>
</ul>
<!--
<p>
In addition, the method <span class='rfc2119'>SHOULD</span> have a <code>throws</code>
clause specifying all of the Java exception classes that correspond to the IDL
<a class='dfnref' href='#dfn-exception'>exceptions</a> that are listed in the
<a class='sym' href='#prod-GetRaises'>GetRaises</a> clause of the attribute, and no others.
</p>
-->
<p>
For each attribute defined on the IDL interface that is not
<a class="dfnref" href="#dfn-read-only">read only</a>, there
<span class="rfc2119">MUST</span> be a corresponding <dfn id="dfn-setter-method">setter method</dfn>
declared on the Java interface with the following characteristics:
</p>
<ul>
<li>The method has no modifiers.</li>
<li>
The return type of the method is <span class="javatype">void</span>.
</li>
<li>
The name of the method is determined as follows:
<ol class="algorithm">
<li>Let <var>identifier</var> be the <a class="dfnref" href="#dfn-identifier">identifier</a> of the <a class="dfnref" href="#dfn-attribute">attribute</a>.</li>
<li>Initialize <var>name</var> to be the string “set”.</li>
<li>Let <var>ucIdentifier</var> be <var>identifier</var> with first character uppercased,
as if passed to the <code>java.lang.Character.toUpperCase()</code> method.</li>
<li>If there exists another attribute on the <a class="dfnref" href="#dfn-interface">interface</a>
with identifier <var>ucIdentifier</var>, then append a single <span class="char">U+005F LOW LINE ("_")</span>
character to <var>name</var>.</li>
<li>Append <var>ucIdentifier</var> to <var>name</var>.</li>
<li>If there exists a <a class="dfnref" href="#dfn-constant">constant</a> or
<a class="dfnref" href="#dfn-operation">operation</a> on the interface with
identifier <var>name</var>, or if <var>name</var> is the same as the name of
one of the methods defined on <span class="javatype">java.lang.Object</span>,
then prepend a single <span class="char">U+005F LOW LINE ("_")</span> character to <var>name</var>.</li>
<li>The name of the method is <var>name</var>.</li>
</ol>
</li>
<li>
The method has a single argument whose type is the Java type that corresponds
to the attribute type, according to the rules in
<a href="#java-type-mapping">section 5.2</a> above.
</li>
<li>
An implementation of this method <span class="rfc2119">MUST</span>
perform the following steps:
<ol class="algorithm">
<li>
Let <var>arg</var> be the Java value that was passed as the
argument to the method.
</li>
<li>
Let <var>idlarg</var> be the result of <a class="dfnref" href="#dfn-convert-java-to-idl-value">converting</a>
<var>arg</var> to an IDL value of the type the attribute is declared to be.
</li>
<li>
Perform the actions for setting the corresponding attribute
with the value <var>idlarg</var> listed in the description of the interface.
</li>
<li>
If the actions performed in the previous step resulted in an
exception being thrown, then allow that exception to propagate
out from this algorithm.
</li>
</ol>
</li>
</ul>
<!--
<p>
In addition, the method <span class='rfc2119'>SHOULD</span> have a <code>throws</code>
clause specifying all of the Java exception classes that correspond to the IDL
exceptions that are listed in the
<a class='sym' href='#prod-SetRaises'>SetRaises</a> clause of the attribute, and no others.
</p>
-->
<!--
<p>
For each attribute defined on the IDL interface that is
<a class='dfnref' href='#dfn-read-only'>read only</a> and is declared with the
<a class='xattr' href='#PutForwards'>[PutForwards]</a>
<a class='dfnref' href='#dfn-extended-attribute'>extended attribute</a>, there
<span class='rfc2119'>MUST</span> be a corresponding setter method
declared on the Java interface with the following characteristics:
</p>
<ul>
<li>The method has no modifiers.</li>
<li>
The return type of the method is <span class='javatype'>void</span>.
</li>
<li>
The tentative name of the method is a
<span class='char'>U+0073 LATIN SMALL S ("s")</span> character, followed by a
<span class='char'>U+0065 LATIN SMALL E ("e")</span> character, followed by a
<span class='char'>U+0074 LATIN SMALL T ("t")</span> character, followed by
the first character of the identifier of the attribute
uppercased (as if passed to the <code>java.lang.Character.toUpperCase()</code>
method), followed by the remaining characters from the identifier of the attribute.
The name of the method is the Java escaped
tenative name of the method prefixed with the smallest number
of <span class='char'>U+005F LOW LINE ("_")</span> characters required to make the
name not equal to the name of a constant or method declared on the Java interface or one of the
methods on the <span class='javatype'>java.lang.Object</span> class.
</li>
<li>
The method has a single argument whose type is the Java type that corresponds
to the type of the attribute identified by the <a class='xattr' href='#PutForwards'>[PutForwards]</a>
extended attribute on the interface type that
this attribute is declared to be of, according to the rules in
<a href='#java-type-mapping'>section <?sref java-type-mapping?></a> <?sdir java-type-mapping?>.
</li>
<li>
An implementation of this method <span class='rfc2119'>MUST</span>
perform the following steps:
<ol class='algorithm'>
<li>
Let <var>arg</var> be the Java value that was passed as the
argument to the method.
</li>
<li>
Let <var>idlarg</var> be the result of <a class='dfnref' href='#dfn-convert-java-to-idl-value'>converting</a>
<var>arg</var> to an IDL value of the type the forwarded-to attribute
is declared to be.
</li>
<li x:step='a'>
Perform the actions for setting the corresponding attribute
with the value <var>idlarg</var> listed in the description of the interface.
</li>
<li>
If the actions performed in the previous step resulted in an
exception being thrown, then allow that exception to propagate
out from this algorithm.
</li>
</ol>
</li>
</ul>
<p>
In addition, the method <span class='rfc2119'>SHOULD</span> have a <code>throws</code>
clause specifying all of the Java exception classes that correspond to the IDL
exceptions that are listed in the
<a class='sym' href='#prod-SetRaises'>SetRaises</a> clause of the attribute
identified by the <a class='xattr' href='#PutForwards'>[PutForwards]</a>
extended attribute on the interface type that
this attribute is declared to be of, and no others.
</p>
-->
</div>
</div>
<div id="java-platform-objects" class="section">
<h3>5.5. Platform objects implementing interfaces</h3>
<p>
A Java <a class="dfnref" href="#dfn-platform-object">platform object</a> that implements an IDL <a class="dfnref" href="#dfn-interface">interface</a>
<span class="rfc2119">MUST</span> be of a Java class which implements the Java interface
that corresponds to the IDL interface.
</p>
<p>
If the IDL interface has a <a class="dfnref" href="#dfn-stringifier">stringifier</a>,
the <code>String toString()</code> method
<span class="rfc2119">MUST</span> be overridden to allow
stringification of the object as required by the IDL
interface. If the <code>stringifier</code> keyword
was used on an <a class="dfnref" href="#dfn-attribute">attribute</a> <var>A</var>,
then, assuming <var>O</var> is the object on which
the method was invoked, the behavior of the overridden
<code>toString</code> method <span class="rfc2119">MUST</span>
be as follows:
</p>
<ol class="algorithm">
<li>
Let <var>R</var> be the result of invoking the <a class="dfnref" href="#dfn-getter-method">getter
method</a> on <var>O</var> that corresponds to the IDL
<a class="dfnref" href="#dfn-attribute">attribute</a>
<var>A</var>.
</li>
<li>Return <var>R</var>.</li>
</ol>
<p>
Otherwise, if the <code>stringifier</code> keyword
was used on an <a class="dfnref" href="#dfn-operation">operation</a>
<var>O</var> with an <a class="dfnref" href="#dfn-identifier">identifier</a>,
then, assuming <var>O</var> is the object on which
the method was invoked, the behavior of the overridden
<code>toString</code> method <span class="rfc2119">MUST</span>
be as follows:
</p>
<ol class="algorithm">
<li>
Let <var>R</var> be the result of invoking the method on <var>O</var> that corresponds to the IDL
<a class="dfnref" href="#dfn-operation">operation</a>
<var>O</var>, passing no arguments.
</li>
<li>Return <var>R</var>.</li>
</ol>
<p>
Otherwise, if the <code>stringifier</code> keyword
was used on an <a class="dfnref" href="#dfn-operation">operation</a>
without an <a class="dfnref" href="#dfn-identifier">identifier</a>, then
the behavior of the overridden <code>toString()</code>
method is the <a class="dfnref" href="#dfn-stringification-behavior">stringification behavior</a>
of the IDL interface, as described in the prose for the IDL interface.
</p>
</div>
<div id="java-user-objects" class="section">
<h3>5.6. User objects implementing interfaces</h3>
<p>
A Java <a class="dfnref" href="#dfn-user-object">user object</a> that implements an IDL <a class="dfnref" href="#dfn-interface">interface</a>
<span class="rfc2119">MUST</span> be of a Java class that implements the Java interface
that corresponds to the IDL interface, either by implementing the interface directly
on that class or by inheriting from another class that implements the interface.
</p>
<div class="note"><div class="noteHeader">Note</div>
<p>For example, with the following IDL:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">[Callback]
interface Base {
void f();
};
[Callback]
interface Derived : Base {
void g();
};</code></pre></div></div>
<p>the Java implementation would provide the following interfaces:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">public interface Base {
void f();
}
public interface Derived extends Base {
void g();
}</code></pre></div></div>
<p>and <a class="dfnref" href="#dfn-user-object">user objects</a> implementing <span class="idltype">Derived</span>
could be defined like the following:</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code"><span class="comment">// Directly implementing the interface</span>
class DerivedImpl1 implements Derived {
public void f() { ... }
public void g() { ... }
}
<span class="comment">// Inheriting from a class that implements the interface</span>
class DerivedImpl2 extends DerivedImpl1 { }</code></pre></div></div>
</div>
</div>
<div id="java-exceptions" class="section">
<h3>5.7. Exceptions</h3>
<p>
For every IDL <a class="dfnref" href="#dfn-exception">exception</a>, there
<span class="rfc2119">MUST</span> exist a corresponding Java class
whose name is the <a class="dfnref" href="#dfn-java-escaped">Java escaped</a>
<a class="dfnref" href="#dfn-identifier">identifier</a> of the IDL exception and which
resides in the Java package corresponding to the exception’s
<a class="dfnref" href="#dfn-enclosing-module">enclosing module</a>.
</p>
<p>
The Java class <span class="rfc2119">MUST</span> have only the <code>public</code> modifier.
If the IDL exception <a class="dfnref" href="#dfn-inherit-exception">inherits</a> from another
exception, then the Java class <span class="rfc2119">MUST</span> be declared to extend
the Java class corresponding to that inherited exception. Otherwise, the Java class <span class="rfc2119">MUST</span>
be declared to extend <span class="javatype">java.lang.RuntimeException</span>.
</p>
<p>
The class <span class="rfc2119">MUST</span> also have constructors and methods with definitions as follows,
where <var>ExceptionName</var> is the name of the class:
</p>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">Java</span></div><div class="blockContent"><pre class="code"><code class="java-code">public <var>ExceptionName</var>() {
}
public <var>ExceptionName</var>(String message) {
super(message);
}
public <var>ExceptionName</var>(String message, Throwable cause) {
super(message, cause);
}
public <var>ExceptionName</var>(Throwable cause) {
super(cause);
}</code></pre></div></div>
<div id="java-exception-constants" class="section">
<h4>5.7.1. Constants</h4>
<p>
For each <a class="dfnref" href="#dfn-constant">constant</a> defined on the
exception, there
<span class="rfc2119">MUST</span> be a corresponding constant declared on the Java class
with the following characteristics:
</p>
<ul>
<li>The constant has no modifiers.</li>
<li>
The type of the constant is the Java type that corresponds to the type of
the IDL constant, according to the rules in <a href="#java-type-mapping">section 5.2</a>
above.
</li>
<li>
The name of the constant is the <a class="dfnref" href="#dfn-java-escaped">Java escaped</a>
<a class="dfnref" href="#dfn-identifier">identifier</a> of the constant.
</li>
<li>
The value of the constant is the result of <a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
the constant’s IDL value to a Java value, according to the rules
in <a href="#java-type-mapping">section 5.2</a>
above.
</li>
</ul>
</div>
<div id="java-exception-fields" class="section">
<h4>5.7.2. Exception fields</h4>
<p>
For each <a class="dfnref" href="#dfn-exception-field">exception field</a> defined on the
<a class="dfnref" href="#dfn-exception">exception</a>, there
<span class="rfc2119">MUST</span> be a corresponding instance variable declared on the Java class
with the following characteristics:
</p>
<ul>
<li>The instance variable has only the modifier <code>public</code>.</li>
<li>
The type of the instance variable is the Java type that corresponds to the type of
the IDL exception field, according to the rules in <a href="#java-type-mapping">section 5.2</a>
above.
</li>
<li>
The name of the instance variable is the <a class="dfnref" href="#dfn-java-escaped">Java escaped</a>
<a class="dfnref" href="#dfn-identifier">identifier</a> of the exception field.
</li>
<li>
The instance variable is not declared with an initializer.
</li>
</ul>
</div>
</div>
<div id="java-exception-throwing" class="section">
<h4>5.8. Throwing exceptions</h4>
<p>
When an <a class="dfnref" href="#dfn-exception">exception</a> of type
<var>E</var> is to be <a class="dfnref" href="#dfn-throw">thrown</a>,
with an optional message <var>M</var>, the following steps
<span class="rfc2119">MUST</span> be followed:
</p>
<ol class="algorithm">
<li>Let <var>C</var> be the corresponding Java class for <var>E</var>.</li>
<li>Let <var>O</var> be the result of constructing a new object of class <var>C</var>.
When invoking the constructor, the result of
<a class="dfnref" href="#dfn-convert-idl-to-java-value">converting</a>
<var>M</var> to a <span class="javatype">java.lang.String</span> object to
is used as the constructor’s sole argument, if <var>M</var> was specified.
If <var>M</var> was not specified, no arguments are passed to the constructor.</li>
<li>Throw <var>O</var>.</li>
</ol>
</div>
</div>
<div id="common" class="section">
<h2>6. Common definitions</h2>
<p>
This section specifies some common definitions that all
<a class="dfnref" href="#dfn-conforming-implementation">conforming implementations</a>
<span class="rfc2119">MUST</span> support.
</p>
<div id="common-DOMTimeStamp" class="section">
<h3>6.1. DOMTimeStamp</h3>
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">typedef unsigned long long DOMTimeStamp;</code></pre></div></div>
<p>
The <span class="idltype">DOMTimeStamp</span> type is used for representing
a number of milliseconds, either as an absolute time (relative to some epoch)
or as a relative amount of time. Specifications that use this type will need
to define how the number of milliseconds is to be interpreted.
</p>
</div>
</div>
<div id="extensibility" class="section">
<h2>7. Extensibility</h2>
<p class="norm">This section is informative.</p>
<p>
Extensions to language binding requirements can be specified
using <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
that do not conflict with those defined in this document. Extensions for
private, project-specific use should not be included in
<a class="dfnref" href="#dfn-idl-fragment">IDL fragments</a>
appearing in other specifications. It is recommended that extensions
that are required for use in other specifications be coordinated
with the group responsible for work on <cite>Web IDL</cite>, which
at the time of writing is the
<a href="http://www.w3.org/2008/webapps/">W3C Web Applications Working Group</a>,
for possible inclusion in a future version of this document.
</p>
<p>
Extensions to any other aspect of the IDL language are
strongly discouraged.
</p>
</div>
<div id="referencing" class="section">
<h2>8. Referencing this specification</h2>
<p class="norm">This section is informative.</p>
<p>
It is expected that other specifications that define DOM interfaces
using a <a class="dfnref" href="#dfn-conforming-idl-fragment">conforming
IDL fragment</a> will reference this specification. It is suggested
that those specifications include a sentence such as the following,
to indicate that the IDL is to be interpreted as described in this
specification:
</p>
<blockquote>
<p>
The IDL fragment in Appendix A of this specification must be interpreted
as required for <em>conforming IDL fragments</em>, as described in the
“Web IDL” specification. <a class="placeholder">[WEBIDL]</a>
</p>
</blockquote>
<p>
In addition, it is suggested that the conformance class for user
agents in referencing specifications be linked to the
<a class="dfnref" href="#dfn-conforming-implementation">conforming
implementation</a> class from this specification:
</p>
<blockquote>
<p>
A conforming FooML user agent must also be a
<em>conforming implementation</em> of the IDL fragment in Appendix A
of this specification, as described in the
“Web IDL” specification. <a class="placeholder">[WEBIDL]</a>
</p>
</blockquote>
</div>
<div id="acknowledgements" class="section">
<h2>9. Acknowledgements</h2>
<p class="norm">This section is informative.</p>
<p>
The editor would like to thank the following people for contributing
to this specification:
Glenn Adams,
David Andersson,
L. David Baron,
Robin Berjon,
Giovanni Campagna,
Brendan Eich,
Gorm Haug Eriksen,
David Flanagan,
Aryeh Gregor,
Marcin Hanclik,
Jed Hartman,
Dominique Hazaël-Massieux,
Ian Hickson,
Björn Höhrmann,
Dimitry Golubovsky,
Kartikaya Gupta,
James Graham,
Aryeh Gregor,
Magnus Kristiansen,
Mark Miller,
Lachlan Hunt,
Oliver Hunt,
Jim Jewett,
Anne van Kesteren,
Jim Ley,
Travis Leithead,
Kevin Lindsey,
Ms2ger,
Andrew Oakley,
岡坂 史紀 (Shiki Okasaka),
Simon Pieters,
Andrei Popescu,
Tim Renouf,
Jonas Sicking,
Garrett Smith,
Geoffrey Sneddon,
Josh Soref,
Maciej Stachowiak,
Jeff Walden,
Allen Wirfs-Brock,
Collin Xu and
Boris Zbarsky.
</p>
<p>
Special thanks also go to Sam Weinig for maintaining this document
while the editor was unavailable to do so.
</p>
</div>
</div>
<div id="appendices">
<div id="idl-grammar" class="section">
<h2>A. IDL grammar</h2>
<p>
This section defines an LL(1) grammar whose start symbol,
<a class="sym" href="#prod-Definitions">Definitions</a>, matches an
entire <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>.
</p>
<p>
Each production in the grammar has on its right hand side either a
non-zero sequence of terminal and non-terminal symbols, or an
epsilon (ε) which indicates no symbols. Symbols that begin with
an uppercase letter are non-terminal symbols. Symbols within quotes
are terminal symbols that are matched with the exact text between
the quotes. Symbols that begin with a lowercase letter are terminal
symbols that are matched by the regular expressions (using Perl 5 regular
expression syntax <a href="#ref-PERLRE">[PERLRE]</a>) as follows:
</p>
<table class="grammar">
<tr>
<td id="prod-integer" class="sym">integer</td>
<td class="regex">=</td>
<td class="regex">-?(0([0-7]*|[Xx][0-9A-Fa-f]+)|[1-9][0-9]*)</td>
</tr>
<tr>
<td id="prod-float" class="sym">float</td>
<td class="regex">=</td>
<td class="regex">-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)</td>
</tr>
<tr>
<td id="prod-identifier" class="sym">identifier</td>
<td class="regex">=</td>
<td class="regex">[A-Z_a-z][0-9A-Z_a-z]*</td>
</tr>
<tr>
<td id="prod-string" class="sym">string</td>
<td class="regex">=</td>
<td class="regex">"[^"]*"</td>
</tr>
<tr>
<td id="prod-whitespace" class="sym">whitespace</td>
<td class="regex">=</td>
<td class="regex">[\t\n\r ]+|[\t\n\r ]*((//.*|/\*.*?\*/)[\t\n\r ]*)+</td>
</tr>
<tr>
<td id="prod-other" class="sym">other</td>
<td class="regex">=</td>
<td class="regex">[^\t\n\r 0-9A-Z_a-z]</td>
</tr>
</table>
<p>
The tokenizer operates on a sequence of Unicode characters
<a href="#ref-UNICODE">[UNICODE]</a>.
When tokenizing, the longest possible match <span class="rfc2119">MUST</span> be used. For example, if the input
text is “<span class="input">a1</span>”, it is tokenized as a single <span class="sym">identifier</span>,
and not as a separate <span class="sym">identifier</span> and <span class="sym">integer</span>.
If the longest possible match could match both an <span class="sym">identifier</span> and
one of the quoted terminal symbols from the grammar, it <span class="rfc2119">MUST</span> be tokenized as the quoted
terminal symbol. Thus, the input text “<span class="input">long</span>” is tokenized as the quoted terminal symbol
<span class="sym">"long"</span> rather than an <span class="sym">identifier</span> called “long”.
</p>
<p>
The IDL syntax is case sensitive, both for the quoted terminal symbols
used in the grammar and the values used for
<span class="sym">identifier</span> terminals. Thus, for
example, the input text “<span class="input">Const</span>” is tokenized as
an <span class="sym">identifier</span> rather than the quoted
terminal symbol <span class="sym">"const"</span>, an
<a class="dfnref" href="#dfn-interface">interface</a> with
<a class="dfnref" href="#dfn-identifier">identifier</a>
“A” is distinct from one named “a”, and an
<a class="dfnref" href="#dfn-extended-attribute">extended attribute</a>
<span class="xattr">[constructor]</span> will not be recognized as
the <a class="xattr" href="#Constructor">[Constructor]</a>
extended attribute.
</p>
<p>
Implicitly, the <span class="sym">whitespace</span> terminal is allowed between every terminal
in the input text being parsed. Such <span class="sym">whitespace</span> terminals, which
actually encompass both whitespace and comments, are ignored while parsing.
</p>
<p>
The following LL(1) grammar, starting with <a class="sym" href="#prod-Definitions">Definitions</a>,
matches an <a class="dfnref" href="#dfn-idl-fragment">IDL fragment</a>:
</p>
<table class="grammar"><tr id="prod-Definitions"><td><span class="prod-number">[1]</span></td><td><a class="sym" href="#proddef-Definitions">Definitions</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Definition">Definition</a> <a class="sym" href="#prod-Definitions">Definitions</a> <br /> |
ε</span></td></tr><tr id="prod-Definition"><td><span class="prod-number">[2]</span></td><td><a class="sym" href="#proddef-Definition">Definition</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-NormalDefinition">NormalDefinition</a> <br /> |
<a class="sym" href="#prod-PartialInterface">PartialInterface</a></span></td></tr><tr id="prod-NormalDefinition"><td><span class="prod-number">[3]</span></td><td><a class="sym" href="#proddef-NormalDefinition">NormalDefinition</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Module">Module</a> <br /> |
<a class="sym" href="#prod-Interface">Interface</a> <br /> |
<a class="sym" href="#prod-Dictionary">Dictionary</a> <br /> |
<a class="sym" href="#prod-Exception">Exception</a> <br /> |
<a class="sym" href="#prod-Typedef">Typedef</a> <br /> |
<a class="sym" href="#prod-ImplementsStatement">ImplementsStatement</a></span></td></tr><tr id="prod-Module"><td><span class="prod-number">[4]</span></td><td><a class="sym" href="#proddef-Module">Module</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"module" <a class="sym" href="#prod-identifier">identifier</a> "{" <a class="sym" href="#prod-Definitions">Definitions</a> "}" ";"</span></td></tr><tr id="prod-Interface"><td><span class="prod-number">[5]</span></td><td><a class="sym" href="#proddef-Interface">Interface</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"interface" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-Inheritance">Inheritance</a> "{" <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a> "}" ";"</span></td></tr><tr id="prod-PartialInterface"><td><span class="prod-number">[6]</span></td><td><a class="sym" href="#proddef-PartialInterface">PartialInterface</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"partial" "interface" <a class="sym" href="#prod-identifier">identifier</a> "{" <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a> "}" ";"</span></td></tr><tr id="prod-Inheritance"><td><span class="prod-number">[7]</span></td><td><a class="sym" href="#proddef-Inheritance">Inheritance</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">":" <a class="sym" href="#prod-ScopedName">ScopedName</a> <br /> |
ε</span></td></tr><tr id="prod-InterfaceMembers"><td><span class="prod-number">[8]</span></td><td><a class="sym" href="#proddef-InterfaceMembers">InterfaceMembers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-InterfaceMember">InterfaceMember</a> <a class="sym" href="#prod-InterfaceMembers">InterfaceMembers</a> <br /> |
ε</span></td></tr><tr id="prod-InterfaceMember"><td><span class="prod-number">[9]</span></td><td><a class="sym" href="#proddef-InterfaceMember">InterfaceMember</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Const">Const</a> <br /> |
<a class="sym" href="#prod-AttributeOrOperation">AttributeOrOperation</a></span></td></tr><tr id="prod-Dictionary"><td><span class="prod-number">[10]</span></td><td><a class="sym" href="#proddef-Dictionary">Dictionary</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"dictionary" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-Inheritance">Inheritance</a> "{" <a class="sym" href="#prod-DictionaryMembers">DictionaryMembers</a> "}" ";"</span></td></tr><tr id="prod-DictionaryMembers"><td><span class="prod-number">[11]</span></td><td><a class="sym" href="#proddef-DictionaryMembers">DictionaryMembers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-DictionaryMember">DictionaryMember</a> <a class="sym" href="#prod-DictionaryMembers">DictionaryMembers</a> <br /> |
ε</span></td></tr><tr id="prod-DictionaryMember"><td><span class="prod-number">[12]</span></td><td><a class="sym" href="#proddef-DictionaryMember">DictionaryMember</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Type">Type</a> <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-DefaultValue">DefaultValue</a> ";"</span></td></tr><tr id="prod-DefaultValue"><td><span class="prod-number">[13]</span></td><td><a class="sym" href="#proddef-DefaultValue">DefaultValue</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"=" <a class="sym" href="#prod-ConstValue">ConstValue</a> <br /> |
ε</span></td></tr><tr id="prod-Exception"><td><span class="prod-number">[14]</span></td><td><a class="sym" href="#proddef-Exception">Exception</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"exception" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-Inheritance">Inheritance</a> "{" <a class="sym" href="#prod-ExceptionMembers">ExceptionMembers</a> "}" ";"</span></td></tr><tr id="prod-ExceptionMembers"><td><span class="prod-number">[15]</span></td><td><a class="sym" href="#proddef-ExceptionMembers">ExceptionMembers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-ExceptionMember">ExceptionMember</a> <a class="sym" href="#prod-ExceptionMembers">ExceptionMembers</a> <br /> |
ε</span></td></tr><tr id="prod-Typedef"><td><span class="prod-number">[16]</span></td><td><a class="sym" href="#proddef-Typedef">Typedef</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"typedef" <a class="sym" href="#prod-Type">Type</a> <a class="sym" href="#prod-identifier">identifier</a> ";"</span></td></tr><tr id="prod-ImplementsStatement"><td><span class="prod-number">[17]</span></td><td><a class="sym" href="#proddef-ImplementsStatement">ImplementsStatement</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ScopedName">ScopedName</a> "implements" <a class="sym" href="#prod-ScopedName">ScopedName</a> ";"</span></td></tr><tr id="prod-Const"><td><span class="prod-number">[18]</span></td><td><a class="sym" href="#proddef-Const">Const</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"const" <a class="sym" href="#prod-ConstType">ConstType</a> <a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-ConstValue">ConstValue</a> ";"</span></td></tr><tr id="prod-ConstValue"><td><span class="prod-number">[19]</span></td><td><a class="sym" href="#proddef-ConstValue">ConstValue</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-BooleanLiteral">BooleanLiteral</a> <br /> |
<a class="sym" href="#prod-integer">integer</a> <br /> |
<a class="sym" href="#prod-float">float</a> <br /> |
<a class="sym" href="#prod-string">string</a> <br /> |
"null"</span></td></tr><tr id="prod-BooleanLiteral"><td><span class="prod-number">[20]</span></td><td><a class="sym" href="#proddef-BooleanLiteral">BooleanLiteral</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"true" <br /> |
"false"</span></td></tr><tr id="prod-AttributeOrOperation"><td><span class="prod-number">[21]</span></td><td><a class="sym" href="#proddef-AttributeOrOperation">AttributeOrOperation</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"stringifier" <a class="sym" href="#prod-StringifierAttributeOrOperation">StringifierAttributeOrOperation</a> <br /> |
<a class="sym" href="#prod-Attribute">Attribute</a> <br /> |
<a class="sym" href="#prod-Operation">Operation</a></span></td></tr><tr id="prod-StringifierAttributeOrOperation"><td><span class="prod-number">[22]</span></td><td><a class="sym" href="#proddef-StringifierAttributeOrOperation">StringifierAttributeOrOperation</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Attribute">Attribute</a> <br /> |
<a class="sym" href="#prod-OperationRest">OperationRest</a> <br /> |
";"</span></td></tr><tr id="prod-Attribute"><td><span class="prod-number">[23]</span></td><td><a class="sym" href="#proddef-Attribute">Attribute</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Inherit">Inherit</a> <a class="sym" href="#prod-ReadOnly">ReadOnly</a> "attribute" <a class="sym" href="#prod-AttributeType">AttributeType</a> <a class="sym" href="#prod-identifier">identifier</a> ";"</span></td></tr><tr id="prod-ReadOnly"><td><span class="prod-number">[24]</span></td><td><a class="sym" href="#proddef-ReadOnly">ReadOnly</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"readonly" <br /> |
ε</span></td></tr><tr id="prod-Inherit"><td><span class="prod-number">[25]</span></td><td><a class="sym" href="#proddef-Inheritance">Inherit</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"inherit" <br /> |
ε</span></td></tr><tr id="prod-Operation"><td><span class="prod-number">[26]</span></td><td><a class="sym" href="#proddef-Operation">Operation</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Qualifiers">Qualifiers</a> <a class="sym" href="#prod-OperationRest">OperationRest</a></span></td></tr><tr id="prod-Qualifiers"><td><span class="prod-number">[27]</span></td><td><a class="sym" href="#proddef-Qualifiers">Qualifiers</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"static" <br /> |
<a class="sym" href="#prod-Specials">Specials</a></span></td></tr><tr id="prod-Specials"><td><span class="prod-number">[28]</span></td><td><a class="sym" href="#proddef-Specials">Specials</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Special">Special</a> <a class="sym" href="#prod-Specials">Specials</a> <br /> |
ε</span></td></tr><tr id="prod-Special"><td><span class="prod-number">[29]</span></td><td><a class="sym" href="#proddef-Special">Special</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"getter" <br /> |
"setter" <br /> |
"creator" <br /> |
"deleter" <br /> |
"legacycaller"</span></td></tr><tr id="prod-OperationRest"><td><span class="prod-number">[30]</span></td><td><a class="sym" href="#proddef-OperationRest">OperationRest</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ReturnType">ReturnType</a> <a class="sym" href="#prod-OptionalIdentifier">OptionalIdentifier</a> "(" <a class="sym" href="#prod-ArgumentList">ArgumentList</a> ")" ";"</span></td></tr><tr id="prod-OptionalIdentifier"><td><span class="prod-number">[31]</span></td><td><a class="sym" href="#proddef-OptionalIdentifier">OptionalIdentifier</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> <br /> |
ε</span></td></tr><tr id="prod-ArgumentList"><td><span class="prod-number">[32]</span></td><td><a class="sym" href="#proddef-ArgumentList">ArgumentList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Argument">Argument</a> <a class="sym" href="#prod-Arguments">Arguments</a> <br /> |
ε</span></td></tr><tr id="prod-Arguments"><td><span class="prod-number">[33]</span></td><td><a class="sym" href="#proddef-Arguments">Arguments</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"," <a class="sym" href="#prod-Argument">Argument</a> <a class="sym" href="#prod-Arguments">Arguments</a> <br /> |
ε</span></td></tr><tr id="prod-Argument"><td><span class="prod-number">[34]</span></td><td><a class="sym" href="#proddef-Argument">Argument</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttributeList">ExtendedAttributeList</a> <a class="sym" href="#prod-Optional">Optional</a> <a class="sym" href="#prod-Type">Type</a> <a class="sym" href="#prod-Ellipsis">Ellipsis</a> <a class="sym" href="#prod-identifier">identifier</a></span></td></tr><tr id="prod-Optional"><td><span class="prod-number">[35]</span></td><td><a class="sym" href="#proddef-Optional">Optional</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"optional" <br /> |
ε</span></td></tr><tr id="prod-Ellipsis"><td><span class="prod-number">[36]</span></td><td><a class="sym" href="#proddef-Ellipsis">Ellipsis</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"..." <br /> |
ε</span></td></tr><tr id="prod-ExceptionMember"><td><span class="prod-number">[37]</span></td><td><a class="sym" href="#proddef-ExceptionMember">ExceptionMember</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Const">Const</a> <br /> |
<a class="sym" href="#prod-ExceptionField">ExceptionField</a></span></td></tr><tr id="prod-ExceptionField"><td><span class="prod-number">[38]</span></td><td><a class="sym" href="#proddef-ExceptionField">ExceptionField</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-AttributeType">AttributeType</a> <a class="sym" href="#prod-identifier">identifier</a> ";"</span></td></tr><tr id="prod-ExtendedAttributeList"><td><span class="prod-number">[39]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeList">ExtendedAttributeList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"[" <a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a> <a class="sym" href="#prod-ExtendedAttributes">ExtendedAttributes</a> "]" <br /> |
ε</span></td></tr><tr id="prod-ExtendedAttributes"><td><span class="prod-number">[40]</span></td><td><a class="sym" href="#proddef-ExtendedAttributes">ExtendedAttributes</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"," <a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a> <a class="sym" href="#prod-ExtendedAttributes">ExtendedAttributes</a> <br /> |
ε</span></td></tr><tr id="prod-ExtendedAttribute"><td><span class="prod-number">[41]</span></td><td><a class="sym" href="#proddef-ExtendedAttribute">ExtendedAttribute</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">
"(" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> ")" <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
<br /> |
"[" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "]" <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
<br /> |
"{" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "}" <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
<br /> |
<a class="sym" href="#prod-Other">Other</a> <a class="sym" href="#prod-ExtendedAttributeRest">ExtendedAttributeRest</a>
</span></td></tr><tr id="prod-ExtendedAttributeRest"><td><span class="prod-number">[42]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeRest">ExtendedAttributeRest</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a> <br /> |
ε</span></td></tr><tr id="prod-ExtendedAttributeInner"><td><span class="prod-number">[43]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeInner">ExtendedAttributeInner</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">
"(" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> ")" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
"[" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "]" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
"{" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a> "}" <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
<a class="sym" href="#prod-OtherOrComma">OtherOrComma</a> <a class="sym" href="#prod-ExtendedAttributeInner">ExtendedAttributeInner</a>
<br /> |
ε
</span></td></tr><tr id="prod-Other"><td><span class="prod-number">[44]</span></td><td><a class="sym" href="#proddef-Other">Other</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">
<a class="sym" href="#prod-integer">integer</a> <br /> |
<a class="sym" href="#prod-float">float</a> <br /> |
<a class="sym" href="#prod-identifier">identifier</a> <br /> |
<a class="sym" href="#prod-string">string</a> <br /> |
<a class="sym" href="#prod-other">other</a>
<br /> |
"..." <br /> |
":" <br /> |
"::" <br /> |
";" <br /> |
"<" <br /> |
"=" <br /> |
">" <br /> |
"?"
<br /> |
"Date" <br /> |
"DOMString" <br /> |
"any" <br /> |
"attribute" <br /> |
"boolean" <br /> |
"byte"
<br /> |
"legacycaller" <br /> |
"const" <br /> |
"creator" <br /> |
"deleter" <br /> |
"double"
<br /> |
"exception" <br /> |
"false" <br /> |
"float" <br /> |
"getter" <br /> |
"implements"
<br /> |
"inherit" <br /> |
"interface" <br /> |
"long" <br /> |
"module" <br /> |
"null" <br /> |
"object" <br /> |
"octet"
<br /> |
"optional" <br /> |
"sequence"
<br /> |
"setter" <br /> |
"short" <br /> |
"static" <br /> |
"stringifier" <br /> |
"true" <br /> |
"typedef"
<br /> |
"unsigned" <br /> |
"void"
</span></td></tr><tr id="prod-OtherOrComma"><td><span class="prod-number">[45]</span></td><td><a class="sym" href="#proddef-OtherOrComma">OtherOrComma</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Other">Other</a> <br /> |
","</span></td></tr><tr id="prod-Type"><td><span class="prod-number">[46]</span></td><td><a class="sym" href="#proddef-Type">Type</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-AttributeType">AttributeType</a> <br /> |
<a class="sym" href="#prod-SequenceType">SequenceType</a></span></td></tr><tr id="prod-SequenceType"><td><span class="prod-number">[47]</span></td><td><a class="sym" href="#proddef-SequenceType">SequenceType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"sequence" "<" <a class="sym" href="#prod-Type">Type</a> ">" <a class="sym" href="#prod-Null">Null</a></span></td></tr><tr id="prod-AttributeType"><td><span class="prod-number">[48]</span></td><td><a class="sym" href="#proddef-AttributeType">AttributeType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-PrimitiveOrStringType">PrimitiveOrStringType</a> <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
<a class="sym" href="#prod-ScopedName">ScopedName</a> <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"object" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"Date" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"any" <a class="sym" href="#prod-TypeSuffixStartingWithArray">TypeSuffixStartingWithArray</a></span></td></tr><tr id="prod-ConstType"><td><span class="prod-number">[49]</span></td><td><a class="sym" href="#proddef-ConstType">ConstType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-PrimitiveOrStringType">PrimitiveOrStringType</a> <a class="sym" href="#prod-Null">Null</a></span></td></tr><tr id="prod-PrimitiveOrStringType"><td><span class="prod-number">[50]</span></td><td><a class="sym" href="#proddef-PrimitiveOrStringType">PrimitiveOrStringType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-UnsignedIntegerType">UnsignedIntegerType</a> <br /> |
"boolean" <br /> |
"byte" <br /> |
"octet" <br /> |
"float" <br /> |
"double" <br /> |
"DOMString"</span></td></tr><tr id="prod-UnsignedIntegerType"><td><span class="prod-number">[51]</span></td><td><a class="sym" href="#proddef-UnsignedIntegerType">UnsignedIntegerType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"unsigned" <a class="sym" href="#prod-IntegerType">IntegerType</a> <br /> |
<a class="sym" href="#prod-IntegerType">IntegerType</a></span></td></tr><tr id="prod-IntegerType"><td><span class="prod-number">[52]</span></td><td><a class="sym" href="#proddef-IntegerType">IntegerType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"short" <br /> |
"long" <a class="sym" href="#prod-OptionalLong">OptionalLong</a></span></td></tr><tr id="prod-OptionalLong"><td><span class="prod-number">[53]</span></td><td><a class="sym" href="#proddef-OptionalLong">OptionalLong</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"long" <br /> |
ε</span></td></tr><tr id="prod-TypeSuffix"><td><span class="prod-number">[54]</span></td><td><a class="sym" href="#proddef-TypeSuffix">TypeSuffix</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"[" "]" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
"?" <a class="sym" href="#prod-TypeSuffixStartingWithArray">TypeSuffixStartingWithArray</a> <br /> |
ε</span></td></tr><tr id="prod-TypeSuffixStartingWithArray"><td><span class="prod-number">[55]</span></td><td><a class="sym" href="#proddef-TypeSuffixStartingWithArray">TypeSuffixStartingWithArray</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"[" "]" <a class="sym" href="#prod-TypeSuffix">TypeSuffix</a> <br /> |
ε</span></td></tr><tr id="prod-Null"><td><span class="prod-number">[56]</span></td><td><a class="sym" href="#proddef-Null">Null</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"?" <br /> |
ε</span></td></tr><tr id="prod-ReturnType"><td><span class="prod-number">[57]</span></td><td><a class="sym" href="#proddef-ReturnType">ReturnType</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-Type">Type</a> <br /> |
"void"</span></td></tr><tr id="prod-ScopedName"><td><span class="prod-number">[58]</span></td><td><a class="sym" href="#proddef-ScopedName">ScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-AbsoluteScopedName">AbsoluteScopedName</a> <br /> |
<a class="sym" href="#prod-RelativeScopedName">RelativeScopedName</a></span></td></tr><tr id="prod-AbsoluteScopedName"><td><span class="prod-number">[59]</span></td><td><a class="sym" href="#proddef-AbsoluteScopedName">AbsoluteScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"::" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a></span></td></tr><tr id="prod-RelativeScopedName"><td><span class="prod-number">[60]</span></td><td><a class="sym" href="#proddef-RelativeScopedName">RelativeScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a></span></td></tr><tr id="prod-ScopedNameParts"><td><span class="prod-number">[61]</span></td><td><a class="sym" href="#proddef-ScopedNameParts">ScopedNameParts</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines">"::" <a class="sym" href="#prod-identifier">identifier</a> <a class="sym" href="#prod-ScopedNameParts">ScopedNameParts</a> <br /> |
ε</span></td></tr><tr id="prod-ExtendedAttributeNoArgs"><td><span class="prod-number">[62]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeNoArgs">ExtendedAttributeNoArgs</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a></span></td></tr><tr id="prod-ExtendedAttributeArgList"><td><span class="prod-number">[63]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeArgList">ExtendedAttributeArgList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "(" <a class="sym" href="#prod-ArgumentList">ArgumentList</a> ")"</span></td></tr><tr id="prod-ExtendedAttributeIdent"><td><span class="prod-number">[64]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeIdent">ExtendedAttributeIdent</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-identifier">identifier</a></span></td></tr><tr id="prod-ExtendedAttributeScopedName"><td><span class="prod-number">[65]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeScopedName">ExtendedAttributeScopedName</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-ScopedName">ScopedName</a></span></td></tr><tr id="prod-ExtendedAttributeNamedArgList"><td><span class="prod-number">[66]</span></td><td><a class="sym" href="#proddef-ExtendedAttributeNamedArgList">ExtendedAttributeNamedArgList</a></td><td class="prod-mid">→</td><td class="prod-rhs"><span class="prod-lines"><a class="sym" href="#prod-identifier">identifier</a> "=" <a class="sym" href="#prod-identifier">identifier</a> "(" <a class="sym" href="#prod-ArgumentList">ArgumentList</a> ")"</span></td></tr></table>
<div class="note"><div class="noteHeader">Note</div>
<p>
The choices listed for the <a class="sym" href="#prod-Other">Other</a>
non-terminal are all of the terminal symbols except for
<span class="sym">"("</span>, <span class="sym">")"</span>,
<span class="sym">"["</span>, <span class="sym">"]"</span>,
<span class="sym">"{"</span>, <span class="sym">"}"</span>
and <span class="sym">","</span>.
</p>
</div>
<p>
While the <a class="sym" href="#prod-ExtendedAttribute">ExtendedAttribute</a>
non-terminal matches any non-empty sequence of terminal symbols (as long as any
parentheses, square brackets or braces are balanced, and the
<span class="sym">","</span> token appears only within those balanced brackets),
only a subset of those
possible sequences are used by the <a class="dfnref" href="#dfn-extended-attribute">extended attributes</a>
defined in this specification — see
<a href="#idl-extended-attributes">section 3.10</a>
for the syntaxes that are used by these extended attributes.
</p>
</div>
<div id="references" class="section">
<h2>B. References</h2>
<div id="normative-references" class="section">
<h3>B.1. Normative references</h3>
<dl>
<dt id="ref-ECMA-262">[ECMA-262]</dt>
<dd>
<cite><a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript Language Specification, 5th Edition</a></cite>,
P. Lakshman and A. Wirfs-Brock, Editors. Ecma International, December 2009. Available at http://www.ecma-international.org/publications/standards/Ecma-262.htm.
</dd>
<dt id="ref-IEEE-754">[IEEE-754]</dt>
<dd>
<cite>IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std 754-1985)</cite>.
Institute of Electrical and Electronics Engineers, 1985.
</dd>
<dt id="ref-JLS3">[JLS3]</dt>
<dd>
<cite><a href="http://java.sun.com/docs/books/jls/">The Java Language Specification, Third Edition</a></cite>.
J. Gosling, et al. Upper Saddle River, New Jersey, Addison-Wesley, 2005.
Available at http://java.sun.com/docs/books/jls/.
</dd>
<dt id="ref-PERLRE">[PERLRE]</dt>
<dd>
<cite><a href="http://search.cpan.org/dist/perl/pod/perlre.pod">Perl regular expressions (Perl 5.8.8)</a></cite>.
The Perl Foundation, February 2006. Available at http://www.perl.com/doc/manual/html/pod/perlre.html.
</dd>
<dt id="ref-RFC2119">[RFC2119]</dt>
<dd>
<cite><a href="http://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a></cite>,
S. Bradner. IETF, March 1997. Available at http://tools.ietf.org/html/rfc2119.
</dd>
<dt id="ref-RFC2781">[RFC2781]</dt>
<dd>
<cite><a href="http://tools.ietf.org/html/rfc2781">UTF-16, an encoding of ISO 10646</a></cite>,
P. Hoffmann and F. Yergeau. IETF, February 2000. Available at http://tools.ietf.org/html/rfc2781.
</dd>
<dt id="ref-UNICODE">[UNICODE]</dt>
<dd>
<cite><a href="http://www.unicode.org/standard/versions/">The Unicode Standard</a></cite>,
Version 6.0 or later. The Unicode Consortium. Mountain View, California, 2011.
ISBN 978-1-936213-01-6. Available at http://www.unicode.org/versions/Unicode6.0.0/.
</dd>
</dl>
</div>
<div id="informative-references" class="section">
<h3>B.2. Informative references</h3>
<dl>
<dt id="ref-DOM3CORE">[DOM3CORE]</dt>
<dd>
<cite><a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/">Document Object Model (DOM) Level 3 Core Specification</a></cite>.
A. Le Hors, et al., Editors. World Wide Web Consortium, April 2004. Available at http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/.
</dd>
<dt id="ref-HTML5">[HTML5]</dt>
<dd>
<cite><a href="http://www.w3.org/TR/2011/WD-html5-20110525/">HTML5</a></cite>.
I. Hickson, Editor. World Wide Web Consortium, May 2011. Available at http://www.w3.org/TR/2011/WD-html5-20110525/.
</dd>
<dt id="ref-OMGIDL">[OMGIDL]</dt>
<dd>
<cite><a href="http://www.omg.org/cgi-bin/doc?formal/08-01-04.pdf">CORBA 3.1 – OMG IDL Syntax and Semantics chapter</a></cite>.
Object Management Group, January 2008. Available at http://www.omg.org/cgi-bin/doc?formal/08-01-04.pdf.
</dd>
</dl>
</div>
</div>
<div id="changes" class="section">
<h2>C. Changes</h2>
<p>
The following is a list of substantial changes to the document on each publication.
</p>
<dl class="changes">
<dt>27 September 2011 – LCWD #2</dt>
<!--
<dt>Current editor’s draft</dt>
-->
<dd>
<ul>
<li>
<p>
Changed exceptions to have an intrinsic type, and added recommendations
to specification authors on how to name exception types.
</p>
</li>
<li>
<p>
Changed <code>inherits getter</code> to <code>inherit</code>.
</p>
</li>
<li>
<p>
Renamed “callers” to “legacy callers” to discourage their use.
</p>
</li>
<li>
<p>
Added <span class="xattr">[EnforceRange]</span> which will cause an
exception to be thrown if an ECMAScript <span class="estype">Number</span>
is out of range (after rounding).
</p>
</li>
<li>
<p>
Tweaked <span class="xattr">[Clamp]</span> so that it rounds to nearest
rather than floors.
</p>
</li>
<li>
<p>
Recommend against using <span class="xattr">[NoInterfaceObject]</span>
for non-supplemental interfaces.
</p>
</li>
<li>
<p>
Added <span class="xattr">[ArrayClass]</span>.
</p>
</li>
<li>
<p>
Made trailing ECMAScript <span class="esvalue">undefined</span> values
in function calls be equivalent to missing optional parameters.
</p>
</li>
<li>
<p>
Removed <span class="xattr">[CopyInheritedPrototype]</span>.
</p>
</li>
<li>
<p>
Made the length property on platform array objects non-configurable.
</p>
</li>
<li>
<p>
Removed <code>omittable</code>, since nobody is using it (and probably won’t,
unless considering non-ECMAScript language bindings). Instead, identifierless
special operations will map to methods with special names in the Java
language binding, rather than being left out altogether.
</p>
</li>
<li>
<p>
Disallows <span class="xattr">[NoInterfaceObject]</span> on interfaces
that have static operations.
</p>
</li>
<li>
<p>
Removed named properties “resolved before prototype properties”.
</p>
</li>
<li>
<p>
Made ECMAScript namespace object properties enumerable.
</p>
</li>
<li>
<p>
Removed raises, setraises and getraises clauses since they do not add any value.
</p>
</li>
<li>
<p>
Added the <span class="xattr">[TreatNonCallableAsNull]</span> extended attribute.
</p>
</li>
<li>
<p>
Made type conversion from an ECMAScript non-object value to an IDL dictionary value
throw an exception.
</p>
</li>
<li>
<p>
Specified that the “prototype” property of a named constructor
has the same value as the one on the interface object.
</p>
</li>
<li>
<p>
Specify <span class="prop">[[Call]]</span> for operations and add
an <span class="xattr">[ImplicitThis]</span> extended attribute
for use on <span class="idltype">Window</span>.
</p>
</li>
<li>
<p>
Tweaked the names of Java getter and setter methods to avoid
conflicts with other interface members.
</p>
</li>
<li>
<p>
Disallowed definitions with special ECMAScript property names
and if they begin with a leading underscore.
</p>
</li>
<li>
<p>
Modified the overload resolution algorithm so that it works
with sequence types.
</p>
</li>
<li>
<p>
Disallows consequential interfaces from defining interface members whose
identifiers are the same as any of those on the original interface.
</p>
</li>
<li>
<p>
Renamed “name getter”, “index getter” and friends to “named property getter”,
“indexed property getter” and so on, since that’s a more accurate description
of what they are.
</p>
</li>
<li>
<p>
Removed the optional <code>in</code> keyword from arguments, since it serves no
useful purpose.
</p>
</li>
</ul>
</dd>
<dt>12 July 2011 – LCWD #1</dt>
<dd>
<ul>
<li>
<p>
Added some green boxes illustrating the syntax of the different IDL
constructs.
</p>
</li>
<li>
<p>
Added IDL syntax to declare that a writable attribute inherits its
getter behavior from a read only attribute of the same name in
on an ancestor interface.
</p>
</li>
<li>
<p>
Made all interface objects be <span class="estype">Function</span> objects,
regardless of whether they have a constructor.
</p>
</li>
<li>
<p>
Added the notion of named properties being “resolved before prototype properties”
to handle the <span class="estype">Window</span> object’s odd treatment
of named properties.
</p>
</li>
<li>
<p>
Specified attributes of ECMAScript properties corresponding to stringifiers,
making them non-enumerable.
</p>
</li>
<li>
<p>
Introduced the terms “platform object” and “user object” to distinguish
between objects provided by the implementation and those created and
supplied by the user of an API. Most of mentions of ECMAScript native
objects were replaced with “user object” and host objects with
“platform object”. Specific requirements on what ECMAScript objects can
be passed to platform objects expecting non-<span class="xattr">[Callback]</span>
interface types are now given.
</p>
</li>
<li>
<p>
Added an <span class="xattr">[Unforgeable]</span> extended attribute
to require properties corresponding to IDL attributes be non-configurable
and to appear as own properties on the object rather than on the prototype.
</p>
</li>
<li>
<p>
Allowed <span class="xattr">[Callback]</span> interfaces to inherit from
other <span class="xattr">[Callback]</span> interfaces.
</p>
</li>
<li>
<p>
Removed array host object prototype objects, since they didn’t have any
useful properties on them. Instead, the <span class="prop">[[Prototype]]</span>
of array host objects are now required to be the <span class="estype">Array</span>
prototype object.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[CopyInheritedPrototype]</span> extended attribute.
</p>
</li>
<li>
<p>
Added support for partial interface definitions.
</p>
</li>
<li>
<p>
Removed mixin prototype objects from the ECMAScript binding. At the IDL level,
objects may now only implement a single inheritance hierarchy of interfaces,
plus any supplemental interfaces that are required due to “implements” statements.
Interface prototype objects for interfaces on the left-hand side of an
“implements” statement now also get properties for members of the interface
on the right-hand side of the statement.
</p>
</li>
<li>
<p>
Tweaked the ECMAScript overload resolution algorithm so that passing too few arguments
will result in an exception being thrown and passing more arguments than the longest
overload will mean those extra arguments will be ignored. Distinguishing which
overload is called when the overloads have the same argument list length is now
performed only on arguments where across all of the overloads, not all of
the types at that position are the same.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[ReplaceableNamedProperties]</span> extended attribute to control
whether named properties on an object can be replaced by assigning to them.
</p>
</li>
<li>
<p>
Required that ECMAScript host objects that support indexed and named properties
and for array host objects refuse to be fixed.
</p>
</li>
<li>
<p>
Removed the “toString” property from array host
objects, so that the one inherited from the
<span class="value">Array</span> prototype object is used instead.
</p>
</li>
<li>
<p>
Changed the implementation requirements for ECMAScript host objects
that support indexed and named properties, and for array host objects,
to use specific <span class="prop">[[GetOwnProperty]]</span>
and <span class="prop">[[DefineOwnProperty]]</span> behavior, instead of
in terms of setting and removing own properties on the object.
</p>
</li>
<li>
<p>
Disallowed sequence and dictionary types from being used as an array
element type.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[Clamp]</span> extended attribute to control
how ECMAScript <span class="estype">Number</span> values are converted to
IDL integer values.
</p>
</li>
<li>
<p>
Added the dictionary type and allowed <span class="idlvalue">null</span> to be specified
as the value of a constant or the default value of a dictionary member.
</p>
</li>
<li>
<p>
Added a <a class="idltype" href="#idl-Date">Date</a> IDL type.
</p>
</li>
<li>
<p>
Point out that special operations for indexed and named properties can be overridden.
</p>
</li>
<li>
<p>
Added requirements on the property enumeration order for indexed
and named properties.
</p>
</li>
<li>
<p>
Required that multiple ECMAScript global environments have independent
copies of interface objects, interface prototype objects, etc., and
defined which global environment’s objects are used when an exception
is thrown.
</p>
</li>
<li>
<p>
Disallowed sequence types from being used as attribute types.
</p>
</li>
<li>
<p>
Removed <span class="idlvalue">null</span> from the set of values for
interface types, <span class="idlvalue">object</span> and array types,
allowed those types to be nullable, and updated the overload resolution
algorithm to account for these changes.
</p>
</li>
<li>
<p>
Made calling an ECMAScript <span class="estype">Function</span> that
corresponds to an IDL operation throw a <span class="estype">TypeError</span>
if the <span class="esvalue">this</span> value isn’t an object that
implements the right interface.
</p>
</li>
<li>
<p>
Add constructors to Java classes corresponding to IDL exceptions.
</p>
</li>
<li>
<p>
Define what it means to throw an IDL exception with a given message.
</p>
</li>
<li>
<p>
Added “constructor” properties back to interface prototype objects.
</p>
</li>
<li>
<p>
Allowed exceptions to inherit from other exceptions, so that they can be more consistent
with native ECMAScript errors and so that we can move away from defining and using
integer exception codes.
</p>
</li>
<li>
<p>
Required that when calling an ECMAScript <span class="estype">Function</span> that
corresponds to an IDL interface, the argument values are converted to IDL values
in order from left to right.
</p>
</li>
<li>
<p>
Made properties corresponding to operations enumerable.
</p>
</li>
<li>
<p>
Changed the interface object and exception interface object properties
on the global object to be configurable.
</p>
</li>
<li>
<p>
Added a signed 8 bit integer types named <a class="idltype" href="#idl-byte">byte</a>.
</p>
</li>
<li>
<p>
Expanded the allowable types for constants to include <a class="idltype" href="#idl-DOMString">DOMString</a>
and nullable primitives.
</p>
</li>
<li>
<p>
Added support for static operations.
</p>
</li>
<li>
<p>
Fixed errors in the <span class="sym">float</span> and
<span class="sym">integer</span> grammar terminals.
</p>
</li>
<li>
<p>
Added productions for array types to the grammar, which were missing.
</p>
</li>
<li>
<p>
Added a section for common IDL definitions that all conforming
implementations must support, the first entry in which is
a definition for the <span class="idltype">DOMTimeStamp</span>
type.
</p>
</li>
</ul>
</dd>
<dt>21 October 2010 – WD</dt>
<dd>
<ul>
<li>
<p>
Made constructors due to <span class="xattr">[Constructor]</span> and
<span class="xattr">[NamedConstructor]</span> callable. Their behavior
when called is the same as when used in a <code>new</code> expression.
</p>
</li>
<li>
<p>
Updated the ECMAScript language binding to target ECMAScript 5th edition,
the biggest part of which is that now interface attributes are
implemented as accessor properties.
</p>
</li>
<li>
<p>
Ensure that corresponding properties do not exist for constants,
attributes and operations named “constructor” or “toString”
if they would conflict with other requirements to have properties
with those names.
</p>
</li>
<li>
<p>
Moved properties corresponding to attributes from host object
instances to their interface prototype objects. Similarly, moved
properties corresponding to exception fields from host exception
objects to their exception interface prototype objects.
</p>
</li>
<li>
<p>
Disallow both <span class="xattr">[PutForwards]</span> and
<span class="xattr">[Replaceable]</span> appearing on the same
attribute.
</p>
</li>
<li>
<p>
Required that callable objects corresponding to operations
be <span class="estype">Function</span> objects.
</p>
</li>
<li>
<p>
Changed the “constructor” property
on interface prototype objects to be writable.
</p>
</li>
<li>
<p>
Changed the “prototype” property on
interface and exception objects be non-enumerable.
</p>
</li>
<li>
<p>
Allowed callers to be overloaded.
</p>
</li>
<li>
<p>
Defined the “length” property on
<span class="estype">Function</span> objects that correspond to operations and constructors.
</p>
</li>
<li>
<p>
Changed sequences to be passed by value, and added an array type
for ordered lists of values that are passed by reference.
</p>
</li>
<li>
<p>
Removed interface forward declarations and the requirement that interfaces
be declared before use.
</p>
</li>
<li>
<p>
Made the <code>in</code> keyword in argument lists optional.
</p>
</li>
<li>
<p>
Changed the <code>Object</code>,
<code>TRUE</code> and <code>FALSE</code>
keywords to be all lowercase.
</p>
</li>
<li>
<p>
Dropped <span class="xattr">[Optional]</span> and <span class="xattr">[Variadic]</span>
in favor of <code>optional</code> and <code>...</code> syntax.
</p>
</li>
<li>
<p>
Dropped <span class="xattr">[ImplementedOn]</span> in favor of an
<code>implements</code> statement.
</p>
</li>
<li>
<p>
Dropped <span class="xattr">[ExceptionConsts]</span> in favor of allowing
constants to be defined directly on exceptions. Defining constants on
modules is now disallowed.
</p>
</li>
<li>
<p>
Changed <span class="xattr">[Constructor]</span> and <span class="xattr">[PutForwards]</span>
to be an ECMAScript-specific extended attribute.
</p>
</li>
<li>
<p>
Turned <span class="xattr">[Callable]</span>,
<span class="xattr">[IndexGetter]</span>,
<span class="xattr">[IndexSetter]</span>,
<span class="xattr">[IndexCreator]</span>,
<span class="xattr">[IndexDeleter]</span>,
<span class="xattr">[NameGetter]</span>,
<span class="xattr">[NameSetter]</span>,
<span class="xattr">[NameCreator]</span>,
<span class="xattr">[NameDeleter]</span> and
<span class="xattr">[Stringifies]</span> into real Web IDL syntax
using <code>caller</code>, <code>getter</code>, <code>setter</code>,
<code>creator</code>, <code>deleter</code> and <code>stringifier</code>.
Dropped <span class="xattr">[NoIndexingOperations]</span> in favor of
an <code>omittable</code> keyword that can be used on the above
six special operations.
</p>
</li>
<li>
<p>
Removed boxed valuetypes and replaced them with the concept
of nullable types.
</p>
</li>
<li>
<p>
Added <span class="xattr">[NamespaceObject]</span> to allow
reflecting module hierarchies in ECMAScript.
</p>
</li>
<li>
<p>
Disallowed specifying <span class="xattr">[Callback]</span> on
interfaces that do not match the criteria for interfaces that
can be implemented by native objects, and disallowed the use
of the <code>FunctionOnly</code> and
<code>PropertyOnly</code> identifiers unless
the interface has only a single operation (or multiple operations,
as long as they all have the same identifier).
</p>
</li>
<li>
<p>
Made corresponding indexed properties and ECMAScript properties
for operations enumerable.
</p>
</li>
<li>
<p>
Outlawed having both <span class="xattr">[NoInterfaceObject]</span> and
<span class="xattr">[Constructor]</span> on an interface.
</p>
</li>
<li>
<p>
Required that identical mixin prototype objects are in fact
the same object.
</p>
</li>
<li>
<p>
Renamed <span class="xattr">[Null]</span> and <span class="xattr">[Undefined]</span>
to <span class="xattr">[TreatNullAs]</span> and <span class="xattr">[TreatUndefinedAs]</span>.
They are now honored when values are returned from native object implemented
operations and attributes.
</p>
</li>
<li>
<p>
Added algorithms for getting and setting values of attributes on
native object implementations of interfaces.
</p>
</li>
<li>
<p>
Added <span class="xattr">[OverrideBuiltins]</span>, which makes
name getters prefer named properties instead of properties on the object itself.
</p>
</li>
<li>
<p>
Fixed bugs in the host object <span class="prop">[[Put]]</span>
algorithm (now <span class="prop">[[DefineOwnProperty]]</span>)
so that name and index creators are actually
invoked, and restructured it as well as the host object
<span class="prop">[[Delete]]</span>
algorithm so that they are easier to read.
</p>
</li>
<li>
<p>
Provided language binding independent advice on handling user
implemented interfaces that throw exceptions or return values
of inappropriate types.
</p>
</li>
<li>
<p>
Renamed the awkwardly worded “object implementing an interface” type
to “interface type”.
</p>
</li>
<li>
<p>
Added an <span class="xattr">[AllowAny]</span> ECMAScript-specific
extended attribute on operation arguments, which indicates that
any type of ECMAScript value is allowed to be passed to that
argument.
</p>
</li>
<li>
<p>
Changed the definition of the effective overload set to take
into account the number of arguments passed, so that it can
be used to resolve overloaded calls properly in the
presence of variadic operations.
</p>
</li>
<li>
<p>
<!--Renamed <span class='idltype'>DOMString</span> to <span class='idltype'>string</span>,
removed it from the list of primitive types, and allowed it-->
Removed <a class="idltype" href="#idl-DOMString">DOMString</a> from the list
of primitive types, removed <span class="idlvalue">null</span>
from its set of values, and allowed it to
be distinguished from primitive types in the overload
resolution algorithm. The <span class="xattr">[Callback]</span>
extended attribute is now also taken into account when a
native object is passed as an argument.
</p>
</li>
<li>
<p>
Defined exception handling for algorithms that call in
to user ECMAScript code.
</p>
</li>
<li>
<p>
Added an algorithm for converting a sequence of 16 bit
unsigned integer code units into a sequence of Unicode
characters.
</p>
</li>
<li>
<p>
Added a <a class="idltype" href="#idl-double">double</a> type for double
precision floating point numbers.
</p>
</li>
<li>
<p>
Define <span class="prop">[[Class]]</span> for host objects
that implement a single interface, regardless of whether
it is annotated with <span class="xattr">[PrototypeRoot]</span>.
</p>
</li>
</ul>
</dd>
<dt>19 December 2008 – WD</dt>
<dd>
<ul>
<li>
<p>
Added a <span class="xattr">[NoIndexingOperations]</span>
extended attribute to indicate that operations annotated
with named property or indexed property extended attributes
won’t result in functions, if the language binding supports
object indexing.
</p>
</li>
<li>
<p>
Changed the way extended attributes are parsed in the grammar
and filled out the Extensibility section to mention how
extended attributes not defined in this document can be used.
</p>
</li>
<li>
<p>
Fixed some bugs in the rules for converting <a class="idltype" href="#idl-float">float</a>
and <a class="idltype" href="#idl-unsigned-long-long">unsigned long long</a> to ECMAScript
<span class="estype">Number</span> values, and vice versa.
</p>
</li>
<li>
<p>
Added <span class="xattr">[Prefix]</span> to change the default
mapping of modules to language binding namespacing constructs.
</p>
</li>
<li>
<p>
Allowed interfaces with constants to be implemented by
ECMAScript native objects. This specifically allows
implementation of a DOM Level 2 Traversal
<span class="idltype">NodeFilter</span> object in script.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[Callable]</span>
extended attribute, which can be used to indicate
the behavior of calling an object as a function.
</p>
</li>
<li>
<p>
Removed a bogus requirement that
<span class="xattr">[PutForwards]</span> identify an
attribute whose type is the same as the attribute that
has the <span class="xattr">[PutForwards]</span>, and
disallowed cycles of forwarding assignments.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[Replaceable]</span> extended
attribute that can be placed on an attribute to indicate
that the corresponding ECMAScript property can be
replaced.
</p>
</li>
<li>
<p>
Added a requirement that <span class="xattr">[Stringifies]</span>
not be specified on an interface that also declares an
interface member named <code>toString</code>.
</p>
</li>
<li>
<p>
Changed the DOMString type to be a sequence of 16 bit
code units, rather than a sequence of Unicode characters.
</p>
</li>
<li>
<p>
Reworded the ECMAScript type mapping section so
that it can be more easily referenced from other
sections of the document.
</p>
</li>
<li>
<p>
Renamed <span class="xattr">[NativeObject]</span> to
<span class="xattr">[Callback]</span>, and gave it an
additional <code>PropertyOnly</code> argument.
</p>
</li>
<li>
<p>
Added an <span class="xattr">[Optional]</span> extended
attribute to make certain kinds of operation overloading
able to be specified more succinctly.
</p>
</li>
<li>
<p>
Reworked operation overloading in IDL so that it is
much more restrictive. Updated the overloaded
operation and constructor resolution in ECMAScript accordingly.
</p>
</li>
<li>
<p>
Specified the behavior of index and name getters
in ECMAScript as being in terms of additional properties
that are placed on the host object. Added
<span class="xattr">[IndexCreator]</span>,
<span class="xattr">[IndexDeleter]</span>,
<span class="xattr">[NameCreator]</span> and
<span class="xattr">[NameDeleter]</span> to handle
more aspects of these properties. The definition
of <span class="prop">[[Get]]</span> for host objects
is removed, but <span class="prop">[[Put]]</span> is
expanded to handle index and name creators/setters,
and <span class="prop">[[Delete]]</span> is now specified
to handle index and name deleters.
</p>
</li>
<li>
<p>
Specified the value of <span class="prop">[[Class]]</span>
for host objects.
</p>
</li>
<li>
<p>
Removed the suggestion to perform tricksy multiple inheritance
simulation in ECMAScript with a mandated way to map multiple
inheritance into a single inheritance prototype chain. Added
<span class="xattr">[ImplementedOn]</span> and
<span class="xattr">[PrototypeRoot]</span> to help with this.
</p>
</li>
<li>
<p>
Made an explicit mention of the <cite>Web Interface Definition
Language (WIDL)</cite> W3C Member submission in the Status
of this Document section.
</p>
</li>
</ul>
</dd>
<dt>29 August 2008 – WD</dt>
<dd>
<ul>
<li>
<p>
Added an <span class="xattr">[NamedConstructor]</span> extended attribute
to handle peculiarities like HTML5’s <code>Image</code> constructor.
</p>
</li>
<li>
<p>
<span class="xattr">[Constructor]</span> extended attributes may now
take an argument list, and more than one can be used on an interface.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[NativeObject]</span> extended attribute
that restricts which interfaces may be implemented by ECMAScript
native objects, and updated the “Native objects implementing interfaces”
section to be more restricted and precise.
</p>
</li>
<li>
<p>
Moved <span class="xattr">[NoInterfaceObject]</span> into the
ECMAScript-specific extended attributes section.
</p>
</li>
<li>
<p>
Fixed errors in a couple of algorithms that were introduced by
steps being renumbered.
</p>
</li>
<li>
<p>
Properties corresponding to IDL constants are now ReadOnly.
</p>
</li>
<li>
<p>
Removed <span class="xattr">[NoNull]</span>, and added
<span class="xattr">[Null]</span> and <span class="xattr">[Undefined]</span>
in its place.
</p>
</li>
<li>
<p>
Made <a class="idltype" href="#idl-DOMString">DOMString</a> an intrinsic type,
but still allow it to be defined as a boxed sequence of
unsigned shorts for compatibility with already published IDL
fragments.
</p>
</li>
<li>
<p>
ECMAScript host object constructors (specified with
<span class="xattr">[Constructor]</span>) now must return an
object that implements the interface.
</p>
</li>
<li>
<p>
Tweaked the abstract and introduction so that it is clear that
Web IDL can be used for specifications that define not only a
DOM, but any interface.
</p>
</li>
<li>
<p>
Clarified the behavior of passing a
non-<span class="esvalue">null</span>,
non-<span class="estype">Object</span>
value to a host object that expects a boxed valuetype.
</p>
</li>
<li>
<p>Renamed document to <cite>Web IDL</cite>.</p>
</li>
</ul>
</dd>
<dt>10 April 2008 – WD</dt>
<dd>
<ul>
<li>
<p>
Restricted boxed valuetypes to boxing only types that cannot
already have <span class="idlvalue">null</span>.</p>
</li>
<li>
<p>
Reworked how operation overloading is specified
(the <span class="xattr">[Overloads]</span> extended attribute
is no longer needed), and how ECMAScript disambiguates
calls to overloaded operations.
</p>
</li>
<li>
<p>Filled in the “Host exception objects” section.</p>
</li>
<li>
<p>
Added an exception interface prototype object for constants
to live in. Added constants to interface objects, interface
prototype objects, exception interface objects and exception
interface prototype objects.
</p>
</li>
<li>
<p>Tweaked the behavior of sequences in ECMAScript.</p>
</li>
<li>
<p>
Added an editorial note about the possibility of somehow
specifying HTML5’s <code>Image</code> constructor.
</p>
</li>
<li>
<p>
Added a <span class="xattr">[NoInterfaceObject]</span> extended attribute,
which prevents an ECMAScript interface object being created for the interface
on which it appears.
</p>
</li>
<li>
<p>Added a <span class="xattr">[Stringifies]</span> extended attribute.</p>
</li>
<li>
<p>
Fixed small bugs in <span class="prop">[[HasProperty]]</span>,
<span class="prop">[[Get]]</span> and <span class="prop">[[Put]]</span>
algorithms for ECMAScript host objects.
</p>
</li>
<li>
<p>
Added an editorial note about the possibility of an extended
attribute that specifies what properties get enumerated in
a for..in loop in ECMAScript.
</p>
</li>
</ul>
</dd>
<dt>17 October 2007 – FPWD</dt>
<dd>
<ul>
<li><p>Initial publication.</p></li>
</ul>
</dd>
</dl>
</div>
</div>
</body>
</html>