1. ์๊ฐ
์ด ์น์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
์ด ํ์ค์ ์น ๋ธ๋ผ์ฐ์ ์ ๊ตฌํ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ธฐ์ ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ์ธํฐํ์ด์ค ์ ์ ์ธ์ด, ์น IDL์ ์ ์ํฉ๋๋ค. ์น IDL์ ์น ํ๋ซํผ์ ์ผ๋ฐ์ ์ธ ์คํฌ๋ฆฝํธ ๊ฐ์ฒด์ ๋์์ ๋ณด๋ค ์ฝ๊ฒ ๋ช ์ธํ ์ ์๋๋ก ํ๋ ๋ค์ํ ๊ธฐ๋ฅ์ ๊ฐ์ง IDL ๋ณํ์ ๋๋ค. ์น IDL๋ก ๊ธฐ์ ๋ ์ธํฐํ์ด์ค๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ์คํ ํ๊ฒฝ ๋ด์ ๊ตฌ์กฐ์ ์ด๋ป๊ฒ ๋์๋๋์ง๋ ์ด๊ณณ์์ ์์ธํ ์ค๋ช ํฉ๋๋ค.
๊ตฌ์ฒด์ ์ผ๋ก, ์น IDL์ ์น ํ๋ซํผ ๊ฐ์ฒด์ ํ๋ฉด API๋ฅผ ๋ช ์ธํ๋ ๊ตฌ๋ฌธ๊ณผ, ๊ทธ API๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌ์กฐ๋ก ์ด๋ป๊ฒ ๋ํ๋๋์ง ์์ธํ ๊ธฐ์ ํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์ ์ ๊ณตํฉ๋๋ค. ์ด๋ก ์ธํด ๊ธ๋ก๋ฒ ์์ฑ ์ค์น, ์ซ์ ์ ๋ ฅ ์ฒ๋ฆฌ, ๋ฐ๋ณต ๋์ ๋ ธ์ถ๊ณผ ๊ฐ์ ์ผ๋ฐ์ ์ธ ์์ ๋ค์ด ์น ํ๋ซํผ ๋ช ์ธ์ ์ ์ฒด์์ ์ผ๊ด์ฑ์ ์ ์งํ ์ ์์ต๋๋ค. ์ด๋ฌํ ๋ช ์ธ์๋ค์ ์น IDL๋ก ์ธํฐํ์ด์ค๋ฅผ ๊ธฐ์ ํ๊ณ , ํ๋ก์ฆ๋ก API ๊ณ ์ ์ ์ธ๋ถ์ฌํญ์ ๋ช ์ธํฉ๋๋ค.
"์๋ฐ์คํฌ๋ฆฝํธ"๋ผ๋ ์ฉ์ด๋ ๊ณต์ ์ฉ์ด ECMAScript๊ฐ ์๋ ECMA-262๋ฅผ ์๋ฏธํ๋ฉฐ, ์๋ฐ์คํฌ๋ฆฝํธ๋ผ๋ ๋ช ์นญ์ด ๋ ๋๋ฆฌ ์๋ ค์ ธ ์๊ธฐ ๋๋ฌธ์ ์ฌ์ฉํฉ๋๋ค.
2. ์ธํฐํ์ด์ค ์ ์ ์ธ์ด
์ด ์น์
์์๋ ์น IDL์ด๋ผ๋ ์ธ์ด๋ฅผ ์ค๋ช
ํฉ๋๋ค. ์ด๋ ์น ํ๋ซํผ์ API๋ฅผ ์ ์ํ๋ ์ธํฐํ์ด์ค๋ฅผ ๋ช
์ธํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์น API๋ฅผ ์ ์ํ๋ ๋ช
์ธ์๋ ํ๋ ์ด์์
IDL
ํ๋๊ทธ๋จผํธ๋ฅผ ํฌํจํ์ฌ,
ํด๋น ๋ช
์ธ์์์ ์ ์๋ API์ ์ธํฐํ์ด์ค(๊ฐ์ฒด๊ฐ ๊ฐ์ง ์ ์๋ ์ํ์ ๋์)๋ฅผ ๊ธฐ์ ํฉ๋๋ค.
IDL ํ๋๊ทธ๋จผํธ๋
IDL ํ๋๊ทธ๋จผํธ์ ๋ฑ์ฅํ ์ ์๋ ๋ค์ํ ์ ์์ ์ข ๋ฅ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: ์ธํฐํ์ด์ค, ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ, ๋ถ๋ถ ๋ฏน์ค์ธ ์ ์, ์ฝ๋ฐฑ ํจ์, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค, ๋ค์์คํ์ด์ค, ๋ถ๋ถ ๋ค์์คํ์ด์ค ์ ์, ๋์ ๋๋ฆฌ, ๋ถ๋ถ ๋์ ๋๋ฆฌ ์ ์, ํ์ ์ ์(typedef) ๋ฐ includes ๋ฌธ์ ๋๋ค. ๋ชจ๋ ์ข ๋ฅ๋ ์๋ ์น์ ์์ ์ ์๋ฉ๋๋ค.
๊ฐ ์ ์
(
[extended_attributes ]interface identifier { /* interface_members... */ };
Definitions ::ExtendedAttributeList Definition Definitions ฮต
Definition ::CallbackOrInterfaceOrMixin Namespace Partial Dictionary Enum Typedef IncludesStatement
์๋๋ IDL ํ๋๊ทธ๋จผํธ์ ์์์ ๋๋ค.
[Exposed =Window ]interface Paint { }; [Exposed =Window ]interface SolidColor :Paint {attribute double red ;attribute double green ;attribute double blue ; }; [Exposed =Window ]interface Pattern :Paint {attribute DOMString imageURL ; }; [Exposed =Window ]interface GraphicalWindow {constructor ();readonly attribute unsigned long width ;readonly attribute unsigned long height ;attribute Paint currentPaint ;undefined drawRectangle (double x ,double y ,double width ,double height );undefined drawText (double x ,double y ,DOMString text ); };
์ฌ๊ธฐ์๋ ๋ค ๊ฐ์ ์ธํฐํ์ด์ค๊ฐ ์ ์๋๊ณ ์์ต๋๋ค.
GraphicalWindow ์ธํฐํ์ด์ค์๋ ๋ ๊ฐ์
์ฝ๊ธฐ ์ ์ฉ ์์ฑ,
ํ๋์ ์ฐ๊ธฐ ๊ฐ๋ฅํ ์์ฑ, ๊ทธ๋ฆฌ๊ณ ๋ ๊ฐ์ ์ฐ์ฐ์ด
์ ์๋์ด ์์ต๋๋ค. GraphicalWindow ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ค์ ํด๋น ์ธ์ด์ ๋ง๋ ๋ฐฉ์์ผ๋ก ์ด ์์ฑ๊ณผ ์ฐ์ฐ์ ๋
ธ์ถํฉ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ์์๋, IDL ์ธํฐํ์ด์ค์ ์์ฑ๋ค์ด ์ ๊ทผ์ ์์ฑ์ผ๋ก, ์ฐ์ฐ๋ค์ ๋ชจ๋ GraphicalWindow ๊ฐ์ฒด์ ํ๋กํ ํ์
๊ฐ์ฒด์ ๋ด์ฅ ํจ์
๊ฐ์ฒด(built-in function object)๋ก์ ๋ฐ์ดํฐ ์์ฑ์ผ๋ก ๋
ธ์ถ๋ฉ๋๋ค. ๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ
๊ฐ์ฒด๋ GraphicalWindow๋ฅผ ๊ตฌํํ๋ฉด ํด๋น ํ๋กํ ํ์
๊ฐ์ฒด๋ฅผ ํ๋กํ ํ์
์ฒด์ธ์ ๊ฐ๊ฒ ๋ฉ๋๋ค.
GraphicalWindow์ ๋ฑ์ฅํ๋ ์์ฑ์ ์ฐ์ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์ฒด์์ ์์ฑ์๊ฐ ์กด์ฌํ๋๋ก ํ์ฌ,
new GraphicalWindow()๋ฅผ ํธ์ถํ๋ฉด ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ์๋ก์ด ๊ฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค.
๋ชจ๋ ์ธํฐํ์ด์ค์๋ [Exposed] ํ์ฅ ์์ฑ์ด
๋ถ์ด ์์ผ๋ฉฐ, ์ด๋ก ์ธํด ์ธํฐํ์ด์ค๊ฐ realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๊ฐ Window
๊ฐ์ฒด์ธ ๊ฒฝ์ฐ์๋ง ์ฌ์ฉํ ์ ์๋๋ก ๋ณด์ฅํฉ๋๋ค.
2.1. ์ด๋ฆ
๋ชจ๋ ์ธํฐํ์ด์ค,
๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์,
๋ค์์คํ์ด์ค,
๋ถ๋ถ ๋ค์์คํ์ด์ค ์ ์,
๋์
๋๋ฆฌ,
๋ถ๋ถ ๋์
๋๋ฆฌ ์ ์,
์ด๊ฑฐํ,
์ฝ๋ฐฑ ํจ์,
์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๋ฐ
ํ์
์ ์(typedef) (์ด๋ค์ ํตํ์ด ์ด๋ฆ์ด ์๋ ์ ์์ด๋ผ ํจ)
๊ทธ๋ฆฌ๊ณ ๋ชจ๋ ์์,
์์ฑ,
๋์
๋๋ฆฌ ๋ฉค๋ฒ๋
์๋ณ์๋ฅผ ๊ฐ์ง๋ฉฐ, ์ผ๋ถ
์ฐ์ฐ๋ ๋ง์ฐฌ๊ฐ์ง์
๋๋ค.
์๋ณ์๋ ์ ์ธ ๋ด ์ด๋๊ฐ์ ๋ฑ์ฅํ๋
-
์ด๋ฆ์ด ์๋ ์ ์์ ๊ฒฝ์ฐ,
identifier ํ ํฐ์ดinterface ,namespace ,dictionary ,enum ๋๋callback ํค์๋ ๋ฐ๋ก ๋ค์ ๋์ค๋ฉฐ, ์ด ํ ํฐ์ด ํด๋น ์ ์์ ์๋ณ์๋ฅผ ๊ฒฐ์ ํฉ๋๋ค.interface interface_identifier { /* interface_members... */ };partial interface interface_identifier { /* interface_members... */ };namespace namespace_identifier { /* namespace_members... */ };partial namespace namespace_identifier { /* namespace_members... */ };dictionary dictionary_identifier { /* dictionary_members... */ };partial dictionary dictionary_identifier { /* dictionary_members... */ };enum enumeration_identifier {"enum" ,"values" /* , ... */ };callback callback_identifier =return_type (/* arguments... */);callback interface callback_interface_identifier { /* interface_members... */ }; -
์์ฑ, ํ์ ์ ์, ๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ๊ฒฝ์ฐ, ์ ์ธ ๋ง์ง๋ง์ ์ธ๋ฏธ์ฝ๋ก ์์ ์์นํ
identifier ํ ํฐ์ด ์๋ณ์๋ฅผ ๊ฒฐ์ ํฉ๋๋ค.[
extended_attributes ]interface identifier {attribute type attribute_identifier ; };typedef type typedef_identifier ;dictionary identifier {type dictionary_member_identifier ; }; -
์์์ ๊ฒฝ์ฐ, ๋ฑํธ ์์ ์์นํ
identifier ํ ํฐ์ด ์๋ณ์๋ฅผ ๊ฒฐ์ ํฉ๋๋ค.const type constant_identifier = 42; -
์ฐ์ฐ์ ๊ฒฝ์ฐ, ๋ฐํ ํ์ ๋ค, ์ฌ๋ ๊ดํธ ์์ ์์นํ
identifier ํ ํฐ(์ฆ,OptionalOperationName ๋ฌธ๋ฒ ๊ธฐํธ์ ์ผ๋ถ๋ก ๋งค์นญ๋๋ ํ ํฐ)์ด ์ฐ์ฐ์ ์๋ณ์๋ฅผ ๊ฒฐ์ ํฉ๋๋ค. ๋ง์ฝ ํด๋นidentifier ํ ํฐ์ด ์๋ค๋ฉด, ์ฐ์ฐ์ ์๋ณ์๋ฅผ ๊ฐ์ง์ง ์์ต๋๋ค.interface interface_identifier {return_type operation_identifier (/* arguments... */); };
์ฐธ๊ณ : ์ฐ์ฐ์ getter, setter์ ๊ฐ์ ํน์ ์ฐ์ฐ์ ์ ์ธํ ๋ ์๋ณ์๊ฐ ์์ ์ ์์ต๋๋ค.
์ด๋ฌํ ๋ชจ๋ ๊ตฌ์กฐ์์, ์๋ณ์๋
์ฐธ๊ณ : ์์ ์ค๋ U+005F (_)๋ ์๋ณ์๊ฐ ์์ฝ์ด์ฒ๋ผ ๋ณด์ด์ง ์๊ฒ ํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ฉฐ, ์๋ฅผ
๋ค์ด "interface"๋ผ๋ ์ด๋ฆ์ ์ธํฐํ์ด์ค๋ฅผ ์ ์ํ ์ ์์ต๋๋ค. ์๋ณ์๋ฅผ ํด์ ํ ๋๋ ์์ U+005F (_)๋ฅผ ์ญ์ ํฉ๋๋ค.
์ฐ์ฐ์ ์ธ์(argument)๋ ๋ ๋์ ๋ฒ์์ ์๋ณ์ ์งํฉ์ ๊ฐ์ง ์ ์์ต๋๋ค. ์ฐ์ฐ ์ ์ธ์์ ์ธ์์ ์๋ณ์๋ ํ์
๋ค์ ๋ฐ๋ก ๋ช
์๋๋ฉฐ,
interface interface_identifier {return_type operation_identifier (argument_type argument_identifier /* , ... */); };
ArgumentNameKeyword ::attribute callback const constructor deleter dictionary enum getter includes inherit interface iterable maplike mixin namespace partial readonly required setlike setter static stringifier typedef unrestricted
์์ ์ธ๊ธ๋ IDL ๊ตฌ์กฐ(์ฐ์ฐ ์ธ์ ์ ์ธ)์ ์๋ณ์๋
"constructor", "toString"์ด๊ฑฐ๋ U+005F (_)๋ก ์์ํด์๋ ์ ๋ฉ๋๋ค. ์ด๋ฐ ๊ฒ๋ค์ ์์ฝ ์๋ณ์๋ผ ๋ถ๋ฆ
๋๋ค.
"toJSON" ์๋ณ์๋ ์์ฝ ์๋ณ์๋
์๋์ง๋ง,
์ ์ ์ฐ์ฐ์์๋ง ๊ฐ์ฒด๋ฅผ JSON ํ์
์ผ๋ก ๋ณํํ๋ ๋ชฉ์ ์ผ๋ก ์ฌ์ฉํด์ผ ํ๋ฉฐ,
ยงโฏ2.5.3.1 toJSON์์ ์ค๋ช
ํฉ๋๋ค.
์ฐธ๊ณ : ํน์ ๊ตฌ์กฐ์ ๋ํ ์๋ณ์ ๋ช ๋ช ์ ํ์ ์ดํ ์น์ ์์ ์ถ๊ฐ๋ ์ ์์ต๋๋ค.
์ฃผ์ด์ง ๊ตฌํ์ฒด๊ฐ ์ง์ํ๋ IDL ํ๋๊ทธ๋จผํธ ์งํฉ ๋ด์์, ๋ชจ๋ ์ธํฐํ์ด์ค, ๋ค์์คํ์ด์ค, ๋์ ๋๋ฆฌ, ์ด๊ฑฐํ, ์ฝ๋ฐฑ ํจ์, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์ธํฐํ์ด์ค, ํ์ ์ ์์ ์๋ณ์๋ ๋ค๋ฅธ ์ธํฐํ์ด์ค, ๋ค์์คํ์ด์ค, ๋์ ๋๋ฆฌ, ์ด๊ฑฐํ, ์ฝ๋ฐฑ ํจ์, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค, ํ์ ์ ์์ ์๋ณ์์ ๊ฐ์์๋ ์ ๋ฉ๋๋ค.
ํ๋์ IDL ํ๋๊ทธ๋จผํธ ๋ด์์๋, ์ ์์ ๋ํ ์ฐธ์กฐ๊ฐ ์ฐธ์กฐ๋ ์ ์์ ์ ์ธ ๋ค์ ๋ฑ์ฅํ์ง ์์๋ ๋ฉ๋๋ค. ๋ํ IDL ํ๋๊ทธ๋จผํธ ๊ฐ์๋ ์ฐธ์กฐํ ์ ์์ต๋๋ค.
๋ฐ๋ผ์, ์๋์ IDL ํ๋๊ทธ๋จผํธ๋ ์ ํจํฉ๋๋ค:
[Exposed =Window ]interface B :A {undefined f (SequenceOfLongs x ); }; [Exposed =Window ]interface A { };typedef sequence <long >SequenceOfLongs ;
์๋์ IDL ํ๋๊ทธ๋จผํธ๋ ์ ์์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ์ ์ด๋ป๊ฒ ์๋ณ์๊ฐ ๋ถ์ฌ๋๋์ง ๋ณด์ฌ์ค๋๋ค.
// ํ์ ์ ์ ์๋ณ์: "number"typedef double number ; // ์ธํฐํ์ด์ค ์๋ณ์: "System" [Exposed =Window ]interface System { // ์ฐ์ฐ ์๋ณ์: "createObject" // ์ฐ์ฐ ์ธ์ ์๋ณ์: "interface"object createObject (DOMString _interface ); // ์ฐ์ฐ ์ธ์ ์๋ณ์: "interface"sequence <object >getObjects (DOMString interface ); // ์ฐ์ฐ์๋ ์๋ณ์๊ฐ ์์; getter ์ ์ธ์.getter DOMString (DOMString keyName ); }; // ์ธํฐํ์ด์ค ์๋ณ์: "TextField" [Exposed =Window ]interface TextField { // ์์ฑ ์๋ณ์: "const"attribute boolean _const ; // ์์ฑ ์๋ณ์: "value"attribute DOMString ?_value ; };
TextField ์ธํฐํ์ด์ค์ ๋ ๋ฒ์งธ ์์ฑ์ (IDL ๋ฌธ๋ฒ์์ "value"๊ฐ ํค์๋๊ฐ ์๋๋ฏ๋ก) ๋ฐ๋์ ๋ฐ์ค๋ก ์ด์ค์ผ์ดํํ ํ์๋ ์์ง๋ง, ๊ทธ๋๋ ์์ฑ์ ์๋ณ์๋ฅผ ์ป๊ธฐ ์ํด ์ธ์ด์ค์ผ์ดํ๋ฉ๋๋ค.
2.2. ์ธํฐํ์ด์ค
IDL ํ๋๊ทธ๋จผํธ๋ ๊ฐ์ฒด ์งํฅ ์์คํ
์
๊ธฐ์ ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ด๋ฌํ ์์คํ
์์ ๊ฐ์ฒด๋ ์ ์ฒด์ฑ์ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, ์ํ์ ํ๋์ ์บก์ํํ ์ํฐํฐ์
๋๋ค.
์ธํฐํ์ด์ค๋
(
[extended_attributes ]interface identifier { /* interface_members... */ };
์ธํฐํ์ด์ค๋
์ธํฐํ์ด์ค ๋ฉค๋ฒ
(
์น IDL์ ์ธํฐํ์ด์ค๋ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ์ด๋ป๊ฒ ๋์ํ๋์ง ๊ธฐ์ ํฉ๋๋ค. ๊ฐ์ฒด ์งํฅ ์ธ์ด ๋ฐ์ธ๋ฉ์์๋, ํน์ IDL ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ๊ฐ์ฒด์ ์ํ๋ฅผ ๊ฒ์ฌํ๊ณ ์์ ํ๋ฉฐ, ์ธํฐํ์ด์ค๊ฐ ๊ธฐ์ ํ๋ ๋์์ ํธ์ถํ ์ ์๋๋ก ์ ๊ณตํ๋ ๊ฒ์ด ๊ธฐ๋๋ฉ๋๋ค.
์ธํฐํ์ด์ค๋ ๋ค๋ฅธ ์ธํฐํ์ด์ค๋ฅผ ์์ํ๋๋ก ์ ์ํ ์ ์์ต๋๋ค. ๋ง์ฝ ์ธํฐํ์ด์ค ์๋ณ์ ๋ค์ U+003A (:)์ ์๋ณ์๊ฐ ์ค๋ฉด, ํด๋น ์๋ณ์๊ฐ ์์๋ฐ๋ ์ธํฐํ์ด์ค๋ฅผ ๋ํ๋ ๋๋ค. ์ด๋ค ๊ฐ์ฒด๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค๋ฅผ ์์ํ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด, ๊ทธ ๊ฐ์ฒด๋ ์์๋ฐ์ ์ธํฐํ์ด์ค๋ ๊ตฌํํ๊ฒ ๋ฉ๋๋ค. ์ฆ, ๊ฐ์ฒด๋ ์์๋ ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ๋ ๊ฐ์ง๊ฒ ๋ฉ๋๋ค.
interface identifier :identifier_of_inherited_interface { /* interface_members... */ };
๋ฉค๋ฒ์ ๋ฑ์ฅ ์์๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ํ๋กํผํฐ ์ด๊ฑฐ์ ์ํฅ์ ๋ฏธ์นฉ๋๋ค.
์ธํฐํ์ด์ค๋ ์์๋ฐ์ ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ์ ๊ฐ์ ์ด๋ฆ์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ๋ฅผ ๋ช ์ํ ์๋ ์์ต๋๋ค. ํ์ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ ํ์ ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ๋ฅผ ๋ ธ์ถํฉ๋๋ค. ์ค๋ฒ๋ผ์ด๋๋ ๋ฉค๋ฒ๋ฅผ ๊ฐ์ฒด์์ ์ ๊ทผํ ์ ์๋์ง๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ ๋ฐ๋ผ ๋ค๋ฆ ๋๋ค.
๋ค์ ๋ ๊ฐ์ ์ธํฐํ์ด์ค๋ฅผ ์ดํด๋ด ์๋ค.
[Exposed =Window ]interface A {undefined f ();undefined g (); }; [Exposed =Window ]interface B :A {undefined f ();undefined g (DOMString x ); };
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ B์ ์ธ์คํด์ค๋ ์๋์ ๊ฐ์ ํ๋กํ ํ์
์ฒด์ธ์ ๊ฐ์ง๋๋ค:
[Object.prototype: Object ํ๋กํ ํ์
๊ฐ์ฒด]
โ
[A.prototype: A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด]
โ
[B.prototype: B์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด]
โ
[instanceOfB]
์๋ฐ์คํฌ๋ฆฝํธ์์ instanceOfB.f()๋ฅผ ํธ์ถํ๋ฉด B์ ์ ์๋ f๊ฐ ์คํ๋ฉ๋๋ค. ํ์ง๋ง A์ f๋
A.prototype.f.call(instanceOfB)๋ก ํธ์ถํ ์ ์์ต๋๋ค.
์ฃผ์ด์ง ์ธํฐํ์ด์ค A์ ์์ ์ธํฐํ์ด์ค๋ค์ A๊ฐ ์ง์ ๋๋ ๊ฐ์ ์ ์ผ๋ก ์์ํ๋ ๋ชจ๋ ์ธํฐํ์ด์ค์ ์งํฉ์ ๋๋ค. A๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค๋ฅผ ์์ํ์ง ์์ผ๋ฉด ์งํฉ์ ๋น์ด ์์ต๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด, ์งํฉ์๋ A๊ฐ ์์ํ๋ ์ธํฐํ์ด์ค B์ B์ ์์ ์ธํฐํ์ด์ค๋ค์ด ํฌํจ๋ฉ๋๋ค.
์ธํฐํ์ด์ค์ ์์ ๊ณ์ธต์ ์ํ(cycle)์ด ์์ด์๋ ์ ๋ฉ๋๋ค. ์ฆ, ์ธํฐํ์ด์ค A๊ฐ ์๊ธฐ ์์ ์ ์์ํ๊ฑฐ๋, B์์ A๋ฅผ ์์ํ๋ ๋ฑ ๋ฐ๋ณต์ ์ผ๋ก ์์ํ ์ ์์ต๋๋ค.
-
result๋ฅผ ยซ ยป๋ก ๋๋ค.
-
interface๋ฅผ I๋ก ๋๋ค.
-
interface๊ฐ null์ด ์๋ ๋์:
-
interface๋ฅผ I๊ฐ ์์ํ๋ ์ธํฐํ์ด์ค๋ก ์ค์ ํ๊ณ , ์์ผ๋ฉด null๋ก ํ๋ค.
-
result๋ฅผ ๋ฐํํ๋ค.
์ผ๋ฐ์ ์ธ ์ธํฐํ์ด์ค์ ๋ค์ค ์์์ ์ง์ํ์ง ์์ผ๋ฉฐ, ๊ฐ์ฒด๋ ์์์ ์ธํฐํ์ด์ค ์งํฉ์ ๊ตฌํํ ์ ์์ต๋๋ค. ๊ฐ์ฒด๋ ํ๋์ ์ฃผ์ด์ง ์ธํฐํ์ด์ค A๋ฅผ ๊ตฌํํ๋๋ก ์ ์๋๋ฉฐ, ์ด๋ A์ ์์ ์ธํฐํ์ด์ค๋ค๋ ๊ตฌํํจ์ ์๋ฏธํฉ๋๋ค. ์ถ๊ฐ๋ก, includes ๋ฌธ์ ์ฌ์ฉํ์ฌ ์ธํฐํ์ด์ค A๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ ๋ฉค๋ฒ๋ ํญ์ ํฌํจํ๋๋ก ์ ์ํ ์ ์์ต๋๋ค. A๊ฐ includeํ๋ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ๋ฉค๋ฒ๋ฅผ ํฌํจํฉ๋๋ค.
๊ฐ ์ธํฐํ์ด์ค ๋ฉค๋ฒ๋ ํ์ฅ
์์ฑ ๋ฆฌ์คํธ(
[extended_attributes ]interface identifier { [extended_attributes ]const type constant_identifier = 42; [extended_attributes ]attribute type identifier ; [extended_attributes ]return_type identifier (/* arguments... */); };
์ธํฐํ์ด์ค์ ๋ํ IDL์
๋ถ๋ถ ์ธํฐํ์ด์ค
์ ์(
interface SomeInterface { /* interface_members... */ };partial interface SomeInterface { /* interface_members... */ };
์ฐธ๊ณ : ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์๋ ๋ช ์ธ ํธ์ง ์, ํ๋์ ์ธํฐํ์ด์ค ์ ์๋ฅผ ์ฌ๋ฌ ๋ฌธ์ ๋๋ ์ฌ๋ฌ ์น์ ์ ๋๋ ์ ๊ธฐ์ ํ๋ ๋ฐ ๋์์ ์ฃผ๊ธฐ ์ํ ๊ฒ์ ๋๋ค.
์ธํฐํ์ด์ค ์ ์์ ๊ทธ ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์์ ๋ฑ์ฅ ์์๋ ์ค์ํ์ง ์์ต๋๋ค.
์ฐธ๊ณ : ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์๋ ์ธํฐํ์ด์ค๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค๋ฅผ ์์ํ๋๋ก ์ง์ ํ ์ ์์ต๋๋ค. ์์์ ์๋์ ์ธํฐํ์ด์ค ์ ์์์ ์ง์ ํด์ผ ํฉ๋๋ค.
์ ์ฉ๋๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ด ์ธํฐํ์ด์ค๊ฐ ํด๋น ์ธ์ด์ ๊ตฌ์กฐ์ ์ด๋ป๊ฒ ๋์๋๋์ง ๊ฒฐ์ ํฉ๋๋ค.
๋ค์ ํ์ฅ ์์ฑ๋ค์ด ์ธํฐํ์ด์ค์ ์ ์ฉ๋ ์ ์์ต๋๋ค:
[CrossOriginIsolated],
[Exposed],
[Global],
[LegacyFactoryFunction],
[LegacyNoInterfaceObject],
[LegacyOverrideBuiltIns],
[LegacyWindowAlias],
[SecureContext].
๋ค์ ํ์ฅ ์์ฑ๋ค์ ๋ถ๋ถ
์ธํฐํ์ด์ค์ ์ ์ฉ๋ ์ ์์ต๋๋ค:
[CrossOriginIsolated],
[Exposed],
[LegacyOverrideBuiltIns],
[SecureContext].
์ธํฐํ์ด์ค๋ ๋ฐ๋์ [Exposed] ํ์ฅ ์์ฑ์ผ๋ก ์ฃผ์
์ฒ๋ฆฌํด์ผ ํฉ๋๋ค.
์ธํฐํ์ด์ค interface์ ์ ๊ทํ๋ ์ด๋ฆ์ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ฉ๋๋ค:
-
identifier๋ฅผ interface์ ์๋ณ์๋ก ๋๋ค.
-
interface์ [
LegacyNamespace] ํ์ฅ ์์ฑ์ด ์์ผ๋ฉด:-
namespace๋ฅผ [
LegacyNamespace] ํ์ฅ ์์ฑ์ ์๋ณ์ ์ธ์๋ก ๋๋ค. -
ยซ namespace, identifier ยป๋ฅผ U+002E (.)๋ก ์ฐ๊ฒฐํ์ฌ ๋ฐํํ๋ค.
-
-
identifier๋ฅผ ๋ฐํํ๋ค.
CallbackOrInterfaceOrMixin ::callback CallbackRestOrInterface interface InterfaceOrMixin
InterfaceOrMixin ::InterfaceRest MixinRest
InterfaceRest ::identifier Inheritance { InterfaceMembers } ;
Partial ::partial PartialDefinition
PartialDefinition ::interface PartialInterfaceOrPartialMixin PartialDictionary Namespace
PartialInterfaceOrPartialMixin ::PartialInterfaceRest MixinRest
PartialInterfaceRest ::identifier { PartialInterfaceMembers } ;
InterfaceMembers ::ExtendedAttributeList InterfaceMember InterfaceMembers ฮต
InterfaceMember ::PartialInterfaceMember Constructor
PartialInterfaceMembers ::ExtendedAttributeList PartialInterfaceMember PartialInterfaceMembers ฮต
PartialInterfaceMember ::Const Operation Stringifier StaticMember Iterable AsyncIterable ReadOnlyMember ReadWriteAttribute ReadWriteMaplike ReadWriteSetlike InheritAttribute
Inheritance ::: identifier ฮต
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์ํธ
์ฐธ์กฐํ๋ ๋ ์ธํฐํ์ด์ค์ ์ ์๋ฅผ ๋ณด์ฌ์ค๋๋ค.
Human๊ณผ Dog๋ ๋ชจ๋ Animal์ ์์ํฉ๋๋ค.
์ด ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ name ์์ฑ์ ๊ฐ๊ฒ ๋ฉ๋๋ค.
[Exposed =Window ]interface Animal {attribute DOMString name ; }; [Exposed =Window ]interface Human :Animal {attribute Dog ?pet ; }; [Exposed =Window ]interface Dog :Animal {attribute Human ?owner ; };
์๋ IDL ํ๋๊ทธ๋จผํธ๋ DOM ์ธํฐํ์ด์ค์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์ ๋จ์ํ๋ ์ ์๋ฅผ ๋ณด์ฌ์ค๋๋ค.
[Exposed =Window ]interface Node {readonly attribute DOMString nodeName ;readonly attribute Node ?parentNode ;Node appendChild (Node newChild );undefined addEventListener (DOMString type ,EventListener listener ); };callback interface EventListener {undefined handleEvent (Event event ); };
์ผ๋ฐ ๊ฐ์ฒด๋ EventListener์ ๊ฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ์ ์์ต๋๋ค:
var node= getNode(); // Node ์ธ์คํด์ค ์ป๊ธฐ var listener= { handleEvent: function ( event) { // ... } }; node. addEventListener( "click" , listener); // ๋์ํจ node. addEventListener( "click" , function () { ... }); // ์ด๊ฒ๋ ๋์ํจ
์ด๋ฐ ๊ฐ์ฒด๋ Node์ ๊ฐ์ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ์๋ ์์ต๋๋ค:
var node= getNode(); // Node ์ธ์คํด์ค ์ป๊ธฐ var newNode= { nodeName: "span" , parentNode: null , appendChild: function ( newchild) { // ... }, addEventListener: function ( type, listener) { // ... } }; node. appendChild( newNode); // TypeError ์์ธ ๋ฐ์
2.3. ์ธํฐํ์ด์ค ๋ฏน์ค์ธ
์ธํฐํ์ด์ค ๋ฏน์ค์ธ์
(
interface mixin identifier { /* mixin_members... */ };
์ฐธ๊ณ : ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ๋ถ๋ถ ์ธํฐํ์ด์ค์ ๋ง์ฐฌ๊ฐ์ง๋ก, ๋ช ์ธ ํธ์ง์ ํธ์๋ฅผ ์ํด ์ฌ์ฉ๋์ด ์ผ๊ด๋ ๊ธฐ๋ฅ ์งํฉ์ ๋ฌถ๊ณ , ์ฌ๋ฌ ์ธํฐํ์ด์ค(๋ฌธ์ ๊ฐ ํฌํจ ๊ฐ๋ฅ)์ ํฌํจํ ์ ์๊ฒ ํฉ๋๋ค. ์ธ์ด ๋ฐ์ธ๋ฉ์ ํตํด ์ง์ ๋ ธ์ถ๋๋๋ก ์๋๋ ๊ฒ์ด ์๋๋๋ค. ยงโฏ2.3.1 ๋ฏน์ค์ธ ๋ฐ ๋ถ๋ถ ์ฌ์ฉ์์ ๋ถ๋ถ ์ธํฐํ์ด์ค, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ, ๋ถ๋ถ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ ์ค ์ด๋ ๊ฒ์ ์ ํํ ์ง ์ค๋ช ํฉ๋๋ค.
์ธํฐํ์ด์ค ๋ฏน์ค์ธ์
์ธํฐํ์ด์ค ๋ฏน์ค์ธ ๋ฉค๋ฒ
(
์ด๋ฌํ ์์ , ์ผ๋ฐ ์ฐ์ฐ , ์ผ๋ฐ ์์ฑ , ๋ฌธ์์ด ๋ณํ์ ๋ ๊ฐ์ฒด๊ฐ ๊ตฌํํ ์ ์๋ ๋์์ ๊ธฐ์ ํ๋ฉฐ, ๋ง์น ์ด๋ฅผ ํฌํจํ๋ ์ธํฐํ์ด์ค ์ ์ง์ ๋ช ์ธํ ๊ฒ์ฒ๋ผ ๋์ํฉ๋๋ค.
์ ์ ์์ฑ, ์ ์ ์ฐ์ฐ, ํน์ ์ฐ์ฐ, ์ดํฐ๋ฌ๋ธ, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ, maplike, setlike ์ ์ธ์ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ ์ ์ธ์ ํฌํจ๋ ์ ์์ต๋๋ค.
์ธํฐํ์ด์ค์ ๋ง์ฐฌ๊ฐ์ง๋ก, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์
IDL๋ ๋ถ๋ถ ์ธํฐํ์ด์ค
๋ฏน์ค์ธ ์ ์(
interface mixin SomeMixin { /* mixin_members... */ };partial interface mixin SomeMixin { /* mixin_members... */ };
๋ฉค๋ฒ์ ๋ฑ์ฅ ์์๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ํ๋กํผํฐ ์ด๊ฑฐ์ ์ํฅ์ ์ค๋๋ค.
์ธํฐํ์ด์ค๋ ๋์ ๋๋ฆฌ์ ๋ฌ๋ฆฌ, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ํ์ ์ ์์ฑํ์ง ์์ต๋๋ค.
์ด ๋ช
์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ ์ค,
[CrossOriginIsolated],
[Exposed], [SecureContext]
๋ง ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ์ ์ฉ๋ฉ๋๋ค.
includes ๋ฌธ์
(
interface_identifier includes mixin_identifier ;
์ฒซ ๋ฒ์งธ ์๋ณ์๋ ์ธํฐํ์ด์ค I๋ฅผ ์ฐธ์กฐํด์ผ ํ๋ฉฐ, ๋ ๋ฒ์งธ ์๋ณ์๋ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ M์ ์ฐธ์กฐํด์ผ ํฉ๋๋ค.
M์ ๊ฐ ๋ฉค๋ฒ๋ ์ธํฐํ์ด์ค I, J, K ๋ฑ includeํ๋ ๋ชจ๋ ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ๋ก ๊ฐ์ฃผ๋ฉ๋๋ค. ์ฆ, M์ ๋ฉค๋ฒ m์ ๋ํด I๋ ๋ฉค๋ฒ mI, J๋ ๋ฉค๋ฒ mJ, K๋ ๋ฉค๋ฒ mK๋ฅผ ๊ฐ๊ฒ ๋ฉ๋๋ค. ํธ์คํธ ์ธํฐํ์ด์ค๋ mI, mJ, mK์ ๊ฐ๊ฐ์ I, J, K๋ฅผ ๋งํฉ๋๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ์์๋, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ ๋ฉค๋ฒ๋ก ์ ์ธ๋ ์ผ๋ฐ ์ฐ์ฐ์ด ๋ด์ฅ ํจ์ ๊ฐ์ฒด ๊ฐ์ ๋ฐ์ดํฐ ์์ฑ์ผ๋ก ๋ ธ์ถ๋ ๋, ์ฐ๊ฒฐ๋ ์ธํฐํ์ด์ค๊ฐ M์ ํฌํจํ๋ ๊ฐ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ง๋ค ๋ณ๋ ๋ด์ฅ ํจ์ ๊ฐ์ฒด๊ฐ ์์ฑ๋ฉ๋๋ค. ์์ฑ๋ ๋ง์ฐฌ๊ฐ์ง๋ก ์ ๊ทผ์ ์์ฑ์ getter์ setter๊ฐ ๊ฐ๊ฐ ๋ณ๋ ๋ด์ฅ ํจ์ ๊ฐ์ฒด๊ฐ ๋ฉ๋๋ค.
includes ๋ฌธ์ ๋ฑ์ฅ ์์๋ ํธ์คํธ ์ธํฐํ์ด์ค์์ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ด ํฌํจ๋๋ ์์์ ์ํฅ์ ์ค๋๋ค.
๋ฉค๋ฒ ์์๋ ๋ช ํํ ๊ท์ ๋์ด ์์ง ์์ผ๋ฉฐ, ํนํ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ด ๋ณ๋ ๋ฌธ์์ ์ ์๋ ๋ ๋์ฑ ๊ทธ๋ ์ต๋๋ค. issue #432์์ ๋ ผ์๋๊ณ ์์ต๋๋ค.
์ด ๋ช ์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ ์ค includes ๋ฌธ์ ์ ์ฉ ๊ฐ๋ฅํ ๊ฒ์ ์์ต๋๋ค.
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์ธํฐํ์ด์ค Entry์ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ Observable์ ์ ์๋ฅผ ๋ณด์ฌ์ค๋๋ค.
includes ๋ฌธ์
Observable์ ๋ฉค๋ฒ๋ค์ด Entry๋ฅผ ๊ตฌํํ๋ ๋ชจ๋ ๊ฐ์ฒด์ ํญ์ ํฌํจ๋๋ค๋
๊ฒ์ ๋ช
์ํฉ๋๋ค.
interface Entry {readonly attribute unsigned short entryType ; // ... };interface mixin Observable {undefined addEventListener (DOMString type ,EventListener listener ,boolean useCapture ); // ... };Entry includes Observable ;
์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋ ๋ชจ๋ Entry์ ํ๋กํ ํ์
์ฒด์ธ์ addEventListener ์์ฑ์ด
์๊ฒ ๋ฉ๋๋ค:
var e= getEntry(); // Entry ์ธ์คํด์ค ์ป๊ธฐ typeof e. addEventListener; // "function"์ผ๋ก ํ๊ฐ๋จ
CallbackOrInterfaceOrMixin ::callback CallbackRestOrInterface interface InterfaceOrMixin
Partial ::partial PartialDefinition
MixinRest ::mixin identifier { MixinMembers } ;
MixinMembers ::ExtendedAttributeList MixinMember MixinMembers ฮต
MixinMember ::Const RegularOperation Stringifier OptionalReadOnly AttributeRest
IncludesStatement ::identifier includes identifier ;
2.3.1. ๋ฏน์ค์ธ ๋ฐ ๋ถ๋ถ ์ฌ์ฉ
์ด ์น์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ์์ฑ, ์์, ์ฐ์ฐ์ ์ฌ๋ฌ ์ธํฐํ์ด์ค์ ๊ณต์ ํ ์ ์๊ฒ ํด์ค๋๋ค. ๋ง์ฝ ํ๋์ ์ธํฐํ์ด์ค๋ง ํ์ฅํ๋ ค๋ ๊ฒฝ์ฐ๋ผ๋ฉด ๋ถ๋ถ ์ธํฐํ์ด์ค ์ฌ์ฉ์ ๊ณ ๋ คํ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค๋ฉด, ๋ค์๊ณผ ๊ฐ์ด ํ์ง ๋ง๊ณ :
interface mixin WindowSessionStorage {readonly attribute Storage sessionStorage ; };Window includes WindowSessionStorage ;
์ด๋ ๊ฒ ํ์ธ์:
partial interface Window {readonly attribute Storage sessionStorage ; };
๋ํ, ๋ค๋ฅธ ๋ช ์ธ์์ ๋ ธ์ถํ๋ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ํ์ฅํ์ฌ window์ worker ๋ฑ ์ฌ๋ฌ ์ปจํ ์คํธ์ ์์ฑ, ์์, ์ฐ์ฐ์ ๋ ธ์ถํ๋ ๋ฑ ๊ณตํต์ ์ธ ํ์ฉ ์ฌ๋ก๋ฅผ ํ๊ฒํ ์๋ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ํํ์ง๋ง ์ฅํฉํ ๋ฐฉ์ ๋์ :
interface mixin GlobalCrypto {readonly attribute Crypto crypto ; };Window includes GlobalCrypto ;WorkerGlobalScope includes GlobalCrypto ;
WindowOrWorkerGlobalScope
์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ๋ถ๋ถ ์ธํฐํ์ด์ค
๋ฏน์ค์ธ์ผ๋ก ํ์ฅํ ์ ์์ต๋๋ค:
partial interface mixin WindowOrWorkerGlobalScope {readonly attribute Crypto crypto ; };
2.4. ์ฝ๋ฐฑ ์ธํฐํ์ด์ค
์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ ์ ์๋ก,
์ฐธ๊ณ : ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ ์ธํฐํ์ด์ค๊ฐ ์๋๋๋ค. ๋ช ์นญ๊ณผ ๋ฌธ๋ฒ์ ํ์ค์ ์ด์ ๋ฒ์ ์์ ์ ๋๋ ๊ฒ์ผ๋ก, ๋น์์๋ ๊ฐ๋ ์ ์ผ๋ก ๋ ๋ง์ ๊ณตํต์ ์ด ์์์ต๋๋ค.
์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋
์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๋ฉค๋ฒ
(
callback interface identifier { /* interface_members... */ };
์ฐธ๊ณ : ์ ์ฌํ ๋ช ์นญ์ ์ฝ๋ฐฑ ํจ์ ์ ์๋ ์ฐธ๊ณ ํ์ธ์.
์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ ์ ํํ ํ๋์ ์ผ๋ฐ ์ฐ์ฐ์ ์ ์ํด์ผ ํฉ๋๋ค.
๋ช ์ธ ์ ์๋ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ฅผ ๊ธฐ์กด API์ ์๊ตฌ์ฌํญ์ ๊ธฐ์ ํ ํ์๊ฐ ์๋ ํ ์ ์ํ์ง ์์์ผ ํฉ๋๋ค. ๋์ ์ฝ๋ฐฑ ํจ์๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
EventListener
๋ฅผ ์ฝ๋ฐฑ
์ธํฐํ์ด์ค๋ก ์ ์ํ ๊ฒ์,
ํน์ ์์ฑ(์ฌ๊ธฐ์๋ handleEvent)์ ๊ฐ์ง ๊ฐ์ฒด๊ฐ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ๊ฒ์ผ๋ก ๊ฐ์ฃผ๋ ์ ์๋๋ก ํด์ผ ํ๋ ๊ธฐ์กด API์ ์์
๋๋ค.
์๋ก์ด API๋ ํธํ์ฑ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ์๋,
์ฝ๋ฐฑ ํจ์๋ฅผ
์ฌ์ฉํ๋ฉด
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ํจ์ ๊ฐ์ฒด๋ง ํ์ฉ๋ฉ๋๋ค.
์ฝ๋ฐฑ ์ธํฐํ์ด์ค๊ฐ ์์๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ ๋ฐ๋์ [Exposed] ํ์ฅ ์์ฑ์ผ๋ก ์ฃผ์
์ฒ๋ฆฌํด์ผ ํฉ๋๋ค.
CallbackRestOrInterface ::CallbackRest interface identifier { CallbackInterfaceMembers } ;
CallbackInterfaceMembers ::ExtendedAttributeList CallbackInterfaceMember CallbackInterfaceMembers ฮต
CallbackInterfaceMember ::Const RegularOperation
2.5. ๋ฉค๋ฒ
์ธํฐํ์ด์ค, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ, ๋ค์์คํ์ด์ค๋
์ค๊ดํธ ์์ ๋ฑ์ฅํ๋ ๋ฉค๋ฒ(๊ฐ๊ฐ
์ด๋ค ์ธํฐํ์ด์ค๊ฐ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ includeํ๋ฉด, ํด๋น ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ๋ฉค๋ฒ๋ค๋ ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ๋ก ๊ฐ์ฃผ๋ฉ๋๋ค. ๋ฐ๋ฉด, ์์๋ฐ์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ๋ ํด๋น ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ๋ก ๊ฐ์ฃผํ์ง ์์ต๋๋ค.
์ฌ๋ฌ ๋ฉค๋ฒ์ ๋ํด ์ ์๋๋ ์์ฑ์ ๋จ๊ณ, getter ๋จ๊ณ, setter ๋จ๊ณ, ๋ฉ์๋ ๋จ๊ณ๋ ํด๋น ์ธํฐํ์ด์ค ๋๋ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ ์์ ์ ์๋ ๋ฉค๋ฒ์์ this ๊ฐ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด๋ ๋ฉค๋ฒ๊ฐ ์ ์ธ๋ ์ธํฐํ์ด์ค ํ์ , ํน์ ๋ฉค๋ฒ๊ฐ ์ ์ธ๋ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ includeํ ํ์ ์ IDL ๊ฐ์ ๋๋ค.
setter ๋จ๊ณ์์๋ ์ง์ ๋ ๊ฐ๋ ์ฌ์ฉํ ์ ์๋๋ฐ, ์ด๋ ํด๋น ์์ฑ์ด ์ ์ธ๋ ํ์ ์ IDL ๊ฐ์ ๋๋ค.
์ธํฐํ์ด์ค, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค, ๋ค์์คํ์ด์ค๋ ๊ฐ๊ฐ ์ง์ํ๋ ๋ฉค๋ฒ์ ์ข ๋ฅ๊ฐ ๋ค๋ฅด๋ฉฐ, ยงโฏ2.2 ์ธํฐํ์ด์ค, ยงโฏ2.3 ์ธํฐํ์ด์ค ๋ฏน์ค์ธ, ยงโฏ2.4 ์ฝ๋ฐฑ ์ธํฐํ์ด์ค, ยงโฏ2.6 ๋ค์์คํ์ด์ค์์ ์ค๋ช ํฉ๋๋ค. ์๋ ํ๋ ์ด๋ฅผ ์์ฝํ ์ฐธ๊ณ ์ฉ ํ์ ๋๋ค:
| ์ธํฐํ์ด์ค | ์ฝ๋ฐฑ ์ธํฐํ์ด์ค | ์ธํฐํ์ด์ค ๋ฏน์ค์ธ | ๋ค์์คํ์ด์ค | |
|---|---|---|---|---|
| ์์ | โ | โ | โ | |
| ์ผ๋ฐ ์์ฑ | โ | โ | ์ค์ง ์ฝ๊ธฐ ์ ์ฉ ์์ฑ๋ง | |
| ์ ์ ์์ฑ | โ | |||
| ์ผ๋ฐ ์ฐ์ฐ | โ | โ | โ | โ |
| ๋ฌธ์์ด ๋ณํ์ | โ | โ | ||
| ํน์ ์ฐ์ฐ | โ | |||
| ์ ์ ์ฐ์ฐ | โ | |||
| ์ดํฐ๋ฌ๋ธ ์ ์ธ | โ | |||
| ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ | โ | |||
| maplike ์ ์ธ | โ | |||
| setlike ์ ์ธ | โ |
2.5.1. ์์
์์๋
(
์์๋ ๊ณผ๊ฑฐ์ ์ฃผ๋ก ์ด๊ฑฐํ ์คํ์ผ๋ก ๋ช ๋ช ๋ ์ ์ ์ฝ๋๋ฅผ ์ ์ํ๋ ๋ฐ ์ฌ์ฉ๋์์ต๋๋ค. ์น ํ๋ซํผ์ ๋ฌธ์์ด ์ฌ์ฉ์ผ๋ก ์ด ํจํด์์ ๋ฒ์ด๋๊ณ ์์ต๋๋ค. ์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ ํธ์ง์๋ ์งํํ๊ธฐ ์ ์ ์ด์๋ฅผ ๋ฑ๋กํ์ฌ ๋ ผ์ํ ๊ฒ์ ๊ฐ๋ ฅํ ๊ถ๊ณ ํฉ๋๋ค.
const type constant_identifier = 42;
์์์ ์๋ณ์๋ ๋์ผํ ์ธํฐํ์ด์ค ๋ฉค๋ฒ ๋๋ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๋ฉค๋ฒ์ ์๋ณ์์ ๊ฐ์์๋ ์
๋ฉ๋๋ค(๋์ผํ ์ธํฐํ์ด์ค๋ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์
์ ์๋).
๋ํ "length", "name", "prototype"์ด์ด์๋ ์ ๋ฉ๋๋ค.
์ฐธ๊ณ : ์ด ์ธ ์ด๋ฆ์ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ์ธํฐํ์ด์ค ๊ฐ์ฒด์ ์ ์๋ ํ๋กํผํฐ ์ด๋ฆ์ ๋๋ค.
์์์ ํ์
(
์์ ์ ์ธ์
์ฐธ๊ณ : ์ด ๊ฐ๋ค์(๋ฌธ์์ด, ๋น ์ํ์ค ํฌํจ) ๋์
๋๋ฆฌ ๋ฉค๋ฒ์ ๊ธฐ๋ณธ๊ฐ์ด๋ ์ต์
์ธ์
๊ธฐ๋ณธ๊ฐ์ผ๋ก๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋จ, ๋ฌธ์์ด, ๋น ์ํ์ค
๋ถ๋ฆฌ์ธ ๋ฆฌํฐ๋ด ํ ํฐ boolean ํ์
์
true์ false์
๋๋ค.
-
S๋ฅผ
integer ํ ํฐ์ ์ผ์นํ๋ ์ค์นผ๋ผ ๊ฐ์ ์ํ์ค๋ก ๋ก๋๋ค. -
S๊ฐ U+002D(-)๋ก ์์ํ๋ฉด sign๋ โ1, ๊ทธ๋ ์ง ์์ผ๋ฉด 1์ ๋๋ค.
-
์ ํ์ U+002D(-) ๋ค์ ์ค์นผ๋ผ ๊ฐ์ ๋ฐ๋ผ base๋ฅผ ๊ฒฐ์ ํฉ๋๋ค:
- U+0030 (0), U+0058 (X)
- U+0030 (0), U+0078 (x)
-
base๋ 16์ ๋๋ค.
- U+0030 (0)
-
base๋ 8์ ๋๋ค.
- ๊ธฐํ
-
base๋ 10์ ๋๋ค.
-
์ ํ์ ์ธ ๋งจ ์ U+002D (-) ๋ฌธ์์ ์ง๋ฒ์ ๋ํ๋ด๋ ์ค์นผ๋ผ ๊ฐ ๋ค์ ๋จ์ ๋ชจ๋ ์ค์นผ๋ผ ๊ฐ ์ base ์ง๋ฒ ์ ์๋ก ํด์ํ ๊ฒฐ๊ณผ๋ฅผ number ๋ก ๋ก๋๋ค.
-
sign ร number๋ฅผ ๋ฐํํฉ๋๋ค.
-
S๋ฅผ
decimal ํ ํฐ์ ์ผ์นํ๋ ์ค์นผ๋ผ ๊ฐ์ ์ํ์ค๋ก ๋ก๋๋ค. -
S๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ
NumericLiteral ๋ก ํ์ฑํ์ ๋์ ์ํ์ ๊ฐ์ result๋ก ๋ก๋๋ค. -
ํด๋น ํ ํฐ์ด
float๋๋unrestricted float์ ๊ฐ์ผ๋ก ์ฌ์ฉ๋๋ฉด, result์ ๊ฐ์ฅ ๊ฐ๊น์ด IEEE 754 ๋จ์ ๋ฐ๋ ๋ถ๋์์์ ์ซ์๊ฐ ๊ฐ์ ๋๋ค. -
๊ทธ ์ธ์๋
double๋๋unrestricted double์ ๊ฐ์ผ๋ก ์ฌ์ฉ๋๋ฉฐ, result์ ๊ฐ์ฅ ๊ฐ๊น์ด IEEE 754 ๋ฐฐ์ ๋ฐ๋ ๋ถ๋์์์ ์ซ์๊ฐ ๊ฐ์ ๋๋ค. [IEEE-754]
์์๊ฐ์ด
- ํ์
unrestricted float, ์์๊ฐInfinity -
๊ฐ์ IEEE 754 ๋จ์ ๋ฐ๋ ์์ ๋ฌดํ๋์ ๋๋ค.
- ํ์
unrestricted double, ์์๊ฐInfinity -
๊ฐ์ IEEE 754 ๋ฐฐ์ ๋ฐ๋ ์์ ๋ฌดํ๋์ ๋๋ค.
- ํ์
unrestricted float, ์์๊ฐ-Infinity -
๊ฐ์ IEEE 754 ๋จ์ ๋ฐ๋ ์์ ๋ฌดํ๋์ ๋๋ค.
- ํ์
unrestricted double, ์์๊ฐ-Infinity -
๊ฐ์ IEEE 754 ๋ฐฐ์ ๋ฐ๋ ์์ ๋ฌดํ๋์ ๋๋ค.
- ํ์
unrestricted float, ์์๊ฐNaN -
๊ฐ์ ๋นํธ ํจํด 0x7fc00000์ IEEE 754 ๋จ์ ๋ฐ๋ NaN์ ๋๋ค.
- ํ์
unrestricted double, ์์๊ฐNaN -
๊ฐ์ ๋นํธ ํจํด 0x7ff8000000000000์ IEEE 754 ๋ฐฐ์ ๋ฐ๋ NaN์ ๋๋ค.
float๋ double ํ์
์
๊ฐ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
์์์ ํ ๋น๋ ๊ฐ์ ํ์ VT์ ์์, ๋์ ๋๋ฆฌ ๋ฉค๋ฒ, ์ต์ ์ธ์ ์์ฒด์ ํ์ DT๋ ํธํ๋์ด์ผ ํ๋ฉฐ, DT์ VT๊ฐ ๋์ผํ๊ฑฐ๋, DT๊ฐ ๋ ํ์ฉ ํ์ ์ด๊ณ ๋ด๋ถ ํ์ ์ด VT์ธ ๊ฒฝ์ฐ์ ํด๋นํฉ๋๋ค.
์์๋ ํด๋น ์ธํฐํ์ด์ค ๋๋ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์ ํน์ ์ธ์คํด์ค์ ์ฐ๊ฒฐ๋์ง ์์ต๋๋ค. ์ธ์คํด์ค์์ ์์๊ฐ ๋ ธ์ถ๋๋์ง ์ฌ๋ถ๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ ๋ฐ๋ผ ๋ค๋ฆ ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ ๊ทธ ์์๊ฐ ์ ์ธ๋ IDL ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ฅผ ํตํด ์์์ ์ ๊ทผํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๋ค์๊ณผ ๊ฐ์ IDL์์:
[Exposed =Window ]interface A {const short rambaldi = 47; };
์์๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ์์ A.rambaldi ๋๋ instanceOfA.rambaldi๋ก ์ ๊ทผํ ์ ์์ต๋๋ค.
์์์ ์ ์ฉ ๊ฐ๋ฅํ ํ์ฅ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
[CrossOriginIsolated],
[Exposed], [SecureContext].
Const ::const ConstType identifier = ConstValue ;
ConstValue ::BooleanLiteral FloatLiteral integer
BooleanLiteral ::true false
FloatLiteral ::decimal -Infinity Infinity NaN
ConstType ::PrimitiveType identifier
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์์ ํ์ ์ ์์๊ฐ ์ด๋ป๊ฒ ์ ์๋ ์ ์๋์ง ๋ณด์ฌ์ค๋๋ค.
[Exposed =Window ]interface Util {const boolean DEBUG =false ;const octet LF = 10;const unsigned long BIT_MASK = 0x0000fc00;const double AVOGADRO = 6.022e23; };
2.5.2. ์์ฑ
์์ฑ์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ ๋๋
๋ค์์คํ์ด์ค ๋ฉค๋ฒ๋ก,
(
-
์ผ๋ฐ ์์ฑ์ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ์ง์ ๋ ์๋ณ์์ ๋ฐ์ดํฐ ํ๋ ๋ฉค๋ฒ๋ฅผ ๊ฐ๋๋ก ์ ์ธํฉ๋๋ค.
interface interface_identifier {attribute type identifier ; }; -
์ ์ ์์ฑ์ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํน์ ๊ฐ์ฒด์ ๊ด๋ จ๋์ง ์์ ์์ฑ์ ์ ์ธํ ๋ ์ฌ์ฉํฉ๋๋ค.
interface interface_identifier {static attribute type identifier ; };
์์ฑ์
์์ฑ attr์ getter
๋จ๊ณ๋ โattr getter ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:โ(๋ชฉ๋ก) ๋๋ โattr getter
๋จ๊ณ๋ ๋ค์์ ์ํํ๋คโ(์ธ๋ผ์ธ ์ค๋ช
)์ ๊ฐ์ ํ
์คํธ๋ก ์๊ฐํด์ผ ํฉ๋๋ค.
์์ฑ attr์ setter
๋จ๊ณ๋ โattr setter ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:โ(๋ชฉ๋ก) ๋๋ โattr setter
๋จ๊ณ๋ ๋ค์์ ์ํํ๋คโ(์ธ๋ผ์ธ ์ค๋ช
)์ ๊ฐ์ ํ
์คํธ๋ก ์๊ฐํด์ผ ํฉ๋๋ค.
์ฐธ๊ณ : getter ๋จ๊ณ๋ฅผ ์ ์ํ ๋๋ this์ ์๋ฌต์ ์ผ๋ก ์ ๊ทผํ ์ ์์ต๋๋ค. setter ๋จ๊ณ๋ฅผ ์ ์ํ ๋๋ this์ ์ง์ ๋ ๊ฐ์ ์๋ฌต์ ์ผ๋ก ์ ๊ทผํ ์ ์์ต๋๋ค.
์์ฑ์ ์๋ณ์๋ ๋์ผํ ์ธํฐํ์ด์ค์ ์ ์๋ ๋ค๋ฅธ ์ธํฐํ์ด์ค ๋ฉค๋ฒ์ ์๋ณ์์ ๊ฐ์์๋ ์ ๋ฉ๋๋ค.
์ ์ ์์ฑ์ ์๋ณ์๋ "prototype"์ด๋ฉด ์ ๋ฉ๋๋ค.
์์ฑ์ ํ์
์
ํ์ ์ ์๋ฅผ ํด์ํ ํ, ์์ฑ์ ํ์ ์ ๋ค์ ํ์ ์ ๋ ํ์ฉ ๋๋ ๋นํ์ฉ ๋ฒ์ ์ด ๋์ด์๋ ์ ๋ฉ๋๋ค:
-
์ ๋์จ ํ์ ์ ๋ ํ์ฉ ๋๋ ๋นํ์ฉ ์ํ์ค ํ์ , ๋์ ๋๋ฆฌ, ๋ ์ฝ๋๊ฐ ํํํ๋ ๋ฉค๋ฒ ํ์ ์ค ํ๋๋ก ํฌํจ๋ ๊ฒฝ์ฐ
์์ฑ์ ์ฝ๊ธฐ ์ ์ฉ์ด๋ฉฐ,
interface interface_identifier {readonly attribute type identifier ; };
ํ์
์ด ํ๋ผ๋ฏธ์ค ํ์
์ธ ์์ฑ์ ๋ฐ๋์ ์ฝ๊ธฐ ์ ์ฉ์ด์ด์ผ ํ๋ฉฐ, ๋ํ [LegacyLenientSetter],
[PutForwards],
[Replaceable],
[SameObject]
ํ์ฅ ์์ฑ์ ๊ฐ์ง ์ ์์ต๋๋ค.
์ฝ๊ธฐ ์ ์ฉ์ด ์๋ ์ผ๋ฐ ์์ฑ์ ์์
์ธํฐํ์ด์ค์์ getter๋ฅผ ์์๋ฐ๋๋ก ์ ์ธํ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด ์์ ์ธํฐํ์ด์ค์ ์ฝ๊ธฐ ์ ์ฉ ์์ฑ์ ํ์ ์ธํฐํ์ด์ค์์ ์ฐ๊ธฐ ๊ฐ๋ฅํ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค.
์์ฑ์ด getter๋ฅผ ์์ํ๋ ค๋ฉด ์ ์ธ์
์ฐธ๊ณ : ๋ฌธ๋ฒ์
[Exposed =Window ]interface Ancestor {readonly attribute TheType theIdentifier ; }; [Exposed =Window ]interface Derived :Ancestor {inherit attribute TheType theIdentifier ; };
interface interface_identifier {stringifier attribute DOMString identifier ; };
๋ค์ ํ์ฅ ์์ฑ์ ์ผ๋ฐ
๋ฐ ์ ์ ์์ฑ์ ์ ์ฉ ๊ฐ๋ฅํฉ๋๋ค:
[CrossOriginIsolated],
[Exposed],
[SameObject],
[SecureContext].
๋ค์ ํ์ฅ ์์ฑ์ ์ผ๋ฐ
์์ฑ์๋ง ์ ์ฉ๋ฉ๋๋ค:
[LegacyLenientSetter],
[LegacyLenientThis],
[PutForwards],
[Replaceable],
[LegacyUnforgeable].
ReadOnlyMember ::readonly ReadOnlyMemberRest
ReadOnlyMemberRest ::AttributeRest MaplikeRest SetlikeRest
ReadWriteAttribute ::AttributeRest
InheritAttribute ::inherit AttributeRest
AttributeRest ::attribute TypeWithExtendedAttributes AttributeName ;
AttributeName ::AttributeNameKeyword identifier
AttributeNameKeyword ::required
OptionalReadOnly ::readonly ฮต
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์ธํฐํ์ด์ค์ ์์ฑ์ ์ ์ธํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค:
[Exposed =Window ]interface Animal { // ์์์ ๋ฌธ์์ด ๊ฐ์ผ๋ก ์ค์ ๊ฐ๋ฅํ ๋จ์ ์์ฑ.readonly attribute DOMString name ; // ๊ฐ์ ํ ๋นํ ์ ์๋ ์์ฑ.attribute unsigned short age ; }; [Exposed =Window ]interface Person :Animal { // Animal์์ getter ๋์์ ์์๋ฐ์ผ๋ฉฐ, Person ์ค๋ช ์์ ๋ณ๋ ๋ช ์ ํ์ ์์.inherit attribute DOMString name ; };
2.5.3. ์ฐ์ฐ
์ฐ์ฐ์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ,
์ฝ๋ฐฑ ์ธํฐํ์ด์ค
๋ฉค๋ฒ, ๋ค์์คํ์ด์ค
๋ฉค๋ฒ
(
-
์ผ๋ฐ ์ฐ์ฐ์ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ์ง์ ๋ ์๋ณ์์ ๋ฉ์๋๋ฅผ ๊ฐ๋๋ก ์ ์ธํฉ๋๋ค.
interface interface_identifier {return_type identifier (/* arguments... */); }; -
ํน์ ์ฐ์ฐ์ ๊ฐ์ฒด ์ธ๋ฑ์ฑ, ๋ฌธ์์ด ๋ณํ ๋ฑ ํน๋ณํ ๋์์ ๊ตฌํํ๋ ๊ฐ์ฒด์ ์ ์ธํ ๋ ์ฌ์ฉํฉ๋๋ค.
interface interface_identifier { /* special_keyword */return_type identifier (/* arguments... */); /* special_keyword */return_type (/* arguments... */); }; -
์ ์ ์ฐ์ฐ์ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํน์ ๊ฐ์ฒด์ ๊ด๋ จ๋์ง ์์ ์ฐ์ฐ์ ์ ์ธํ ๋ ์ฌ์ฉํฉ๋๋ค.
interface interface_identifier {static return_type identifier (/* arguments... */); };
์ฐ์ฐ์ ์๋ณ์๊ฐ ์๊ณ
์ฐ์ฐ์ ์๋ณ์๊ฐ ์์ผ๋ฉด ๋ฐ๋์ ํน์ ํค์๋๋ฅผ ์ฌ์ฉํ์ฌ ํน์ ์ฐ์ฐ์ผ๋ก ์ ์ธํด์ผ ํฉ๋๋ค.
์ผ๋ฐ ์ฐ์ฐ ๋๋ ์ ์ ์ฐ์ฐ์ ์๋ณ์๋ ๋์ผํ
์ธํฐํ์ด์ค, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค,
๋ค์์คํ์ด์ค์ ์ ์๋ ์์๋ ์์ฑ์ ์๋ณ์์ ๊ฐ์์๋ ์ ๋ฉ๋๋ค.
์ ์ ์ฐ์ฐ์ ์๋ณ์๋ "prototype"์ด๋ฉด ์ ๋ฉ๋๋ค.
์ฐธ๊ณ : ์ฐ์ฐ์ ์๋ณ์๋ ๋์ผ ์ธํฐํ์ด์ค์ ๋ค๋ฅธ ์ฐ์ฐ๊ณผ ๊ฐ์ ์ ์์ต๋๋ค. ์ด๋ ์ฐ์ฐ ์ค๋ฒ๋ก๋ฉ์ ๋ช ์ธํ๋ ๋ฐฉ์์ ๋๋ค.
์ฐธ๊ณ : ์ ์ ์ฐ์ฐ์ ์๋ณ์๋ ๋์ผ ์ธํฐํ์ด์ค์ ์ ์๋ ์ผ๋ฐ ์ฐ์ฐ์ ์๋ณ์์ ๊ฐ์ ์ ์์ต๋๋ค.
์ฐ์ฐ์ ๋ฐํ ํ์
์ ์ฐ์ฐ ์ ์ธ์์ ์๋ณ์
์์ ๋ฑ์ฅํ๋ ํ์
(
์ฐ์ฐ์ ์ธ์(
์ฐธ๊ณ : ํํ๋ ฅ์ ์ํด, ์ฐ์ฐ ์ธ์์ ์๋ณ์๋
์ฐ์ฐ ์ธ์์
์ธ์ ํ์ ์ ํ์ ์ ์ ํด์ ํ, ๋ ํ์ฉ ํ์ (nullable type)์ด๋ฉด, ๊ทธ ๋ด๋ถ ํ์ ์ ๋์ ๋๋ฆฌ ํ์ ์ผ ์ ์์ต๋๋ค.
interface interface_identifier {return_type identifier (type identifier ,type identifier /* , ... */); };
๊ฐ ์ธ์์ ์๋ณ์๋ ๋์ผ ์ฐ์ฐ ์ ์ธ ๋ด์ ๋ค๋ฅธ ์ธ์ ์๋ณ์์ ๊ฐ์์๋ ์ ๋ฉ๋๋ค.
๊ฐ ์ธ์๋ ํ์ฅ ์์ฑ
๋ฆฌ์คํธ(
interface interface_identifier {return_type identifier ([extended_attributes ]type identifier , [extended_attributes ]type identifier /* , ... */); };
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์ธํฐํ์ด์ค์ ์ผ๋ฐ ์ฐ์ฐ์ ์ ์ธํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค:
[Exposed =Window ]interface Dimensions {attribute unsigned long width ;attribute unsigned long height ; }; [Exposed =Window ]interface Button { // ์ธ์๋ฅผ ๋ฐ์ง ์๊ณ ๋ถ๋ฆฌ์ธ์ ๋ฐํํ๋ ์ฐ์ฐ.boolean isMouseOver (); // ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ๋ค.undefined setDimensions (Dimensions size );undefined setDimensions (unsigned long width ,unsigned long height ); };
์ฐ์ฐ ๋๋ ์์ฑ์ ์ฐ์ฐ์ ๋ง์ง๋ง ์ธ์๊ฐ
interface interface_identifier {return_type identifier (type ...identifier );return_type identifier (type identifier ,type ...identifier ); };
ํ์ฅ ์์ฑ ์ค ์ธ์ ๋ฆฌ์คํธ๋ฅผ ๋ฐ๋
([LegacyFactoryFunction])
๋ฐ ์ฝ๋ฐฑ ํจ์๋
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ๋ ๊ฐ์ ๊ฐ๋ณ ์ธ์ ์ฐ์ฐ์ ๊ฐ์ง ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface IntegerSet {readonly attribute unsigned long cardinality ;undefined union (long ...ints );undefined intersection (long ...ints ); };
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ๊ฐ๋ณ ์ธ์ ์ฐ์ฐ์ ์ถ๊ฐ ์ธ์๋ฅผ ๋ฐ์ ์ ์๋ ํจ์๋ก ๊ตฌํ๋ฉ๋๋ค:
var s= getIntegerSet(); // IntegerSet ์ธ์คํด์ค ์ป๊ธฐ s. union(); // 'ints'์ ํด๋นํ๋ ์ธ์๋ฅผ ์ ๋๊น s. union( 1 , 4 , 7 ); // 'ints'์ ํด๋นํ๋ ์ธ์๋ฅผ ์ธ ๊ฐ ๋๊น
๊ฐ๋ณ ์ธ์ ํจ์๋ฅผ ์ง์ํ์ง ์๋ ์ธ์ด ๋ฐ์ธ๋ฉ์์๋ ๋ช ์์ ์ผ๋ก ๋ฐฐ์ด์ด๋ ๋ฆฌ์คํธ๋ฅผ ์ธ์๋ก ๋๊ธฐ๋๋ก ๋ช ์ธํ ์ ์์ต๋๋ค.
์ธ์์
interface interface_identifier {return_type identifier (type identifier ,optional type identifier ); };
์ต์
์ธ์๋ ๊ธฐ๋ณธ๊ฐ๋ ๊ฐ์ง ์ ์์ต๋๋ค. ์ธ์ ์๋ณ์ ๋ค์ U+003D(=)์ ๊ฐ(
interface interface_identifier {return_type identifier (type identifier ,optional type identifier = "value"); };
boolean
ํ์
์ ์ต์
์ธ์์
์ธ์ ํ์ ์ด ๋์ ๋๋ฆฌ ํ์ ๋๋ ์ ๋์จ ํ์ ์ค ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ํ๋๋ก ๋์ ๋๋ฆฌ ํ์ ์ ๊ฐ๋ ํ์ ์ด๋ฉฐ, ํด๋น ๋์ ๋๋ฆฌ ํ์ ๋ฐ ์กฐ์์ ํ์ ๋ฉค๋ฒ๊ฐ ์๊ณ , ์ธ์๊ฐ ๋ง์ง๋ง์ด๊ฑฐ๋ ๋ค๋ฐ๋ฅด๋ ์ธ์๋ค์ด ๋ชจ๋ ์ต์ ์ธ์๋ผ๋ฉด, ํด๋น ์ธ์๋ ์ต์ ์ผ๋ก ์ ์ธ๋๊ณ ๊ธฐ๋ณธ๊ฐ์ ์ง์ ํด์ผ ํฉ๋๋ค.
์ด๋ API ์ค๊ณ์ ์ฌ์ฉ์๊ฐ ๋์ ๋๋ฆฌ์ ๊ธฐ๋ณธ๊ฐ๋ง ์ฌ์ฉํ๊ณ ์ถ์ ๋ ๋น ๋์ ๋๋ฆฌ ๊ฐ์ ๊ตณ์ด ๋๊ธฐ์ง ์์๋ ๋๋๋ก ํ๊ธฐ ์ํจ์ ๋๋ค.
๋๊ฐ ๊ธฐ๋ณธ๊ฐ์ผ๋ก
๋ถ๋ฆฌ์ธ ๋ฆฌํฐ๋ด ํ ํฐ(
undefined์
๋๋ค.
-
S๋ฅผ
string ํ ํฐ์์ ์๋ U+0022(") ์ค์นผ๋ผ ๊ฐ์ ์ ๊ฑฐํ ํ ๋จ์ ์ค์นผ๋ผ ๊ฐ ์ํ์ค๋ก ๋ก๋๋ค. -
์ธ์ ํ์ ์ ๋ฐ๋ผ:
DOMStringUSVString- ์ด๊ฑฐํ ํ์
-
string ํ ํฐ์ ๊ฐ์ S์ ๋๋ค. ByteString-
๋จ, S์๋ U+00FF๋ฅผ ์ด๊ณผํ๋ ์ฝ๋ ํฌ์ธํธ๊ฐ ์์ด์ผ ํฉ๋๋ค.
string ํ ํฐ์ ๊ฐ์ ๋ํ ์ธ์ฝ๋ฉ๋ S์ ๋๋ค.
์ต์ ์ธ์์ ํ์ ์ด ์ด๊ฑฐํ์ด๋ฉด, ์ง์ ๋ ๊ธฐ๋ณธ๊ฐ์ ๋ฐ๋์ ํด๋น ์ด๊ฑฐํ ๊ฐ ์ค ํ๋์ฌ์ผ ํฉ๋๋ค.
์ต์
์ธ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋ ํ ํฐ ๊ฐ
์ต์
์ธ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋ ํ ํฐ ๊ฐ
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ๋ ๊ฐ์ง ์ธ์ ๋ฆฌ์คํธ ๊ธธ์ด๋ก ํธ์ถ ๊ฐ๋ฅํ ๋จ์ผ ์ฐ์ฐ์ ๊ฐ์ง ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface ColorCreator {object createColor (double v1 ,double v2 ,double v3 ,optional double alpha ); };
์ด๋ ์๋์ฒ๋ผ ๋ ๊ฐ์ ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ์ ๊ฐ์ง ์ธํฐํ์ด์ค์ ๊ฐ์ต๋๋ค:
[Exposed =Window ]interface ColorCreator {object createColor (double v1 ,double v2 ,double v3 );object createColor (double v1 ,double v2 ,double v3 ,double alpha ); };
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ๋์ ๋๋ฆฌ ์ธ์๋ฅผ ๋ฐ๋ ์ฐ์ฐ์ ๊ฐ์ง ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค:
dictionary LookupOptions {boolean caseSensitive =false ; }; [Exposed =Window ]interface AddressBook {boolean hasAddressForName (USVString name ,optional LookupOptions options = {}); };
hasAddressForName์ ์ธ์ ํ๋๋ง ๋๊ฒจ ํธ์ถํ๋ฉด, ๋ ๋ฒ์งธ ์ธ์๋ ๊ธฐ๋ณธ ์ด๊ธฐํ๋ LookupOptions ๋์
๋๋ฆฌ๊ฐ ๋๋ฉฐ,
caseSensitive๋
์ฐ์ฐ์ ์ ์ฉ ๊ฐ๋ฅํ ํ์ฅ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
[CrossOriginIsolated],
[Default],
[Exposed],
[LegacyUnforgeable],
[NewObject],
[SecureContext].
์ฐ์ฐ operation์ ๋ฉ์๋
๋จ๊ณ๋ โoperation(arg1, arg2, ...) ๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:โ(๋ชฉ๋ก)
๋๋ โoperation(arg1,
arg2, ...) ๋ฉ์๋ ๋จ๊ณ๋ ๋ค์์ ์ํํ๋คโ(์ธ๋ผ์ธ ์ค๋ช
)์ ๊ฐ์ ํ
์คํธ๋ก ์๊ฐํด์ผ ํฉ๋๋ค.
์ฐธ๊ณ : ๋ฉ์๋ ๋จ๊ณ๋ฅผ ์ ์ํ ๋๋ this์ ์๋ฌต์ ์ผ๋ก ์ ๊ทผํ ์ ์์ต๋๋ค.
DefaultValue ::ConstValue string [ ] { } null undefined
Operation ::RegularOperation SpecialOperation
RegularOperation ::Type OperationRest
SpecialOperation ::Special RegularOperation
Special ::getter setter deleter
OperationRest ::OptionalOperationName ( ArgumentList ) ;
OptionalOperationName ::OperationName ฮต
OperationName ::OperationNameKeyword identifier
OperationNameKeyword ::includes
ArgumentList ::Argument Arguments ฮต
Arguments ::, Argument Arguments ฮต
Argument ::ExtendedAttributeList ArgumentRest
ArgumentRest ::optional TypeWithExtendedAttributes ArgumentName Default Type Ellipsis ArgumentName
ArgumentName ::ArgumentNameKeyword identifier
Ellipsis ::... ฮต
ArgumentNameKeyword ::attribute callback const constructor deleter dictionary enum getter includes inherit interface iterable maplike mixin namespace partial readonly required setlike setter static stringifier typedef unrestricted
2.5.3.1. toJSON
toJSON ์ผ๋ฐ ์ฐ์ฐ์ ์ ์ธํจ์ผ๋ก์จ,
์ธํฐํ์ด์ค๋ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ฅผ JSON ํ์
์ผ๋ก ๋ณํํ๋ ๋ฐฉ๋ฒ์ ๋ช
์ธํฉ๋๋ค.
toJSON ์ผ๋ฐ ์ฐ์ฐ์ ์ด๋ฌํ ์ฉ๋๋ฅผ ์ํด ์์ฝ๋์ด ์์ต๋๋ค.
๋ฐ๋์ ์ธ์๋ฅผ ๋ฐ์ง ์์์ผ ํ๋ฉฐ, JSON ํ์
์
๋ฐํํด์ผ ํฉ๋๋ค.
JSON ํ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
๋ ํ์ฉ ํ์ (๋ด๋ถ ํ์ ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
์ฃผ์ ํ์ (๋ด๋ถ ํ์ ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
์ ๋์จ ํ์ (๋ฉค๋ฒ ํ์ ์ด ๋ชจ๋ JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
ํ์ ์ ์ (์ ์ด๋ฆ์ด ๋ถ์ฌ๋๋ ํ์ ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
์ํ์ค ํ์ (ํ๋ผ๋ฏธํฐ ํ์ ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
๋ถ๋ณ ๋ฐฐ์ด ํ์ (ํ๋ผ๋ฏธํฐ ํ์ ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
๋์ ๋๋ฆฌ ํ์ (๋์ ๋๋ฆฌ์ ๊ทธ ์์ ๋์ ๋๋ฆฌ ์ ์ ์ธ๋ ๋ชจ๋ ๋ฉค๋ฒ ํ์ ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
๋ ์ฝ๋ (๋ชจ๋ ๊ฐ์ด JSON ํ์ ์ธ ๊ฒฝ์ฐ),
-
์ธํฐํ์ด์ค ํ์ (์์ ์ด๋ ์์๋ฐ์ ์ธํฐํ์ด์ค์
toJSON์ฐ์ฐ์ด ์ ์ธ๋ ๊ฒฝ์ฐ),
toJSON ์ผ๋ฐ ์ฐ์ฐ
์ด ๊ฐ์ฒด์์ ์ด๋ป๊ฒ ๋
ธ์ถ๋๋์ง, ๊ทธ๋ฆฌ๊ณ JSON
ํ์
์ด JSON ๋ฌธ์์ด๋ก ๋ณํ๋๋ ๋ฐฉ์์ ์ธ์ด ๋ฐ์ธ๋ฉ์ ๋ฐ๋ผ ๋ค๋ฆ
๋๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋, toJSON ๋ฉ์๋๋ฅผ ๋
ธ์ถํ์ฌ JSON ํ์
์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ฐํํ๊ณ ,
JSON.stringify()
ํจ์๋ก JSON ๋ฌธ์์ด๋ก ๋ณํํ ์ ์๋๋ก ํฉ๋๋ค.
๋ํ, ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ toJSON ์ฐ์ฐ์ [Default] ํ์ฅ ์์ฑ์ ์ฌ์ฉํ
์ ์์ผ๋ฉฐ,
์ด ๊ฒฝ์ฐ ๊ธฐ๋ณธ toJSON
๋จ๊ณ๊ฐ ๋์ ๋
ธ์ถ๋ฉ๋๋ค.
์๋ IDL ํ๋๊ทธ๋จผํธ๋ Transaction ์ธํฐํ์ด์ค์ toJSON ๋ฉ์๋๋ฅผ ํ๋ก์ฆ๋ก ์ ์ํ ์์์
๋๋ค:
[Exposed =Window ]interface Transaction {readonly attribute DOMString from ;readonly attribute DOMString to ;readonly attribute double amount ;readonly attribute DOMString description ;readonly attribute unsigned long number ;TransactionJSON toJSON (); };dictionary TransactionJSON {Account from ;Account to ;double amount ;DOMString description ; };
Transaction ์ธํฐํ์ด์ค์ toJSON ์ผ๋ฐ ์ฐ์ฐ์ ๋ค์๊ณผ ๊ฐ์ด ์ ์ํ ์ ์์ต๋๋ค:
toJSON() ๋ฉ์๋ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:
-
json์ ์ ๋งต์ผ๋ก๋ก๋๋ค.
-
๊ฐ ์์ฑ identifier attr์ ๋ํด ยซ"from", "to", "amount", "description"ยป:
-
value๋ฅผ getter ๋จ๊ณ๋ฅผ this์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
json[attr]์ value๋ฅผ ์ค์ ํฉ๋๋ค.
-
-
json์ ๋ฐํํฉ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ Transaction ๊ฐ์ฒด์ toJSON() ๋ฉ์๋๊ฐ ์กด์ฌํฉ๋๋ค:
// Transaction ์ธ์คํด์ค ์ป๊ธฐ var txn= getTransaction(); // ์๋์ ๊ฐ์ ๊ฐ์ฒด๋ก ํ๊ฐ๋จ: // { // from: "Bob", // to: "Alice", // amount: 50, // description: "books" // } txn. toJSON(); // ์๋์ ๊ฐ์ ๋ฌธ์์ด๋ก ํ๊ฐ๋จ: // '{"from":"Bob","to":"Alice","amount":50,"description":"books"}' JSON. stringify( txn);
2.5.4. ์์ฑ์ ์ฐ์ฐ
์ธํฐํ์ด์ค์ ์์ฑ์ ์ฐ์ฐ ๋ฉค๋ฒ(
ํ๋์ ์ธํฐํ์ด์ค์๋ ์ฌ๋ฌ ๊ฐ์ ์์ฑ์ ์ฐ์ฐ์ด ์์ ์ ์์ต๋๋ค. ์ธํฐํ์ด์ค์ ๊ฐ๊ฐ์ ์์ฑ์ ์ฐ์ฐ์ ๋ํด, ์ง์ ๋ ์ธ์๋ฅผ ๋๊ฒจ ์ธ์คํด์ค๋ฅผ ์์ฑํ ๋ฐฉ๋ฒ์ด ์ ๊ณต๋ฉ๋๋ค.
์์ฑ์ ์ฐ์ฐ์ด ์ธํฐํ์ด์ค
interface์ ๋ฉค๋ฒ์ผ ๋
์์ฑ์ ๋จ๊ณ๋
โThe new interface(arg1, arg2, ...) ์์ฑ์ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:โ(๋ชฉ๋ก) ๋๋
โThe
new interface(arg1, arg2, ...) ์์ฑ์ ๋จ๊ณ๋ ๋ค์์ ์ํํ๋คโ(์ธ๋ผ์ธ ์ค๋ช
)์ ๊ฐ์
ํ
์คํธ๋ก ์๊ฐํด์ผ ํฉ๋๋ค.
์์ฑ์ ๋จ๊ณ๋ ์๋ฌด ๊ฒ๋ ํ์ง ์๊ฑฐ๋, this์ ์ ๋ฌ๋ ๊ฐ์ ์ด๊ธฐํํ๊ฑฐ๋, ์์ธ๋ฅผ ๋์ง ์ ์์ต๋๋ค.
์์ฑ์๊ฐ
this๋ฅผ ์ด๊ธฐํํ์ง ์๋ ๊ฒฝ์ฐ,
โThe new Example(init) ์์ฑ์ ๋จ๊ณ๋ ์๋ฌด ๊ฒ๋ ํ์ง ์๋๋ค.โ๋ผ๊ณ ์ธ ์ ์์ต๋๋ค.
ยงโฏ3.7.1 ์ธํฐํ์ด์ค ๊ฐ์ฒด์์ ์์ฑ์ ์ฐ์ฐ์ด ์ด๋ป๊ฒ ๊ตฌํ๋๋์ง ์์ธํ ์ค๋ช ํฉ๋๋ค.
์๋ IDL์ ๋ ๊ฐ์ ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค. ๋ ๋ฒ์งธ ์ธํฐํ์ด์ค์๋ ์์ฑ์ ์ฐ์ฐ์ด ์์ง๋ง, ์ฒซ ๋ฒ์งธ์๋ ์์ต๋๋ค.
[Exposed =Window ]interface NodeList {Node item (unsigned long index );readonly attribute unsigned long length ; }; [Exposed =Window ]interface Circle {constructor ();constructor (double radius );attribute double r ;attribute double cx ;attribute double cy ;readonly attribute double circumference ; };
์ด ์ธํฐํ์ด์ค๋ค์ ์ง์ํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋ Circle ์ธํฐํ์ด์ค ๊ฐ์ฒด์ [[Construct]] ๋ด๋ถ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋ฉฐ,
์ด๋ฅผ ํตํด ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ์ ๊ฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค.
์ธ์๋ 0๊ฐ ๋๋ 1๊ฐ๋ฅผ ๋ฐ์ ์ ์์ต๋๋ค.
NodeList ์ธํฐํ์ด์ค ๊ฐ์ฒด๊ฐ [[Construct]] ๋ด๋ถ ๋ฉ์๋๋ฅผ ๊ตฌํํ๋์ง๋ ๋ช
ํํ์ง ์์ต๋๋ค. ์ด์จ๋ ์ด๋ฅผ
์์ฑ์๋ก ์ฌ์ฉํ๋ ค ํ๋ฉด TypeError๊ฐ
๋ฐ์ํฉ๋๋ค. [whatwg/webidl Issue #698]
var x= new Circle(); // 0๊ฐ ์ธ์ ์์ฑ์๋ก Circle ์ธํฐํ์ด์ค ๊ตฌํ ๊ฐ์ฒด ์์ฑ // ํ๋ซํผ ๊ฐ์ฒด ์ฐธ์กฐ ๋ฐํ var y= new Circle( 1.25 ); // 1๊ฐ ์ธ์ ์์ฑ์๋ก Circle ๊ฐ์ฒด ์์ฑ var z= new NodeList(); // ์์ฑ์ ์ ์ธ์ด ์์ผ๋ฏ๋ก TypeError ๋ฐ์
Constructor ::constructor ( ArgumentList ) ;
ArgumentList ::Argument Arguments ฮต
Ellipsis ::... ฮต
ArgumentNameKeyword ::attribute callback const constructor deleter dictionary enum getter includes inherit interface iterable maplike mixin namespace partial readonly required setlike setter static stringifier typedef unrestricted
2.5.5. ๋ฌธ์์ด ๋ณํ์
์ธํฐํ์ด์ค์ ๋ฌธ์์ด ๋ณํ์๊ฐ ์์ผ๋ฉด,
ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ๊ธฐ๋ณธ๊ฐ์ด ์๋ ๋ฌธ์์ด ๋ณํ(conversion)์ ๊ฐ๋๋ค๋ ์๋ฏธ์
๋๋ค. ๋ฌธ์์ด ๋ณํ์๋
interface interface_identifier {stringifier ; };
์ธํฐํ์ด์ค์ ํจ๊ป ์ค๋ช ๋๋ ํ๋ก์ฆ(prose)์์๋ ํด๋น ์ธํฐํ์ด์ค์ ๋ฌธ์์ด ๋ณํ ๋์์ ์ ์ํด์ผ ํฉ๋๋ค.
DOMString
๋๋ USVString
ํ์
์ ์์ฑ์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
๋ํ ์ ์ ์์ฑ์๋ ์ฌ์ฉํ ์
์์ต๋๋ค.
interface interface_identifier {stringifier attribute DOMString identifier ; };
ํน์ ์ธํฐํ์ด์ค์๋ ๋ฌธ์์ด ๋ณํ์๊ฐ ์ต๋ ํ๋๋ง ์กด์ฌํด์ผ ํฉ๋๋ค.
Stringifier ::stringifier StringifierRest
StringifierRest ::OptionalReadOnly AttributeRest ;
์๋ IDL ํ๋๊ทธ๋จผํธ๋
name ์์ฑ ๊ฐ์ผ๋ก ๋ฌธ์์ด ๋ณํ๋๋ ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface Student {constructor ();attribute unsigned long id ;stringifier attribute DOMString name ; };
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ Student ๊ฐ์ฒด๋ฅผ ๋ฌธ์์ด์ด ํ์ํ ๊ณณ์์ ์ฌ์ฉํ๋ฉด ๊ฐ์ฒด์ name ์์ฑ
๊ฐ์ด ์ฌ์ฉ๋ฉ๋๋ค:
var s= new Student(); s. id= 12345678 ; s. name= 'ๅจๆฐๅซ' ; var greeting= 'Hello, ' + s+ '!' ; // greeting == 'Hello, ๅจๆฐๅซ!'
์๋ IDL ํ๋๊ทธ๋จผํธ๋ IDL ์์ฒด์ ๋ช ์๋์ง ์์ ์ปค์คํ ๋ฌธ์์ด ๋ณํ ๋์์ ๊ฐ์ง ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ]interface Student {constructor ();attribute unsigned long id ;attribute DOMString ?familyName ;attribute DOMString givenName ;stringifier ; };
๋ฐ๋ผ์ ๋ฌธ์์ด ๋ณํ ๋์์ ์ค๋ช
ํ๋ ํ๋ก์ฆ๊ฐ ํ์ํฉ๋๋ค.
familyName๊ณผ givenName ์์ฑ์ ๊ฐ๊ฐ ์ฑ๊ณผ ์ด๋ฆ ๊ฐ๋
์ ๋ํ๋ธ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
๋ฌธ์์ด ๋ณํ ๋์ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:
์ด IDL์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ ๋์ ์์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
var s= new Student(); s. id= 12345679 ; s. familyName= 'Smithee' ; s. givenName= 'Alan' ; var greeting= 'Hi ' + s; // greeting == 'Hi Alan Smithee'
2.5.6. ํน์ ์ฐ์ฐ
ํน์ ์ฐ์ฐ์ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์ ํน์ ์ข ๋ฅ์ ํน๋ณํ ๋์์ ์ ์ธํ๋ ๊ฒ์ ๋๋ค. ํน์ ์ฐ์ฐ์ ์ฐ์ฐ ์ ์ธ์ ํน์ ํค์๋๋ฅผ ์ฌ์ฉํด ์ ์ธํฉ๋๋ค.
ํน์ ์ฐ์ฐ์๋ ์ธ ๊ฐ์ง ์ข ๋ฅ๊ฐ ์์ต๋๋ค. ์๋ ํ๋ ๊ฐ ํน์ ์ฐ์ฐ์ ์ข ๋ฅ๋ณ๋ก ์ฌ์ฉ๋๋ ํน์ ํค์๋์ ๊ทธ ๋ชฉ์ ์ ๋ํ๋ ๋๋ค:
| ํน์ ์ฐ์ฐ | ํค์๋ | ๋ชฉ์ |
|---|---|---|
| Getter | ๊ฐ์ฒด๊ฐ ํ๋กํผํฐ ์กฐํ๋ฅผ ์ํด ์ธ๋ฑ์ฑ๋ ๋ ๋์์ ์ ์ํฉ๋๋ค. | |
| Setter | ๊ฐ์ฒด๊ฐ ํ๋กํผํฐ ํ ๋น ๋๋ ์์ฑ ์ ์ธ๋ฑ์ฑ๋ ๋ ๋์์ ์ ์ํฉ๋๋ค. | |
| Deleter | ๊ฐ์ฒด๊ฐ ํ๋กํผํฐ ์ญ์ ๋ฅผ ์ํด ์ธ๋ฑ์ฑ๋ ๋ ๋์์ ์ ์ํฉ๋๋ค. |
๋ชจ๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ด ๋ค ๊ฐ์ง ์ข ๋ฅ์ ํน์ ๊ฐ์ฒด ๋์์ ๋ชจ๋ ์ง์ํ๋ ๊ฒ์ ์๋๋๋ค. ํน์ ์ฐ์ฐ์ด ์๋ณ์ ์์ด ์ ์ธ๋ ๊ฒฝ์ฐ, ํด๋น ์ข ๋ฅ์ ํน์ ์ฐ์ฐ์ ์ง์ํ์ง ์๋ ์ธ์ด ๋ฐ์ธ๋ฉ์์๋ ํด๋น ๊ธฐ๋ฅ์ด ์ ๊ณต๋์ง ์์ต๋๋ค.
์๋ IDL ํ๋๊ทธ๋จผํธ๋ getter์ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface Dictionary {readonly attribute unsigned long propertyCount ;getter double (DOMString propertyName );setter undefined (DOMString propertyName ,double propertyValue ); };
ํ๋กํผํฐ getter์ setter๋ฅผ ์ง์ํ์ง ์๋ ์ธ์ด ๋ฐ์ธ๋ฉ์์๋, Dictionary๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ํด๋น ํน๋ณ ๋์์ ๊ฐ์ง ์์ต๋๋ค.
ํน์ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์ฌ์ฉํด ์ ์ํ๋ ๊ฒ์, ํด๋น ํน์ ์ฐ์ฐ์ ์๋ณ์ ์์ด ๋ณ๋์ ์ ์ธ์ผ๋ก ๋ถ๋ฆฌํ๋ ๊ฒ๊ณผ ๋๋ฑํฉ๋๋ค. ์ด ๋ฐฉ์์ ์ธํฐํ์ด์ค ์ฐ์ฐ์ ๋ฉ์๋ ๋จ๊ณ๋ฅผ ๋จ์ํํ๊ธฐ ์ํด ํ์ฉ๋ฉ๋๋ค.
๋ค์ ๋ ์ธํฐํ์ด์ค๋ ๋๋ฑํฉ๋๋ค:
[Exposed =Window ]interface Dictionary {readonly attribute unsigned long propertyCount ;getter double getProperty (DOMString propertyName );setter undefined setProperty (DOMString propertyName ,double propertyValue ); };
[Exposed =Window ]interface Dictionary {readonly attribute unsigned long propertyCount ;double getProperty (DOMString propertyName );undefined setProperty (DOMString propertyName ,double propertyValue );getter double (DOMString propertyName );setter undefined (DOMString propertyName ,double propertyValue ); };
ํน์ ํน์ ํค์๋๋ ์ฐ์ฐ์์ ๋ ๋ฒ ์ด์ ๋ฑ์ฅํด์๋ ์ ๋ฉ๋๋ค.
Getter์ setter์๋ ๋ ๊ฐ์ง ์ข
๋ฅ๊ฐ ์์ต๋๋ค: DOMString์
ํ๋กํผํฐ ์ด๋ฆ์ผ๋ก ๋ฐ๋
์ด๋ฆ ์๋ ํ๋กํผํฐ getter์
์ด๋ฆ ์๋ ํ๋กํผํฐ setter๊ฐ ์๊ณ ,
unsigned long์
ํ๋กํผํฐ ์ธ๋ฑ์ค๋ก ๋ฐ๋
์ธ๋ฑ์ค ํ๋กํผํฐ getter ๋ฐ
์ธ๋ฑ์ค ํ๋กํผํฐ setter๊ฐ ์์ต๋๋ค.
deleter๋ ํ ์ข
๋ฅ๋ง ์์ต๋๋ค:
์ด๋ฆ ์๋ ํ๋กํผํฐ deleter.
์์ธํ ๋ด์ฉ์ ยงโฏ2.5.6.1 ์ธ๋ฑ์ค ํ๋กํผํฐ์ ยงโฏ2.5.6.2 ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ฐธ์กฐํ์ธ์.
ํน์ ์ธํฐํ์ด์ค์๋ ์ด๋ฆ ์๋ ํ๋กํผํฐ deleter๊ฐ ์ต๋ ํ๋, getter์ setter์ ๊ฐ ์ข ๋ฅ๋ ์ต๋ ํ๋๋ง ์กด์ฌํด์ผ ํฉ๋๋ค.
์ธํฐํ์ด์ค์ ํน์ ์ข ๋ฅ์ setter๊ฐ ์์ผ๋ฉด ๋ฐ๋์ ๊ฐ์ ์ข ๋ฅ์ getter๋ ์์ด์ผ ํฉ๋๋ค. ์ด๋ฆ ์๋ ํ๋กํผํฐ deleter๊ฐ ์์ผ๋ฉด, ๋ฐ๋์ ์ด๋ฆ ์๋ ํ๋กํผํฐ getter๋ ์์ด์ผ ํฉ๋๋ค.
์ฐ์ฐ์ผ๋ก ์ ์ธ๋ ํน์ ์ฐ์ฐ์ ๊ฐ๋ณ ์ธ์(variadic)๊ฐ ์๋์ด์ผ ํ๋ฉฐ, ์ต์ ์ธ์๋ฅผ ๊ฐ์ง ์ ์์ต๋๋ค.
๊ฐ์ฒด๊ฐ ๋ ๊ฐ ์ด์์ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉฐ, ๋์ผํ ํน์ ์ฐ์ฐ์ ์ ์ํ๋ค๋ฉด, ์ค์ ์ด๋ค ํน์ ์ฐ์ฐ์ด ํธ์ถ๋๋์ง๋ ์ ์๋์ง ์์ต๋๋ค.
2.5.6.1. ์ธ๋ฑ์ค ํ๋กํผํฐ
์ธ๋ฑ์ค ํ๋กํผํฐ getter๋ฅผ ์ ์ํ ์ธํฐํ์ด์ค๋ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ค๊ณ ํ๋ค. ํ์ฅํด์, ํ๋ซํผ ๊ฐ์ฒด๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ค๊ณ ํ๋ ค๋ฉด ํด๋น ๊ฐ์ฒด๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด ๋๋ค.
์ธํฐํ์ด์ค๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ฉด, ์ธํฐํ์ด์ค ์ ์์๋ ๊ฐ์ฒด๊ฐ ์ธ์ ๋ ์ง ์ด๋ค ์ธ๋ฑ์ค๋ก ์ธ๋ฑ์ฑ๋ ์ ์๋์ง ๊ธฐ์ ์ด ํฌํจ๋์ด์ผ ํ๋ค. ์ด ์ธ๋ฑ์ค๋ค์ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค๋ผ๊ณ ํ๋ค.
์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค๋ "length"๋ผ๋ ์ ์ํ ์์ฑ์ ์ ์ํด์ผ ํ๋ค.
์ธ๋ฑ์ค ํ๋กํผํฐ getter๋
๋ฐ๋์ unsigned long
ํ๋์ ์ธ์๋ฅผ ๋ฐ์์ผ ํ๋ค.
์ธ๋ฑ์ค ํ๋กํผํฐ setter๋
๋ฐ๋์ ๋ ๊ฐ์ ์ธ์๋ฅผ ๋ฐ์์ผ ํ๋ฉฐ, ์ฒซ ๋ฒ์งธ ์ธ์๋ unsigned long์ด์ด์ผ
ํ๋ค.
interface interface_identifier {getter type identifier (unsigned long identifier );setter type identifier (unsigned long identifier ,type identifier );getter type (unsigned long identifier );setter type (unsigned long identifier ,type identifier ); };
์ธ๋ฑ์ค ํ๋กํผํฐ getter์ setter ์ ์์๋ ๋ค์ ์๊ตฌ ์ฌํญ์ด ์ ์ฉ๋๋ค:
-
์ธ๋ฑ์ค ํ๋กํผํฐ getter๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค๋ก ์ธ๋ฑ์ฑํ๋ฉด ํด๋น ์ธ๋ฑ์ค๋ฅผ ์ ์ผ ์ธ์๋ก ๋๊ฒจ ์ฐ์ฐ์ ํธ์ถํ ๊ฒฐ๊ณผ๊ฐ์ด ๋ฐํ๋๋ค. ๋ง์ฝ ์ธ๋ฑ์ค ํ๋กํผํฐ getter ์ ์ธ์ ์๋ณ์๊ฐ ์๋ค๋ฉด, ์ธํฐํ์ด์ค ์ ์์ ์ฃผ์ด์ง ์ธ๋ฑ์ค์ ๋ํด ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ๊ฒฐ์ ๋ฐฉ๋ฒ์ ๊ธฐ์ ํด์ผ ํ๋ค.
-
์ธ๋ฑ์ค ํ๋กํผํฐ setter๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค์ ๊ฐ์ผ๋ก ํ๋กํผํฐ ํ ๋น/์์ฑ์ ์ํด ์ธ๋ฑ์ฑํ๋ฉด, ์ธ๋ฑ์ค๋ฅผ ์ฒซ ๋ฒ์งธ ์ธ์, ๊ฐ์ ๋ ๋ฒ์งธ ์ธ์๋ก ๋๊ฒจ ์ฐ์ฐ์ ํธ์ถํ ๊ฒ๊ณผ ๋์ผํ๊ฒ ๋์ํ๋ค. ๋ง์ฝ ์ธ๋ฑ์ค ํ๋กํผํฐ setter ์ ์ธ์ ์๋ณ์๊ฐ ์๋ค๋ฉด, ์ธํฐํ์ด์ค ์ ์์ ๊ธฐ์กด ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ์ค์ (๊ธฐ์กด ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ์ค์ )๊ณผ ์ ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ์ค์ (์ ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ์ค์ ) ๋ฐฉ๋ฒ์ ๊ธฐ์ ํด์ผ ํ๋ค.
์ธ๋ฑ์ค ํ๋กํผํฐ getter๋ setter๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ ์๋ก ์ธ๋ฑ์ฑํ ๋(์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค๊ฐ ์๋ ๊ฒฝ์ฐ) ํด๋น ์ฐ์ฐ์ ํด๋น ์ธ๋ฑ์ค๋ก ํธ์ถํ๋ ๊ฒ๊ณผ ๊ฐ์ ๋์์ ๋ฐ๋์ ํ์ง๋ ์๋๋ค. ์ค์ ๋์์ ์ธ์ด ๋ฐ์ธ๋ฉ๋ง๋ค ๋ค๋ฅด๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ ์ผ๋ฐ ํ๋กํผํฐ ์กฐํ๊ฐ ์คํ๋๋ค. ์๋ฅผ ๋ค์ด, ์๋ IDL์ ๋ณด์:
[Exposed =Window ]interface A {getter DOMString toWord (unsigned long index ); };
A๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค๋ฅผ 0 โค index < 2๋ก ๊ฐ์ง๋ค๊ณ ๊ฐ์ ํ๊ณ , toWord๋ ์ธ์๋ฅผ ์์ด ๋จ์ด๋ก ๋ฐ๊ฟ ๋ฐํํ๋ค๊ณ ํ์. ์ธ๋ฑ์ค๊ฐ ๋ฒ์๋ฅผ ๋ฒ์ด๋ ๊ฒฝ์ฐ ์ฐ์ฐ ํธ์ถ๊ณผ ์ง์ ์ธ๋ฑ์ฑ์ ๋ค๋ฅด๊ฒ ๋์ํ๋ค:
var a= getA(); a. toWord( 0 ); // "zero" ๋ฐํ a[ 0 ]; // ์ญ์ "zero" ๋ฐํ a. toWord( 5 ); // "five" ๋ฐํ a[ 5 ]; // "5"๋ผ๋ ํ๋กํผํฐ๊ฐ ์์ผ๋ฏ๋ก undefined ๋ฐํ
์๋ IDL ํ๋๊ทธ๋จผํธ๋
OrderedMap ์ธํฐํ์ด์ค๋ฅผ ์ ์ํ๋ฉฐ,
์ด๋ฆ ๋๋ ์ธ๋ฑ์ค ๋ฒํธ๋ก ๊ฐ์ ์กฐํ/์ค์ ํ ์ ์์ต๋๋ค:
[Exposed =Window ]interface OrderedMap {readonly attribute unsigned long size ;getter any getByIndex (unsigned long index );setter undefined setByIndex (unsigned long index ,any value );getter any get (DOMString name );setter undefined set (DOMString name ,any value ); };
๋ชจ๋ ํน์ ์ฐ์ฐ์ด ์๋ณ์๋ฅผ ์ฌ์ฉํ ์ฐ์ฐ์ผ๋ก ์ ์ธ๋์ด ์์ผ๋ฏ๋ก, ์ถ๊ฐ์ ์ผ๋ก ํ์ํ ํ๋ก์ฆ๋ ์ด๋ค ํค๋ค์ด ์๋์ง์ ๋ํ ์ค๋ช
๋ฟ์
๋๋ค. get() ์ฐ์ฐ์ด ์กด์ฌํ์ง ์๋
ํญ๋ชฉ์ ์กฐํํ ๋
OrderedMap์ ๊ตฌํํ๋ ๊ฐ์ฒด map์ 0 โค index <map.size๋ฒ์์ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ค.๋ํ,
get()์ ๋๊ฒผ์ ๋ null์ด ์๋ ๊ฐ์ ๋ฐํํ๋ ๋ชจ๋ ์ด๋ฆ์ ๋ํด ์ด๋ฆ ํ๋กํผํฐ๋ ์ง์ํ๋ค.
ยงโฏ3.9 ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์์ ์ค๋ช
ํ ๋๋ก,
์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์
OrderedMap ์ธํฐํ์ด์ค์ ์ด๋ฆ/์ธ๋ฑ์ค ํ๋กํผํฐ์ ํด๋นํ๋ ํ๋กํผํฐ๊ฐ ์์ฑ๋๋ค.
์ด ํ๋กํผํฐ๋ค์ ๊ฐ์ฒด์ ๋ฉ์๋๋ฅผ ํธ์ถํ๋ ๊ฒ๊ณผ ๋์ผํ๊ฒ ์ํธ์์ฉํ ์ ์์ผ๋ฉฐ, ์๋ ์์์ฒ๋ผ ์ฌ์ฉํ ์ ์์ต๋๋ค:
// map์ OrderedMap ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด๋ผ๊ณ ๊ฐ์ var map= getOrderedMap(); var x, y; x= map[ 0 ]; // map.length > 0์ด๋ฉด ์๋์ ๋๋ฑ: // x = map.getByIndex(0) // ์ฆ, map์ "0"์ด๋ผ๋ ํ๋กํผํฐ๊ฐ ์์ผ๋ฏ๋ก // ๊ทธ๋ ์ง ์์ผ๋ฉด x๋ undefined map[ 1 ] = false ; // ์๋์ ๋๋ฑ: // map.setByIndex(1, false) y= map. apple; // apple์ด๋ผ๋ ์ด๋ฆ ํ๋กํผํฐ๊ฐ ์์ผ๋ฉด ์๋์ ๋๋ฑ: // y = map.get('apple') // ์์ผ๋ฉด y๋ undefined map. berry= 123 ; // ์๋์ ๋๋ฑ: // map.set('berry', 123) delete map. cake; // cake๋ผ๋ ์ด๋ฆ ํ๋กํผํฐ๊ฐ ์์ผ๋ฉด ํด๋น ํ๋กํผํฐ ์ญ์ ํ ์๋ ๋๋ฑ: // map.remove("cake")
2.5.6.2. ์ด๋ฆ ํ๋กํผํฐ
์ด๋ฆ ํ๋กํผํฐ getter๋ฅผ ์ ์ํ ์ธํฐํ์ด์ค๋ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ค๊ณ ํ๋ค. ํ์ฅํด์, ํ๋ซํผ ๊ฐ์ฒด๊ฐ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ค๊ณ ํ๋ ค๋ฉด ํด๋น ๊ฐ์ฒด๊ฐ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด ๋๋ค.
์ธํฐํ์ด์ค๊ฐ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ฉด, ์ธํฐํ์ด์ค ์ ์์๋ ๊ฐ์ฒด๋ฅผ ์ธ์ ๋ ์ง ์ด๋ค ์ด๋ฆ์ผ๋ก ์ธ๋ฑ์ฑํ ์ ์๋์ง(์์๊ฐ ์๋ ์ด๋ฆ ์งํฉ) ๊ธฐ์ ์ด ํฌํจ๋์ด์ผ ํ๋ค. ์ด ์ด๋ฆ๋ค์ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ์ด๋ผ๊ณ ํ๋ค.
์ด๋ฆ ํ๋กํผํฐ getter์ deleter๋
๋ฐ๋์ DOMString
ํ๋์ ์ธ์๋ฅผ ๋ฐ์์ผ ํ๋ค.
์ด๋ฆ ํ๋กํผํฐ setter๋
๋ฐ๋์ ๋ ๊ฐ์ ์ธ์๋ฅผ ๋ฐ์์ผ ํ๋ฉฐ, ์ฒซ ๋ฒ์งธ ์ธ์๋ DOMString์ด์ด์ผ
ํ๋ค.
interface interface_identifier {getter type identifier (DOMString identifier );setter type identifier (DOMString identifier ,type identifier );deleter type identifier (DOMString identifier );getter type (DOMString identifier );setter type (DOMString identifier ,type identifier );deleter type (DOMString identifier ); };
์ด๋ฆ ํ๋กํผํฐ getter, setter, deleter ์ ์์๋ ๋ค์ ์๊ตฌ ์ฌํญ์ด ์ ์ฉ๋๋ค:
-
์ด๋ฆ ํ๋กํผํฐ getter๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ์ผ๋ก ์ธ๋ฑ์ฑํ๋ฉด ํด๋น ์ด๋ฆ์ ์ ์ผ ์ธ์๋ก ๋๊ฒจ ์ฐ์ฐ์ ํธ์ถํ ๊ฒฐ๊ณผ๊ฐ์ด ๋ฐํ๋๋ค. ๋ง์ฝ ์ด๋ฆ ํ๋กํผํฐ getter ์ ์ธ์ ์๋ณ์๊ฐ ์๋ค๋ฉด, ์ธํฐํ์ด์ค ์ ์์ ์ฃผ์ด์ง ์ด๋ฆ์ ๋ํด ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ๊ฒฐ์ ๋ฐฉ๋ฒ์ ๊ธฐ์ ํด์ผ ํ๋ค.
-
์ด๋ฆ ํ๋กํผํฐ setter๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ๊ณผ ๊ฐ์ผ๋ก ํ๋กํผํฐ ํ ๋น/์์ฑ์ ์ํด ์ธ๋ฑ์ฑํ๋ฉด, ์ด๋ฆ์ ์ฒซ ๋ฒ์งธ ์ธ์, ๊ฐ์ ๋ ๋ฒ์งธ ์ธ์๋ก ๋๊ฒจ ์ฐ์ฐ์ ํธ์ถํ ๊ฒ๊ณผ ๋์ผํ๊ฒ ๋์ํ๋ค. ๋ง์ฝ ์ด๋ฆ ํ๋กํผํฐ setter ์ ์ธ์ ์๋ณ์๊ฐ ์๋ค๋ฉด, ์ธํฐํ์ด์ค ์ ์์ ๊ธฐ์กด ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ์ค์ (๊ธฐ์กด ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ์ค์ )๊ณผ ์ ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ์ค์ (์ ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ์ค์ ) ๋ฐฉ๋ฒ์ ๊ธฐ์ ํด์ผ ํ๋ค.
-
์ด๋ฆ ํ๋กํผํฐ deleter๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ์ผ๋ก ์ญ์ ์ธ๋ฑ์ฑํ๋ฉด, ์ด๋ฆ์ ์ ์ผ ์ธ์๋ก ๋๊ฒจ ์ฐ์ฐ์ ํธ์ถํ ๊ฒ๊ณผ ๋์ผํ๊ฒ ๋์ํ๋ค. ๋ง์ฝ ์ด๋ฆ ํ๋กํผํฐ deleter ์ ์ธ์ ์๋ณ์๊ฐ ์๋ค๋ฉด, ์ธํฐํ์ด์ค ์ ์์ ์ฃผ์ด์ง ์ด๋ฆ์ ๋ํด ๊ธฐ์กด ์ด๋ฆ ํ๋กํผํฐ ์ญ์ ๋ฐฉ๋ฒ์ ๊ธฐ์ ํด์ผ ํ๋ค.
์ฐธ๊ณ : ์ธ๋ฑ์ค ํ๋กํผํฐ์ ๋ง์ฐฌ๊ฐ์ง๋ก, ์ด๋ฆ ํ๋กํผํฐ getter, setter ๋๋ deleter ๊ฐ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ์จ์ ์ง์ ๋ ๊ฒฝ์ฐ, ๊ฐ์ฒด๋ฅผ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ์ด ์๋ ์ด๋ฆ์ผ๋ก ์ธ๋ฑ์ฑํ ๋ ํด๋น ์ฐ์ฐ์ ํด๋น ์ด๋ฆ์ผ๋ก ํธ์ถํ๋ ๊ฒ๊ณผ ๋ฐ๋์ ๊ฐ์ ๋์์ ํ๋ ๊ฒ์ ์๋๋ฉฐ, ์ค์ ๋์์ ์ธ์ด ๋ฐ์ธ๋ฉ๋ง๋ค ๋ค๋ฆ ๋๋ค.
2.5.7. ์ ์ ์์ฑ ๋ฐ ์ฐ์ฐ
์ ์ ์์ฑ ๋ฐ
์ ์ ์ฐ์ฐ
์ ํด๋น ์ธํฐํ์ด์ค์ ํน์ ์ธ์คํด์ค๊ฐ ์๋๋ผ
์ธํฐํ์ด์ค ์์ฒด์ ์ฐ๊ฒฐ๋๋ ์์ฑ/์ฐ์ฐ์
๋๋ค. ์ ์ ์์ฑ๊ณผ ์ฐ์ฐ์ ์ ์ธ์
์ ์ ์ฐ์ฐ์ ํธ์ถํ๊ฑฐ๋ ์ ์ ์์ฑ์ ์ฐธ์กฐํ๋ ๊ฒ์ด ์ธํฐํ์ด์ค ์ธ์คํด์ค์์ ๊ฐ๋ฅํ์ง๋ ์ธ์ด ๋ฐ์ธ๋ฉ๋ง๋ค ๋ค๋ฆ ๋๋ค.
StaticMember ::static StaticMemberRest
StaticMemberRest ::OptionalReadOnly AttributeRest RegularOperation
์๋ IDL ํ๋๊ทธ๋จผํธ๋
Circle ์ธํฐํ์ด์ค์ ์ ์ ์ฐ์ฐ์ด ์ ์ธ๋ ์์์
๋๋ค:
[Exposed =Window ]interface Point { /* ... */ }; [Exposed =Window ]interface Circle {attribute double cx ;attribute double cy ;attribute double radius ;static readonly attribute long triangulationCount ;static Point triangulate (Circle c1 ,Circle c2 ,Circle c3 ); };
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ triangulate์ ํจ์ ๊ฐ์ฒด์ triangulationCount์ ์ ๊ทผ์ ํ๋กํผํฐ๊ฐ
Circle์ ์ธํฐํ์ด์ค ๊ฐ์ฒด์ ์กด์ฌํฉ๋๋ค:
var circles= getCircles(); // Circle ๊ฐ์ฒด ๋ฐฐ์ด typeof Circle. triangulate; // "function" ๋ฐํ typeof Circle. triangulationCount; // "number" ๋ฐํ Circle. prototype. triangulate; // undefined ๋ฐํ Circle. prototype. triangulationCount; // ์ญ์ undefined ๋ฐํ circles[ 0 ]. triangulate; // ์ด ์ญ์ undefined circles[ 0 ]. triangulationCount; // ์ด๊ฒ๋ undefined // ์ ์ ์ฐ์ฐ ํธ์ถ var triangulationPoint= Circle. triangulate( circles[ 0 ], circles[ 1 ], circles[ 2 ]); // ์ํํ ์ผ๊ฐ๋ถํ ๊ฐ์ ํ์ธ window. alert( Circle. triangulationCount);
2.5.8. ์ค๋ฒ๋ก๋ฉ
์ธํฐํ์ด์ค์ ์ ์๋ ์ผ๋ฐ ์ฐ์ฐ ๋๋ ์ ์ ์ฐ์ฐ์ด ๋์ผํ ์ข ๋ฅ(์ผ๋ฐ ๋๋ ์ ์ )์ ๋ค๋ฅธ ์ฐ์ฐ๊ณผ ๋์ผํ ์๋ณ์๋ฅผ ๊ฐ์ง๋ฉด, ํด๋น ์ฐ์ฐ์ ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ์ด๋ผ ํ๋ค. ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ์ ์๋ณ์๊ฐ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์์ ํธ์ถ๋ ๋, ์ ๋ฌ๋ ์ธ์์ ๊ฐ์์ ํ์ ์ ๋ฐ๋ผ ์ค์ ๋ก ์ด๋ค ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ์ด ํธ์ถ๋๋์ง๊ฐ ๊ฒฐ์ ๋๋ค. ์์ฑ์ ์ฐ์ฐ๋ ์ค๋ฒ๋ก๋ฉ๋ ์ ์๋ค. ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ๊ณผ ์์ฑ์๊ฐ ๋ฐ์ ์ ์๋ ์ธ์์๋ ๋ช ๊ฐ์ง ์ ํ์ด ์์ผ๋ฉฐ, ์ด๋ฅผ ์ค๋ช ํ๊ธฐ ์ํด ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ด๋ผ๋ ๊ฐ๋ ์ ์ฌ์ฉํ๋ค.
์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ ์งํฉ์ ๋ค์ ์ค ํ๋๋ฅผ ๋ง์กฑํด์ผ ํ๋ค:
-
์ฐ์ฐ ์ค ๋ฐํ ํ์ ์ด ํ๋ผ๋ฏธ์ค ํ์ ์ธ ๊ฒ์ด ์์ด์ผ ํ๋ค;
-
๋ชจ๋ ์ฐ์ฐ์ ๋ฐํ ํ์ ์ด ํ๋ผ๋ฏธ์ค ํ์ ์ด์ด์ผ ํ๋ค.
์ฐ์ฐ์ ์ธํฐํ์ด์ค, ๋ถ๋ถ ์ธํฐํ์ด์ค, ์ธํฐํ์ด์ค ๋ฏน์ค์ธ, ๋ถ๋ถ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ ์ ์๋ฅผ ๋๋๋ค์ด ์ค๋ฒ๋ก๋ฉ๋ ์ ์๋ค.
์๋ฅผ ๋ค์ด, ์๋์ f์ g์ ๋ํ ์ค๋ฒ๋ก๋ฉ์ ํ์ฉ๋์ง ์๋๋ค:
[Exposed =Window ]interface A {undefined f (); };partial interface A {undefined f (double x );undefined g (); };partial interface A {undefined g (DOMString x ); };
์ฐธ๊ณ ๋ก ์์ฑ์ ์ฐ์ฐ๊ณผ
[LegacyFactoryFunction]
ํ์ฅ ์์ฑ์
๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์์๋ ๋ฑ์ฅํ ์ ์์ผ๋ฏ๋ก,
์์ฑ์ ์ค๋ฒ๋ก๋ฉ์ ์ถ๊ฐ๋ก ๊ธ์งํ ํ์๋ ์๋ค.
์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์
ํน์ ์ฐ์ฐ,
์์ฑ์(์์ฑ์ ์ฐ์ฐ
๋๋ [LegacyFactoryFunction]),
๋๋ ์ฝ๋ฐฑ ํจ์์ ๋ํด
ํ์ฉ๋๋ ํธ์ถ์ ๋ํ๋ธ๋ค.
์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ ๊ณ์ฐ ์๊ณ ๋ฆฌ์ฆ์ ๋ค์ ๋ค ๊ฐ์ง IDL ๊ตฌ์กฐ์ ๋ํด ๋์ํ๋ฉฐ, ๊ฐ ๊ตฌ์กฐ๋ง๋ค
ํ์ํ ์
๋ ฅ์ด ์๋ค:
- ์ผ๋ฐ ์ฐ์ฐ์ ๊ฒฝ์ฐ
- ์ ์ ์ฐ์ฐ์ ๊ฒฝ์ฐ
-
-
์ฐ์ฐ์ด ์ ์๋ ์ธํฐํ์ด์ค
-
์ฐ์ฐ์ ์๋ณ์
-
์ ๋ฌํ ์ธ์์ ๊ฐ์
-
- ์์ฑ์์ ๊ฒฝ์ฐ
-
-
์์ฑ์ ์ฐ์ฐ์ด ์ ์๋ ์ธํฐํ์ด์ค
-
์ ๋ฌํ ์ธ์์ ๊ฐ์
-
- ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์ ๊ฒฝ์ฐ
-
-
[
LegacyFactoryFunction] ํ์ฅ ์์ฑ์ด ์ ์๋ ์ธํฐํ์ด์ค -
๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์ ์๋ณ์
-
์ ๋ฌํ ์ธ์์ ๊ฐ์
-
์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ์ธํฐํ์ด์ค์ ์ง์ ๋ ์ค๋ฒ๋ก๋ฉ ์ฐ์ฐ๊ณผ ์์ฑ์์ ๋ชจํธํจ์ด ์๋์ง ํ๋ณํ๋ ๋ฐ ์ฌ์ฉ๋๋ค.
์์ดํ ๋ค์ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ํํ๋ก, (ํธ์ถ ๊ฐ์ฒด, ํ์ ๋ฆฌ์คํธ, ์ต์ ๋๋ฆฌํฐ ๋ฆฌ์คํธ) ํํ๋ฅผ ๊ฐ์ง๋ค. ์๋์ ๊ฐ ์์ดํ ์ค๋ช :
-
ํธ์ถ ๊ฐ์ฒด๋ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ด ์ผ๋ฐ ์ฐ์ฐ, ์ ์ ์ฐ์ฐ ๋๋ ์์ฑ์ ์ฐ์ฐ์ผ ๋ ์ฐ์ฐ์ด๊ณ , ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ด ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์ผ ๋๋ ํ์ฅ ์์ฑ์ด๋ค.
-
ํ์ ๋ฆฌ์คํธ๋ IDL ํ์ ๋ค์ ๋ฆฌ์คํธ์ด๋ค.
-
์ต์ ๋๋ฆฌํฐ ๋ฆฌ์คํธ๋ "required", "optional", "variadic" ์ค ํ๋์ ์ต์ ๋๋ฆฌํฐ ๊ฐ์ ์ธ๋ฑ์ค๋ณ๋ก ๊ฐ์ง๋ ๋ฆฌ์คํธ์ด๋ค. ํด๋น ์ธ์๊ฐ ์ต์ ์ธ์์ธ์ง, ๊ฐ๋ณ ์ธ์์ธ์ง๋ฅผ ํ์ํ๋ค.
๊ฐ ํํ์ ํด๋น ํ์ ์ ์ธ์๊ฐ ๋ฆฌ์คํธ๋ก ์ฐ์ฐ, ์์ฑ์, ์ฝ๋ฐฑ ํจ์๋ฅผ ํธ์ถํ ์ ์์์ ์๋ฏธํ๋ค. ์ต์ ์ธ์ ๋ฐ ๊ฐ๋ณ ์ธ์ ์ฐ์ฐ/์์ฑ์ ๋๋ถ์, ๋์ผํ ์ฐ์ฐ์ด๋ ์์ฑ์๋ก ์๋ณ๋๋ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ ์์ดํ ์ด ์ฌ๋ฌ ๊ฐ ์์ ์ ์๋ค.
-
์ฐ์ฐ ๋๋ ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์ ์๋ณ์๋ A
-
์ธ์ ๊ฐ์๋ N
-
์ธํฐํ์ด์ค๋ I
ํ์ฅ ์์ฑ์ ์ธ์๋, ํ์ฅ ์์ฑ์ ๋ช ๋ช ๋ ์ธ์ ๋ฆฌ์คํธ์ ์ธ์๋ฅผ ์๋ฏธํ๋ค.
-
S๋ฅผ ์์ ์๋ ์งํฉ์ผ๋ก ๋๋ค.
-
F๋ฅผ ์์ ์๋ ์งํฉ์ผ๋ก ๋๋ค. ์์ดํ ์ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ ์ข ๋ฅ์ ๋ฐ๋ผ ๋ค์๊ณผ ๊ฐ๋ค:
- ์ผ๋ฐ ์ฐ์ฐ์ ๊ฒฝ์ฐ
-
F์ ์์๋ ์ธํฐํ์ด์ค I์ ์ ์๋ A ์๋ณ์์ ์ผ๋ฐ ์ฐ์ฐ์ด๋ค.
- ์ ์ ์ฐ์ฐ์ ๊ฒฝ์ฐ
-
F์ ์์๋ ์ธํฐํ์ด์ค I์ ์ ์๋ A ์๋ณ์์ ์ ์ ์ฐ์ฐ์ด๋ค.
- ์์ฑ์์ ๊ฒฝ์ฐ
-
F์ ์์๋ ์ธํฐํ์ด์ค I์ ์์ฑ์ ์ฐ์ฐ์ด๋ค.
- ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์ ๊ฒฝ์ฐ
-
F์ ์์๋ ์ธํฐํ์ด์ค I์ ์ ์๋ [
LegacyFactoryFunction] ํ์ฅ ์์ฑ ์ค ๋ช ๋ช ๋ ์ธ์ ๋ฆฌ์คํธ์ ์๋ณ์๊ฐ A์ธ ๊ฒ๋ค์ด๋ค.
-
maxarg๋ฅผ F์ ์ฐ์ฐ, ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์, ์ฝ๋ฐฑ ํจ์์์ ์ ์ธ๋ ์ต๋ ์ธ์ ๊ฐ์๋ก ๋๋ค. ๊ฐ๋ณ ์ธ์ ์ฐ์ฐ ๋ฐ ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์์, ...์ด ๋ถ์ ์ธ์๋ 1๊ฐ๋ก ์ผ๋ค.
์ฐธ๊ณ :
undefined f(long x, long... y);๋ ์ธ์ 2๊ฐ๋ก ๊ฐ์ฃผ๋๋ค. -
max๋ฅผ max(maxarg, N)๋ก ๋๋ค.
-
๊ฐ F์ ์ฐ์ฐ ๋๋ ํ์ฅ ์์ฑ X์ ๋ํด:
-
arguments๋ฅผ X์ ์ ์ธ๋ ์ธ์๋ค์ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
n์ arguments์ ํฌ๊ธฐ๋ก ๋๋ค.
-
types๋ฅผ ํ์ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
optionalityValues๋ฅผ ์ต์ ๋๋ฆฌํฐ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
๊ฐ arguments์ argument์ ๋ํด:
-
types์ argument์ ํ์ ์ ์ถ๊ฐํ๋ค.
-
optionalityValues์, argument๊ฐ ๋ง์ง๋ง ๊ฐ๋ณ ์ธ์๋ฉด "variadic", ์ต์ ์ธ์๋ฉด "optional", ๊ทธ ์ธ๋ "required"๋ฅผ ์ถ๊ฐํ๋ค.
-
-
X๊ฐ ๊ฐ๋ณ ์ธ์๋ก ์ ์ธ๋์๋ค๋ฉด:
-
๊ฐ i์ ๋ํด, ๋ฒ์ n๋ถํฐ max๊น์ง(๋๊ฐ ์ ์ธ):
-
t๋ฅผ ํ์ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
o๋ฅผ ์ต์ ๋๋ฆฌํฐ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
๊ฐ j์ ๋ํด, ๋ฒ์ 0๋ถํฐ n๊น์ง, ๋๊ฐ ์ ์ธ:
-
t์ types[j]๋ฅผ ์ถ๊ฐํ๋ค.
-
o์ optionalityValues[j]๋ฅผ ์ถ๊ฐํ๋ค.
-
-
๊ฐ j์ ๋ํด, ๋ฒ์ n๋ถํฐ i๊น์ง, ๋๊ฐ ํฌํจ:
-
t์ types[nโ1]๋ฅผ ์ถ๊ฐํ๋ค.
-
o์ "variadic"์ ์ถ๊ฐํ๋ค.
-
-
-
-
i๋ฅผ nโ1๋ก ๋๋ค.
-
i โฅ 0์ธ ๋์:
-
arguments[i]๊ฐ ์ต์ ์ธ์๊ฐ ์๋๋ฉด break.
-
t๋ฅผ ํ์ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
o๋ฅผ ์ต์ ๋๋ฆฌํฐ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
๊ฐ j์ ๋ํด, ๋ฒ์ 0๋ถํฐ i๊น์ง, ๋๊ฐ ์ ์ธ:
-
t์ types[j]๋ฅผ ์ถ๊ฐํ๋ค.
-
o์ optionalityValues[j]๋ฅผ ์ถ๊ฐํ๋ค.
-
-
S์ (X, t, o) ํํ์ ์ถ๊ฐํ๋ค.
์ฐธ๊ณ : i๊ฐ 0์ด๋ฉด S์ (X, ยซ ยป, ยซ ยป) (์ฌ๊ธฐ์ "ยซ ยป"๋ ๋น ๋ฆฌ์คํธ)๋ฅผ ์ถ๊ฐํ๋ค๋ ๋ป์ด๋ค.
-
i๋ฅผ iโ1๋ก ๋๋ค.
-
-
-
S๋ฅผ ๋ฐํํ๋ค.
๋ค์ ์ธํฐํ์ด์ค์ ๋ํด:
[Exposed =Window ]interface A { /* f1 */undefined f (DOMString a ); /* f2 */undefined f (Node a ,DOMString b ,double ...c ); /* f3 */undefined f (); /* f4 */undefined f (Event a ,DOMString b ,optional DOMString c ,double ...d ); };
Node์ Event๊ฐ ์๋ก ๋ค๋ฅธ ์ธํฐํ์ด์ค์ด๋ฉฐ, ์ด๋ค ๊ฐ์ฒด๋ ๋ ๋ค๋ฅผ ๊ตฌํํ ์ ์๋ค๋ฉด,
์ผ๋ฐ ์ฐ์ฐ์ ์๋ณ์ f์ ์ธ์ ๊ฐ์ 4์ ๋ํด ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ๋ค์๊ณผ ๊ฐ๋ค:
ยซ (f1, ยซ DOMString ยป, ยซ required ยป), (f2, ยซ Node, DOMString ยป, ยซ required, required ยป), (f2, ยซ Node, DOMString, double ยป, ยซ required, required, variadic ยป), (f2, ยซ Node, DOMString, double, double ยป, ยซ required, required, variadic, variadic ยป), (f3, ยซ ยป, ยซ ยป), (f4, ยซ Event, DOMString ยป, ยซ required, required ยป), (f4, ยซ Event, DOMString, DOMString ยป, ยซ required, required, optional ยป), (f4, ยซ Event, DOMString, DOMString, double ยป, ยซ required, required, optional, variadic ยป) ยป
๋ ํ์ ์ด ๊ตฌ๋ณ ๊ฐ๋ฅํ๋ค๋ ๊ฒ์ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด true๋ฅผ ๋ฐํํ๋ ๊ฒฝ์ฐ์ด๋ค.
-
ํ ํ์ ์ด ๋ ํ์ฉ ํ์ ์ ํฌํจํ๊ณ , ๋ค๋ฅธ ํ์ ์ด ๋ ํ์ฉ ํ์ ์ ํฌํจํ๊ฑฐ๋, ์ ๋์จ ํ์ ์ด๋ฉฐ ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ๋์ ๋๋ฆฌ ํ์ ์ด ํฌํจ๋๊ฑฐ๋, ๋์ ๋๋ฆฌ ํ์ ์ด๋ฉด, false๋ฅผ ๋ฐํํ๋ค.
-
๋ ํ์ ๋ชจ๋ ์ ๋์จ ํ์ ๋๋ ๋ ํ์ฉ ์ ๋์จ ํ์ ์ด๋ฉด, ๊ฐ ๋ฉค๋ฒ ํ์ ์ด ์๋ก ๊ตฌ๋ณ ๊ฐ๋ฅํ๋ฉด true, ์๋๋ฉด false๋ฅผ ๋ฐํํ๋ค.
-
ํ ํ์ ์ด ์ ๋์จ ํ์ ๋๋ ๋ ํ์ฉ ์ ๋์จ ํ์ ์ด๋ฉด, ์ ๋์จ ํ์ ์ ๊ฐ ๋ฉค๋ฒ ํ์ ์ด ๋น์ ๋์จ ํ์ ๊ณผ ๊ตฌ๋ณ ๊ฐ๋ฅํ๋ฉด true, ์๋๋ฉด false๋ฅผ ๋ฐํํ๋ค.
-
๊ฐ ํ์ ์ ๋ด๋ถ ํ์ (์ฃผ์ ํ์ ์ด๋ฉด)๊ณผ ๋ด๋ถ ํ์ (๊ทธ ๊ฒฐ๊ณผ๊ฐ ๋ ํ์ฉ ํ์ ์ด๋ฉด)์ ์ทจํ "๊ฐ์ฅ ์์ชฝ" ํ์ ์ ๊ณ ๋ คํ๋ค. ์ด ๋ ํ์ ์ด ์๋ ํ์ ์นดํ ๊ณ ๋ฆฌ์ ์ํ๊ณ , ํด๋น ๊ต์ฐจ์ ์ โ ๋๋ ์ง์ ๋ ์กฐ๊ฑด(a, b, c, d)์ด ๋ง์กฑ๋๋ฉด true, ์๋๋ฉด false๋ฅผ ๋ฐํํ๋ค.
์นดํ ๊ณ ๋ฆฌ:
- interface-like
- dictionary-like
- sequence-like
undefinedbooleannumeric typesbigintstring typesobjectsymbolinterface-likecallback functiondictionary-likeasync sequencesequence-likeundefined โ โ โ โ โ โ โ โ โ โ boolean โ โ โ โ โ โ โ โ โ โ numeric types (b) โ โ โ โ โ โ โ โ bigint โ โ โ โ โ โ โ โ string types โ โ โ โ โ (d) โ object โ symbol โ โ โ โ โ interface-like (a) โ โ โ โ callback function (c) โ โ dictionary-like โ โ โ async sequence sequence-like -
์๋ณ๋ ๋ interface-like ํ์ ์ด ์๋ก ๋ค๋ฅด๊ณ , ์ด๋ค ํ๋ซํผ ๊ฐ์ฒด๋ ๋ ํ์ ์ ๋ชจ๋ ๊ตฌํํ์ง ์๋๋ค.
-
ํ์ ์ด ๊ตฌ๋ณ ๊ฐ๋ฅํ์ง๋ง, ์ค๋ฒ๋ก๋ฉ์์ ์ฌ์ฉ์ ๋ณ๋์ ์ ํ์ด ์๋ค. ๋ํ ์ด ํ์ ์ ์ ๋์จ ์ฌ์ฉ์ ๊ดํ ์กฐ์ธ๋ ์ฐธ๊ณ ํ ๊ฒ.
-
[
LegacyTreatNonObjectAsNull] ํ์ฅ ์์ฑ์ด ์๋ ์ฝ๋ฐฑ ํจ์๋ dictionary-like ์นดํ ๊ณ ๋ฆฌ ํ์ ๊ณผ ๊ตฌ๋ณ ๊ฐ๋ฅํ๋ค.์๋ฅผ ๋ค์ด, ECMAScript ๊ฐ์ ์ฝ๋ฐฑ ํจ์์ ๋์ ๋๋ฆฌ-like ํ์ ์ ํฌํจํ๋ ์ ๋์จ ํ์ ์ผ๋ก ๋ณํํ ๋, ๊ฐ์ด ํธ์ถ ๊ฐ๋ฅ์ด๋ฉด ์ฝ๋ฐฑ ํจ์๋ก, ์๋๋ฉด ๋์ ๋๋ฆฌ-like ํ์ ์ผ๋ก ๋ณํ๋๋ค. -
ํ์ ์ ๊ตฌ๋ณ ๊ฐ๋ฅํ์ง๋ง, ๋ฌธ์์ด ํ์ ์ด ์ค๋ฒ๋ก๋ ์งํฉ์ด๋ ์ ๋์จ์๋ ์์ผ๋ฉด ECMAScript ๊ฐ์์ ๋ณํํ ๋ ๋ฌธ์์ด ๊ฐ์ฒด ๋ ๋น๋๊ธฐ ์ํ์ค ํ์ ์ผ๋ก ๋ณํ๋์ง ์๋๋ค( %Symbol.iterator% ๋ฉ์๋๊ฐ ์๋๋ผ๋).
double๊ณผDOMString์ ์ซ์ ํ์ ๊ณผ ๋ฌธ์์ด ํ์ ๊ต์ฐจ์ ์ โ์ด ์์ผ๋ฏ๋ก ๊ตฌ๋ณ ๊ฐ๋ฅํ๋ค.double๊ณผlong์ ๋ชจ๋ ์ซ์ ํ์ ์ด๋ฏ๋ก, ์ซ์ ํ์ ๊ณผ ์ซ์ ํ์ ์ ๊ต์ฐจ์ ์ โ์ด๋ ๋ฌธ์๊ฐ ์์ผ๋ฏ๋ก ๊ตฌ๋ณ ๋ถ๊ฐ๋ฅํ๋ค.๋ค์๊ณผ ๊ฐ์ ๋:callback interface CBIface {undefined handle (); }; [Exposed =Window ]interface Iface {attribute DOMString attr2 ; };dictionary Dict {DOMString field1 ; };CBIface๋Iface์๋ ๊ตฌ๋ณ ๊ฐ๋ฅํ๋ค(๋์ ๋๋ฆฌ-like์ ์ธํฐํ์ด์ค-like ๊ต์ฐจ์ ์ โ์ด ์์). ํ์ง๋งDict์๋ ๊ตฌ๋ณ ๋ถ๊ฐ๋ฅํ๋ค(๋์ ๋๋ฆฌ-like ๊ต์ฐจ์ ์ โ ์์).ํ๋ผ๋ฏธ์ค ํ์ ์ ์ ํ์ ์์ผ๋ฏ๋ก, ์ด๋ค ๋ค๋ฅธ ํ์ ๊ณผ๋ ๊ตฌ๋ณ ๋ถ๊ฐ๋ฅํ๋ค.
์ฃผ์ด์ง ํจ๊ณผ์ ์ค๋ฒ๋ก๋ ์งํฉ ์์ ๊ฐ์ ํ์ ๋ฆฌ์คํธ ํฌ๊ธฐ ๋ฅผ ๊ฐ๋ ํญ๋ชฉ ์ด ๋ ์ด์์ด๋ฉด, ๊ทธ๋ฌํ ํญ๋ชฉ๋ค์ ๋ํด ์ด๋ค ์ธ๋ฑ์ค i ๊ฐ ์กด์ฌํ์ฌ ๋ชจ๋ ํญ๋ชฉ ์์ ์ธ๋ฑ์ค i ์ ์๋ ํ์ ๋ค์ด ๊ตฌ๋ณ ๊ฐ๋ฅ ํด์ผ ํฉ๋๋ค. ์ด ์กฐ๊ฑด์ ๋ง์กฑํ๋ ๊ฐ์ฅ ์์ ์ธ๋ฑ์ค๋ฅผ, ํด๋น ํ์ ๋ฆฌ์คํธ ํฌ๊ธฐ๋ฅผ ๊ฐ๋ ํจ๊ณผ์ ์ค๋ฒ๋ก๋ ์งํฉ ์ ํญ๋ชฉ๋ค์ ๋ํ ๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค ๋ผ๊ณ ํฉ๋๋ค.
ํจ๊ณผ์ ์ค๋ฒ๋ก๋ ์งํฉ ์๋ ๊ฐ์ ํ์ ๋ฆฌ์คํธ ํฌ๊ธฐ ๋ฅผ ๊ฐ๋ ํญ๋ชฉ ์ด ๋ ์ด์ ์์ผ๋ฉด์, ๊ทธ์ค ํ๋์ ํญ๋ชฉ ์ ๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค ์ bigint ์ธ์๋ฅผ ๊ฐ๊ณ ๋ค๋ฅธ ํ๋๋ ๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค ์ ์ซ์ ํ์ ์ธ์๋ฅผ ๊ฐ๋ ๊ฒฝ์ฐ๊ฐ ์์ด์๋ ์ ๋ฉ๋๋ค.
์ ์์์ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ์๊ฐํด๋ณด์.
type list๊ฐ 2, 3, 4์ธ ์์ดํ
์ด ์ฌ๋ฌ ๊ฐ ์๋ค.
๊ฐ type list ํฌ๊ธฐ๋ณ๋ก ๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค๋ 0์ด๋ค. Node์
Event๊ฐ ๊ตฌ๋ณ ๊ฐ๋ฅ์ด๊ธฐ ๋๋ฌธ์ด๋ค.
์๋์ ๊ฐ์ ์ค๋ฒ๋ก๋ฉ์ ํ์ฉ๋์ง ์๋๋ค:
[Exposed =Window ]interface B {undefined f (DOMString x );undefined f (USVString x ); };
DOMString
๊ณผ USVString
์ ๊ตฌ๋ณ ๋ถ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ด๋ค.
๋ํ, ์ด๋ค type list ํฌ๊ธฐ์ ๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค๋ณด๋ค ์์ ์ธ๋ฑ์ค j์ ๋ํด, ๋ชจ๋ ์์ดํ ์ type list์์ j๋ฒ์งธ ํ์ ์ด ๊ฐ์์ผ ํ๋ฉฐ, ๋ชจ๋ ์์ดํ ์ optionality list์์ j๋ฒ์งธ optionality ๊ฐ๋ ๊ฐ์์ผ ํ๋ค.
๋ค์์ ํ์ฉ๋์ง ์๋๋ค:
[Exposed =Window ]interface B { /* f1 */undefined f (DOMString w ); /* f2 */undefined f (long w ,double x ,Node y ,Node z ); /* f3 */undefined f (double w ,double x ,DOMString y ,Node z ); };
์ธ์ ๊ฐ์ 4์์์ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ์๋์ ๊ฐ๋ค:
ยซ (f1, ยซ DOMString ยป, ยซ required ยป), (f2, ยซ long, double, Node, Node ยป, ยซ required, required, required, required ยป), (f3, ยซ double, double, DOMString, Node ยป, ยซ required, required, required, required ยป) ยป
type list ํฌ๊ธฐ๊ฐ 4์ธ ์์ดํ
๋ค์์,
๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค
๋ 2์ด๋ค. Node์
DOMString
์ด ๊ตฌ๋ณ ๊ฐ๋ฅ์ด๊ธฐ
๋๋ฌธ์ด๋ค.
๊ทธ๋ฌ๋ ์ด ๋ ์ค๋ฒ๋ก๋์ 0๋ฒ์งธ ์ธ์ ํ์
์ด ๋ค๋ฅด๋ฏ๋ก, ์ค๋ฒ๋ก๋ฉ์ ํ์ฉ๋์ง ์๋๋ค.
2.5.8.1. ์ค๋ฒ๋ก๋ฉ vs. ์ ๋์จ ํ์
์ด ์น์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
IDL ์ฐ์ฐ์ ์ ์ํ๋ ๋ช ์ธ์์, ์ค๋ฒ๋ก๋ฉ๊ณผ ์ ๋์จ ํ์ , ์ต์ ์ธ์ ์กฐํฉ์ด ๊ธฐ๋ฅ์ ์ผ๋ก ๊ฒน์น๋ ๋ถ๋ถ์ด ์์ด ๋ณด์ผ ์ ์์ต๋๋ค.
๋จผ์ ์ค๋ฒ๋ก๋ฉ์ ์ ๋์จ ํ์
์ด๋ ์ต์
์ธ์์๋
๋์์ด ๋ค๋ฅด๋ฉฐ, ํ๋๋ก ์์ ํ ๋์ฒดํ ์ ์๋ค(๋ฌผ๋ก ์ถ๊ฐ์ ์ธ ํ๋ก์ฆ๊ฐ ์์ผ๋ฉด ๊ฐ๋ฅํ์ง๋ง, ์ด๋ Web IDL ํ์
์์คํ
์ ๋ชฉ์ ์ ์ด๊ธ๋๋ค). ์๋ฅผ ๋ค์ด stroke()
์ฐ์ฐ์ด CanvasDrawPath
์ธํฐํ์ด์ค์ ์ ์๋์ด ์๋ค๊ณ ํ์ [HTML]:
interface CanvasDrawPathExcerpt {undefined stroke ();undefined stroke (Path2D path ); };
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋, stroke(undefined)๋ฅผ ํธ์ถํ๋ฉด ๋ ๋ฒ์งธ ์ค๋ฒ๋ก๋๊ฐ ์ ํ๋๋ฉฐ, TypeError
๊ฐ ๋ฐ์ํ๋ค. Path2D๋ก
๋ณํ๋ ์ ์๊ธฐ ๋๋ฌธ์ด๋ค.
ํ์ง๋ง ์ฐ์ฐ์ด ์ต์
์ธ์๋ก ํ๋๋ก ํฉ์ณ์ง๋ค๋ฉด,
interface CanvasDrawPathExcerptOptional {undefined stroke (optional Path2D path ); };
์ค๋ฒ๋ก๋ ๊ฒฐ์ ์๊ณ ๋ฆฌ์ฆ์ path ์ธ์๋ฅผ ๋๋ฝ๋ ๊ฒ์ผ๋ก ์ฒ๋ฆฌํ๊ณ ์์ธ๋ฅผ ๋ฐ์์ํค์ง ์์ต๋๋ค.
์ฐธ๊ณ : ์ด ์์์์ ํ์์ ๋์์ด ์ค์ ๋ก Web ๊ฐ๋ฐ์๊ฐ ๊ธฐ๋ํ๋ ๊ฒ์
๋๋ค. CanvasDrawPath
๋ฅผ ์๋ก ์ค๊ณํ๋ค๋ฉด ์ต์
์ธ์๋ก stroke()๋ฅผ ์ ์ํ ๊ฒ์
๋๋ค.
๋ํ ์๋ฏธ์ ์ฐจ์ด๋ ์์ต๋๋ค. ์ ๋์จ ํ์ ์ "์ด๋ค ํ์ ์ด๋ ๋์์ด ๋์ฒด๋ก ๊ฐ๋ค"๋ ์๋ฏธ๋ก ์ฃผ๋ก ์ฐ์ด๊ณ , ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ์ C++ ๋ฑ ์ธ์ด์ ์ค๋ฒ๋ก๋ฉ๊ณผ ์ ๋์๋๋ ๊ตฌ์กฐ๋ก, ์ธ์ ํ์ ์ ๋ฐ๋ผ ๋์์ด ํฌ๊ฒ ๋ฌ๋ผ์ง๋ ๊ฒฝ์ฐ์ ๋ ์ ํฉํฉ๋๋ค. ํ์ง๋ง ์ด๋ฐ ๊ฒฝ์ฐ ๋๋ถ๋ถ์ ํผ๋์ ํผํ๊ธฐ ์ํด ์ฐ์ฐ ์ด๋ฆ์ ๋ค๋ฅด๊ฒ ํ๋ ๊ฒ์ด ์ข์ผ๋ฉฐ, ์๋ฐ์คํฌ๋ฆฝํธ๋ ์ธ์ด ์ฐจ์์ ์ค๋ฒ๋ก๋ฉ์ ์ ๊ณตํ์ง ์์ผ๋ฏ๋ก ์๋ก์ด API์๋ ์ค๋ฒ๋ก๋ฉ์ ๊ฑฐ์ ์ ํฉํ์ง ์๊ณ , ๋ ๊ฑฐ์ API๋ ํน์ํ ๊ฒฝ์ฐ์๋ง ์ฌ์ฉ๋ฉ๋๋ค.
๊ทธ๋๋ ์ด๋ค IDL ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ง ์ด๋ ค์ธ ๋ ์๋์ ๊ฐ์ ๊ถ๊ณ ์ ์์๋ฅผ ์ฐธ๊ณ ํ์ธ์:
-
์ธ์ ํ์ ๋ณ๋ก ๋ฐํ ํ์ ์ด ๋ค๋ฅผ ํ์๊ฐ ์๋ ํน์ดํ ๊ฒฝ์ฐ์๋ ์ค๋ฒ๋ก๋ฉ์ด ๋ ํํ๋ ฅ์ด ์ข์ต๋๋ค. ์ด๋ฐ API ์ค๊ณ๋ ๊ฑฐ์ ๋ฐ๋์งํ์ง ์์ผ๋ฉฐ, ๋ณดํต ์ด๋ฆ์ด ๋ค๋ฅธ ์ฐ์ฐ์ผ๋ก ๋ถ๋ฆฌํ๋ ๊ฒ์ด ๋ ๋ซ์ต๋๋ค.
์๋ฅผ ๋ค์ด
calculate()๊ฐlong,DOMString,CalculatableInterface(์ธํฐํ์ด์ค ํ์ ) ์ค ํ๋๋ฅผ ๋ฐ์, ์ธ์ ํ์ ๊ณผ ๋์ผํ ํ์ ์ ๊ฐ์ ๋ฐํํ๋ค๋ฉด, ์๋์ฒ๋ผ ์ค๋ฒ๋ก๋ฉ์ด ๋ ๋ช ํํ๋ค:interface A {long calculate (long input );DOMString calculate (DOMString input );CalculatableInterface calculate (CalculatableInterface input ); };์๋์ฒ๋ผ ์ ๋์จ ํ์ ๊ณผ ํ์ ์ ์๋ฅผ ์ฐ๋ฉด, ๋ฐํ๊ฐ์ด ํญ์ input ํ์ ๊ณผ ๊ฐ๋ค๋ ์ฌ์ค์ด ๋ช ํํ ๋๋ฌ๋์ง ์๋๋ค:
typedef (long or DOMString or CalculatableInterface )Calculatable ;interface A {Calculatable calculate (Calculatable input ); };์ API๋ผ๋ฉด, ์ค๋ฒ๋ก๋ฉ ๋์ ์๋์ฒ๋ผ ์ด๋ฆ์ ๊ตฌ์ฒด์ ์ผ๋ก ๋๋๋ ๊ฒ์ด ๋ ์ข์ต๋๋ค:
interface A {long calculateNumber (long input );DOMString calculateString (DOMString input );CalculatableInterface calculateCalculatableInterface (CalculatableInterface input ); };์ด๋ ๊ฒ ํ๋ฉด Web ๊ฐ๋ฐ์๊ฐ ๋ช ํํ๊ณ ํผ๋ ์๋ ์ฝ๋๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
-
์ธ์ ํ์ ์ด๋ ๊ฐ์์ ๋ฐ๋ผ ์๋ฏธ์ ์ผ๋ก ๋์์ด ํฌ๊ฒ ๋ฌ๋ผ์ง๋ฉด ์ค๋ฒ๋ก๋ฉ์ ์ ํธํฉ๋๋ค. ๋จ, ์ด ๊ฒฝ์ฐ๋ ๋ณดํต ์ด๋ฆ์ ๋ถ๋ฆฌํ๋ ๊ฒ์ด ์ข๊ณ , ๋ ๊ฑฐ์ API์์ ์ด๋ฐ ํจํด์ด ์ข ์ข ๋ณด์ ๋๋ค.
์๋ฅผ ๋ค์ด
supports(property, value)์supports(conditionText)๋CSS์ธํฐํ์ด์ค์ ์๋์ฒ๋ผ ์ ์๋จ [CSS3-CONDITIONAL] [CSSOM]:partial interface CSS {static boolean supports (CSSOMString property ,CSSOMString value );static boolean supports (CSSOMString conditionText ); };์ต์ ์ธ์๋ก IDL์ ์๋์ฒ๋ผ ์ธ ์๋ ์์ง๋ง,
partial interface CSSExcerptOptional {static boolean supports (CSSOMString propertyOrConditionText ,optional CSSOMString value ); };๋ ๋ฒ์ ์ ๋น๊ตํ๋ฉด, ๋ ๊ฐ๋ ์ด ์ฒซ ๋ฒ์งธ ์ธ์์ ํผํฉ๋์ด ์์ด ๊ตฌ๋ถ์ด ์ด๋ ต์ต๋๋ค. ์ค๋ฒ๋ก๋ฉ์ ์ฐ๋ฉด property๊ฐ value์ ์ง์ ์ด๋ฃจ๋์ง, conditionText์ธ์ง ๋ช ํํ๊ฒ ๊ตฌ๋ถํ ์ ์์ผ๋ฉฐ, ๋ฉ์๋ ๋จ๊ณ๋ ์ค๋ฒ๋ก๋ฉ๋ ์ฐ์ฐ์ ๋ฉ์๋ ๋จ๊ณ๋ ๊ฐ๊ฐ ๋ ๋ฆฝ์ ์ธ ๋ธ๋ก์ผ๋ก ๋ช ์ธํ ์ ์์ด ๋ช ์ธ๋ฅผ ์ฝ๊ณ ์ฐ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค. ์ต์ ์ธ์๋ ๊ทธ๋ ์ง ์์ต๋๋ค. ๋ฐ๋ผ์ ์ฒซ ๋ฒ์งธ ๊ฒฝ์ฐ์๋ ๋ช ์ธ ์์ฑ์๊ฐ ์ฐ์ฐ์ ๋ฉ์๋ ๋จ๊ณ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์์ฑํ ์ ์์ต๋๋ค.
supports(property, value)๋ฉ์๋ ๋จ๊ณ:-
โฆ
supports(conditionText)๋ฉ์๋ ๋จ๊ณ:-
โฆ
value๋ฅผ ์ต์ ์ธ์๋ก ์ธ ๊ฒฝ์ฐ, ๋ช ์ธ ์์ฑ์๋ ์ค๋ฒ๋ก๋ ๊ฒฐ์ ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ค์ ์ฌํํ๋ ๋ค์๊ณผ ๊ฐ์ ๋ฐ๋ณต์ ์ธ ์ค๋ช ์ ๋ ๋ง์ด ์จ์ผ ํฉ๋๋ค:
supports(propertyOrConditionText, value)๋ฉ์๋ ๋จ๊ณ:-
value๊ฐ ์์ผ๋ฉด:
-
property๋ฅผ propertyOrConditionText๋ก ๋๋ค.
-
โฆ
-
-
์์ผ๋ฉด:
-
conditionText๋ฅผ propertyOrConditionText๋ก ๋๋ค.
-
โฆ
-
๋ ์ค๋ฒ๋ก๋๊ฐ ๊ณตํต๋ถ๋ชจ๊ฐ ๊ฑฐ์ ์๋ค๋ฉด, ์ค๋ฒ๋ก๋ ๊ฒฐ์ ์ IDL์ ๋งก๊ธฐ๋ ๊ฒ์ด ๋ ๋ซ์ต๋๋ค.
-
-
์ฌ๋ฌ ์ธ์์ ๋ํด ํ์ ์กฐํฉ์ด ์์ ๋ก์ด ๊ฒฝ์ฐ์๋ ์ ๋์จ ํ์ ์ด ์ ์ผํ ํด๊ฒฐ์ฑ ์ผ ์ ์์ต๋๋ค.
typedef (long long or DOMString or CalculatableInterface )SupportedArgument ;interface A {undefined add (SupportedArgument operand1 ,SupportedArgument operand2 ); };์
add()์ฐ์ฐ์ ์ค๋ฒ๋ก๋ฉ์ผ๋ก ๋ช ์ธํ๋ ค๋ฉด,interface A {undefined add (long long operand1 ,long long operand2 );undefined add (long long operand1 ,DOMString operand2 );undefined add (long long operand1 ,CalculatableInterface operand2 );undefined add (DOMString operand1 ,long long operand2 );undefined add (DOMString operand1 ,DOMString operand2 );undefined add (DOMString operand1 ,CalculatableInterface operand2 );undefined add (CalculatableInterface operand1 ,long long operand2 );undefined add (CalculatableInterface operand1 ,DOMString operand2 );undefined add (CalculatableInterface operand1 ,CalculatableInterface operand2 ); };๊ทธ๋ฆฌ๊ณ 9๋ฐฐ์ ํ๋ก์ฆ๊ฐ ํ์ํฉ๋๋ค!
-
๋ช ์ธ ์์ฑ์๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ์ธ์๊ฐ ์์ ๋์
undefined ๋ฅผ ๋๊ธธ ๋๋ฅผ ๋์ผํ๊ฒ ์ฒ๋ฆฌํ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.์๋์ ๊ฐ์ IDL ํ๋๊ทธ๋จผํธ๊ฐ ์๋ค๊ณ ํ ๋:
interface A {undefined foo ();undefined foo (Node ?arg ); };์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋
foo(undefined)์foo(null)๋ชจ๋foo(arg)์ฐ์ฐ์ ๋จ๊ณ๊ฐ ์คํ๋๊ณ , arg๋ null์ด ๋๋ค.foo()๋ง ํธ์ถํ๋ฉด ์ฒซ ๋ฒ์งธ ์ค๋ฒ๋ก๋๊ฐ ์ ํ๋๋ค. ์ด๋ ๋ง์ API ์ฌ์ฉ์์๊ฒ ์ง๊ด์ ์ด์ง ์์ ์ ์๋ค. ๋์ ๋ช ์ธ ์์ฑ์๋ ์ต์ ์ธ์๋ฅผ ์ฌ์ฉํ์ฌ,foo()์foo(undefined)๋ชจ๋ "arg๊ฐ ๋๋ฝ๋จ"์ผ๋ก ๋ถ๋ฅ๋๋๋ก ํ ๊ฒ์ ๊ถ์ฅํ๋ค.interface A {undefined foo (optional Node ?arg ); };์ผ๋ฐ์ ์ผ๋ก ์ต์ ์
optional ํค์๋๋ก ํํํ๋ ๊ฒ์ด, ์ค๋ฒ๋ก๋ฉ๋ณด๋ค ๋ ์ ํฉํ๋ค.
์ ๊ฒฝ์ฐ์ ํด๋นํ์ง ์์ผ๋ฉด ๋ช ์ธ ์์ฑ์๊ฐ ์คํ์ผ์ ์ ํํ๋ฉด ๋ฉ๋๋ค. ๋ ์ค ์ด๋ ์ชฝ๋ ์๋ํ ๋์์ ์ถฉ๋ถํ ํํํ ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค. ๋จ, ๋ณํ ์๊ณ ๋ฆฌ์ฆ ๋ฐ ์ ๋์จ ํ์ , ์ต์ ์ธ์์ ์ ์๊ฐ ์ค๋ฒ๋ก๋ฉ ๊ฒฐ์ ์๊ณ ๋ฆฌ์ฆ๋ณด๋ค ๊ตฌํ๊ณผ ์ดํด๊ฐ ์ฝ๊ณ , ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์ ๋ ์ ํฉํ API๋ฅผ ๋ง๋๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค. ํน๋ณํ ์ด์ ๊ฐ ์๋ค๋ฉด ์ ๋์จ ํ์ , ์ต์ ์ธ์๋ฅผ ๊ธฐ๋ณธ ์ ํ์ผ๋ก ์ผ๊ธธ ๊ถ์ฅํ๋ค.
๋ช ์ธ๋ ํ์ํ๋ค๋ฉด ์ ๋์จ ํ์ ๊ณผ ์ค๋ฒ๋ก๋ฉ์ ํผํฉํด ์ฌ์ฉํ ์๋ ์๋ค.
2.5.9. ์ดํฐ๋ฌ๋ธ ์ ์ธ
์ธํฐํ์ด์ค๋ ์ดํฐ๋ฌ๋ธ๋ก ์ ์ธ๋ ์ ์์ผ๋ฉฐ,
์ด๋ ์ธํฐํ์ด์ค ๋ณธ๋ฌธ์ ์ดํฐ๋ฌ๋ธ
์ ์ธ(
interface interface_identifier {iterable <value_type >;iterable <key_type ,value_type >; };
์ธํฐํ์ด์ค๋ฅผ ์ดํฐ๋ฌ๋ธ๋ก ๊ตฌํํ ๊ฐ์ฒด๋ ๊ฐ์ ์ํ์ค๋ก ์ป์ ์ ์๋๋ก ๋ฐ๋ณต(iterate)ํ ์ ์๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ ์ดํฐ๋ฌ๋ธ ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์
entries, forEach,
keys, values, %Symbol.iterator%
ํ๋กํผํฐ๊ฐ ์๋ค.
ํ์ ํ๋ผ๋ฏธํฐ๊ฐ ํ๋๋ฉด ๊ฐ ์ดํฐ๋ ์ดํฐ์ด๋ฉฐ, ํด๋น ํ์ ์ ๊ฐ์ ์ ๊ณตํ๋ค. ํ์ ํ๋ผ๋ฏธํฐ๊ฐ ๋์ด๋ฉด ์ ์ดํฐ๋ ์ดํฐ์ด๋ฉฐ, ๊ฐ ์์ ์ ๊ณตํ๋ค.
๊ฐ ์์ ํค ํ์ ๊ณผ ๊ฐ ํ์ ์ด ์ฃผ์ด์ก์ ๋ ๋ ๊ฐ์ ๊ตฌ์กฐ์ฒด ์์ดํ ์ผ๋ก ์ด๋ฃจ์ด์ง๋ค:
-
์์ดํ ์ ์ด๋ฆ์ด "key"์ด๊ณ , ๊ฐ ์์ ํค๋ผ ํ๋ฉฐ, ๊ฐ์ ํค ํ์ ์ IDL ๊ฐ์ด๋ค;
-
์์ดํ ์ ์ด๋ฆ์ด "value"์ด๊ณ , ๊ฐ ์์ ๊ฐ์ด๋ผ ํ๋ฉฐ, ๊ฐ์ ๊ฐ ํ์ ์ IDL ๊ฐ์ด๋ค.
๊ฐ ์ดํฐ๋ ์ดํฐ๋ ๋ฐ๋์ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค์๋ง ์ ์ธ๋ ์ ์๋ค. ๊ฐ ์ดํฐ๋ ์ดํฐ์ value-type์ ์ธ๋ฑ์ค ํ๋กํผํฐ getter๊ฐ ๋ฐํํ๋ ํ์ ๊ณผ ๊ฐ์์ผ ํ๋ค. ๊ฐ ์ดํฐ๋ ์ดํฐ๋ ํด๋น ๊ฐ์ฒด์ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ๋ฐ๋ณต(iterate)ํ๋ ๊ฒ์ผ๋ก ์๋ฌต์ ์ผ๋ก ์ ์๋๋ค.
์ ์ดํฐ๋ ์ดํฐ๋ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค์ ์ ์ธ๋ ์ ์๋ค.
ํ์ด ๋ฐ๋ณต์๊ฐ ์๋ ์ธํฐํ์ด์ค์ ๋ํ ์ค๋ช ์ ๊ฐ ์ธํฐํ์ด์ค ์ธ์คํด์ค๋ง๋ค ๋ฆฌ์คํธ๋ฅผ ๊ฐ ์์ ํํ๋ก ์ ์ํด์ผ ํ๋ฉฐ, ์ด ๋ฆฌ์คํธ๋ ๋ฐ๋ณตํ ๊ฐ ์์ ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ์์ ๊ฐ ์ดํฐ๋ ์ดํฐ์ forEach ๋ฉ์๋๋ Array.prototype.forEach์ฒ๋ผ ์ฝ๋ฐฑ์ ํธ์ถํ๊ณ , ์ ์ดํฐ๋ ์ดํฐ์ forEach๋ Map.prototype.forEach์ฒ๋ผ ํธ์ถํ๋ค.
๊ฐ ์ดํฐ๋ ์ดํฐ๋ ํ์ฌ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค์๋ง ํ์ฉ๋๋ฏ๋ก Array ์คํ์ผ forEach๊ฐ ์ ํฉํ๋ค. ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ์ง ์๋ ์ธํฐํ์ด์ค๋, Set.prototype.forEach์ฒ๋ผ key์ value๊ฐ ๊ฐ์ forEach๊ฐ ํ์ํ ๊ฐ์ ๋ฐ๋ณตํ๋ ์ดํฐ๋ ์ดํฐ๊ฐ ํ์ํ๋ค๋ฉด, ์ด์๋ฅผ ๋ฑ๋กํด ์ฃผ์ธ์.
์ฐธ๊ณ : ์ด๋ array
์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด ๋์ ๋ฐฉ์์ด๋ค.
์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ธํฐํ์ด์ค์ ๊ฒฝ์ฐ, entries,
keys, values, %Symbol.iterator%
๊ฐ ๋ฐํํ๋ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ ์ค์ array ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด์ด๋ค.
์ดํฐ๋ฌ๋ธ ์ ์ธ์ด
์๋ ์ธํฐํ์ด์ค์๋
"entries", "forEach", "keys", "values"๋ผ๋ ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ฉฐ,
์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ์ด ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ค.
๋ค์ SessionManager ์ธํฐํ์ด์ค๋ username์ ํค๋ก Session ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ ์
์๋ค:
[Exposed =Window ]interface SessionManager {Session getSessionForUser (DOMString username );iterable <DOMString ,Session >; }; [Exposed =Window ]interface Session {readonly attribute DOMString username ; // ... };
์ดํฐ๋ ์ดํฐ์ ๋์์ ์๋์ฒ๋ผ ์ ์๋ ์ ์๋ค:
๋ฐ๋ณตํ ๊ฐ ์์ username์ key, ํด๋น username์ ๋์ํ๋
SessionManager๊ฐ์ฒด์ ์ด๋ฆฐSession๊ฐ์ฒด๋ฅผ value๋ก ํ์ฌ, username ๊ธฐ์ค์ผ๋ก ์ ๋ ฌ๋ ๊ฐ ์ ๋ฆฌ์คํธ์ด๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ SessionManager ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ values ๋ฉ์๋๊ฐ ์๊ณ ,
์ด ํจ์๋ ํธ์ถ ์ ๋ค์ ๊ฐ์ ๋ฐํํ๋ next ๋ฉ์๋๋ฅผ ๊ฐ์ง ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ค. keys์ entries
๋ฉ์๋๋ ๊ฐ๊ฐ session ๊ฐ์ฒด์ username, username/Session ๊ฐ์ฒด ์์ ๋ฐ๋ณตํ๋ค. %Symbol.iterator%
๋ฉ์๋๋ ์์ด์ SessionManager๋ฅผ for..of ๋ฃจํ์์ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ,
entries์ ๊ฐ์ ๊ฐ์ ๋ฐ๋ณตํ๋ค:
// SessionManager ์ธ์คํด์ค๋ฅผ ์ป๋๋ค. // ์๋ฅผ ๋ค์ด "anna", "brian" ์ ์ ์ธ์ ์ด ์๋ค๊ณ ๊ฐ์ . var sm= getSessionManager(); typeof SessionManager. prototype. values; // "function" ๋ฐํ var it= sm. values(); // values()๋ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด ๋ฐํ String( it); // "[object SessionManager Iterator]" ๋ฐํ typeof it. next; // "function" ๋ฐํ // ์๋ ๋ฃจํ๋ "anna", "brian"์ ๋ก๊ทธํ๋ค. for (;;) { let result= it. next(); if ( result. done) { break ; } let session= result. value; console. log( session. username); } // ์ด๊ฒ๋ "anna", "brian"์ ๋ก๊ทธํ๋ค. for ( let usernameof sm. keys()) { console. log( username); } // ์๋๋ ๋์ผํ๋ค. for ( let [ username, session] of sm) { console. log( username); }
์ธํฐํ์ด์ค์๋ ํ๋์ ์ดํฐ๋ฌ๋ธ ์ ์ธ๋ง ์กด์ฌํด์ผ ํ๋ค. ์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์์ผ๋ฉด ์ ๋๋ค. ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ ์ธํฐํ์ด์ค์ ๊ทธ ์์ ์ธํฐํ์ด์ค์๋ maplike ์ ์ธ, setlike ์ ์ธ, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์์ด์๋ ์ ๋๋ค.
์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ ์ฉ ๊ฐ๋ฅํ ํ์ฅ ์์ฑ:
[CrossOriginIsolated],
[Exposed], [SecureContext].
Iterable ::iterable < TypeWithExtendedAttributes OptionalType > ;
OptionalType ::, TypeWithExtendedAttributes ฮต
2.5.10. ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ
์ธํฐํ์ด์ค๋
๋น๋๊ธฐ ๋ฐ๋ณต
์ ์ธ
(
interface interface_identifier {async_iterable <value_type >;async_iterable <value_type >(/* arguments... */);async_iterable <key_type ,value_type >;async_iterable <key_type ,value_type >(/* arguments... */); };
๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ๋ก ์ ์ธ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ ๊ฐ์ ๋น๋๊ธฐ๋ก ๋ฐ๋ณต(iterate)ํด์ ์ป์ ์ ์๋ค.
ํ์ ํ๋ผ๋ฏธํฐ๊ฐ ํ๋๋ฉด ๊ฐ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด๋ฉฐ, ํด๋น ํ์ ์ ๊ฐ์ ๋น๋๊ธฐ๋ก ์ ๊ณตํ๋ค. ๋ ๊ฐ๋ฉด ์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด๋ฉฐ, ๊ฐ ์์ ๋น๋๊ธฐ๋ก ์ ๊ณตํ๋ค.
์ธ์๊ฐ ์๋ค๋ฉด, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ธ์(
%Symbol.asyncIterator%
์ values ํ๋กํผํฐ๊ฐ ์๋ค.
์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด๋ฉด entries, keys ํ๋กํผํฐ๋ ์๋ค.
์ด ๋ชจ๋ ๋ฉ์๋๋ ์ต์
์ธ์๋ฅผ ๋ฐ์ ์ ์์ผ๋ฉฐ, ์ ๋ฌ๋ ์ธ์๋ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ธ์ ๋ฆฌ์คํธ์ ๋์ํ๋ฉฐ,
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ์ด๊ธฐํ ๋จ๊ณ์์ ์ฒ๋ฆฌ๋๋ค.
์ด ์๊ตฌ์กฐ๊ฑด ๋๋ถ์ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ for-await-of๊ฐ ์ธํฐํ์ด์ค ์ธ์คํด์ค์ ๋ฐ๋ก ์ธ ์ ์๋ค.
for-await-of๋ %Symbol.asyncIterator%๋ฅผ
์ธ์ ์์ด ํธ์ถํ๊ธฐ ๋๋ฌธ์ด๋ค.
๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ ์ธํฐํ์ด์ค์ ํ๋ก์ฆ์๋
๋ค์ ๋ฐ๋ณต ๊ฒฐ๊ณผ
์ป๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ํด์ผ ํ๋ค.
์ด ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ณต ์ค์ธ ์ธํฐํ์ด์ค ์ธ์คํด์ค์ ๋น๋๊ธฐ
์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ฅผ ๋ฐ์ผ๋ฉฐ(์ํ ์ ์ฅ์ ์ ์ฉ),
Promise๋ฅผ
๋ฐํํด์ผ ํ๋ค. ์ด Promise๋ reject๋๊ฑฐ๋, ๋ฐ๋ณต ์ข
๋ฃ ์ ํธ๋ฅผ ๋ํ๋ด๋ ๋ฐ๋ณต ์ข
๋ฃ ๊ฐ์ resolveํ๊ฑฐ๋, ์๋ ์ค ํ๋๋ฅผ resolveํ๋ค:
- ๊ฐ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ๊ฒฝ์ฐ:
-
์ ์ธ๋ ํ์ ์ ๊ฐ
- ์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ๊ฒฝ์ฐ:
-
์ ์ธ๋ ๋ ํ์ ์ ๊ฐ์ ํฌํจํ๋ ํํ
๋ํ ํ๋ก์ฆ์์ ๋น๋๊ธฐ
์ดํฐ๋ ์ดํฐ ๋ฐํ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ํ ์ ์๋ค. ์ด ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ณต ์ค์ธ ์ธํฐํ์ด์ค ์ธ์คํด์ค, ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด, any ํ์
์ ์ธ์ ํ๋๋ฅผ ๋ฐ๋๋ค.
์ด๋ ์ดํฐ๋ ์ดํฐ๊ฐ ์ค๋จ๋ ๋ ํธ์ถ๋๋ฉฐ, Promise๋ฅผ
๋ฐํํด์ผ ํ๋ฉฐ, fulfill๋๋ฉด ๊ฐ์ ๋ฌด์๋๊ณ , reject๋๋ฉด ์๋ฌ๊ฐ ์ฌ์ฉ์์๊ฒ ์ ๋ฌ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ ์ด ์๊ณ ๋ฆฌ์ฆ์ ํตํด async iterator์ return()์ด ํธ์ถ๋ ๋ ๋์์ ์ปค์คํฐ๋ง์ด์ฆํ ์
์๋ค. ์ด๋ break๋ return์ผ๋ก for-await-of ๋ฃจํ๋ฅผ
๋น ์ ธ๋๊ฐ ๋ ๊ฐ์ฅ ํํ ๋ฐ์ํ๋ค.
throw()์ ๋ํ ์ ์ฌํ hook๋ ์ถ๊ฐํ ์ ์๋ค. ํ์ฌ๊น์ง ํ์๊ฐ ์์์ง๋ง, ๊ทธ๋ฐ API๊ฐ ํ์ํ๋ค๋ฉด ์ด์๋ฅผ ๋ฑ๋กํด ์ฃผ์ธ์.
๋ํ ํ๋ก์ฆ์์ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ์ด๊ธฐํ ๋จ๊ณ๋ ์ ์ํ ์ ์๋ค. ์ด๋ ๋ฐ๋ณต ์ค์ธ ์ธํฐํ์ด์ค ์ธ์คํด์ค, ์๋ก ์์ฑ๋ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด, ์ ๋ฌ๋ ์ธ์๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ ๋ฆฌ์คํธ๋ฅผ ๋ฐ๋๋ค.
๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ ์ธํฐํ์ด์ค์๋
"entries", "keys", "values"๋ผ๋ ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ฉฐ,
์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ์ด ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ค.
๋ค์ SessionManager ์ธํฐํ์ด์ค๋ username์ ํค๋ก Session ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ ์
์๋ค:
[Exposed =Window ]interface SessionManager {Session getSessionForUser (DOMString username );async_iterable <DOMString ,Session >; }; [Exposed =Window ]interface Session {readonly attribute DOMString username ; // ... };
์ดํฐ๋ ์ดํฐ์ ๋์์ ์๋์ฒ๋ผ ์ ์๋ ์ ์๋ค:
SessionManager๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ iterator์ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ์ด๊ธฐํ ๋จ๊ณ:
iterator์ ํ์ฌ ์ํ๋ฅผ "์์ง ์์ํ์ง ์์"์ผ๋ก ์ค์ ํ๋ค.
SessionManager manager์ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ iterator์ ๋ํด ๋ค์ ๋ฐ๋ณต ๊ฒฐ๊ณผ ์ป๊ธฐ:
promise๋ฅผ ์ Promise๋ก ๋๋ค.
key๋ฅผ ๋ค์ ๊ฐ์ผ๋ก ๋๋ค(์์ผ๋ฉด null):
- ๋ง์ฝ iterator์ ํ์ฌ ์ํ๊ฐ "์์ง ์์ํ์ง ์์"์ด๋ผ๋ฉด
manager์ ์ด๋ฆฐ ์ธ์ ์ค username์ด ๊ฐ์ฅ ์์ ๊ฐ(์ฌ์ ์)
- ๊ทธ ์ธ
manager์ ์ด๋ฆฐ ์ธ์ ์ค iterator์ ํ์ฌ ์ํ๋ณด๋ค ํฐ username ์ค ๊ฐ์ฅ ์์ ๊ฐ(์ฌ์ ์)
์ฐธ๊ณ : iterator์ ํ์ฌ ์ํ๊ฐ ์ด๋ฏธ ์ด๋ฆฐ ์ธ์ ์ ์์ ์๋ ์๋ค.
key๊ฐ null์ด๋ฉด:
promise๋ฅผ ๋ฐ๋ณต ์ข ๋ฃ๋ก resolveํ๋ค.
๊ทธ ์ธ:
session์ key์ ๋์ํ๋
Session๊ฐ์ฒด๋ก ๋๋ค.promise๋ฅผ (username, session)๋ก resolveํ๋ค.
iterator์ ํ์ฌ ์ํ๋ฅผ username์ผ๋ก ์ค์ ํ๋ค.
promise๋ฅผ ๋ฐํํ๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ SessionManager ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ values ๋ฉ์๋๊ฐ ์๊ณ ,
์ด ํจ์๋ ํธ์ถ ์ ๋ค์ ๊ฐ์ ๋ฐํํ๋ next ๋ฉ์๋๋ฅผ ๊ฐ์ง ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ค. keys์
entries ๋ฉ์๋๋ ๊ฐ๊ฐ session ๊ฐ์ฒด์ username, username/Session ๊ฐ์ฒด ์์ ๋ฐ๋ณตํ๋ค.
%Symbol.asyncIterator%
๋ฉ์๋๋ ์์ด์ SessionManager๋ฅผ for await..of ๋ฃจํ์์ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ,
entries์ ๊ฐ์ ๊ฐ์ ๋ฐ๋ณตํ๋ค:
// SessionManager ์ธ์คํด์ค๋ฅผ ์ป๋๋ค. // ์๋ฅผ ๋ค์ด "anna", "brian" ์ ์ ์ธ์ ์ด ์๋ค๊ณ ๊ฐ์ . var sm= getSessionManager(); typeof SessionManager. prototype. values; // "function" ๋ฐํ var it= sm. values(); // values()๋ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด ๋ฐํ typeof it. next; // "function" ๋ฐํ // ์๋ ๋ฃจํ๋ "anna", "brian"์ ๋ก๊ทธํ๋ค. for await ( let usernameof sm. keys()) { console. log( username); } // ์ด๊ฒ๋ ๋์ผํ๋ค. for await ( let [ username, session] of sm) { console. log( username); }
์ธํฐํ์ด์ค์๋ ํ๋์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ๋ง ์กด์ฌํด์ผ ํ๋ค. ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ ์ธํฐํ์ด์ค์ ์์ ์ธํฐํ์ด์ค์๋ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์์ผ๋ฉด ์ ๋๋ค. ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ ์ธํฐํ์ด์ค์ ๊ทธ ์์ ์ธํฐํ์ด์ค์๋ maplike ์ ์ธ, setlike ์ ์ธ, ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์์ด์๋ ์ ๋๋ค.
๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ ์ฉ ๊ฐ๋ฅํ ํ์ฅ ์์ฑ:
[CrossOriginIsolated],
[Exposed],
[SecureContext].
์ด ํ์ฅ ์์ฑ๋ค์ ํ์ฌ๋ ์ ์ฉ๋์ง ์์ผ๋ฉฐ, ์ถํ ์ ์ฉ๋๋ฉด ์์๋๋ก ๋์ํ ๊ฒ์ด๋ค.
AsyncIterable ::async_iterable < TypeWithExtendedAttributes OptionalType > OptionalArgumentList ;
OptionalArgumentList ::( ArgumentList ) ฮต
2.5.11. Maplike ์ ์ธ
์ธํฐํ์ด์ค๋ maplike๋ก ์ ์ธ๋ ์ ์์ผ๋ฉฐ,
์ด๋ ์ธํฐํ์ด์ค ๋ณธ๋ฌธ์ maplike ์ ์ธ
(
interface interface_identifier {readonly maplike <key_type ,value_type >;maplike <key_type ,value_type >; };
maplike๋ก ์ ์ธ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋, ์ฒ์์๋ ๋น์ด ์๊ณ , ํคโ๊ฐ ์์ ์์ ์๋ map์ ๋ํ๋ด๋ฉฐ, ์ด๋ฅผ ํด๋น ๊ฐ์ฒด์ map ์ํธ๋ฆฌ๋ผ๊ณ ํ๋ค. ํค์ ๊ฐ์ ํ์ ์ maplike ์ ์ธ์ ๊บพ์ ๊ดํธ์ ์ง์ ๋๋ค. ํค๋ ๋ฐ๋์ ๊ณ ์ ํด์ผ ํ๋ค.
๋ช ์ธ ์์ฑ์๋ map ์ํธ๋ฆฌ์ ๋ด์ฉ์ ์์ ํ ์ ์์ผ๋ฉฐ, ์ด๋ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋์์ ๊ฐ์ฒด์ ๋ด์ฉ์ ์๋์ผ๋ก ๋ฐ์๋๋ค.
maplike ์ธํฐํ์ด์ค๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ ์ ์ ํ map ์ํธ๋ฆฌ ์ง์ API๋ฅผ ์ง์ํ๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ map ์ํธ๋ฆฌ์ ์ํธ์์ฉํ๋ API๋ ์๋ฐ์คํฌ๋ฆฝํธ
Map
๊ฐ์ฒด์ ์ ์ฌํ๋ค. entries,
forEach, get,
has, keys,
values, %Symbol.iterator%
๋ฉ์๋, ๊ทธ๋ฆฌ๊ณ size getter๋ฅผ ํฌํจํ๋ค.
์ฝ๊ธฐโ์ฐ๊ธฐ maplike์ผ ๊ฒฝ์ฐ, clear,
delete, set ๋ฉ์๋๋ ํฌํจํ๋ค.
maplike ์ธํฐํ์ด์ค์๋ "entries", "forEach", "get", "has",
"keys", "size", "values" ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ฉฐ,
์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ์ด ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ค.
์ฝ๊ธฐโ์ฐ๊ธฐ maplike ์ธํฐํ์ด์ค์๋ "clear", "delete", "set" ์ด๋ฆ์ ์์ฑ
๋๋ ์์๊ฐ ์กด์ฌํด์๋ ์ ๋๋ฉฐ,
์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ํด๋น ์ด๋ฆ์ ์์ฑ์ด๋ ์์๊ฐ ์์ด์๋ ์ ๋๋ค.
์ฐธ๊ณ : ์ฝ๊ธฐโ์ฐ๊ธฐ maplike ์ธํฐํ์ด์ค๋ ์ผ๋ฐ ์ฐ์ฐ์ผ๋ก
"clear", "delete", "set" ์ด๋ฆ์ ๊ฐ์ง ์ ์์ผ๋ฉฐ, ์ด๋ ํด๋น ๋ฉ์๋์ ๊ธฐ๋ณธ ๊ตฌํ์ ๋ฎ์ด์ด๋ค(ยงโฏ3.7.11 Maplike ์ ์ธ ์ฐธ์กฐ). ์ด๋ฐ ์ฐ์ฐ์ด ์ ์๋๋ฉด, ๊ฐ ๋ฉ์๋์ ๊ธฐ๋ณธ ๊ตฌํ์ ๋ช
์๋ ์
๋ ฅ/์ถ๋ ฅ ๊ธฐ๋์น์ ์ผ์นํด์ผ ํ๋ค.
์ธํฐํ์ด์ค์๋ ํ๋์ maplike ์ ์ธ๋ง ์กด์ฌํด์ผ ํ๋ค. maplike ์ธํฐํ์ด์ค์ ์์ ์ธํฐํ์ด์ค์๋ maplike ์ ์ธ์ด ์์ผ๋ฉด ์ ๋๋ค. maplike ์ธํฐํ์ด์ค์ ์์ ์ธํฐํ์ด์ค์๋ ์ดํฐ๋ฌ๋ธ ์ ์ธ, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ, setlike ์ ์ธ, ์ธ๋ฑ์ค ํ๋กํผํฐ getter๊ฐ ์์ด์๋ ์ ๋๋ค.
ReadOnlyMember ::readonly ReadOnlyMemberRest
ReadWriteMaplike ::MaplikeRest
MaplikeRest ::maplike < TypeWithExtendedAttributes , TypeWithExtendedAttributes > ;
์ด ๋ช ์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ์ maplike ์ ์ธ์ ์ ์ฉ๋์ง ์๋๋ค.
์์ ์ถ๊ฐ ํ์.
2.5.12. Setlike ์ ์ธ
์ธํฐํ์ด์ค๋ setlike๋ก ์ ์ธ๋ ์ ์์ผ๋ฉฐ,
์ด๋ ์ธํฐํ์ด์ค ๋ณธ๋ฌธ์ setlike ์ ์ธ
(
interface interface_identifier {readonly setlike <type >;setlike <type >; };
setlike๋ก ์ ์ธ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋, ์ฒ์์๋ ๋น์ด ์๊ณ , ๊ฐ์ ์์ ์๋ ์งํฉ์ ๋ํ๋ด๋ฉฐ, ์ด๋ฅผ ํด๋น ๊ฐ์ฒด์ set ์ํธ๋ฆฌ๋ผ๊ณ ํ๋ค. ๊ฐ์ ํ์ ์ setlike ์ ์ธ์ ๊บพ์ ๊ดํธ์ ์ง์ ๋๋ค. ๊ฐ์ ๋ฐ๋์ ๊ณ ์ ํด์ผ ํ๋ค.
๋ช ์ธ ์์ฑ์๋ set ์ํธ๋ฆฌ์ ๋ด์ฉ์ ์์ ํ ์ ์์ผ๋ฉฐ, ์ด๋ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋์์ ๊ฐ์ฒด์ ๋ด์ฉ์ ์๋์ผ๋ก ๋ฐ์๋๋ค.
setlike ์ธํฐํ์ด์ค๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ ์ ์ ํ set ์ํธ๋ฆฌ ์ง์ API๋ฅผ ์ง์ํ๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ set ์ํธ๋ฆฌ์ ์ํธ์์ฉํ๋ API๋ ์๋ฐ์คํฌ๋ฆฝํธ
Set
๊ฐ์ฒด์ ์ ์ฌํ๋ค. entries,
forEach, has,
keys, values,
%Symbol.iterator%
๋ฉ์๋, ๊ทธ๋ฆฌ๊ณ size getter๋ฅผ ํฌํจํ๋ค.
์ฝ๊ธฐโ์ฐ๊ธฐ setlike์ผ ๊ฒฝ์ฐ, add,
clear, delete ๋ฉ์๋๋ ํฌํจํ๋ค.
setlike ์ธํฐํ์ด์ค์๋ "entries", "forEach", "has", "keys",
"size", "values" ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ฉฐ,
์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ์ด ์ด๋ฆ์ ์์ฑ, ์์, ์ผ๋ฐ ์ฐ์ฐ์ด ์กด์ฌํด์๋ ์ ๋๋ค.
์ฝ๊ธฐโ์ฐ๊ธฐ setlike ์ธํฐํ์ด์ค์๋ "add", "clear", "delete" ์ด๋ฆ์ ์์ฑ
๋๋ ์์๊ฐ ์กด์ฌํด์๋ ์ ๋๋ฉฐ,
์์๋ฐ์ ์ธํฐํ์ด์ค์๋ ํด๋น ์ด๋ฆ์ ์์ฑ์ด๋ ์์๊ฐ ์์ด์๋ ์ ๋๋ค.
์ฐธ๊ณ : ์ฝ๊ธฐโ์ฐ๊ธฐ setlike ์ธํฐํ์ด์ค๋ ์ผ๋ฐ ์ฐ์ฐ์ผ๋ก
"add", "clear", "delete" ์ด๋ฆ์ ๊ฐ์ง ์ ์์ผ๋ฉฐ, ์ด๋ ํด๋น ๋ฉ์๋์ ๊ธฐ๋ณธ ๊ตฌํ์ ๋ฎ์ด์ด๋ค(ยงโฏ3.7.12 Setlike ์ ์ธ ์ฐธ์กฐ). ์ด๋ฐ ์ฐ์ฐ์ด ์ ์๋๋ฉด, ๊ฐ ๋ฉ์๋์ ๊ธฐ๋ณธ ๊ตฌํ์ ๋ช
์๋ ์
๋ ฅ/์ถ๋ ฅ ๊ธฐ๋์น์ ์ผ์นํด์ผ ํ๋ค.
์ธํฐํ์ด์ค์๋ ํ๋์ setlike ์ ์ธ๋ง ์กด์ฌํด์ผ ํ๋ค. setlike ์ธํฐํ์ด์ค์ ์์ ์ธํฐํ์ด์ค์๋ setlike ์ ์ธ์ด ์์ผ๋ฉด ์ ๋๋ค. setlike ์ธํฐํ์ด์ค์ ์์ ์ธํฐํ์ด์ค์๋ ์ดํฐ๋ฌ๋ธ ์ ์ธ, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ, maplike ์ ์ธ, ์ธ๋ฑ์ค ํ๋กํผํฐ getter๊ฐ ์์ด์๋ ์ ๋๋ค.
ReadOnlyMember ::readonly ReadOnlyMemberRest
ReadWriteSetlike ::SetlikeRest
SetlikeRest ::setlike < TypeWithExtendedAttributes > ;
์ด ๋ช ์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ์ setlike ์ ์ธ์ ์ ์ฉ๋์ง ์๋๋ค.
์์ ์ถ๊ฐ ํ์.
2.6. ๋ค์์คํ์ด์ค
๋ค์์คํ์ด์ค๋, ์ ์ญ ์ฑ๊ธํด๊ณผ
๊ด๋ จ ๋์์ ์ ์ธํ๋ ์ ์(
namespace identifier { /* namespace_members... */ };
๋ค์์คํ์ด์ค๋
๋ค์์คํ์ด์ค ๋ฉค๋ฒ๋ค์ ๋ช
์ธ(
์ธํฐํ์ด์ค์ ๋ง์ฐฌ๊ฐ์ง๋ก, ๋ค์์คํ์ด์ค์ IDL๋
๋ถ๋ถ ๋ค์์คํ์ด์ค
์ ์(
namespace SomeNamespace { /* namespace_members... */ };partial namespace SomeNamespace { /* namespace_members... */ };
์ฐธ๊ณ : ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์์ฒ๋ผ, ๋ถ๋ถ ๋ค์์คํ์ด์ค ์ ์๋ ๋ช ์ธ ํธ์ง์ ๋๊ธฐ ์ํ ๊ฒ์ผ๋ก, ๋ค์์คํ์ด์ค ์ ์๋ฅผ ๋ฌธ์์ ์ฌ๋ฌ ์น์ ๋๋ ์ฌ๋ฌ ๋ฌธ์์ ๊ฑธ์ณ ๋ถ๋ฆฌํด ๊ธฐ์ ํ ์ ์๊ฒ ํด์ค๋๋ค.
๋ฉค๋ฒ๊ฐ ๋ฑ์ฅํ๋ ์์๋ JavaScript ๋ฐ์ธ๋ฉ์์ ํ๋กํผํฐ ์ด๊ฑฐ์ ์ํฅ์ ๋ฏธ์นฉ๋๋ค.
์ธํฐํ์ด์ค๋ ๋์ ๋๋ฆฌ์ ๋ค๋ฅด๊ฒ, ๋ค์์คํ์ด์ค๋ ํ์ ์ ์์ฑํ์ง ์์ต๋๋ค.
์ด ๋ช
์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ ์ค, [CrossOriginIsolated],
[Exposed],
[SecureContext]๋ง
๋ค์์คํ์ด์ค์ ์ ์ฉํ ์ ์์ต๋๋ค.
๋ค์์คํ์ด์ค๋ ๋ฐ๋์ [Exposed] ํ์ฅ ์์ฑ์ผ๋ก
์ด๋
ธํ
์ดํธํด์ผ ํฉ๋๋ค.
Partial ::partial PartialDefinition
Namespace ::namespace identifier { NamespaceMembers } ;
NamespaceMembers ::ExtendedAttributeList NamespaceMember NamespaceMembers ฮต
NamespaceMember ::RegularOperation readonly AttributeRest Const
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ๋ค์์คํ์ด์ค๋ฅผ ์ ์ํฉ๋๋ค.
namespace VectorUtils {readonly attribute Vector unit ;double dotProduct (Vector x ,Vector y );Vector crossProduct (Vector x ,Vector y ); };
์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋ ์ ์ญ VectorUtils ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋
ธ์ถ๋๋ฉฐ, ์ด๋ ๋จ์ ๊ฐ์ฒด(ํ๋กํ ํ์
์ %Object.prototype%)
์ด๊ณ , ์ ์ธ๋ ์ฐ์ฐ๋ง๋ค ์ด๊ฑฐ ๊ฐ๋ฅํ ๋ฐ์ดํฐ ํ๋กํผํฐ, ์ ์ธ๋ ์์ฑ๋ง๋ค ์ด๊ฑฐ ๊ฐ๋ฅํ ์ฝ๊ธฐ ์ ์ฉ ์ ๊ทผ์๋ฅผ ๊ฐ์ง๋๋ค:
Object. getPrototypeOf( VectorUtils); // Object.prototype ๋ฐํ Object. keys( VectorUtils); // ["dotProduct", "crossProduct"] ๋ฐํ Object. getOwnPropertyDescriptor( VectorUtils, "dotProduct" ); // { value: <a function>, enumerable: true, configurable: true, writable: true } ๋ฐํ Object. getOwnPropertyDescriptor( VectorUtils, "unit" ); // { get: <a function>, enumerable: true, configurable: true } ๋ฐํ
2.7. ๋์ ๋๋ฆฌ
๋์
๋๋ฆฌ๋,
dictionary identifier { /* dictionary_members... */ };
๋์ ๋๋ฆฌ ์ธ์คํด์ค๋ ์ธ์ด๋ณ ํํ(์: ํด๋นํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด)์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ ์งํ์ง ์๋๋ค. ์๋ฅผ ๋ค์ด, ๋์ ๋๋ฆฌ๋ฅผ ์ฐ์ฐ์์ ๋ฐํํ๋ฉด, ํ์ฌ ๋์ ๋๋ฆฌ ๊ฐ์ผ๋ก๋ถํฐ ์๋ก์ด ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๊ฐ ์์ฑ๋๋ค. ๋ฐ๋๋ก ์ฐ์ฐ์์ ๋์ ๋๋ฆฌ๋ฅผ ์ธ์๋ก ๋ฐ์ ๊ฒฝ์ฐ, ์ ๋ฌ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก๋ถํฐ ๋์ ๋๋ฆฌ๋ก ํ ๋ฒ๋ง ๋ณํ์ด ์ํ๋๋ค. ๋์ ๋๋ฆฌ๋ฅผ ์์ ํด๋ ํด๋น ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด์๋ ๋ฐ์๋์ง ์๊ณ , ๊ทธ ๋ฐ๋๋ ๋ง์ฐฌ๊ฐ์ง๋ค.
๋์ ๋๋ฆฌ๋ ์์ฑ์ด๋ ์์์ ํ์ ์ผ๋ก ์ฌ์ฉ๋ ์ ์๋ค.
๋์ ๋๋ฆฌ๋ ๋ค๋ฅธ ๋์ ๋๋ฆฌ๋ฅผ ์์ํ๋๋ก ์ ์ํ ์ ์๋ค. ๋์ ๋๋ฆฌ์ ์๋ณ์ ๋ค์ ์ฝ๋ก ๊ณผ ์๋ณ์๊ฐ ์ค๋ฉด, ํด๋น ์๋ณ์๋ ์์๋ฐ๋ ๋์ ๋๋ฆฌ๋ฅผ ์๋ณํ๋ค. ๋ฐ๋์ ๋์ ๋๋ฆฌ๋ฅผ ์๋ณํด์ผ ํ๋ค.
๋์ ๋๋ฆฌ์ ์์ ๊ณ์ธต์ ์ํ ๊ตฌ์กฐ๊ฐ ์์ผ๋ฉด ์ ๋๋ค. ์ฆ, ๋์ ๋๋ฆฌ A๊ฐ ์๊ธฐ ์์ ์ ์์ํ๊ฑฐ๋, B๋ฅผ ์์ํ๋ฉด์ B๊ฐ ๋ค์ A๋ฅผ ์์ํ๋ ๋ฐฉ์์ ๊ธ์ง๋๋ค.
dictionary Base { /* dictionary_members... */ };dictionary Derived :Base { /* dictionary_members... */ };
๋์ ๋๋ฆฌ D์ ์์๋ ๋์ ๋๋ฆฌ๋ค์ D๊ฐ ์ง์ ๋๋ ๊ฐ์ ์ ์ผ๋ก ์์๋ฐ๋ ๋ชจ๋ ๋์ ๋๋ฆฌ ์งํฉ์ ์๋ฏธํ๋ค. D๊ฐ ๋ค๋ฅธ ๋์ ๋๋ฆฌ๋ฅผ ์์ํ์ง ์์ผ๋ฉด ์งํฉ์ ๋น์ด ์๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด, D๊ฐ ์์ํ ๋์ ๋๋ฆฌ E์ E์ ์์๋ ๋์ ๋๋ฆฌ๋ค์ด ๋ชจ๋ ํฌํจ๋๋ค.
๋์ ๋๋ฆฌ ๋ฉค๋ฒ๋ ํ์๋ก ์ง์ ๋ ์ ์๋ค. ์ด ๊ฒฝ์ฐ, ํด๋น ๋ฉค๋ฒ์ ๊ฐ์ ์ ๊ณตํ์ง ์์ผ๋ฉด ์ธ์ด๋ณ ๊ฐ์์ ๋์ ๋๋ฆฌ๋ก ๋ณํํ ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. ํ์๊ฐ ์๋ ๋ฉค๋ฒ๋ ์ต์ ์ด๋ค.
๋์ ๋๋ฆฌ ๋ฉค๋ฒ๋ฅผ ํ์๋ก ์ง์ ํ๋ ๊ฒ์, ์ธ์ด๋ณ ๋์ ๋๋ฆฌ ํํ(์: ์ฐ์ฐ ์ธ์๋ก ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ ์ ๋ฌํ ๋)์์๋ง ํจ๊ณผ๊ฐ ์๋ค. ์ด์ธ์ ๊ฒฝ์ฐ, ์ฆ ์ฐ์ฐ์์ ๋์ ๋๋ฆฌ๋ฅผ ๋ฐํ ํ์ ์ผ๋ก๋ง ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋ฑ์๋ ๋ฉค๋ฒ๋ฅผ ์ต์ ์ผ๋ก ๋จ๊ฒจ๋๋ ๊ฒ์ด ์ข๋ค.
ํ์ D์ ๋์ ๋๋ฆฌ ๊ฐ์๋, D์ D์ ์์๋ ๋์ ๋๋ฆฌ๋ค์ ์ ์๋ ๋ชจ๋ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ๋ํ ์ํธ๋ฆฌ๊ฐ ์์ ์ ์๋ค. ํ์ ๋๋ ๊ธฐ๋ณธ๊ฐ์ด ์ง์ ๋ ๋ฉค๋ฒ๋ ๋ฐ๋์ ์ํธ๋ฆฌ๊ฐ ์กด์ฌํ๋ค. ๊ทธ ์ธ ๋ฉค๋ฒ์ ์ํธ๋ฆฌ๋ ์กด์ฌํ ์๋ ์๊ณ , ์๋ ์๋ ์๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋, ๋์
๋๋ฆฌ ๋ฉค๋ฒ์ ํด๋นํ๋ ํ๋กํผํฐ ๊ฐ์ด
์ฐ์ฐ ์ธ์ ๊ธฐ๋ณธ๊ฐ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก,
boolean
ํ์
๋์
๋๋ฆฌ ๋ฉค๋ฒ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก
๋ฌธ์์ด ํค๋ฅผ ๊ฐ์ง ์์ ์๋ map์, ๋ชจ๋ ์ํธ๋ฆฌ๊ฐ ๋์ ๋๋ฆฌ D์ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ๋์ํ๊ณ , ํ์ ์ด ๋ง๊ณ , ํ์ ๋๋ ๊ธฐ๋ณธ๊ฐ ๋ฉค๋ฒ์ ๋ํ ์ํธ๋ฆฌ๊ฐ ๋ชจ๋ ์กด์ฌํ๋ฉด ์๋ฌต์ ์ผ๋ก D ํ์ ์ ๋์ ๋๋ฆฌ ๊ฐ์ผ๋ก ๊ฐ์ฃผ๋ ์ ์๋ค.
dictionary Descriptor {DOMString name ;sequence <unsigned long >serviceIdentifiers ; };
Descriptor ๋์
๋๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ด ์์ฑํ ์ ์๋ค:
-
identifiers๋ฅผ ยซ 1, 3, 7 ยป๋ก ๋๋ค.
-
ยซ[ "name" โ "test", "serviceIdentifiers" โ identifiers ]ยป๋ฅผ ๋ฐํํ๋ค.
๊ฐ ๋์
๋๋ฆฌ
๋ฉค๋ฒ(
๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ํ์ ์ด typedef ํด์ ํ ๋ ํ์ฉ ํ์ ์ด๋ฉด, ๋ด๋ถ ํ์ ์ด ๋์ ๋๋ฆฌ ํ์ ์ด๋ฉด ์ ๋๋ค.
dictionary identifier {type identifier ; };
์ต์
๋์
๋๋ฆฌ ๋ฉค๋ฒ์
์๋ณ์ ๋ค์ U+003D(=)์ ๊ฐ(
dictionary identifier {type identifier = "value"; };
๋ถ๋ฆฌ์ธ ๋ฆฌํฐ๋ด ํ ํฐ(
๋์ ๋๋ฆฌ ๋ฉค๋ฒ ํ์ ์ด ์ด๊ฑฐํ์ด๋ฉด, ๊ธฐ๋ณธ๊ฐ์ ๋ฐ๋์ ์ด๊ฑฐํ์ ๊ฐ ์ค ํ๋์ฌ์ผ ํ๋ค.
๋์
๋๋ฆฌ ๋ฉค๋ฒ ํ์
์์
dictionary identifier {required type identifier ; };
๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ํ์ ์๋ ํด๋น ๋์ ๋๋ฆฌ๊ฐ ํฌํจ๋๋ฉด ์ ๋๋ค. ํ์ ์ด ๋์ ๋๋ฆฌ D๋ฅผ ํฌํจํ๋ค๋ ๊ฒ์ ๋ค์ ์ค ํ๋๋ผ๋ ์ฐธ์ด๋ฉด ์ฑ๋ฆฝํ๋ค:
-
ํ์ ์ด D์ด๋ค.
-
ํ์ ์ด D๋ฅผ ์์ํ๋ ๋์ ๋๋ฆฌ์ด๋ค.
-
ํ์ ์ด ๋ ํ์ฉ ํ์ ์ด๋ฉด์, ๋ด๋ถ ํ์ ์ด D๋ฅผ ํฌํจํ๋ค.
-
ํ์ ์ด ์ํ์ค ํ์ ๋๋ ๋ถ๋ณ ๋ฐฐ์ด์ด๋ฉด์, ์์ ํ์ ์ด D๋ฅผ ํฌํจํ๋ค.
-
ํ์ ์ด ์ ๋์จ ํ์ ์ด๋ฉฐ, ๋ฉค๋ฒ ํ์ ์ค ํ๋๊ฐ D๋ฅผ ํฌํจํ๋ค.
-
ํ์ ์ด ๋์ ๋๋ฆฌ์ด๊ณ , ๊ทธ ๋ฉค๋ฒ ๋๋ ์์ ๋ฉค๋ฒ์ ํ์ ์ค D๋ฅผ ํฌํจํ๋ ๊ฒ์ด ์๋ค.
-
ํ์ ์ด
record<K, V>์ด๊ณ , V๊ฐ D๋ฅผ ํฌํจํ๋ค.
์ธํฐํ์ด์ค์ ๋ง์ฐฌ๊ฐ์ง๋ก, ๋์
๋๋ฆฌ์ IDL๋ ๋ถ๋ถ ๋์
๋๋ฆฌ ์ ์(
dictionary SomeDictionary { /* dictionary_members... */ };partial dictionary SomeDictionary { /* dictionary_members... */ };
์ฐธ๊ณ : ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์์ ๊ฐ์ด, ๋ถ๋ถ ๋์ ๋๋ฆฌ ์ ์๋ ๋ช ์ธ ํธ์ง์ ๋๊ธฐ ์ํ ๊ฒ์ผ๋ก, ๋์ ๋๋ฆฌ ์ ์๋ฅผ ๋ฌธ์์ ์ฌ๋ฌ ์น์ ์ด๋ ์ฌ๋ฌ ๋ฌธ์์ ๊ฑธ์ณ ๋ถ๋ฆฌํ ์ ์๊ฒ ํด์ค๋ค.
๋์ ๋๋ฆฌ์ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ ์์๋, ์์๋ ๋ฉค๋ฒ๊ฐ ๋น์์ ๋ฉค๋ฒ๋ณด๋ค ์์ ์ค๊ณ , ํ ๋์ ๋๋ฆฌ ์ ์(๋ถ๋ถ ๋์ ๋๋ฆฌ ํฌํจ) ๋ด ๋ฉค๋ฒ๋ค์ ์๋ณ์์ ์ ๋์ฝ๋ ์ฝ๋ํฌ์ธํธ ๊ธฐ์ค์ผ๋ก ์ฌ์ ์ ์ ๋ ฌ๋๋ค.
์ฌ์ ๊ฐ์ ํญ๋ชฉ์ ํญ์ ํด๋นํ๋ ์ฌ์ ๋ฉค๋ฒ์ ์์๋๋ก ์ ๋ ฌ๋๋ฉฐ, ์ด๋ค์ด ์ค์ ๋ ์์์๋ ๋ฌด๊ดํฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์๋ ์ ์๊ฐ ์์ ๋:
dictionary B :A {long b ;long a ; };dictionary A {long c ;long g ; };dictionary C :B {long e ;long f ; };partial dictionary A {long h ;long d ; };
C ํ์
๋์
๋๋ฆฌ ๊ฐ์ ๋์
๋๋ฆฌ ๋ฉค๋ฒ ์์๋
c, d, g, h, a, b, e, f์ด๋ค.
๋์ ๋๋ฆฌ ๋ฉค๋ฒ๋ ์์๊ฐ ํ์ํ๋ค. ์๋ํ๋ฉด ์ผ๋ถ ์ธ์ด ๋ฐ์ธ๋ฉ์์ ๋์ ๋๋ฆฌ ๊ฐ์ ํ๋ซํผ ๊ฐ์ฒด์ ์ ๋ฌํ ๋, ๋์ ๋๋ฆฌ ๋ฉค๋ฒ๋ฅผ ์กฐํํ๋ ์์์ ๋ฐ๋ผ ๋์์ด ๋ฌ๋ผ์ง ์ ์๊ธฐ ๋๋ฌธ์ด๋ค. ์๋ฅผ ๋ค์ด ์๋ ์ธํฐํ์ด์ค:
[Exposed =Window ]interface Something {undefined f (A a ); };
๊ทธ๋ฆฌ๊ณ ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋:
var something= getSomething(); // Something ์ธ์คํด์ค ์ป๊ธฐ var x= 0 ; var dict= { }; Object. defineProperty( dict, "d" , { get: function () { return ++ x; } }); Object. defineProperty( dict, "c" , { get: function () { return ++ x; } }); something. f( dict);
๋์
๋๋ฆฌ ๋ฉค๋ฒ๋ฅผ ์กฐํํ๋ ์์์ ๋ฐ๋ผ ๊ฐ์ด ๋ฌ๋ผ์ง๋ค. A์ ์์๊ฐ c, d์ด๋ฏ๋ก,
c ๊ฐ์ 1, d ๊ฐ์ 2๊ฐ ๋๋ค.
๋ฐ๋ผ์ ํญ๋ชฉ์ด ๋์ผํ ํค์ ๋์ผํ ๊ฐ์ ๊ฐ๋ ๋ ์ฌ์ ๊ฐ์ ํด๋น ํญ๋ชฉ๋ค์ด ์ค์ ๋ ์์์ ๊ด๊ณ์์ด ๋์ผํฉ๋๋ค. ํด๋น ํญ๋ชฉ๋ค์ด ์ค์ ๋ ์์์๋ ๋ฌด๊ดํฉ๋๋ค.
์ฌ์ ๋ฉค๋ฒ์ ์๋ณ์๋ ํด๋น ์ฌ์ ๋๋ ํด๋น ์ฌ์ ์ ์์๋ ์ฌ์ ์ ์ ์๋ ๋ค๋ฅธ ์ฌ์ ๋ฉค๋ฒ์ ์๋ณ์์ ๊ฐ์์๋ ์ ๋ฉ๋๋ค.
์ฌ์ ์๋ ํ์ฅ ์์ฑ์ด ์ ์ฉ๋์ง ์์ต๋๋ค.
Partial ::partial PartialDefinition
Dictionary ::dictionary identifier Inheritance { DictionaryMembers } ;
DictionaryMembers ::DictionaryMember DictionaryMembers ฮต
DictionaryMember ::ExtendedAttributeList DictionaryMemberRest
DictionaryMemberRest ::required TypeWithExtendedAttributes identifier ; Type identifier Default ;
PartialDictionary ::dictionary identifier { DictionaryMembers } ;
Default ::= DefaultValue ฮต
DefaultValue ::ConstValue string [ ] { } null undefined
Inheritance ::: identifier ฮต
๋์ ๋๋ฆฌ ํ์ ์ ํ ๊ฐ์ง ์ฉ๋๋, ์ต์ ์ธ์๋ฅผ ์ฐ์ฐ์ ์ฌ๋ฌ ๊ฐ ์ ๊ณตํ๋ฉด์, ํธ์ถ ์ ์ธ์ ์์์ ๊ตฌ์ ๋ฐ์ง ์๊ฒ ํ๋ ๊ฒ์ด๋ค. ์๋ฅผ ๋ค์ด, ๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ฅผ ๋ณด์:
[Exposed =Window ]interface Point {constructor ();attribute double x ;attribute double y ; };dictionary PaintOptions {DOMString fillPattern = "black";DOMString strokePattern ;Point position ; }; [Exposed =Window ]interface GraphicsContext {undefined drawRectangle (double width ,double height ,optional PaintOptions options ); };
IDL์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋, ์ต์
PaintOptions ๋์
๋๋ฆฌ์
Object๋ฅผ ๋๊ธธ ์ ์๋ค:
// GraphicsContext ์ธ์คํด์ค ์ป๊ธฐ var ctx= getGraphicsContext(); // ์ฌ๊ฐํ ๊ทธ๋ฆฌ๊ธฐ ctx. drawRectangle( 300 , 200 , { fillPattern: "red" , position: new Point( 10 , 10 ) });
PaintOptions์ ๋ฉค๋ฒ๋ ์ต์
์ด๋ค.
fillPattern์ ์๋ตํ๋ฉด, drawRectangle ์ ์์์ ๊ธฐ๋ณธ๊ฐ์ด ์๋ค๊ณ ๊ฐ์ฃผํ๊ณ ๋ฐ๋ก
์๋ต ์ฒ๋ฆฌ ๋ฌธ๊ตฌ๋ฅผ ๋ฃ์ง ์์๋ ๋๋ค.
strokePattern๊ณผ position ์๋ต ์๋ drawRectangle์์ ๋ช
์์ ์ผ๋ก ์ฒ๋ฆฌํด์ผ ํ๋ค.
2.8. ์์ธ
์์ธ๋ ์ค๋ฅ๋ฅผ ๋ํ๋ด๋ ๊ฐ์ฒด ํ์
์ผ๋ก,
๊ตฌํ์ฒด์์ throw ํ๊ฑฐ๋ ๊ฐ์ฒ๋ผ ๋ค๋ฃฐ ์ ์๋ค. Web IDL์๋ ๋ช
์ธ์์ ์ฐ์ฐ, ์์ฑ ๋ฑ์ ์ฐธ์กฐ ๋๋ throwํ ์ ์๋ ์ฌ๋ฌ ๊ธฐ๋ณธ ์์ธ๊ฐ ์ ์๋์ด ์๋ค. ์ธํฐํ์ด์ค์์ DOMException์
์์ํ์ฌ ์ปค์คํ
์์ธ ํ์
๋ ์ ์ํ ์ ์๋ค.
๋จ์ ์์ธ๋ ๋ค์ ํ์ ์ค ํ๋๋ก ์๋ณ๋๋ค:
-
EvalError -
RangeError -
ReferenceError -
TypeError -
URIError
์ด๋ JavaScript์ ๋ชจ๋ ์ค๋ฅ ๊ฐ์ฒด์ ํด๋นํ์ง๋ง,
๋ค์์ ์ ์ธ๋ฉ๋๋ค.
AggregateError
๋ฐ SuppressedError๋
๋ค๋ฅธ ์ค๋ฅ๋ฅผ ๊ฐ์ธ๋ ์ฉ๋๋ก๋ง ์ค๊ณ๋์์ผ๋ฉฐ, SyntaxError๋
JavaScript ํ์์์
์ฌ์ฉํ๋๋ก ์์ฝ๋์ด ์๊ณ , Error๋
์์ฑ์๊ฐ ์ฌ์ฉํ๋๋ก
์์ฝ๋์ด ์์ต๋๋ค. ๊ฐ ๋จ์
์์ธ์ ์๋ฏธ๋ ํด๋น ์ค๋ฅ ๊ฐ์ฒด์ ์๋ฏธ์
JavaScript ๋ช
์ธ์์ ์ผ์นํฉ๋๋ค.
๋ ๋ฒ์งธ ์์ธ ์ข
๋ฅ๋ DOMException์ผ๋ก,
๋ฐ์ํ ์ค๋ฅ์ ๋ํด name์ผ๋ก
ํ๋ก๊ทธ๋๋ฐ์ ์ผ๋ก ์์ธ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ค.
name ๊ฐ์ ์๋ DOMException ์ด๋ฆ ํ
์ด๋ธ์์ ์ ์ ๋๋ค.
DOMException์
์ธํฐํ์ด์ค ํ์
์ด๋ฏ๋ก IDL์์ ํ์
์ผ๋ก ์ฌ์ฉํ ์
์๋ค. ์๋ฅผ ๋ค์ด ์ฐ์ฐ์ DOMException
๋ฐํ ํ์
์ผ๋ก ์ ์ธํ ์ ์์ง๋ง,
์์ธ๋ ๋ฐํ์ด ์๋๋ผ throwํ๋ ๊ฒ์ด๋ฏ๋ก ์ด๋ฐ ํจํด์ ๋ฐ๋์งํ์ง ์๋ค.
์ธ ๋ฒ์งธ ์์ธ ์ข
๋ฅ๋ DOMException์
์์ํ ์ธํฐํ์ด์ค์ด๋ค.
์ด๋ค์ ๋ ๋ณต์กํ๋ฏ๋ก ยงโฏ2.8.2 DOMException ํ์ ์ธํฐํ์ด์ค์์ ๋ฐ๋ก ์ค๋ช
ํ๋ค.
๋จ์ ์์ธ๋
ํ์
์ด๋ฆ์ ์ ๊ณตํด ์์ฑํ ์ ์๋ค. DOMException์
name ๋ค์ DOMException์ ์ ๊ณตํ์ฌ ์์ฑํ๋ค.
์์ธ๋ throwํ ์๋ ์๋๋ฐ, ์ด๋๋ ์์ฑํ ๋์ ๋์ผํ ์ ๋ณด๊ฐ ํ์ํ๋ค. ๋ ๊ฒฝ์ฐ ๋ชจ๋ ์์ธ๊ฐ ๋ฌด์์ ์๋ฏธํ๋์ง์ ๋ํ ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์์ผ๋ฉฐ,
์์ธ ๋ฉ์์ง ์์ฑ์ ์ ์ฉํ๋ค.
์์ธ๋ฅผ ์์ฑํ๊ณ throwํ๋ ๋ฌธ๊ตฌ ์์:
๋จ์ ์์ธ TypeError๋ฅผ
throwํ๋ ค๋ฉด:
name์ด "NotAllowedError"์ธ
DOMException์
throwํ๋ ค๋ฉด:
"NotAllowedError" DOMException์ throwํ๋ค.
name์ด "SyntaxError"์ธ
DOMException์
์์ฑํ๋ ค๋ฉด:
object๋ฅผ ์๋ก ์์ฑ๋ "SyntaxError" DOMException์ผ๋ก ๋๋ค.
name์ด "OperationError"์ธ
DOMException์ผ๋ก
promise๋ฅผ rejectํ๋ ค๋ฉด:
p๋ฅผ "OperationError" DOMException์ผ๋ก rejectํ๋ค.
์์ธ ๋ฉ์์ง์ ์ถ๊ฐ ์ ๋ณด๋ฅผ ํฌํจํ๋ ์์:
"SyntaxError" DOMException์ throwํ๋ค. ์ด ๋ ์ฃผ์ด์ง ๊ฐ์ ํ์ฉ๋์ง ์๋ ํํ ๊ณต๋ฐฑ์ด ์์๋ค๊ณ ๋ช ์ํ๋ค.
์ด๋ฐ ์ถ๊ฐ ์ปจํ ์คํธ๋ ์์ธ ๋ฐ์ ์ด์ ๊ฐ ๋ช ํํ์ง ์์ ๋(์: ์๊ณ ๋ฆฌ์ฆ ์ฌ๋ฌ ๋จ๊ณ์์ "SyntaxError" DOMException์ throwํ ๋) ๊ตฌํ์์๊ฒ ๋์์ด ๋๋ค. ๋ฐ๋ฉด, ์๋ฅผ ๋ค์ด ์ฌ์ฉ์๊ฐ ํน์ ๊ธฐ๋ฅ ์ฌ์ฉ ๊ถํ์ ์ ๊ณตํ๋์ง ๊ฒ์ฌํ๊ณ ๋ฐ๋ก "NotAllowedError" DOMException์ throwํ๋ ๊ฒฝ์ฐ์๋ ๋ฉ์์ง ๊ตฌ์ฒดํ๊ฐ ํ์ํ์ง ์๋ค.
์์ธ ์์ฑ ๋ฐ throw์ ์ค์ ๋์์ ์ธ์ด ๋ฐ์ธ๋ฉ๋ง๋ค ๋ค๋ฅด๋ค.
ยงโฏ3.14.3 ์์ธ ์์ฑ ๋ฐ throw์์ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์ ์์ธ ์์ฑ ๋ฐ throw์ ์์ธ ๋์์ ๋ณผ ์ ์๋ค.
2.8.1.
๊ธฐ๋ณธ DOMException
์ค๋ฅ ์ด๋ฆ
์๋ DOMException ์ด๋ฆ ํ
์ด๋ธ์
๊ธฐ๋ณธ DOMException
์ธํฐํ์ด์ค ์ธ์คํด์ค์
ํ์ฉ๋๋ ๋ชจ๋ ์ด๋ฆ๊ณผ,
๊ฐ ์ด๋ฆ์ ์๋ฏธ ๋ฐ ๋ ๊ฑฐ์ ์ซ์ ์ค๋ฅ ์ฝ๋ ๊ฐ์ ์ค๋ช
ํฉ๋๋ค.
DOMException์ ์์ํ ์ธํฐํ์ด์ค(์๋ ยงโฏ2.8.2 DOMException ํ์ ์ธํฐํ์ด์ค ์ฐธ๊ณ )๋
์์ฒด ์ด๋ฆ์ ๊ฐ์ง๋ฉฐ, ์ด ํ
์ด๋ธ์๋ ํฌํจ๋์ง ์์ต๋๋ค.
DOMException์ ์์ฑํ๊ฑฐ๋ throwํ ๋,
๋ช
์ธ์๋ ๋ฐ๋์ ์ด ์ด๋ฆ ์ค ํ๋๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ๋ง์ฝ ๋ช
์ธ์๊ฐ ์ด๋ค ์ด๋ฆ๋ ์ ํฉํ์ง ์๋ค๊ณ ์๊ฐ๋๋ฉด,
์ด์๋ฅผ ๋ฑ๋กํด ์๋ก์ด
์ด๋ฆ ์ถ๊ฐ๋ฅผ ๋
ผ์ํด์ผ ํ๋ฉฐ,
์ปค๋ฎค๋ํฐ๊ฐ ์ด๋ฐ ์์
์ ์กฐ์จํ ์ ์์ต๋๋ค. ์๋ก์ด ์ผ์ด์ค๋ณ ์ด๋ฆ์,
์น ๊ฐ๋ฐ์๊ฐ ๋จ์ผ API์์ ์ฌ๋ฌ ์ค๋ฅ ์กฐ๊ฑด์ ๊ตฌ๋ถํ ํ์๊ฐ ์์ ๋๋ง ์ค์ํฉ๋๋ค.
DOMException
์ด๋ฆ ์ค "deprecated"๋ก ํ์๋ ๊ฒ์ ๋ ๊ฑฐ์๋ฅผ ์ํด ๋จ์ ์์ง๋ง,
์ฌ์ฉ์ ๊ถ์ฅํ์ง ์์ต๋๋ค.
์ฐธ๊ณ : ์ฌ๊ธฐ ์ ์๋ "SyntaxError"
DOMException๊ณผ
JavaScript์ SyntaxError๋ฅผ
ํผ๋ํ์ง ๋ง์ธ์.
"SyntaxError"
DOMException์ ์น API์์ ํ์ฑ ์ค๋ฅ(์:
์
๋ ํฐ ํ์ฑ ๋ฑ)๋ฅผ ๋ณด๊ณ ํ๋ ๋ฐ ์ฌ์ฉ๋๋ฉฐ,
JavaScript SyntaxError๋
JS ํ์ ์ฉ๋๋ก ์์ฝ๋์ด ์์ต๋๋ค.
ํผ๋์ ํผํ๊ธฐ ์ํด, ํญ์ "SyntaxError"
DOMException ํ๊ธฐ๋ฅผ ์ฌ์ฉํ๊ณ , DOMException์ ๊ฐ๋ฆฌํฌ ๋ ๋จ์ํ SyntaxError๋ผ๊ณ ๋ง ์ฐ์ง ๋ง์ธ์.
[DOM]
| ์ด๋ฆ | ์ค๋ช | ๋ ๊ฑฐ์ ์ฝ๋ ์ด๋ฆ ๋ฐ ๊ฐ |
|---|---|---|
"IndexSizeError"
|
์ฌ์ฉ ์ค๋จ๋จ. ๋์ RangeError
์ฌ์ฉ.
|
INDEX_SIZE_ERR (1)
|
"HierarchyRequestError"
|
์ฐ์ฐ ๊ฒฐ๊ณผ๊ฐ ์๋ชป๋ ๋ ธ๋ ํธ๋ฆฌ๊ฐ ๋ ๋. [DOM] | HIERARCHY_REQUEST_ERR (3)
|
"WrongDocumentError"
|
๊ฐ์ฒด๊ฐ ์๋ชป๋ ๋ฌธ์์ ์์ ๋. [DOM] | WRONG_DOCUMENT_ERR (4)
|
"InvalidCharacterError"
|
๋ฌธ์์ด์ ์๋ชป๋ ๋ฌธ์๊ฐ ํฌํจ๋จ. | INVALID_CHARACTER_ERR (5)
|
"NoModificationAllowedError"
|
๊ฐ์ฒด๋ฅผ ์์ ํ ์ ์์. | NO_MODIFICATION_ALLOWED_ERR (7)
|
"NotFoundError"
|
๊ฐ์ฒด๋ฅผ ์ฌ๊ธฐ์ ์ฐพ์ ์ ์์. | NOT_FOUND_ERR (8)
|
"NotSupportedError"
|
์ฐ์ฐ์ด ์ง์๋์ง ์์. | NOT_SUPPORTED_ERR (9)
|
"InUseAttributeError"
|
์์ฑ์ด ๋ค๋ฅธ ์์์์ ์ด๋ฏธ ์ฌ์ฉ ์ค์. [DOM] | INUSE_ATTRIBUTE_ERR (10)
|
"InvalidStateError"
|
๊ฐ์ฒด๊ฐ ์ฌ๋ฐ๋ฅด์ง ์์ ์ํ์. | INVALID_STATE_ERR (11)
|
"SyntaxError"
|
๋ฌธ์์ด์ด ์์ ํจํด๊ณผ ์ผ์นํ์ง ์์. | SYNTAX_ERR (12)
|
"InvalidModificationError"
|
์ด ๋ฐฉ์์ผ๋ก ๊ฐ์ฒด๋ฅผ ์์ ํ ์ ์์. | INVALID_MODIFICATION_ERR (13)
|
"NamespaceError"
|
์ฐ์ฐ์ด Namespaces in XML์ ์ํด ํ์ฉ๋์ง ์์. [XML-NAMES] | NAMESPACE_ERR (14)
|
"InvalidAccessError"
|
์ฌ์ฉ ์ค๋จ๋จ.
์๋ชป๋ ์ธ์์๋ TypeError,
์ง์๋์ง ์๋ ์ฐ์ฐ์๋ "NotSupportedError"
DOMException,
๊ฑฐ๋ถ๋ ์์ฒญ์๋ "NotAllowedError"
DOMException ์ฌ์ฉ.
|
INVALID_ACCESS_ERR (15)
|
"TypeMismatchError"
|
์ฌ์ฉ ์ค๋จ๋จ. ๋์ TypeError ์ฌ์ฉ.
|
TYPE_MISMATCH_ERR (17)
|
"SecurityError"
|
์ฐ์ฐ์ด ์์ ํ์ง ์์. | SECURITY_ERR (18)
|
"NetworkError"
|
๋คํธ์ํฌ ์ค๋ฅ๊ฐ ๋ฐ์ํจ. | NETWORK_ERR (19)
|
"AbortError"
|
์ฐ์ฐ์ด ์ค๋จ๋จ. | ABORT_ERR (20)
|
"URLMismatchError"
|
์ฌ์ฉ ์ค๋จ๋จ. | URL_MISMATCH_ERR (21)
|
"QuotaExceededError"
|
์ฌ์ฉ ์ค๋จ๋จ. ๋์ QuotaExceededError
DOMException ํ์
์ธํฐํ์ด์ค ์ฌ์ฉ.
|
QUOTA_EXCEEDED_ERR (22)
|
"TimeoutError"
|
์ฐ์ฐ์ด ์ ํ ์๊ฐ์ ์ด๊ณผํจ. | TIMEOUT_ERR (23)
|
"InvalidNodeTypeError"
|
์ ๊ณต๋ ๋ ธ๋๊ฐ ์ด ์ฐ์ฐ์ ๋ถ์ ํฉํ๊ฑฐ๋ ์์ ๋ ธ๋๊ฐ ๋ถ์ ํฉํจ. [DOM] | INVALID_NODE_TYPE_ERR (24)
|
"DataCloneError"
|
๊ฐ์ฒด๋ฅผ ๋ณต์ ํ ์ ์์. | DATA_CLONE_ERR (25)
|
"EncodingError"
|
์ธ์ฝ๋ฉ(๋๋ ๋์ฝ๋ฉ) ์์ ์ด ์คํจํจ. | โ |
"NotReadableError"
|
I/O ์ฝ๊ธฐ ์์ ์ด ์คํจํจ. | โ |
"UnknownError"
|
์ ์ ์๋ ์ผ์์ ์ด์ (์: ๋ฉ๋ชจ๋ฆฌ ๋ถ์กฑ)๋ก ์ฐ์ฐ์ด ์คํจํจ. | โ |
"ConstraintError"
|
ํธ๋์ญ์ ์ ๋ณ์ด ์์ ์ด ์ ์ฝ ์กฐ๊ฑด์ ๋ง์กฑํ์ง ์์ ์คํจํจ. [INDEXEDDB] | โ |
"DataError"
|
์ ๊ณต๋ ๋ฐ์ดํฐ๊ฐ ๋ถ์ถฉ๋ถํจ. | โ |
"TransactionInactiveError"
|
์์ฒญ์ด ํ์ฌ ํ์ฑ ์ํ๊ฐ ์๋๊ฑฐ๋ ์ข ๋ฃ๋ ํธ๋์ญ์ ์ ๋ํด ์คํ๋จ. [INDEXEDDB] | โ |
"ReadOnlyError"
|
"readonly" ํธ๋์ญ์ ์์ ๋ณ์ด ์์ ์๋ํจ. [INDEXEDDB] | โ |
"VersionError"
|
๊ธฐ์กด ๋ฒ์ ๋ณด๋ค ๋ฎ์ ๋ฒ์ ์ผ๋ก ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ด๋ ค๊ณ ์๋ํจ. [INDEXEDDB] | โ |
"OperationError"
|
์ฐ์ฐ๋ณ ์ด์ ๋ก ์ฐ์ฐ์ด ์คํจํจ. | โ |
"NotAllowedError"
|
ํ์ฌ ์ปจํ ์คํธ์์ ์ฌ์ฉ์ ์์ด์ ํธ ๋๋ ํ๋ซํผ์์ ์์ฒญ์ด ํ์ฉ๋์ง ์์(์: ์ฌ์ฉ์๊ฐ ๊ถํ ๊ฑฐ๋ถํจ). | โ |
"OptOutError"
|
์ฌ์ฉ์๊ฐ ํด๋น ํ๋ก์ธ์ค๋ฅผ ๊ฑฐ๋ถํจ. | โ |
2.8.2.
DOMException
ํ์ ์ธํฐํ์ด์ค
์์ธ๊ฐ DOMException์ name์ผ๋ก ์ ๊ณต๋๋ ์ ๋ณด ์ธ์, ์ถ๊ฐ๋ก ํ๋ก๊ทธ๋๋ฐ์ ์ผ๋ก ์กฐํ ๊ฐ๋ฅํ ์ ๋ณด๋ฅผ ๋ด์์ผ ํ ๋,
๋ช
์ธ ์์ฑ์๋ DOMException๋ฅผ ์์ํ๋ ์ธํฐํ์ด์ค๋ฅผ ๋ง๋ค ์ ์๋ค.
์ด๋ฐ ์ธํฐํ์ด์ค๋ ๊ฐ๋ฐ์๊ฐ ์์ธก ๊ฐ๋ฅํ ํํ๋ก ๋ค๋ฃฐ ์ ์๋๋ก ๋ค์ ๊ท์น์ ๋ฐ๋ผ์ผ ํ๋ค:
-
์ธํฐํ์ด์ค์ ์๋ณ์๋ ๋ฐ๋์
Error๋ก ๋๋์ผ ํ๋ฉฐ,DOMException์ด๋ฆ ํ ์ด๋ธ์ ์๋ ์ด๋ฆ์ด๋ฉด ์ ๋๋ค. -
์ธํฐํ์ด์ค์๋, ์ธ์คํด์ค์ name์ ์ธํฐํ์ด์ค์ ์๋ณ์๋ก ์ค์ ํ๋ ์์ฑ์ ์ฐ์ฐ์ด ์์ด์ผ ํ๋ค.
-
์์ฑ์ ์ฐ์ฐ์ ์ฒซ ๋ฒ์งธ ์ธ์๋ ์ต์
DOMStringํ์ ์ message์ด๋ฉฐ, ๊ธฐ๋ณธ๊ฐ์ ๋น ๋ฌธ์์ด์ด์ด์ผ ํ๊ณ , ์ธ์คํด์ค์ message๋ฅผ message๋ก ์ค์ ํด์ผ ํ๋ค. -
์์ฑ์ ์ฐ์ฐ์ ๋ ๋ฒ์งธ ์ธ์๋ ๋ ธ์ถํ ์ถ๊ฐ ์ ๋ณด๋ฅผ ๋ด๋ ๋์ ๋๋ฆฌ์ฌ์ผ ํ๋ค.
-
์์ฑ์ ๋์ ๋๋ฆฌ์ ๋ฉค๋ฒ์ ๋์ผํ ์ด๋ฆ์ ๊ฐ์ง ์ฝ๊ธฐ ์ ์ฉ ์์ฑ์ ๊ฐ์ง๋ฉฐ, ์์ฑ์ ์ฐ์ฐ์์ ๋ฐ์ ๊ฐ์ ๋ฐํํด์ผ ํ๋ค.
-
์ง๋ ฌํ ๊ฐ๋ฅํ ๊ฐ์ฒด์ฌ์ผ ํ๋ฉฐ, ์ง๋ ฌํ ๋จ๊ณ์ ์ญ์ง๋ ฌํ ๋จ๊ณ์์ ์ถ๊ฐ ์ ๋ณด๊ฐ ๋ณด์กด๋์ด์ผ ํ๋ค.
์ด ์๊ตฌ๋ก ์ธํด, ์ด๋ฐ ์ธํฐํ์ด์ค์ ์์๋ code ํ๋กํผํฐ๋ ํญ์ 0์ ๋ฐํํ๋ค.
DOMException ํ์ ์ธํฐํ์ด์ค๋ฅผ ์์ฑํ๊ฑฐ๋ throwํ๋ ค๋ฉด, ํด๋น ์ธํฐํ์ด์ค ์๋ณ์์ ์ถ๊ฐ ์ ๋ณด๊ฐ ํ์ํ๋ค.
QuotaExceededError ์ธ์คํด์ค๋ฅผ
throwํ๋ ค๋ฉด:
QuotaExceededError๋ฅผ throwํ๋ค. quota๋ 42, requested๋ 50์ผ๋ก ์ค์ ํ๋ค.
2.8.3. ๋ฏธ๋ฆฌ ์ ์๋ DOMException
ํ์ ์ธํฐํ์ด์ค
์ด ํ์ค์์๋ ํ์ฌ ๋ฏธ๋ฆฌ ์ ์๋ DOMException
ํ์ ์ธํฐํ์ด์ค๊ฐ ํ๋ ์๋ค:
[Exposed=*,Serializable ]interface :QuotaExceededError DOMException {constructor (optional DOMString = "",message optional QuotaExceededErrorOptions = {});options readonly attribute double ?quota ;readonly attribute double ?requested ; };dictionary {QuotaExceededErrorOptions double ;quota double ; };requested
QuotaExceededError ์์ธ๋ ํ ๋น๋์
์ด๊ณผํ์ ๋ throwํ ์ ์๋ค. ๋ ๊ฐ์ ์์ฑ(quota, requested)์ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, ์น ๊ฐ๋ฐ์๊ฐ ์์ ์ ์์ฒญ๊ณผ ํ ๋น๋ ๊ฐ์ ๋น๊ตํ ์ ์๋๋ก ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ค.
์ด์ ๋ฒ์ ์ ํ์ค์์๋ "QuotaExceededError"๊ฐ ๊ธฐ๋ณธ DOMException ์ค๋ฅ ์ด๋ฆ ์ค ํ๋์์ผ๋, ์ด๋ฐ ์ ๋ณด๋ฅผ ์ ๊ณตํ ์ ์๋๋ก ํ
์ธํฐํ์ด์ค๋ก ์น๊ฒฉ๋์๋ค.
๋ชจ๋ QuotaExceededError
์ธ์คํด์ค๋
requested์ quota๋ผ๋ ๋ ๊ฐ์ ์ซ์ ๋๋ null ๊ฐ์ ๊ฐ์ง๋ฉฐ, ์ต์ด ๊ฐ์ ๋ชจ๋ null์ด๋ค.
new QuotaExceededError(message, options)
์์ฑ์ ๋จ๊ณ:
-
options["
quota"]๊ฐ ์์ผ๋ฉด:-
options["
quota"]๊ฐ 0๋ณด๋ค ์์ผ๋ฉดRangeError๋ฅผ throwํ๋ค.
-
-
options["
requested"]๊ฐ ์์ผ๋ฉด:-
options["
requested"]๊ฐ 0๋ณด๋ค ์์ผ๋ฉดRangeError๋ฅผ throwํ๋ค.
-
-
this ์ quota ๊ฐ null์ด ์๋๊ณ , this ์ requested ๊ฐ null์ด ์๋๋ฉฐ, this ์ requested ๊ฐ this ์ quota ๋ณด๋ค ์์ผ๋ฉด RangeError ๋ฅผ throwํ๋ค.
quota getter๋ this์ quota๋ฅผ ๋ฐํํ๋ค.
requested getter๋ this์ requested๋ฅผ ๋ฐํํ๋ค.
QuotaExceededError ์ธํฐํ์ด์ค๋
DOMException์ code getter๋ฅผ ์์๋ฐ์ผ๋ฉฐ, ํญ์ 22๋ฅผ
๋ฐํํ๋ค. ํ์ง๋ง ์ด ๊ฐ์ ์์กดํ๋ ๊ฒ์ ๊ถ์ฅ๋์ง ์๋๋ค(QuotaExceededError์ DOMException ๋ชจ๋์์). ๋์ name getter๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๋ ๋ซ๋ค.
QuotaExceededError ๊ฐ์ฒด๋ ์ง๋ ฌํ ๊ฐ๋ฅํ
๊ฐ์ฒด์ด๋ค.
-
DOMException์ ์ง๋ ฌํ ๋จ๊ณ๋ฅผ value, serialized์ ๋ํด ์คํํ๋ค. -
serialized.[[Quota]]๋ฅผ value์ quota๋ก ์ค์ ํ๋ค.
-
serialized.[[Requested]]๋ฅผ value์ requested๋ก ์ค์ ํ๋ค.
-
DOMException์ ์ญ์ง๋ ฌํ ๋จ๊ณ๋ฅผ serialized, value์ ๋ํด ์คํํ๋ค. -
value์ quota๋ฅผ serialized.[[Quota]]๋ก ์ค์ ํ๋ค.
-
value์ requested๋ฅผ serialized.[[Requested]]๋ก ์ค์ ํ๋ค.
QuotaExceededError๋ฅผ ์์ฑํ๊ฑฐ๋ throwํ ๋, requested์ quota๊ฐ ๋ชจ๋ null์ด ์๋๋ฉด์ requested๊ฐ quota๋ณด๋ค ์์ผ๋ฉด ์ ๋๋ค.
2.9. ์ด๊ฑฐํ
์ด๊ฑฐํ์ด๋, DOMString
๊ฐ์ด
์์ฑ์ ํ ๋น๋๊ฑฐ๋ ์ฐ์ฐ์ ์ธ์๋ก ์ ๋ฌ๋ ๋, ๊ฐ๋ฅํ ๊ฐ์ ์ ํํ๋ ๋ฐ
์ฌ์ฉํ ์ ์๋ค.
enum identifier {"enum" ,"values" /* , ... */ };
์ด๊ฑฐํ ๊ฐ์
์ผํ๋ก ๊ตฌ๋ถ๋
์ด๊ฑฐํ ๊ฐ์ ๋ชจ๋ ์๋ฌธ์๋ก ํ๊ณ , ์ฌ๋ฌ ๋จ์ด๋ ๋์(-)๋ก ๊ตฌ๋ถํ๊ฑฐ๋ ์์ ๊ตฌ๋ถํ์ง ์๋ ๊ฒ์ด ๊ฐ๋ ฅํ ๊ถ์ฅ๋๋ค.
ํน๋ณํ ์ด์ ๊ฐ ์์ผ๋ฉด ๋ค๋ฅธ ๋ช
๋ช
๊ท์น์ ์ฌ์ฉํ์ง ๋ง ๊ฒ. ์๋ฅผ ๋ค์ด, ๊ฐ์ฒด ์์ฑ ์๋ฏธ์ ๊ฐ์
"createobject" ๋๋ "create-object"๋ก ํ ์ ์๋ค.
๊ด๋ จ API์์ ์ผ๊ด์ฑ์ ์ํด ๋จ์ด ๊ตฌ๋ถ ๋ฐฉ์๋ ์ ์คํ ๊ฒฐ์ ํ ๊ฒ.
์ด๊ฑฐํ ํ์ ์์ฑ์ ์ ํจํ์ง ์์ ๋ฌธ์์ด ๊ฐ์ ํ ๋นํ๊ฑฐ๋, ์ฐ์ฐ ์ธ์๋ก ์ ๋ฌํ๋ ๊ฒฝ์ฐ์ ๋์์ ์ธ์ด ๋ฐ์ธ๋ฉ์ ๋ฐ๋ผ ๋ค๋ฅด๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ ์์ฑ์ ์๋ชป๋ ๋ฌธ์์ด ๊ฐ์ ํ ๋นํ๋ฉด ๋ฌด์๋์ง๋ง, ๋ค๋ฅธ ๋งฅ๋ฝ(์: ์ฐ์ฐ ์ธ์)์์๋ ์์ธ๊ฐ throw๋๋ค.
์ด ๋ช ์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ์ ์ด๊ฑฐํ์ ์ ์ฉ๋์ง ์๋๋ค.
Enum ::enum identifier { EnumValueList } ;
EnumValueList ::string EnumValueListComma
EnumValueListComma ::, EnumValueListString ฮต
EnumValueListString ::string EnumValueListComma ฮต
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์ด๊ฑฐํ์ ์์ฑ ํ์ ๊ณผ ์ฐ์ฐ ์ธ์๋ก ์ฌ์ฉํ ์์์ด๋ค:
enum MealType {"rice" ,"noodles" ,"other" }; [Exposed =Window ]interface Meal {attribute MealType type ;attribute double size ; // g ๋จ์undefined initialize (MealType type ,double size ); };
์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋ type ์์ฑ์ด๋ initialize ํจ์ ์ธ์์ ํ ๋นํ ์ ์๋ ๋ฌธ์์ด์ด ์ด๊ฑฐํ์ ๋ช ์๋ ๋ฌธ์์ด๋ก ์ ํ๋๋ค.
var meal= getMeal(); // Meal ์ธ์คํด์ค ์ป๊ธฐ meal. initialize( "rice" , 200 ); // ์ ์์ ์ผ๋ก ํธ์ถ๋จ try { meal. initialize( "sandwich" , 100 ); // TypeError ๋ฐ์ } catch ( e) { } meal. type= "noodles" ; // ์ ์ ํ ๋น meal. type= "dumplings" ; // ๋ฌด์๋จ meal. type== "noodles" ; // true ๋ฐํ
2.10. ์ฝ๋ฐฑ ํจ์
"Custom DOM Elements" ๋ช ์ธ์์๋ ํ๋ซํผ ๊ฐ์ฒด ์ ๊ณต ํจ์์๋ ์ฝ๋ฐฑ ํจ์ ํ์ ์ ์ฌ์ฉํ๊ณ ์ถ์ดํฉ๋๋ค. ์ฝ๋ฐฑ ํจ์ ๋์ ๊ทธ๋ฅ "ํจ์"๋ก ์ด๋ฆ์ ๋ฐ๊ฟ์ ๋ ๊ฐ์ง ์ฉ๋ ๋ชจ๋ ๋ช ํํ ํ ์ ์์๊น์?
์ฝ๋ฐฑ ํจ์๋,
callback identifier =return_type (/* arguments... */);
์ฐธ๊ณ : ์ ์ฌ ์ด๋ฆ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ ์ฐธ๊ณ ํ์ธ์.
๋ฑํธ ์ผ์ชฝ์ ์๋ณ์๊ฐ ์ฝ๋ฐฑ ํจ์ ์ด๋ฆ์ด๋ฉฐ,
์ค๋ฅธ์ชฝ์ ๋ฐํ ํ์
๊ณผ ์ธ์ ๋ชฉ๋ก(
์ฝ๋ฐฑ ํจ์๋ ์์์ ํ์ ์ผ๋ก ์ฌ์ฉ๋ ์ ์์ต๋๋ค.
์ฝ๋ฐฑ ํจ์์ ์ ์ฉ ๊ฐ๋ฅํ ํ์ฅ ์์ฑ:
[LegacyTreatNonObjectAsNull].
CallbackOrInterfaceOrMixin ::callback CallbackRestOrInterface interface InterfaceOrMixin
CallbackRest ::identifier = Type ( ArgumentList ) ;
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ์ฐ์ฐ์ด ์๋ฃ๋ ๋ ์ฌ์ฉ์ ์ ์ ํจ์๋ฅผ ํธ์ถํ๋ API์ ์ฝ๋ฐฑ ํจ์๋ฅผ ์ ์ํ ์์์ ๋๋ค.
callback AsyncOperationCallback =undefined (DOMString status ); [Exposed =Window ]interface AsyncOperations {undefined performOperation (AsyncOperationCallback whenFinished ); };
์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ์์๋ ํจ์ ๊ฐ์ฒด๊ฐ ์ฐ์ฐ ์ธ์๋ก ์ ๋ฌ๋๋ค.
var ops= getAsyncOperations(); // AsyncOperations ์ธ์คํด์ค ์ป๊ธฐ ops. performOperation( function ( status) { window. alert( "Operation finished, status is " + status+ "." ); });
2.11. ํ์ ์ ์
ํ์
์ ์(typedef)๋,
typedef type identifier ;
์ ์ด๋ฆ์ ๋ถ์ฌ๋ฐ๋
ํ์
์
์ด ๋ช ์ธ์์ ์ ์๋ ํ์ฅ ์์ฑ์ ํ์ ์ ์์ ์ ์ฉ๋์ง ์์ต๋๋ค.
Typedef ::typedef TypeWithExtendedAttributes identifier ;
์๋ IDL ํ๋๊ทธ๋จผํธ๋ ํ์ ์ ์(typedef)๋ฅผ ์ฌ์ฉํด ๊ธด ์ํ์ค ํ์ ๋์ ์งง์ ์๋ณ์๋ฅผ ์ธ ์ ์๊ฒ ํ๋ ์๋ฅผ ๋ณด์ฌ์ค๋๋ค.
[Exposed =Window ]interface Point {attribute double x ;attribute double y ; };typedef sequence <Point >Points ; [Exposed =Window ]interface Widget {boolean pointWithinBounds (Point p );boolean allPointsWithinBounds (Points ps ); };
2.12. ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด
ํ๋์ IDL ํ๋๊ทธ๋จผํธ ์งํฉ์ ๋ํ ๊ตฌํ์์๋, ๊ฐ์ฒด๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๊ณ ํ ์ ์์ต๋๋ค.
ํ๋ซํผ ๊ฐ์ฒด๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์ ๋๋ค.
๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด๋
[Global] ํ์ฅ ์์ฑ์ด ์๋
์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ณ ,
์ธ๋ฑ์ค ํ๋กํผํฐ ๋๋
์ด๋ฆ
ํ๋กํผํฐ ๋๋ ๋ ๋ค๋ฅผ ์ง์ํ๋
ํ๋ซํผ ๊ฐ์ฒด์
๋๋ค.
์๋ฅผ ๋ค์ด ๋ธ๋ผ์ฐ์ ์์๋,
๋ธ๋ผ์ฐ์ ๊ฐ ๊ตฌํํ DOM ๊ฐ์ฒด๋ค(Node, Document ๋ฑ ์ธํฐํ์ด์ค ๊ตฌํ)์
ํ์ด์ง ๋ด ์๋ฐ์คํฌ๋ฆฝํธ์์ ์น ํ์ด์ง ๋ด์ฉ์ ์ ๊ทผํ ์ ์๊ฒ ํด์ฃผ๋ ํ๋ซํผ ๊ฐ์ฒด์
๋๋ค. ์ด๋ฐ ๊ฐ์ฒด๋ค์ C++ ๋ฑ์ผ๋ก ๊ตฌํ๋ ํน์ ๊ฐ์ฒด์ผ ์๋ ์๊ณ , ๋ค์ดํฐ๋ธ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด์ผ ์๋
์์ต๋๋ค. ์ด์จ๋ , ํ๋์ IDL ํ๋๊ทธ๋จผํธ ์งํฉ์ ๋ํ ๊ตฌํ์์๋,
๋ชจ๋ ํ๋ซํผ ๊ฐ์ฒด๋ฅผ ์ธ์ํ ์
์์ด์ผ ํฉ๋๋ค. ์ด๊ฒ์ ๋ด๋ถ์ ์ผ๋ก ๊ฐ์ฒด๊ฐ ํ๋ซํผ ๊ฐ์ฒด์์ ๊ธฐ๋กํ๊ฑฐ๋, ๊ฐ์ฒด๊ฐ ํน์ C++ ํด๋์ค์์ ๊ตฌํ๋ ๊ฒ์ ๊ฐ์งํ๋ ๋ฐฉ์ ๋ฑ์ผ๋ก ์ด๋ค์ง ์ ์์ต๋๋ค. ์ด๋ค ๋ฐฉ์์ผ๋ก ์ธ์ํ ์ง๋ ๊ตฌํ์ฒด๋ง๋ค
๋ค๋ฆ
๋๋ค.
์์คํ
๋ด ๋ค๋ฅธ ๊ฐ์ฒด๋ค์ ํ๋ซํผ ๊ฐ์ฒด๋ก ์ทจ๊ธ๋์ง ์์ต๋๋ค. ์๋ฅผ ๋ค์ด,
๋ธ๋ผ์ฐ์ ์์ ์น ํ์ด์ง๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ถ๋ฌ์ DOM Core๋ฅผ ๊ตฌํํ๋ค๊ณ ํด๋,
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ Node ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํด ๋ง๋ ๊ฐ์ฒด๋
๋ธ๋ผ์ฐ์ ๊ตฌํ์ฒด๊ฐ Node๋ฅผ ๊ตฌํํ ํ๋ซํผ ๊ฐ์ฒด๋ก ์ทจ๊ธ๋์ง ์์ต๋๋ค.
๋ฐ๋ฉด ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋
์ด๋ค ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ก๋ ๊ตฌํํ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด ์น API๊ฐ ์ ์(์ฌ์ฉ์) ์ ์ ์ฐ์ฐ์ ํธ์ถํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, DOM Events ๊ตฌํ์์๋
EventListener
์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ๊ฐ์ฒด๋ฅผ ์ฝ๋ฐฑ ๋ฑ๋ก์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
2.13. ํ์
์ด ์ ์์๋ Web IDL์ด ์ง์ํ๋ ํ์ , ๊ฐ ํ์ ์ ๋์ํ๋ ๊ฐ์ ์งํฉ ๋๋ Infra ํ์ , ๊ทธ๋ฆฌ๊ณ ํด๋น ํ์ ์ ์์๊ฐ ์ด๋ป๊ฒ ํํ๋๋์ง๋ฅผ ๋์ดํฉ๋๋ค.
๋ค์ ํ์
์ ์ ์ ํ์
์ผ๋ก ์๋ ค์ ธ
์์ต๋๋ค:
byte,
octet,
short,
unsigned short,
long,
unsigned long,
long long
๋ฐ
unsigned long long์
๋๋ค.
๋ค์ ํ์
์ ์ซ์ ํ์
์ผ๋ก ์๋ ค์ ธ
์์ต๋๋ค:
์ ์ ํ์
,
float,
unrestricted float,
double ๋ฐ
unrestricted double์
๋๋ค.
๊ธฐ๋ณธ ํ์
์
bigint,
boolean
๋ฐ ์ซ์ ํ์
์
๋๋ค.
๋ฌธ์์ด ํ์
์
DOMString,
๋ชจ๋ ์ด๊ฑฐํ ํ์
,
ByteString
๋ฐ USVString์
๋๋ค.
๋ฒํผ ํ์
์
ArrayBuffer
๋ฐ SharedArrayBuffer์
๋๋ค.
ํ์ํ ๋ฐฐ์ด
ํ์
์
Int8Array,
Int16Array,
Int32Array,
Uint8Array,
Uint16Array,
Uint32Array,
Uint8ClampedArray,
BigInt64Array,
BigUint64Array,
Float16Array,
Float32Array,
๋ฐ
Float64Array์
๋๋ค.
๋ฒํผ ๋ทฐ
ํ์
์ DataView
๋ฐ ํ์ํ ๋ฐฐ์ด
ํ์
์
๋๋ค.
๋ฒํผ ์์ค ํ์ ์ ๋ฒํผ ํ์ ๋ฐ ๋ฒํผ ๋ทฐ ํ์ ์ ๋๋ค.
object
ํ์
,
๋ชจ๋ ์ธํฐํ์ด์ค ํ์
๋ฐ
๋ชจ๋ ์ฝ๋ฐฑ
์ธํฐํ์ด์ค ํ์
์
๊ฐ์ฒด
ํ์
์ผ๋ก ์๋ ค์ ธ ์์ต๋๋ค.
์ฐ์ฐ์ ํธ์ถํ๊ฑฐ๋ ์์ฑ์ ๊ฐ์ ํ ๋นํ๊ธฐ ์ํด ์ธ์ด ๋ฐ์ธ๋ฉ๋ณ ํ์ ์์ IDL ํ์ ์ผ๋ก ๋ณํํ ๋์๋, ํ์ํ ๋ชจ๋ ๋ณํ์ด ์ฐ์ฐ ๋๋ ์์ฑ ํ ๋น์ ๋ํด ์ง์ ๋ ๊ธฐ๋ฅ์ด ์ํ๋๊ธฐ ์ ์ ์๋ฃ๋ฉ๋๋ค. ๋ณํ์ ์ํํ ์ ์๋ ๊ฒฝ์ฐ์๋ ์ฐ์ฐ์ด ์คํ๋์ง ์๊ฑฐ๋ ์์ฑ์ด ๊ฐฑ์ ๋์ง ์์ต๋๋ค. ์ผ๋ถ ์ธ์ด ๋ฐ์ธ๋ฉ์์๋ ํ์ ๋ณํ์ผ๋ก ์ธํด ์์ธ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ์ด๋ฌํ ๊ฒฝ์ฐ ํด๋น ์์ธ๋ ์ฐ์ฐ์ ํธ์ถํ๊ฑฐ๋ ์์ฑ์ ๊ฐ์ ํ ๋นํ๋ ค๊ณ ์๋ํ ์ฝ๋๋ก ์ ํ๋ฉ๋๋ค.
Type ::SingleType UnionType Null
TypeWithExtendedAttributes ::ExtendedAttributeList Type
SingleType ::DistinguishableType any PromiseType
UnionType ::( UnionMemberType or UnionMemberType UnionMemberTypes )
UnionMemberType ::ExtendedAttributeList DistinguishableType UnionType Null
UnionMemberTypes ::or UnionMemberType UnionMemberTypes ฮต
DistinguishableType ::PrimitiveType Null StringType Null identifier Null sequence < TypeWithExtendedAttributes > Null async_sequence < TypeWithExtendedAttributes > Null object Null symbol Null BufferRelatedType Null FrozenArray < TypeWithExtendedAttributes > Null ObservableArray < TypeWithExtendedAttributes > Null RecordType Null undefined Null
PrimitiveType ::UnsignedIntegerType UnrestrictedFloatType boolean byte octet bigint
UnrestrictedFloatType ::unrestricted FloatType FloatType
FloatType ::float double
UnsignedIntegerType ::unsigned IntegerType IntegerType
IntegerType ::short long OptionalLong
OptionalLong ::long ฮต
StringType ::ByteString DOMString USVString
PromiseType ::Promise < Type >
RecordType ::record < StringType , TypeWithExtendedAttributes >
Null ::? ฮต
2.13.1. any
any ํ์
์
๋ชจ๋ ๋ค๋ฅธ non-union ํ์
์ ํฉ์งํฉ์
๋๋ค.
any ํ์
์
๊ฐ ๊ฐ์ด ํน์ non-any
ํ์
๊ณผ ์ฐ๊ฒฐ๋์ด ์๋ค๋ ์ ์์ discriminated union ํ์
๊ณผ ์ ์ฌํฉ๋๋ค.
์๋ฅผ ๋ค์ด, any ํ์
์ ํ
๊ฐ์
unsigned long
150์ด๊ณ ,
๋ ๋ค๋ฅธ ๊ฐ์ long
150์
๋๋ค.
์ด ๋์ ์๋ก ๋ค๋ฅธ ๊ฐ์
๋๋ค.
any ๊ฐ์ ํน์ ํ์
์ ํน์ ํ์
์ด๋ผ๊ณ ํฉ๋๋ค.
(union ํ์
์ ๊ฐ๋
ํน์ ํ์
์ ๊ฐ์ง๋๋ค.)
2.13.2. undefined
undefined
ํ์
์ ๊ณ ์ ํ ๊ฐ์ ํ๋๋ง ๊ฐ์ง๋๋ค.
undefined
์์ ๊ฐ์ IDL์์
undefined
ํ์
์ ์ด๋ค ๊ฒฝ์ฐ์๋(์ฐ์ฐ, ์ฝ๋ฐฑ ํจ์, ์์ฑ์ ์ฐ์ฐ ๋ฑ) ์ธ์ ํ์
์ด๋,
๋์
๋๋ฆฌ ๋ฉค๋ฒ ํ์
(์ง์
๋๋ union ๋ด)์ผ๋ก ์ฌ์ฉํด์๋ ์ ๋ฉ๋๋ค.
๋์ ์ต์
์ธ์๋,
non-ํ์ ๋์
๋๋ฆฌ ๋ฉค๋ฒ๋ฅผ ์ฌ์ฉํ์ธ์.
์ฐธ๊ณ : ์ด ๊ฐ์ ์ด์ ์๋ void๋ก ํ๊ธฐ๋์์ผ๋ฉฐ,
์ฌ์ฉ ๋ฐฉ์์ด ๋ ์ ํ์ ์ด์์ต๋๋ค.
2.13.3. boolean
boolean
ํ์
์ ๋ถ๋ฆฌ์ธ๊ณผ
๋์๋ฉ๋๋ค.
boolean
์์ ๊ฐ์
IDL์์
2.13.4. byte
byte ํ์
์
8๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
byte ์์ ๊ฐ์
IDL์์
2.13.5. octet
octet ํ์
์
8๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
octet ์์ ๊ฐ์
IDL์์
2.13.6. short
short ํ์
์
16๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
short ์์ ๊ฐ์
IDL์์
2.13.7. unsigned short
unsigned short
ํ์
์ 16๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
unsigned short
์์ ๊ฐ์ IDL์์
2.13.8. long
long ํ์
์
32๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
long ์์ ๊ฐ์
IDL์์
2.13.9. unsigned long
unsigned long
ํ์
์ 32๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
unsigned long
์์ ๊ฐ์ IDL์์
2.13.10. long long
long long
ํ์
์ 64๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
long long
์์ ๊ฐ์ IDL์์
2.13.11. unsigned long long
unsigned long long
ํ์
์ 64๋นํธ ๋ถํธ ์๋ ์ ์์ ๋์๋ฉ๋๋ค.
unsigned long long
์์ ๊ฐ์ IDL์์
2.13.12. float
float ํ์
์
๋ถ๋์์์ ์ซ์ ํ์
์ผ๋ก,
์ ํํ ๋จ์ ๋ฐ๋ 32๋นํธ IEEE 754 ๋ถ๋์์์ ์ซ์ ์งํฉ์ ๋์ํฉ๋๋ค. [IEEE-754]
float ์์ ๊ฐ์
IDL์์
32๋นํธ ๋ถ๋์์์ ํ์
์ ํน๋ณํ ์จ์ผ ํ ์ด์ ๊ฐ ์๋ค๋ฉด,
double์
float ๋์ ์ฌ์ฉํ๋
๊ฒ์ด ์ข์ต๋๋ค. double์ด ํํํ
์ ์๋ ๊ฐ ์งํฉ์ด JavaScript Number์ ๋ ์ ์ฌํ๊ธฐ ๋๋ฌธ์
๋๋ค.
2.13.13. unrestricted float
unrestricted float
ํ์
์ ๋ถ๋์์์ ์ซ์ ํ์
์ผ๋ก,
๋ชจ๋ ๊ฐ๋ฅํ ๋จ์ ๋ฐ๋ 32๋นํธ IEEE 754 ๋ถ๋์์์ ๊ฐ(์ ํ, ๋ฌดํ ๋ฐ NaN)์ ํฌํจํฉ๋๋ค. [IEEE-754]
unrestricted float
์์ ๊ฐ์ IDL์์
2.13.14. double
double
ํ์
์ ๋ถ๋์์์ ์ซ์ ํ์
์ผ๋ก,
์ ํํ ๋ฐฐ์ ๋ฐ๋ 64๋นํธ IEEE 754 ๋ถ๋์์์ ์ซ์ ์งํฉ์ ๋์ํฉ๋๋ค. [IEEE-754]
double
์์ ๊ฐ์ IDL์์
2.13.15. unrestricted double
unrestricted double
ํ์
์ ๋ถ๋์์์ ์ซ์ ํ์
์ผ๋ก,
๋ชจ๋ ๊ฐ๋ฅํ ๋ฐฐ์ ๋ฐ๋ 64๋นํธ IEEE 754 ๋ถ๋์์์ ๊ฐ(์ ํ, ๋ฌดํ ๋ฐ NaN)์ ํฌํจํฉ๋๋ค. [IEEE-754]
unrestricted double
์์ ๊ฐ์ IDL์์
2.13.16. bigint
bigint
ํ์
์ ๋ฒ์๊ฐ ์ ํ๋์ง ์์ ์์์ ์ ์ ํ์
์
๋๋ค.
bigint
์์ ๊ฐ์ IDL์์
2.13.17. DOMString
DOMString
ํ์
์ ๋ฌธ์์ด๊ณผ ๋์๋ฉ๋๋ค.
์ฐธ๊ณ : DOMString
ํ์
์ ๊ฐ์ด ์๋๋๋ค.
DOMString,
์ฆ IDL์์ DOMString?์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
์ฐธ๊ณ : DOMString
๊ฐ์๋ ๋งค์น๋์ง ์๋ ์๋ก๊ฒ์ดํธ ์ฝ๋ ํฌ์ธํธ๊ฐ ํฌํจ๋ ์ ์์ต๋๋ค. ์ด๋ฅผ ์ํ์ง
์๋ ๊ฒฝ์ฐ USVString์
์ฌ์ฉํ์ธ์.
IDL์์๋ DOMString
์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ๋ค๋ง DOMString
๋์
๋๋ฆฌ ๋ฉค๋ฒ ๊ธฐ๋ณธ๊ฐ์ด๋ ์ฐ์ฐ ์ต์
์ธ์ ๊ธฐ๋ณธ๊ฐ์๋
๋ฌธ์์ด ๋ฆฌํฐ๋ด ํ ํฐ์ ๊ฐ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
2.13.18. ByteString
ByteString
ํ์
์ ๋ฐ์ดํธ ์ํ์ค์ ๋์ํฉ๋๋ค.
IDL์์๋ ์์ ByteString
๊ฐ์ ๋ํ๋ผ ๋ฐฉ๋ฒ์ด ์์ง๋ง, ByteString
์ฌ์
๋ฉค๋ฒ์ ๊ธฐ๋ณธ๊ฐ
๋ฐ ์ฐ์ฐ์
์ ํ์ ์ธ์ ๊ธฐ๋ณธ๊ฐ์
๋ช
์ธ์์๋
ByteString์
HTTP์ ๊ฐ์ด ๋ฐ์ดํธ์ ๋ฌธ์์ด์ ์๋ก ๋ฐ๊พธ์ด ์ฌ์ฉํ๋
ํ๋กํ ์ฝ๊ณผ ์ํธ ์์ฉํ๋ ๊ฒฝ์ฐ์๋ง ์ฌ์ฉํด์ผ ํฉ๋๋ค. ์ผ๋ฐ์ ์ผ๋ก
๋ฌธ์์ด์
DOMString
๊ฐ์ผ๋ก ๋ํ๋ด์ผ ํ๋ฉฐ, ๋ฌธ์์ด์ ๊ฐ์ด ํญ์
ASCII ๋๋ ์ด๋ค 8๋นํธ ๋ฌธ์ ์ธ์ฝ๋ฉ์ ์ํ ๊ฒ์ผ๋ก ์์๋๋ ๊ฒฝ์ฐ์๋
๋ง์ฐฌ๊ฐ์ง์
๋๋ค. octet ๋๋
์ํ์ค๋
๊ณ ์ ๋ฐฐ์ด์
byte
์์๋ฅผ ์ฌ์ฉํ๊ฑฐ๋, Uint8Array,
๋๋ Int8Array๋ฅผ
์ฌ์ฉํ์ฌ 8๋นํธ ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ดํด์ผ ํ๋ฉฐ,
ByteString์
์ฌ์ฉํด์๋ ์ ๋ฉ๋๋ค.
2.13.19. USVString
USVString
ํ์
์
์ค์นผ๋ผ ๊ฐ ๋ฌธ์์ด์ ๋์ํฉ๋๋ค.
๋ฌธ๋งฅ์ ๋ฐ๋ผ
์ด๋ค์ ์ฝ๋
๋จ์์ ์ํ์ค
๋๋ ์ค์นผ๋ผ
๊ฐ์ ์ํ์ค๋ก ์ทจ๊ธํ ์ ์์ต๋๋ค.
IDL์์๋ ์์ USVString
๊ฐ์ ๋ํ๋ผ ๋ฐฉ๋ฒ์ด ์์ง๋ง, USVString
์ฌ์
๋ฉค๋ฒ์ ๊ธฐ๋ณธ๊ฐ
๋ฐ ์ฐ์ฐ์
์ ํ์ ์ธ์ ๊ธฐ๋ณธ๊ฐ์
๋ช
์ธ์๋ USVString์ ํ
์คํธ ์ฒ๋ฆฌ API์์ ์ค์นผ๋ผ
๊ฐ ๋ฌธ์์ด์ด ํ์ํ ๊ฒฝ์ฐ์๋ง ์จ์ผ ํฉ๋๋ค. ๋๋ถ๋ถ์ ๋ฌธ์์ด ์ฌ์ฉ API์์๋ DOMString์ ์จ์ผ ํ๋ฉฐ, ํด๋น ๋ฌธ์์ด์ ์ฝ๋ ์ ๋์ ํด์ํ์ง ์์ต๋๋ค. ํท๊ฐ๋ฆด ๊ฒฝ์ฐ DOMString์ ์ฌ์ฉํ์ธ์.
2.13.20. object
object ํ์
์ ๊ฐ๋ฅํ ๋ชจ๋ non-null ๊ฐ์ฒด ์ฐธ์กฐ ์งํฉ์
๋์ํฉ๋๋ค.
IDL์์๋ object ์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
๋ชจ๋ ๊ฐ์ฒด ์ฐธ์กฐ์ object?๋ฅผ ์ฌ์ฉํ์ธ์.
2.13.21. symbol
symbol
ํ์
์ ๋ชจ๋ ๊ฐ๋ฅํ ์ฌ๋ณผ ๊ฐ ์งํฉ์ ๋์ํฉ๋๋ค. ์ฌ๋ณผ ๊ฐ์ ๋ถํฌ๋ช
ํ๋ฉฐ, object ๊ฐ์ ์๋์ง๋ง ๊ณ ์ ์ฑ(์๊ธฐ ์์ ๊ณผ๋ง ๊ฐ์)์ ๊ฐ์ง๋๋ค.
IDL์์๋ symbol ์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
2.13.22. ์ธํฐํ์ด์ค ํ์
์๋ณ์๊ฐ ์ธํฐํ์ด์ค๋ฅผ ์ง์ ํ๋ฉด, ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ non-null ๊ฐ์ฒด ์ฐธ์กฐ์ ์งํฉ์ ํ์ ์ผ๋ก ์ฐธ์กฐํฉ๋๋ค.
์ธํฐํ์ด์ค ํ์ ์ IDL ๊ฐ์ ๊ฐ์ฒด ์ฐธ์กฐ๋ก ํํ๋ฉ๋๋ค.
ํน์ ์ธํฐํ์ด์ค ํ์ ์ ๋ํ ์์ ๊ฐ์ฒด ์ฐธ์กฐ ๊ฐ์ IDL์์ ํํํ ๋ฐฉ๋ฒ์ ์์ต๋๋ค.
ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด ์ฐธ์กฐ์
2.13.23. ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์
์๋ณ์๊ฐ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ฅผ ์ง์ ํ๋ฉด, ๋ชจ๋ ๊ฐ๋ฅํ non-null ๊ฐ์ฒด ์ฐธ์กฐ ์งํฉ์ ํ์ ์ผ๋ก ์ฐธ์กฐํฉ๋๋ค.
์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ์ IDL ๊ฐ์ ๊ฐ์ฒด ์ฐธ์กฐ์ ์ฝ๋ฐฑ ์ปจํ ์คํธ์ ํํ๋ก ํํ๋ฉ๋๋ค. ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ ์ธ์ด ๋ฐ์ธ๋ฉ๋ณ ๊ฐ์ด๋ฉฐ, ๊ฐ์ฒด ์ฐธ์กฐ๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํ ๋์ ์คํ ์ปจํ ์คํธ ์ ๋ณด๋ฅผ ์ ์ฅํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด์์๋ ์ฝ๋ฐฑ ์ปจํ ์คํธ์ Object ๊ฐ์ด IDL ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ์ผ๋ก ๋ณํ๋ ๋์ incumbent settings object ์ฐธ์กฐ๊ฐ ์ ์ฅ๋ฉ๋๋ค. ยงโฏ3.2.16 Callback interface types ์ฐธ๊ณ .
ํน์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ์ ๋ํ ์์ ๊ฐ์ฒด ์ฐธ์กฐ ๊ฐ์ IDL์์ ํํํ ๋ฐฉ๋ฒ์ ์์ต๋๋ค.
๋ชจ๋ ๊ฐ์ฒด ์ฐธ์กฐ์
2.13.24. ๋์ ๋๋ฆฌ ํ์
์๋ณ์๊ฐ ๋์ ๋๋ฆฌ๋ฅผ ์ง์ ํ๋ฉด, ํด๋น ๋์ ๋๋ฆฌ ์ ์๋ฅผ ๋ฐ๋ฅด๋ ๋ชจ๋ ๋์ ๋๋ฆฌ ์งํฉ์ ํ์ ์ผ๋ก ์ฐธ์กฐํฉ๋๋ค.
์์ ์๋ ๋งต์ ๋ฆฌํฐ๋ด ๋ฌธ๋ฒ๋, ๋งต์ด ํน์ ๋์ ๋๋ฆฌ ํ์ ์ธ์คํด์ค๋ก ๊ฐ์ฃผ๋๋ค๋ ๊ฒ ๋ฌธ๋งฅ์์ ๋ช ํํ๋ค๋ฉด ๋์ ๋๋ฆฌ ํํ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ IDL ํ๋๊ทธ๋จผํธ ๋ด์ ์์ ๋์ ๋๋ฆฌ ๊ฐ์ ํํํ๋ ๋ฐฉ๋ฒ์ ์์ต๋๋ค.
2.13.25. ์ด๊ฑฐํ ํ์
์๋ณ์๊ฐ
์ด๊ฑฐํ์ ์๋ณํ๋ ๊ฒฝ์ฐ
๊ทธ ์๋ณ์๋
๊ฐ์ด ๋ฌธ์์ด ์งํฉ(์ฝ๋
๋จ์์ ์ํ์ค์ด๋ฉฐ,
DOMString๊ณผ
๊ฐ์)์ธ ํ์
์
์ฐธ์กฐํ๋ ๋ฐ
์ฌ์ฉ๋๋ฉฐ, ์ด ๋ฌธ์์ด๋ค์
์ด๊ฑฐํ์
๊ฐ์
๋๋ค.
DOMString๊ณผ
๋ง์ฐฌ๊ฐ์ง๋ก,
IDL์์๋ ์์ ์ด๊ฑฐํ
๊ฐ์ ๋ํ๋ผ ๋ฐฉ๋ฒ์ด ์์ง๋ง, ์ด๊ฑฐํ ํ์
์ ์ฌ์ ๋ฉค๋ฒ ๊ธฐ๋ณธ
๊ฐ
๋ฐ ์ฐ์ฐ์
์ ํ์ ์ธ์ ๊ธฐ๋ณธ๊ฐ์
2.13.26. ์ฝ๋ฐฑ ํจ์ ํ์
์๋ณ์๊ฐ ์ฝ๋ฐฑ ํจ์๋ฅผ ์ง์ ํ๋ฉด, ํด๋น ์๊ทธ๋์ฒ์ ํจ์ ๊ฐ์ฒด ์ฐธ์กฐ ์งํฉ์ ํ์ ์ผ๋ก ์ฐธ์กฐํฉ๋๋ค.
์ฐธ๊ณ : [LegacyTreatNonObjectAsNull]
ํ์ฅ ์์ฑ์ด ์ฝ๋ฐฑ ํจ์ ์ ์์ ์ง์ ๋ ๊ฒฝ์ฐ, ํจ์๊ฐ ์๋ ๊ฐ์ฒด ์ฐธ์กฐ๋ ๊ฐ์ด ๋ ์ ์์ต๋๋ค.
์ฝ๋ฐฑ ํจ์ ํ์ ์ IDL ๊ฐ์ ๊ฐ์ฒด ์ฐธ์กฐ์ ์ฝ๋ฐฑ ์ปจํ ์คํธ์ ํํ๋ก ํํ๋ฉ๋๋ค.
์ฐธ๊ณ : ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก, ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ ์๋ฐ์คํฌ๋ฆฝํธ Object ๊ฐ์ด IDL ์ฝ๋ฐฑ ํจ์ ํ์ ๊ฐ์ผ๋ก ๋ณํ๋ ๋์ incumbent settings object ์ฐธ์กฐ๋ฅผ ์ ์ฅํ๋ ๋ฐ ์ฐ์ ๋๋ค. ยงโฏ3.2.19 Callback function types ์ฐธ๊ณ .
IDL์์๋ ์ฝ๋ฐฑ ํจ์ ์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
2.13.27. ๋ ํ์ฉ ํ์ โ T?
๋ ํ์ฉ ํ์
์ ๊ธฐ์กด ํ์
(์ด๋ฅผ
๋ด๋ถ ํ์
์ด๋ผ ํจ)์์
-
any, -
๋ค๋ฅธ ๋ ํ์ฉ ํ์ ,
-
์์ฒด๊ฐ ๋ ํ์ฉ ํ์ ์ ํฌํจํ๊ฑฐ๋, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ๋์ ๋๋ฆฌ ํ์ ์ด ์๋ ์ ๋์จ ํ์ .
์ฐธ๊ณ : ๋์ ๋๋ฆฌ ํ์ ์ ์ผ๋ฐ์ ์ผ๋ก ๋ ํ์ฉ์ผ ์ ์์ง๋ง, ์ฐ์ฐ ์ธ์ ๋๋ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ํ์ ์ผ๋ก ์ฌ์ฉ๋๋ ๊ฒฝ์ฐ์๋ ๋ ํ์ฉ์ผ ์ ์์ต๋๋ค.
์์์ ํ์ ๋๋ ํ์ ๋ฒ์ฃผ X์ ๋ํด, ์ ์ฌ์ ์ผ๋ก ๋ ํ์ฉ X๋ X์ด๊ฑฐ๋ ๋ ํ์ฉ ํ์ ์ด๋ฉฐ, ๊ทธ ๋ด๋ถ ํ์ ์ X์ ๋๋ค.
IDL์์ ๋ ํ์ฉ ํ์
์์ ๊ฐ์
ํด๋น ๋ด๋ถ
ํ์
์ ์์ ๊ฐ๊ณผ
๊ฐ์ ๋ฐฉ์์ผ๋ก ํํ๋๊ฑฐ๋
์๋ฅผ ๋ค์ด, boolean?์ผ๋ก ํ๊ธฐํฉ๋๋ค:
[Exposed =Window ]interface NetworkFetcher {undefined get (optional boolean ?areWeThereYet =false ); };
๋ค์ ์ธํฐํ์ด์ค์๋ ๋ ๊ฐ์ ์์ฑ์ด ์์ต๋๋ค. ํ๋๋ DOMString
๋๋
Node ๊ฐ์ฒด ์ฐธ์กฐ ๋๋
[Exposed =Window ]interface Node {readonly attribute DOMString ?namespaceURI ;readonly attribute Node ?parentNode ; // ... };
2.13.28. ์ํ์ค ํ์ โ sequence<T>
sequence<T> ํ์ ์ (๊ธธ์ด๊ฐ 0์ผ ์๋ ์๋) ๋ฆฌ์คํธ๋ก, ๊ฐ ๊ฐ์ด T ํ์ ์ธ ๋ฆฌ์คํธ ํ์ ์ ๋๋ค.
์ํ์ค๋ ํญ์ ๊ฐ์ผ๋ก ์ ๋ฌ๋ฉ๋๋ค. ์ํ์ค๊ฐ ์ด๋ค ๊ฐ์ฒด๋ก ํํ๋๋ ์ธ์ด ๋ฐ์ธ๋ฉ์์๋, ์ํ์ค๋ฅผ ํ๋ซํผ ๊ฐ์ฒด์ ์ ๋ฌํด๋ ํด๋น ๊ฐ์ฒด์ ์ํ์ค ์ฐธ์กฐ๊ฐ ๋จ์ง ์์ต๋๋ค. ๋ง์ฐฌ๊ฐ์ง๋ก ํ๋ซํผ ๊ฐ์ฒด์์ ๋ฐํ๋ ์ํ์ค๋ ๋ณต์ฌ๋ณธ์ด๋ฉฐ, ์ด๋ฅผ ์์ ํด๋ ํ๋ซํผ ๊ฐ์ฒด์๋ ์ํฅ์ ๋ฏธ์น์ง ์์ต๋๋ค.
๋ฆฌ์คํธ์ ๋ฆฌํฐ๋ด ๋ฌธ๋ฒ๋, ๋ฆฌ์คํธ๊ฐ ์ํ์ค ํ์ ์ธ์คํด์ค๋ก ๊ฐ์ฃผ๋๋ค๋ ๊ฒ ๋ฌธ๋งฅ์์ ๋ช ํํ๋ค๋ฉด ์ํ์ค ํํ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ํ์ง๋ง IDL ํ๋๊ทธ๋จผํธ ๋ด์ ์์ ์ํ์ค ๊ฐ์ ํํํ๋ ๋ฐฉ๋ฒ์ ์์ต๋๋ค.
์ํ์ค๋ ์์ฑ์ด๋ ์์ ํ์ ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ฐธ๊ณ : ์ด ์ ํ์ ๋ช ์ธ ์์ฑ์์ API ์ฌ์ฉ์์๊ฒ ์ํ์ค๊ฐ ์ฐธ์กฐ๊ฐ ์๋ ๋ณต์ฌ๋ณธ์ผ๋ก ์ ๋ฌ๋๋ค๋ ์ ์ ๋ช ํํ ํ๊ธฐ ์ํ ๊ฒ์ ๋๋ค. ์ํ์ค ํ์ ์ ์์ฑ ๋์ , ์ํ์ค๋ฅผ get/setํ๋ ์ฐ์ฐ์ ์์ผ๋ก ์ ๊ณตํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ด๋ค ๋ฆฌ์คํธ๋, ๊ทธ ํญ๋ชฉ์ด ๋ชจ๋ T ํ์
์ด๋ฉด ์๋ฌต์ ์ผ๋ก
sequence<T>๋ก ๊ฐ์ฃผํ ์ ์์ต๋๋ค.
2.13.29. ๋น๋๊ธฐ ์ํ์ค ํ์ โ async_sequence<T>
async_sequence ํ์ ์ T ํ์ ๊ฐ์ ๋น๋๊ธฐ์ ์ผ๋ก ์ดํฐ๋ ์ด์ ํ ์ ์๋(๋ฌดํ ๊ฐ๋ฅ์ฑ ํฌํจ) ๊ฐ์ฒด ์ฐธ์กฐ ์งํฉ์ ํ์ ์ผ๋ก ํ๋ ํ๋ผ๋ฏธํฐํ ํ์ ์ ๋๋ค.
์ํ์ค์ ๋ฌ๋ฆฌ, ๋น๋๊ธฐ ์ํ์ค๋ ๊ณ ์ ๊ธธ์ด ๋ฆฌ์คํธ๊ฐ ์๋๋ผ ๋ชจ๋ ๊ฐ์ด ๋ฏธ๋ฆฌ ์๋ ค์ง ์ํ๊ฐ ์๋๋๋ค. async_sequence๋ก ์์ฑ๋ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ํ์ค๋ lazyํ๋ฉฐ, ๊ฐ์ ์ดํฐ๋ ์ด์ ์ค์๋ง ๋น๋๊ธฐ์ ์ผ๋ก ์์ฑ๋ ์ ์์ผ๋ฏ๋ก, ๊ฐ์ด๋ ๊ธธ์ด๋ ์ํ์ค ์์ฑ ์์ ์ ์ ์ ์์ต๋๋ค.
์ธ์ด ๋ฐ์ธ๋ฉ์์ async_sequence๊ฐ ๊ฐ์ฒด๋ก ํํ๋๋ ๊ฒฝ์ฐ ์ฐธ์กฐ๋ก ์ ๋ฌ๋ฉ๋๋ค. ์ฆ, async_sequence๋ฅผ ํ๋ซํผ ๊ฐ์ฒด์ ์ ๋ฌํ๋ฉด ํด๋น ๊ฐ์ฒด์ ์ฐธ์กฐ๊ฐ ๋จ์ต๋๋ค. ํ๋ซํผ ๊ฐ์ฒด์์ ๋ฐํ๋ async_sequence๋ ๋์ผ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ์ด๋ฉฐ, ์ด๋ฅผ ์์ ํ๋ฉด ํ๋ซํผ ๊ฐ์ฒด์ ์ํฅ์ ๋ฏธ์นฉ๋๋ค. ์ด๋ ํญ์ ๊ฐ์ผ๋ก ์ ๋ฌ๋๋ ์ํ์ค์๋ ๋ค๋ฆ ๋๋ค.
์ฐธ๊ณ : async_sequence๋ IDL์์ ์์ฑํ ์ ์์ต๋๋ค. ์ฐ์ฐ์์ ๋ฐํํ๊ฑฐ๋ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ ํ์ ์ผ๋ก ์ธ ๊ฒฝ์ฐ, async_sequence๋ ํธ์คํธ ํ๊ฒฝ์์ ์์ฑ๋์ด ์ธ์ด ๋ฐ์ธ๋ฉ์ ํตํด IDL ํ์ ์ผ๋ก ๋ณํ๋ ๊ฒ์ ๋๋ค. ์ฐ์ฐ์์ async_sequence๋ฅผ ๋ฐํํ๋ ๋์ , ์ธํฐํ์ด์ค๋ฅผ ๋ฐํํ๊ณ ๊ทธ ์ธํฐํ์ด์ค์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ๋ฌ์ผ ํ ์ ์์ต๋๋ค.
async_sequence๋ ์์ฑ์ด๋ ์์ ํ์ ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
IDL์์๋ async_sequence ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
2.13.30. ๋ ์ฝ๋ ํ์ โ record<K, V>
๋ ์ฝ๋ ํ์
์
๊ฐ์ด ์์๊ฐ
์๋ ๋งต์ธ ๋งค๊ฐ๋ณ์ํ๋ ํ์
์ด๋ฉฐ,
ํค๋ K์ ์ธ์คํด์ค์ด๊ณ ๊ฐ์
V์ ์ธ์คํด์ค์
๋๋ค. K๋
๋ค์ ์ค
ํ๋์ฌ์ผ ํฉ๋๋ค. DOMString,
USVString,
๋๋ ByteString.
์์๊ฐ ์๋ ๋งต์ ๋ฆฌํฐ๋ด ๊ตฌ๋ฌธ์ ๋ฌธ๋งฅ์ ํด๋น ๋งต์ด ๋ ์ฝ๋๋ก ์ทจ๊ธ๋๋ค๋ ๊ฒ์ด ์๋ฌต์ ์ผ๋ก ์ดํด๋๋ ๊ฒฝ์ฐ ๋ ์ฝ๋๋ฅผ ๋ํ๋ด๋ ๋ฐ์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ IDL ์กฐ๊ฐ ๋ด๋ถ์์ ์์ ๋ ์ฝ๋ ๊ฐ์ ๋ํ๋ผ ๋ฐฉ๋ฒ์ ์์ต๋๋ค.
๋ ์ฝ๋๋ ํญ์ ๊ฐ์ผ๋ก ์ ๋ฌ๋ฉ๋๋ค. ๋ ์ฝ๋๊ฐ ์ด๋ค ์ข ๋ฅ์ ๊ฐ์ฒด๋ก ํํ๋๋ ์ธ์ด ๋ฐ์ธ๋ฉ์์ ๋ ์ฝ๋๋ฅผ ํ๋ซํผ ๊ฐ์ฒด์ ์ ๋ฌํด๋ ํด๋น ๊ฐ์ฒด๊ฐ ๋ ์ฝ๋์ ๋ํ ์ฐธ์กฐ๋ฅผ ์ ์งํ๊ฒ ๋์ง๋ ์์ต๋๋ค. ๋ง์ฐฌ๊ฐ์ง๋ก ํ๋ซํผ ๊ฐ์ฒด์์ ๋ฐํ๋ ๋ชจ๋ ๋ ์ฝ๋๋ ๋ณต์ฌ๋ณธ์ด๋ฉฐ, ์ฌ๊ธฐ์ ๊ฐํ ์์ ์ฌํญ์ ํ๋ซํผ ๊ฐ์ฒด์ ํ์๋์ง ์์ต๋๋ค.
๋ ์ฝ๋๋ ์์ฑ ๋๋ ์์์ ํ์ ์ผ๋ก ์ฌ์ฉํด์๋ ์ ๋ฉ๋๋ค.
๋ชจ๋ ์์๊ฐ ์๋
๋งต์ ๋ค์ ์กฐ๊ฑด์ ์ถฉ์กฑํ๋ ํ ์๋ฌต์ ์ผ๋ก
record<K, V>๋ก ์ทจ๊ธํ ์ ์์ต๋๋ค.
ํด๋น ๋งต์๋ ํญ๋ชฉ๋ง ํฌํจ๋์ด์ผ ํ๋ฉฐ, ๊ทธ ํค๋
๋ชจ๋ K ํ์
์ด๊ณ ๊ทธ ๊ฐ์
๋ชจ๋ V ํ์
์ด์ด์ผ ํฉ๋๋ค.
2.13.31. ํ๋ผ๋ฏธ์ค ํ์ โ Promise<T>
ํ๋ผ๋ฏธ์ค ํ์ ์ ํ๋ผ๋ฏธํฐํ๋ ํ์ ์ผ๋ก, ๊ฐ์ด ๋น๋๊ธฐ ์์ ์ ๊ฒฐ๊ณผ๋ฅผ ๋์ค์ ๋ฐ์ ์ ์๋ โ์๋ฆฌ ํ์์โ ๊ฐ์ฒด ์ฐธ์กฐ์ ๋๋ค. ์์ธํ ํ๋ผ๋ฏธ์ค ๊ฐ์ฒด ์๋ฏธ๋ JavaScript ๋ช ์ธ section 25.4 ์ฐธ๊ณ .
ํ๋ผ๋ฏธ์ค ํ์ ์ ๋ ํ์ฉ์ด ์๋์ง๋ง, T๋ ๋ ํ์ฉ์ผ ์ ์์ต๋๋ค.
IDL์์๋ ํ๋ผ๋ฏธ์ค ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
2.13.32. ์ ๋์จ ํ์
์ ๋์จ ํ์
์ ๊ฐ ์งํฉ์ด ๋ ๊ฐ ์ด์์
ํ์
๊ฐ ์งํฉ์ ํฉ์งํฉ์ด ๋๋ ํ์
์
๋๋ค. ์ ๋์จ ํ์
(
์๋ฅผ ๋ค์ด (Node or DOMString) ๋๋ (double or sequence<double>)์ฒ๋ผ ์ธ ์ ์์ต๋๋ค. ์ ๋์จ
ํ์
์ ์ฒด์ (Node or DOMString)?์ฒ๋ผ ํ๊ธฐํฉ๋๋ค.
์ ๋์จ ํ์
์ ๋ฉค๋ฒ ํ์
์ ์ค์ฒฉ๋ ์ ๋์จ ํ์
์๊น์ง ๋ด๋ ค๊ฐ์ง ์์ต๋๋ค. ์๋ฅผ ๋ค์ด
(double or (sequence<long> or Event) or (Node or DOMString)?)์ ๋ฉค๋ฒ ํ์
์
double, (sequence<long> or Event), (Node or DOMString)?์
๋๋ค.
any ํ์
์ฒ๋ผ, ์ ๋์จ ํ์
๊ฐ๋ ํน์ ํ์
์ ๊ฐ์ง๋ฉฐ, ์ด๋ ํด๋น ๊ฐ๊ณผ ์ผ์นํ๋ ๋ฉค๋ฒ ํ์
์
๋๋ค.
์ ๋์ธ ํ์ ์ ํํํ๋ ๋ฉค๋ฒ ํ์ ์, ๊ฒฝ์ฐ์ ๋ฐ๋ผ ์ฃผ์์ด ์ง์ ๋ ์ ์์ผ๋ฉฐ, ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ๋๋ ํ์ ์ ์งํฉ์ ๋๋ค:
-
T๋ฅผ ์ ๋์ธ ํ์ ์ผ๋ก ๋ก๋๋ค.
-
S๋ฅผ โ ๋ก ์ด๊ธฐํํฉ๋๋ค.
-
T์ ๊ฐ ๋ฉค๋ฒ ํ์ U์ ๋ํด:
-
U๊ฐ ์ฃผ์์ด ์ง์ ๋ ํ์ ์ธ ๊ฒฝ์ฐ, U๋ฅผ U์ ๋ด๋ถ ํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
U๊ฐ ๋ ํ์ฉ ํ์ ์ธ ๊ฒฝ์ฐ, U๋ฅผ U์ ๋ด๋ถ ํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
U๊ฐ ์ ๋์ธ ํ์ ์ธ ๊ฒฝ์ฐ, S์ U์ ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, U๋ ์ ๋์ธ ํ์ ์ด ์๋๋๋ค. U๋ฅผ S์ ์ถ๊ฐํฉ๋๋ค.
-
-
S๋ฅผ ๋ฐํํฉ๋๋ค.
์ฐธ๊ณ : ์๋ฅผ ๋ค์ด, ์ ๋์จ ํ์
(Node or (sequence<long> or Event) or (XMLHttpRequest or DOMString)? or sequence<(sequence<double> or NodeList)>)์
ํํํ๋ ๋ฉค๋ฒ ํ์
์ Node,
sequence<long>, Event, XMLHttpRequest, DOMString,
sequence<(sequence<double> or NodeList)>์
๋๋ค.
๋ ํ์ฉ ๋ฉค๋ฒ ํ์ ์ ์๋ ์ ๋์ธ ํ์ ์ ๋ํด ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ๋๋ ์ ์์ ๋๋ค:
-
T๋ฅผ ์ ๋์ธ ํ์ ์ผ๋ก ๋ก๋๋ค.
-
n์ 0์ผ๋ก ์ด๊ธฐํํฉ๋๋ค.
-
T์ ๊ฐ ๋ฉค๋ฒ ํ์ U์ ๋ํด:
-
U๊ฐ ๋ ํ์ฉ ํ์ ์ธ ๊ฒฝ์ฐ:
-
n์ n + 1๋ก ์ค์ ํฉ๋๋ค.
-
U๋ฅผ U์ ๋ด๋ถ ํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
-
U๊ฐ ์ ๋์ธ ํ์ ์ธ ๊ฒฝ์ฐ:
-
m์ U์ ๋ ํ์ฉ ๋ฉค๋ฒ ํ์ ์ ์๋ก ๋ก๋๋ค.
-
n์ n + m์ผ๋ก ์ค์ ํฉ๋๋ค.
-
-
-
n์ ๋ฐํํฉ๋๋ค.
any ํ์
์
์ ๋์ธ
๋ฉค๋ฒ ํ์
์ผ๋ก ์ฌ์ฉํด์๋
์ ๋ฉ๋๋ค.
๋ ํ์ฉ ๋ฉค๋ฒ ํ์ ์ ์๋ ์ ๋์ธ ํ์ ์์ ๋ฐ๋์ 0 ๋๋ 1์ด์ด์ผ ํ๋ฉฐ, 1์ธ ๊ฒฝ์ฐ ์ ๋์ธ ํ์ ์ ๋์ ๋๋ฆฌ ํ์ ์ด ํํํ๋ ๋ฉค๋ฒ ํ์ ์๋ ์์ด์๋ ์ ๋ฉ๋๋ค.
ํ์ ์ด ๋ค์ ์กฐ๊ฑด์ ์ถฉ์กฑํ๋ฉด ๋ ํ์ฉ ํ์ ์ ํฌํจํฉ๋๋ค:
-
ํ์ ์ด ๋ ํ์ฉ ํ์ ์ด๊ฑฐ๋,
-
ํ์ ์ด ์ฃผ์์ด ์ง์ ๋ ํ์ ์ด๊ณ ๊ทธ ๋ด๋ถ ํ์ ์ด ๋ ํ์ฉ ํ์ ์ด๊ฑฐ๋,
-
ํ์ ์ด ์ ๋์ธ ํ์ ์ด๊ณ ๊ทธ ๋ ํ์ฉ ๋ฉค๋ฒ ํ์ ์ ์๊ฐ 1์ ๋๋ค.
์ ๋์ธ ํ์ ์ ์๋ ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ๊ฐ ์, T์ U๋ ๋ฐ๋์ ๊ตฌ๋ณ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค.
bigint์
์ซ์ ํ์
์ ์ ๋์ธ์ ๋ง๋ค ์ ์์ต๋๋ค.
๊ทธ๋ฌ๋ ์ด๋ ์ผ๋ฐ์ ์ผ๋ก ๊ฐ์ ์ฌ์ฉํ๋ ๋์ ํ์์ ์ง์ ํ๋
NumberFormat๊ณผ ๊ฐ์ ์ธํฐํ์ด์ค์๋ง ์ฌ์ฉํ๋๋ก
์๋๋ ๊ฒ์
๋๋ค.
๊ณ์ฐ์ ๊ฐ์ ์ฌ์ฉํ๋ ๊ฒ์ด ์๋๋๋ค.
์ด๋ฌํ ์ ๋์ธ์ ๋ฐ์๋ค์ธ ๋ค์
์ซ์ ํ์
์ ๊ฐ์ bigint๋ก ๋ณํํ์ฌ
์ถ๊ฐ๋ก ์ฒ๋ฆฌํ๋ ๊ฒ์ ์ ์ ํ์ง ์์ต๋๋ค. ์ด๋
์ ๋ฐ๋ ์ค๋ฅ๋ฅผ ๋ฐ์์ํฌ ์ํ์ด ์๊ธฐ ๋๋ฌธ์
๋๋ค.
์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ๊ธฐ ์ ์
์ด์๋ฅผ
์ ์ถํด
์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
ํ์ ์ด ๋ค์ ์กฐ๊ฑด์ ์ถฉ์กฑํ๋ฉด undefined๋ฅผ ํฌํจํฉ๋๋ค:
-
ํ์ ์ด
undefined์ด๊ฑฐ๋, ๋๋ -
ํ์ ์ด ๋ ํ์ฉ ํ์ ์ด๊ณ ๊ทธ ๋ด๋ถ ํ์ ์ด undefined๋ฅผ ํฌํจํ๊ฑฐ๋,
-
ํ์ ์ด ์ฃผ์์ด ์ง์ ๋ ํ์ ์ด๊ณ ๊ทธ ๋ด๋ถ ํ์ ์ด undefined๋ฅผ ํฌํจํ๊ฑฐ๋,
-
ํ์ ์ด ์ ๋์ธ ํ์ ์ด๊ณ ๊ทธ ๋ฉค๋ฒ ํ์ ์ค ํ๋๊ฐ undefined๋ฅผ ํฌํจํฉ๋๋ค.
IDL์์ ์ ๋์ธ ํ์ ์์ ๊ฐ์ ํด๋น ๋ฉค๋ฒ ํ์ ์ ์์ ๊ฐ๊ณผ ๋์ผํ ๋ฐฉ์์ผ๋ก ํํ๋ฉ๋๋ค.
DistinguishableType ::PrimitiveType Null StringType Null identifier Null sequence < TypeWithExtendedAttributes > Null async_sequence < TypeWithExtendedAttributes > Null object Null symbol Null BufferRelatedType Null FrozenArray < TypeWithExtendedAttributes > Null ObservableArray < TypeWithExtendedAttributes > Null RecordType Null undefined Null
2.13.33. ์ฃผ์ ํ์
ํน์ ํ์ฅ ์์ฑ์ ๊ธฐ์กด ํ์ ์ ์ง์ ํ๋ฉด ์ถ๊ฐ ํ์ ์ ๋ง๋ค ์ ์์ต๋๋ค. ์ด๋ฌํ ํ์ ์ ์ฃผ์ ํ์ ์ด๋ผ ํ๋ฉฐ, ์ด๋ค์ด ์ฃผ์์ ๋ค๋ ํ์ ์ ๋ด๋ถ ํ์ ์ด๋ผ ํฉ๋๋ค.
[Clamp] long์ ์ฃผ์
ํ์
์ ์ ์ํฉ๋๋ค. ์ด ํ์
์ ๋ด๋ถ ํ์
long์ ๋์์ ๊ธฐ๋ฐ์ผ๋ก
ํ์ง๋ง, [Clamp] ํ์ฅ ์์ฑ์
์ง์ ๋ ๋๋ก ๋์์ด ์์ ๋ฉ๋๋ค.
์๋ ํ์ฅ ์์ฑ๋ค์ด ํ์
์ ์ ์ฉ ๊ฐ๋ฅํฉ๋๋ค:
[AllowResizable],
[AllowShared],
[Clamp],
[EnforceRange],
๊ทธ๋ฆฌ๊ณ
[LegacyNullToEmptyString].
-
extended attributes๋ฅผ ์๋ก์ด ๋น ์งํฉ์ผ๋ก ๋ก๋๋ค.
-
type์ด
Type ์ด๊ณ , ๋ฐ๋ก ๋ค์ ๋ด๋ถ์ ์๋TypeWithExtendedAttributes ์์ฑ ๊ท์น์ ํด๋นํ๋ค๋ฉด, ์ถ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ ํ์ฅ ์์ฑ ์ค ์์ฑ ๊ท์น์ExtendedAttributeList ์ ์๋ ๊ฐ๊ฐ์ extended attributes์ ์ถ๊ฐํฉ๋๋ค. -
type์ด ๋ฉค๋ฒ ํ์ ์ด๊ณ ์ ๋์ธ ํ์ U์ ๋ฉค๋ฒ๋ผ๋ฉด, ์ถ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ ์ฐ๊ฒฐ๋ ํ์ฅ ์์ฑ U์ ๊ฒ์ extended attributes์ ์ถ๊ฐํฉ๋๋ค.
-
type์ด ๋ด๋ถ ํ์ ์ด๊ณ ๋ ํ์ฉ ํ์ N์ ๊ฒ์ด๋ผ๋ฉด, ์ถ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ ์ฐ๊ฒฐ๋ ํ์ฅ ์์ฑ N์ ๊ฒ์ extended attributes์ ์ถ๊ฐํฉ๋๋ค.
-
type์ด ์ธ์ A์ ํ์ ์ด๊ณ ํด๋น ์ธ์๊ฐ
optional ํค์๋๋ก ์ ์ธ๋์ง ์์๋ค๋ฉด, ์ถ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ extended attributes์ ๋ค์์ ๋ชจ๋ ํ์ฅ ์์ฑ ์คExtendedAttributeList ์ ์์ผ๋ฉฐ A์Argument ์์ฑ ๊ท์น์ ์ํ๊ณ ํ์ ์ ์ ์ฉ ๊ฐ๋ฅํ ๊ฒ๋ค์ ์ถ๊ฐํฉ๋๋ค.[
Exposed =Window ]interface I {undefined f ([XAttr ]long attrib ); };[
XAttr]์ด ๋ค์ ์กฐ๊ฑด์ ์ถฉ์กฑํ๋ ๊ฒฝ์ฐ์๋ง ์ด๊ฒ์ด ์ด ๋จ๊ณ์ ์์์ ์ ์ํ์ญ์์ค. ์ฆ, ํ์ ์ ์ ์ฉ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด [XAttr]์ ์ธ์์ ์ ์ฉ๋๋ ๊ฒ์ด๋ฉฐ, ์ธ์์ ํ์ ์๋ ์ ์ฉ๋์ง ์์ต๋๋ค. -
type์ด ๋์ ๋๋ฆฌ ๋ฉค๋ฒ M์ ํ์ ์ด๊ณ ํด๋น ๋ฉค๋ฒ๊ฐ ํ์๊ฐ ์๋๋ผ๋ฉด, ์ถ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ extended attributes์ ๋ค์์ ๋ชจ๋ ํ์ฅ ์์ฑ ์ค
ExtendedAttributeList ์ ์์ผ๋ฉฐ M์DictionaryMember ์์ฑ ๊ท์น์ ์ํ๊ณ ํ์ ์ ์ ์ฉ ๊ฐ๋ฅํ ๊ฒ๋ค์ ์ถ๊ฐํฉ๋๋ค.dictionary D { [XAttr ]long member ; };[
XAttr]์ด ๋ค์ ์กฐ๊ฑด์ ์ถฉ์กฑํ๋ ๊ฒฝ์ฐ์๋ง ์ด๊ฒ์ด ์ด ๋จ๊ณ์ ์์์ ์ ์ํ์ญ์์ค. ์ฆ, ํ์ ์ ์ ์ฉ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด [XAttr]์ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ์ ์ฉ๋๋ ๊ฒ์ด๋ฉฐ, ๋ฉค๋ฒ์ ํ์ ์๋ ์ ์ฉ๋์ง ์์ต๋๋ค. -
type์ด typedef์ธ ๊ฒฝ์ฐ, ์ถ๊ฐ๋ฅผ ์ฌ์ฉํ์ฌ ์ฐ๊ฒฐ๋ ํ์ฅ ์์ฑ ์ค ์ ์ด๋ฆ์ด ๋ถ์ฌ๋๋ ํ์ ๊ณผ ์ฐ๊ฒฐ๋ ๊ฒ์ extended attributes์ ์ถ๊ฐํฉ๋๋ค.
-
extended attributes๋ฅผ ๋ฐํํฉ๋๋ค.
์ด๋ค ํ์ ์ ๋ํด์๋, ๊ทธ ํ์ ๊ณผ ์ฐ๊ฒฐ๋ ํ์ฅ ์์ฑ์ ๋ฐ๋์ ํ์ฅ ์์ฑ ์ค ํ์ ์ ์ ์ฉ ๊ฐ๋ฅํ ๊ฒ๋ง ํฌํจํด์ผ ํฉ๋๋ค.
2.13.34. ๋ฒํผ ์์ค ํ์
๋ฐ์ดํฐ ๋ฒํผ๋ ๋ฒํผ ๋ทฐ ๊ฐ์ฒด์ ๋ํ ๋ชจ๋ non-null ์ฐธ์กฐ ์งํฉ์ ๋์ํ๋ ํ์ ๋ค์ด ์์ต๋๋ค. ์๋ ํ๋ ๊ฐ ํ์ ๊ณผ ํด๋น ํ์ ์ด ํํํ๋ ๋ฒํผ/๋ทฐ ์ข ๋ฅ๋ฅผ ๋ํ๋ ๋๋ค.
| ํ์ | ๋ฒํผ ์ข ๋ฅ |
|---|---|
ArrayBuffer
|
๊ณ ์ ๋ ๋ฐ์ดํธ ์์ ๋ฒํผ๋ฅผ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ(๋ ๊ฐ๋ฅ)๋ฅผ ๊ฐ์ง ๊ฐ์ฒด |
SharedArrayBuffer
|
๊ณ ์ ๋ ๋ฐ์ดํธ ์์ ๊ณต์ ๋ฒํผ๋ฅผ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ(๋ ๋ถ๊ฐ)๋ฅผ ๊ฐ์ง ๊ฐ์ฒด |
DataView
|
์์ ์คํ์ ์์ ์ ์, ๋ถ๋์์์ ๊ฐ์ ํ์ ๋ณ๋ก ์ ๊ทผํ ์ ์๋ ๋ฒํผ ํ์ ์ธ์คํด์ค์ ๋ทฐ |
Int8Array
|
๋ฒํผ ํ์ ์ธ์คํด์ค๋ฅผ ์ฃผ์ด์ง ๋นํธ ํฌ๊ธฐ์ 2์ ๋ณด์ ๋ถํธ ์๋ ์ ์ ๋ฐฐ์ด๋ก ๋ ธ์ถํ๋ ๋ทฐ |
Int16Array
|
|
Int32Array
|
|
BigInt64Array
|
|
Uint8Array
|
๋ฒํผ ํ์ ์ธ์คํด์ค๋ฅผ ์ฃผ์ด์ง ๋นํธ ํฌ๊ธฐ์ ๋ถํธ ์๋ ์ ์ ๋ฐฐ์ด๋ก ๋ ธ์ถํ๋ ๋ทฐ |
Uint16Array
|
|
Uint32Array
|
|
BigUint64Array
|
|
Uint8ClampedArray
|
๋ฒํผ ํ์ ์ธ์คํด์ค๋ฅผ 8๋นํธ ๋ถํธ ์๋ ์ ์ ๋ฐฐ์ด๋ก ๋ ธ์ถํ๋ฉฐ, ๊ฐ์ ํด๋จํ ๋ณํ๋จ |
Float16Array
|
๋ฒํผ ํ์ ์ธ์คํด์ค๋ฅผ ์ง์ ๋ ๋นํธ ํฌ๊ธฐ์ IEEE 754 ๋ถ๋์์์ ์ซ์ ๋ฐฐ์ด๋ก ๋ ธ์ถํ๋ ๋ทฐ; Float16Array๋ ECMAScript ์ ์ [PROPOSAL-FLOAT16ARRAY]์ ํด๋นํจ. |
Float32Array
|
|
Float64Array
|
์ฐธ๊ณ : ์ด ํ์ ๋ค์ ๋ชจ๋ JavaScript์์ ์ ์๋ ํด๋์ค์ ํด๋นํฉ๋๋ค.
IDL์์๋ ์ด๋ฌํ ํ์ ์ ์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
๋ช ์ธ ์ฐ๋ฌธ(prose) ์์ค์์, IDL ๋ฒํผ ์์ค ํ์ ์ ๋จ์ํ ๊ฐ์ฒด ์ฐธ์กฐ์ ๋๋ค. ๋ฒํผ ๋ด๋ถ ๋ฐ์ดํธ๋ฅผ ์กฐํ/์กฐ์ํ๋ ค๋ฉด ๋ช ์ธ ์ฐ๋ฌธ์์ ยงโฏ3.2.26 ๋ฒํผ ์์ค ํ์ ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
BufferRelatedType ::ArrayBuffer SharedArrayBuffer DataView Int8Array Int16Array Int32Array Uint8Array Uint16Array Uint32Array Uint8ClampedArray BigInt64Array BigUint64Array Float16Array Float32Array Float64Array
2.13.35. ๋ถ๋ณ ๋ฐฐ์ด ํ์ โ FrozenArray<T>
๋ถ๋ณ ๋ฐฐ์ด ํ์ ์ ํ๋ผ๋ฏธํฐํ๋ ํ์ ์ผ๋ก, ๊ฐ์ด ๊ณ ์ ๊ธธ์ด์ ์์ ๋ถ๊ฐ ๊ฐ ๋ฐฐ์ด์ ๊ฐ์ง ๊ฐ์ฒด ์ฐธ์กฐ์ ๋๋ค. ๋ฐฐ์ด์ ๊ฐ ๊ฐ์ T ํ์ ์ ๋๋ค.
๋ถ๋ณ ๋ฐฐ์ด ํ์ ์ ์ธํฐํ์ด์ค์ ์ ์๋ ์ผ๋ฐ ์์ฑ์ด๋ static ์์ฑ ํ์ ์ผ๋ก๋ง ์ฌ์ฉํด์ผ ํฉ๋๋ค.
[Exposed =Window ]interface PersonalPreferences {readonly attribute FrozenArray <DOMString >favoriteColors ;attribute FrozenArray <DOMString >favoriteFoods ;undefined randomizeFavoriteColors (); };
์ด ์์ฑ๋ค์ ๋์ ์ ์ ์์:
๊ฐPersonalPreferences๋ favorite colors(FrozenArray<DOMString>)๋ฅผ ๊ฐ๊ณ , ์ด๊ธฐ๊ฐ์ ยซ "purple", "aquamarine" ยป๋ก ๋ถ๋ณ ๋ฐฐ์ด ์์ฑ ๊ฒฐ๊ณผ์ ๋๋ค.๊ฐ
PersonalPreferences๋ favorite foods(FrozenArray<DOMString>)๋ ๊ฐ๊ณ , ์ด๊ธฐ๊ฐ์ ๋น ๋ฆฌ์คํธ๋ก ๋ถ๋ณ ๋ฐฐ์ด ์์ฑ ๊ฒฐ๊ณผ์ ๋๋ค.
favoriteColorsgetter ๋จ๊ณ๋ this์ favorite colors๋ฅผ ๋ฐํํฉ๋๋ค.
favoriteFoodsgetter ๋จ๊ณ๋ this์ favorite foods๋ฅผ ๋ฐํํฉ๋๋ค.
favoriteFoodssetter ๋จ๊ณ๋ this์ favorite foods๋ฅผ ์ง์ ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค.
randomizeFavoriteColors()๋ฉ์๋ ๋จ๊ณ๋:
newFavoriteColors๋ฅผ ์์๋ก ์ ํํ ์์ 2๊ฐ์ ๋ฌธ์์ด ๋ฆฌ์คํธ๋ก ๋๋ค.
this์ favorite colors๋ฅผ ๋ถ๋ณ ๋ฐฐ์ด ์์ฑ(newFavoriteColors) ๊ฒฐ๊ณผ๋ก ์ค์ .
FrozenArray<T> ๊ฐ์ ์ฐธ์กฐ์ด๋ฏ๋ก, ์ํ์ค ํ์ ์ฒ๋ผ ๊ฐ์ผ๋ก ์ ๋ฌ๋๋ ๋ฆฌ์คํธ์๋ ๋ค๋ฆ ๋๋ค.
IDL์์๋ ๋ถ๋ณ ๋ฐฐ์ด ์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
2.13.36. ๊ด์ฐฐ ๋ฐฐ์ด ํ์ โ ObservableArray<T>
๊ด์ฐฐ ๋ฐฐ์ด ํ์ ์ ํ๋ผ๋ฏธํฐํ๋ ํ์ ์ผ๋ก, ๊ฐ์ด T ํ์ ๊ฐ์ฒด์ ๋ณ๊ฒฝ ๊ฐ๋ฅํ ๋ฆฌ์คํธ์, ์ ์ ์ฝ๋๊ฐ ๋ฆฌ์คํธ๋ฅผ ์์ ํ ๋ ์คํ๋๋ ๋์์ ๊ฒฐํฉํ ๊ฐ์ฒด ์ฐธ์กฐ์ ๋๋ค.
ํ๋ผ๋ฏธํฐํ ํ์ T๋ ๋์ ๋๋ฆฌ ํ์ , ์ํ์ค ํ์ , ๋ ์ฝ๋ ํ์ , ๊ด์ฐฐ ๋ฐฐ์ด ํ์ ์ด ๋ ์ ์์ต๋๋ค. ํ์ง๋ง T๋ ๋ ํ์ฉ์ผ ์ ์์ต๋๋ค.
์ํ์ค ํ์ ๊ณผ ๋ถ๋ณ ๋ฐฐ์ด ํ์ ์ฒ๋ผ, ๊ด์ฐฐ ๋ฐฐ์ด ํ์ ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐฐ์ด ํ์ ์ ๊ฐ์ธ๋ฉฐ ์ถ๊ฐ ์๋ฏธ๋ฅผ ๋ถ์ฌํฉ๋๋ค.
๊ด์ฐฐ ๋ฐฐ์ด ํ์ ์ ์ธํฐํ์ด์ค์ ์ ์๋ ์ผ๋ฐ ์์ฑ ํ์ ์ผ๋ก๋ง ์ฌ์ฉํด์ผ ํฉ๋๋ค.
๊ด์ฐฐ ๋ฐฐ์ด ์์ฑ์๋ ๋ช ์ธ ์ ์๊ฐ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ํ ์ ์์ต๋๋ค:
-
์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ โ ๊ด์ฐฐ ๋ฐฐ์ด์ ์ค์ ๋ IDL ๊ฐ๊ณผ ๊ทธ ์ธ๋ฑ์ค๋ฅผ ๋ฐ์;
-
์ธ๋ฑ์ค ๊ฐ ์ญ์ ์๊ณ ๋ฆฌ์ฆ โ ๊ด์ฐฐ ๋ฐฐ์ด์์ ์ญ์ ๋ IDL ๊ฐ๊ณผ ๊ทธ ์ธ๋ฑ์ค๋ฅผ ๋ฐ์.
์ด ๋ ์๊ณ ๋ฆฌ์ฆ์ ๋ชจ๋ ์ ํ์ ์ด๋ฉฐ, ์ ์๋์ง ์์ผ๋ฉด ๊ธฐ๋ณธ ๋์์ ์๋ฌด๊ฒ๋ ํ์ง ์๋ ๊ฒ์ ๋๋ค. ๋ ์๊ณ ๋ฆฌ์ฆ ๋ชจ๋ ์์ธ๋ฅผ throwํ ์ ์์ต๋๋ค(์: ๊ฐ์ด ์๋ชป๋ ๊ฒฝ์ฐ ๊ฑฐ๋ถ).
์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋๊ฐ ๊ธฐ์กด ์ธ๋ฑ์ค์ ์ ๊ฐ์ ์ค์ ํ๋ฉด, ๋จผ์ ์ธ๋ฑ์ค ๊ฐ ์ญ์ ์๊ณ ๋ฆฌ์ฆ์ด ์คํ๋์ด ๊ธฐ์กด ๊ฐ์ ์ญ์ ํ๊ณ , ๊ทธ ๋ค์ ์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ์ด ์ ๊ฐ์ ์ค์ ํฉ๋๋ค.
๊ด์ฐฐ ๋ฐฐ์ด ํ์ ์ธ ์ผ๋ฐ ์์ฑ๋ง๋ค ๋ฐฑํน ๋ฆฌ์คํธ๊ฐ ์์ผ๋ฉฐ, ์ด๋ ๋ฆฌ์คํธ๋ก, ์ด๊น๊ฐ์ ๋น ๋ฆฌ์คํธ์ ๋๋ค. ๋ช ์ธ ์ ์๋ ๋ฐฑํน ๋ฆฌ์คํธ ๋ด์ฉ์ ์์ ํ ์ ์๊ณ , ์ด๋ ์๋ฐ์คํฌ๋ฆฝํธ์์ ๊ด์ฐฐ ๋ฐฐ์ด ๋ด์ฉ์๋ ์ฆ์ ๋ฐ์๋ฉ๋๋ค. ๋ง์ฐฌ๊ฐ์ง๋ก ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋๊ฐ ๊ด์ฐฐ ๋ฐฐ์ด์ ์์ ํ๋ฉด ์ธ๋ฑ์ค ๊ฐ ์ค์ , ์ธ๋ฑ์ค ๊ฐ ์ญ์ ์๊ณ ๋ฆฌ์ฆ์ ๊ฑฐ์ณ ๋ฐฑํน ๋ฆฌ์คํธ์๋ ๋ฐ์๋ฉ๋๋ค.
IDL์์๋ ๊ด์ฐฐ ๋ฐฐ์ด ์์ ๊ฐ์ ํํํ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค.
[Exposed =Window ]interface Building {attribute ObservableArray <Employee >employees ; };
์ด ์์ฑ์ ๋์ ์ ์ ์์:
Building์employees์์ฑ์ ๋ํด ์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ(์ธ์: employee, index):
employee๊ฐ ์ค๋ ๊ฑด๋ฌผ ์ถ์ ๋ถ๊ฐ์ด๋ฉด "
NotAllowedError"DOMException์ throw.index๊ฐ 200 ์ด์์ด๋ฉด
QuotaExceededError๋ฅผ throwํ๊ณ , quota๋ 200, requested๋ index๋ก ์ค์ .employee๋ฅผ ์ ๋ฌด์ ํฌ์ !
Building์employees์์ฑ์ ๋ํด ์ธ๋ฑ์ค ๊ฐ ์ญ์ ์๊ณ ๋ฆฌ์ฆ(์ธ์: employee, index):
employee๊ฐ ๊ฑด๋ฌผ์ ๋ ๋ฌ์์ ๊ฒฝ๋น์ ์๋ฆผ.
์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋์์ employees ํ๋กํผํฐ๋ฅผ ์๋์ ๊ฐ์ด ์กฐ์ํ ์ ์์ต๋๋ค:
// Building ์ธ์คํด์ค ์ป๊ธฐ const building= getBuilding(); building. employees. push( new Employee( "A" )); building. employees. push( new Employee( "B" )); building. employees. push( new Employee( "C" )); building. employees. splice( 2 , 1 ); const employeeB= building. employees. pop(); building. employees= [ new Employee( "D" ), employeeB, new Employee( "C" )]; building. employees. length= 0 ; // ์์ธ ๋ฐ์: building. employees. push( "not an Employee; a string instead" );
์ ์กฐ์๋ค์ ๋ชจ๋ ์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ์ ๊ฑฐ์น๋ฉฐ, ์กฐ๊ฑด์ ๋ง์ผ๋ฉด ์์ธ๊ฐ throw๋ ์ ์์ต๋๋ค. ๋ํ ํด๋น ์ฌ์ด๋ ์ดํํธ๋ ์ธ๋ฑ์ค ๊ฐ ์ญ์ ์๊ณ ๋ฆฌ์ฆ์์ ์ ์๋ ๋๋ก ์คํ๋ฉ๋๋ค.
์ JS ์์์์ %Array.prototype%์ ๋ชจ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐฐ์ด ๋ฉ์๋๊ฐ ๊ด์ฐฐ ๋ฐฐ์ด์ ๋ชจ๋ ๋์ํ๋ ์ ๋ ์ฃผ๋ชฉํ์ธ์. ์ค์ ๋ก Array ์ธ์คํด์ค์ฒ๋ผ ๋์ํฉ๋๋ค:
const normalArray= []; // ๋ง์ฝ building.employees๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ getter ์ธํฐํ์ด์ค์๋ค๋ฉด: normalArray์ building.employees ํ๋๋ง ๋ค์ด๊ฐ. // // ๊ด์ฐฐ ๋ฐฐ์ด(๋ฐ ๋ถ๋ณ ๋ฐฐ์ด)์ ๊ฒฝ์ฐ: normalArray์๋ building.employees์ ๋ชจ๋ ํญ๋ชฉ์ด ๋ค์ด๊ฐ. normalArray. concat( building. employees); // names๋ JS Array์. const names= building. employees. map( employee=> employee. name); // ๋ธ๋๋ ์ฒดํฌ ํต๊ณผ: console. assert( building. employeesinstanceof Array); console. assert( Array. isArray( building. employees)); console. assert( building. employees. constructor === Array); // JSON.stringify์๋ ๋ฐฐ์ด๋ก ์ทจ๊ธ๋จ! (๋ฐ๊นฅ [] ์ฐธ์กฐ.) console. assert( JSON. stringify( building. employees) === `[{}]` );
2.14. ํ์ฅ ์์ฑ
ํ์ฅ
์์ฑ์ ์ฃผ์์ด๋ฉฐ
๋ค์์ ๋ํ๋ ์ ์์ต๋๋ค.
์ ์,
์ฃผ์์ด ์ง์ ๋ ํ์
์ผ๋ก์์ ํ์
,
์ธํฐํ์ด์ค
๋ฉค๋ฒ,
์ธํฐํ์ด์ค ๋ฏน์ค์ธ
๋ฉค๋ฒ,
์ฝ๋ฐฑ
์ธํฐํ์ด์ค ๋ฉค๋ฒ,
๋ค์์คํ์ด์ค
๋ฉค๋ฒ,
๋์
๋๋ฆฌ
๋ฉค๋ฒ,
๊ทธ๋ฆฌ๊ณ ์ฐ์ฐ ์ธ์์ ๋ํ๋ ์ ์์ผ๋ฉฐ,
์ธ์ด ๋ฐ์ธ๋ฉ์ด ์ด๋ฌํ ๊ตฌ๋ฌธ์ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ ์ ์ดํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
ํ์ฅ ์์ฑ์
| ๋ฌธ๋ฒ ๊ธฐํธ | ํ์ | ์ |
|---|---|---|
|
|
์ธ์๋ฅผ ๋ฐ์ง ์์ |
[Replaceable]
|
|
|
์ธ์ ๋ชฉ๋ก์ ๋ฐ์ |
ํ์ฌ๋ ์ฌ์ฉ๋์ง ์์; ์ด์ ์๋ [Constructor(double x, double y)]์์ ์ฌ์ฉ๋จ
|
|
|
๋ช ๋ช ๋ ์ธ์ ๋ชฉ๋ก์ ๋ฐ์ |
[LegacyFactoryFunction=Image(DOMString src)]
|
|
|
์๋ณ์๋ฅผ ๋ฐ์ |
[PutForwards=name]
|
|
|
๋ฌธ์์ด์ ๋ฐ์ |
[Reflect="popover"]
|
|
|
์ ์๋ฅผ ๋ฐ์ |
[ReflectDefault=2]
|
|
|
์ญ์ง์๋ฅผ ๋ฐ์ |
[ReflectDefault=2.0]
|
|
|
์ ์ ๋ชฉ๋ก์ ๋ฐ์ |
[ReflectRange=(2, 600)]
|
|
|
์๋ณ์ ๋ชฉ๋ก์ ๋ฐ์ |
[Exposed=(Window,Worker)]
|
|
|
์์ผ๋์นด๋๋ฅผ ๋ฐ์ |
[Exposed=*]
|
์ด ๋ช ์ธ๋ JavaScript ์ธ์ด ๋ฐ์ธ๋ฉ์ ์ ์ฉ ๊ฐ๋ฅํ ์ฌ๋ฌ ํ์ฅ ์์ฑ์ ์ ์ํ๋ฉฐ, ์ด์ ๋ํด์๋ ยง 3.3 ํ์ฅ ์์ฑ์์ ์ค๋ช ํฉ๋๋ค. ๊ฐ ํ์ฅ ์์ฑ ์ ์๋ ์์ ๋ค์ฏ ๊ฐ์ง ํ์ ์ค ์ด๋ค ํ์์ด ํ์ฉ๋๋์ง ๋ช ์ํฉ๋๋ค.
ExtendedAttributeList ::[ ExtendedAttribute ExtendedAttributes ] ฮต
ExtendedAttributes ::, ExtendedAttribute ExtendedAttributes ฮต
ExtendedAttribute ::( ExtendedAttributeInner ) ExtendedAttributeRest [ ExtendedAttributeInner ] ExtendedAttributeRest { ExtendedAttributeInner } ExtendedAttributeRest Other ExtendedAttributeRest
ExtendedAttributeRest ::ExtendedAttribute ฮต
ExtendedAttributeInner ::( ExtendedAttributeInner ) ExtendedAttributeInner [ ExtendedAttributeInner ] ExtendedAttributeInner { ExtendedAttributeInner } ExtendedAttributeInner OtherOrComma ExtendedAttributeInner ฮต
Other ::integer decimal identifier string other - -Infinity . ... : ; < = > ? * ByteString DOMString FrozenArray Infinity NaN ObservableArray Promise USVString any bigint boolean byte double false float long null object octet or optional record sequence short symbol true unsigned undefined ArgumentNameKeyword BufferRelatedType
OtherOrComma ::Other ,
IdentifierList ::identifier Identifiers
Identifiers ::, identifier Identifiers ฮต
IntegerList ::integer Integers
Integers ::, integer Integers ฮต
ExtendedAttributeNoArgs ::identifier
ExtendedAttributeArgList ::identifier ( ArgumentList )
ExtendedAttributeIdent ::identifier = identifier
ExtendedAttributeString ::identifier = string
ExtendedAttributeInteger ::identifier = integer
ExtendedAttributeDecimal ::identifier = decimal
ExtendedAttributeWildcard ::identifier = *
ExtendedAttributeIdentList ::identifier = ( IdentifierList )
ExtendedAttributeIntegerList ::identifier = ( IntegerList )
ExtendedAttributeNamedArgList ::identifier = identifier ( ArgumentList )
3. ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐ์ธ๋ฉ
์ด ์ ์์๋ ยงโฏ2 ์ธํฐํ์ด์ค ์ ์ ์ธ์ด์ ์ ์๋ IDL๋ก ์์ฑ๋ ์ ์๋ค์ด ECMAScript ์ธ์ด ๋ช ์ธ [ECMA-262]์ ๊ท์ ๋ ์๋ฐ์คํฌ๋ฆฝํธ์ ํน์ ๊ตฌ์กฐ์ ์ด๋ป๊ฒ ๋์๋๋์ง ์ค๋ช ํ๋ค.
๋ณ๋ ๋ช ์ ์์ผ๋ฉด, ์ด ์ ์์ ์ ์๋ ๊ฐ์ฒด๋ ECMAScript ยงโฏ10.1 ์ผ๋ฐ ๊ฐ์ฒด ๋ด๋ถ ๋ฉ์๋์ ๋ด๋ถ ์ฌ๋กฏ์ ๊ธฐ์ ๋ ์ผ๋ฐ ๊ฐ์ฒด์ด๋ฉฐ, ๊ฐ์ฒด๊ฐ ํจ์ ๊ฐ์ฒด๋ผ๋ฉด ECMAScript ยงโฏ10.3 ๋ด์ฅ ํจ์ ๊ฐ์ฒด์ ๋ฐ๋ฅธ๋ค.
์ด ์ ์์๋ ๊ฐ์ฒด์ ๋ด๋ถ ๋ฉ์๋์ ๋ด๋ถ ์ฌ๋กฏ ์ผ๋ถ๋ฅผ ์ฌ์ ์ํ ์ ์๋ค. ๋ค๋ฅธ ํํ ํ์ค ๋ํ ์ธํฐํ์ด์ค์ ์ธ์คํด์ค์ธ ํ๋ซํผ ๊ฐ์ฒด์ ๋ด๋ถ ๋ฉ์๋๋ ๋ด๋ถ ์ฌ๋กฏ ์ ์๋ฅผ ์ฌ์ ์ํ ์ ์๋ค. ์ด๋ ๊ฒ ์๋ฏธ๊ฐ ๋ณ๊ฒฝ๋ ๊ฐ์ฒด๋ ํน์ด ๊ฐ์ฒด ๊ท์น์ ๋ฐ๋ผ ๋ค๋ค์ ธ์ผ ํ๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด์ ๋ด๋ถ ๋ฉ์๋๋ฅผ ์ฌ์ ์ํ๋ ๊ฒ์ ์ ์์ค ์์
์ด๋ฉฐ,
์ผ๋ฐ ๊ฐ์ฒด์ ๋ค๋ฅด๊ฒ ๋์ํ ์ ์์ผ๋ฏ๋ก, ๋ณด์์ด๋ ํธํ์ฑ ๋ฑ ๊ผญ ํ์ํ ๊ฒฝ์ฐ์๋ง ์จ์ผ ํ๋ค.
ํ์ฌ HTMLAllCollection
๋ฐ Location
์ธํฐํ์ด์ค ์ ์์ ์ฌ์ฉ๋จ. [HTML]
๋ณ๋ ๋ช ์ ์์ผ๋ฉด, ์ด ์ ๋ฐ ๋ค๋ฅธ ํํ ํ์ค์์ ์ ์๋ ํน์ด ๊ฐ์ฒด(Exotic Object)๋ ์ผ๋ฐ ๊ฐ์ฒด์ ๋์ผํ ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ง๋ฉฐ, ๋ณ๋ ์ ์๊ฐ ์๋ ๋ชจ๋ ๋ด๋ถ ๋ฉ์๋๋ ์ผ๋ฐ ๊ฐ์ฒด์ ๋ด๋ถ ๋ฉ์๋์ ๋์ผํ๋ค.
๋ณ๋ ๋ช
์ ์์ผ๋ฉด, ์ด ์ ์์ ์ ์๋ ๊ฐ์ฒด์ [[Extensible]] ๋ด๋ถ ์ฌ๋กฏ ๊ฐ์
๋ณ๋ ๋ช
์ ์์ผ๋ฉด, ์ด ์ ์์ ์ ์๋ ๊ฐ์ฒด์ [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ ๊ฐ์ %Object.prototype%์ด๋ค.
์ด ์ ์์ ์ค๋ช
ํ๋ ์ผ๋ถ ๊ฐ์ฒด๋ ํด๋์ค
๋ฌธ์์ด์ ๊ฐ์ง๋ค.
ํด๋์ค ๋ฌธ์์ด์ Object.prototype.toString์ ๋ฐํ ๋ฌธ์์ด์ ํฌํจ๋๋ ๊ฐ์ด๋ค.
๊ฐ์ฒด๊ฐ ํด๋์ค ๋ฌธ์์ด classString์ ๊ฐ์ง๋ฉด, ์์ฑ ์์ ์ ํด๋น ๊ฐ์ฒด๋
%Symbol.toStringTag%
์ฌ๋ณผ ์ด๋ฆ์ ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์ผ ํ๋ฉฐ, PropertyDescriptor{[[Writable]]:
์ด ์ ์ ์๊ณ ๋ฆฌ์ฆ์ ECMAScript ยงโฏ5.2 ์๊ณ ๋ฆฌ์ฆ ๊ท์น(๋จ๊ณ์ ํ์ ๋จ๊ณ, ์ํ ์ฐ์ฐ ๋ฑ) ๋ฐ ECMA-262์ ๋ค๋ฅธ ๋ถ๋ถ์์ ์ ์๋ ์ถ์ ์ฐ์ฐยทํ๊ธฐ๋ฒ์ ๋ฐ๋ฅธ๋ค.
์๊ณ ๋ฆฌ์ฆ์์
throw SomethingError
๋ผ๊ณ ํ๋ฉด, ์ด๋ ํ์ฌ realm์์ ์๋ก์ด ์๋ฐ์คํฌ๋ฆฝํธ
SomethingError ๊ฐ์ฒด๋ฅผ ์์ฑํด throwํ๋ ๊ฒ์ ์๋ฏธํ๋ฉฐ, ECMA-262 ์๊ณ ๋ฆฌ์ฆ๊ณผ ๋์ผํ๋ค.
์๊ณ ๋ฆฌ์ฆ ๋จ๊ณ์์ ๋ค๋ฅธ ์๊ณ ๋ฆฌ์ฆ์ด๋ ์ถ์ ์ฐ์ฐ์ ํธ์ถํ๊ณ , ๊ทธ ๊ณผ์ ์์ ์์ธ๊ฐ ๋ช ์์ ์ผ๋ก ์ฒ๋ฆฌ๋์ง ์๋ ๊ฒฝ์ฐ, ์์ธ๊ฐ ๋ฐ์ํ๋ฉด ์๊ณ ๋ฆฌ์ฆ ์คํ์ ์ค๋จ๋๊ณ ์์ธ๊ฐ ํธ์ถ์์๊ฒ ์ ๋ฌ๋๋ค.
๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ๋ณด์:
ToString์ ์์ธ๋ฅผ
throwํ ์ ์๋ค(์: ({ toString: function() { throw 1 } }) ์ ๋ฌ ์).
์ ์๊ณ ๋ฆฌ์ฆ์์ ์์ธ๊ฐ ์ฒ๋ฆฌ๋์ง ์์ผ๋ฏ๋ก, ์์ธ๊ฐ ๋ฐ์ํ๋ฉด ์๊ณ ๋ฆฌ์ฆ ์คํ์ ์ค๋จ๋๊ณ ์์ธ๊ฐ ํธ์ถ์์๊ฒ ์ ๋ฌ๋๋ค.
3.1. ์๋ฐ์คํฌ๋ฆฝํธ ํ๊ฒฝ
์ฃผ์ด์ง IDL ํ๋๊ทธ๋จผํธ ์งํฉ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์์๋, ํด๋น IDL ํ๋๊ทธ๋จผํธ์ ์ ์๋ ๊ฐ์ฒด์ ๋์๋๋ ์ฌ๋ฌ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๊ฐ ์กด์ฌํ๋ค. ์ด ๊ฐ์ฒด๋ค์ ์ด๊ธฐ ๊ฐ์ฒด๋ผ ํ๋ฉฐ, ๋ค์์ ํฌํจํ๋ค:
๊ฐ realm์๋ ๊ณ ์ ํ ์ด๊ธฐ ๊ฐ์ฒด ์งํฉ์ด ์์ด์ผ ํ๋ฉฐ, ํด๋น realm์ ์๋ฐ์คํฌ๋ฆฝํธ ์คํ ์ปจํ ์คํธ ์ง์ ์ , realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๊ฐ ์์ฑ๋ ํ์ ๋ง๋ค์ด์ง๋ค. ๋์ผ realm์ ๋ชจ๋ ์ด๊ธฐ ๊ฐ์ฒด [[Prototype]]์ ๊ทธ realm์์ ๊ฐ์ ธ์์ผ ํ๋ค.
HTML ์ฌ์ฉ์ ์์ด์ ํธ์์๋ ์ฌ๋ฌ realm์ด ํ๋ ์ ๋๋ ์๋์ฐ๊ฐ ์ฌ๋ฌ ๊ฐ์ผ ๋ ์กด์ฌํ ์ ์๋ค. ๊ฐ ํ๋ ์ยท์๋์ฐ๋ง๋ค ๊ณ ์ ํ ์ด๊ธฐ ๊ฐ์ฒด ์งํฉ์ ๊ฐ์ง๋ฉฐ, ์๋ HTML ๋ฌธ์๋ก ํ์ธํ ์ ์๋ค:
<!DOCTYPE html> < title > Different Realms</ title > < iframe id = a ></ iframe > < script > var iframe= document. getElementById( "a" ); var w= iframe. contentWindow; // ํ๋ ์์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด Object== w. Object; // false ๋ฐํ (ECMA-262 ์ค์) Node== w. Node; // false ๋ฐํ iframeinstanceof w. Node; // false ๋ฐํ iframeinstanceof w. Object; // false ๋ฐํ iframe. appendChildinstanceof Function; // true ๋ฐํ iframe. appendChildinstanceof w. Function; // false ๋ฐํ </ script >
์ฐธ๊ณ : ๋ชจ๋ ์ธํฐํ์ด์ค๋ ์ด๋ค realm์ ๋ ธ์ถ๋๋์ง ์ ์ํ๋ค. ์๋ฅผ ๋ค์ด, Web Worker์ฉ realm์ ์น ํ์ด์ง realm๊ณผ ๋ ธ์ถ๋๋ ์ธํฐํ์ด์ค ์งํฉ์ด ๋ค๋ฅผ ์ ์๋ค.
์์ฑ ์์ ์์ ์๋ฐ์คํฌ๋ฆฝํธ ๋ช ์ธ์๋ ๋ฐ์๋์ง ์์์ผ๋, ๋ชจ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ ์ฐ๊ฒฐ๋ realm์ ๊ฐ์ ธ์ผ ํ๋ค. ๊ฐ์ฒด์ realm์ ์ฐ๊ฒฐํ๋ ๋ฉ์ปค๋์ฆ์ ์์ง ๋ช ํํ ๊ท์ ๋์ง ์์์ผ๋, ํ๋ซํผ ๊ฐ์ฒด์ ๊ฒฝ์ฐ ์ฐ๊ฒฐ๋ realm์ ๊ฐ์ฒด์ ๊ด๋ จ realm๊ณผ ๋์ผํ๋ฉฐ, ํน์ดํ์ง ์์ ํจ์ ๊ฐ์ฒด(์ฆ, ํธ์ถ ๊ฐ๋ฅ ํ๋ก์๋ bound ํจ์๊ฐ ์๋ ๊ฒฝ์ฐ)๋ ํจ์ ๊ฐ์ฒด์ [[Realm]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ด ์ฐ๊ฒฐ๋ realm์ด๋ค.
3.2. ์๋ฐ์คํฌ๋ฆฝํธ ํ์ ๋งคํ
์ด ์ ์์๋ IDL์ ํ์ ์ด ์๋ฐ์คํฌ๋ฆฝํธ ํ์ ์ ์ด๋ป๊ฒ ๋งคํ๋๋์ง ์ค๋ช ํ๋ค.
์๋ ๊ฐ ํ์ ์ ์์๋ ํน์ IDL ํ์ ๊ฐ์ด ์๋ฐ์คํฌ๋ฆฝํธ์์ ์ด๋ป๊ฒ ํํ๋๋์ง ์ค๋ช ํ๋ค. ๊ฐ IDL ํ์ ๋ง๋ค, ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ด ํด๋น ํ์ ์ ๊ธฐ๋ํ๋ ํ๋ซํผ ๊ฐ์ฒด์ ์ ๋ฌ๋ ๋ ์ด๋ป๊ฒ IDL ๊ฐ์ผ๋ก ๋ณํ๋๋์ง์, ํด๋น ํ์ ์ IDL ๊ฐ์ด ํ๋ซํผ ๊ฐ์ฒด์์ ๋ฐํ๋ ๋ ์ด๋ป๊ฒ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํ๋๋์ง๋ฅผ ์ค๋ช ํ๋ค.
์๋ ํ์ ์ ๊ณผ ์๊ณ ๋ฆฌ์ฆ์, ํ์ ํค๋์ ๋ช ์๋ ํ์ ์ ํ์ฅ ์์ฑ์ ์ ์ฉํด ๋ง๋ ์ฃผ์ ํ์ ์๋ ๋์ผํ๊ฒ ์ ์ฉ๋๋ค.
3.2.1. any
IDL any ํ์
์
๋ชจ๋ ๋ค๋ฅธ IDL ํ์
์ ํฉ์งํฉ์ด๋ฏ๋ก, ๋ชจ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ ํ์
์ ๋์๋ ์ ์๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด IDL any ๊ฐ์ผ๋ก ๋ง๋๋
์๊ณ ๋ฆฌ์ฆ:
-
V๊ฐ
undefined ์ด๋ฉด, ๊ณ ์ ํundefinedIDL ๊ฐ์ ๋ฐํํ๋ค. -
V๊ฐ
null ์ด๋ฉด,null object?์ฐธ์กฐ๋ฅผ ๋ฐํํ๋ค. -
V๊ฐ ๋ถ๋ฆฌ์ธ์ด๋ฉด, ๋์ผํ ์ง๋ฆฟ๊ฐ์ ๋ํ๋ด๋
boolean๊ฐ์ ๋ฐํํ๋ค. -
V๊ฐ ์ซ์์ด๋ฉด, V๋ฅผ unrestricted double๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
V๊ฐ BigInt์ด๋ฉด, V๋ฅผ bigint๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
V๊ฐ ๋ฌธ์์ด์ด๋ฉด, V๋ฅผ DOMString์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
V๊ฐ ์ฌ๋ณผ์ด๋ฉด, V๋ฅผ symbol๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
V๊ฐ ๊ฐ์ฒด์ด๋ฉด, V๋ฅผ ์ฐธ์กฐํ๋ IDL
object๊ฐ์ ๋ฐํํ๋ค.
IDL any ๊ฐ์
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํ๋ ๋,
ํด๋น IDL any ๊ฐ์ ํน์ ํ์
์ ๋ํด ์๋ ์ ์์ ์ค๋ช
ํ ๋ณํ ๊ท์น์ ๋ฐ๋ฅธ๋ค.
3.2.2. undefined
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํด
undefined
๊ฐ์ผ๋ก ๋ง๋ค ๋๋,
V๋ฅผ ๋ฌด์ํ๊ณ ๊ณ ์ ํ undefined
๊ฐ์ ๋ฐํํ๋ค.
๊ณ ์ ํ IDL undefined
๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํ๋ ๋ ์๋ฐ์คํฌ๋ฆฝํธ
3.2.3. boolean
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด boolean ๊ฐ์ผ๋ก ๋ง๋๋
์๊ณ ๋ฆฌ์ฆ:
IDL boolean ๊ฐ
true๋ ์๋ฐ์คํฌ๋ฆฝํธ
๊ฐ์ผ๋ก ๋ณํ๋ ๋ ์๋ฐ์คํฌ๋ฆฝํธ false ๋ ์๋ฐ์คํฌ๋ฆฝํธ
3.2.4. ์ ์ ํ์
์ด ์ ์์ ์ฌ์ฉํ๋ ์ํ ์ฐ์ฐ์, ECMAScript ยงโฏ5.2 ์๊ณ ๋ฆฌ์ฆ ๊ท์น์ ์ ์๋ ๊ฒ ํฌํจ, ์ํ์ ์ค์์ ๋ํ ์ ํํ ์ํ์ ๊ฒฐ๊ณผ๋ฅผ ์๋ฏธํ๋ค.
์ฆ, x๊ฐ Number ๊ฐ์ผ ๋, โx์ ๋ํด ์ฐ์ฐํ๋คโ๋ ๊ฒ์ โx์ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง ์ํ์ ์ค์์ ๋ํด ์ฐ์ฐํ๋คโ์ ์ฝ์ด์ด๋ค.
3.2.4.1. byte
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด byte ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 8, "
signed") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
byte๊ฐ์ ๋ฐํํ๋ค.
IDL byte ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก
๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL byte ๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
Number ๊ฐ์ [โ128, 127] ๋ฒ์์ ์ ์๋ค.
3.2.4.2. octet
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด octet ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 8, "
unsigned") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
octet๊ฐ์ ๋ฐํํ๋ค.
IDL octet ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก
๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL octet ๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง
Number์ด๋ค.
Number ๊ฐ์ [0, 255] ๋ฒ์์ ์ ์๋ค.
3.2.4.3. short
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด short ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 16, "
signed") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
short๊ฐ์ ๋ฐํํ๋ค.
IDL short ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก
๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL short ๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง
Number์ด๋ค.
Number ๊ฐ์ [โ32768, 32767] ๋ฒ์์ ์ ์๋ค.
3.2.4.4. unsigned short
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด unsigned short ๊ฐ์ผ๋ก ๋ง๋๋
์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 16, "
unsigned") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
unsigned short๊ฐ์ ๋ฐํํ๋ค.
IDL unsigned short ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL unsigned short ๊ฐ๊ณผ ๋์ผํ
์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
Number ๊ฐ์ [0, 65535] ๋ฒ์์ ์ ์๋ค.
3.2.4.5. long
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด long ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 32, "
signed") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
long๊ฐ์ ๋ฐํํ๋ค.
IDL long ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก
๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL long ๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
Number ๊ฐ์ [โ2147483648, 2147483647] ๋ฒ์์ ์ ์๋ค.
3.2.4.6. unsigned long
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด unsigned long
๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 32, "
unsigned") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
unsigned long๊ฐ์ ๋ฐํํ๋ค.
IDL unsigned long ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL unsigned long ๊ฐ๊ณผ ๋์ผํ
์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
Number ๊ฐ์ [0, 4294967295] ๋ฒ์์ ์ ์๋ค.
3.2.4.7. long long
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด long long ๊ฐ์ผ๋ก ๋ง๋๋
์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 64, "
signed") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
long long๊ฐ์ ๋ฐํํ๋ค.
IDL long long ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น long long ๊ฐ์ ๊ฐ์ฅ ๊ฐ๊น์ด Number
๊ฐ์ด๋ค. ๋ ๊ฐ์ด ๋์ผํ๊ฒ ๊ฐ๊น์ธ ๊ฒฝ์ฐ ์ ํจ์ซ์๊ฐ ์ง์์ธ ๊ฐ์ ์ ํํ๋ค.
long long์ด [โ253 + 1,
253 โ 1] ๋ฒ์์ ์์ผ๋ฉด Number๊ฐ long long๊ณผ ๋์ผํ ๊ฐ์ ์ ํํ ํํํ ์ ์๋ค.
3.2.4.8. unsigned long long
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด unsigned long long ๊ฐ์ผ๋ก
๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๋ฅผ ? ConvertToInt(V, 64, "
unsigned") ๊ฒฐ๊ณผ๋ก ๋๋ค. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
unsigned long long๊ฐ์ ๋ฐํํ๋ค.
IDL unsigned long long
๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น unsigned long long ๊ฐ์
๊ฐ์ฅ ๊ฐ๊น์ด Number ๊ฐ์ด๋ค. ๋ ๊ฐ์ด ๋์ผํ๊ฒ ๊ฐ๊น์ธ ๊ฒฝ์ฐ ์ ํจ์ซ์๊ฐ ์ง์์ธ ๊ฐ์ ์ ํํ๋ค.
unsigned long long์ด
253 โ 1 ์ดํ์ด๋ฉด Number๊ฐ unsigned long long๊ณผ ๋์ผํ ๊ฐ์ ์ ํํ ํํํ ์ ์๋ค.
3.2.4.9. ์ถ์ ์ฐ์ฐ
IntegerPart(n):
ConvertToInt(V, bitLength, signedness):
-
bitLength๊ฐ 64์ธ ๊ฒฝ์ฐ:
-
upperBound๋ฅผ 253 โ 1๋ก ๋ก๋๋ค.
-
signedness๊ฐ "
unsigned"์ด๋ฉด, lowerBound๋ฅผ 0์ผ๋ก ๋ก๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด lowerBound๋ฅผ โ253 + 1๋ก ๋ก๋๋ค.
์ฐธ๊ณ : ์ด๋ ๊ฒ ํ๋ฉด
long longํ์ ์ด [EnforceRange] ๋๋ [Clamp] ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋ ๊ฒฝ์ฐ JavaScript์ Number ํ์ ์์ ๋ชจํธํ์ง ์์ ์ ์๋ก ํํํ ์ ์์ต๋๋ค.
-
-
๊ทธ๋ ์ง ์๊ณ , signedness๊ฐ "
unsigned"์ธ ๊ฒฝ์ฐ:-
lowerBound๋ฅผ 0์ผ๋ก ๋ก๋๋ค.
-
upperBound๋ฅผ 2bitLength โ 1๋ก ๋ก๋๋ค.
-
-
๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ:
-
lowerBound๋ฅผ -2bitLength โ 1๋ก ๋ก๋๋ค.
-
upperBound๋ฅผ 2bitLength โ 1 โ 1๋ก ๋ก๋๋ค.
-
-
x๊ฐ โ0์ด๋ฉด, x๋ฅผ +0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
๋ณํ ๋์์ด [
EnforceRange] ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋ IDL ํ์ ์ธ ๊ฒฝ์ฐ:-
x๊ฐ
NaN , +โ ๋๋ โโ์ด๋ฉด,TypeError๋ฅผ ๋ฐ์์ํต๋๋ค. -
x๋ฅผ IntegerPart(x)๋ก ์ค์ ํฉ๋๋ค.
-
x < lowerBound ๋๋ x > upperBound์ด๋ฉด,
TypeError๋ฅผ ๋ฐ์์ํต๋๋ค. -
x๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
x๊ฐ
NaN ์ด ์๋๊ณ ๋ณํ ๋์์ด [Clamp] ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋ IDL ํ์ ์ด๋ฉด, ๋ค์์ ์ํํฉ๋๋ค: -
x๊ฐ
NaN , +0, +โ ๋๋ โโ์ด๋ฉด, +0์ ๋ฐํํฉ๋๋ค. -
x๋ฅผ IntegerPart(x)๋ก ์ค์ ํฉ๋๋ค.
-
x๋ฅผ x ๋ชจ๋๋ก 2bitLength๋ก ์ค์ ํฉ๋๋ค.
-
signedness๊ฐ "
signed"์ด๊ณ x โฅ 2bitLength โ 1์ด๋ฉด, x โ 2bitLength๋ฅผ ๋ฐํํฉ๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, x๋ฅผ ๋ฐํํฉ๋๋ค.
3.2.5. float
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด float ๊ฐ์ผ๋ก
๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x ๊ฐ
NaN , +โ ๋๋ โโ์ด๋ฉด TypeError ๋ฅผ throw ํ๋ค. -
S๋ฅผ ์ ํ IEEE 754 ๋จ์ ๋ฐ๋ ๋ถ๋์์์ ๊ฐ ์งํฉ(โ0 ์ ์ธ)์ 2128, โ2128 ๋ ํน์๊ฐ์ ์ถ๊ฐํ ์งํฉ์ผ๋ก ๋๋ค.
-
y๋ฅผ x์ ๊ฐ์ฅ ๊ฐ๊น์ด S ๋ด ๊ฐ์ผ๋ก ๋๊ณ , ๋์ผํ๊ฒ ๊ฐ๊น์ธ ๊ฒฝ์ฐ ์ ํจ์ซ์๊ฐ ์ง์์ธ ๊ฐ์ ์ ํํ๋ค. (2128, โ2128๋ ์ง์ ์ ํจ์ซ์๋ก ๊ฐ์ฃผ.)
-
y ๊ฐ 2 128 ๋๋ โ2 128 ์ด๋ฉด TypeError ๋ฅผ throw ํ๋ค.
-
y๊ฐ +0์ด๊ณ x๊ฐ ์์๋ฉด โ0์ ๋ฐํ.
-
y๋ฅผ ๋ฐํ.
IDL float ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ
๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น IDL float ๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง
Number์ด๋ค.
3.2.6. unrestricted float
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด unrestricted float ๊ฐ์ผ๋ก
๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๊ฐ
NaN ์ด๋ฉด IEEE 754 NaN ๊ฐ(bit ํจํด 0x7fc00000)๊ณผ ๋์๋๋ IDLunrestricted float๊ฐ์ ๋ฐํ. -
S๋ฅผ ์ ํ IEEE 754 ๋จ์ ๋ฐ๋ ๋ถ๋์์์ ๊ฐ ์งํฉ(โ0 ์ ์ธ)์ 2128, โ2128 ๋ ํน์๊ฐ์ ์ถ๊ฐํ ์งํฉ์ผ๋ก ๋๋ค.
-
y๋ฅผ x์ ๊ฐ์ฅ ๊ฐ๊น์ด S ๋ด ๊ฐ์ผ๋ก ๋๊ณ , ๋์ผํ๊ฒ ๊ฐ๊น์ธ ๊ฒฝ์ฐ ์ ํจ์ซ์๊ฐ ์ง์์ธ ๊ฐ์ ์ ํํ๋ค. (2128, โ2128๋ ์ง์ ์ ํจ์ซ์๋ก ๊ฐ์ฃผ.)
-
y๊ฐ 2128์ด๋ฉด +โ๋ฅผ ๋ฐํ.
-
y๊ฐ โ2128์ด๋ฉด โโ๋ฅผ ๋ฐํ.
-
y๊ฐ +0์ด๊ณ x๊ฐ ์์๋ฉด โ0์ ๋ฐํ.
-
y๋ฅผ ๋ฐํ.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ
IDL unrestricted float ๊ฐ์
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ Number:
-
ํด๋น IDL unrestricted float ๊ฐ์ด NaN์ด๋ฉด Number ๊ฐ๋
NaN ์ด๋ค. -
๊ทธ ์ธ์๋ ํด๋น IDL
unrestricted float๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
3.2.7. double
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด double ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
IDL double ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น double ๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
3.2.8. unrestricted double
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด unrestricted double
๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
x๊ฐ
NaN ์ด๋ฉด IEEE 754 NaN ๊ฐ(bit ํจํด 0x7ff8000000000000)๊ณผ ๋์๋๋ IDLunrestricted double๊ฐ์ ๋ฐํ. -
x์ ๋์ผํ ์์น ๊ฐ์ ๋ํ๋ด๋ IDL
unrestricted double๊ฐ์ ๋ฐํ.
์ฐธ๊ณ : ์๋ฐ์คํฌ๋ฆฝํธ
IDL unrestricted double
๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ Number:
-
ํด๋น IDL unrestricted double ๊ฐ์ด NaN์ด๋ฉด Number ๊ฐ๋
NaN ์ด๋ค. -
๊ทธ ์ธ์๋ ํด๋น IDL
unrestricted double๊ฐ๊ณผ ๋์ผํ ์์น ๊ฐ์ ๊ฐ์ง Number์ด๋ค.
3.2.9. bigint
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด bigint ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
IDL bigint ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ BigInt:
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ ๋ณํํด์ IDL ์ซ์ ํ์
T ๋๋ bigint
๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
3.2.10. DOMString
JavaScript ๊ฐ V๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํ์ฌ ๋ณํ๋์ด
IDL DOMString
๊ฐ์ด ๋ฉ๋๋ค:
-
V๊ฐ
null ์ด๊ณ ๋ณํ ๋์์ด [LegacyNullToEmptyString] ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋ IDL ํ์ ์ด๋ฉด, ๋น ๋ฌธ์์ด์ ๋ํ๋ด๋DOMString๊ฐ์ ๋ฐํํฉ๋๋ค. -
JavaScript String ๊ฐ x๊ฐ ๋ํ๋ด๋ ๊ฒ๊ณผ ๋์ผํ ์ฝ๋ ๋จ์ ์ํ์ค๋ฅผ ๋ํ๋ด๋ IDL
DOMString๊ฐ์ ๋ฐํํฉ๋๋ค.
IDL DOMString
๊ฐ์ JavaScript
๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋
IDL DOMString์ด
๋ํ๋ด๋ ๊ฒ๊ณผ ๋์ผํ ์ฝ๋ ๋จ์ ์ํ์ค๋ฅผ ๋ํ๋ด๋ String
๊ฐ์
๋๋ค.
3.2.11. ByteString
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด ByteString ๊ฐ์ผ๋ก
๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
IDL ByteString ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น ByteString๊ณผ ๊ธธ์ด๊ฐ ๊ฐ๊ณ ๊ฐ ์์ ๊ฐ์ด
ByteString์ ํด๋น ์์์ ๋์ผํ String ๊ฐ์ด๋ค.
3.2.12. USVString
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด USVString ๊ฐ์ผ๋ก ๋ง๋๋
์๊ณ ๋ฆฌ์ฆ:
-
string์ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ๋ณํ์ ํตํด ์ค์นผ๋ผ ๊ฐ ์ํ์ค๋ก ๋ณํํ ๊ฒฐ๊ณผ์ธ IDL
USVString๊ฐ์ ๋ฐํ.
IDL USVString
๊ฐ S๋ฅผ
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ S
์์ฒด๋ค.
3.2.13. object
IDL object ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ Object ๊ฐ์ผ๋ก ํํ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก
๋ณํํด object ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
V๊ฐ Object๊ฐ ์๋๋ฉด
TypeError๋ฅผ ๋์ง๋๋ค. -
V์ ๋์ผ ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL
object๊ฐ์ ๋ฐํ.
IDL object ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น object๊ฐ ์ฐธ์กฐํ๋ ๋์ผ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ Object
๊ฐ์ด๋ค.
3.2.14. symbol
IDL symbol ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ Symbol ๊ฐ์ผ๋ก ํํ๋๋ค.
symbol ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
V๊ฐ Symbol์ด ์๋๋ฉด
TypeError๋ฅผ ๋์ง๋๋ค. -
V์ ๋์ผ ์ฌ๋ณผ์ ์ฐธ์กฐํ๋ IDL
symbol๊ฐ์ ๋ฐํ.
IDL symbol ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋,
ํด๋น symbol๊ณผ ๋์ผ ์ฌ๋ณผ์ ์ฐธ์กฐํ๋ Symbol ๊ฐ์ด๋ค.
3.2.15. ์ธํฐํ์ด์ค ํ์
IDL ์ธํฐํ์ด์ค ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ Object ๊ฐ(ํจ์ ๊ฐ์ฒด ํฌํจ)์ผ๋ก ํํ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํด ์ธํฐํ์ด์ค ํ์ ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ(I๋ ํด๋น ์ธํฐํ์ด์ค):
-
V๊ฐ I๋ฅผ ๊ตฌํํ๋ฉด, ํด๋น ํ๋ซํผ ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ์ธํฐํ์ด์ค ํ์ ๊ฐ์ ๋ฐํ.
IDL ์ธํฐํ์ด์ค ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋, ํด๋น ์ธํฐํ์ด์ค ํ์ ๊ฐ์ด ์ฐธ์กฐํ๋ ๋์ผ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ Object ๊ฐ์ด๋ค.
3.2.16. ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์
IDL ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ Object ๊ฐ(ํจ์ ๊ฐ์ฒด ํฌํจ)์ผ๋ก ํํ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํด ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
V ๊ฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด , TypeError ๋ฅผ throw ํ๋ค.
-
V๋ฅผ ์ฐธ์กฐํ๊ณ , incumbent settings object๋ฅผ ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ก ํ๋ IDL ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ์ ๋ฐํ.
IDL ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋, ํด๋น ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ์ด ์ฐธ์กฐํ๋ ๋์ผ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ Object ๊ฐ์ด๋ค.
3.2.17. ๋์ ๋๋ฆฌ ํ์
IDL ๋์ ๋๋ฆฌ ํ์ ๊ฐ์ JavaScript Object ๊ฐ์ผ๋ก ํํ๋ฉ๋๋ค. ๊ฐ์ฒด(๋๋ ๊ทธ ํ๋กํ ํ์ ์ฒด์ธ)์ ์์ฑ์ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ์ ๋์ํฉ๋๋ค.
JavaScript ๊ฐ jsDict๋ ๋ณํ๋์ด IDL ๋์ ๋๋ฆฌ ํ์ ๊ฐ์ด ๋๋ฉฐ, ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํฉ๋๋ค(์ฌ๊ธฐ์ D๋ ๋์ ๋๋ฆฌ ํ์ ์ ๋๋ค):
-
jsDict๊ฐ Object๊ฐ ์๋๊ณ jsDict๊ฐ
undefined ๋null ๋ ์๋๋ผ๋ฉด,TypeError๋ฅผ ๋ฐ์์ํต๋๋ค. -
idlDict๋ฅผ ํ์ D์ ๋์ ๋๋ฆฌ๋ฅผ ๋ํ๋ด๋ ๋น ์์๊ฐ ์ง์ ๋ ๋งต์ผ๋ก ๋ก๋๋ค.
-
dictionaries๋ฅผ D์ D์ ๋ชจ๋ ์์๋ ๋์ ๋๋ฆฌ๋ก ๊ตฌ์ฑ๋ ๋ชฉ๋ก์ผ๋ก ๋๊ณ , ๊ฐ์ฅ ๋ ํ์๋ ๊ฒ๋ถํฐ ๊ฐ์ฅ ๋ง์ด ํ์๋ ๊ฒ ์์๋ก ์ ๋ ฌํฉ๋๋ค.
-
dictionaries์ ๊ฐ ๋์ ๋๋ฆฌ dictionary์ ๋ํด ์์๋๋ก:
-
dictionary์ ์ ์ธ๋ ๊ฐ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ member์ ๋ํด ์ฌ์ ์์ผ๋ก:
-
key๋ฅผ member์ ์๋ณ์๋ก ๋ก๋๋ค.
-
jsDict๊ฐ
undefined ๋๋null ์ธ ๊ฒฝ์ฐ:-
jsMemberValue๋ฅผ
undefined ๋ก ๋ก๋๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด,
-
jsMemberValue๊ฐ
undefined ๊ฐ ์๋ ๊ฒฝ์ฐ: -
๊ทธ๋ ์ง ์๊ณ , jsMemberValue๊ฐ
undefined ์ด์ง๋ง member์ ๊ธฐ๋ณธ๊ฐ์ด ์๋ ๊ฒฝ์ฐ:-
idlMemberValue๋ฅผ member์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋ก๋๋ค.
-
idlDict[key]๋ฅผ ์ค์ ํ์ฌ idlMemberValue๋ก ํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์๊ณ , jsMemberValue๊ฐ
undefined ์ด๊ณ member๊ฐ ํ์์ธ ๊ฒฝ์ฐ,TypeError๋ฅผ ๋ฐ์์ํต๋๋ค.
-
-
-
idlDict๋ฅผ ๋ฐํํฉ๋๋ค.
์ฐธ๊ณ : JavaScript ๊ฐ์ฒด์์ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ๋ฅผ ์กฐํํ๋ ์์๋ ๊ฐ์ฒด์ ์์ฑ ์ด๊ฑฐ ์์์ ๋ฐ๋์ ๊ฐ์ง๋ ์์ต๋๋ค.
IDL ๋์ ๋๋ฆฌ ๊ฐ V๋ ๋ณํ๋์ด JavaScript Object ๊ฐ์ด ๋๋ฉฐ, ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํฉ๋๋ค(์ฌ๊ธฐ์ D๋ ๋์ ๋๋ฆฌ์ ๋๋ค):
-
O๋ฅผ OrdinaryObjectCreate(
%Object.prototype%)๋ก ๋ก๋๋ค. -
dictionaries๋ฅผ D์ D์ ๋ชจ๋ ์์๋ ๋์ ๋๋ฆฌ๋ก ๊ตฌ์ฑ๋ ๋ชฉ๋ก์ผ๋ก ๋๊ณ , ๊ฐ์ฅ ๋ ํ์๋ ๊ฒ๋ถํฐ ๊ฐ์ฅ ๋ง์ด ํ์๋ ๊ฒ ์์๋ก ์ ๋ ฌํฉ๋๋ค.
-
dictionaries์ ๊ฐ ๋์ ๋๋ฆฌ dictionary์ ๋ํด ์์๋๋ก:
-
dictionary์ ์ ์ธ๋ ๊ฐ ๋์ ๋๋ฆฌ ๋ฉค๋ฒ member์ ๋ํด ์ฌ์ ์์ผ๋ก:
-
key๋ฅผ member์ ์๋ณ์๋ก ๋ก๋๋ค.
-
V[key]๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ:
-
idlValue๋ฅผ V[key]๋ก ๋ก๋๋ค.
-
value๋ฅผ idlValue๋ฅผ JavaScript ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค.
-
! CreateDataPropertyOrThrow(O, key, value)๋ฅผ ์ํํฉ๋๋ค.
member์ ๊ธฐ๋ณธ๊ฐ์ด ์์ผ๋ฉด, key๋ ํญ์ V์ ์กด์ฌํ๋ค๋ ์ ์ ๊ธฐ์ตํ์ญ์์ค.
-
-
-
-
O๋ฅผ ๋ฐํํฉ๋๋ค.
3.2.18. ์ด๊ฑฐํ ํ์
IDL ์ด๊ฑฐํ ํ์ ์ ์๋ฐ์คํฌ๋ฆฝํธ String ๊ฐ์ผ๋ก ํํ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํด ์ด๊ฑฐํ ํ์ ๊ฐ์ผ๋ก ๋ง๋๋ ๋ฐฉ๋ฒ(E๋ ํด๋น ์ด๊ฑฐํ):
-
S๊ฐ E์ ์ด๊ฑฐํ ๊ฐ์ ํฌํจ๋์ง ์์ผ๋ฉด throw
TypeError. -
S์ ๋์ผํ E ํ์ ์ ์ด๊ฑฐํ ๊ฐ์ ๋ฐํ.
IDL ์ด๊ฑฐํ ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋, ํด๋น ์ด๊ฑฐํ ๊ฐ๊ณผ ๋์ผํ ์ฝ๋ ์ ๋ ์ํ์ค๋ฅผ ๋ํ๋ด๋ String ๊ฐ์ด๋ค.
3.2.19. ์ฝ๋ฐฑ ํจ์ ํ์
IDL ์ฝ๋ฐฑ ํจ์ ํ์
์ ์๋ฐ์คํฌ๋ฆฝํธ ํจ์
๊ฐ์ฒด๋ก ํํ๋๋ค. ๋จ, [LegacyTreatNonObjectAsNull]์ด
๋ถ์ ๊ฒฝ์ฐ์๋ ์๋ฌด ๊ฐ์ฒด๋ ๋ ์ ์๋ค.
JavaScript ๊ฐ V๋ ๋ณํ๋์ด ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํจ์ผ๋ก์จ IDL ์ฝ๋ฐฑ ํจ์ ํ์ ๊ฐ์ด ๋ฉ๋๋ค:
-
IsCallable(V) ํธ์ถ ๊ฒฐ๊ณผ๊ฐ
false ์ด๊ณ IDL ๊ฐ์ผ๋ก์ ๋ณํ์ด V๊ฐ ์์ฑ์ ํ ๋น๋์๊ธฐ ๋๋ฌธ์ ์ํ๋๋ ๊ฒ์ด ์๋๋ฉฐ, ํด๋น ์์ฑ์ ํ์ ์ด ๋ ํ์ฉ ์ฝ๋ฐฑ ํจ์์ด๊ณ [LegacyTreatNonObjectAsNull]๋ก ์ฃผ์์ด ์ง์ ๋์ด ์๋ค๋ฉด,TypeError๋ฅผ ๋ฐ์์ํต๋๋ค. -
V๊ฐ ๋ํ๋ด๋ ๊ฒ๊ณผ ๋์ผํ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๊ณ , ํ์ง ์ค์ ๊ฐ์ฒด๋ฅผ ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ก ํ๋ IDL ์ฝ๋ฐฑ ํจ์ ํ์ ๊ฐ์ ๋ฐํํฉ๋๋ค.
IDL ์ฝ๋ฐฑ ํจ์ ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋, ํด๋น ์ฝ๋ฐฑ ํจ์ ํ์ ๊ฐ์ด ์ฐธ์กฐํ๋ ๋์ผ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๊ฐ์ด๋ค.
3.2.20. ๋ ํ์ฉ ํ์ โ T?
IDL ๋ ํ์ฉ ํ์
๊ฐ์
๋ด๋ถ IDL ํ์
์ ๋์ํ๋ JavaScript
ํ์
์ ๊ฐ ๋๋
JavaScript
JavaScript ๊ฐ V๋ ๋ณํ๋์ด
IDL ๋ ํ์ฉ
ํ์
T?
๊ฐ(T๋ ๋ด๋ถ ํ์
)์ด
๋๋ฉฐ, ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
V๊ฐ Object๊ฐ ์๋๊ณ , IDL ๊ฐ์ผ๋ก์ ๋ณํ์ด V๊ฐ ์์ฑ์ ํ ๋น๋์๊ธฐ ๋๋ฌธ์ ์ํ๋๊ณ ๊ทธ ํ์ ์ด ๋ ํ์ฉ ์ฝ๋ฐฑ ํจ์์ด๋ฉฐ [
LegacyTreatNonObjectAsNull]๋ก ์ฃผ์์ด ์ง์ ๋์ด ์๋ค๋ฉด, IDL ๋ ํ์ฉ ํ์T?๊ฐnull ์ ๋ฐํํฉ๋๋ค. -
๊ทธ๋ ์ง ์๊ณ , V๊ฐ
undefined ์ด๋ฉฐ, T๊ฐ undefined๋ฅผ ํฌํจํ๋ค๋ฉด, ์ ์ผํundefined๊ฐ์ ๋ฐํํฉ๋๋ค. -
๊ทธ๋ ์ง ์๊ณ , V๊ฐ
null ๋๋undefined ์ด๋ฉด, IDL ๋ ํ์ฉ ํ์T?๊ฐnull ์ ๋ฐํํฉ๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, V๋ฅผ ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ฉฐ, ๋ด๋ถ IDL ํ์
T์ ๋ํ ๊ท์น์ ์ฌ์ฉํฉ๋๋ค.
IDL ๋ ํ์ฉ ํ์ ๊ฐ์ JavaScript ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
IDL ๋ ํ์ฉ ํ์
T?๊ฐ์ดnull ์ด๋ฉด, JavaScript ๊ฐ์null ์ ๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, JavaScript ๊ฐ์ IDL ๋ ํ์ฉ ํ์ ๊ฐ์ ๋ด๋ถ IDL ํ์
T์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ์ ๋๋ค.
3.2.21. ์ํ์ค โ sequence<T>
IDL sequence<T> ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ Array ๊ฐ์ผ๋ก ํํ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํด sequence<T> ๊ฐ์ผ๋ก ๋ง๋๋ ๋ฐฉ๋ฒ:
-
V ๊ฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด , TypeError ๋ฅผ throw ํ๋ค.
-
method๋ฅผ ? GetMethod(V,
%Symbol.iterator%) ๊ฒฐ๊ณผ๋ก ๋๋ค. -
V์ method๋ก ์ํ์ค ์์ฑ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํ.
sequence<T> ํ์ ์ IDL ์ํ์ค ๊ฐ S๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ Array ๊ฐ์ฒด๋ก ๋ณํํ๋ ๋ฐฉ๋ฒ:
-
n์ S์ ๊ธธ์ด๋ก ๋๋ค.
-
A๋ฅผ
[]์์ผ๋ก ์์ฑํ ์ Array ๊ฐ์ฒด๋ก ๋๋ค. -
i๋ฅผ 0์ผ๋ก ์ด๊ธฐํ.
-
i < n ๋์:
-
V๋ฅผ S์ ์ธ๋ฑ์ค i์ ๊ฐ์ผ๋ก ๋๋ค.
-
E๋ฅผ V๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(A, P, E)์ ์ํ.
-
i๋ฅผ i + 1๋ก ์ค์ .
-
-
A๋ฅผ ๋ฐํ.
3.2.21.1. ์ดํฐ๋ฌ๋ธ์์ ์ํ์ค ์์ฑํ๊ธฐ
์ดํฐ๋ฌ๋ธ iterable๊ณผ ์ดํฐ๋ ์ดํฐ getter method๊ฐ ์ฃผ์ด์ก์ ๋, sequence<T> ํ์ ์ IDL ๊ฐ์ ์์ฑํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ๋ค:
-
iteratorRecord๋ฅผ ? GetIteratorFromMethod(iterable, method)๋ก ์ค์ ํ๋ค.
-
i๋ฅผ 0์ผ๋ก ์ด๊ธฐํํ๋ค.
-
๋ฐ๋ณตํ๋ค
-
next๋ฅผ ? IteratorStepValue(iteratorRecord)๋ก ์ค์ ํ๋ค.
-
next๊ฐ
done ์ด๋ฉด, i ๊ธธ์ด์ sequence<T> ํ์ ์ IDL ์ํ์ค ๊ฐ์ ๋ฐํํ๋ค. ์ด๋ ์ธ๋ฑ์ค j์ ์์ ๊ฐ์ Sj์ด๋ค. -
Si๋ฅผ next๋ฅผ T ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ด๊ธฐํํ๋ค.
-
i๋ฅผ i + 1๋ก ์ค์ ํ๋ค.
-
๋ค์ interface๋ ์ํ์ค ํ์ ์ attribute์ ์ํ์ค ํ์ ์ ์ธ์๋ฅผ ๊ฐ๋ operation์ ์ ์ํ๋ค.
[Exposed =Window ]interface Canvas {sequence <DOMString >getSupportedImageCodecs ();undefined drawPolygon (sequence <double >coordinates );sequence <double >getLastDrawnPolygon (); // ... };
์ด ์ธํฐํ์ด์ค์ JavaScript ๊ตฌํ์์, String ํ์
์ ์์๋ฅผ ๊ฐ์ง Array ๊ฐ์ฒด๋ sequence<DOMString>์
๋ํ๋ด๊ณ , Number ํ์
์ ์์๋ฅผ ๊ฐ์ง Array๋ sequence<double>์ ๋ํ๋ธ๋ค. Array ๊ฐ์ฒด๋ ์ค์ง์ ์ผ๋ก
๊ฐ์ผ๋ก ์ ๋ฌ๋๋ค; getSupportedImageCodecs() ํจ์๋ฅผ ํธ์ถํ ๋๋ง๋ค ์๋ก์ด Array๊ฐ ๋ฐํ๋๋ฉฐ, Array๋ฅผ
drawPolygon์ ์ ๋ฌํ๋๋ผ๋ ํธ์ถ์ด ๋๋ ํ ์ฐธ์กฐ๊ฐ ์ ์ง๋์ง ์๋๋ค.
// Canvas ์ธ์คํด์ค๋ฅผ ์ป๋๋ค. getSupportedImageCodecs()๊ฐ "image/png"์ "image/svg+xml" ๋ ๊ฐ์ DOMString ๊ฐ์ ๊ฐ๋ ์ํ์ค๋ฅผ ๋ฐํํ๋ค๊ณ ๊ฐ์ . // ๊ธธ์ด๊ฐ 2์ธ Array ๊ฐ์ฒด. var canvas= getCanvas(); // ๊ธธ์ด๊ฐ 2์ธ Array ๊ฐ์ฒด. var supportedImageCodecs= canvas. getSupportedImageCodecs(); // "image/png"๋ก ํ๊ฐ๋จ. supportedImageCodecs[ 0 ]; // canvas.getSupportedImageCodecs()๋ฅผ ํธ์ถํ ๋๋ง๋ค ์๋ก์ด Array ๊ฐ์ฒด๊ฐ ๋ฐํ๋๋ฏ๋ก, ๋ฐํ๋ Array๋ฅผ ์์ ํด๋ ๋ค์ ํธ์ถ์ ๊ฐ์๋ ์ํฅ์ด ์๋ค. supportedImageCodecs[ 0 ] = "image/jpeg" ; // "image/png"๋ก ํ๊ฐ๋จ. canvas. getSupportedImageCodecs()[ 0 ]; // ๊ฐ ํธ์ถ๋ง๋ค ์๋ก์ด Array ๊ฐ์ฒด๊ฐ ๋ฐํ๋๋ฏ๋ก, ์ด ๋น๊ต๋ false๊ฐ ๋จ. canvas. getSupportedImageCodecs() == canvas. getSupportedImageCodecs(); // Number์ Array... var a= [ 0 , 0 , 100 , 0 , 50 , 62.5 ]; // ...์ sequence<double>์ ๊ธฐ๋ํ๋ ํ๋ซํผ ๊ฐ์ฒด์ ์ ๋ฌํ ์ ์์. canvas. drawPolygon( a); // ๊ฐ ์์๋ ๋จผ์ ToNumber()๋ฅผ ํธ์ถํ์ฌ double๋ก ๋ณํ๋จ. // ๋ฐ๋ผ์ ๋ค์ ํธ์ถ์ ์ด์ ํธ์ถ๊ณผ ๋์ผํ์ง๋ง "hi"๊ฐ drawPolygon() ๋ฐํ ์ ์ alert๋จ. a= [ false , "" , { valueOf: function () { alert( "hi" ); return 100 ; } }, 0 , "50" , new Number( 62.5 )]; canvas. drawPolygon( a); // drawPolygon()์ ์ ๋ฌ๋ Array๋ฅผ ๋ณ๊ฒฝํด๋ Canvas์๋ ์ํฅ์ ์ฃผ์ง ์์. ๊ฐ์ผ๋ก ์ ๋ฌ๋๊ธฐ ๋๋ฌธ. a[ 4 ] = 20 ; var b= canvas. getLastDrawnPolygon(); alert( b[ 4 ]); // "50"์ด alert๋จ.
3.2.22. ๋น๋๊ธฐ ์ํ์ค โ async_sequence<T>
JavaScript ๋ฐ์ธ๋ฉ์์, IDL async sequence ๊ฐ์ ๋ค์ struct์ items๋ก ํํ๋๋ค:
-
object, JavaScript ๊ฐ
-
method, JavaScript ๊ฐ
-
type, "
sync" ๋๋ "async"
-
V๊ฐ Object๊ฐ ์๋๋ฉด, TypeError๋ฅผ
throwํ๋ค. -
method๋ฅผ ? GetMethod(obj,
%Symbol.asyncIterator%)๋ก ์ค์ ํ๋ค. -
method๊ฐ
undefined ์ผ ๊ฒฝ์ฐ:-
syncMethod๋ฅผ ? GetMethod(obj,
%Symbol.iterator%)๋ก ์ค์ ํ๋ค. -
IDL async sequence ๊ฐ์ ๋ฐํํ๋ค. object๋ V, method๋ syncMethod, type์ "
sync"๋ก ์ค์ ๋๋ค.
-
-
IDL async sequence ๊ฐ์ ๋ฐํํ๋ค. object๋ V, method๋ method, type ์ "
async"๋ก ์ค์ ๋๋ค.
-
V์ object๋ฅผ ๋ฐํํ๋ค.
3.2.22.1. ๋น๋๊ธฐ ์ํ์ค ๋ฐ๋ณต
๋น๋๊ธฐ ์ํ์ค๋ ์ง์ ์ ์ผ๋ก ๋ฐ๋ณต๋์ง ์๋๋ค. ๋์ ๋จผ์ ์ด์ด์ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ๋ฅผ ์์ฑํ๋ค. ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ๋ ๋น๋๊ธฐ์ ์ผ๋ก ๋ฐ๋ณตํ์ฌ ๊ฐ์ ์์ฑํ ์ ์๋ค.
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ๋ค์ ๊ตฌ์กฐ์ฒด์ด๋ฉฐ, ๋ค์ ํญ๋ชฉ๋ค์ ๊ฐ์ง๋ค:
-
underlying record, Iterator Record
-
type parameter, ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ๊ฐ ์์ฑํ๋ ๊ฐ์ ํ์ ์ ๋ํ๋ด๋ IDL ํ์
๋น๋๊ธฐ ์ํ์ค ์ด๊ธฐ๋ฅผ ์ํด
async_sequence<T>
sequence์ ๋ํด:
-
iterator๋ฅผ ? GetIteratorFromMethod(sequence์ object, sequence์ method)๋ก ์ค์ ํ๋ค.
-
sequence์ type์ด "
sync"์ด๋ฉด, iterator๋ฅผ CreateAsyncFromSyncIterator(iterator)๋ก ์ค์ ํ๋ค. -
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ ๋ฐํํ๋๋ฐ, underlying record๋ iterator๋ก, type parameter๋ T๋ก ์ค์ ํ๋ค.
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ์ ๋ค์ ๊ฐ ๊ตฌํ๊ธฐ๋ฅผ ์ํด ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ iterator์ ๋ํด:
-
nextResult๋ฅผ IteratorNext(iterator์ underlying record)๋ก ์ค์ ํ๋ค.
-
nextResult๊ฐ abrupt completion์ด๋ฉด, ๊ฑฐ๋ถ๋ ํ๋ผ๋ฏธ์ค nextResult.[[Value]]๋ฅผ ๋ฐํํ๋ค.
-
nextPromise๋ฅผ ํด๊ฒฐ๋ ํ๋ผ๋ฏธ์ค nextResult.[[Value]]๋ก ์ค์ ํ๋ค.
-
nextPromise์ ๋ํด ๋ฐ์ํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋๋ฐ, ์ด๋ iterResult๋ฅผ ์ธ์๋ก ํ๋ค:
-
iterResult๊ฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด, throw ํ๋ค.
TypeError. -
done์ ? IteratorComplete(iterResult)๋ก ์ค์ ํ๋ค.
-
done์ด true์ด๋ฉด:
-
๋ฐ๋ณต ์ข ๋ฃ๋ฅผ ๋ฐํํ๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
V๋ฅผ ? IteratorValue(iterResult)๋ก ์ค์ ํ๋ค.
-
value๋ฅผ ๋ณํ V๋ฅผ iterator์ type parameter ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
value๋ฅผ ๋ฐํํ๋ค.
-
-
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๋ซ๊ธฐ๋ฅผ ์ํด
async iterator<T>
iterator,
ECMAScript ๊ฐ reason๊ณผ ํจ๊ป:
-
iteratorRecord๋ฅผ iterator์ underlying record๋ก ์ค์ ํ๋ค.
-
iteratorObj๋ฅผ iteratorRecord.[[Iterator]]๋ก ์ค์ ํ๋ค.
-
returnMethod๋ฅผ GetMethod(iteratorObj, "
return")๋ก ์ค์ ํ๋ค. -
returnMethod๊ฐ abrupt completion์ด๋ฉด, ๊ฑฐ๋ถ๋ ํ๋ผ๋ฏธ์ค returnMethod.[[Value]]๋ฅผ ๋ฐํํ๋ค.
-
returnMethod๊ฐ
undefined ์ด๋ฉด, ํด๊ฒฐ๋ ํ๋ผ๋ฏธ์คundefined๋ฅผ ๋ฐํํ๋ค. -
returnResult๋ฅผ Call(returnMethod.[[Value]], iteratorObj, ยซ reason ยป)๋ก ์ค์ ํ๋ค.
-
returnResult๊ฐ abrupt completion์ด๋ฉด, ๊ฑฐ๋ถ๋ ํ๋ผ๋ฏธ์ค returnResult.[[Value]]๋ฅผ ๋ฐํํ๋ค.
-
returnPromise๋ฅผ ํด๊ฒฐ๋ ํ๋ผ๋ฏธ์ค returnResult.[[Value]]๋ก ์ค์ ํ๋ค.
-
returnPromise์ ๋ํด ๋ฐ์ํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋๋ฐ, returnPromiseResult๋ฅผ ์ธ์๋ก ํ๋ค:
-
returnPromiseResult๊ฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด, throw ํ๋ค.
TypeError. -
undefined๋ฅผ ๋ฐํํ๋ค.
-
concatN์ operation์ด๋ฉฐ, ๋น๋๊ธฐ ์ํ์ค์์ ์์ฑ๋ ๋ชจ๋ ๋ฌธ์์ด์ ์ฐ๊ฒฐํ ๊ฐ์ ํ๋ผ๋ฏธ์ค๋ก ๋ฐํํ๋ค. ์ด ์ฐ๊ฒฐ์ ๋น๋๊ธฐ
์ํ์ค๊ฐ maxN๊ฐ์ ๋ฌธ์์ด์ ์์ฑํ๋ฉด ์ค๋จ๋๊ณ ์ดํฐ๋ ์ดํฐ๋ฅผ ๋ซ๋๋ค.
interface I {
Promise<DOMString> concatN(async_sequence<DOMString> strings, unsigned long maxN);
};
concatN(sequence, maxN) ๋ฉ์๋ ๋จ๊ณ:
-
promise๋ฅผ ์๋ก์ด ํ๋ผ๋ฏธ์ค๋ก ์ค์ ํ๋ค.
-
result๋ฅผ ๋น ๋ฌธ์์ด๋ก ์ค์ ํ๋ค.
-
n์ 0์ผ๋ก ์ค์ ํ๋ค.
-
iterator๋ฅผ ๋น๋๊ธฐ ์ํ์ค ์ด๊ธฐ์ ๊ฒฐ๊ณผ๋ก sequence์ ๋ํด ์์ฑํ๋ค.
-
step์ ๋น๋๊ธฐ ์ํ์ค๋ฅผ ์ฒ๋ฆฌํ ๋จ๊ณ๋ค์ ์ํ์ค๋ก ์ค์ ํ๋ค:
-
next๋ฅผ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ์ ๋ค์ ๊ฐ ๊ตฌํ๊ธฐ์ ๊ฒฐ๊ณผ๋ก iterator์ ๋ํด ์ป๋๋ค.
-
๋ฐ์ํ์ฌ next๋ฅผ ์ฒ๋ฆฌํ๋ค:
-
next๊ฐ ๊ฐ v๋ก ์ดํ๋์๋ค๋ฉด:
-
v๊ฐ ๋ฐ๋ณต ์ข ๋ฃ๋ผ๋ฉด, resolveํ์ฌ promise๋ฅผ result๋ก ์ดํํ๋ค.
-
result๋ฅผ result์ v๋ฅผ ์ฐ๊ฒฐํ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
n์ n + 1๋ก ์ค์ ํ๋ค.
-
n์ด maxN๋ผ๋ฉด:
-
finish๋ฅผ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๋ซ๊ธฐ ๊ฒฐ๊ณผ๋ก iterator์ reason
undefined๋ก ์ป๋๋ค. -
๋ฐ์ํ์ฌ finish๋ฅผ ์ฒ๋ฆฌํ๋ค:
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
step์ ํธ์ถํ๋ค.
-
-
-
next๊ฐ r๋ก ๊ฑฐ๋ถ๋์๋ค๋ฉด, rejectํ์ฌ promise๋ฅผ r๋ก ๊ฑฐ๋ถํ๋ค.
-
-
-
step์ ํธ์ถํ๋ค.
-
promise๋ฅผ ๋ฐํํ๋ค.
3.2.23. ๋ ์ฝ๋ โ record<K, V>
IDL record<K, V> ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด ๊ฐ์ผ๋ก ํํ๋ฉ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ O๋ ๋ณํ๋์ด
IDL
record<K, V>
๊ฐ์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ ์ ์ฐจ๋ฅผ ๋ฐ๋ฆ
๋๋ค:
-
O๊ฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด, throw๋ฅผ ๋ฐ์์ํต๋๋ค.
TypeError. -
result๋ฅผ
record<K, V>์ ์๋ก์ด ๋น ์ธ์คํด์ค๋ก ์ค์ ํฉ๋๋ค. -
keys๋ฅผ ? O.[[OwnPropertyKeys]]()๋ก ์ค์ ํฉ๋๋ค.
-
๊ฐ keys์ key์ ๋ํด:
-
desc๋ฅผ ? O.[[GetOwnProperty]](key)๋ก ์ค์ ํฉ๋๋ค.
-
desc๊ฐ
undefined ๊ฐ ์๋๊ณ , desc.[[Enumerable]]๊ฐtrue ์ผ ๊ฒฝ์ฐ:-
typedKey๋ฅผ key IDL ๊ฐ์ผ๋ก ๋ณํ ํ์ฌ ํ์ K๋ก ์ฒ๋ฆฌํฉ๋๋ค.
-
typedValue๋ฅผ value IDL ๊ฐ์ผ๋ก ๋ณํ ํ์ฌ ํ์ V๋ก ์ฒ๋ฆฌํฉ๋๋ค.
-
result[typedKey]์ typedValue๋ฅผ ์ค์ ํฉ๋๋ค.
์ฐธ๊ณ : K๊ฐ
USVString์ด๊ณ key์ ์ง์ด ์๋ ๋๋ฆฌ๋ฌธ์๊ฐ ํฌํจ๋ ๊ฒฝ์ฐ, typedKey๊ฐ ์ด๋ฏธ result์ ์์ ์ ์์ต๋๋ค.
-
-
-
result๋ฅผ ๋ฐํํฉ๋๋ค.
IDL
record<โฆ>
๊ฐ D๋
๋ณํ๋์ด
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ค์๊ณผ ๊ฐ์ด ์ฒ๋ฆฌ๋ฉ๋๋ค:
-
result๋ฅผ OrdinaryObjectCreate(
%Object.prototype%)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. -
๊ฐ D์ key โ value ์์ ๋ํด:
-
jsKey๋ฅผ key ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
jsValue๋ฅผ value ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
created๋ฅผ ! CreateDataProperty(result, jsKey, jsValue)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
Assert: created๋
true ์ ๋๋ค.
-
-
result๋ฅผ ๋ฐํํฉ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ {b: 3, a: 4}๋ฅผ
record<DOMString, double>
์ธ์๋ก ์ ๋ฌํ๋ฉด,
IDL ๊ฐ ยซ[ "b" โ 3, "a" โ 4 ]ยป๊ฐ ๋ฉ๋๋ค.
๋ ์ฝ๋๋ ์์ ์ ์ด๊ฑฐ
๊ฐ๋ฅํ
ํ๋กํผํฐ๋ง ๊ณ ๋ คํ๋ฏ๋ก, ๋ค์๊ณผ ๊ฐ์ IDL ์ฐ์ฐ
record<DOMString, double>
identity(record<DOMString, double> arg)์ด ์ธ์๋ฅผ ๋ฐํํ ๋, ์๋ ์ฝ๋๋ assertion์ ๋ง์กฑํฉ๋๋ค:
let proto= { a: 3 , b: 4 }; let obj= { __proto__: proto, d: 5 , c: 6 } Object. defineProperty( obj, "e" , { value: 7 , enumerable: false }); let result= identity( obj); console. assert( result. a=== undefined ); console. assert( result. b=== undefined ); console. assert( result. e=== undefined ); let entries= Object. entries( result); console. assert( entries[ 0 ][ 0 ] === "d" ); console. assert( entries[ 0 ][ 1 ] === 5 ); console. assert( entries[ 1 ][ 0 ] === "c" ); console. assert( entries[ 1 ][ 1 ] === 6 );
๋ ์ฝ๋์ ํค์ ๊ฐ์ ์ ์ฝ๋ ์ ์์ผ๋ฉฐ, ํค๋ ์ธ ๋ฌธ์์ด ํ์ ์ค์์๋ง ์ ์ฝ๋ ์ ์์ต๋๋ค. ์๋ ๋ณํ์ ๋ค์๊ณผ ๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ์ง๋๋ค:
| ๊ฐ | ํ์ ์ ์ ๋ฌ | ๊ฒฐ๊ณผ |
|---|---|---|
{"๐": 1}
|
record<ByteString, double>
|
TypeError
|
{"\uD83D": 1}
|
record<USVString, double>
|
ยซ[ "\uFFFD" โ 1 ]ยป
|
{"\uD83D": {hello: "world"}}
|
record<DOMString, double>
|
ยซ[ "\uD83D" โ 0 ]ยป
|
3.2.24. Promise ํ์ โ Promise<T>
IDL promise ํ์ ๊ฐ์ JavaScript PromiseCapability ๋ ์ฝ๋๋ก ํํ๋ฉ๋๋ค.
JavaScript ๊ฐ V๋ ๋ณํ๋์ด
IDL์
Promise<T>
๊ฐ์ผ๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค. ์ ์ฐจ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
promiseCapability๋ฅผ ? NewPromiseCapability(
%Promise%)๋ก ์ค์ ํฉ๋๋ค. -
? Call(promiseCapability.[[Resolve]],
undefined , ยซ V ยป)๋ฅผ ์ํํฉ๋๋ค. -
promiseCapability๋ฅผ ๋ฐํํฉ๋๋ค.
IDL promise ํ์ ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋, ํด๋น IDL promise ํ์ ์ด ํํํ๋ ๋ ์ฝ๋์ [[Promise]] ํ๋์ ๊ฐ์ ๋๋ค.
JS ๊ฐ์ Promise<T> IDL ๊ฐ์ผ๋ก ๋ณํํ ๋,
๋จผ์ ๊ทธ ๊ฐ์ด (IDL) Promise๋ก ๊ฐ์ธ์ง๊ณ ,
์ดํ์ ๋ฉ์ปค๋์ฆ์ด ๊ทธ promise๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ T ํ์
์ ๊ฐ์ผ๋ก
ํด๊ฒฐ๋๋๋ก ๋ณด์ฅํฉ๋๋ค.
์ฆ, ์๋ฅผ ๋ค์ด,
Promise<T> ์ธ์๋ฅผ ๋ฐ๋๋ก ์ ์๋ ๋ฉ์๋๋
Promise
๊ฐ์ฒด
(๊ฒฐ๊ตญ T ๊ฐ์ฒด๋ก ํด๊ฒฐ๋์ด์ผ ํ๋)์
T ๊ฐ์ฒด ์์ฒด ๋ชจ๋๋ฅผ ์๋์ผ๋ก ํ์ฉํฉ๋๋ค.
(์ฒ์์๋ ๊ทธ ์ธ์ ์ด๋ค ํ์ ์ ๊ฐ์ฒด๋ ๋ฐ์๋ค์ด์ง๋ง, ์๋ชป๋ ํ์ ์ผ๋ก ํด๊ฒฐ๋ ๊ฒฝ์ฐ promise๋ฅผ ์๋์ผ๋ก ๊ฑฐ์ ํ๊ฒ ๋ฉ๋๋ค.)
3.2.24.1. Promise ์์ฑ ๋ฐ ์กฐ์
์๋ก์ด promise ์์ฑ์
Promise<T>
ํ์
์ผ๋ก realm realm์์ ์์ฑํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
constructor๋ฅผ realm.[[Intrinsics]].[[
%Promise%]]๋ก ์ค์ ํฉ๋๋ค. -
? NewPromiseCapability(constructor)๋ฅผ ๋ฐํํฉ๋๋ค.
ํด๊ฒฐ๋ promise ์์ฑ์
Promise<T>
ํ์
์ผ๋ก x (ํ์
T์ ๊ฐ)์ ํจ๊ป realm realm์์ ์์ฑํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
value๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ x์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
constructor๋ฅผ realm.[[Intrinsics]].[[
%Promise%]]๋ก ์ค์ ํฉ๋๋ค. -
promiseCapability๋ฅผ ? NewPromiseCapability(constructor)๋ก ์ค์ ํฉ๋๋ค.
-
! Call(promiseCapability.[[Resolve]],
undefined , ยซ value ยป)๋ฅผ ์ํํฉ๋๋ค. -
promiseCapability๋ฅผ ๋ฐํํฉ๋๋ค.
๊ฑฐ๋ถ๋ promise ์์ฑ์
Promise<T>
ํ์
์ผ๋ก reason r (์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ)๊ณผ ํจ๊ป realm realm์์ ์์ฑํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
constructor๋ฅผ realm.[[Intrinsics]].[[
%Promise%]]๋ก ์ค์ ํฉ๋๋ค. -
promiseCapability๋ฅผ ? NewPromiseCapability(constructor)๋ก ์ค์ ํฉ๋๋ค.
-
! Call(promiseCapability.[[Reject]],
undefined , ยซ r ยป)๋ฅผ ์ํํฉ๋๋ค. -
promiseCapability๋ฅผ ๋ฐํํฉ๋๋ค.
resolve๋ฅผ
Promise<T>
p์ x (ํ์
T์ ๊ฐ)๋ก ํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
x๊ฐ ์ฃผ์ด์ง์ง ์์๋ค๋ฉด,
undefined๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
value๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ x์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
! Call(p.[[Resolve]],
undefined , ยซ value ยป)๋ฅผ ์ํํฉ๋๋ค.
T๊ฐ undefined
์ธ ๊ฒฝ์ฐ, x ์ธ์๋ ์๋ตํ ์ ์์ผ๋ฏ๋ก ๋ ๊ฐ๋จํ "resolve p" ์ฌ์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค.
reject๋ฅผ
Promise<T>
p์ reason r (์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ)์ผ๋ก ํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
react๋ฅผ
Promise<T>
promise์ ๋ํด, promise๊ฐ ์ดํ๋๊ฑฐ๋ ๊ฑฐ๋ถ๋์์ ๋ ์ํํ 1~2๊ฐ์ ๋จ๊ณ ์งํฉ์ ๋ฐ์, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
onFulfilledSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ก V๋ฅผ ๋ฐ์ต๋๋ค:
-
value๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํ V (ํ์ T)๋ก ์ค์ ํฉ๋๋ค.
-
promise๊ฐ ์ดํ๋์์ ๋ ์คํํ ๋จ๊ณ๊ฐ ์๋ค๋ฉด, result๋ฅผ ํด๋น ๋จ๊ณ๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. T๊ฐ
undefined๊ฐ ์๋๋ฉด value๋ฅผ ์ธ์๋ก ์ ๋ฌํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด result๋ฅผ value๋ก ์ค์ ํฉ๋๋ค. -
result๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ์ฌ ๋ฐํํฉ๋๋ค.
-
-
onFulfilled๋ฅผ CreateBuiltinFunction(onFulfilledSteps, 1, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค:
-
onRejectedSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ก R๋ฅผ ๋ฐ์ต๋๋ค:
-
reason๋ฅผ IDL ๊ฐ์ผ๋ก ๋ณํํ R (ํ์
any)๋ก ์ค์ ํฉ๋๋ค. -
promise๊ฐ ๊ฑฐ๋ถ๋์์ ๋ ์คํํ ๋จ๊ณ๊ฐ ์๋ค๋ฉด, result๋ฅผ ํด๋น ๋จ๊ณ๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด result๋ฅผ ๊ฑฐ๋ถ๋ promise ์์ฑ reason์ผ๋ก ์ค์ ํฉ๋๋ค.
-
result๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ์ฌ ๋ฐํํฉ๋๋ค.
-
-
onRejected๋ฅผ CreateBuiltinFunction(onRejectedSteps, 1, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค:
-
constructor๋ฅผ promise.[[Promise]].[[Realm]].[[Intrinsics]].[[
%Promise%]]๋ก ์ค์ ํฉ๋๋ค. -
newCapability๋ฅผ ? NewPromiseCapability(constructor)๋ก ์ค์ ํฉ๋๋ค.
์ฐธ๊ณ : ๋ชจ๋ ํธ์ถ์๊ฐ ๋ฐํ๋
Promise๋ฅผ ์ฌ์ฉํ ํ์๋ ์์ต๋๋ค. ๊ตฌํ์ฒด๋ newCapability ์์ฑ ์๋ต์ ๊ณ ๋ คํ ์ ์์ต๋๋ค. -
PerformPromiseThen(promise.[[Promise]], onFulfilled, onRejected, newCapability)๋ฅผ ์ํํฉ๋๋ค.
-
newCapability๋ฅผ ๋ฐํํฉ๋๋ค.
์ฐธ๊ณ : ์ด ์๊ณ ๋ฆฌ์ฆ์
promise.then()
๋ฉ์๋์ ๋งค์ฐ ์ ์ฌํ๊ฒ ๋์ํฉ๋๋ค.
ํนํ, ๋จ๊ณ์์ U ํ์
์ด๋
Promise<U>
๊ฐ์ ๋ฐํํ๋ ๊ฒฝ์ฐ,
์ด ์๊ณ ๋ฆฌ์ฆ ์ญ์
Promise<U>
๋ฅผ ๋ฐํํฉ๋๋ค.
์ด๋ค ๋จ๊ณ ์ดํ ์ ์ํ๋ฅผ
Promise<T>
promise๊ฐ ์ดํ๋ ๋, ํ์
T ๊ฐ์ ๋ฐ๋ ๋จ๊ณ steps๋ก ๋ค์์ ์ํํฉ๋๋ค:
-
react๋ฅผ promise์ ๋ํด ํธ์ถํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค:
-
promise๊ฐ ๊ฐ v๋ก ์ดํ๋์๋ค๋ฉด:
-
steps๋ฅผ v๋ก ์ํํฉ๋๋ค.
-
-
์ด๋ค ๋จ๊ณ ๊ฑฐ๋ถ ์ ์ํ๋ฅผ
Promise<T>
promise๊ฐ ๊ฑฐ๋ถ๋ ๋, ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ ๋ฐ๋ ๋จ๊ณ steps๋ก ๋ค์์ ์ํํฉ๋๋ค:
-
react๋ฅผ promise์ ๋ํด ํธ์ถํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค:
-
promise๊ฐ reason r๋ก ๊ฑฐ๋ถ๋์๋ค๋ฉด:
-
steps๋ฅผ r๋ก ์ํํฉ๋๋ค.
-
-
๋ชจ๋ ๋๊ธฐ(wait for all)๋ฅผ
list ํ์
์ธ
Promise<T>
๊ฐ promises์ ๋ํด,
list ํ์
T ๊ฐ์ ๋ฐ๋ ์ฑ๊ณต ๋จ๊ณ successSteps์
๊ฑฐ๋ถ reason any ๊ฐ์ ๋ฐ๋ ์คํจ
๋จ๊ณ failureSteps๋ก ๋ค์์ ์ํํฉ๋๋ค:
-
fullfilledCount๋ฅผ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
rejected๋ฅผ false๋ก ์ค์ ํฉ๋๋ค.
-
rejectionHandlerSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ก arg๋ฅผ ๋ฐ์ต๋๋ค:
-
rejected๊ฐ true์ด๋ฉด ์ด ๋จ๊ณ๋ค์ ์ค๋จํฉ๋๋ค.
-
rejected๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
-
failureSteps๋ฅผ arg๋ก ์ํํฉ๋๋ค.
-
-
rejectionHandler๋ฅผ CreateBuiltinFunction(rejectionHandlerSteps, 1, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค:
-
total์ promises์ size๋ก ์ค์ ํฉ๋๋ค.
-
total์ด 0์ด๋ฉด:
-
๋ง์ดํฌ๋กํ์คํฌ ํ์ successSteps๋ฅผ ยซ ยป๋ก ์ํํ๋๋ก ์ถ๊ฐํฉ๋๋ค.
-
๋ฐํํฉ๋๋ค.
-
-
index๋ฅผ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
result๋ฅผ list ํ์ ์ผ๋ก, total ๊ฐ์ null ๊ฐ์ผ๋ก ์ด๊ธฐํํฉ๋๋ค.
-
๊ฐ promises์ promise์ ๋ํด:
-
promiseIndex๋ฅผ index๋ก ์ค์ ํฉ๋๋ค.
-
fulfillmentHandler๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ก arg๋ฅผ ๋ฐ์ต๋๋ค:
-
result[promiseIndex]์ arg๋ฅผ ์ค์ ํฉ๋๋ค.
-
fullfilledCount๋ฅผ fullfilledCount+1๋ก ์ค์ ํฉ๋๋ค.
-
fullfilledCount๊ฐ total๊ณผ ๊ฐ์ผ๋ฉด, successSteps๋ฅผ result๋ก ์ํํฉ๋๋ค.
-
-
fulfillmentHandler๋ฅผ CreateBuiltinFunction(fulfillmentHandler, 1, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค:
-
PerformPromiseThen(promise, fulfillmentHandler, rejectionHandler)๋ฅผ ์ํํฉ๋๋ค.
-
index๋ฅผ index+1๋ก ์ค์ ํฉ๋๋ค.
-
๋ชจ๋ ๊ธฐ๋ค๋ฆฌ๋ promise ์ป๊ธฐ๋ฅผ
list ํ์
Promise<T>
๊ฐ promises์
realm realm์ ๋ํด ์ป์ผ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
promise๋ฅผ ์๋ก์ด promise ์์ฑ์ผ๋ก
Promise<sequence<T>>ํ์ ์ผ๋ก realm์์ ์์ฑํฉ๋๋ค. -
successSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ก results๋ฅผ ๋ฐ์ต๋๋ค:
-
resolve promise๋ฅผ results๋ก ์ํํฉ๋๋ค.
-
-
failureSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ก reason์ ๋ฐ์ต๋๋ค:
-
reject promise ๋ฅผ reason์ผ๋ก ์ํํฉ๋๋ค.
-
-
๋ชจ๋ ๋๊ธฐ(wait for all)๋ฅผ promises์ successSteps, failureSteps๋ก ์ํํฉ๋๋ค.
-
promise๋ฅผ ๋ฐํํฉ๋๋ค.
์ด ์ ์๋ ์ฌ๋ฌ promise์ ๊ฒฐ๊ณผ๋ฅผ ์ง๊ณํ ๋ค, ๊ทธ ๊ฒฐ๊ณผ๋ก ๋ ๋ค๋ฅธ promise๋ฅผ ์์ฑํ๊ณ ์ถ์ ๋ ์ ์ฉํฉ๋๋ค. JavaScript์
Promise.all()
๊ณผ ๊ฐ์ ๋ฐฉ์์
๋๋ค. ๋ ๋ค๋ฅธ promise๋ฅผ ์์ฑํ ํ์๊ฐ ์๋ค๋ฉด ๋ชจ๋ ๋๊ธฐ(waiting for all)๊ฐ ๋ ์ ํฉํ ์ ์์ต๋๋ค.
Promise<T>
promise์
promise.[[Promise]].[[PromiseIsHandled]]๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
์ด ์ ์๋ ๊ฑฐ๋ถ๊ฐ ์์ฃผ ๋ฌด์๋ ๊ฒ์ผ๋ก ์์๋๋ promise์ ์ ์ฉํ๋ฉฐ, ์ด๋ฌํ promise๊ฐ unhandledrejection
์ด๋ฒคํธ๋ฅผ ๋ฐ์์ํค์ง ์๊ฒ ํฉ๋๋ค. ๊ฐ์ฅ ํํ ์ฌ์ฉ ์ฌ๋ก๋ ์น ๊ฐ๋ฐ์๊ฐ ํ์ธํ ์๋, ํ์ง ์์ ์๋ ์๋ promise ์์ฑ์
๋๋ค.
์๋ฅผ ๋ค์ด writableStreamWriter.closed
promise๊ฐ ์์ต๋๋ค.
3.2.24.2. ์์
delay๋ ์ฐ์ฐ์ด๋ฉฐ,
์ง์ ํ ๋ฐ๋ฆฌ์ด ํ์ ์ดํ๋๋ promise๋ฅผ ๋ฐํํฉ๋๋ค.
ํ ์ค์ ์ค๋ช
์ผ๋ก promise๋ฅผ ์ด๋ป๊ฒ ๊ฐ๋จํ๊ฒ resolveํ ์ ์๋์ง ๋ณด์ฌ์ค๋๋ค.
interface I {Promise <undefined >delay (unrestricted double ms ); };
delay(ms) ๋ฉ์๋ ๋จ๊ณ:
-
realm์ this์ ๊ด๋ จ ๋ ๋ฆ์ผ๋ก ์ค์ ํ๋ค.
-
taskSource๋ฅผ ์ ์ ํ ํ์คํฌ ์์ค๋ก ์ค์ ํ๋ค.
-
ms๊ฐ NaN์ด๋ฉด ms๋ฅผ +0์ผ๋ก, ์๋๋ฉด ms์ +0 ์ค ๋ ํฐ ๊ฐ์ผ๋ก ms๋ฅผ ์ค์ ํ๋ค.
-
p๋ฅผ ์๋ก์ด promise๋ก realm์์ ์์ฑํ๋ค.
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
ms ๋ฐ๋ฆฌ์ด ๋๊ธฐํ๋ค.
-
ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ resolve p๋ฅผ ์ํํ๋ค.
-
-
p๋ฅผ ๋ฐํํ๋ค.
validatedDelay ์ฐ์ฐ์ delay ํจ์์ ์ ์ฌํ์ง๋ง, ์ธ์๋ฅผ
๊ฒ์ฆํฉ๋๋ค.
์ด ์์๋ ๋น๋๊ธฐ ์์
์ ์์ํ๊ธฐ ์ ์ ์ฆ์ ์คํจ๋ฅผ ์๋ฆด ๋ rejected promise๋ฅผ ์ด๋ป๊ฒ ์ฌ์ฉํ๋์ง ๋ณด์ฌ์ค๋๋ค.
interface I {Promise <undefined >validatedDelay (unrestricted double ms ); };
validatedDelay(ms) ๋ฉ์๋ ๋จ๊ณ:
-
realm์ this์ ๊ด๋ จ ๋ ๋ฆ์ผ๋ก ์ค์ ํ๋ค.
-
taskSource๋ฅผ ์ ์ ํ ํ์คํฌ ์์ค๋ก ์ค์ ํ๋ค.
-
ms๊ฐ NaN์ด๋ฉด ๊ฑฐ๋ถ๋ promise
TypeError๋ฅผ realm์์ ๋ฐํํ๋ค. -
ms < 0์ด๋ฉด ๊ฑฐ๋ถ๋ promise
RangeError๋ฅผ realm์์ ๋ฐํํ๋ค. -
p๋ฅผ ์๋ก์ด promise๋ก realm์์ ์์ฑํ๋ค.
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
ms ๋ฐ๋ฆฌ์ด ๋๊ธฐํ๋ค.
-
ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ resolve p๋ฅผ ์ํํ๋ค.
-
-
p๋ฅผ ๋ฐํํ๋ค.
addDelay๋ ์ฐ์ฐ์ด๋ฉฐ, promise๊ฐ settle๋ ํ ๋ฐํ promise๊ฐ settle๋๊ธฐ๊น์ง ์ถ๊ฐ ๋ฐ๋ฆฌ์ด
์ง์ฐ์ ์ ๊ณตํฉ๋๋ค.
interface I {Promise <any >addDelay (Promise <any >promise ,unrestricted double ms ); };
addDelay(ms, promise) ๋ฉ์๋ ๋จ๊ณ:
-
realm์ this์ ๊ด๋ จ ๋ ๋ฆ์ผ๋ก ์ค์ ํ๋ค.
-
taskSource๋ฅผ ์ ์ ํ ํ์คํฌ ์์ค๋ก ์ค์ ํ๋ค.
-
ms๊ฐ NaN์ด๋ฉด ms๋ฅผ +0์ผ๋ก, ์๋๋ฉด ms์ +0 ์ค ๋ ํฐ ๊ฐ์ผ๋ก ms๋ฅผ ์ค์ ํ๋ค.
-
p๋ฅผ ์๋ก์ด promise๋ก realm์์ ์์ฑํ๋ค.
-
React๋ฅผ promise์ ๋ํด ์ํํ๋ค:
-
promise๊ฐ ๊ฐ v๋ก ์ดํ๋์๋ค๋ฉด:
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
ms ๋ฐ๋ฆฌ์ด ๋๊ธฐํ๋ค.
-
ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ resolve p๋ฅผ v๋ก ์ํํ๋ค.
-
-
-
promise๊ฐ reason r๋ก ๊ฑฐ๋ถ๋์๋ค๋ฉด:
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
ms ๋ฐ๋ฆฌ์ด ๋๊ธฐํ๋ค.
-
ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ reject p๋ฅผ r๋ก ์ํํ๋ค.
-
-
-
-
p๋ฅผ ๋ฐํํ๋ค.
environment.ready๋ ํน์ฑ(attribute)์ด๋ฉฐ, ํ๊ฒฝ(์: DOM ๋ฌธ์)์ ์ผ๋ถ๊ฐ "์ค๋น๋จ" ์ํ๊ฐ ๋์์์ ์๋ฆฝ๋๋ค.
ํ๊ฒฝ ๋น๋๊ธฐ์ฑ์ ํํํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
interface Environment {readonly attribute Promise <undefined >ready ; };
๋ชจ๋ Environment ๊ฐ์ฒด๋ ready promise๋ฅผ ๊ฐ์ ธ์ผ ํ๋ฉฐ,
์ด ๊ฐ์
Promise<undefined>์ด๋ค.
ready ํน์ฑ getter ๋จ๊ณ:
-
this์ ready promise๋ฅผ ๋ฐํํ๋ค.
Environment ๊ฐ์ฒด๋ฅผ realm realm์์ ์์ฑํ๋ ค๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
taskSource๋ฅผ ์ ์ ํ ํ์คํฌ ์์ค๋ก ์ค์ ํ๋ค.
-
environment๋ฅผ ์๋ก์ด
Environment๊ฐ์ฒด๋ก realm์์ ์์ฑํ๋ค. -
environment์ ready promise๋ฅผ ์๋ก์ด promise๋ก realm์์ ์ค์ ํ๋ค.
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
๋น๋๊ธฐ ์์ ์ํ.
-
environment๊ฐ ์ ์์ ์ผ๋ก ready๊ฐ ๋๋ฉด, ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ resolve environment์ ready promise๋ฅผ ์ํํ๋ค.
-
environment๊ฐ ready๊ฐ ๋์ง ๋ชปํ๋ฉด, ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ reject environment์ ready promise๋ฅผ "
NetworkError"DOMException์ผ๋ก ๊ฑฐ๋ถํ๋ค.
-
-
environment๋ฅผ ๋ฐํํ๋ค.
addBookmark๋ ์ฐ์ฐ์ด๋ฉฐ, ์ฌ์ฉ์์๊ฒ ํ์ฌ ์นํ์ด์ง๋ฅผ ๋ถ๋งํฌ์ ์ถ๊ฐํด๋ฌ๋ผ๊ณ ์์ฒญํฉ๋๋ค.
์ค์ ๋์์ธ ์์
์์ ํ์๋ ์์๋ก,
ํ๊ฒฝ ๋น๋๊ธฐ์ฑ๊ณผ ์ฆ์ ๊ฑฐ๋ถ๋ฅผ ๋ค๋ฃจ๋ ํ์ค์ ์ธ ์๋๋ฆฌ์ค๋ฅผ ๋ณด์ฌ์ค๋๋ค.
interface I {Promise <undefined >addBookmark (); };
addBookmark() ๋ฉ์๋ ๋จ๊ณ:
-
taskSource๋ฅผ ์ ์ ํ ํ์คํฌ ์์ค๋ก ์ค์ ํ๋ค.
-
์ด ๋ฉ์๋๊ฐ ๋ช ์์ ์ฌ์ฉ์ ๋์์ ๊ฒฐ๊ณผ๋ก ํธ์ถ๋์ง ์์๋ค๋ฉด, ๊ฑฐ๋ถ๋ promise๋ฅผ "
SecurityError"DOMException์ผ๋ก ๋ฐํํ๋ค. -
๋ฌธ์์ ๋์ ๋ชจ๋๊ฐ standalone์ด๋ฉด ๊ฑฐ๋ถ๋ promise๋ฅผ "
NotSupportedError"DOMException์ผ๋ก ๋ฐํํ๋ค. -
promise๋ฅผ ์๋ก์ด promise๋ก ์์ฑํ๋ค.
-
info๋ฅผ ์น ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ์ป์ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
๋ค์ ๋จ๊ณ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ๋ค:
-
info๋ฅผ ํ์ฉํ์ฌ, ์ฌ์ฉ์ ์์ด์ ํธ๋ณ ๋ฐฉ์์ผ๋ก ์ต์ข ์ฌ์ฉ์๊ฐ ๋ถ๋งํฌ ์ถ๊ฐ ์ฌ๋ถ๋ฅผ ์ ํํ๋๋ก ํ๋ค.
-
์ต์ข ์ฌ์ฉ์๊ฐ ๋ถ๋งํฌ ์ถ๊ฐ ์์ฒญ์ ์ค๋จ(์: ESC ํค, ์ทจ์ ๋ฒํผ ๋ฑ)ํ๋ฉด, ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ reject promise๋ฅผ "
AbortError"DOMException์ผ๋ก ์ํํ๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ, ํ์คํฌ ํ์ ๋ฑ๋กํ์ฌ taskSource์ resolve promise๋ฅผ ์ํํ๋ค.
-
-
-
promise๋ฅผ ๋ฐํํ๋ค.
[SERVICE-WORKERS]์
์ฌ๋ฌ ๊ณณ์์ ๋ชจ๋
๊ธฐ๋ค๋ฆฌ๋ promise ์ป๊ธฐ(get a promise to wait for all)๋ฅผ ์ฌ์ฉํฉ๋๋ค.
batchRequest๋ ๊ทธ ์ฉ๋ก ์ค ํ๋๋ฅผ ๋จ์ํํ ์์์
๋๋ค.
์
๋ ฅ๊ฐ์ผ๋ก sequence ํ์
์
URL ๋ชฉ๋ก์ ๋ฐ๊ณ , ๊ฐ URL์ fetchํ์ฌ ์์ฑ๋ sequence ํ์
์
Response
๊ฐ์ฒด์ promise๋ฅผ ๋ฐํํฉ๋๋ค.
fetch ์ค ํ๋๋ผ๋ ์คํจํ๋ฉด, ํด๋น ์คํจ๋ก ๊ฑฐ๋ถ๋ promise๋ฅผ ๋ฐํํฉ๋๋ค.
interface I {Promise <sequence <Response >>batchRequest (sequence <USVString >urls ); };
batchRequest(urls) ๋ฉ์๋ ๋จ๊ณ:
-
responsePromises๋ฅผ ยซ ยป๋ก ์ค์ ํ๋ค.
-
๊ฐ urls์ url์ ๋ํด:
-
p๋ฅผ ๋ชจ๋ ๊ธฐ๋ค๋ฆฌ๋ promise ์ป๊ธฐ๋ก responsePromises์ ๋ํด ํธ์ถํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
p๋ฅผ ๋ฐํํ๋ค.
3.2.25. Union ํ์
IDL union ํ์ ๊ฐ์ ํด๋น union์ ๋ฉค๋ฒ ํ์ ์ ํด๋นํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ํํ๋ฉ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ฅผ IDL union ํ์ ๊ฐ์ผ๋ก ๋ณํํ๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ํฉ๋๋ค:
-
union ํ์ ์ด undefined๋ฅผ ํฌํจํ๊ณ V๊ฐ
undefined ๋ผ๋ฉด, ๊ณ ์ ํundefined๊ฐ์ ๋ฐํํฉ๋๋ค. -
union ํ์ ์ด nullable ํ์ ์ ํฌํจํ๊ณ V๊ฐ
null ๋๋undefined ๋ผ๋ฉด, IDL ๊ฐnull ์ ๋ฐํํฉ๋๋ค. -
types๋ฅผ union ํ์ ์ ํํํ๋ ๋ฉค๋ฒ ํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
V๊ฐ
null ๋๋undefined ๋ผ๋ฉด:-
types์ dictionary ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น dictionary ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด:
-
types์ interface ํ์ ์ด ํฌํจ๋์ด ์๊ณ V๊ฐ ์ด๋ฅผ ๊ตฌํํ๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
types์
object๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ Object์ด๋ฉฐ, [[ArrayBufferData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์๊ณ , IsSharedArrayBuffer(V)๊ฐ false๋ผ๋ฉด:
-
types์
ArrayBuffer๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผArrayBuffer๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. -
types์
object๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ Object์ด๋ฉฐ, [[ArrayBufferData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์๊ณ , IsSharedArrayBuffer(V)๊ฐ true๋ผ๋ฉด:
-
types์
SharedArrayBuffer๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผSharedArrayBuffer๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. -
types์
object๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ Object์ด๋ฉฐ, [[DataView]] ๋ด๋ถ ์ฌ๋กฏ์ด ์๋ค๋ฉด:
-
V๊ฐ Object์ด๋ฉฐ, [[TypedArrayName]] ๋ด๋ถ ์ฌ๋กฏ์ด ์๋ค๋ฉด:
-
types์ typed array ํ์ ์ด ํฌํจ๋์ด ์๊ณ , ํด๋น ํ์ ์ด๋ฆ์ด V์ [[TypedArrayName]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ๊ณผ ๊ฐ๋ค๋ฉด, V๋ฅผ ํด๋น ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์
object๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
IsCallable(V)๊ฐ true๋ผ๋ฉด:
-
types์ callback function ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น callback function ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์
object๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ Object๋ผ๋ฉด:
-
types์ async sequence ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด
-
types์ string ํ์ ์ด ํฌํจ๋์ด ์์ง ์๊ฑฐ๋, V์ [[StringData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์๋ค๋ฉด,
-
asyncMethod๋ฅผ ? GetMethod(V,
%Symbol.asyncIterator%)๋ก ์ค์ ํฉ๋๋ค. -
asyncMethod๊ฐ
undefined ๊ฐ ์๋๋ฉด, IDL async sequence ๊ฐ์ ๋ฐํํฉ๋๋ค. object๋ V, method๋ syncMethod, type์ "async"๋ก ์ค์ ํฉ๋๋ค. -
syncMethod๋ฅผ ? GetMethod(V,
%Symbol.iterator%)๋ก ์ค์ ํฉ๋๋ค. -
syncMethod๊ฐ
undefined ๊ฐ ์๋๋ฉด, IDL async sequence ๊ฐ์ ๋ฐํํฉ๋๋ค. object๋ V, method๋ syncMethod, type์ "sync"๋ก ์ค์ ํฉ๋๋ค.
-
-
-
types์ sequence ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด
-
method๋ฅผ ? GetMethod(V,
%Symbol.iterator%)๋ก ์ค์ ํฉ๋๋ค. -
method๊ฐ
undefined ๊ฐ ์๋๋ฉด, ํด๋น ํ์ ์ ์ํ์ค ์์ฑ ๊ฒฐ๊ณผ๋ฅผ V์ method๋ก ๋ฐํํฉ๋๋ค.
-
-
types์ frozen array ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด
-
method๋ฅผ ? GetMethod(V,
%Symbol.iterator%)๋ก ์ค์ ํฉ๋๋ค. -
method๊ฐ
undefined ๊ฐ ์๋๋ฉด, ํด๋น ํ์ ์ frozen array ์์ฑ ๊ฒฐ๊ณผ๋ฅผ V์ method๋ก ๋ฐํํฉ๋๋ค.
-
-
types์ dictionary ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น dictionary ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์ record ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น record ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์ callback interface ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น callback interface ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์
object๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ Boolean ํ์ ์ด๋ผ๋ฉด:
-
V๊ฐ Number ํ์ ์ด๋ผ๋ฉด:
-
types์ numeric ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น numeric ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
V๊ฐ BigInt ํ์ ์ด๋ผ๋ฉด:
-
types์ string ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์ numeric ํ์ ๊ณผ
bigint๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น numeric ํ์ ๋๋bigint๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. -
types์ numeric ํ์ ์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผ ํด๋น numeric ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
types์
boolean์ด ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผboolean์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. -
types์
bigint๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด, V๋ฅผbigint๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค. -
TypeError๋ฅผ throwํฉ๋๋ค.
TypeError.
IDL union ํ์ ๊ฐ์ ํด๋น union ๊ฐ์ ๊ตฌ์ฒด ํ์ (specific type)์ ๋ํ ๋ณํ ๊ท์น์ ๋ฐ๋ผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํ๋ฉ๋๋ค. (์์ธํ ๋ด์ฉ์ ยงโฏ3.2 JavaScript ํ์ ๋งคํ ์ฐธ์กฐ)
3.2.26. ๋ฒํผ ์์ค ํ์
IDL ArrayBuffer
๊ฐ์ ํด๋น JavaScript ํด๋์ค์ ๊ฐ์ฒด๋ก ํํ๋ฉ๋๋ค.
ํด๋น ๊ฐ์ด ์ฐ๊ฒฐ๋ [AllowResizable]
ํ์ฅ
์์ฑ์ ๊ฐ์ง ์๋ ๊ฒฝ์ฐ, JavaScript ArrayBuffer
๊ฐ์ฒด V ์ค IsFixedLengthArrayBuffer(V)๊ฐ true์ธ ๊ฒ๋ง์ ๊ธฐ๋ฐ์ผ๋ก ํ ์
์์ต๋๋ค.
IDL SharedArrayBuffer
๊ฐ์ ํด๋น JavaScript
ํด๋์ค์ ๊ฐ์ฒด๋ก ํํ๋ฉ๋๋ค. ํด๋น ๊ฐ์ด ์ฐ๊ฒฐ๋ [AllowResizable]
ํ์ฅ
์์ฑ์ ๊ฐ์ง ์๋ ๊ฒฝ์ฐ, JavaScript
SharedArrayBuffer
๊ฐ์ฒด V ์ค
IsFixedLengthArrayBuffer(V)๊ฐ true์ธ ๊ฒ๋ง์ ๊ธฐ๋ฐ์ผ๋ก ํ
์ ์์ต๋๋ค.
IDL ๋ฒํผ ๋ทฐ ํ์ ์ ๊ฐ์ ํด๋น JavaScript ํด๋์ค์ ๊ฐ์ฒด๋ก ํํ๋๋ฉฐ, ์ด๋ฌํ ๊ฐ์ฒด์๋ ๋ค์๊ณผ ๊ฐ์ ์ถ๊ฐ ์ ํ์ด ์ ์ฉ๋ฉ๋๋ค.
-
ํ์
์ด ์ฐ๊ฒฐ๋ ๋ค์ ๋
[
AllowResizable] ๋๋ [AllowShared] ํ์ฅ ์์ฑ ์ค ์ด๋ ๊ฒ๊ณผ๋ ์ฐ๊ฒฐ๋์ง ์์ ๊ฒฝ์ฐ, ์ ์ฉ ๊ฐ๋ฅํ๋ค๋ฉด ํด๋น ๊ฐ์ JavaScriptArrayBuffer๊ฐ์ฒด V ์ค IsFixedLengthArrayBuffer(V)๊ฐ true์ธ ๊ฒ๋ง์ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์์ต๋๋ค. -
ํ์
์ด ์ฐ๊ฒฐ๋ ๋ค์
[
AllowResizable] ํ์ฅ ์์ฑ์ ๊ฐ์ง๋ง ๋ค์ [AllowShared] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๋ ๊ฒฝ์ฐ, ์ ์ฉ ๊ฐ๋ฅํ๋ค๋ฉด ํด๋น ๊ฐ์ JavaScriptArrayBuffer๊ฐ์ฒด๋ง์ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์์ต๋๋ค. -
ํ์
์ด ์ฐ๊ฒฐ๋ [
AllowShared] ํ์ฅ ์์ฑ์ ๊ฐ์ง๋ง ๋ค์ [AllowResizable] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๋ ๊ฒฝ์ฐ, ํด๋น ๊ฐ์ JavaScriptArrayBuffer๋ฐSharedArrayBuffer๊ฐ์ฒด V ์ค IsFixedLengthArrayBuffer(V)๊ฐ true์ธ ๊ฒ๋ง์ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์์ต๋๋ค. -
ํ์
์ด ์ฐ๊ฒฐ๋ ๋ค์ ๋
[
AllowResizable] ๋ฐ [AllowShared] ํ์ฅ ์์ฑ ๋ชจ๋๋ฅผ ๊ฐ๋ ๊ฒฝ์ฐ, ํด๋น ๊ฐ์ ๋ชจ๋ JavaScriptArrayBuffer๋๋SharedArrayBuffer๊ฐ์ฒด๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์์ต๋๋ค.
JavaScript ๊ฐ V๋ ๋ณํ๋์ด
IDL ArrayBuffer
๊ฐ์ด ๋๋ฉฐ, ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํฉ๋๋ค:
-
V๊ฐ Object๊ฐ ์๋๊ฑฐ๋, V์ [[ArrayBufferData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ผ๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋
TypeError์ ๋๋ค. -
IsSharedArrayBuffer(V)๊ฐ true์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋
TypeError์ ๋๋ค. -
๋ณํ ๋์์ธ IDL ํ์ ์ด ์ฐ๊ฒฐ๋ [
AllowResizable] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๊ณ , IsFixedLengthArrayBuffer(V)๊ฐ false์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋TypeError์ ๋๋ค. -
IDL
ArrayBuffer๊ฐ ์ค V์ ๋์ผํ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ์ธ ๊ฐ์ ๋ฐํํฉ๋๋ค.
JavaScript ๊ฐ V๋ ๋ณํ๋์ด
IDL SharedArrayBuffer
๊ฐ์ด ๋๋ฉฐ, ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํฉ๋๋ค:
-
V๊ฐ Object๊ฐ ์๋๊ฑฐ๋, V์ [[ArrayBufferData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ผ๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋
TypeError์ ๋๋ค. -
IsSharedArrayBuffer(V)๊ฐ false์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋
TypeError์ ๋๋ค. -
๋ณํ ๋์์ธ IDL ํ์ ์ด ์ฐ๊ฒฐ๋ [
AllowResizable] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๊ณ , IsFixedLengthArrayBuffer(V)๊ฐ false์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋TypeError์ ๋๋ค. -
IDL
SharedArrayBuffer๊ฐ ์ค V์ ๋์ผํ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ์ธ ๊ฐ์ ๋ฐํํฉ๋๋ค.
JavaScript ๊ฐ V๋ ๋ณํ๋์ด
IDL DataView
๊ฐ์ด ๋๋ฉฐ, ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํฉ๋๋ค:
-
V๊ฐ Object๊ฐ ์๋๊ฑฐ๋, V์ [[DataView]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ผ๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋
TypeError์ ๋๋ค. -
๋ณํ ๋์์ธ IDL ํ์ ์ด ์ฐ๊ฒฐ๋ [
AllowShared] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๊ณ , IsSharedArrayBuffer(V.[[ViewedArrayBuffer]]) ๊ฐ true์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋TypeError์ ๋๋ค. -
๋ณํ ๋์์ธ IDL ํ์ ์ด ์ฐ๊ฒฐ๋ [
AllowResizable] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๊ณ , IsFixedLengthArrayBuffer(V.[[ViewedArrayBuffer]]) ๊ฐ false์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋TypeError์ ๋๋ค. -
IDL
DataView๊ฐ ์ค V์ ๋์ผํ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ์ธ ๊ฐ์ ๋ฐํํฉ๋๋ค.
JavaScript ๊ฐ V๋
๋ณํ๋์ด
IDL Int8Array,
Int16Array,
Int32Array,
Uint8Array,
Uint16Array,
Uint32Array,
Uint8ClampedArray,
BigInt64Array,
BigUint64Array,
Float16Array,
Float32Array,
๋๋
Float64Array
๊ฐ์ผ๋ก
๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์คํํ์ฌ ๋ณํ๋ฉ๋๋ค:
-
T๋ฅผ V๊ฐ ๋ณํ๋๋ ๋์ IDL ํ์ ์ผ๋ก ๋ก๋๋ค.
-
V๊ฐ Object๊ฐ ์๋๊ฑฐ๋, V์ [[TypedArrayName]] ๋ด๋ถ ์ฌ๋กฏ ์ค T์ ์ด๋ฆ๊ณผ ๊ฐ์ ๊ฐ์ ๊ฐ์ง ๊ฒ์ด ์๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋
TypeError์ ๋๋ค. -
๋ณํ ๋์์ธ IDL ํ์ ์ด ์ฐ๊ฒฐ๋ [
AllowShared] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๊ณ , IsSharedArrayBuffer(V.[[ViewedArrayBuffer]]) ๊ฐ true์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋TypeError์ ๋๋ค. -
๋ณํ ๋์์ธ IDL ํ์ ์ด ์ฐ๊ฒฐ๋ [
AllowResizable] ํ์ฅ ์์ฑ์ ๊ฐ์ง ์๊ณ , IsFixedLengthArrayBuffer(V.[[ViewedArrayBuffer]]) ๊ฐ false์ด๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํต๋๋ค. ๊ทธ ์์ธ๋TypeError์ ๋๋ค. -
V์ ๋์ผํ ๊ฐ์ฒด์ ๋ํ ์ฐธ์กฐ์ธ ํ์ T์ IDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
ArrayBuffer๋ฅผ
๋ฐ์ดํธ
์ํ์ค
bytes์ realm realm์์ ์์ฑํฉ๋๋ค:
-
jsArrayBuffer๋ฅผ ? AllocateArrayBuffer(realm.[[Intrinsics]].[[
%ArrayBuffer%]], bytes์ ๊ธธ์ด)๋ก ์ค์ ํฉ๋๋ค. -
arrayBuffer๋ฅผ ๋ณํ์ ํตํด jsArrayBuffer๋ฅผ
ArrayBufferํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค. -
bytes๋ฅผ arrayBuffer์ ์์ฑํฉ๋๋ค.
-
arrayBuffer๋ฅผ ๋ฐํํฉ๋๋ค.
SharedArrayBuffer๋ฅผ
๋ฐ์ดํธ
์ํ์ค bytes์ realm realm์์ ์์ฑํฉ๋๋ค:
-
jsSharedArrayBuffer๋ฅผ ? AllocateSharedArrayBuffer(realm.[[Intrinsics]].[[
%SharedArrayBuffer%]], bytes์ ๊ธธ์ด)๋ก ์ค์ ํฉ๋๋ค. -
sharedArrayBuffer๋ฅผ ๋ณํ์ ํตํด jsSharedArrayBuffer๋ฅผ
SharedArrayBufferํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค. -
bytes๋ฅผ sharedArrayBuffer์ ์์ฑํฉ๋๋ค.
-
sharedArrayBuffer๋ฅผ ๋ฐํํฉ๋๋ค.
ArrayBufferView
ํ์
์ค ํ๋๋ฅผ
๋ฐ์ดํธ
์ํ์ค bytes์ realm realm์์ ์์ฑํฉ๋๋ค:
-
๋จ, ํ์ ์ด
DataView๊ฐ ์๋๋ผ๋ฉด, bytes์ ๊ธธ์ด๋ฅผ ํด๋น ํ์ ์ ์์ ํฌ๊ธฐ๋ก ๋๋ ๋๋จธ์ง๊ฐ 0์ด์ด์ผ ํฉ๋๋ค. -
arrayBuffer๋ฅผ ์์ฑ์ ํตํด
ArrayBuffer๋ก bytes์ realm์์ ์์ฑํฉ๋๋ค. -
jsArrayBuffer๋ฅผ ๋ณํ์ ํตํด arrayBuffer๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
constructor๋ฅผ realm.[[Intrinsics]]์์ ์์ฑํ
ArrayBufferViewํ์ ์ ๋ง๋ ์์ฑ์๋ก ์ค์ ํฉ๋๋ค. -
jsView๋ฅผ ! Construct(constructor, ยซ jsArrayBuffer ยป)๋ก ์์ฑํฉ๋๋ค.
-
๋ณํ์ ํตํด jsView๋ฅผ ํด๋น ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
jsBufferSource๋ฅผ ๋ณํ์ ํตํด bufferSource๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
jsArrayBuffer๋ฅผ jsBufferSource๋ก ์ค์ ํฉ๋๋ค.
-
offset์ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
length์ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
jsBufferSource๊ฐ [[ViewedArrayBuffer]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ง๋ฉด:
-
jsArrayBuffer๋ฅผ jsBufferSource.[[ViewedArrayBuffer]]๋ก ์ค์ ํฉ๋๋ค.
-
offset์ jsBufferSource.[[ByteOffset]]๋ก ์ค์ ํฉ๋๋ค.
-
length์ jsBufferSource.[[ByteLength]]๋ก ์ค์ ํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
jsBufferSource๋
ArrayBuffer๋๋SharedArrayBuffer๊ฐ์ฒด์ฌ์ผ ํฉ๋๋ค. -
length์ jsBufferSource.[[ArrayBufferByteLength]]๋ก ์ค์ ํฉ๋๋ค.
-
-
IsDetachedBuffer(jsArrayBuffer)๊ฐ true๋ฉด ๋น ๋ฐ์ดํธ ์ํ์ค๋ฅผ ๋ฐํํฉ๋๋ค.
-
bytes๋ฅผ ๋ฐ์ดํธ ์ํ์ค๋ก ์์ฑํ๋ฉฐ, ๊ธธ์ด๋ length๋ก ์ค์ ํฉ๋๋ค.
-
๊ฐ i์ ๋ํด, ๋ฒ์ offset๋ถํฐ offset + length๊น์ง์์ ๋๊ฐ์ ์ ์ธํ๊ณ , ์ค์ ๋์์ธ bytes[i โ offset]์ GetValueFromBuffer(jsArrayBuffer, i, Uint8, true, Unordered)๋ก ์ค์ ํฉ๋๋ค.
-
bytes๋ฅผ ๋ฐํํฉ๋๋ค.
-
jsBufferSource๋ฅผ ๋ณํ์ ํตํด bufferSource๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
jsBufferSource๊ฐ [[ViewedArrayBuffer]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ง๋ฉด, jsBufferSource.[[ByteLength]]๋ฅผ ๋ฐํํฉ๋๋ค.
-
jsBufferSource.[[ArrayBufferByteLength]]๋ฅผ ๋ฐํํฉ๋๋ค.
-
bufferSource๊ฐ ๋ฒํผ ํ์ ์ธ์คํด์ค๋ผ๋ฉด bufferSource๋ฅผ ๋ฐํํฉ๋๋ค.
-
jsBufferView๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ bufferSource์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
jsBuffer๋ฅผ jsBufferView.[[ViewedArrayBuffer]]๋ก ์ค์ ํฉ๋๋ค.
-
IsSharedArrayBuffer(jsBuffer)๊ฐ false๋ผ๋ฉด, ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ IDL ๊ฐ์ผ๋ก ๋ณํํ์ฌ jsBuffer๋ฅผ
ArrayBufferํ์ ์ผ๋ก ๋ฐํํฉ๋๋ค. -
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ IDL ๊ฐ์ผ๋ก ๋ณํํ์ฌ jsBuffer๋ฅผ
SharedArrayBufferํ์ ์ผ๋ก ๋ฐํํฉ๋๋ค.
-
jsArrayBuffer๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ arrayBuffer์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๋จ์ธ: bytes์ ๊ธธ์ด(length) โค jsArrayBuffer.[[ArrayBufferByteLength]] โ startingOffset.
-
๊ฐ i์ ๋ํด, ๋ฒ์ startingOffset๋ถํฐ startingOffset + bytes์ ๊ธธ์ด๊น์ง์์ ๋๊ฐ์ ์ ์ธํ๊ณ , ๋ค์์ ์ํํฉ๋๋ค: SetValueInBuffer(jsArrayBuffer, i, Uint8, bytes[i - startingOffset], true, Unordered).
ArrayBufferView
view์ ์ธ ๋, ์ต์
๋๋ก
startingOffset (๊ธฐ๋ณธ๊ฐ 0)์ ๋ฐ์ ์ ์์ต๋๋ค:
-
jsView๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ view์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๋จ์ธ: bytes์ ๊ธธ์ด โค jsView.[[ByteLength]] โ startingOffset.
-
๋จ์ธ: view๊ฐ
DataView๊ฐ ์๋ ๊ฒฝ์ฐ, bytes์ ๊ธธ์ด๋ฅผ modulo view์ ํ์ ์ ์์ ํฌ๊ธฐ(element size)๋ก ๋๋ ๋๋จธ์ง๊ฐ 0์์ ๋ณด์ฅํฉ๋๋ค. -
arrayBuffer๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ IDL ๊ฐ์ผ๋ก ๋ณํํ์ฌ jsView.[[ViewedArrayBuffer]]๋ฅผ
ArrayBufferํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค. -
์ฐ๊ธฐ(write)๋ฅผ bytes์ arrayBuffer๋ก, startingOffset์ jsView.[[ByteOffset]] + startingOffset์ผ๋ก ํ์ฌ ์ํํฉ๋๋ค.
SharedArrayBuffer
๊ฐ์ฒด๊ฐ ๊ด๋ จ๋ ๊ฒฝ์ฐ ๋์ฑ ๊ทธ๋ ์ต๋๋ค.
๊ณต์ ๋์ง ์์ ๊ฒฝ์ฐ, ๋ณด๋ค ๊ถ์ฅ๋๋ ํจํด์ transfer(์ด์ )๋ฅผ ๋จผ์ ์ํํ์ฌ
ArrayBuffer
์ธ์คํด์ค์ ์ฐ๊ธฐ๊ฐ ๋ค๋ฅธ ์์ ๊ณผ ๊ฒน์น์ง ์๋๋ก ๋ณด์ฅํ ๋ค, ํ์์ ๋ฐ๋ผ ์ ArrayBuffer
์ธ์คํด์ค๋ฅผ ์์ฑ์ ์ฝ๋์ ์ ๊ณตํ๋ ๊ฒ์
๋๋ค. ๋๋ ๋ฒํผ ์์ค๊ฐ ๊ฐ์ง ๋ฐ์ดํธ์ ๋ณต์ฌ๋ณธ์ ์ป์ด
ํด๋น ๋ฐ์ดํธ๋ฅผ ์์ ํ ๋ค, ์ด๋ฅผ ์ฌ์ฉํด ์์ฑํ ์๋ก์ด ArrayBuffer๋ ArrayBufferView
๋ฅผ ์์ฑ์ ์ฝ๋์ ์ ๊ณตํ ์ ์์ต๋๋ค.
ArrayBuffer
arrayBuffer์ ๋ํด ๋ค์์ ์ํํฉ๋๋ค:
-
jsArrayBuffer๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ arrayBuffer์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
? DetachArrayBuffer(jsArrayBuffer)๋ฅผ ์ํํฉ๋๋ค.
๋ง์ฝ
jsArrayBuffer๊ฐ [[ArrayBufferDetachKey]]๊ฐ undefined๊ฐ ์๋ ๊ฒฝ์ฐ,
(์: WebAssembly.Memory์
buffer
์์ฑ๊ฐ ๋ฑ) ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค.
[WASM-JS-API-1]
์ด๋ฏธ detached(๋ถ๋ฆฌ๋จ)๋ ๋ฒํผ๋ฅผ detachํ๋ ๊ฒ์ ์๋ฌด ํจ๊ณผ๊ฐ ์์ต๋๋ค.
-
jsArrayBuffer๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ bufferSource์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
jsArrayBuffer๊ฐ [[ViewedArrayBuffer]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ง ๊ฒฝ์ฐ, jsArrayBuffer๋ฅผ jsArrayBuffer.[[ViewedArrayBuffer]]๋ก ์ค์ ํฉ๋๋ค.
-
IsDetachedBuffer(jsArrayBuffer)๋ฅผ ๋ฐํํฉ๋๋ค.
-
jsArrayBuffer๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ bufferSource์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
jsArrayBuffer๊ฐ [[ViewedArrayBuffer]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ง ๊ฒฝ์ฐ, jsArrayBuffer๋ฅผ jsArrayBuffer.[[ViewedArrayBuffer]]๋ก ์ค์ ํฉ๋๋ค.
-
IsSharedArrayBuffer(jsArrayBuffer)๊ฐ true์ด๋ฉด false ๋ฐํ.
-
IsDetachedBuffer(jsArrayBuffer)๊ฐ true์ด๋ฉด false ๋ฐํ.
-
jsArrayBuffer.[[ArrayBufferDetachKey]]๊ฐ
undefined ๊ฐ ์๋๋ฉด false ๋ฐํ. -
true ๋ฐํ.
ArrayBuffer
arrayBuffer๋ฅผ, ์ต์
๋ํ๊ฒ
realm targetRealm์ ์ด์ ํ ๋:
-
jsArrayBuffer๋ฅผ IDL์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ arrayBuffer์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
IsDetachedBuffer(jsArrayBuffer)๊ฐ true๋ฉด, TypeError๋ฅผ throwํฉ๋๋ค.
TypeError. -
arrayBufferData๋ฅผ jsArrayBuffer.[[ArrayBufferData]]๋ก ์ค์ ํฉ๋๋ค.
-
arrayBufferByteLength๋ฅผ jsArrayBuffer.[[ArrayBufferByteLength]]๋ก ์ค์ ํฉ๋๋ค.
-
? DetachArrayBuffer(jsArrayBuffer)๋ฅผ ์ํํฉ๋๋ค.
-
targetRealm์ด ์์ผ๋ฉด targetRealm์ ํ์ฌ realm์ผ๋ก ์ค์ ํฉ๋๋ค.
-
jsTransferred๋ฅผ ? AllocateArrayBuffer(targetRealm.[[Intrinsics]].[[
%ArrayBuffer%]], 0)๋ก ์ค์ ํฉ๋๋ค. -
jsTransferred.[[ArrayBufferData]]๋ฅผ arrayBufferData๋ก ์ค์ ํฉ๋๋ค.
-
jsTransferred.[[ArrayBufferByteLength]]๋ฅผ arrayBufferByteLength๋ก ์ค์ ํฉ๋๋ค.
-
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ IDL ๊ฐ์ผ๋ก ๋ณํํ์ฌ jsTransferred๋ฅผ
ArrayBufferํ์ ์ผ๋ก ๋ฐํํฉ๋๋ค.
-
arrayBuffer๊ฐ detached(๋ถ๋ฆฌ๋จ)๋ ์ ์๋ ๊ฒฝ์ฐ, ํด๋น ์๊ณ ๋ฆฌ์ฆ ์ค๋ช (์ฐธ๊ณ )์ ๋ช ์๋ ์ด์ ๋๋ฌธ์ ๋๋ค;
-
arrayBuffer๊ฐ ์ด๋ฏธ detached(๋ถ๋ฆฌ๋จ)์ธ ๊ฒฝ์ฐ;
-
realm์ ์ถฉ๋ถํ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํ ๋นํ ์ ์์ ๋. ์ผ๋ฐ์ ์ผ๋ก ์ด๋ realm์ด arrayBuffer๊ฐ ํ ๋น๋ ์์ด์ ํธ ํด๋ฌ์คํฐ(agent cluster)์ ๋ค๋ฅผ ๋๋ง ๋ฐ์ํฉ๋๋ค. ๋์ผํ ์์ด์ ํธ ํด๋ฌ์คํฐ์ธ ๊ฒฝ์ฐ์๋ ๊ตฌํ์ฒด๊ฐ ๋ฐฑํน ํฌ์ธํฐ๋ง ๋ณ๊ฒฝํ์ฌ ๋ ๋์ ์ฑ๋ฅ๊ณผ ํ ๋น ์์ด ๋์ผํ ๊ด์ฐฐ ๊ฐ๋ฅํ ๊ฒฐ๊ณผ๋ฅผ ์ป์ ์ ์์ต๋๋ค.
3.2.27. ๋ถ๋ณ ๋ฐฐ์ด โ FrozenArray<T>
๋ถ๋ณ ๋ฐฐ์ด ํ์ ์ ๊ฐ์ ๋ถ๋ณ(frozen) JavaScript Array ๊ฐ์ฒด ์ฐธ์กฐ๋ก ํํ๋ฉ๋๋ค.
JavaScript ๊ฐ V๋ฅผ ๋ณํํ์ฌ IDL FrozenArray<T> ๊ฐ์ผ๋ก ๋ง๋๋ ์๊ณ ๋ฆฌ์ฆ:
-
values๋ฅผ ๋ณํํ์ฌ V๋ฅผ IDL ํ์ sequence<T>์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
๋ถ๋ณ ๋ฐฐ์ด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ values๋ฅผ ๋ฃ์ด ๋ฐํํ๋ค.
๋ถ๋ณ ๋ฐฐ์ด ์์ฑ ์๊ณ ๋ฆฌ์ฆ: ํ์ T์ ๊ฐ ์ํ์ค์ ๋ํด ์๋ ๋จ๊ณ๋ฅผ ์คํํ๋ค:
-
array๋ฅผ IDL โ JavaScript ๊ฐ ๋ณํ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ํ์ T ๊ฐ ์ํ์ค๋ฅผ ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
! SetIntegrityLevel(array, "
frozen")์ ์ํํ๋ค. -
array๋ฅผ ๋ฐํํ๋ค.
IDL โ JavaScript ๊ฐ ๋ณํ ์๊ณ ๋ฆฌ์ฆ ๊ฒฐ๊ณผ๋ก IDL FrozenArray<T> ๊ฐ์ JavaScript ๊ฐ์ผ๋ก ๋ณํํ๋ฉด, ํด๋น IDL FrozenArray<T>์ด ์ฐธ์กฐํ๋ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ Object ๊ฐ์ด ๋๋ค.
3.2.27.1. ์ดํฐ๋ฌ๋ธ๋ก๋ถํฐ ๋ถ๋ณ ๋ฐฐ์ด ์์ฑ
์ดํฐ๋ฌ๋ธ iterable๊ณผ ์ดํฐ๋ ์ดํฐ getter method๊ฐ ์ฃผ์ด์ก์ ๋, IDL ํ์ FrozenArray<T>๋ฅผ ์์ฑํ๋ ์๊ณ ๋ฆฌ์ฆ:
-
values๋ฅผ ์ดํฐ๋ฌ๋ธ๋ก๋ถํฐ ์ํ์ค ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ iterable๊ณผ method๋ฅผ ๋ฃ์ด ํ์ sequence<T>๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
๋ถ๋ณ ๋ฐฐ์ด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ values๋ฅผ ๋ฃ์ด ๋ฐํํ๋ค.
3.2.28. ๊ด์ธก ๋ฐฐ์ด โ ObservableArray<T>
๊ด์ธก ๋ฐฐ์ด ํ์ ์ ๊ฐ์ observable array exotic object๋ก ํํ๋ฉ๋๋ค.
์ผ๋ฐ์ ์ธ ๋ณํ ์๊ณ ๋ฆฌ์ฆ ๋์ , ๊ด์ธก ๋ฐฐ์ด ํ์ ์ attribute getter์ attribute setter ์๊ณ ๋ฆฌ์ฆ์ ์ผ๋ถ๋ก ํน๋ณํ๊ฒ ์ฒ๋ฆฌ๋ฉ๋๋ค.
JavaScript ๋ฐ์ธ๋ฉ์์ ํ๋ซํผ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ JavaScript ๊ฐ์ฒด๋ backing observable array exotic object๋ฅผ ๊ฐ ์ ๊ท attribute์ ๋ํด ๊ด์ธก ๋ฐฐ์ด ํ์ ์ ๋ํด ๊ฐ์ง๋๋ค. ์ด๋ attribute ์ ์ ์๊ณ ๋ฆฌ์ฆ์ ์ผ๋ถ๋ก ์์ฑ ๋ฐ ๊ด๋ฆฌ๋ฉ๋๋ค.
-
๋จ์ธ: obj๋ ๊ตฌํํ interface์ ์ ๊ท attribute attribute๊ฐ ์๋ค.
-
oa๋ฅผ obj์ backing observable array exotic object๋ก attribute์ ๋ํด ์ค์ ํ๋ค.
-
oa.[[ProxyHandler]].[[BackingList]]๋ฅผ ๋ฐํํ๋ค.
3.3. ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ
์ด ์ ์์๋ JavaScript ๋ฐ์ธ๋ฉ์ ์ํฅ์ ์ฃผ๋ ์ฌ๋ฌ ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ ์ํฉ๋๋ค.
3.3.1. [AllowResizable]
๋ง์ฝ [AllowResizable]
ํ์ฅ
์์ฑ์ด ์ ์ฌ์ ์ผ๋ก ๋
ํ์ฉ
๋ฒํผ ํ์
์ ๋ํ๋๋ฉด, ํด๋นํ๋
JavaScript์ ๊ฐ๊ฐ ๋์ํ๋
ArrayBuffer
๋๋ SharedArrayBuffer
๊ฐ์ฒด๊ฐ
ํฌ๊ธฐ ์กฐ์ ๊ฐ๋ฅํ๋๋ก ํ์ฉํ๋ ์ IDL ํ์
์ ๋ง๋ญ๋๋ค.
๋ง์ฝ [AllowResizable]
ํ์ฅ
์์ฑ์ด ์ ์ฌ์ ์ผ๋ก ๋
ํ์ฉ
๋ฒํผ ๋ทฐ ํ์
์ ๋ํ๋๊ณ
[AllowShared]
ํ์ฅ
์์ฑ์ ๋ํ๋์ง ์์ผ๋ฉด, ์
IDL ํ์
์ ๋ง๋ค์ด ๋ฒํผ ๋ทฐ ํ์
์ด JavaScript
ArrayBuffer
์ค ํฌ๊ธฐ ์กฐ์ ๊ฐ๋ฅํ ๊ฒ์ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์๊ฒ ํ๋ฉฐ, ๊ณ ์ ๊ธธ์ด์
ArrayBuffer๋ง์
๊ธฐ๋ฐ์ผ๋ก ํ๋๋ก ์ ํํ์ง ์์ต๋๋ค.
๋ง์ฝ [AllowResizable]
ํ์ฅ
์์ฑ๊ณผ [AllowShared]
ํ์ฅ
์์ฑ์ด
๋ชจ๋ ์ ์ฌ์ ์ผ๋ก ๋ ํ์ฉ ๋ฒํผ ๋ทฐ ํ์
์ ๋ํ๋๋ฉด, ์ IDL
ํ์
์ ๋ง๋ค์ด
๋ฒํผ ๋ทฐ ํ์
์ด ์ถ๊ฐ๋ก JavaScript
SharedArrayBuffer
์ค ํ์ฅ ๊ฐ๋ฅํ ๊ฒ์ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์๊ฒ ํฉ๋๋ค.
[AllowResizable]
ํ์ฅ ์์ฑ์ ๋ฐ๋์ ์ธ์๋ฅผ ๋ฐ์ง
์์์ผ ํฉ๋๋ค.
์ ์ฌ์ ์ผ๋ก ๋ ํ์ฉ ๋ฒํผ ์์ค ํ์
์ด
์๋ ํ์
์
[AllowResizable]
ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋์ด์๋ ์ ๋ฉ๋๋ค.
[AllowResizable]์
์ฌ์ฉ์ ์๋ฐ๋๋ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์
ยง 3.2.26 ๋ฒํผ ์์ค ํ์
์ JavaScript ๊ฐ์ IDL ๋ฒํผ ์์ค ํ์
์ผ๋ก ๋ณํํ๋ ๊ท์น์ ์ฐธ์กฐํ์ญ์์ค.
[AllowResizable]
๋ฐ [AllowShared]
๋ ๋ค์ ์ฌ์ฉ ์๋ ยง 3.3.2 [AllowShared]์ ์๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
3.3.2. [AllowShared]
๋ง์ฝ [AllowShared]
ํ์ฅ
์์ฑ์ด ์ ์ฌ์ ์ผ๋ก ๋
ํ์ฉ
๋ฒํผ ๋ทฐ ํ์
์ ๋ํ๋๋ฉด,
๊ฐ์ฒด๊ฐ ๋ค์์ ๊ธฐ๋ฐ์ผ๋ก ํ ์ ์๊ฒ ํ๋ ์ IDL ํ์
์ ๋ง๋ญ๋๋ค:
SharedArrayBuffer
์ฆ, ArrayBuffer๋ง์
๊ธฐ๋ฐ์ผ๋ก ํ๋๋ก ์ ํํ์ง ์์ต๋๋ค.
[AllowShared]
ํ์ฅ ์์ฑ์ ๋ฐ๋์ ์ธ์๋ฅผ
๋ฐ์ง ์์์ผ ํฉ๋๋ค.
์ ์ฌ์ ์ผ๋ก ๋ ํ์ฉ ๋ฒํผ ๋ทฐ ํ์
์ด ์๋ ํ์
์
[AllowShared]
ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋์ด์๋ ์ ๋ฉ๋๋ค.
[AllowShared]์
์ฌ์ฉ์ ์๋ฐ๋๋ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์
ยง 3.2.26 ๋ฒํผ ์์ค ํ์
์ JavaScript ๊ฐ์ IDL ๋ฒํผ ๋ทฐ ํ์
์ผ๋ก ๋ณํํ๋ ๊ท์น์ ์ฐธ์กฐํ์ญ์์ค.
3.3.3. [Clamp]
[Clamp] ํ์ฅ
์์ฑ์ด ์ ์ฌ์ ์ผ๋ก ๋
ํ์ฉ ์ ์ ํ์
์ ๋ํ๋๋ฉด,
JavaScript Number๊ฐ IDL ํ์
์ผ๋ก ๋ณํ๋ ๋
๋ฒ์๋ฅผ ๋ฒ์ด๋ ๊ฐ์ ๋ชจ๋๋ก ์ฐ์ฐ์ ์ฌ์ฉํ๋ ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ๋ ๋์ ์ ํจํ ๊ฐ์ ๋ฒ์๋ก ์ ํ๋๋๋ก ํ๋
์๋ก์ด IDL ํ์
์ ๋ง๋ญ๋๋ค(ToInt32, ToUint32 ๋ฑ).
[Clamp]
ํ์ฅ ์์ฑ์ ๋ฐ๋์
์ธ์๋ฅผ
๋ฐ์ง ์์์ผ ํฉ๋๋ค.
[Clamp] ํ์ฅ
์์ฑ์ผ๋ก ์ฃผ์์ด ์ง์ ๋ ํ์
์ ์ฝ๊ธฐ ์ ์ฉ
์์ฑ์ ๋ํ๋์๋ ์ ๋ฉ๋๋ค. ํ์
์ ์ฐ๊ฒฐ๋ ๋ค์ ๋
[Clamp] ๋ฐ [EnforceRange]
ํ์ฅ ์์ฑ์ ๋ชจ๋ ๊ฐ์ ธ์๋ ์ ๋ฉ๋๋ค. ๋ค์์ ํด๋นํ์ง ์๋ ํ์
์
์ ์ฌ์ ์ผ๋ก
๋ ํ์ฉ ์ ์
ํ์
์ด ์๋๋ฉด
[Clamp] ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋์ด์๋ ์ ๋ฉ๋๋ค.
JavaScript ๊ฐ์ ๋ค์ํ IDL ์ ์
ํ์
์ผ๋ก ๋ณํํ๋ ๊ท์น์ ยง 3.2.4 ์ ์ ํ์
์ ์ฐธ์กฐํ์ญ์์ค.
๋ค์ ์ฌ์ฉ์ ์๋ฐ๋๋ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์ ๊ดํ ๊ฒ์
๋๋ค:
[Clamp].
๋ค์ IDL ํ๋๊ทธ๋จผํธ์์๋
์ธ ๊ฐ์ octet ์ธ์๋ฅผ
๋ฐ๋
๋ ๊ฐ์ operation์ด ์ ์ธ๋์ด
์์ต๋๋ค.
ํ๋๋ ์ธ ์ธ์ ๋ชจ๋์ [Clamp] ํ์ฅ
์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ๊ณ , ๋ค๋ฅธ ํ๋๋ ์ฌ์ฉํ์ง ์์ต๋๋ค:
[Exposed =Window ]interface GraphicsContext {undefined setColor (octet red ,octet green ,octet blue );undefined setColorClamped ([Clamp ]octet red , [Clamp ]octet green , [Clamp ]octet blue ); };
setColorClamped๋ฅผ ๋ฒ์๋ฅผ ๋ฒ์ด๋ Number ๊ฐ๊ณผ ํจ๊ป ํธ์ถํ๋ฉด,
octet ํ์
์
๋ฒ์ [0, 255]๋ก ๊ฐ์ ํด๋จํํฉ๋๋ค.
// GraphicsContext ์ธ์คํด์ค๋ฅผ ์ป์. var context= getGraphicsContext(); // [Clamp]๊ฐ ์๋ ๋ฒ์ ์ ToUint8์ ์ฌ์ฉํ์ฌ Number๋ฅผ octet์ผ๋ก ๋ณํํฉ๋๋ค. // ์ด๋ setColor(255, 255, 1)์ ํธ์ถํ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค. context. setColor( - 1 , 255 , 257 ); // ๋ฒ์ ์ด๊ณผ ๊ฐ์ setColorClamped์ ์ ๋ฌ. // ์ด๋ setColorClamped(0, 255, 255)๋ฅผ ํธ์ถํ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค. context. setColorClamped( - 1 , 255 , 257 );
3.3.4. [CrossOriginIsolated]
[CrossOriginIsolated]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
interface,
partial
interface,
interface mixin,
partial
interface
mixin,
callback
interface,
namespace,
partial
namespace,
interface
member,
interface mixin
member, ๋๋
namespace
member์ ๋ํ๋๋ฉด,
ํด๋น ๊ตฌ์ฑ ์์๊ฐ ๋
ธ์ถ๋๋ ํ๊ฒฝ์ด cross-origin isolated
capability
๊ฐ true์ผ ๋๋ง ๋
ธ์ถ๋จ์ ๋ํ๋
๋๋ค. [CrossOriginIsolated]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ๋ค๋ฅธ ๊ตฌ์ฑ ์์์ ์ฌ์ฉํ๋ฉด ์ ๋ฉ๋๋ค.
[CrossOriginIsolated]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์ธ์๋ฅผ
๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[CrossOriginIsolated]
๊ฐ ์ค๋ฒ๋ก๋๋ operation์ ๋ํ๋๋ฉด,
๋ชจ๋ ์ค๋ฒ๋ก๋์ ๋ฐ๋์ ๋ํ๋์ผ ํฉ๋๋ค.
[CrossOriginIsolated]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
๋ค์ ๊ฒฝ์ฐ ๋ชจ๋์ ๋ช
์๋ ์ ์์ต๋๋ค:
-
interface member์ ๊ทธ interface ๋๋ partial interface ๋ ๋ค์;
-
interface mixin member์ ๊ทธ interface mixin ๋๋ partial interface mixin ๋ ๋ค์;
-
namespace member์ ๊ทธ namespace ๋๋ partial namespace ๋ ๋ค์.
์ฐธ๊ณ : ์ด๋ [CrossOriginIsolated]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ
๋ฉค๋ฒ์ ์ถ๊ฐํด๋
์ ์ ์ ์ฒด์ ์ด๋ฏธ [CrossOriginIsolated] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์์ผ๋ฉด ๋ฉค๋ฒ์ ๋
ธ์ถ ๋ฒ์๊ฐ ์ถ๊ฐ๋ก ์ ํ๋์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค.
[CrossOriginIsolated]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ interface๋
[CrossOriginIsolated]๋ฅผ ๋ช
์ํ ๋ค๋ฅธ interface๋ฅผ ์์ํ๋ฉด ์
๋ฉ๋๋ค.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ ๋ชจ๋ ์ปจํ ์คํธ์์ ์คํ ๊ฐ๋ฅํ operation 1๊ฐ์, cross-origin isolated ์ปจํ ์คํธ์์๋ง ์คํ ๊ฐ๋ฅํ operation 2๊ฐ๋ฅผ ๊ฐ์ง interface๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ]interface ExampleFeature { // ๋ชจ๋ ์ปจํ ์คํธ์์ ์ฑ๊ณตPromise <Result >calculateNotSoSecretResult (); // ์ด operation์ ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์ ๋ ธ์ถ๋์ง ์์ต๋๋ค. ํด๋น ์ปจํ ์คํธ์์ ExampleFeature.prototype์ "calculateSecretResult" ์์ฑ์ด ์์ต๋๋ค. [CrossOriginIsolated ]Promise <Result >calculateSecretResult (); // ๋ง์ฐฌ๊ฐ์ง๋ก ์ด attribute๋ ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์ ๋ ธ์ถ๋์ง ์์ผ๋ฉฐ, // ExampleFeature.prototype์ "secretBoolean" ์์ฑ์ด ์์ต๋๋ค. [CrossOriginIsolated ]readonly attribute boolean secretBoolean ; }; // HighResolutionTimer๋ ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์ ๋ ธ์ถ๋์ง ์์ผ๋ฉฐ, ๋ฉค๋ฒ๋ ๋ ธ์ถ๋์ง ์์ต๋๋ค. // ํด๋น ์ปจํ ์คํธ์์ Window์ "HighResolutionTimer" ์์ฑ์ด ์์ต๋๋ค. [Exposed =Window ,CrossOriginIsolated ]interface HighResolutionTimer {DOMHighResTimeStamp getHighResolutionTime (); }; // ์๋ interface mixin ๋ฉค๋ฒ๋ ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์์๋ ๋ ธ์ถ๋์ง ์์ต๋๋ค. ์ฆ, ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์์๋ ExampleFeature.prototype์ "snap" ์์ฑ์ด ์์ต๋๋ค. [CrossOriginIsolated ]interface mixin Snapshotable {Promise <boolean >snap (); };ExampleFeature includes Snapshotable ; // ๋ฐ๋ฉด, ์๋ interface mixin ๋ฉค๋ฒ๋ ํธ์คํธ interface์ [CrossOriginIsolated] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์์ผ๋ฉด ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์์๋ ๋ ธ์ถ๋ฉ๋๋ค. // ์ฆ, ๋น๊ฒฉ๋ฆฌ ์ปจํ ์คํธ์์๋ ExampleFeature.prototype์ "log" ์์ฑ์ด ์์ต๋๋ค.interface mixin Loggable {Promise <boolean >log (); };ExampleFeature includes Loggable ;
3.3.5. [Default]
[Default]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
์ ๊ท operation์
๋ํ๋๋ฉด,
ํด๋น operation์ด ํธ์ถ๋ ๋ ์ ์ ํ ๊ธฐ๋ณธ ๋ฉ์๋ ๋จ๊ณ๋ฅผ ์ํํด์ผ ํจ์ ๋ํ๋
๋๋ค.
[Default]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ
ํฉ๋๋ค.
[Default]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์ ๊ท
operation ์ธ์๋ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ,
ํด๋น operation์ ๊ธฐ๋ณธ ๋ฉ์๋ ๋จ๊ณ๊ฐ ์ ์๋์ด ์์ด์ผ ํฉ๋๋ค.
์์๋ก, [Default]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ toJSON ์ ๊ท operation์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
[Exposed =Window ]interface Animal {attribute DOMString name ;attribute unsigned short age ; [Default ]object toJSON (); }; [Exposed =Window ]interface Human :Animal {attribute Dog ?pet ; [Default ]object toJSON (); }; [Exposed =Window ]interface Dog :Animal {attribute DOMString ?breed ; };
JavaScript ๋ฐ์ธ๋ฉ์์๋ Animal, Human,
๊ทธ๋ฆฌ๊ณ ์์์ ํตํด Dog ๊ฐ์ฒด์๋ toJSON() ๋ฉ์๋๊ฐ ์กด์ฌํฉ๋๋ค:
// Human ์ธ์คํด์ค๋ฅผ ์ป์. var alice= getHuman(); // ์๋์ ๊ฐ์ ๊ฐ์ฒด๋ก ํ๊ฐ๋จ ("pet"์ Dog ์ธ์คํด์ค๋ฅผ ๊ทธ๋๋ก ๊ฐ๊ณ ์์): // // { // name: "Alice", // age: 59, // pet: Dog // } alice. toJSON(); // ์๋์ ๊ฐ์ ๊ฐ์ฒด๋ก ํ๊ฐ๋จ ("breed"๋ Dog ์ธํฐํ์ด์ค๊ฐ ๊ธฐ๋ณธ toJSON ๋จ๊ณ๋ฅผ ์ฌ์ฉํ์ง ์์ผ๋ฏ๋ก ์์): // // { // name: "Tramp", // age: 6 // } alice. pet. toJSON(); // ์๋์ ๊ฐ์ ๋ฌธ์์ด๋ก ํ๊ฐ๋จ: // '{"name":"Alice","age":59,"pet":{"name":"Tramp","age":6}}' JSON. stringify( alice);
3.3.6. [EnforceRange]
[EnforceRange]
ํ์ฅ
์์ฑ์ด ์ ์ฌ์ ์ผ๋ก ๋
ํ์ฉ
์ ์ ํ์
์ ๋ํ๋๋ฉด,
JavaScript Number๊ฐ
IDL ํ์
์ผ๋ก ๋ณํ๋ ๋, ๋ฒ์๋ฅผ ๋ฒ์ด๋ ๊ฐ์ ๋ชจ๋๋ก ์ฐ์ฐ์ ์ฌ์ฉํ๋ ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ์ฌ
์ ํจํ ๊ฐ์ผ๋ก ๋ณํ๋๋ ๋์ ์์ธ๊ฐ ๋ฐ์ํ๋๋ก ํ๋ ์ IDL ํ์
์ ๋ง๋ญ๋๋ค
(ToInt32, ToUint32 ๋ฑ).
Number๋ ๋ฒ์์ ๋น๊ตํ์ฌ ๊ฒ์ฌ๋๊ธฐ ์ ์ 0์ ํฅํด ๋ฐ์ฌ๋ฆผ๋ฉ๋๋ค.
[EnforceRange]
ํ์ฅ ์์ฑ์ ๋ฐ๋์
์ธ์๋ฅผ
๋ฐ์ง ์์์ผ ํฉ๋๋ค.
[EnforceRange]
ํ์ฅ ์์ฑ์ผ๋ก ์ฃผ์์ด ์ง์ ๋ ํ์
์
์ฝ๊ธฐ ์ ์ฉ ์์ฑ์ ๋ํ๋์๋ ์ ๋ฉ๋๋ค. ํ์
์
[Clamp] ๋ฐ
[EnforceRange]
ํ์ฅ ์์ฑ ๋ชจ๋์ ์ฐ๊ฒฐ๋์ด์๋ ์ ๋ฉ๋๋ค. ๋ค์์ ํด๋นํ์ง ์๋ ํ์
์
์ ์ฌ์ ์ผ๋ก
๋ ํ์ฉ ์ ์
ํ์
์ด ์๋๋ฉด
[EnforceRange]
ํ์ฅ ์์ฑ๊ณผ ์ฐ๊ฒฐ๋์ด์๋ ์ ๋ฉ๋๋ค.
JavaScript ๊ฐ์ ๋ค์ํ IDL ์ ์
ํ์
์ผ๋ก ๋ณํํ๋ ๊ท์น์ ยง 3.2 JavaScript ํ์
๋งคํ์์ ์ฐธ์กฐํ์๊ธฐ ๋ฐ๋ผ๋ฉฐ,
์ด๋
[EnforceRange]์
์ฌ์ฉ์ ์๋ฐ๋๋ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์ ์ค๋ช
ํฉ๋๋ค.
๋ค์ IDL ํ๋๊ทธ๋จผํธ์์๋
์ธ ๊ฐ์ octet ์ธ์๋ฅผ
๋ฐ๋
๋ ๊ฐ์ operation์ด ์ ์ธ๋์ด
์์ต๋๋ค.
ํ๋๋ ์ธ ์ธ์ ๋ชจ๋์ [EnforceRange]
ํ์ฅ
์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ๊ณ , ๋ค๋ฅธ ํ๋๋ ์ฌ์ฉํ์ง ์์ต๋๋ค:
[Exposed =Window ]interface GraphicsContext {undefined setColor (octet red ,octet green ,octet blue );undefined setColorEnforcedRange ([EnforceRange ]octet red , [EnforceRange ]octet green , [EnforceRange ]octet blue ); };
IDL์ JavaScript ๊ตฌํ์์ setColorEnforcedRange๋ฅผ ๋ฒ์๋ฅผ ๋ฒ์ด๋ Number ๊ฐ๊ณผ ํจ๊ป ํธ์ถํ๋ฉด,
octet
ํ์
์ ๋ฒ์๋ฅผ ๋ฒ์ด๋๋ฏ๋ก ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค.
// GraphicsContext ์ธ์คํด์ค๋ฅผ ์ป์. var context= getGraphicsContext(); // [EnforceRange]๊ฐ ์๋ ๋ฒ์ ์ ToUint8์ ์ฌ์ฉํ์ฌ Number๋ฅผ octet์ผ๋ก ๋ณํํฉ๋๋ค. // ์ด๋ setColor(255, 255, 1)์ ํธ์ถํ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค. context. setColor( - 1 , 255 , 257 ); // setColorEnforcedRange๋ฅผ ํธ์ถํ๋ฉด Number๊ฐ 0 ๋ฐฉํฅ์ผ๋ก ๋ฐ์ฌ๋ฆผ๋ฉ๋๋ค. // ์ด๋ setColor(0, 255, 255)๋ฅผ ํธ์ถํ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค. context. setColorEnforcedRange( - 0.9 , 255 , 255.2 ); // ์๋๋ ์์ธ(TypeError)๋ฅผ ๋ฐ์์ํต๋๋ค. ๋ฐ์ฌ๋ฆผ ํ์๋ ์ฒซ ๋ฒ์งธ์ ์ธ ๋ฒ์งธ ์ธ์๊ฐ ๋ฒ์ ๋ฐ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค. context. setColorEnforcedRange( - 1 , 255 , 256 );
3.3.7. [Exposed]
[Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
interface,
partial interface,
interface mixin,
partial interface mixin,
callback interface,
namespace,
partial namespace, ๋๋
๊ฐ๋ณ interface member,
interface mixin member, ๋๋
namespace member์ ๋ํ๋๋ฉด,
ํด๋น ๊ตฌ์ฑ์์๊ฐ ํน์ ๊ธ๋ก๋ฒ ์ธํฐํ์ด์ค ์งํฉ์ ๋
ธ์ถ๋จ์ ์๋ฏธํฉ๋๋ค.
[Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์๋ณ์,
์๋ณ์ ๋ฆฌ์คํธ ๋๋
์์ผ๋์นด๋๋ฅผ ๊ฐ์ ธ์ผ ํฉ๋๋ค.
๋ช
์๋ ๊ฐ ์๋ณ์๋ ์ด๋ค interface์ ๊ธ๋ก๋ฒ ์ด๋ฆ์ด์ด์ผ ํ๋ฉฐ, ์ค๋ณต๋๋ฉด ์ ๋ฉ๋๋ค.
์์ ์ ๋
ธ์ถ ์งํฉ(own exposure
set)
์ ์๋ณ์๋ค์ ์งํฉ์ด๊ฑฐ๋, ํน์ ๊ฐ
*์
๋๋ค. ์ ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
- [
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ณ์ I๋ฅผ ๊ฐ์ง ๋ -
์์ ์ ๋ ธ์ถ ์งํฉ์ ์งํฉ ยซ I ยป ์ ๋๋ค.
- [
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ณ์ ๋ฆฌ์คํธ I๋ฅผ ๊ฐ์ง ๋ -
์์ ์ ๋ ธ์ถ ์งํฉ์ ์งํฉ I ์ ๋๋ค.
- [
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์์ผ๋์นด๋๋ฅผ ๊ฐ์ง ๋ -
์์ ์ ๋ ธ์ถ ์งํฉ์
*์ ๋๋ค.
[Exposed=*]๋ ์ ์คํ๊ฒ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
API๊ฐ ์๋ก์ด ๊ธฐ๋ฅ์ ๋
ธ์ถํ์ง ์์ ๋๋ง ์ ํฉํฉ๋๋ค.
API๊ฐ ์ผ๋ถ ํ๊ฒฝ์์ ์ ํ๋๊ฑฐ๋ ๋นํ์ฑํ๋ ์ ์๋ค๋ฉด, ๊ธ๋ก๋ฒ์ ๋ช
์์ ์ผ๋ก ๋ฆฌ์คํธํ๋ ๊ฒ์ด ๋ ๋ฐ๋์งํฉ๋๋ค.
๋ ธ์ถ ์งํฉ ๊ต์งํฉ์ ๊ตฌ์ฑ ์์ C์ interface-or-null H์ ๋ํด ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ฉ๋๋ค:
-
๋จ์ธ: C๋ interface member, interface mixin member, namespace member, partial interface, partial interface mixin, partial namespace, ๋๋ interface mixin์ด๋ค.
-
๋จ์ธ: H๋ interface ๋๋ null์ด๋ค.
-
H๊ฐ null์ด๋ฉด, C์ ์์ ์ ๋ ธ์ถ ์งํฉ์ ๋ฐํํ๋ค.
-
C์ ์์ ์ ๋ ธ์ถ ์งํฉ์ด
*์ด๋ฉด, H์ ๋ ธ์ถ ์งํฉ์ ๋ฐํํ๋ค. -
H์ ๋ ธ์ถ ์งํฉ์ด
*์ด๋ฉด, C์ ์์ ์ ๋ ธ์ถ ์งํฉ์ ๋ฐํํ๋ค. -
C์ ์์ ์ ๋ ธ์ถ ์งํฉ๊ณผ H์ ๋ ธ์ถ ์งํฉ์ ๊ต์งํฉ์ ๋ฐํํ๋ค.
-
๋จ์ธ: C๋ interface, callback interface, namespace, interface member, interface mixin member, ๋๋ namespace member์ด๋ค.
-
H๋ฅผ C๊ฐ interface mixin member์ผ ๊ฒฝ์ฐ ํธ์คํธ ์ธํฐํ์ด์ค๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด null๋ก ์ค์ ํ๋ค.
-
C๊ฐ interface member, interface mixin member, ๋๋ namespace member๋ผ๋ฉด:
-
[
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ C์ ๋ช ์๋์ด ์์ผ๋ฉด, ๋ ธ์ถ ์งํฉ ๊ต์งํฉ์ C์ H๋ก ๋ฐํํ๋ค. -
C๋ฅผ interface, partial interface, interface mixin, partial interface mixin, namespace, ๋๋ partial namespace์ C๋ก ์ค์ ํ๋ค.
-
-
C๊ฐ partial interface, partial interface mixin, ๋๋ partial namespace์ผ ๊ฒฝ์ฐ:
-
[
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ C์ ๋ช ์๋์ด ์์ผ๋ฉด, ๋ ธ์ถ ์งํฉ ๊ต์งํฉ์ C์ H๋ก ๋ฐํํ๋ค. -
C๋ฅผ ์๋ interface, interface mixin, ๋๋ namespace ์ ์์ C๋ก ์ค์ ํ๋ค.
-
-
C๊ฐ interface mixin์ผ ๊ฒฝ์ฐ:
-
๋จ์ธ: H๋ null์ด ์๋๋ค.
-
[
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ C์ ๋ช ์๋์ด ์์ผ๋ฉด, ๋ ธ์ถ ์งํฉ ๊ต์งํฉ์ C์ H๋ก ๋ฐํํ๋ค. -
C๋ฅผ H๋ก ์ค์ ํ๋ค.
-
-
๋จ์ธ: C๋ interface, callback interface, ๋๋ namespace์ด๋ค.
-
๋จ์ธ: [
Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ C์ ๋ช ์๋์ด ์๋ค. -
C์ ์์ ์ ๋ ธ์ถ ์งํฉ์ ๋ฐํํ๋ค.
[Exposed]
๊ฐ ์ค๋ฒ๋ก๋๋ operation์ ๋ํ๋๋ฉด,
๋ชจ๋ ์ค๋ฒ๋ก๋์ ๋์ผํ๊ฒ ๋ํ๋์ผ ํฉ๋๋ค.
[Exposed]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
interface member, interface mixin member, ๋๋ namespace member์,
๊ทธ๋ฆฌ๊ณ partial interface, partial interface mixin, ๋๋ partial namespace ๊ทธ ๋ฉค๋ฒ๊ฐ ์ ์ธ๋ ์ ์ ๋ชจ๋์ ๋ช
์๋ ์ ์์ต๋๋ค.
์ฐธ๊ณ : [Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ
partial interface, partial interface mixin, ๋๋ partial namespace์ ์ถ๊ฐํ๋ ๊ฒ์
ํด๋น ์ ์์ ๊ฐ ๋ฉค๋ฒ์ ์ด๋
ธํ
์ด์
ํ๋ ์ฝ์ ํํ์
๋๋ค.
[Exposed]
๊ฐ partial interface ๋๋ partial namespace์ ๋ํ๋๋ฉด,
partial์ ์์ ์ ๋
ธ์ถ ์งํฉ์
partial์ ์๋ interface ๋๋ namespace์ ๋
ธ์ถ ์งํฉ์ ๋ถ๋ถ์งํฉ์ด์ด์ผ
ํฉ๋๋ค.
[Exposed]
๊ฐ interface member ๋๋ namespace member์ ๋ํ๋๋ฉด,
member์ ๋
ธ์ถ
์งํฉ์
ํด๋น interface ๋๋ namespace์ ๋
ธ์ถ ์งํฉ์ ๋ถ๋ถ์งํฉ์ด์ด์ผ
ํฉ๋๋ค.
[Exposed]
๊ฐ partial interface mixin๊ณผ ๊ทธ ์๋ interface mixin ๋ชจ๋์ ๋ํ๋๋ฉด,
partial interface mixin์ ์์ ์ ๋
ธ์ถ ์งํฉ์
interface mixin์ ์์ ์ ๋
ธ์ถ ์งํฉ์ ๋ถ๋ถ์งํฉ์ด์ด์ผ ํฉ๋๋ค.
[Exposed]
๊ฐ interface mixin member์
interface mixin ๋ชจ๋์ ๋ํ๋๋ฉด,
interface mixin member์ ์์ ์ ๋
ธ์ถ ์งํฉ์
interface mixin์ ์์ ์ ๋
ธ์ถ ์งํฉ์ ๋ถ๋ถ์งํฉ์ด์ด์ผ ํฉ๋๋ค.
interface X๊ฐ ๋ค๋ฅธ interface Y๋ฅผ ์์ํ๋ฉด, X์ ๋ ธ์ถ ์งํฉ์ Y์ ๋ ธ์ถ ์งํฉ์ ๋ถ๋ถ์งํฉ์ด์ด์ผ ํฉ๋๋ค.
์ฐธ๊ณ : interface mixin์ ์ฌ๋ฌ interface์ ํฌํจ๋ ์ ์์ผ๋ฏ๋ก,
๊ทธ ๋ฉค๋ฒ์ ๋
ธ์ถ ์งํฉ์
๊ทธ๊ฒ์ ํฌํจํ๋ interface์ ๋ฐ๋ผ ๊ฒฐ์ ๋๋ค.
interface mixin member, partial interface mixin, ๋๋ interface mixin์ [Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์์ผ๋ฉด,
ํด๋น interface mixin member์ ๋
ธ์ถ ์งํฉ์
ํด๋น ๊ตฌ์ฑ ์์์ ์์ ์ ๋
ธ์ถ ์งํฉ๊ณผ ํธ์คํธ ์ธํฐํ์ด์ค์ ๋
ธ์ถ ์งํฉ์ ๊ต์งํฉ์ด ๋๋ค.
๊ทธ๋ ์ง ์์ผ๋ฉด ํธ์คํธ ์ธํฐํ์ด์ค์ ๋
ธ์ถ ์งํฉ์ด ๋๋ค.
-
construct์ ๋ ธ์ถ ์งํฉ์ด
*๊ฐ ์๋๊ณ , realm.[[GlobalObject]]๊ฐ construct์ ๋ ธ์ถ ์งํฉ์ ํฌํจ๋ interface๋ฅผ ๊ตฌํํ์ง ์๋๋ค๋ฉด, false๋ฅผ ๋ฐํํ๋ค. -
realm์ ์ค์ ๊ฐ์ฒด๊ฐ ๋ณด์ ์ปจํ ์คํธ๊ฐ ์๋๊ณ , construct๊ฐ [
SecureContext]์์ ์กฐ๊ฑด๋ถ ๋ ธ์ถ๋จ ์ํ๋ผ๋ฉด, false๋ฅผ ๋ฐํํ๋ค. -
realm์ ์ค์ ๊ฐ์ฒด์ cross-origin isolated capability๊ฐ false์ด๊ณ , construct๊ฐ [
CrossOriginIsolated]์์ ์กฐ๊ฑด๋ถ ๋ ธ์ถ๋จ ์ํ๋ผ๋ฉด, false๋ฅผ ๋ฐํํ๋ค. -
true๋ฅผ ๋ฐํํ๋ค.
-
๋จ์ธ: construct๋ interface, callback interface, namespace, interface member, interface mixin member, ๋๋ namespace member์ด๋ค.
-
H๋ฅผ construct๊ฐ interface mixin member์ผ ๊ฒฝ์ฐ ํธ์คํธ ์ธํฐํ์ด์ค๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด null๋ก ์ค์ ํ๋ค.
-
construct๊ฐ interface member, interface mixin member, ๋๋ namespace member๋ผ๋ฉด:
-
exposure condition ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ construct์ ๋ช ์๋์ด ์์ผ๋ฉด, true๋ฅผ ๋ฐํํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด construct๋ฅผ interface, partial interface, interface mixin, partial interface mixin, namespace, ๋๋ partial namespace์ construct๋ก ์ค์ ํ๋ค.
-
-
construct๊ฐ partial interface, partial interface mixin, ๋๋ partial namespace์ผ ๊ฒฝ์ฐ:
-
exposure condition ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ construct์ ๋ช ์๋์ด ์์ผ๋ฉด, true๋ฅผ ๋ฐํํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด construct๋ฅผ ์๋ interface, interface mixin, ๋๋ namespace ์ ์์ construct๋ก ์ค์ ํ๋ค.
-
-
construct๊ฐ interface mixin์ผ ๊ฒฝ์ฐ:
-
exposure condition ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ construct์ ๋ช ์๋์ด ์์ผ๋ฉด, true๋ฅผ ๋ฐํํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด construct๋ฅผ H๋ก ์ค์ ํ๋ค.
-
-
๋จ์ธ: construct๋ interface, callback interface, ๋๋ namespace์ด๋ค.
-
exposure condition ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ construct์ ๋ช ์๋์ด ์์ผ๋ฉด, true๋ฅผ ๋ฐํํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด false๋ฅผ ๋ฐํํ๋ค.
์ฐธ๊ณ : JavaScript ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ๊ด๋ จ ์ค์ ๊ฐ์ฒด๊ฐ ์๊ฐ์ด ์ง๋๋ ๋ณด์ ์ปจํ ์คํธ ๋๋ cross-origin isolated capability ์ฌ๋ถ๊ฐ ๋ฐ๋ ์ ์์ผ๋ฏ๋ก, ์ธํฐํ์ด์ค ๋๋ ์ธํฐํ์ด์ค ๋ฉค๋ฒ์ ํ๋กํผํฐ๋ฅผ ์์ฑํ ์ง ๊ฒฐ์ ํ๋ ๊ฒ์ ์ด๊ธฐ ๊ฐ์ฒด๊ฐ ์์ฑ๋ ๋ ํ ๋ฒ๋ง ์ด๋ฃจ์ด์ง๋ฉด ๋ฉ๋๋ค.
์์ธํ ์๊ตฌ์ฌํญ์
ยงโฏ3.7 ์ธํฐํ์ด์ค,
ยงโฏ3.7.5 ์์,
ยงโฏ3.7.6 ์์ฑ,
ยงโฏ3.7.7 ์ฐ์ฐ ๋ฐ
[Exposed] ์ฌ์ฉ ๊ท์น์ ์ฐธ์กฐํ์ธ์.
[Exposed]๋ interface,
callback
interface, namespace, ๋๋ ๊ฐ๋ณ interface member,
mixin,
namespace
member๊ฐ ์์ปค,
Worklet,
Window,
๋๋ ์ด๋ค์ ์กฐํฉ์์ ์ฌ์ฉ ๊ฐ๋ฅํ๋๋ก ์ ์ดํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ ์ด๋ฅผ ์ด๋ป๊ฒ ๋ฌ์ฑํ ์ ์๋์ง ๋ณด์ฌ์ค๋๋ค:
[Exposed =Window ,Global =Window ]interface Window { // ... }; // SharedWorkerGlobalScope์ DedicatedWorkerGlobalScope ๋ชจ๋์์ ๋์ผํ ์๋ณ์ Worker๋ฅผ ์ฌ์ฉํ๋ฉด, // [Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์์ ๋ ๋ค ํ ๋ฒ์ ์ง์ ํ ์ ์์ต๋๋ค. [Exposed =Worker ,Global =Worker ]interface SharedWorkerGlobalScope :WorkerGlobalScope { // ... }; [Exposed =Worker ,Global =Worker ]interface DedicatedWorkerGlobalScope :WorkerGlobalScope { // ... }; // Dimensions๋ ์์ปค์ ๋ฉ์ธ ์ค๋ ๋ ๋ชจ๋์์ ์ฌ์ฉ ๊ฐ๋ฅ [Exposed =(Window ,Worker )]interface Dimensions {constructor (double width ,double height );readonly attribute double width ;readonly attribute double height ; }; // WorkerNavigator๋ ์์ปค์์๋ง ์ฌ์ฉ ๊ฐ๋ฅ. ์์ปค์ ๊ธ๋ก๋ฒ ์ค์ฝํ์์ WorkerNavigator๋ฅผ ํ๊ฐํ๋ฉด ์ธํฐํ์ด์ค ๊ฐ์ฒด๊ฐ ๋ฐํ๋๊ณ , // ๋ฉ์ธ ์ค๋ ๋์์๋ ReferenceError๊ฐ ๋ฐ์ํฉ๋๋ค. [Exposed =Worker ]interface WorkerNavigator { // ... }; // Node๋ ๋ฉ์ธ ์ค๋ ๋์์๋ง ์ฌ์ฉ ๊ฐ๋ฅ. ์์ปค์ ๊ธ๋ก๋ฒ ์ค์ฝํ์์ Node๋ฅผ ํ๊ฐํ๋ฉด ReferenceError๊ฐ ๋ฐ์ํฉ๋๋ค. [Exposed =Window ]interface Node { // ... }; // MathUtils๋ ์์ปค์ ๋ฉ์ธ ์ค๋ ๋ ๋ชจ๋์์ ์ฌ์ฉ ๊ฐ๋ฅ [Exposed =(Window ,Worker )]namespace MathUtils {double someComplicatedFunction (double x ,double y ); }; // WorkerUtils๋ ์์ปค์์๋ง ์ฌ์ฉ ๊ฐ๋ฅ. ์์ปค์ ๊ธ๋ก๋ฒ ์ค์ฝํ์์ WorkerUtils๋ฅผ ํ๊ฐํ๋ฉด ๋ค์์คํ์ด์ค ๊ฐ์ฒด๊ฐ ๋ฐํ๋๊ณ , // ๋ฉ์ธ ์ค๋ ๋์์๋ ReferenceError๊ฐ ๋ฐ์ํฉ๋๋ค. [Exposed =Worker ]namespace WorkerUtils {undefined setPriority (double x ); }; // NodeUtils๋ ๋ฉ์ธ ์ค๋ ๋์์๋ง ์ฌ์ฉ ๊ฐ๋ฅ. ์์ปค์ ๊ธ๋ก๋ฒ ์ค์ฝํ์์ NodeUtils๋ฅผ ํ๊ฐํ๋ฉด ReferenceError๊ฐ ๋ฐ์ํฉ๋๋ค. [Exposed =Window ]namespace NodeUtils {DOMString getAllText (Node node ); };
3.3.8. [Global]
[Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
interface์ ๋ํ๋๋ฉด,
ํด๋น interface๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๊ฐ
realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ก ์ฌ์ฉ๋จ์ ์๋ฏธํฉ๋๋ค.
[Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
๋ํ
ํด๋น interface์
๊ธ๋ก๋ฒ ์ด๋ฆ(global names)์
์ ์ํฉ๋๋ค:
- [
Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ณ์(identifier)๋ฅผ ๊ฐ์ง๋ ๊ฒฝ์ฐ -
ยซ ์ฃผ์ด์ง ์๋ณ์ ยป
- [
Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ณ์ ๋ฆฌ์คํธ(identifier list)๋ฅผ ๊ฐ์ง๋ ๊ฒฝ์ฐ -
์๋ณ์ ๋ฆฌ์คํธ
[Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์์ ํํ ์ค ํ๋์ฌ์ผ ํฉ๋๋ค.
์ฐธ๊ณ : ํด๋น interface์ ๊ธ๋ก๋ฒ ์ด๋ฆ(global names)์ [Exposed] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์์
์ฐธ์กฐํ ์ ์๋ ์๋ณ์์
๋๋ค.
ํ๋์ ์ด๋ฆ์ด ์ฌ๋ฌ ๊ธ๋ก๋ฒ ์ธํฐํ์ด์ค์์ ๊ณต์ ๋ ์ ์์ผ๋ฏ๋ก,
ํ๋์ ์ธํฐํ์ด์ค๊ฐ [Exposed]๋ฅผ ์ฌ์ฉํด์ ์ฌ๋ฌ
๊ธ๋ก๋ฒ์ ์ฝ๊ฒ ๋
ธ์ถ๋ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด "Worker"๋ ์ฌ๋ฌ ์ค๋ ๋ ๊ด๋ จ ๊ธ๋ก๋ฒ ์ธํฐํ์ด์ค๋ฅผ ์ฐธ์กฐํฉ๋๋ค.
์ด๋ฌํ ๊ธ๋ก๋ฒ interface์ ๊ฒฝ์ฐ ํ๋กํ ํ์ ์ฒด์ธ ๊ตฌ์กฐ์ interface member์ ํด๋นํ๋ ํ๋กํผํฐ๊ฐ ํ๋กํ ํ์ ๊ฐ์ฒด์ ์ด๋ป๊ฒ ๋ฐ์๋๋์ง๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค์ ๋ค๋ฆ ๋๋ค. ๊ตฌ์ฒด์ ์ผ๋ก:
-
๋ชจ๋ ์ด๋ฆ์๋ ํ๋กํผํฐ(named properties)๋ ํ๋กํ ํ์ ์ฒด์ธ ์์ ๊ฐ์ฒด(์ฆ, named properties object)์ ๋ ธ์ถ๋๋ฉฐ, ๊ฐ์ฒด ์์ฒด์๋ ๋ ธ์ถ๋์ง ์์ต๋๋ค.
-
interface member๋ค์ interface์์ ๊ฐ์ฒด ์์ฒด์ ํ๋กํผํฐ๋ก ๋์๋๋ฉฐ, interface prototype objects์๋ ๋์๋์ง ์์ต๋๋ค.
๋ชจ๋ realm์ ๊ธ๋ก๋ฒ ํ๋กํ ํ์ ์ฒด์ธ ๋ณ๊ฒฝ ๊ฐ๋ฅ(is global prototype chain mutable) ๋ถ๋ฆฌ์ธ์ ๊ฐ์ง๋ฉฐ, realm์ด ์์ฑ๋ ๋ ์ค์ ํ ์ ์์ต๋๋ค. ํด๋น ๊ฐ์ realm์ ์๋ช ๋์ ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค. ๊ธฐ๋ณธ๊ฐ์ false์ ๋๋ค.
์ด๋ ShadowRealm ๊ธ๋ก๋ฒ์ด mutable ํ๋กํ ํ์
์ ๊ฐ์ง ์ ์๊ฒ ํฉ๋๋ค.
์ด๋ฆ์๋ ํ๋กํผํฐ(named properties)๋ฅผ ํ๋กํ ํ์ ์ฒด์ธ ๊ฐ์ฒด์ ๋ฐฐ์นํ๋ ์ด์ ๋ ๋ณ์ ์ ์ธ ๋ฐ bareword ํ ๋น์ด ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ํ๋กํผํฐ๋ก ์ด๋ฆ์๋ ํ๋กํผํฐ๋ฅผ shadowํ๋๋ก ํ๊ธฐ ์ํจ์ ๋๋ค.
interface member์ ๋์ํ๋ ํ๋กํผํฐ๋ฅผ ๊ฐ์ฒด ์์ฒด์ ๋ฐฐ์นํ๋ฉด, ์๋์ ๊ฐ์ feature detection ์ฝ๋๊ฐ ๋์ํ๊ฒ ๋ฉ๋๋ค:
var indexedDB= window. indexedDB|| window. webkitIndexedDB|| window. mozIndexedDB|| window. msIndexedDB; var requestAnimationFrame= window. requestAnimationFrame|| window. mozRequestAnimationFrame|| ...;
JavaScript์์ ๋ณ์ ์ ์ธ์ด ์ฒ๋ฆฌ๋๋ ๋ฐฉ์ ๋๋ฌธ์,
์ ์ฝ๋๋ window.indexedDB ๋ฐ window.requestAnimationFrame์ด
[Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
interface์ ์ฌ์ฉ๋ ๊ฒฝ์ฐ:
-
ํด๋น interface๋ named property setter๋ฅผ ์ ์ํ๋ฉด ์ ๋ฉ๋๋ค.
-
ํด๋น interface๋ indexed property getter๋ setter๋ฅผ ์ ์ํ๋ฉด ์ ๋ฉ๋๋ค.
-
ํด๋น interface๋ constructor operation์ ์ ์ํ๋ฉด ์ ๋ฉ๋๋ค.
-
ํด๋น interface๋ [
LegacyOverrideBuiltIns] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ํจ๊ป ์ ์ธํ๋ฉด ์ ๋ฉ๋๋ค. -
ํด๋น interface๋ [
LegacyOverrideBuiltIns] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ๋ช ์ํ ๋ค๋ฅธ interface๋ฅผ ์์ํ๋ฉด ์ ๋ฉ๋๋ค. -
๋ค๋ฅธ ์ด๋ค interface๋ ํด๋น interface๋ฅผ ์์ํ๋ฉด ์ ๋ฉ๋๋ค.
[Global]์ด
partial
interface ์ ์์ ์ง์ ๋ ๊ฒฝ์ฐ,
ํด๋น partial interface ์ ์๋
named
property getter๋ฅผ ์ ์ํ๋ ๋ถ๋ถ์ด์ด์ผ ํฉ๋๋ค.
[Global] ํ์ฅ ์์ฑ์ ๋์ผํ
realm์์ ํ๋ ์ด์์ ๊ฐ์ฒด๊ฐ ๊ตฌํํ ์ ์๋ ์ธํฐํ์ด์ค์ ์ฌ์ฉํด์๋ ์ ๋ฉ๋๋ค.
์ฐธ๊ณ : ์ด๋ named properties object๊ฐ ํ๋กํ ํ์ ์ฒด์ธ์ ์์นํ๋ฉฐ, ์ฌ๋ฌ ๊ฐ์ฒด์ named properties๊ฐ ํด๋น ๊ฐ์ฒด์์ ๋ชจ๋ ๋ ธ์ถ๋๋ ๊ฒ์ ์๋ฏธ๊ฐ ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
interface์ [Global]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
์ ์ธ๋ ๊ฒฝ์ฐ,
ํด๋น interface ์ ์ฒด์ ๊ฑธ์ณ ๋์ผํ ์๋ณ์๋ฅผ ๊ฐ์ง member๊ฐ ๋ ์ด์ ์กด์ฌํ ์ ์์ต๋๋ค.
๋ํ, ํ๋์ stringifier๋
ํ๋์ iterable ์ ์ธ,
async iterable ์ ์ธ,
maplike
์ ์ธ,
setlike
์ ์ธ๋ ๋ ์ด์ ์กด์ฌํ ์ ์์ต๋๋ค.
์ฐธ๊ณ : interface์ ๋ชจ๋ member๋ ํด๋น interface๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์ ๋ชจ๋ ํํํ๋์ด ํ ๋น๋๊ธฐ ๋๋ฌธ์ ๋๋ค.
์์ธํ ์๊ตฌ์ฌํญ์ ยงโฏ3.7.4 ์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด(named properties object)์์ [Global] ์ฌ์ฉ ์ ์ด๋ฆ์๋ ํ๋กํผํฐ ๊ด๋ จ
๊ท์น,
ยงโฏ3.7.5 ์์, ยงโฏ3.7.6 ์์ฑ, ยงโฏ3.7.7 ์ฐ์ฐ์์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ์ ๋์ํ๋ ํ๋กํผํฐ์ ์์น์ ๊ดํ ์๊ตฌ์ฌํญ์ ์ฐธ๊ณ ํ์ธ์.
Window interface๋ frame์ Window ๊ฐ์ฒด์ ํ๋กํผํฐ๋ก ๋
ธ์ถํฉ๋๋ค.
Window ๊ฐ์ฒด๋ JavaScript ๊ธ๋ก๋ฒ ๊ฐ์ฒด ์ญํ ๋ ํ๋ฏ๋ก,
๋ณ์ ์ ์ธ์ด๋ ์ด๋ฆ์๋ ํ๋กํผํฐ์ ๋ํ ํ ๋น์ ํด๋น ๊ฐ์ผ๋ก ๋์ฒด๋ฉ๋๋ค.
attribute์ ๋ํด ๋ณ์๋ฅผ ์ ์ธํ๋ฉด ๊ธฐ์กด ํ๋กํผํฐ๊ฐ ๋์ฒด๋์ง ์์ต๋๋ค.
[Exposed =Window ,Global =Window ]interface Window {getter any (DOMString name );attribute DOMString name ; // ... };
์๋ HTML ๋ฌธ์๋ Window ๊ฐ์ฒด์ ์ด๋ฆ์๋ ํ๋กํผํฐ๊ฐ shadow๋๋ ๋ฐฉ๋ฒ๊ณผ,
attribute์ ๊ฐ์ ์ด๋ฆ์ ๋ณ์ ์ ์ธ์ด ๊ธฐ์กด ํ๋กํผํฐ๋ฅผ ๋์ฒดํ์ง ์๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค:
<!DOCTYPE html> < title > Variable declarations and assignments on Window</ title > < iframe name = abc ></ iframe > <!-- Shadowing named properties --> < script > window. abc; // iframe์ Window ๊ฐ์ฒด๋ฅผ ๋ฐํ. abc= 1 ; // ์ด๋ฆ์๋ ํ๋กํผํฐ๋ฅผ shadowํจ. window. abc; // 1์ ๋ฐํ. </ script > <!-- IDL attribute ํ๋กํผํฐ ๋ณด์กด --> < script > Window. prototype. def= 2 ; // ํ๋กํ ํ์ ์ ํ๋กํผํฐ ์ถ๊ฐ. window. hasOwnProperty( "length" ); // true ๋ฐํ. length; // 1 ๋ฐํ. def; // 2 ๋ฐํ. </ script > < script > var length; // ๋ณ์ ์ ์ธ์ ๊ธฐ์กด ํ๋กํผํฐ๋ฅผ ๋์ฒดํ์ง ์์. length; // 1 ๋ฐํ. var def; // ๋ณ์ ์ ์ธ์ shadow ํ๋กํผํฐ๋ฅผ ์์ฑ. def; // undefined ๋ฐํ. </ script >
3.3.9. [NewObject]
[NewObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ ๊ท
๋๋ static
operation์ ๋ํ๋๋ฉด,
ํด๋น operation์ ํธ์ถํ ๋
ํญ์ ์๋ก ์์ฑ๋ ๊ฐ์ฒด์ ์ฐธ์กฐ๋ฅผ ๋ฐํํด์ผ ํจ์ ๋ํ๋
๋๋ค.
[NewObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[NewObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ ๊ท
๋๋ static
operation ์ค,
๋ฐํ ํ์
์ด interface ํ์
๋๋
promise ํ์
์ธ ๊ฒ์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ์ด ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
createElement()
operation(Document
interface์ ๋ฉ์๋)์ ์ ํฉํฉ๋๋ค.
ํธ์ถ ์ ํญ์ ์ ๊ฐ์ฒด๊ฐ ๋ฐํ๋๊ธฐ ๋๋ฌธ์
๋๋ค. [DOM]
[Exposed =Window ]interface Document :Node { [NewObject ]Element createElement (DOMString localName ); // ... };
3.3.10. [PutForwards]
[PutForwards]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ฝ๊ธฐ ์ ์ฉ
์ ๊ท attribute ์ ์ธ์, ํด๋น ํ์
์ด interface ํ์
์ผ ๋ ๋ํ๋๋ฉด,
ํด๋น attribute์ ๊ฐ์ ํ ๋นํ ๋ ํน์ ๋์์ ํ๋๋ก ํฉ๋๋ค.
์ฆ, ํ ๋น์ด ๊ทธ attribute๊ฐ ์ฐธ์กฐํ๋ ๊ฐ์ฒด์ ํน์ attribute(ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ ์ธ์์ ๋ช
์๋)์ "์ ๋ฌ"๋ฉ๋๋ค.
[PutForwards]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์๋ณ์๋ฅผ ๊ฐ์ ธ์ผ ํฉ๋๋ค.
๋ค์์ ๊ฐ์ ํฉ๋๋ค:
-
A: [
PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ํ๋ attribute -
I: A๊ฐ ์ ์ธ๋ interface
-
J: A์ ํ์ ์ผ๋ก ์ ์ธ๋ interface ํ์
-
N: ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ ์ธ์ ์๋ณ์
์ด ๊ฒฝ์ฐ, J์ attribute B๊ฐ ์กด์ฌํด์ผ ํ๋ฉฐ, ํด๋น ์๋ณ์๋ N ์ ๋๋ค. I๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์ A์ ๊ฐ์ ํ ๋นํ๋ฉด, ๋์ A๊ฐ ์ฐธ์กฐํ๋ ๊ฐ์ฒด์ B attribute์ ๊ฐ์ด ํ ๋น๋ฉ๋๋ค.
[PutForwards]-๊ฐ ๋ถ์ attribute๋ ์ฒด์ธ(chained)์ด ๊ฐ๋ฅํฉ๋๋ค.
์ฆ, [PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ถ์
attribute๊ฐ
๋ค์ ๊ฐ์ ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ๊ฐ์ง attribute๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค.
๋จ, ์ ๋ฌ๋ ํ ๋น ์ฒด์ธ์ ์ฌ์ดํด์ด ์์ผ๋ฉด ์ ๋ฉ๋๋ค. ์ฌ์ดํด์ ์ ๋ฌ๋ ํ ๋น์ ๋ฐ๋ผ๊ฐ๋ค ํน์ ์ธํฐํ์ด์ค์ attribute๊ฐ ๋ค์ ๋ํ๋๋ฉด ๋ฐ์ํ ๊ฒ์
๋๋ค.
[PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ถ์
attribute๋
[LegacyLenientSetter] ๋๋
[Replaceable] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ํจ๊ป ์ ์ธํ ์
์์ต๋๋ค.
[PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ฝ๊ธฐ ์ ์ฉ attribute๊ฐ ์๋ ๊ณณ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
static attribute์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
namespace์ ์ ์ธ๋ attribute์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[PutForwards]์ ๊ตฌํ ๋ฐฉ๋ฒ์ ์์ฑ(Attributes) ์ ์ ์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋
์ด๋ฆ(Name)๊ณผ ์ฌ๋(Person) interface๋ฅผ ์ ์ํฉ๋๋ค.
Person interface์ name attribute์
[PutForwards]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ์ฌ,
ํด๋น attribute์ ๊ฐ์ ํ ๋นํ๋ฉด
Person ๊ฐ์ฒด์ full attribute์ ๊ฐ์ด ํ ๋น๋จ์ ๋ํ๋
๋๋ค:
[Exposed =Window ]interface Name {attribute DOMString full ;attribute DOMString family ;attribute DOMString given ; }; [Exposed =Window ]interface Person { [PutForwards =full ]readonly attribute Name name ;attribute unsigned short age ; };
JavaScript ๋ฐ์ธ๋ฉ์์๋ name ํ๋กํผํฐ์ ๊ฐ์ ํ ๋นํ ์ ์์ต๋๋ค:
var p= getPerson(); // Person ์ธ์คํด์ค ํ๋. p. name= 'John Citizen' ; // ์ด ๋ฌธ์ฅ... p. name. full= 'John Citizen' ; // ...์ด ๋ฌธ์ฅ๊ณผ ๋์ผํ ๋์.
3.3.11. [Replaceable]
[Replaceable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ฝ๊ธฐ ์ ์ฉ
์ ๊ท attribute์ ๋ํ๋๋ฉด,
ํด๋น ํ๋ซํผ ๊ฐ์ฒด์์ ํด๋น ํ๋กํผํฐ๋ฅผ ํ ๋นํ๋ฉด
ํ ๋น๋ ๊ฐ์ผ๋ก ๋์ผํ ์ด๋ฆ์ own property๊ฐ ๊ฐ์ฒด์ ์์ฑ๋ฉ๋๋ค. ์ด ํ๋กํผํฐ๋
interface prototype object์ ์๋ accessor
property๋ฅผ shadowํ๊ฒ ๋ฉ๋๋ค.
[Replaceable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[Replaceable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ถ์ attribute๋
[LegacyLenientSetter] ๋๋
[PutForwards] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ํจ๊ป ์ ์ธํ ์
์์ต๋๋ค.
[Replaceable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์ฝ๊ธฐ ์ ์ฉ์ด ์๋ attribute์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[Replaceable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
static attribute์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[Replaceable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
namespace์ ์ ์ธ๋ attribute์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ์ ยงโฏ3.7.6 ์์ฑ์์ [Replaceable] ์ฌ์ฉ ๊ท์น์ ์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ ์นด์ดํฐ๋ฅผ ์ฆ๊ฐ์ํค๋ operation๊ณผ 0์ผ๋ก ์ด๊ธฐํ๋๋ ์นด์ดํฐ์ ๊ฐ์ ๋ ธ์ถํ๋ attribute๋ฅผ ๊ฐ์ง interface๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface Counter { [Replaceable ]readonly attribute unsigned long value ;undefined increment (); };
ํ๋ซํผ ๊ฐ์ฒด์์ value ํ๋กํผํฐ์ ๊ฐ์
ํ ๋นํ๋ฉด,
ํด๋น attribute์ ๋์ํ๋ ํ๋กํผํฐ๋ฅผ shadowํฉ๋๋ค:
var counter= getCounter(); // Counter ์ธ์คํด์ค ํ๋. counter. value; // 0 ๋ฐํ. counter. hasOwnProperty( "value" ); // false ๋ฐํ. Object. getPrototypeOf( counter). hasOwnProperty( "value" ); // true ๋ฐํ. counter. increment(); counter. increment(); counter. value; // 2 ๋ฐํ. counter. value= 'a' ; // Counter::value์๋ ๋ฌด๊ดํ ๊ฐ์ผ๋ก shadow. // counter. hasOwnProperty( "value" ); // true ๋ฐํ. counter. increment(); counter. value; // 'a' ๋ฐํ. delete counter. value; // ์๋ ํ๋กํผํฐ ๋ณต์. counter. value; // 3 ๋ฐํ.
3.3.12. [SameObject]
[SameObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ฝ๊ธฐ ์ ์ฉ
attribute์ ๋ํ๋๋ฉด,
ํด๋น ๊ฐ์ฒด์ attribute ๊ฐ์ ์ป์ ๋ ํญ์ ๋์ผํ ๊ฐ์ ๋ฐํํด์ผ ํจ์ ๋ํ๋
๋๋ค.
[SameObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[SameObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ฝ๊ธฐ ์ ์ฉ attribute ์ค,
ํ์
์ด interface ํ์
๋๋ object์ผ ๋๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
์์๋ก, ์ด ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
implementation
attribute(Document
interface์ ์์ฑ)์ ์ ํฉํฉ๋๋ค.
ํด๋น Document
๊ฐ์ฒด์ ๋ํด ํญ์ ๋์ผํ ๊ฐ์ฒด๊ฐ ๋ฐํ๋๊ธฐ ๋๋ฌธ์
๋๋ค. [DOM]
[Exposed =Window ]interface Document :Node { [SameObject ]readonly attribute DOMImplementation implementation ; // ... };
3.3.13. [SecureContext]
[SecureContext]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ
interface,
partial interface,
interface mixin,
partial interface mixin,
callback interface,
namespace,
partial namespace,
interface member,
interface mixin member, ๋๋
namespace member์ ๋ํ๋๋ฉด,
ํด๋น ๊ตฌ์ฑ ์์๊ฐ ๋
ธ์ถ๋๋ ํ๊ฒฝ์ด ๋ณด์ ์ปจํ
์คํธ(secure
context)์ผ ๋๋ง ๋
ธ์ถ๋จ์ ๋ํ๋
๋๋ค.
[SecureContext]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ๋ค๋ฅธ ๊ตฌ์ฑ ์์์ ์ฌ์ฉํ๋ฉด ์ ๋ฉ๋๋ค.
[SecureContext]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[SecureContext]
๊ฐ ์ค๋ฒ๋ก๋๋ operation์ ๋ํ๋๋ฉด,
๋ชจ๋ ์ค๋ฒ๋ก๋์ ๋ฐ๋์ ๋ํ๋์ผ ํฉ๋๋ค.
[SecureContext]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ๋ค์ ๊ฒฝ์ฐ ๋ชจ๋์ ๋ช
์๋ ์ ์์ต๋๋ค:
-
interface member์ ๊ทธ interface ๋๋ partial interface ๋ ๋ค์;
-
interface mixin member์ ๊ทธ interface mixin ๋๋ partial interface mixin ๋ ๋ค์;
-
namespace member์ ๊ทธ namespace ๋๋ partial namespace ๋ ๋ค์.
์ฐธ๊ณ : [SecureContext]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ๋ฉค๋ฒ์ ์ถ๊ฐํด๋
์ ์ ์ ์ฒด์ ์ด๋ฏธ [SecureContext] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์์ผ๋ฉด ๋ฉค๋ฒ์ ๋
ธ์ถ ๋ฒ์๊ฐ ์ถ๊ฐ๋ก ์ ํ๋์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค.
[SecureContext]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ interface๋
[SecureContext]๋ฅผ ๋ช
์ํ ๋ค๋ฅธ interface๋ฅผ ์์ํ๋ฉด ์ ๋ฉ๋๋ค.
[SecureContext]
๋ [CrossOriginIsolated]์์
์กฐ๊ฑด๋ถ ๋
ธ์ถ๋จ ์ํ์ธ ๊ตฌ์ฑ ์์์๋ ๋ช
์ํ ์ ์์ต๋๋ค.
(๋ชจ๋ cross-origin isolated ํ๊ฒฝ์ ํญ์ ๋ณด์ ์ปจํ
์คํธ์ด๋ฏ๋ก ์ค๋ณต์
๋๋ค.)
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ ๋ชจ๋ ์ปจํ ์คํธ์์ ์คํ ๊ฐ๋ฅํ operation 1๊ฐ์, ๋ณด์ ์ปจํ ์คํธ์์๋ง ์คํ ๊ฐ๋ฅํ operation 2๊ฐ๋ฅผ ๊ฐ์ง interface๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ]interface ExampleFeature { // ๋ชจ๋ ์ปจํ ์คํธ์์ ์ฑ๊ณตPromise <Result >calculateNotSoSecretResult (); // ์ด operation์ ๋น๋ณด์ ์ปจํ ์คํธ์ ๋ ธ์ถ๋์ง ์์ต๋๋ค. ํด๋น ์ปจํ ์คํธ์์ ExampleFeature.prototype์ "calculateSecretResult" ์์ฑ์ด ์์ต๋๋ค. [SecureContext ]Promise <Result >calculateSecretResult (); // ๋ง์ฐฌ๊ฐ์ง๋ก ์ด attribute๋ ๋น๋ณด์ ์ปจํ ์คํธ์ ๋ ธ์ถ๋์ง ์์ผ๋ฉฐ, // ExampleFeature.prototype์ "secretBoolean" ์์ฑ์ด ์์ต๋๋ค. [SecureContext ]readonly attribute boolean secretBoolean ; }; // HeartbeatSensor๋ ๋น๋ณด์ ์ปจํ ์คํธ์ ๋ ธ์ถ๋์ง ์์ผ๋ฉฐ, ๋ฉค๋ฒ๋ ๋ ธ์ถ๋์ง ์์ต๋๋ค. // ํด๋น ์ปจํ ์คํธ์์ Window์ "HeartbeatSensor" ์์ฑ์ด ์์ต๋๋ค. [Exposed =Window ,SecureContext ]interface HeartbeatSensor {Promise <float >getHeartbeatsPerMinute (); }; // ์๋ interface mixin ๋ฉค๋ฒ๋ ๋น๋ณด์ ์ปจํ ์คํธ์์๋ ๋ ธ์ถ๋์ง ์์ต๋๋ค. ์ฆ, ๋น๋ณด์ ์ปจํ ์คํธ์์๋ ExampleFeature.prototype์ "snap" ์์ฑ์ด ์์ต๋๋ค. [SecureContext ]interface mixin Snapshotable {Promise <boolean >snap (); };ExampleFeature includes Snapshotable ; // ๋ฐ๋ฉด, ์๋ interface mixin ๋ฉค๋ฒ๋ ํธ์คํธ interface์ [SecureContext] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์์ผ๋ฉด ๋น๋ณด์ ์ปจํ ์คํธ์์๋ ๋ ธ์ถ๋ฉ๋๋ค. // ์ฆ, ๋น๋ณด์ ์ปจํ ์คํธ์์๋ ExampleFeature.prototype์ "log" ์์ฑ์ด ์์ต๋๋ค.interface mixin Loggable {Promise <boolean >log (); };ExampleFeature includes Loggable ;
3.3.14. [Unscopable]
[Unscopable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ ๊ท attribute
๋๋ ์ ๊ท operation์ ๋ํ๋๋ฉด,
ํด๋น ์ธํฐํ์ด์ค์ ๋ฉค๋ฒ๋ฅผ ๊ฐ์ง ๊ฐ์ฒด๊ฐ ํด๋น ๋ฉค๋ฒ์ ํ๋กํผํฐ๋ช
์ ๊ฐ์ฒด ํ๊ฒฝ ๋ ์ฝ๋์ base object์ ํฌํจํ์ง ์๊ฒ ๋จ์ ์๋ฏธํฉ๋๋ค.
๊ฒฐ๊ณผ์ ์ผ๋ก ํ๋กํผํฐ๋ช
๊ณผ ๋์ผํ ์๋ณ์๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ with ๋ฌธ์์ ํด๋น ํ๋กํผํฐ๊ฐ ํด์๋์ง ์์ต๋๋ค.
์ด๋ ํ๋กํผํฐ๋ช
์ interface prototype object์
%Symbol.unscopables%
ํ๋กํผํฐ ๊ฐ์ ํฌํจ์์ผ ๊ตฌํ๋ฉ๋๋ค.
[Unscopable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[Unscopable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์ ๊ท attribute
๋๋ ์ ๊ท operation ์ธ์ ๊ณณ์ ์ฌ์ฉํ๋ฉด ์ ๋ฉ๋๋ค.
[Unscopable]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ namespace์ ์ ์ธ๋ attribute์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๊ตฌ์ฒด์ ์ธ ์๊ตฌ์ฌํญ์ ยงโฏ3.7.3 ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์์ [Unscopable] ๊ด๋ จ ๊ท์น์ ์ฐธ๊ณ ํ์ธ์.
์๋ฅผ ๋ค์ด, ๋ค์๊ณผ ๊ฐ์ด IDL์ ์ ์ํ ๊ฒฝ์ฐ:
[Exposed =Window ]interface Thing {undefined f (); [Unscopable ]g (); };
f ํ๋กํผํฐ๋ with ๋ฌธ์์ ์๋ณ์๋ก ์ฐธ์กฐํ ์ ์์ง๋ง,
g ํ๋กํผํฐ๋ ์ฐธ์กฐํ ์ ์์ต๋๋ค:
var thing= getThing(); // Thing ์ธ์คํด์ค with ( thing) { f; // Function ๊ฐ์ฒด ๋ฐํ. g; // ReferenceError ๋ฐ์. }
3.4. ๋ ๊ฑฐ์ ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ
์ด ์ ์์๋ ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ ์ค, JavaScript ๋ฐ์ธ๋ฉ์ ์ํฅ์ ์ฃผ๋ ์ฌ๋ฌ ์ข ๋ฅ๋ฅผ ์ ์ํฉ๋๋ค. ยงโฏ3.3 ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ์๋ ๊ฒ๊ณผ ๋ฌ๋ฆฌ, ์ด๋ค ์ดํธ๋ฆฌ๋ทฐํธ๋ ๋ ๊ฑฐ์ Web ํ๋ซํผ ๊ธฐ๋ฅ ๋ช ์ธ๋ฅผ ์ํด์๋ง ์กด์ฌํฉ๋๋ค. ๋ช ์ธ์์ ์ฌ์ฉํ์ง ๋ง๊ณ , ๋ ๊ฑฐ์ API์ ๋์์ ๋ช ์ํ ํ์๊ฐ ์์ ๋๋ง ์ฌ์ฉํด์ผ ํฉ๋๋ค.
์ด๋ฌํ ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ ์ฌ์ฉ์ ๊ณ ๋ คํ๋ ํธ์ง์๋ ์ด์๋ฅผ ๋ฑ๋ก ํ์ฌ ๋ ผ์ํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
3.4.1. [LegacyFactoryFunction]
์ด ๊ธฐ๋ฅ ๋์ ์ธํฐํ์ด์ค์ ์์ฑ์ operation์ ์ ์ํ์ธ์.
[LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ interface์ ๋ํ๋๋ฉด,
JavaScript ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ์ง์ ๋ ์ด๋ฆ์ ํ๋กํผํฐ๊ฐ ์์ฑ๋๊ณ ,
๊ทธ ๊ฐ์ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ฅผ ์์ฑํ ์ ์๋ ํจ์๊ฐ ๋ฉ๋๋ค.
ํ๋์ interface์ ์ฌ๋ฌ [LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ํ๋ ์ ์์ต๋๋ค.
[LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
named argument list๋ฅผ ๊ฐ์ ธ์ผ ํฉ๋๋ค.
"LegacyFactoryFunction]์
์๋ณ์(identifier)์
๋๋ค.
interface์ ๋ํ๋ ๊ฐ [LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ง๋ค,
ํด๋น ํ๋กํผํฐ์ ๊ฐ์ธ ์์ฑ์ ํจ์์ ์ธ์๋ฅผ ์ ๋ฌํ์ฌ
interface ๊ตฌํ ๊ฐ์ฒด๋ฅผ ์์ฑํ ์ ์๋ ๋ฐฉ๋ฒ์ด ์ ๊ณต๋ฉ๋๋ค.
์๋ณ์๋
๋ค๋ฅธ interface์ [LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ์ฌ์ฉ๋ ๊ฒ๊ณผ ๊ฐ์ผ๋ฉด ์ ๋๋ฉฐ,
์ด interface ๋๋ ๋ค๋ฅธ interface์ [LegacyWindowAlias]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ์ฌ์ฉ๋ ์๋ณ์์ ๊ฐ์๋ ์ ๋ฉ๋๋ค.
๋ํ interface object๊ฐ ์๋ interface์ ์๋ณ์์ ๊ฐ์๋ ์ ๋๊ณ ,
reserved identifier๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyFactoryFunction]
์ [Global] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
๊ฐ์ interface์ ๋์์ ๋ช
์ํ ์ ์์ต๋๋ค.
๋ ๊ฑฐ์ factory ํจ์์ ๊ตฌํ ๋ฐฉ๋ฒ์ ยงโฏ3.7.2 Legacy factory functions์์ ์์ธํ ์ค๋ช ํฉ๋๋ค.
๋ค์ IDL์
[LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ๋ interface๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ,LegacyFactoryFunction =Audio (DOMString src )]interface HTMLAudioElement :HTMLMediaElement { // ... };
์ด interface๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋ HTMLAudioElement
๊ฐ์ฒด๋ฅผ Audio ํจ์๋ก ์์ฑํ ์ ์์ต๋๋ค.
typeof Audio; // 'function' ๋ฐํ. var a2= new Audio( 'a.flac' ); // ์ธ์ 1๊ฐ ์์ฑ์๋ฅผ ์ฌ์ฉํด HTMLAudioElement ์์ฑ. //
๋ ๊ฑฐ์ ๋์์ผ๋ก, ์ด๋ฌํ factory ํจ์๋ prototype ํ๋กํผํฐ๊ฐ ์๋ interface์ prototype๊ณผ ๊ฐ์ต๋๋ค:
console. assert( Audio. prototype=== HTMLAudioElement. prototype);
3.4.2. [LegacyLenientSetter]
[LegacyLenientSetter]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ฝ๊ธฐ ์ ์ฉ
์ ๊ท attribute์ ๋ํ๋๋ฉด,
ํด๋น attribute์ accessor property์ no-op setter๊ฐ ์์ฑ๋ฉ๋๋ค.
์ด๋ก ์ธํด strict mode์์ ์๋ชป๋ ํ๋กํผํฐ ํ ๋น์ด ์์ธ ์์ด ๋ฌด์๋ฉ๋๋ค.
์ค์ ํ์ด์ง์์๋ ์ ์๊ฐ IDL attribute๋ฅผ polyfillํ๋ ค๊ณ ํ๋กํผํฐ์ ํ ๋นํ๋ ๊ฒฝ์ฐ๊ฐ ์ข
์ข
์์ผ๋,
์ค์ ๋ก๋ ํด๋น ํ๋กํผํฐ๊ฐ ์ด๋ฏธ ์กด์ฌํ๋ ๊ฒฝ์ฐ๋ ์์ต๋๋ค.
strict mode์์๋ ์์ธ๊ฐ ๋ฐ์ํ์ฌ ํ์ด์ง๊ฐ ๊นจ์ง ์ ์์ง๋ง,
[LegacyLenientSetter]
๊ฐ ์์ผ๋ฉด ๋ธ๋ผ์ฐ์ ์์ ํด๋น ๊ธฐ๋ฅ์ shipํ ์ ์๊ฒ ๋ ์๋ ์์ต๋๋ค.
[LegacyLenientSetter]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
์ฝ๊ธฐ ์ ์ฉ ์ ๊ท attribute ์ธ์ ๊ณณ์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyLenientSetter]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ถ์ attribute๋
[PutForwards]
๋๋ [Replaceable] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ์ ํจ๊ป ์ ์ธํ ์
์์ต๋๋ค.
[LegacyLenientSetter]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ namespace์ ์ ์ธ๋ attribute์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyLenientSetter]์ ๊ตฌํ ๋ฐฉ๋ฒ์ ์์ฑ(Attributes) ์ ์ ์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL์ [LegacyLenientSetter]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ๋ interface๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ]interface Example { [LegacyLenientSetter ]readonly attribute DOMString x ;readonly attribute DOMString y ; };
์ด ์ธํฐํ์ด์ค๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋
x์ ๋์ํ๋ accessor property์ setter๊ฐ ์กด์ฌํ๋ฉฐ,
strict mode์์๋ ์๋ฌด ๋์์ ํ์ง ์์ต๋๋ค.
"use strict" ; var example= getExample(); // Example ์ธ์คํด์ค ํ๋. // strict mode์์๋ setter๋ no-op์ด๋ฏ๋ก ์์ธ ์์. example. x= 1 ; // strict mode์์ setter ์์ผ๋ฏ๋ก TypeError ๋ฐ์. example. y= 1 ;
3.4.3. [LegacyLenientThis]
[LegacyLenientThis]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์ ๊ท attribute์ ๋ํ๋๋ฉด,
ํด๋น attribute์ getter๋ setter๋ฅผ
[LegacyLenientThis]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
static attribute์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyLenientThis]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ namespace์ ์ ์ธ๋ attribute์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyLenientThis]์ ๊ตฌํ ๋ฐฉ๋ฒ์ ์์ฑ(Attributes) ์ ์ ์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL์
[LegacyLenientThis]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ๋ interface๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ]interface Example { [LegacyLenientThis ]attribute DOMString x ;attribute DOMString y ; };
์ด ์ธํฐํ์ด์ค๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋
x์ ๋์ํ๋ accessor property์ getter์ setter๋ฅผ
Example ๊ฐ์ฒด๊ฐ ์๋ ๊ฐ์ฒด๋ก๋ ํธ์ถํ ์ ์์ต๋๋ค.
var example= getExample(); // Example ์ธ์คํด์ค ํ๋. var obj= { }; // ์ ์ ๋์. example. x; // this ๊ฐ์ด Example ๊ฐ์ฒด๊ฐ ์๋๊ณ [LegacyLenientThis]๊ฐ ์ฌ์ฉ๋์์ผ๋ฏ๋ก ๋ฌด์๋จ. Object. getOwnPropertyDescriptor( Example. prototype, "x" ). get. call( obj); // Example.prototype๋ Example ๊ฐ์ฒด๊ฐ ์๋๋ฏ๋ก ๋ฌด์๋จ. Example. prototype. x; // Example.prototype์ด Example ๊ฐ์ฒด๊ฐ ์๋๋ฏ๋ก TypeError ๋ฐ์. Example. prototype. y;
3.4.4. [LegacyNamespace]
์ด ๊ธฐ๋ฅ ๋์ , ์ธํฐํ์ด์ค ์ด๋ฆ์ ํน์ ์ ๋์ฌ๋ก ์์ํ๋ ๋ค์ด๋ฐ ์ปจ๋ฒค์ ์ ์ฌ์ฉํ์ฌ ์๋ณ์์ ์ ์์ด ์์ฑํ์ธ์.
[LegacyNamespace]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ interface์ ๋ํ๋๋ฉด,
ํด๋น ์ธํฐํ์ด์ค ๊ฐ์ฒด๊ฐ ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ํ๋กํผํฐ๋ก ์์ฑ๋์ง ์๊ณ ,
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ ์ธ์๋ก ์ง์ ๋ namespace์ ํ๋กํผํฐ๋ก ์์ฑ๋จ์ ์๋ฏธํฉ๋๋ค.
[LegacyNamespace]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์๋ณ์๋ฅผ ๊ฐ์ ธ์ผ ํ๋ฉฐ,
ํด๋น ์๋ณ์๋ namespace ์ ์์ ์๋ณ์์ฌ์ผ ํฉ๋๋ค.
[LegacyNamespace]
์ [LegacyNoInterfaceObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ๊ฐ์ interface์ ๋์์ ๋ช
์ํ ์ ์์ต๋๋ค.
interface๊ฐ namespace์ ์ด๋ป๊ฒ ๋ ธ์ถ๋๋์ง์ ๋ํ ์์ธํ ๋ด์ฉ์ ยงโฏ3.13.1 ๋ค์์คํ์ด์ค ๊ฐ์ฒด๋ฅผ ์ฐธ๊ณ ํ์ธ์.
LegacyNamespace]์ผ๋ก ์ ์๋ interface๋ฅผ ๋ณด์ฌ์ค๋๋ค.
namespace Foo { }; [LegacyNamespace =Foo ]interface Bar {constructor (); };
์ ๋ค์์คํ์ด์ค์ ์ธํฐํ์ด์ค๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋, Bar ์์ฑ์๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ ๊ทผํ ์ ์์ต๋๋ค:
var instance= new Foo. Bar();
3.4.5. [LegacyNoInterfaceObject]
[LegacyNoInterfaceObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ interface์ ๋ํ๋๋ฉด,
ํด๋น ์ธํฐํ์ด์ค์ JavaScript ๋ฐ์ธ๋ฉ์์ interface object๊ฐ ์กด์ฌํ์ง
์์์ ์๋ฏธํฉ๋๋ค.
[LegacyNoInterfaceObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
์ธ์๋ฅผ ๊ฐ์ง์ง ์์์ผ ํฉ๋๋ค.
[LegacyNoInterfaceObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
ํด๋น interface์ ์์ฑ์๋ static operation์ด ์ ์๋์ด ์์ผ๋ฉด ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyNoInterfaceObject] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ช ์๋์ง ์์ interface๋, [LegacyNoInterfaceObject] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋ช ์๋ interface๋ฅผ ์์ํ๋ฉด ์ ๋ฉ๋๋ค.
๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ์ ยงโฏ3.7 ์ธํฐํ์ด์ค์์ [LegacyNoInterfaceObject]
์ฌ์ฉ ๊ท์น์ ์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ ํ๋๋ JavaScript ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ์ธํฐํ์ด์ค ๊ฐ์ฒด๊ฐ ๋ ธ์ถ๋๋ interface, ํ๋๋ ์ธํฐํ์ด์ค ๊ฐ์ฒด๊ฐ ๋ ธ์ถ๋์ง ์๋ interface๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface Storage {undefined addEntry (unsigned long key ,any value ); }; [Exposed =Window ,LegacyNoInterfaceObject ]interface Query {any lookupEntry (unsigned long key ); };
์ IDL์ JavaScript ๊ตฌํ์์๋
Storage์ ํ๋กํ ํ์
์ ์กฐ์ํ ์ ์์ง๋ง,
Query์ ํ๋กํ ํ์
์ ์กฐ์ํ ์ ์์ต๋๋ค.
typeof Storage; // "object" ๋ฐํ // Storage.addEntry์ alert() ํธ๋ ์ด์ฑ ์ถ๊ฐ var fn= Storage. prototype. addEntry; Storage. prototype. addEntry= function ( key, value) { alert( 'Calling addEntry()' ); return fn. call( this , key, value); }; typeof Query; // "undefined" ๋ฐํ var fn= Query. prototype. lookupEntry; // ์์ธ ๋ฐ์, Query๋ ์ ์๋์ง ์์
3.4.6. [LegacyNullToEmptyString]
[LegacyNullToEmptyString]
ํ์ฅ
์์ฑ์ด DOMString
๋๋ USVString
ํ์
์ ๋ํ๋๋ฉด,
JavaScript null"๋ก ๋ฌธ์์ดํ๋๋ ๋์
๋น ๋ฌธ์์ด๋ก ๋ณํ๋ฉ๋๋ค.
[LegacyNullToEmptyString]
ํ์ฅ ์์ฑ์ DOMString
๋๋ USVString์ด
์๋ ํ์
๊ณผ
์ฐ๊ฒฐ๋์ด์๋ ์ ๋ฉ๋๋ค.
์ฐธ๊ณ : ํ์ฅ ์์ฑ ์ค
ํ์
์ ์ ์ฉ ๊ฐ๋ฅํ ๋ค๋ฅธ ๊ฒ๋ค๊ณผ ๋ฌ๋ฆฌ,
[LegacyNullToEmptyString]์
DOMString?์ ๊ฐ์ ๋ ํ์ฉ ํ์
์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyNullToEmptyString]์
์ฌ์ฉ์
์๋ฐ๋๋ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์ ยง 3.2.10 DOMString์ ์ฐธ์กฐํ์ญ์์ค.
[Exposed =Window ]interface Dog {attribute DOMString name ;attribute [LegacyNullToEmptyString ]DOMString owner ;boolean isMemberOfBreed ([LegacyNullToEmptyString ]DOMString breedName ); };
์ด Dog interface๋ฅผ ๊ตฌํํ๋ JavaScript์์๋,
owner ํ๋กํผํฐ์ isMemberOfBreed ํจ์์ ์ธ์๋ก null" ๋์ ๋น ๋ฌธ์์ด๋ก ์ฒ๋ฆฌ๋ฉ๋๋ค:
var d= getDog(); // Dog ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํ๋ซํผ ๊ฐ์ฒด d d. name= null ; // .name ํ๋กํผํฐ์ "null"์ด ํ ๋น๋จ. d. owner= null ; // .owner ํ๋กํผํฐ์ ""์ด ํ ๋น๋จ. d. isMemberOfBreed( null ); // isMemberOfBreed ํจ์์ ""์ด ์ ๋ฌ๋จ.
3.4.7. [LegacyOverrideBuiltIns]
[LegacyOverrideBuiltIns]
ํ์ฅ
์์ฑ์ด
์ธํฐํ์ด์ค์ ๋ํ๋๋ฉด,
ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์์
๊ฐ์ฒด์ ๋ชจ๋ ์ง์๋๋ ์์ฑ ์ด๋ฆ์ ํด๋นํ๋ ์์ฑ์ด
๊ฐ์ฒด์ ์๋ ๊ฒ์ฒ๋ผ ๋ํ๋จ์ ๋ํ๋
๋๋ค.
๊ฐ์ฒด ๋๋ ๊ทธ
ํ๋กํ ํ์
์ฒด์ธ์ ์ด๋ค ๋ค๋ฅธ ์์ฑ์ด ์กด์ฌํ๋์ง์ ๊ด๊ณ์์ด ๊ทธ๋ ์ต๋๋ค. ์ด๋ ๋ช
๋ช
๋ ์์ฑ์ด ํญ์
๊ทธ๋ ์ง ์์ผ๋ฉด ๊ฐ์ฒด์ ๋ํ๋ ๋ชจ๋ ์์ฑ์ ๊ฐ๋ฆฌ๊ฒ ๋จ์ ์๋ฏธํฉ๋๋ค.
์ด๋ ์ผ๋ฐ์ ์ธ ๋์๊ณผ ๋์กฐ๋๋ฉฐ, ์ผ๋ฐ์ ์ธ ๋์์์๋ ๋ช
๋ช
๋ ์์ฑ์ด
๊ฐ์ฒด ์์ฒด ๋๋ ๊ทธ ํ๋กํ ํ์
์ฒด์ธ์ ์ด๋๊ฐ์
๊ฐ์ ์ด๋ฆ์ ์์ฑ์ด ์๋ ๊ฒฝ์ฐ์๋ง ๋
ธ์ถ๋ฉ๋๋ค.
[LegacyOverrideBuiltIns]
ํ์ฅ ์์ฑ์ ๋ฐ๋์
์ธ์๋ฅผ
๋ฐ์ง ์์์ผ ํ๋ฉฐ
๋ค์๊ณผ ๊ฐ์ ์ธํฐํ์ด์ค์๋ ๋ํ๋์๋ ์ ๋ฉ๋๋ค.
๋ช
๋ช
๋ ์์ฑ
getter๋ฅผ ์ ์ํ์ง ์๊ฑฐ๋
[Global] ํ์ฅ
์์ฑ์ผ๋ก๋ ์ ์ธ๋ ์ธํฐํ์ด์ค์
๋๋ค.
ํ์ฅ ์์ฑ์ด
๋ถ๋ถ
์ธํฐํ์ด์ค
์ ์์ ์ง์ ๋ ๊ฒฝ์ฐ, ํด๋น ๋ถ๋ถ ์ธํฐํ์ด์ค ์ ์๋ ๋ฐ๋์
์ธํฐํ์ด์ค ์ ์์์
๋ช
๋ช
๋
์์ฑ getter๋ฅผ ์ ์ํ๋ ๋ถ๋ถ์ด์ด์ผ ํฉ๋๋ค.
[LegacyOverrideBuiltIns]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ partial interface ์ ์์ ๋ช
์๋๋ฉด,
ํด๋น partial interface๊ฐ ์๋ interface ์ ์ฒด์ ๋ช
์๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผํฉ๋๋ค.
๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ์ ยงโฏ3.9 ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์ ยงโฏ3.9.3 [[DefineOwnProperty]]์์ [LegacyOverrideBuiltIns] ์ฌ์ฉ
๊ท์น์ ์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋ ํ๋๋ named property getter๊ฐ ์๋ interface, ํ๋๋ ์๋ interface๋ฅผ ์ ์ํฉ๋๋ค:
[Exposed =Window ]interface StringMap {readonly attribute unsigned long length ;getter DOMString lookup (DOMString key ); }; [Exposed =Window ,LegacyOverrideBuiltIns ]interface StringMap2 {readonly attribute unsigned long length ;getter DOMString lookup (DOMString key ); };
์ ๋ ์ธํฐํ์ด์ค๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋, ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์์ ํน์ ํ๋กํผํฐ๋ฅผ ์ป์ผ๋ฉด ์๋ก ๋ค๋ฅธ ๊ฒฐ๊ณผ๊ฐ ๋์ต๋๋ค:
// StringMap ์ธ์คํด์ค๋ฅผ ํ๋ํฉ๋๋ค. "abc", "length", "toString"์ด ์ง์๋๋ ํ๋กํผํฐ๋ช ์ด๋ผ๊ณ ๊ฐ์ ํฉ๋๋ค. var map1= getStringMap(); // named property getter๋ฅผ ํธ์ถํฉ๋๋ค. map1. abc; // ๊ฐ์ฒด์ "length" ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์ค๋ฉฐ, length attribute์ ๋์ํฉ๋๋ค. map1. length; // ๊ฐ์ฒด์ ํ๋กํ ํ์ ์ฒด์ธ์์ "toString" ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์ต๋๋ค. map1. toString; // StringMap2 ์ธ์คํด์ค๋ฅผ ํ๋ํฉ๋๋ค. ์ญ์ "abc", "length", "toString"์ด ์ง์๋ฉ๋๋ค. var map2= getStringMap2(); // named property getter๋ฅผ ํธ์ถํฉ๋๋ค. map2. abc; // "length" ํ๋กํผํฐ๊ฐ length attribute์ ๋์ํจ์๋ ๋ถ๊ตฌํ๊ณ , ์ญ์ named property getter๋ฅผ ํธ์ถํฉ๋๋ค. map2. length; // "toString"์ด map2์ ํ๋กํ ํ์ ์ฒด์ธ์ ์์์๋ ๋ถ๊ตฌํ๊ณ , ์ญ์ named property getter๋ฅผ ํธ์ถํฉ๋๋ค. map2. toString;
3.4.8. [LegacyTreatNonObjectAsNull]
[LegacyTreatNonObjectAsNull]
ํ์ฅ
์์ฑ์ด ์ฝ๋ฐฑ
ํจ์์ ๋ํ๋๋ฉด,
์ด๋ ํ์
์ด ๋ ํ์ฉ
์ฝ๋ฐฑ
ํจ์์ธ ์์ฑ์ ํ ๋น๋ ๋ชจ๋ ๊ฐ์ด ๋
๋์จํ๊ฒ ๋ณํ๋จ์ ๋ํ๋
๋๋ค. ๊ฐ์ด ๊ฐ์ฒด๊ฐ ์๋๋ฉด
null๋ก ๋ณํ๋๊ณ , ๊ฐ์ด ํธ์ถ ๊ฐ๋ฅํ์ง ์์ผ๋ฉด
ํธ์ถ๋์ด๋ ์๋ฌด ์์
๋ ํ์ง ์๋
์ฝ๋ฐฑ
ํจ์ ๊ฐ์ผ๋ก ๋ณํ๋ฉ๋๋ค.
ยง 3.2.20 ๋ ํ์ฉ ํ์
โ T?, ยง 3.2.19
์ฝ๋ฐฑ ํจ์ ํ์
๋ฐ ยง 3.12 ์ฝ๋ฐฑ
ํจ์ ํธ์ถ์ ์ฐธ์กฐํ์ญ์์ค.
์ด๋ ๋ค์ ์ฌ์ฉ์ ์๋ฐ๋๋ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์ ๊ดํ ๊ฒ์
๋๋ค:
[LegacyTreatNonObjectAsNull]
์
๋๋ค.
๋ค์ IDL
์กฐ๊ฐ์ ํ๋์
์์ฑ์ ๊ฐ์ง๋ ์ธํฐํ์ด์ค๋ฅผ ์ ์ํ๋ฉฐ, ๊ทธ ํ์
์ [LegacyTreatNonObjectAsNull]๋ก
์ฃผ์์ด ์ง์ ๋
์ฝ๋ฐฑ
ํจ์์ด๊ณ , ๋ค๋ฅธ ํ๋์ ํ์
์
์ฝ๋ฐฑ
ํจ์์ด๋ฉฐ ํ์ฅ ์์ฑ์ด ์์ต๋๋ค:
callback OccurrenceHandler =undefined (DOMString details ); [LegacyTreatNonObjectAsNull ]callback ErrorHandler =undefined (DOMString details ); [Exposed =Window ]interface Manager {attribute OccurrenceHandler ?handler1 ;attribute ErrorHandler ?handler2 ; };
JavaScript์์, ๊ฐ์ฒด๊ฐ ์๋ ๊ฐ(Number ๋ฑ)์ด๋ ํธ์ถ ๊ฐ๋ฅ(callable)์ด ์๋ ๊ฐ์ handler1์ ํ ๋นํ๋ฉด handler2์ ํ ๋นํ ๋์ ๋์์ด ๋ค๋ฆ ๋๋ค:
var manager= getManager(); // Manager ์ธ์คํด์ค ํ๋ manager. handler1= function () { }; manager. handler1; // ํจ์ ๋ฐํ try { manager. handler1= 123 ; // TypeError ๋ฐ์ } catch ( e) { } try { manager. handler1= {}; // TypeError ๋ฐ์ } catch ( e) { } manager. handler2= function () { }; manager. handler2; // ํจ์ ๋ฐํ manager. handler2= 123 ; manager. handler2; // null ๋ฐํ manager. handler2= {}; manager. handler2; // ๊ฐ์ฒด ๋ฐํ
3.4.9. [LegacyUnenumerableNamedProperties]
[LegacyUnenumerableNamedProperties]
ํ์ฅ
์์ฑ์ด
์ธํฐํ์ด์ค์ ๋ํ๋๊ณ
ํด๋น ์ธํฐํ์ด์ค๊ฐ ๋ช
๋ช
๋ ์์ฑ์ ์ง์ํ๋ ๊ฒฝ์ฐ,
์ด๋ ์ธํฐํ์ด์ค์ ๋ชจ๋ ๋ช
๋ช
๋ ์์ฑ์ด ์ด๊ฑฐ ๋ถ๊ฐ๋ฅํจ์ ๋ํ๋
๋๋ค.
[LegacyUnenumerableNamedProperties]
ํ์ฅ ์์ฑ์ ๋ฐ๋์
์ธ์๋ฅผ
๋ฐ์ง ์์์ผ ํ๋ฉฐ
๋ค์๊ณผ ๊ฐ์ ์ธํฐํ์ด์ค์๋ ๋ํ๋์๋ ์ ๋ฉ๋๋ค.
๋ช
๋ช
๋ ์์ฑ
getter๋ฅผ ์ ์ํ์ง ์๋ ์ธํฐํ์ด์ค์
๋๋ค.
[LegacyUnenumerableNamedProperties]
ํ์ฅ ์์ฑ์ด ์ธํฐํ์ด์ค์ ์ง์ ๋ ๊ฒฝ์ฐ, ์ด๋ ํด๋น ์ธํฐํ์ด์ค์์ ํ์๋ ๋ชจ๋ ์ธํฐํ์ด์ค์ ์ ์ฉ๋๋ฉฐ
๊ทธ ์ด๋ ์ธํฐํ์ด์ค์๋ ์ง์ ๋์ด์๋ ์ ๋ฉ๋๋ค.
๋ค์์ ๊ตฌ์ฒด์ ์ธ ์๊ตฌ ์ฌํญ์ ยง 3.9.1 [[GetOwnProperty]]์ ์ฐธ์กฐํ์ญ์์ค.
์ด๋ ๋ค์ ์ฌ์ฉ์ ์๋ฐ๋ฉ๋๋ค.
[LegacyUnenumerableNamedProperties]
์
๋๋ค.
3.4.10. [LegacyUnforgeable]
[LegacyUnforgeable]
ํ์ฅ
์์ฑ์ด
์ผ๋ฐ
์์ฑ ๋๋ ๋น-์ ์ ์ฐ์ฐ์ ๋ํ๋๋ฉด,
์ด๋ ํด๋น ์์ฑ ๋๋ ์ฐ์ฐ์ด
JavaScript ์์ฑ์ผ๋ก ๋ฐ์๋๋ฉฐ
๊ทธ ๋์์ ์์ ํ ์ ์๊ณ
๊ฐ์ฒด์์ ์์ฑ ์กฐํ๋ฅผ ์ํํ๋ฉด
ํญ์ ํด๋น ์์ฑ์ ์์ฑ ๊ฐ์ด ๋ฐํ๋๋ ๋ฐฉ์์์ ๋ํ๋
๋๋ค.
ํนํ, ํด๋น ์์ฑ์ ๊ตฌ์ฑ ๋ถ๊ฐ๋ฅํ๋ฉฐ
ํ๋กํ ํ์
์ด ์๋๋ผ ๊ฐ์ฒด ์์ฒด์ ๊ณ ์ ์์ฑ์ผ๋ก
์กด์ฌํฉ๋๋ค.
์์ฑ ๋๋ ์ฐ์ฐ์ ์ฃผ์ด์ง ์ธํฐํ์ด์ค A์์
์์กฐ
๋ถ๊ฐ๋ฅํ๋ค๊ณ ํฉ๋๋ค.
ํด๋น ์์ฑ ๋๋ ์ฐ์ฐ์ด A์ ์ ์ธ๋์ด ์๊ณ ,
[LegacyUnforgeable]
ํ์ฅ
์์ฑ์ผ๋ก ์ฃผ์์ด ์ง์ ๋ ๊ฒฝ์ฐ์
๋๋ค.
[LegacyUnforgeable]
ํ์ฅ ์์ฑ์ ๋ฐ๋์ ์ธ์๋ฅผ
๋ฐ์ง ์์์ผ ํฉ๋๋ค.
[LegacyUnforgeable]
ํ์ฅ
์์ฑ์
์ผ๋ฐ ์์ฑ
๋๋ ๋น-์ ์
์ฐ์ฐ ์ด์ธ์๋ ๋ํ๋์๋ ์ ๋ฉ๋๋ค.
์ด๊ฒ์ด ์ฐ์ฐ์ ๋ํ๋๋ ๊ฒฝ์ฐ,
ํด๋น ์ธํฐํ์ด์ค์์ ๋์ผํ
์๋ณ์๋ฅผ ๊ฐ์ง ๋ชจ๋ ์ฐ์ฐ์๋
๋ํ๋์ผ ํฉ๋๋ค.
[LegacyUnforgeable]
ํ์ฅ ์์ฑ์
๋ค์์คํ์ด์ค์ ์ ์ธ๋ ์์ฑ์๋ ์ฌ์ฉํด์๋ ์ ๋ฉ๋๋ค.
์์ฑ ๋๋ ์ฐ์ฐ X๊ฐ ์ธํฐํ์ด์ค A์์ ์์กฐ ๋ถ๊ฐ๋ฅํ๊ณ , A๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค B์ ์์๋ ์ธํฐํ์ด์ค ์ค ํ๋๋ผ๋ฉด, B์๋ ์ผ๋ฐ ์์ฑ ๋๋ ๋น-์ ์ ์ฐ์ฐ ์ค X์ ๋์ผํ ์๋ณ์๋ฅผ ๊ฐ์ง ๊ฒ์ด ์์ด์๋ ์ ๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด, ์๋์ ๊ฐ์ ์ฝ๋๋ ํ์ฉ๋์ง ์์ต๋๋ค:
[Exposed =Window ]interface A1 { [LegacyUnforgeable ]readonly attribute DOMString x ; }; [Exposed =Window ]interface B1 :A1 {undefined x (); // ํ์ฉ๋์ง ์์; A1์ x์ ์ํด shadow๋จ. }; [Exposed =Window ]interface B2 :A1 { };B2 includes M1 ;interface mixin M1 {undefined x (); // ํ์ฉ๋์ง ์์; B2์ x๊ฐ A1์ x์ ์ํด shadow๋จ. };
๊ตฌ์ฒด์ ์๊ตฌ์ฌํญ์ ยงโฏ3.7.6 ์์ฑ,
ยงโฏ3.7.7 ์ฐ์ฐ,
ยงโฏ3.8 ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํ๋ซํผ ๊ฐ์ฒด,
ยงโฏ3.9 ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด,
ยงโฏ3.9.3 [[DefineOwnProperty]]์์ [LegacyUnforgeable] ์ฌ์ฉ ๊ท์น์
์ฐธ๊ณ ํ์ธ์.
๋ค์ IDL ํ๋๊ทธ๋จผํธ๋
๋ ๊ฐ์ attribute๋ฅผ ๊ฐ์ง
interface๋ฅผ ์ ์ํ๋ฉฐ,
๊ทธ ์ค ํ๋๋ [LegacyUnforgeable]๋ก
์ง์ ๋์ด
์์ต๋๋ค:
[Exposed =Window ]interface System { [LegacyUnforgeable ]readonly attribute DOMString username ;readonly attribute long long loginTime ; };
ํด๋น interface๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋ username attribute๊ฐ ๊ฐ์ฒด ์์ฒด์ non-configurable ํ๋กํผํฐ๋ก ๋ ธ์ถ๋ฉ๋๋ค:
var system= getSystem(); // System ์ธ์คํด์ค ํ๋. system. hasOwnProperty( "username" ); // true ๋ฐํ system. hasOwnProperty( "loginTime" ); // false ๋ฐํ System. prototype. hasOwnProperty( "username" ); // false ๋ฐํ System. prototype. hasOwnProperty( "loginTime" ); // true ๋ฐํ try { // ํด๋น ํ๋กํผํฐ๊ฐ non-configurable์ด๋ฏ๋ก ์คํจํจ. Object. defineProperty( system, "username" , { value: "administrator" }); } catch ( e) { } // ์๋ defineProperty๋ ์ฑ๊ณต (System.prototype.loginTime์ configurable) var forgedLoginTime= 5 ; Object. defineProperty( System. prototype, "loginTime" , { value: forgedLoginTime}); system. loginTime; // forgedLoginTime ๋ฐํ
3.4.11. [LegacyWindowAlias]
[LegacyWindowAlias]
ํ์ฅ
์์ฑ์ด ์ธํฐํ์ด์ค์ ๋ํ๋๋ฉด,
์ด๋ Window
์ธํฐํ์ด์ค๊ฐ ๋ค์ ๊ฐ๊ฐ์ ๋ํด
์์ฑ์ ๊ฐ๊ฒ ๋จ์ ๋ํ๋
๋๋ค.
ํ์ฅ ์์ฑ์ ์ธ๊ธ๋ ๊ฐ ์๋ณ์์ ๋ํด,
๊ทธ ๊ฐ์ ํด๋น ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค
๊ฐ์ฒด์
๋๋ค.
[LegacyWindowAlias]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ์๋ณ์ ๋๋
์๋ณ์
๋ฆฌ์คํธ๋ฅผ ๊ฐ์ ธ์ผ ํฉ๋๋ค.
โ=โ ์ดํ์ ๋์ค๋ ์๋ณ์๋ค์ [LegacyWindowAlias]์ ์๋ณ์(identifier)์
๋๋ค.
[LegacyWindowAlias]์ ์๋ณ์๋ค์
์ด interface ๋๋ ๋ค๋ฅธ interface์ [LegacyWindowAlias]์์ ์ฌ์ฉ๋ ๊ฒ๊ณผ ๊ฐ์ผ๋ฉด
์ ๋๋ฉฐ,
์ด interface ๋๋ ๋ค๋ฅธ interface์ [LegacyFactoryFunction]์์
์ฌ์ฉ๋ ์๋ณ์์ ๊ฐ์๋ ์ ๋๊ณ ,
interface ๊ฐ์ฒด๊ฐ ์๋ interface์ ์๋ณ์์ ๊ฐ์๋ ์ ๋๋ฉฐ,
์์ฝ๋ ์๋ณ์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
[LegacyWindowAlias]์ [LegacyNoInterfaceObject]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ๊ฐ์ interface์ ๋์์ ๋ช
์ํ ์ ์์ต๋๋ค.
[LegacyWindowAlias]์ [LegacyNamespace] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ ๊ฐ์
interface์ ๋ช
์ํ ์ ์์ต๋๋ค.
[LegacyWindowAlias] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋
Window
interface๊ฐ ๋
ธ์ถ ์งํฉ์ ํฌํจ๋์ง ์์ interface์๋ ๋ช
์ํ ์ ์์ต๋๋ค.
ํ interface์ ํ๋ ์ด์์ [LegacyWindowAlias] ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ
๋ช
์ํ ์ ์์ต๋๋ค.
๋ ๊ฑฐ์ window alias์ ๊ตฌํ ๋ฐฉ๋ฒ์ ยงโฏ3.7 ์ธํฐํ์ด์ค์์ ์์ธํ ์ค๋ช ํฉ๋๋ค.
๋ค์ IDL์
[LegacyWindowAlias]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๋ฅผ ์ฌ์ฉํ๋ interface๋ฅผ ์ ์ํฉ๋๋ค.
[Exposed =Window ,LegacyWindowAlias =WebKitCSSMatrix ]interface DOMMatrix :DOMMatrixReadOnly { // ... };
์ด interface๋ฅผ ์ง์ํ๋ JavaScript ๊ตฌํ์์๋
Window
๊ฐ์ฒด์ ๋์ผํ ๊ฐ์ ๊ฐ์ง๋ ๋ ๊ฐ์ ํ๋กํผํฐ๊ฐ ๋
ธ์ถ๋ฉ๋๋ค.
ํ๋๋ ๋ณดํต๋๋ก interface ๊ฐ์ฒด๋ฅผ ๋
ธ์ถํ๊ณ ,
ํ๋๋ ๋ ๊ฑฐ์ ์ด๋ฆ์ผ๋ก ๋
ธ์ถํฉ๋๋ค.
WebKitCSSMatrix=== DOMMatrix; // true ๋ฐํ var m= new WebKitCSSMatrix(); // DOMMatrix๋ฅผ ๊ตฌํํ๋ ์ ๊ฐ์ฒด ์์ฑ // m. constructor === DOMMatrix; // true ๋ฐํ m. constructor === WebKitCSSMatrix; // true ๋ฐํ {}. toString. call( m); // '[object DOMMatrix]' ๋ฐํ
3.5. ๋ณด์(Security)
์๋ ์ ๋ค์ ์ ์๋ ํน์ ์๊ณ ๋ฆฌ์ฆ์ ์ฃผ์ด์ง ๊ฐ์ฒด์ ๋ณด์ ๊ฒ์ฌ๋ฅผ ์ํํ๋ค๊ณ ์ ์๋์ด ์์ต๋๋ค. ์ด ๊ฒ์ฌ๋ ์ฃผ์ด์ง operation ํธ์ถ์ด๋ attribute ์ ๊ทผ์ด ํ์ฉ๋์ด์ผ ํ๋์ง๋ฅผ ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ๋ณด์ ๊ฒ์ฌ๋ ๋ค์ ์ธ ์ ๋ ฅ๊ฐ์ ์ฌ์ฉํฉ๋๋ค:
-
operation ํธ์ถ์ด๋ attribute ์ ๊ทผ์ด ์ํ๋๋ ํ๋ซํผ ๊ฐ์ฒด
-
ํด๋น operation ๋๋ attribute์ ์๋ณ์
-
ํจ์ ๊ฐ์ฒด(function object)์ ํ์ โ "method"(IDL operation์ ํด๋นํ๋ ๊ฒฝ์ฐ), "getter"/"setter"(IDL attribute์ getter/setter ํจ์์ ํด๋นํ๋ ๊ฒฝ์ฐ)
์ฐธ๊ณ : HTML ํ์ค์์๋ ๋ณด์ ๊ฒ์ฌ ์ํ ๋ฐฉ๋ฒ์ ์ ์ํฉ๋๋ค. [HTML]
3.6. ์ค๋ฒ๋ก๋ ํด์ ์๊ณ ๋ฆฌ์ฆ
ํจ์ ํธ์ถ์ด ํด๊ฒฐ๋๋ ๋ฐฉ์์ ์ ์ํ๊ธฐ ์ํด, ์ค๋ฒ๋ก๋ ํด๊ฒฐ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ํฉ๋๋ค. ์ ๋ ฅ์ ์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ, S์ JavaScript ๊ฐ ๋ชฉ๋ก args์ ๋๋ค. ์ถ๋ ฅ์ ์ฐ์ฐ ๋๋ S์ ํญ๋ชฉ ์ค ํ๋์ ํ์ฅ ์์ฑ๊ณผ IDL ๊ฐ ๋ชฉ๋ก ๋๋ ํน์ ๊ฐ โmissingโ์ผ๋ก ๊ตฌ์ฑ๋ ์์ ๋๋ค. ์๊ณ ๋ฆฌ์ฆ์ ๋ค์๊ณผ ๊ฐ์ด ๋์ํฉ๋๋ค:
-
maxarg๋ฅผ S์ ํญ๋ชฉ ์ค ๊ฐ์ฅ ๊ธด ํ์ ๋ชฉ๋ก์ ๊ธธ์ด๋ก ๋ก๋๋ค.
-
n์ args์ ํฌ๊ธฐ๋ก ๋ก๋๋ค.
-
argcount๋ฅผ min(maxarg, n)์ผ๋ก ์ด๊ธฐํํฉ๋๋ค.
-
ํ์ ๋ชฉ๋ก์ ๊ธธ์ด๊ฐ argcount๊ฐ ์๋ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
d๋ฅผ โ1๋ก ์ด๊ธฐํํฉ๋๋ค.
-
method๋ฅผ
undefined ๋ก ์ด๊ธฐํํฉ๋๋ค. -
S์ ๋ ์ด์์ ํญ๋ชฉ์ด ์์ผ๋ฉด, d๋ฅผ S์ ํญ๋ชฉ์ ๋ํ ๊ตฌ๋ณ ์ธ์ ์ธ๋ฑ์ค๋ก ์ค์ ํฉ๋๋ค.
-
values๋ฅผ ๋น ๋ชฉ๋ก์ผ๋ก ์ด๊ธฐํํ๋ฉฐ, ๊ฐ ํญ๋ชฉ์ IDL ๊ฐ ๋๋ ํน์ ๊ฐ โmissingโ ์ค ํ๋๊ฐ ๋ฉ๋๋ค.
-
i๋ฅผ 0์ผ๋ก ์ด๊ธฐํํฉ๋๋ค.
-
i < d์ธ ๋์:
-
V๋ฅผ args[i]๋ก ๋ก๋๋ค.
-
type์ S์ ์์์ ํญ๋ชฉ์ ํ์ ๋ชฉ๋ก์์ ์ธ๋ฑ์ค i์ ์๋ ํ์ ์ผ๋ก ๋ก๋๋ค.
์ฐธ๊ณ : ์ด ์์ ์์ S์ ๋ชจ๋ ํญ๋ชฉ์ ์ธ๋ฑ์ค i์์ ๋์ผํ ํ์ ๊ณผ ์ ํ์ฑ ๊ฐ์ ๊ฐ์ง๋๋ค.
-
optionality๋ฅผ S์ ์์์ ํญ๋ชฉ์ ์ ํ์ฑ ๊ฐ ๋ชฉ๋ก์์ ์ธ๋ฑ์ค i์ ์๋ ๊ฐ์ผ๋ก ๋ก๋๋ค.
-
optionality๊ฐ โoptionalโ์ด๊ณ V๊ฐ
undefined ์ด๋ฉด, ๋ค์์ ์ํํฉ๋๋ค:-
์ธ๋ฑ์ค i์ ์ธ์๊ฐ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ ์ธ๋์ด ์์ผ๋ฉด, ํด๋น ๊ธฐ๋ณธ๊ฐ์ values์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, ํน์ ๊ฐ โmissingโ์ values์ ์ถ๊ฐํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด, V๋ฅผ IDL ํ์ type์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ values์ ์ถ๊ฐํฉ๋๋ค.
-
i๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
i = d์ด๋ฉด:
-
V๋ฅผ args[i]๋ก ๋ก๋๋ค.
์ฐธ๊ณ : ์ด๋ ์ด๋ค ์ค๋ฒ๋ก๋๊ฐ ์ ํ๋๋์ง ํด๊ฒฐํ๋ ๋ฐ ์ฌ์ฉ๋ ์ธ์์ ๋๋ค.
-
V๊ฐ
undefined ์ด๊ณ , S์ ์ ํ์ฑ ๊ฐ ๋ชฉ๋ก์ ์ธ๋ฑ์ค i์ โoptionalโ์ด ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด, ๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค. -
๊ทธ๋ ์ง ์๊ณ : V๊ฐ
null ๋๋undefined ์ด๊ณ , S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ๋ ํ์ฉ ํ์ ์ ํฌํจํ๊ฑฐ๋ ๊ทธ ํํํ๋ ๋ฉค๋ฒ์ ๋์ ๋๋ฆฌ ํ์ ์ด ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ ํ๋ซํผ ๊ฐ์ฒด์ด๊ณ , S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Object์ด๊ณ , V์ [[ArrayBufferData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ผ๋ฉฐ, S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Object์ด๊ณ , V์ [[DataView]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ผ๋ฉฐ, S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Object์ด๊ณ , V์ [[TypedArrayName]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ผ๋ฉฐ, S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ด๋ฆ์ด V์ [[TypedArrayName]] ๋ด๋ถ ์ฌ๋กฏ ๊ฐ๊ณผ ๊ฐ์ ํ์ ๋ฐฐ์ด ํ์
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์๊ณ : IsCallable(V)๊ฐ true์ด๊ณ , S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฝ๋ฐฑ ํจ์ ํ์
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Object์ด๊ณ S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๊ทธ๋ฆฌ๊ณ ๋ค์์ด ๋ชจ๋ ์ฐธ์ธ ๊ฒ์ ์๋๋ฉฐ,
-
V์ [[StringData]] ๋ด๋ถ ์ฌ๋กฏ์ด ์์ต๋๋ค
-
S๊ฐ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๋ฅผ ๊ฐ์ง๋๋ค,
-
๋ฌธ์์ด ํ์ ์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ๋ฌธ์์ด ํ์ ์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๊ทธ๋ฆฌ๊ณ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ ํ,
-
method๋ฅผ ? GetMethod(V,
%Symbol.asyncIterator%)๋ก ๋ก๋๋ค. -
method๊ฐ
undefined ์ด๋ฉด, method๋ฅผ ? GetMethod(V,%Symbol.iterator%)๋ก ์ค์ ํฉ๋๋ค.
method๊ฐ
undefined ๊ฐ ์๋๋ฉด, ๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค. -
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Object์ด๊ณ S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๊ทธ๋ฆฌ๊ณ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํ ํ,
-
method๋ฅผ ? GetMethod(V,
%Symbol.iterator%)๋ก ๋ก๋๋ค.
method๊ฐ
undefined ๊ฐ ์๋๋ฉด, ๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค. -
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Object์ด๊ณ S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Boolean์ด๊ณ S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ Number์ด๊ณ S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : V๊ฐ BigInt์ด๊ณ S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์์ ํ์ ์ค ํ๋์ ๋ ํ์ฉ ๋ฒ์
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : S์ ํ์ ๋ชฉ๋ก์ ์์น i์ ๋ค์ ํ์ ์ค ํ๋๊ฐ ์๋ ํญ๋ชฉ์ด ์๋ค๋ฉด,
-
์ฃผ์์ด ์ง์ ๋ ํ์ ์ผ๋ก, ๊ทธ ๋ด๋ถ ํ์ ์ด ์์ ํ์ ์ค ํ๋์ธ ๊ฒ
-
์ ๋์ธ ํ์ , ๋ ํ์ฉ ์ ๋์ธ ํ์ ๋๋ ์ฃผ์์ด ์ง์ ๋ ์ ๋์ธ ํ์ ์ผ๋ก, ํํํ๋ ๋ฉค๋ฒ ํ์ ์ ์์ ํ์ ์ค ํ๋๊ฐ ์๋ ๊ฒ
๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ : S์ ํ์ ๋ชฉ๋ก์ ์์น i์
any๊ฐ ์๋ ํญ๋ชฉ์ด ์์ผ๋ฉด, ๋ค๋ฅธ ๋ชจ๋ ํญ๋ชฉ์ S์์ ์ ๊ฑฐํฉ๋๋ค.
-
-
callable์ S์ ์ ์ผํ ํญ๋ชฉ์ ์ฐ์ฐ ๋๋ ํ์ฅ ์์ฑ์ผ๋ก ๋ก๋๋ค.
-
i = d์ด๊ณ method๊ฐ
undefined ๊ฐ ์๋๋ฉด:-
V๋ฅผ args[i]๋ก ๋ก๋๋ค.
-
T๋ฅผ S์ ๋จ์ ํญ๋ชฉ์ ํ์ ๋ชฉ๋ก์์ ์ธ๋ฑ์ค i์ ์๋ ํ์ ์ผ๋ก ๋ก๋๋ค.
-
๋จ์ธ: T๋ ์ํ์ค ํ์ ์ ๋๋ค.
-
V์ method๋ก๋ถํฐ ํ์ T์ ์ํ์ค๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ฅผ values์ ์ถ๊ฐํฉ๋๋ค.
-
i๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
i < argcount์ธ ๋์:
-
V๋ฅผ args[i]๋ก ๋ก๋๋ค.
-
type์ S์ ๋จ์ ํญ๋ชฉ์ ํ์ ๋ชฉ๋ก์์ ์ธ๋ฑ์ค i์ ์๋ ํ์ ์ผ๋ก ๋ก๋๋ค.
-
optionality๋ฅผ S์ ๋จ์ ํญ๋ชฉ์ ์ ํ์ฑ ๊ฐ ๋ชฉ๋ก์์ ์ธ๋ฑ์ค i์ ์๋ ๊ฐ์ผ๋ก ๋ก๋๋ค.
-
optionality๊ฐ โoptionalโ์ด๊ณ V๊ฐ
undefined ์ด๋ฉด, ๋ค์์ ์ํํฉ๋๋ค:-
์ธ๋ฑ์ค i์ ์ธ์๊ฐ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ ์ธ๋์ด ์์ผ๋ฉด, ํด๋น ๊ธฐ๋ณธ๊ฐ์ values์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, ํน์ ๊ฐ โmissingโ์ values์ ์ถ๊ฐํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด, V๋ฅผ IDL ํ์ type์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ values์ ์ถ๊ฐํฉ๋๋ค.
-
i๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
i๊ฐ callable์ด ๋ฐ๋๋ก ์ ์ธ๋ ์ธ์์ ์๋ณด๋ค ์์ ๋์:
-
callable์ ์ธ๋ฑ์ค i์ ์๋ ์ธ์๊ฐ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ ์ธ๋์ด ์์ผ๋ฉด, ํด๋น ๊ธฐ๋ณธ๊ฐ์ values์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ , callable์ ์ธ๋ฑ์ค i์ ์๋ ์ธ์๊ฐ ๊ฐ๋ณ ์ธ์๊ฐ ์๋๋ฉด, ํน์ ๊ฐ โmissingโ์ values์ ์ถ๊ฐํฉ๋๋ค.
-
i๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
<callable, values> ์์ ๋ฐํํฉ๋๋ค.
์ค๋ฒ๋ก๋ ํด์ ์๊ณ ๋ฆฌ์ฆ์ ์ด๋ค ์ค๋ฒ๋ก๋๋ operation, ์์ฑ์ ๋ฑ์ด ํธ์ถ๋๋์ง ์๋ณํ๋ ๊ฒ๊ณผ, JavaScript ์ธ์ ๊ฐ์ ํด๋นํ๋ IDL ๊ฐ์ผ๋ก ๋ณํํ๋ ๋ ์์ ์ ์ํํฉ๋๋ค. ๋น๊ณต์์ ์ผ๋ก ์๋ ๋ฐฉ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๋จผ์ , ์ ํจํ ์ค๋ฒ๋ก๋๋ฅผ ์ ํํ๋ ๊ณผ์ ์ ํจ์์ ์ ๋ฌ๋ JavaScript ์ธ์ ๊ฐ์๋ฅผ ๊ณ ๋ คํ์ฌ ์งํ๋ฉ๋๋ค:
-
๊ฐ์ฅ ๊ธด ์ค๋ฒ๋ก๋ ์ธ์ ๋ฆฌ์คํธ๋ณด๋ค ๋ ๋ง์ ์ธ์๊ฐ ์ ๋ฌ๋ ๊ฒฝ์ฐ, ๊ทธ ์ด๊ณผ ์ธ์๋ค์ ๋ฌด์๋ฉ๋๋ค.
-
์ด๋ ๊ฒ ๋ค์ชฝ ์ธ์๋ค์ ๋ฌด์ํ๊ณ ๋๋ฉด, ์ ํํ ๊ทธ ๊ฐ์์ ์ธ์๋ฅผ ๋ฐ์ ์ ์๋ ์ค๋ฒ๋ก๋๋ง ๊ณ ๋ คํฉ๋๋ค. ๋ง์ฝ ๊ทธ๋ฐ ์ค๋ฒ๋ก๋๊ฐ ์๋ค๋ฉด
TypeError๊ฐ ๋ฐ์ํฉ๋๋ค.
์ฌ๋ฐ๋ฅธ ์ธ์ ๊ฐ์์ ์ค๋ฒ๋ก๋ ์งํฉ์ ์ป์ ํ์๋, JavaScript ๊ฐ๋ค์ ์ผ์ชฝ๋ถํฐ ์ค๋ฅธ์ชฝ์ผ๋ก ๋ณํํฉ๋๋ค. ์ค๋ฒ๋ก๋ ์ ์ฝ์ ์ฑ์ง ๋๋ถ์, ์ด ์์ ์ ์ค๋ฒ๋ก๋๊ฐ ์ฌ๋ฌ ๊ฐ ๋จ์ ์๋ค๋ฉด, ์ธ์ ๋ฆฌ์คํธ ์ค ํ ์์น์์ ์ต์ข ์ ์ผ๋ก ์ด๋ค ์ค๋ฒ๋ก๋๋ฅผ ์ ํํ ์ง ๊ตฌ๋ถํ๊ฒ ๋ฉ๋๋ค. ์ด ์์น๊ฐ ๊ตฌ๋ถ ์ธ์ ์ธ๋ฑ์ค(distinguishing argument index)์ ๋๋ค.
๋จผ์ ๊ตฌ๋ถ ์ธ์ ์ผ์ชฝ์ ์ธ์๋ค์ ๋ณํํฉ๋๋ค.(๊ตฌ๋ถ ์ธ์ ์ธ๋ฑ์ค ์ผ์ชฝ์ ์์นํ ์ธ์๋ ๋ชจ๋ ์ค๋ฒ๋ก๋์์ ๊ฐ์ ํ์
์ด์ด์ผ ํฉ๋๋ค.) ๊ทธ ๋ค์, ๊ตฌ๋ถ ์ธ์ ์ธ๋ฑ์ค์ ์ ๋ฌ๋ JavaScript
๊ฐ์ ํ์
์ ๊ฒ์ฌํ์ฌ ์ด๋ค IDL ํ์
์ ๋์๋ ์ ์๋์ง ๊ฒฐ์ ํฉ๋๋ค.
์ด๋ฅผ ํตํด ์ต์ข
์ ์ผ๋ก ํธ์ถํ ์ค๋ฒ๋ก๋๋ฅผ ์ ํํฉ๋๋ค. ๋ง์ฝ ์ ๋ฌ๋ ๊ฐ์ด TypeError๊ฐ ๋ฐ์ํฉ๋๋ค.
์ผ๋ฐ์ ์ผ๋ก, ๊ตฌ๋ถ ์ธ์ ์ธ๋ฑ์ค์ ๊ฐ ๊ฒ์ฌ์๋ ๋ถ์์ฉ์ด ์์ผ๋ฉฐ, ์ค๋ฒ๋ก๋ ํด์ ์๊ณ ๋ฆฌ์ฆ์์ ๋ฐ์ํ๋ ์ ์ผํ ๋ถ์์ฉ์ JavaScript ๊ฐ์ IDL ๊ฐ์ผ๋ก ๋ณํํ๋ ๊ณผ์ ์๋ง ์์ต๋๋ค.
(์์ธ์ ์ผ๋ก, ์ด๋ค ์ค๋ฒ๋ก๋๊ฐ ๊ตฌ๋ถ ์ธ์ ์ธ๋ฑ์ค์ async sequence ํ์
,
sequence ํ์
,
๋๋ frozen array ํ์
์ ๊ฐ์ง๋ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค.
์ด๋๋ %Symbol.asyncIterator%
/ %Symbol.iterator%
ํ๋กํผํฐ๋ฅผ ์ป์ด ์ ํฉํ ์ค๋ฒ๋ก๋๋ฅผ ๊ฒฐ์ ํ๋ฉฐ, ๊ตฌ๋ถ ์ธ์์ ๋ํ ๋ณํ์ ๋ฐ๋ก ์ํํ ๋ค ๋ค์ ๋จ๊ณ๋ฅผ ๊ณ์ ์งํํฉ๋๋ค.)
์ด์ ์ฌ์ฉํ ์ค๋ฒ๋ก๋๊ฐ ๊ฒฐ์ ๋์์ต๋๋ค. ๋จ์ ์ธ์๋ค์ ๊ตฌ๋ถ ์ธ์๋ถํฐ ์ค๋ฅธ์ชฝ์ผ๋ก ๋ณํํ๋ฉฐ, ์์ ์ด๊ณผ๋์ด ๋ฌด์๋ ์ธ์๋ค์ ๊ณ์ ๋ฌด์ํฉ๋๋ค.
optional ์ธ์์ JavaScript ๊ฐ์ ํด๋น IDL ๊ฐ์ผ๋ก ๋ณํํ ๋,
๋ง์ง๋ง ๊ฐ๋ณ ์ธ์(variadic argument)์ ํด๋นํ๋ optional ์ธ์์์๋
3.7. ์ธํฐํ์ด์ค
์ฃผ์ด์ง realm์์
๋
ธ์ถ๋๋ฉฐ
[LegacyNoInterfaceObject]
๋๋ [LegacyNamespace]
ํ์ฅ
์์ฑ์ผ๋ก ์ ์ธ๋์ง ์์ ๋ชจ๋ ์ธํฐํ์ด์ค์ ๋ํด,
ํด๋น realm์ ์ ์ญ ๊ฐ์ฒด์ ๋์ํ๋ ์์ฑ์ด ์กด์ฌํฉ๋๋ค.
ํด๋น ์์ฑ์ ์ด๋ฆ์ ์ธํฐํ์ด์ค์ ์๋ณ์์ด๋ฉฐ,
๊ทธ ๊ฐ์ ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ผ๊ณ
ํ๋ ๊ฐ์ฒด์
๋๋ค.
์ธํฐํ์ด์ค ๊ฐ์ฒด์ ํน์ฑ์ ยง 3.7.1 ์ธํฐํ์ด์ค
๊ฐ์ฒด์ ์ค๋ช
๋์ด ์์ต๋๋ค.
[LegacyWindowAlias]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ๋
ธ์ถ๋ ์ธํฐํ์ด์ค์ ์ง์ ๋์ด ์์ผ๋ฉด,
[LegacyWindowAlias]์ ๊ฐ ์๋ณ์๋ค์ ํฌํจ๋ ๊ฐ ์๋ณ์์ ๋ํด,
Window
๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ๋์ํ๋ ํ๋กํผํฐ๊ฐ ์กด์ฌํฉ๋๋ค.
ํ๋กํผํฐ ์ด๋ฆ์ ์ฃผ์ด์ง ์๋ณ์์ด๊ณ ,
๊ฐ์ ํด๋น ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค ๊ฐ์ฒด ์ฐธ์กฐ์
๋๋ค.
๋ํ, ๋
ธ์ถ๋ ์ธํฐํ์ด์ค์ [LegacyFactoryFunction]
ํ์ฅ ์ดํธ๋ฆฌ๋ทฐํธ๊ฐ ์๋ค๋ฉด,
์๋ฐ์คํฌ๋ฆฝํธ ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ๋์ํ๋ ํ๋กํผํฐ๊ฐ ์กด์ฌํฉ๋๋ค.
ํ๋กํผํฐ ์ด๋ฆ์ [LegacyFactoryFunction]์ ์๋ณ์์ด๊ณ ,
๊ฐ์ ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์(legacy factory function)์ด๋ฉฐ,
ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ฅผ ์์ฑํ ์ ์๋๋ก ํฉ๋๋ค.
๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์ ํน์ฑ์ ยงโฏ3.7.2 ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์์์ ์ค๋ช
ํฉ๋๋ค.
jsValue๋ฅผ interface ์ธํฐํ์ด์ค์ ๋ํด, name ์๋ณ์์ type ํ์ ์ผ๋ก ๊ตฌํ ๊ฐ์ฒด ์ฒดํฌ(implementation-check an object)ํ๋ ์ ์ฐจ:
-
object๊ฐ ํ๋ซํผ ๊ฐ์ฒด(platform object)๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฌ(perform a security check)๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ํํ๋ค:
-
ํ๋ซํผ ๊ฐ์ฒด object
-
์๋ณ์ name
-
ํ์ type
-
-
object๊ฐ interface๋ฅผ ๊ตฌํ(implement)ํ์ง ์์ผ๋ฉด throw
TypeError๋ฅผ ๋ฐ์์ํจ๋ค. -
object๋ฅผ ๋ฐํํ๋ค.
์ด ์๊ณ ๋ฆฌ์ฆ์ ์์ง ๋ชจ๋ ๊ณณ์์ ์ผ๊ด๋๊ฒ ์ฌ์ฉ๋๊ณ ์์ง ์์ต๋๋ค.
3.7.1. ์ธํฐํ์ด์ค ๊ฐ์ฒด
์ฃผ์ด์ง ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ ์ธํฐํ์ด์ค์ ๋ํ ๋ด์ฅ ํจ์ ๊ฐ์ฒด(built-in function object)์ ๋๋ค. ํด๋น ๊ฐ์ฒด๋ ์์ ๋ฐ static ์ฐ์ฐ์ ๋์ํ๋ ํ๋กํผํฐ๋ฅผ ๊ฐ์ง๋ฉฐ, ์ด์ ๋ํ ์์ธํ ๋ด์ฉ์ ยงโฏ3.7.5 ์์์ ยงโฏ3.7.7 ์ฐ์ฐ์์ ์ค๋ช ํฉ๋๋ค.
ํด๋น ์ธํฐํ์ด์ค๊ฐ ์์ฑ์ ์ฐ์ฐ(constructor operation)์ผ๋ก ์ ์ธ๋ ๊ฒฝ์ฐ, ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ฅผ ์์ฑ์(constructor)๋ก ํธ์ถํ์ฌ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ฅผ ์์ฑํ ์ ์์ต๋๋ค. ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ฅผ ํจ์๋ก ํธ์ถํ๋ฉด ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ธํฐํ์ด์ค ๊ฐ์ฒด์ ์ธํฐํ์ด์ค๊ฐ ์์ฑ์ ์ฐ์ฐ์ผ๋ก ์ ์ธ๋์ง ์์ ๊ฒฝ์ฐ, ํจ์๋ก ํธ์ถํ๊ฑฐ๋ ์์ฑ์๋ก ํธ์ถํ๋ฉด ์์ธ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ธํฐํ์ด์ค ๊ฐ์ฒด๋ ์ธํฐํ์ด์ค์ ๋ํ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ผ๋ ์ฐ๊ด ๊ฐ์ฒด๋ฅผ ๊ฐ์ง๋๋ค. ์ด ๊ฐ์ฒด๋ ์ธํฐํ์ด์ค์ ์ ์๋ ์ ๊ท attribute ๋ฐ ์ ๊ท ์ฐ์ฐ์ ๋์ํ๋ ํ๋กํผํฐ๋ฅผ ๊ฐ์ง๋ฉฐ, ยงโฏ3.7.3 ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด์์ ์์ธํ ์ค๋ช ํฉ๋๋ค.
์ฐธ๊ณ : ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ ํจ์
๊ฐ์ฒด(function object)์ด๋ฏ๋ก,
typeof ์ฐ์ฐ์๋ฅผ ์ ์ฉํ๋ฉด "function"์ ๋ฐํํฉ๋๋ค.
์ธํฐํ์ด์ค๋ ์์ฑ์ ์ฌ์ ์ ๋จ๊ณ(overridden constructor steps)๋ฅผ ๊ฐ์ง ์ ์์ผ๋ฉฐ, ์ธํฐํ์ด์ค ๊ฐ์ฒด๊ฐ ํธ์ถ๋๊ฑฐ๋ ์์ฑ๋ ๋ ๋์์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์ธํฐํ์ด์ค๋ ์ด๋ฌํ ๋จ๊ณ๋ฅผ ๊ฐ์ง ์์ต๋๋ค.
์ผ๋ฐ์ ์ผ๋ก ์์ฑ์๋ ์์ฑ์ ์ฐ์ฐ ๋ฐ ๊ทธ ๋์์ ์ ์ํ์ฌ ์ค๋ช ํฉ๋๋ค. ์์ฑ์ ์ฌ์ ์ ๋จ๊ณ๋ ๋ ๋ณต์กํ ์ํฉ์์๋ง ์ฌ์ฉํด์ผ ํฉ๋๋ค. ์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ ํธ์ง์๋ ์ด์๋ฅผ ๋ฑ๋กํ์ฌ ๋ ผ์ํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
์ฃผ์ด์ง ์ธํฐํ์ด์ค I์ ๋ํ ์ธํฐํ์ด์ค ๊ฐ์ฒด, id ์๋ณ์์ realm์์์ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ(create an interface object)๋๋ค:
-
steps๋ฅผ I์ ์ฌ์ ์๋ ์์ฑ์ ๋จ๊ณ๊ฐ ์กด์ฌํ๋ค๋ฉด ๊ทธ ๊ฐ์ผ๋ก, ๊ทธ๋ ์ง ์๋ค๋ฉด ๋ค์ ๋จ๊ณ๋ค๋ก ๋๋ค:
-
I๊ฐ ์์ฑ์ ์ฐ์ฐ์๋ก ์ ์ธ๋์ง ์์๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
NewTarget์ดundefined ๋ผ๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)TypeError. -
args๋ฅผ ์ ๋ฌ๋ฐ์ ์ธ์๋ค๋ก ๋๋ค.
-
n์ args์ ํฌ๊ธฐ๋ก ๋๋ค.
-
id๋ฅผ ์ธํฐํ์ด์ค I์ ์๋ณ์(identifier)๋ก ๋๋ค.
-
์์ฑ์์ ๋ํด ํจ๊ณผ์ ์ธ ์ค๋ฒ๋ก๋ ์งํฉ์ ๊ณ์ฐํ๋ผ. ์๋ณ์ id์ ์ธํฐํ์ด์ค I, ์ธ์ ๊ฐ์ n์ ์ด์ฉํ์ฌ ๊ณ์ฐํ๊ณ , ๊ฒฐ๊ณผ๋ฅผ S๋ก ๋๋ค.
-
<constructor, values>๋ฅผ ์ค๋ฒ๋ก๋ ํด๊ฒฐ ์๊ณ ๋ฆฌ์ฆ์ S์ args๋ฅผ ์ ๋ฌํ์ฌ ์ป์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
object๋ฅผ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ์ ๊ฐ์ฒด๋ฅผ ๋ด๋ถ์ ์ผ๋ก ์์ฑํ ๊ฒฐ๊ณผ๋ก ๋๋ค. I, realm, ๊ทธ๋ฆฌ๊ณ
NewTarget์ ์ธ์๋ก ์ฌ์ฉํ๋ค. -
constructor์ ์์ฑ์ ๋จ๊ณ๋ฅผ object๋ฅผ this๋ก, values๋ฅผ ์ธ์๊ฐ์ผ๋ก ํ์ฌ ์ํํ๋ค.
-
O๋ฅผ object๋ฅผ JavaScript ๊ฐ์ผ๋ก ๋ณํํ ๊ฐ์ผ๋ก ๋๋ค.
-
๋จ์ธ: O๋ I๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด๋ค.
-
๋จ์ธ: O.[[Realm]]์ realm์ด๋ค.
-
O๋ฅผ ๋ฐํํ๋ค.
-
-
constructorProto๋ฅผ realm.[[Intrinsics]].[[
%Function.prototype%]] ๊ฐ์ผ๋ก ๋๋ค. -
I๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค P๋ก๋ถํฐ ์์๋ฐ์๋ค๋ฉด, constructorProto๋ฅผ realm์์ P์ ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ก ์ค์ ํ๋ค.
-
unforgeables๋ฅผ OrdinaryObjectCreate(
null )์ ๊ฒฐ๊ณผ๋ก ๋๋ค. -
I์ ์์กฐ ๋ถ๊ฐ๋ฅํ ์ ๊ท ์ฐ์ฐ์ unforgeables์, realm์ ์ฐธ๊ณ ํ์ฌ ์ ์ํ๋ค.
-
I์ ์์กฐ ๋ถ๊ฐ๋ฅํ ์ ๊ท ์์ฑ์ unforgeables์, realm์ ์ฐธ๊ณ ํ์ฌ ์ ์ํ๋ค.
-
F.[[Unforgeables]]๋ฅผ unforgeables๋ก ์ค์ ํ๋ค.
์ฐธ๊ณ : ์ด ๊ฐ์ฒด๋ ์ฌ์ฉ์ ์ฝ๋์ ๋ ธ์ถ๋์ง ์๋๋ค. ์ด๋ ์ค์ง ์ธํฐํ์ด์ค์ ์์กฐ ๋ถ๊ฐ๋ฅํ ๋ฉค๋ฒ๋ฅผ ๊ฐ์ง ๋ชจ๋ ์ธ์คํด์ค๊ฐ ์์ฑ getter, ์์ฑ setter, ์ฐ์ฐ ํจ์์ ๋ํด ๋์ผํ JavaScript ํจ์ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋๋ก ํ๊ธฐ ์ํด ์กด์ฌํ๋ค.
-
length๋ฅผ 0์ผ๋ก ๋๋ค.
-
I๊ฐ ์์ฑ์ ์ฐ์ฐ์๋ก ์ ์ธ๋์๋ค๋ฉด,
-
์์ฑ์์ ๋ํด ํจ๊ณผ์ ์ธ ์ค๋ฒ๋ก๋ ์งํฉ์ ๊ณ์ฐํ๋ผ. ์๋ณ์ id, ์ธํฐํ์ด์ค I, ์ธ์ ๊ฐ์ 0์ ์ฌ์ฉํ๋ค. ๊ฒฐ๊ณผ๋ฅผ S๋ก ๋๋ค.
-
length๋ฅผ S์ ์ํธ๋ฆฌ๋ค ์ค ๊ฐ์ฅ ์งง์ ์ธ์ ๋ชฉ๋ก์ ๊ธธ์ด๋ก ์ค์ ํ๋ค.
-
-
F๋ฅผ CreateBuiltinFunction(steps, length, id, ยซ [[Unforgeables]] ยป, realm, constructorProto) ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
proto๋ฅผ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด ์์ฑ ๊ฒฐ๊ณผ๋ก ๋๋ค. ์ธํฐํ์ด์ค I์ realm์ ์ฌ์ฉํ๋ค.
-
! DefinePropertyOrThrow(F, "
prototype", PropertyDescriptor{[[Value]]: proto, [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:false })๋ฅผ ์ํํ๋ค. -
์์ ์ ์๋ฅผ ์ธํฐํ์ด์ค I์ F, realm์ ๋ํด ์ํํ๋ค.
-
์ ์ ์์ฑ ์ ์๋ฅผ ์ธํฐํ์ด์ค I, F, realm์ ๋ํด ์ํํ๋ค.
-
์ ์ ์ฐ์ฐ ์ ์๋ฅผ ์ธํฐํ์ด์ค I, F, realm์ ๋ํด ์ํํ๋ค.
-
F๋ฅผ ๋ฐํํ๋ค.
3.7.2. ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์
์ด๋ค ๋ ๊ฑฐ์
ํฉํฐ๋ฆฌ ํจ์๋ ํ๋ ์ด์์
[LegacyFactoryFunction]
ํ์ฅ
์์ฑ์ผ๋ก ์ธํด ์กด์ฌํ๋ฉฐ
์ฃผ์ด์ง ์๋ณ์๋ฅผ ๊ฐ์ง ๋ด์ฅ ํจ์ ๊ฐ์ฒด์
๋๋ค.
์ด๋ฅผ ํตํด ๊ฐ์ฒด๋ฅผ ์์ฑํ ์ ์์ผ๋ฉฐ, ํด๋น ๊ฐ์ฒด๋
๋ค์
[LegacyFactoryFunction]
ํ์ฅ ์์ฑ์ด ๋ํ๋๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํฉ๋๋ค.
๋ ๊ฑฐ์ ํฉํฐ๋ฆฌ ํจ์ ์ค ์๋ณ์๊ฐ id์ด๊ณ ์ฃผ์ด์ง ์ธํฐํ์ด์ค I์ ๋ํด Realm realm์ ์๋ ๊ฒ์ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ๋ฉ๋๋ค:
-
steps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ๋ก๋๋ค:
-
NewTarget๊ฐundefined ์ธ ๊ฒฝ์ฐ, ๋ฐ์์ํฌ ์์ธ๋TypeError์ ๋๋ค. -
args๋ฅผ ์ ๋ฌ๋ ์ธ์๋ก ๋ก๋๋ค.
-
n์ ํฌ๊ธฐ์ธ args์ ๊ฐ์ผ๋ก ๋ก๋๋ค.
-
์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ๊ณ์ฐํฉ๋๋ค. ๋ค์ ๋ ๊ฑฐ์ ํฉํฐ๋ฆฌ ํจ์์ ๋ํด ์๋ณ์ id๋ฅผ ๊ฐ์ง๋ฉฐ ์ธํฐํ์ด์ค I์ ์๊ณ ์ธ์ ์๊ฐ n์ธ ๊ฒฝ์ฐ์ ๋๋ค. ๊ทธ ๊ฒฐ๊ณผ๋ฅผ S๋ก ๋ก๋๋ค.
-
<constructor, values>๋ฅผ ๋ค์ ์ ๋ฌ์ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. S์ args๋ฅผ ์ค๋ฒ๋ก๋ ํด๊ฒฐ ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ฌํฉ๋๋ค.
-
object๋ฅผ ๋ด๋ถ์ ์ผ๋ก I๋ฅผ ๊ตฌํํ๋ ์ ๊ฐ์ฒด๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ๋ก๋๋ค. ์ด๋ realm๊ณผ
NewTarget์ ์ฌ์ฉํฉ๋๋ค. -
constructor์ ์์ฑ์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค. object๋ฅผ this๋ก, values๋ฅผ ์ธ์ ๊ฐ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
-
O๋ฅผ object๋ฅผ JavaScript ๊ฐ์ผ๋ก ๋ณํํ ๊ฒ์ผ๋ก ๋ก๋๋ค.
-
๋จ์ธ: O๋ ๊ตฌํ ๋์์ด I์ธ ๊ฐ์ฒด์ ๋๋ค.
-
๋จ์ธ: O.[[Realm]]์ realm์ ๋๋ค.
-
O๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
์ ํจ ์ค๋ฒ๋ก๋ ์งํฉ์ ๊ณ์ฐํฉ๋๋ค. ๋ค์ ๋ ๊ฑฐ์ ํฉํฐ๋ฆฌ ํจ์์ ๋ํด ์๋ณ์ id๋ฅผ ๊ฐ์ง๋ฉฐ ์ธํฐํ์ด์ค I์ ์๊ณ ์ธ์ ์๊ฐ 0์ธ ๊ฒฝ์ฐ์ ๋๋ค. ๊ทธ ๊ฒฐ๊ณผ๋ฅผ S๋ก ๋ก๋๋ค.
-
length๋ฅผ S์ ํญ๋ชฉ ์ค ๊ฐ์ฅ ์งง์ ์ธ์ ๋ชฉ๋ก์ ๊ธธ์ด๋ก ๋ก๋๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, length, id, ยซ ยป, realm)์ผ๋ก ๋ก๋๋ค.
-
proto๋ฅผ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ก ๋ก๋๋ค. ์ด ๊ฐ์ฒด๋ ์ธํฐํ์ด์ค I์ realm ๋ด ๊ฐ์ฒด์ ๋๋ค.
-
๋ค์์ ์ํํฉ๋๋ค: ! DefinePropertyOrThrow(F, "
prototype", PropertyDescriptor{[[Value]]: proto, [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:false }). -
F๋ฅผ ๋ฐํํฉ๋๋ค.
3.7.3. ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด
์ ์๋ ๋ชจ๋ ์ธํฐํ์ด์ค์๋
์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด๊ฐ ์กด์ฌํ๋ฉฐ,
์ธํฐํ์ด์ค๊ฐ
[LegacyNoInterfaceObject]
ํ์ฅ
์์ฑ์ผ๋ก ์ ์ธ๋์๋์ง ์ฌ๋ถ์ ๊ด๊ณ์์ต๋๋ค.
์ฃผ์ด์ง ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ ์ธํฐํ์ด์ค interface์ Realm realm์ ๋ํด ๋ค์๊ณผ ๊ฐ์ด ์์ฑ๋ฉ๋๋ค:
-
proto๋ฅผ null๋ก ๋ก๋๋ค.
-
interface๊ฐ [
Global] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์ด ์๊ณ , interface๊ฐ ๋ช ๋ช ๋ ์์ฑ์ ์ง์ํ๋ฉด, proto๋ฅผ interface์ realm์ ๋ํด ๋ช ๋ช ๋ ์์ฑ ๊ฐ์ฒด๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. -
๊ทธ๋ ์ง ์๊ณ , interface๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค์์ ์์ํ๋๋ก ์ ์ธ๋ ๊ฒฝ์ฐ, proto๋ฅผ realm์ ์๋ ํด๋น ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค. ์ด๋ ํด๋น ์์๋ ์ธํฐํ์ด์ค์ ๊ฒ์ ๋๋ค.
-
๊ทธ๋ ์ง ์๊ณ , interface๊ฐ
DOMException์ธํฐํ์ด์ค์ธ ๊ฒฝ์ฐ, proto๋ฅผ realm.[[Intrinsics]].[[%Error.prototype%]]๋ก ์ค์ ํฉ๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, proto๋ฅผ realm.[[Intrinsics]].[[
%Object.prototype%]]๋ก ์ค์ ํฉ๋๋ค. -
๋จ์ธ: proto๋ Object์ ๋๋ค.
-
interfaceProtoObj๋ฅผ null๋ก ๋ก๋๋ค.
-
realm์ ์ ์ญ ํ๋กํ ํ์ ์ฒด์ธ์ด ๋ณ๊ฒฝ ๊ฐ๋ฅํ์ง ์ฌ๋ถ๊ฐ true์ด๋ฉด:
-
interfaceProtoObj๋ฅผ OrdinaryObjectCreate(proto)๋ก ์ค์ ํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์๊ณ , interface๊ฐ [
Global] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์ด ์๊ฑฐ๋, interface๊ฐ [Global] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋ ์ธํฐํ์ด์ค์ ์์๋ ์ธํฐํ์ด์ค ์งํฉ์ ํฌํจ๋์ด ์๋ค๋ฉด:-
interfaceProtoObj๋ฅผ MakeBasicObject(ยซ [[Prototype]], [[Extensible]] ยป)๋ก ์ค์ ํฉ๋๋ค.
-
interfaceProtoObj.[[Prototype]]์ proto๋ก ์ค์ ํฉ๋๋ค.
-
๋ถ๋ณ ํ๋กํ ํ์ ํน์ ๊ฐ์ฒด์ ๊ณ ์ ํ interfaceProtoObj์ ๋ด๋ถ ๋ฉ์๋๋ฅผ ๋ค์์ ์ง์ ๋ ์ ์๋ก ์ค์ ํฉ๋๋ค: ECMA-262 ๋ถ๋ณ ํ๋กํ ํ์ ํน์ ๊ฐ์ฒด.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด, interfaceProtoObj๋ฅผ OrdinaryObjectCreate(proto)๋ก ์ค์ ํฉ๋๋ค.
-
interface์ [
Unscopable] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋ ๋ฉค๋ฒ๊ฐ ํ๋๋ผ๋ ์๋ค๋ฉด, ๋ค์์ ์ํํฉ๋๋ค:-
unscopableObject๋ฅผ OrdinaryObjectCreate(
null )๋ก ๋ก๋๋ค. -
interface์ [
Unscopable] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋ ๊ฐ ๋ ธ์ถ๋ ๋ฉค๋ฒ member์ ๋ํด:-
id๋ฅผ member์ ์๋ณ์๋ก ๋ก๋๋ค.
-
! CreateDataPropertyOrThrow(unscopableObject, id,
true )๋ฅผ ์ํํฉ๋๋ค.
-
-
desc๋ฅผ PropertyDescriptor{[[Value]]: unscopableObject, [[Writable]]:
false , [[Enumerable]]:false , [[Configurable]]:true }๋ก ๋ก๋๋ค. -
! DefinePropertyOrThrow(interfaceProtoObj,
%Symbol.unscopables%, desc)๋ฅผ ์ํํฉ๋๋ค.
-
-
interface๊ฐ [
Global] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์ง ์์๋ค๋ฉด:-
์ฃผ์ด์ง realm์ ๋ํด interfaceProtoObj์ interface์ ์ผ๋ฐ ์์ฑ์ ์ ์ํฉ๋๋ค.
-
์ฃผ์ด์ง realm์ ๋ํด interfaceProtoObj์ interface์ ์ผ๋ฐ ์ฐ์ฐ์ ์ ์ํฉ๋๋ค.
-
์ฃผ์ด์ง realm์ ๋ํด interfaceProtoObj์ interface์ ๋ฐ๋ณต ๋ฉ์๋๋ฅผ ์ ์ํฉ๋๋ค.
-
์ฃผ์ด์ง realm์ ๋ํด interfaceProtoObj์ interface์ ๋น๋๊ธฐ ๋ฐ๋ณต ๋ฉ์๋๋ฅผ ์ ์ํฉ๋๋ค.
-
-
์ฃผ์ด์ง realm์ ๋ํด interfaceProtoObj์ interface์ ์์๋ฅผ ์ ์ํฉ๋๋ค.
-
[
LegacyNoInterfaceObject] ํ์ฅ ์์ฑ์ด interface์ ์ง์ ๋์ง ์์๋ค๋ฉด:-
constructor๋ฅผ realm์ ์๋ interface์ ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ก ๋ก๋๋ค.
-
desc๋ฅผ PropertyDescriptor{[[Writable]]:
true , [[Enumerable]]:false , [[Configurable]]:true , [[Value]]: constructor}๋ก ๋ก๋๋ค. -
! DefinePropertyOrThrow(interfaceProtoObj, "
constructor", desc)๋ฅผ ์ํํฉ๋๋ค.
-
-
interfaceProtoObj๋ฅผ ๋ฐํํฉ๋๋ค.
๋ํ, ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ ๋ค์์์ ์ ์ธ์ ์ผ๋ก ์์ฑ์ ์ป์ต๋๋ค:
๋์ ์ด๋ฌํ ์์ฑ์ ๋ช ๋ นํ์ผ๋ก ์ ์ํฉ๋๋ค.
[LegacyNoInterfaceObject]
ํ์ฅ
์์ฑ์ผ๋ก
์ ์๋ ์ธํฐํ์ด์ค์
์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด๋
์ ๊ทผํ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ๋ค์ IDL์ด ์๋ ๊ฒฝ์ฐ:
[Exposed =Window ,LegacyNoInterfaceObject ]interface Foo { };partial interface Window {attribute Foo foo ; };
์ธํฐํ์ด์ค
๊ฐ์ฒด๋ฅผ ํตํด ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์ ์ ๊ทผํ ์๋ ์์ต๋๋ค.
(window.Foo๋ก ์กด์ฌํ์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค). ๊ทธ๋ฌ๋
Foo ์ธ์คํด์ค๋ [[GetPrototypeOf]]
๋ด๋ถ ๋ฉ์๋๋ฅผ ํธ์ถํ์ฌ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด๋ฅผ ๋
ธ์ถํ ์ ์์ต๋๋ค. ์ด ์์์๋
Object.getPrototypeOf(window.foo)์
๋๋ค.
์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด์ ํด๋์ค ๋ฌธ์์ด์ ์ธํฐํ์ด์ค์ ์ ๊ทํ๋ ์ด๋ฆ์ ๋๋ค.
3.7.4. ์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด
๋ค์๊ณผ ๊ฐ์ด ์ ์ธ๋ ๋ชจ๋ ์ธํฐํ์ด์ค์ ๋ํด
[Global]
ํ์ฅ
์์ฑ์ผ๋ก
์ ์ธ๋๊ณ ๋ช
๋ช
๋ ์์ฑ์ ์ง์ํ๋ ๊ฒฝ์ฐ,
ํด๋น ์ธํฐํ์ด์ค์๋ ๋ช
๋ช
๋
์์ฑ ๊ฐ์ฒด๋ผ๋ ๊ฐ์ฒด๊ฐ ์กด์ฌํ๋ฉฐ
์ด ๊ฐ์ฒด์์ ๋ช
๋ช
๋ ์์ฑ์ด ๋
ธ์ถ๋ฉ๋๋ค.
-
proto๋ฅผ null๋ก ํ๋ค.
-
interface๊ฐ ๋ค๋ฅธ ์ธํฐํ์ด์ค๋ฅผ ์์ํ๋ฉด, proto๋ฅผ ์์๋ ์ธํฐํ์ด์ค์ ๋ํ ํด๋น realm์์์ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ก ํ๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด proto๋ฅผ realm.[[Intrinsics]].[[
%Object.prototype%]]๋ก ํ๋ค. -
obj๋ฅผ MakeBasicObject(ยซ [[Prototype]], [[Extensible]] ยป)๋ก ํ๋ค.
-
obj.[[GetOwnProperty]]๋ฅผ ยงโฏ3.7.4.1 [[GetOwnProperty]]์ ๋ช ์๋ ๋๋ก ์ค์ ํ๋ค.
-
obj.[[DefineOwnProperty]]๋ฅผ ยงโฏ3.7.4.2 [[DefineOwnProperty]]์ ๋ช ์๋ ๋๋ก ์ค์ ํ๋ค.
-
obj.[[Delete]]๋ฅผ ยงโฏ3.7.4.3 [[Delete]]์ ๋ช ์๋ ๋๋ก ์ค์ ํ๋ค.
-
obj.[[SetPrototypeOf]]๋ฅผ ยงโฏ3.7.4.4 [[SetPrototypeOf]]์ ๋ช ์๋ ๋๋ก ์ค์ ํ๋ค.
-
obj.[[PreventExtensions]]๋ฅผ ยงโฏ3.7.4.5 [[PreventExtensions]]์ ๋ช ์๋ ๋๋ก ์ค์ ํ๋ค.
-
obj.[[Prototype]]์ proto๋ฅผ ์ค์ ํ๋ค.
-
obj๋ฅผ ๋ฐํํ๋ค.
์ฐธ๊ณ : ์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด์ [[OwnPropertyKeys]] ๋ด๋ถ ๋ฉ์๋๋ OrdinaryOwnPropertyKeys๋ฅผ ๊ณ์ ์ฌ์ฉํฉ๋๋ค. ์ด๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์ ๋ค๋ฆ ๋๋ค. ์ด๋ฆ์๋ ํ๋กํผํฐ๋ โ์ค์ โ own property๊ฐ ์๋๋ฏ๋ก ์ด ๋ด๋ถ ๋ฉ์๋์์๋ ๋ฐํ๋์ง ์์ต๋๋ค.
์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด์ ํด๋์ค ๋ฌธ์์ด(class string)์
์ธํฐํ์ด์ค์ ์๋ณ์์ ๋ฌธ์์ด "Properties"๋ฅผ ์ฐ๊ฒฐํ ๊ฐ์
๋๋ค.
3.7.4.1. [[GetOwnProperty]]
๋ช ๋ช ๋ ์์ฑ ๊ฐ์ฒด O์ [[GetOwnProperty]] ๋ด๋ถ ๋ฉ์๋๊ฐ ์์ฑ ํค P๋ก ํธ์ถ๋๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
A๋ฅผ ๋ช ๋ช ๋ ์์ฑ ๊ฐ์ฒด O์ ๋ํ ์ธํฐํ์ด์ค๋ก ๋ก๋๋ค.
-
object๋ฅผ O.[[Realm]]์ ์ ์ญ ๊ฐ์ฒด๋ก ๋ก๋๋ค.
-
๋จ์ธ: object๋ A๋ฅผ ๊ตฌํํฉ๋๋ค.
-
์์ฑ ์ด๋ฆ P์ ๊ฐ์ฒด object๋ฅผ ์ฌ์ฉํ์ฌ ๋ช ๋ช ๋ ์์ฑ ๊ฐ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ์คํํ ๊ฒฐ๊ณผ๊ฐ true์ด๋ฉด:
-
operation์ ๋ช ๋ช ๋ ์์ฑ getter๋ฅผ ์ ์ธํ๋ ๋ฐ ์ฌ์ฉ๋ ์ฐ์ฐ์ผ๋ก ๋ก๋๋ค.
-
value๋ฅผ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ๋ก๋๋ค.
-
operation์ด ์๋ณ์ ์์ด ์ ์๋์๋ค๋ฉด, value๋ฅผ ์ธํฐํ์ด์ค ์ค๋ช ์ ๋์ด๋ ๋จ๊ณ๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ์ฌ ๋ช ๋ช ๋ ์์ฑ์ ๊ฐ์ ๊ฒฐ์ ํฉ๋๋ค. ์ด๋ P๋ฅผ ์ด๋ฆ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, operation์ ์๋ณ์์ ํจ๊ป ์ ์๋์์ต๋๋ค. value๋ฅผ operation์ ์ค๋ช ์ ๋์ด๋ ๋จ๊ณ๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ฉฐ, P๋ฅผ ์ ์ผํ ์ธ์ ๊ฐ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
-
desc๋ฅผ ํ๋๊ฐ ์๋ ์๋ก ์์ฑ๋ ์์ฑ ์ค๋ช ์๋ก ๋ก๋๋ค.
-
desc.[[Value]]๋ฅผ value๋ฅผ JavaScript ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
A๊ฐ [
LegacyUnenumerableNamedProperties] ํ์ฅ ์์ฑ์ด ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ค๋ฉด, desc.[[Enumerable]]์false ๋ก ์ค์ ํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉดtrue ๋ก ์ค์ ํฉ๋๋ค. -
desc.[[Writable]]์
true ๋ก ์ค์ ํ๊ณ desc.[[Configurable]]์true ๋ก ์ค์ ํฉ๋๋ค. -
desc๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
OrdinaryGetOwnProperty(O, P)๋ฅผ ๋ฐํํฉ๋๋ค.
3.7.4.2. [[DefineOwnProperty]]
์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด์ [[DefineOwnProperty]] ๋ด๋ถ ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋, ๋ค์ ๋จ๊ณ๊ฐ ์ํ๋ฉ๋๋ค:
-
false ๋ฅผ ๋ฐํํ๋ค.
3.7.4.3. [[Delete]]
์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด์ [[Delete]] ๋ด๋ถ ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋, ๋ค์ ๋จ๊ณ๊ฐ ์ํ๋ฉ๋๋ค:
-
false ๋ฅผ ๋ฐํํ๋ค.
3.7.4.4. [[SetPrototypeOf]]
์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด O์ [[SetPrototypeOf]] ๋ด๋ถ ๋ฉ์๋๊ฐ JavaScript ๊ฐ V๋ก ํธ์ถ๋ ๋, ๋ค์ ๋จ๊ณ๊ฐ ์ํ๋๋ค:
-
๋ง์ฝ O์ ์ฐ๊ด realm์ ๊ธ๋ก๋ฒ ํ๋กํ ํ์ ์ฒด์ธ์ด mutable๋ผ๋ฉด, ? OrdinarySetPrototypeOf(O, V)๋ฅผ ๋ฐํํ๋ค.
-
? SetImmutablePrototype(O, V)๋ฅผ ๋ฐํํ๋ค.
3.7.4.5. [[PreventExtensions]]
์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด์ [[PreventExtensions]] ๋ด๋ถ ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋, ๋ค์ ๋จ๊ณ๊ฐ ์ํ๋๋ค:
-
false ๋ฅผ ๋ฐํํ๋ค.
์ฐธ๊ณ : ์ด๋ ๊ฒ ํ๋ฉด [[PreventExtensions]]๊ฐ ์คํจํ๋ฉด์ ์ด๋ฆ์๋ ํ๋กํผํฐ ๊ฐ์ฒด๊ฐ ํ์ฅ ๊ฐ๋ฅ(extensible)ํ๊ฒ ์ ์ง๋ฉ๋๋ค.
3.7.5. ์์
์์๋ ์ธํฐํ์ด์ค
๊ฐ์ฒด,
๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด,
์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด ๋ฐ
์ธํฐํ์ด์ค๊ฐ [Global] ํ์ฅ
์์ฑ์ผ๋ก ์ ์ธ๋ ๊ฒฝ์ฐ,
ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๋จ์ผ ๊ฐ์ฒด์ ๋
ธ์ถ๋ฉ๋๋ค.
-
๊ฐ๊ฐ์ ์์ const์ ๋ํด, ๋ฉค๋ฒ๊ฐ definition์ ์ํ ๊ฒฝ์ฐ:
-
const๊ฐ realm์์ ๋ ธ์ถ๋์ง ์์๋ค๋ฉด, ๊ณ์ํฉ๋๋ค.
-
value๋ฅผ IDL ๊ฐ์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
desc๋ฅผ PropertyDescriptor{[[Writable]]:
false , [[Enumerable]]:true , [[Configurable]]:false , [[Value]]: value}๋ก ์ค์ ํฉ๋๋ค. -
id๋ฅผ const์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
! DefinePropertyOrThrow(target, id, desc)๋ฅผ ์ํํฉ๋๋ค.
-
3.7.6. ์์ฑ
์ ์
์์ฑ์ ๋ค์์ ๋
ธ์ถ๋ฉ๋๋ค ์ธํฐํ์ด์ค ๊ฐ์ฒด.
์ผ๋ฐ
์์ฑ์ ๋ค์์ ๋
ธ์ถ๋ฉ๋๋ค ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด,
์์ฑ์ด ์์กฐ ๋ถ๊ฐ๋ฅํ๊ฑฐ๋
์ธํฐํ์ด์ค๊ฐ [Global] ํ์ฅ
์์ฑ์ผ๋ก ์ ์ธ๋ ๊ฒฝ์ฐ๋ฅผ ์ ์ธํ๋ฉฐ,
์ด ๊ฒฝ์ฐ ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๋ชจ๋ ๊ฐ์ฒด์ ๋
ธ์ถ๋ฉ๋๋ค.
-
attributes๋ฅผ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค. ์ด ๋ชฉ๋ก์ ์ผ๋ฐ ์์ฑ ์ค definition์ ๋ฉค๋ฒ์ธ ๊ฒ๋ค์ ๋๋ค.
-
์ ๊ฑฐํฉ๋๋ค. attributes์์ ์์ฑ ์ค ์์กฐ ๋ถ๊ฐ์ธ ๊ฒ์ ๋ชจ๋ ์ ๊ฑฐํฉ๋๋ค.
-
์์ฑ ์ ์ํ๊ธฐ: attributes๋ฅผ definition์ ์์ฑ์ผ๋ก target์ realm์ ์ฌ์ฉํด ์ ์ํฉ๋๋ค.
-
attributes๋ฅผ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค. ์ด ๋ชฉ๋ก์ ์ ์ ์์ฑ ์ค ๋ฉค๋ฒ์ธ ๊ฒ๋ค์ ๋๋ค.
-
์์ฑ ์ ์ํ๊ธฐ: attributes๋ฅผ definition์ ์์ฑ์ผ๋ก target์ realm์ ์ฌ์ฉํด ์ ์ํฉ๋๋ค.
-
attributes๋ฅผ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค. ์ด ๋ชฉ๋ก์ ์์กฐ ๋ถ๊ฐ ์ผ๋ฐ ์์ฑ ์ค ๋ฉค๋ฒ์ธ ๊ฒ๋ค์ ๋๋ค.
-
์์ฑ ์ ์ํ๊ธฐ: attributes๋ฅผ definition์ ์์ฑ์ผ๋ก target์ realm์ ์ฌ์ฉํด ์ ์ํฉ๋๋ค.
-
๊ฐ๊ฐ์ ์์ฑ attr์ ๋ํด attributes์์:
-
๋ง์ฝ attr๊ฐ realm์์ ๋ ธ์ถ๋์ง ์์๋ค๋ฉด, continueํฉ๋๋ค.
-
getter๋ฅผ ์์ฑ getter๋ฅผ ์์ฑํด์ attr, definition, realm์ ์ธ์๋ก ํ์ฌ ์ค์ ํฉ๋๋ค.
-
setter๋ฅผ ์์ฑ setter๋ฅผ ์์ฑํด์ attr, definition, realm์ ์ธ์๋ก ํ์ฌ ์ค์ ํฉ๋๋ค.
์ฐธ๊ณ : ์์ฑ setter ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ attr๊ฐ ์ฝ๊ธฐ ์ ์ฉ์ผ ๊ฒฝ์ฐ
undefined ๋ฅผ ๋ฐํํฉ๋๋ค. -
configurable๋ฅผ attr๊ฐ ์์กฐ ๋ถ๊ฐ์ด๋ฉด
false ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดtrue ๋ก ์ค์ ํฉ๋๋ค. -
desc๋ฅผ PropertyDescriptor{[[Getter]]: getter, [[Setter]]: setter, [[Enumerable]]:
true , [[Configurable]]: configurable}๋ก ์ค์ ํฉ๋๋ค. -
id๋ฅผ attr์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
! DefinePropertyOrThrow(target, id, desc)๋ฅผ ์ํํฉ๋๋ค.
-
๋ง์ฝ attr์ ํ์ ์ด observable array type์ด๊ณ ํ์ ์ธ์๊ฐ T๋ผ๋ฉด, target์ backing observable array exotic object๋ฅผ observable array exotic object ์์ฑํ๊ธฐ์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ์ธ์๋ realm, T, attr์ ์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ, ์ธ๋ฑ์ค ๊ฐ ์ญ์ ์๊ณ ๋ฆฌ์ฆ์ ๋๋ค.
-
์์ฑ getter๋ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ๋ฉ๋๋ค. ์์ฑ attribute, ๋ค์์คํ์ด์ค ๋๋ ์ธํฐํ์ด์ค target, realm realm์ ์ธ์๋ก ํฉ๋๋ค:
-
steps๋ฅผ ๋ค์ ๋จ๊ณ๋ค์ ์ฐ์์ผ๋ก ๋๋ค:
-
๋ค์ ๋จ๊ณ๋ค์ ์๋ํ๋ค:
-
idlObject๋ฅผ null๋ก ๋๋ค.
-
target์ด ์ธํฐํ์ด์ค์ด๊ณ , attribute๊ฐ ์ผ๋ฐ ์์ฑ์ด๋ผ๋ฉด:
-
jsValue๋ฅผ
this ๊ฐ(๋จ,null ๋๋undefined ๊ฐ ์๋๋ผ๋ฉด) ์๋๋ฉด realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ก ๋๋ค. (์ดํ ๋จ๊ณ์์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๊ฐ target์ ๊ตฌํํ์ง ์๊ณ [LegacyLenientThis] ๊ฐ ์ง์ ๋์ง ์์๋ค๋ฉดTypeError๊ฐ ๋ฐ์ํ๋ค.) -
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, attribute์ ์๋ณ์, "getter"๋ฅผ ์ ๋ฌํ๋ค.
-
jsValue๊ฐ target์ ๊ตฌํํ์ง ์๋๋ค๋ฉด:
-
attribute์ [
LegacyLenientThis] ํ์ฅ ์์ฑ์ด ์ง์ ๋์ด ์์ผ๋ฉดundefined ๋ฅผ ๋ฐํํ๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError.
-
-
attribute์ ํ์ ์ด observable array ํ์ ๋ผ๋ฉด, jsValue์ backing observable array exotic object๋ฅผ attribute์ ๋ํด ๋ฐํํ๋ค.
-
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ์ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
-
R์ attribute์ getter ๋จ๊ณ๋ฅผ idlObject๋ฅผ this๋ก ํ์ฌ ์คํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
๋ณํ(converting) ๊ฒฐ๊ณผ์ธ R์ attribute์ ์ ์ธ๋ ํ์ ์ JavaScript ๊ฐ์ผ๋ก ๋ฐํํ๋ค.
-
๊ทธ๋ฆฌ๊ณ ์์ธ E๊ฐ ๋ฐ์ํ๋ค๋ฉด:
-
attribute์ ํ์ ์ด promise ํ์ ์ด๋ฉด, ! Call(
%Promise.reject%,%Promise%, ยซEยป)๋ฅผ ๋ฐํํ๋ค. -
๊ทธ ์ธ์๋, ์ด ๋จ๊ณ๋ค์ ์ข ๋ฃํ๊ณ ์์ธ๊ฐ ์ ํ๋๋๋ก ํ๋ค.
-
-
name์ "
get" ๋ฌธ์์ด์ attribute์ ์๋ณ์ ์์ ๋ถ์ธ ๊ฐ์ผ๋ก ๋๋ค. -
F๋ฅผ CreateBuiltinFunction(steps, 0, name, ยซ ยป, realm)์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
F๋ฅผ ๋ฐํํ๋ค.
์์ฑ setter ๋ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ๋ฉ๋๋ค. ์์ฑ attribute, ๋ค์์คํ์ด์ค ๋๋ ์ธํฐํ์ด์ค target, ๊ทธ๋ฆฌ๊ณ realm realm์ด ์ฃผ์ด์ก์ ๋:
-
๋ง์ฝ target์ด ๋ค์์คํ์ด์ค๋ผ๋ฉด:
-
๋จ์ธ: attribute๋ ์ฝ๊ธฐ ์ ์ฉ์ด๋ค.
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
-
๋ง์ฝ attribute๊ฐ ์ฝ๊ธฐ ์ ์ฉ์ด๊ณ [
LegacyLenientSetter], [PutForwards] ๋๋ [Replaceable] ํ์ฅ ์์ฑ์ด ์ง์ ๋์ง ์์๋ค๋ฉดundefined ๋ฅผ ๋ฐํํ๋ค. ์์ฑ setter ํจ์๊ฐ ์กด์ฌํ์ง ์๋๋ค. -
๋จ์ธ: attribute์ ํ์ ์ promise ํ์ ์ด ์๋๋ค.
-
steps๋ฅผ ๋ค์ ๋จ๊ณ๋ค์ ์ฐ์์ผ๋ก ๋๋ค:
-
V๋ฅผ
undefined ๋ก ๋๋ค. -
๋ง์ฝ ์ธ์๊ฐ ์ ๋ฌ๋์๋ค๋ฉด, V๋ฅผ ์ฒซ ๋ฒ์งธ ์ ๋ฌ๋ ์ธ์์ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
id๋ฅผ attribute์ ์๋ณ์๋ก ๋๋ค.
-
idlObject๋ฅผ null๋ก ๋๋ค.
-
attribute๊ฐ ์ผ๋ฐ ์์ฑ์ด๋ฉด:
-
jsValue๋ฅผ
this ๊ฐ(๋จ,null ๋๋undefined ๊ฐ ์๋๋ผ๋ฉด) ์๋๋ฉด realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ก ๋๋ค. (์ดํ ๋จ๊ณ์์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๊ฐ target์ ๊ตฌํํ์ง ์๊ณ [LegacyLenientThis] ๊ฐ ์ง์ ๋์ง ์์๋ค๋ฉดTypeError๊ฐ ๋ฐ์ํ๋ค.) -
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, id, "setter"๋ฅผ ์ ๋ฌํ๋ค.
-
validThis๋ฅผ jsValue๊ฐ target์ ๊ตฌํํ๋ฉด true, ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ก ๋๋ค.
-
validThis๊ฐ false์ด๊ณ attribute์ [
LegacyLenientThis] ํ์ฅ ์์ฑ์ด ์ง์ ๋์ด ์์ง ์๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)TypeError. -
attribute๊ฐ [
Replaceable] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด:-
? CreateDataPropertyOrThrow(jsValue, id, V).
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
-
validThis๊ฐ false์ด๋ฉด
undefined ๋ฅผ ๋ฐํํ๋ค. -
attribute๊ฐ [
LegacyLenientSetter] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,undefined ๋ฅผ ๋ฐํํ๋ค. -
attribute๊ฐ [
PutForwards] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด:-
Q๊ฐ Object๊ฐ ์๋๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
forwardId๋ฅผ [
PutForwards] ํ์ฅ ์์ฑ์ ์๋ณ์ ์ธ์๋ก ๋๋ค. -
undefined ๋ฅผ ๋ฐํํ๋ค.
-
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
attribute์ ํ์ ์ด ํ์ ์ธ์ T๋ฅผ ๊ฐ์ง observable array ํ์ ์ด๋ฉด:
-
newValues๋ฅผ ๋ณํ(converting)ํ, V๋ฅผ sequence<T> ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
oa๋ฅผ idlObject์ attribute์ ํด๋นํ๋ backing observable array exotic object๋ก ๋๋ค.
-
Set the length๋ฅผ oa.[[ProxyHandler]]์ ๋ํด 0์ผ๋ก ์ํํ๋ค.
-
i๋ฅผ 0์ผ๋ก ๋๋ค.
-
i < newValues์ ํฌ๊ธฐ์ธ ๋์:
-
oa.[[ProxyHandler]].[[SetAlgorithm]]์ด ์ ๊ณตํ๋ ์๊ณ ๋ฆฌ์ฆ ๋จ๊ณ๋ฅผ newValues[i]์ i๋ฅผ ์ธ์๋ก ํ์ฌ ์ํํ๋ค.
-
Append newValues[i]๋ฅผ oa.[[ProxyHandler]].[[BackingList]]์ ์ถ๊ฐํ๋ค.
-
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
-
-
idlValue๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ํ๋ค:
- attribute์ ํ์ ์ด ์ด๊ฑฐํ์ธ ๊ฒฝ์ฐ
-
-
S๊ฐ ์ด๊ฑฐํ ๊ฐ๋ค ์ค ํ๋๊ฐ ์๋๋ฉด
undefined ๋ฅผ ๋ฐํํ๋ค. -
๊ทธ ์ธ์๋, idlValue๋ฅผ S์ ๋์ผํ ์ด๊ฑฐํ ๊ฐ์ผ๋ก ๋๋ค.
- ๊ทธ ์ธ
- idlValue๋ฅผ ๋ณํ(converting)ํ V๋ฅผ attribute์ ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
setter ๋จ๊ณ๋ฅผ attribute์ ๋ํด, idlObject๋ฅผ this, idlValue๋ฅผ ์ฃผ์ด์ง ๊ฐ์ผ๋ก ํ์ฌ ์ํํ๋ค.
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
-
name์ "
set" ๋ฌธ์์ด์ id ์์ ๋ถ์ธ ๊ฐ์ผ๋ก ๋๋ค. -
F๋ฅผ CreateBuiltinFunction(steps, 1, name, ยซ ยป, realm)์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
F๋ฅผ ๋ฐํํ๋ค.
์ฐธ๊ณ : IDL ์์ฑ์๋ ๋จ์ผ ํ๋กํผํฐ๋ง ์์ง๋ง, ์ ๊ทผ์ ํ๋กํผํฐ getter์ setter๋ ํด๋น IDL ์์ฑ์ ๋์ํ๋ ํ๋กํผํฐ๊ฐ ์ ๊ทผ๋ ๊ฐ์ฒด์ this ๊ฐ์ ์ ๋ฌ๋ฐ์ผ๋ฏ๋ก ์ธ์คํด์ค๋ณ ๋ฐ์ดํฐ๋ฅผ ๋ ธ์ถํ ์ ์์ต๋๋ค.
์ฐธ๊ณ : ์ฝ๊ธฐ ์ ์ฉ ์์ฑ
์ ๋์ํ๋ ํ๋กํผํฐ์ ๊ฐ์ ํ ๋นํ๋ ค๊ณ ํ๋ฉด, ์คํฌ๋ฆฝํธ๊ฐ ์๊ฒฉ ๋ชจ๋(strict mode)์ธ์ง์ ๋ฐ๋ผ ๋์์ด ๋ฌ๋ผ์ง๋๋ค.
์๊ฒฉ ๋ชจ๋์์๋ ํด๋น ํ ๋น์ด TypeError
๋ฅผ ๋ฐ์์ํค๊ณ , ์๊ฒฉ ๋ชจ๋๊ฐ ์๋๋ฉด ํ ๋น ์๋๊ฐ ๋ฌด์๋ฉ๋๋ค.
3.7.7. ์ฐ์ฐ(Operations)
๊ฐ ์ธํฐํ์ด์ค์์ ์ ์๋,
๋
ธ์ถ๋ ์ฐ์ฐ์ ๊ณ ์ ํ ์๋ณ์๋ง๋ค
ํด๋นํ๋ ํ๋กํผํฐ๊ฐ ์กด์ฌํฉ๋๋ค.
์ ์ ์ฐ์ฐ์ ์ธํฐํ์ด์ค ๊ฐ์ฒด์
๋
ธ์ถ๋ฉ๋๋ค.
์ผ๋ฐ ์ฐ์ฐ์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์ ๋
ธ์ถ๋ฉ๋๋ค.
๋จ, ์ฐ์ฐ์ด ์์กฐ ๋ถ๊ฐ์ด๊ฑฐ๋,
์ธํฐํ์ด์ค๊ฐ [Global] ํ์ฅ ์์ฑ์ผ๋ก
์ ์ธ๋ ๊ฒฝ์ฐ์๋,
ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๋ชจ๋ ๊ฐ์ฒด์ ๋
ธ์ถ๋ฉ๋๋ค.
-
operations๋ฅผ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค. ์ด ๋ชฉ๋ก์ ์ผ๋ฐ ์ฐ์ฐ ์ค ๋ฉค๋ฒ์ธ ๊ฒ๋ค์ ๋๋ค.
-
์ ๊ฑฐํฉ๋๋ค. operations์์ ์ฐ์ฐ ์ค ์์กฐ ๋ถ๊ฐ์ธ ๊ฒ๋ค์ ๋ชจ๋ ์ ๊ฑฐํฉ๋๋ค.
-
์ฐ์ฐ ์ ์ํ๊ธฐ: operations๋ฅผ definition์ ์ฐ์ฐ์ผ๋ก target์ realm์ ์ฌ์ฉํด ์ ์ํฉ๋๋ค.
-
operations๋ฅผ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค. ์ด ๋ชฉ๋ก์ ์ ์ ์ฐ์ฐ ์ค ๋ฉค๋ฒ์ธ ๊ฒ๋ค์ ๋๋ค.
-
์ฐ์ฐ ์ ์ํ๊ธฐ: operations๋ฅผ definition์ ์ฐ์ฐ์ผ๋ก target์ realm์ ์ฌ์ฉํด ์ ์ํฉ๋๋ค.
-
operations๋ฅผ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค. ์ด ๋ชฉ๋ก์ ์์กฐ ๋ถ๊ฐ ์ผ๋ฐ ์ฐ์ฐ ์ค ๋ฉค๋ฒ์ธ ๊ฒ๋ค์ ๋๋ค.
-
์ฐ์ฐ ์ ์ํ๊ธฐ: operations๋ฅผ definition์ ์ฐ์ฐ์ผ๋ก target์ realm์ ์ฌ์ฉํด ์ ์ํฉ๋๋ค.
-
๊ฐ๊ฐ์ ์ฐ์ฐ op์ ๋ํด operations์์:
-
๋ง์ฝ op๊ฐ realm์์ ๋ ธ์ถ๋์ง ์์๋ค๋ฉด, continueํฉ๋๋ค.
-
method๋ฅผ ์ฐ์ฐ ํจ์ ์์ฑํ๊ธฐ์ ๊ฒฐ๊ณผ๋ก op, definition, realm์ ์ธ์๋ก ํ์ฌ ์ค์ ํฉ๋๋ค.
-
modifiable๋ฅผ op๊ฐ ์์กฐ ๋ถ๊ฐ์ด๋ฉด
false ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดtrue ๋ก ์ค์ ํฉ๋๋ค. -
desc๋ฅผ PropertyDescriptor{[[Value]]: method, [[Writable]]: modifiable, [[Enumerable]]:
true , [[Configurable]]: modifiable}๋ก ์ค์ ํฉ๋๋ค. -
id๋ฅผ op์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
! DefinePropertyOrThrow(target, id, desc)๋ฅผ ์ํํฉ๋๋ค.
-
-
id๋ฅผ op์ ์๋ณ์๋ก ๋๋ค.
-
args๋ฅผ ํจ์ ์ธ์๊ฐ์ผ๋ก ๋ฐ์์ ๋ steps๋ฅผ ๋ค์ ๋จ๊ณ์ ์ฐ์์ผ๋ก ๋๋ค:
-
๋ค์ ๋จ๊ณ๋ค์ ์๋ํ๋ค:
-
idlObject๋ฅผ null๋ก ๋๋ค.
-
target์ด ์ธํฐํ์ด์ค์ด๊ณ , op๊ฐ ์ ์ ์ฐ์ฐ์ด ์๋๋ผ๋ฉด:
-
jsValue๊ฐ
this ๊ฐ์ด๋ผ๋ฉด, ์ด ๊ฐ์ดnull ๋๋undefined ๊ฐ ์๋๋ผ๋ฉด ๊ทธ๋๋ก ๋๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ก ํ๋ค. (์ดํ ๋ช ๋จ๊ณ์์, ๊ธ๋ก๋ฒ ๊ฐ์ฒด๊ฐ target์ ๊ตฌํํ์ง ์์ผ๋ฉดTypeError๊ฐ ๋ฐ์ํ๋ค.) -
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฌ๋ฅผ ์ํํ๋ค. jsValue, id, "method"๋ฅผ ์ ๋ฌํ๋ค.
-
jsValue๊ฐ target ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
-
n์ args์ ํฌ๊ธฐ๋ก ๋๋ค.
-
์ค๋ฒ๋ก๋ ์งํฉ์ ๊ณ์ฐํ๋ค. ์ ๊ท ์ฐ์ฐ(op์ด ์ ๊ท ์ฐ์ฐ์ธ ๊ฒฝ์ฐ) ๋๋ ์ ์ ์ฐ์ฐ(op์ด ์ ์ ์ฐ์ฐ์ธ ๊ฒฝ์ฐ)์ ๋ํด, ์๋ณ์ id์ target ๋ฐ ์ธ์ ๊ฐ์ n๋ฅผ ์ฌ์ฉํ๋ฉฐ, ๊ฒฐ๊ณผ๋ฅผ S๋ก ๋๋ค.
-
<operation, values>๋ฅผ S์ args๋ฅผ ์ค๋ฒ๋ก๋ ๊ฒฐ์ ์๊ณ ๋ฆฌ์ฆ์ ์ ๋ฌํ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
R์
null ๋ก ๋๋ค. -
operation์ด [
Default] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด:-
๋จ์ธ: operation์ default ๋ฉ์๋ ๋จ๊ณ๋ฅผ ๊ฐ์ง๋ค.
-
R์ operation์ default ๋ฉ์๋ ๋จ๊ณ๋ฅผ idlObject๋ฅผ this, values๋ฅผ ์ธ์๊ฐ์ผ๋ก ํ์ฌ ์ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, operation์ ๋ฉ์๋ ๋จ๊ณ๋ฅผ idlObject๋ฅผ this, values๋ฅผ ์ธ์๊ฐ์ผ๋ก ํ์ฌ ์ํํ ๊ฒฐ๊ณผ๋ฅผ R๋ก ์ค์ ํ๋ค.
-
R์ JavaScript ๊ฐ์ผ๋ก ๋ณํํ์ฌ ๋ฐํํ๋ค.
R์ op์ด ๋ฐํ ํ์ ์ผ๋ก ์ ์ธํ IDL ๊ฐ์์ ๊ฐ์ ํ๋ค. [whatwg/webidl Issue #674]
-
๊ทธ๋ฆฌ๊ณ ์์ธ E๊ฐ ๋ฐ์ํ๋ค๋ฉด:
-
op์ ๋ฐํ ํ์ ์ด promise ํ์ ์ธ ๊ฒฝ์ฐ, ! Call(
%Promise.reject%,%Promise%, ยซEยป)๋ฅผ ๋ฐํํ๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ, ์ด ๋จ๊ณ๋ค์ ์ข ๋ฃํ๊ณ ์์ธ๊ฐ ์ ํ๋๋๋ก ํ๋ค.
-
-
์ค๋ฒ๋ก๋ ์งํฉ์ ๊ณ์ฐํ๋ค. ์ ๊ท ์ฐ์ฐ(op์ด ์ ๊ท ์ฐ์ฐ์ธ ๊ฒฝ์ฐ) ๋๋ ์ ์ ์ฐ์ฐ(op์ด ์ ์ ์ฐ์ฐ์ธ ๊ฒฝ์ฐ)์ ๋ํด ์๋ณ์ id, target, ์ธ์ ๊ฐ์ 0์ ์ฌ์ฉํ๊ณ ๊ฒฐ๊ณผ๋ฅผ S๋ก ๋๋ค.
-
length๋ฅผ S์ ์ํธ๋ฆฌ๋ค ์ค ๊ฐ์ฅ ์งง์ ์ธ์ ๋ชฉ๋ก์ ๊ธธ์ด๋ก ๋๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, length, id, ยซ ยป, realm)์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
F๋ฅผ ๋ฐํํ๋ค.
3.7.7.1. ๊ธฐ๋ณธ ์ฐ์ฐ
์ผ๋ฐ ์ฐ์ฐ์ด ๊ธฐ๋ณธ ๋ฉ์๋ ๋จ๊ณ๋ฅผ ๊ฐ๋๋ค ๋ ๊ทธ ์๋ณ์๊ฐ ์๋ ํ์ ์ฒซ ๋ฒ์งธ ์ด์ ๋ฑ์ฅํ๋ ๊ฒฝ์ฐ๋ฅผ ๋งํฉ๋๋ค. ์ด ๊ฒฝ์ฐ, ๊ธฐ๋ณธ ๋ฉ์๋ ๋จ๊ณ๋ ํ ๋ ๋ฒ์งธ ์ด์์ ์ฐ๊ฒฐ๋ ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ผ ๊ฒฐ์ ๋๊ณ , ์ฐ์ฐ์ ํ ์ธ ๋ฒ์งธ ์ด์ ๋ช ์๋ ๋ฐํ ํ์ ์ ๊ฐ์ ธ์ผ ํฉ๋๋ค.
| ์๋ณ์ | ๊ธฐ๋ณธ ๋ฉ์๋ ๋จ๊ณ | ๋ฐํ ํ์ |
|---|---|---|
"toJSON" |
๊ธฐ๋ณธ toJSON ๋จ๊ณ | object
|
์ผ๋ฐ ์ฐ์ฐ์ด ๊ธฐ๋ณธ ๋ฉ์๋ ๋จ๊ณ๋ฅผ
๊ฐ์ง ์๋๋ค๋ฉด, [Default] ํ์ฅ ์์ฑ์ผ๋ก
์ ์ธํ๋ฉด ์ ๋ฉ๋๋ค.
3.7.7.1.1. ๊ธฐ๋ณธ toJSON ์ฐ์ฐ
๊ธฐ๋ณธ toJSON ๋จ๊ณ๋ ์ธํฐํ์ด์ค I์ ๋ํด ๋ค์๊ณผ ๊ฐ์ด ๋์ํฉ๋๋ค:
-
map์ ์๋ก์ด ์์๊ฐ ์๋ ๋งต์ผ๋ก ์ค์ ํฉ๋๋ค.
-
stack์ ์์ ์คํ ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ์ธํฐํ์ด์ค I์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
์์ ์คํ์ ์์ฑ ๊ฐ ์์ง ์๊ณ ๋ฆฌ์ฆ์ this, stack, map๊ณผ ํจ๊ป ์คํํฉ๋๋ค.
-
result๋ฅผ OrdinaryObjectCreate(
%Object.prototype%)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. -
๊ฐ key โ value์ ๋ํด map์์:
-
k๋ฅผ key ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
v๋ฅผ value ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
! CreateDataPropertyOrThrow(result, k, v)๋ฅผ ์คํํฉ๋๋ค.
-
-
result๋ฅผ ๋ฐํํฉ๋๋ค.
์์ ์คํ์ ์์ฑ ๊ฐ ์์ง ์๊ณ ๋ฆฌ์ฆ์, ํ๋ซํผ ๊ฐ์ฒด object, ์คํ stack, ์์๊ฐ ์๋ ๋งต map์ด ์ฃผ์ด์ก์ ๋ ๋ค์๊ณผ ๊ฐ์ด ๋์ํฉ๋๋ค:
-
I๋ฅผ stack์์ popํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
์์ฑ ๊ฐ ์์ง ์๊ณ ๋ฆฌ์ฆ์ object, I, map๊ณผ ํจ๊ป ์คํํฉ๋๋ค.
-
๋ง์ฝ stack์ด ๋น์ด์์ง ์๋ค๋ฉด, ์์ ์คํ์ ์์ฑ ๊ฐ ์์ง ์๊ณ ๋ฆฌ์ฆ์ object, stack, map๊ณผ ํจ๊ป ๋ค์ ์คํํฉ๋๋ค.
์์ฑ ๊ฐ ์์ง ์๊ณ ๋ฆฌ์ฆ์ ํ๋ซํผ ๊ฐ์ฒด object, ์ธํฐํ์ด์ค I, ์์๊ฐ ์๋ ๋งต map์ด ์ฃผ์ด์ก์ ๋ ๋ค์๊ณผ ๊ฐ์ด ๋์ํฉ๋๋ค:
-
๋ง์ฝ I์ [
Default] ํ์ฅ ์์ฑ์ด ๋ถ์toJSON์ฐ์ฐ์ด ์ ์ธ๋์ด ์๋ค๋ฉด, ๊ฐ ๋ ธ์ถ๋ ์ผ๋ฐ ์์ฑ attr์ ๋ํด, ์ธํฐํ์ด์ค ๋ฉค๋ฒ๊ฐ I์ธ ๊ฒ๋ค์ ์์๋๋ก:-
id๋ฅผ attr์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ getter ๋จ๊ณ๋ฅผ attr์ ๋ํด object๋ฅผ this๋ก ์ฌ์ฉํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๋ง์ฝ value๊ฐ JSON ํ์ ์ด๋ผ๋ฉด, map์ ์ค์ ํ์ฌ map[id]์ value๋ฅผ ์ง์ ํฉ๋๋ค.
-
์์ ์คํ ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ์ธํฐํ์ด์ค I์ ๋ํด ๋ค์๊ณผ ๊ฐ์ด ๋์ํฉ๋๋ค:
-
stack์ ์๋ก์ด ์คํ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
stack์ pushํ์ฌ I๋ฅผ ๋ฃ์ต๋๋ค.
-
while I๊ฐ ์์ํ๋ ์ธํฐํ์ด์ค๊ฐ ์์ ๋,
-
I๋ฅผ ๊ทธ ์ธํฐํ์ด์ค๋ก ์ค์ ํฉ๋๋ค.
-
stack์ pushํ์ฌ I๋ฅผ ๋ฃ์ต๋๋ค.
-
-
stack์ ๋ฐํํฉ๋๋ค.
toJSON ์ฐ์ฐ์ [Default] ํ์ฅ
์์ฑ์ด ์ ์ธ๋ ์ธํฐํ์ด์ค์
์ผ๋ฐ ์์ฑ๋ง
ํฌํจ๋๋ฉฐ, ์์๋ ์ธํฐํ์ด์ค์ ํด๋น ์ฐ์ฐ์ด ์ ์ธ๋์๋๋ผ๋ ํฌํจ๋์ง ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ์๋ IDL fragment๋ฅผ ๋ณด์ธ์:
[Exposed=Window]
interface A {
[Default] object toJSON();
attribute DOMString a;
};
[Exposed=Window]
interface B : A {
attribute DOMString b;
};
[Exposed=Window]
interface C : B {
[Default] object toJSON();
attribute DOMString c;
};
์์์ ์ ์๋ C ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ๊ฐ์ฒด์ toJSON() ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด ์๋์ ๊ฐ์ JSON ๊ฐ์ฒด๊ฐ ๋ฐํ๋ฉ๋๋ค:
{ "a" : "..." , "c" : "..." }
์์์ ์ ์๋ A ๋๋ B ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ๊ฐ์ฒด์ toJSON()
๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด:
{ "a" : "..." }
toJSON ์ฐ์ฐ์ ์ธํฐํ์ด์ค ๋ฏน์ค์ธ(๋๋ ๋ถ๋ถ ์ธํฐํ์ด์ค)์์๋ ์ ์ธํ ์ ์์ผ๋ฉฐ, ์ด๋ ์๋
์ธํฐํ์ด์ค์ ์ ์ธํ๋ ๊ฒ๊ณผ ๋์ผํ๊ฒ
๋์ํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ์๋ IDL
fragment๋ฅผ ๋ณด์ธ์:
[Exposed=Window]
interface D {
attribute DOMString d;
};
interface mixin M {
[Default] object toJSON();
attribute DOMString m;
};
D includes M;
์์์ ์ ์๋ D ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ๊ฐ์ฒด์ toJSON() ๋ฉ์๋๋ฅผ ํธ์ถํ๋ฉด:
{ "d" : "..." , "m" : "..." }
3.7.8. ๋ฌธ์์ดํ์(Stringifiers)
์ธํฐํ์ด์ค์ ๋ ธ์ถ๋ ๋ฌธ์์ดํ์(stringifier)๊ฐ ์๋ค๋ฉด, ๋ค์ ํน์ฑ์ ๊ฐ์ง ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ์ ์ด๋ฆ์ "
toString"์ด๋ค. -
stringifier๊ฐ ์ธํฐํ์ด์ค์์ ์์กฐ ๋ถ๊ฐ๋ฅํ๊ฑฐ๋ ๋๋ ์ธํฐํ์ด์ค๊ฐ [
Global] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋ ๊ฒฝ์ฐ, ํด๋น ํ๋กํผํฐ๋ ๊ทธ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๋ชจ๋ ๊ฐ์ฒด์ ์กด์ฌํ๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด, ํด๋น ํ๋กํผํฐ๋ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด์ ์กด์ฌํ๋ค. -
ํ๋กํผํฐ๋ { [[Writable]]: B, [[Enumerable]]:
true , [[Configurable]]: B } ์์ฑ์ ๊ฐ์ง๋ฉฐ, ์ฌ๊ธฐ์ B๋ stringifier๊ฐ ์ธํฐํ์ด์ค์์ ์์กฐ ๋ถ๊ฐ๋ฅํ ๊ฒฝ์ฐfalse ์ด๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉดtrue ์ด๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(toStringSteps, 0, "
toString", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ toStringSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
thisValue๋ฅผ
this ๊ฐ์ผ๋ก ๋๋ค. -
O๊ฐ ํ๋ซํผ ๊ฐ์ฒด์ด๋ฉด, ๋ค์์ ์ ๋ฌํ์ฌ ๋ณด์ ๊ฒ์ฌ๋ฅผ ์ํํ๋ค.
-
ํ๋ซํผ ๊ฐ์ฒด O,
-
์๋ณ์์ธ stringifier, ๊ทธ๋ฆฌ๊ณ
-
ํ์ "
method".
-
-
O๊ฐ stringifier๊ฐ ์ ์ธ๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์์ผ๋ฉด,
TypeError๋ฅผ ๋์ง๋ค. -
V๋ฅผ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ๋๋ค.
-
stringifier๊ฐ ์ง์ ๋ ๋ฐฉ์์ ๋ฐ๋ผ:- ์ ์ธ์ผ๋ก์
-
V๋ฅผ ์ธํฐํ์ด์ค์ ๋ฌธ์์ดํ ๋์์ ์ํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
- ์์ฑ์ ๋ํด
-
V๋ฅผ ํด๋น ์์ฑ์ getter ๋จ๊ณ (๋๋ ์ด ์์ฑ์ด getter๋ฅผ ์์ํ๋๋ก ์ ์ธ๋ ๊ฒฝ์ฐ, ์์๋ ์์ฑ์ getter ๋จ๊ณ์ ๋์ด๋ ๋จ๊ณ)๋ฅผ O๋ฅผ this๋ก ํ์ฌ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํ๋ค.
-
V๋ฅผ String ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
3.7.9. ์ดํฐ๋ฌ๋ธ ์ ์ธ
-
๋ง์ฝ definition์ ์ธ๋ฑ์ค ํ๋กํผํฐ getter๊ฐ ์๋ค๋ฉด:
-
DefineMethodProperty(target,
%Symbol.iterator%,%Array.prototype.values%, false)๋ฅผ ์ํํฉ๋๋ค. -
๋ง์ฝ definition์ ๊ฐ ์ดํฐ๋ ์ดํฐ๊ฐ ์๋ค๋ฉด:
-
! CreateDataPropertyOrThrow(target, "
entries",%Array.prototype.entries%)๋ฅผ ์ํํฉ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
keys",%Array.prototype.keys%)๋ฅผ ์ํํฉ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
values",%Array.prototype.values%)๋ฅผ ์ํํฉ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
forEach",%Array.prototype.forEach%)๋ฅผ ์ํํฉ๋๋ค.
-
-
-
๊ทธ๋ ์ง ์๊ณ definition์ ์ ์ดํฐ๋ ์ดํฐ๊ฐ ์๋ค๋ฉด:
-
%Symbol.iterator%๋ฐentries๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
steps๋ฅผ ๋ค์ ์ผ๋ จ์ ๋จ๊ณ๋ก ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
%Symbol.iterator%", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
definition์ ๋ํด ์๋ก ์์ฑ๋ ๊ธฐ๋ณธ ๋ฐ๋ณต์ ๊ฐ์ฒด(default iterator object)๋ฅผ ๋ฐํํ๋ค. jsValue๋ฅผ target์ผ๋ก, "
key+value"๋ฅผ kind๋ก, index๋ 0์ผ๋ก ํ๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, 0, "
entries", ยซ ยป, realm)๋ก ๋๋ค. -
DefineMethodProperty(target,
%Symbol.iterator%, F, false)๋ฅผ ์ํํ๋ค. -
! CreateDataPropertyOrThrow(target, "
entries", F)๋ฅผ ์ํํ๋ค.
-
-
keys๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
steps๋ฅผ ๋ค์ ์ผ๋ จ์ ๋จ๊ณ๋ก ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
keys", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
definition์ ๋ํด ์๋ก ์์ฑ๋ ๊ธฐ๋ณธ ๋ฐ๋ณต์ ๊ฐ์ฒด(default iterator object)๋ฅผ ๋ฐํํ๋ค. jsValue๋ฅผ target์ผ๋ก, "
key"๋ฅผ kind๋ก, index๋ 0์ผ๋ก ํ๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, 0, "
keys", ยซ ยป, realm)๋ก ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
keys", F)๋ฅผ ์ํํ๋ค.
-
-
values๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
steps๋ฅผ ๋ค์ ์ผ๋ จ์ ๋จ๊ณ๋ก ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
values", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
definition์ ๋ํด ์๋ก ์์ฑ๋ ๊ธฐ๋ณธ ๋ฐ๋ณต์ ๊ฐ์ฒด(default iterator object)๋ฅผ ๋ฐํํ๋ค. jsValue๋ฅผ target์ผ๋ก, "
value"๋ฅผ kind๋ก, index๋ 0์ผ๋ก ํ๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, 0, "
values", ยซ ยป, realm)๋ก ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
values", F)๋ฅผ ์ํํ๋ค.
-
-
forEach๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
ํจ์ ์ธ์๊ฐ callback ๋ฐ thisArg๋ฅผ ๋ฐ์์ ๋ steps๋ฅผ ๋ค์ ์ผ๋ จ์ ๋จ๊ณ๋ก ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
forEach", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
idlCallback๋ฅผ callback์ IDL ๊ฐ์ผ๋ก ๋ณํ(
Functionํ์ )ํ ๊ฐ์ผ๋ก ๋๋ค. -
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
-
pairs๋ฅผ idlObject์ ๋ฐ๋ณตํด์ผ ํ๋ ๊ฐ ์(value pairs to iterate over)์ ๋ฆฌ์คํธ๋ก ๋๋ค.
-
i๋ฅผ 0์ผ๋ก ๋๋ค.
-
i < pairs์ ํฌ๊ธฐ์ผ ๋์:
-
pair๋ฅผ pairs[i]๋ก ๋๋ค.
-
์ฝ๋ฐฑ ํจ์ ํธ์ถ์ ์ํํ๋ค. idlCallback์ ยซ pair์ value, pair์ key, idlObject ยป ๋ฐ thisArg๋ฅผ ์ฝ๋ฐฑ this ๊ฐ์ผ๋ก ํ์ฌ ํธ์ถํ๋ค.
-
pairs๋ฅผ idlObject์ ํ์ฌ ๋ฐ๋ณตํด์ผ ํ๋ ๊ฐ ์ ๋ฆฌ์คํธ๋ก ๋ค์ ์ค์ ํ๋ค. (์ค๊ฐ์ ๋ณ๊ฒฝ๋ ์๋ ์๋ค.)
-
i๋ฅผ i + 1๋ก ์ค์ ํ๋ค.
-
-
F๋ฅผ CreateBuiltinFunction(steps, 1, "
forEach", ยซ ยป, realm)๋ก ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
forEach", F)๋ฅผ ์ํํ๋ค.
-
-
3.7.9.1. ๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด
๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ ์ง์ ๋ ์ธํฐํ์ด์ค, target, ์ดํฐ๋ ์ด์ kind์ ๋ํด [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์ด ํด๋น ์ธํฐํ์ด์ค์ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด์ธ ๊ฐ์ฒด์ ๋๋ค.
๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ ์ธ ๊ฐ์ง ๋ด๋ถ ๊ฐ์ ๊ฐ์ง๋๋ค:
-
target: ์ดํฐ๋ ์ด์ ํ ๊ฐ์ ๊ฐ์ง ๊ฐ์ฒด
-
kind: ์ดํฐ๋ ์ด์ ์ข ๋ฅ
-
index: ์ดํฐ๋ ์ด์ ํ ๊ฐ์ ํ์ฌ ์ธ๋ฑ์ค
์ฐธ๊ณ : ๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ ์ ์ดํฐ๋ ์ดํฐ์๋ง ์ฌ์ฉ๋ฉ๋๋ค. ๊ฐ ์ดํฐ๋ ์ดํฐ๋ ํ์ฌ ๊ฐ์ฒด์ ์ง์ํ๋ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ง ์ดํฐ๋ ์ด์ ํ๋๋ก ์ ํ๋์ด ์์ผ๋ฏ๋ก, ํ์ค JavaScript Array ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํฉ๋๋ค.
์ฐธ๊ณ : ๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋
ํด๋์ค ๋ฌธ์์ด์ ๊ฐ์ง์ง ์์ต๋๋ค;
Object.prototype.toString()์ ์ธํฐํ์ด์ค์ ๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด์ ํธ์ถํ๋ฉด,
ํด๋น ์ธํฐํ์ด์ค์ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด์ ํด๋์ค ๋ฌธ์์ด์ด ์ฌ์ฉ๋ฉ๋๋ค.
3.7.9.2. ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด
์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด๋ ์ง์ ๋ ์ธํฐํ์ด์ค์ ๋ํด ์ ์ดํฐ๋ ์ดํฐ๊ฐ ์๋ ๋ชจ๋ ์ธํฐํ์ด์ค์ ์กด์ฌํฉ๋๋ค. ํด๋น ์ธํฐํ์ด์ค์ ๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด์ ํ๋กํ ํ์ ์ญํ ์ ํฉ๋๋ค.
[[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์
์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด์์
%Iterator.prototype%์ด์ด์ผ
ํฉ๋๋ค.
-
kind ๊ฐ์ ๋ฐ๋ผ result๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ฒฐ์ ํฉ๋๋ค:
- "
key" -
-
idlKey๋ฅผ pair์ key๋ก ์ค์ ํฉ๋๋ค.
-
key๋ฅผ IDL to JS ๊ฐ ๋ณํํ์ฌ idlKey๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
result๋ key์ ๋๋ค.
-
- "
value" -
-
idlValue๋ฅผ pair์ value๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ IDL to JS ๊ฐ ๋ณํํ์ฌ idlValue๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
result๋ value์ ๋๋ค.
-
- "
key+value" -
-
idlKey๋ฅผ pair์ key๋ก ์ค์ ํฉ๋๋ค.
-
idlValue๋ฅผ pair์ value๋ก ์ค์ ํฉ๋๋ค.
-
key๋ฅผ IDL to JS ๊ฐ ๋ณํํ์ฌ idlKey๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ IDL to JS ๊ฐ ๋ณํํ์ฌ idlValue๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
array๋ฅผ ! ArrayCreate(2)๋ก ์ค์ ํฉ๋๋ค.
-
! CreateDataPropertyOrThrow(array, "
0", key)๋ฅผ ์ํํฉ๋๋ค. -
! CreateDataPropertyOrThrow(array, "
1", value)๋ฅผ ์ํํฉ๋๋ค. -
result๋ array์ ๋๋ค.
-
- "
-
CreateIteratorResultObject(result,
false )๋ฅผ ๋ฐํํฉ๋๋ค.
์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด๋ ์์ฑ์ด
{ [[Writable]]: next ๋ฐ์ดํฐ ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์ผ ํ๋ฉฐ,
๊ทธ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(nextSteps, 0,
"next", ยซ ยป)์ด์ด์ผ ํ๋ค.
์ฌ๊ธฐ์ nextSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค:
-
interface๋ฅผ ํด๋น ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด๊ฐ ์กด์ฌํ๋ ์ธํฐํ์ด์ค๋ก ์ค์ ํฉ๋๋ค.
-
thisValue๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
object๊ฐ ํ๋ซํผ ๊ฐ์ฒด์ด๋ฉด, ๋ณด์ ๊ฒ์ฌ ์ํ์ ๋ค์ ์ธ์๋ก ํ์ฌ ์คํํฉ๋๋ค:
-
ํ๋ซํผ ๊ฐ์ฒด object,
-
์๋ณ์ "
next", -
ํ์ "
method"
-
-
object๊ฐ interface์ ๊ธฐ๋ณธ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด, throw๋ฅผ ์ฌ์ฉํด
TypeError๋ฅผ ๋ฐ์์ํต๋๋ค. -
index๋ฅผ object์ index๋ก ์ค์ ํฉ๋๋ค.
-
kind๋ฅผ object์ kind๋ก ์ค์ ํฉ๋๋ค.
-
values๋ฅผ object์ target์ ์ดํฐ๋ ์ด์ ํ ๊ฐ ์ ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค.
-
len์ values์ ๊ธธ์ด๋ก ์ค์ ํฉ๋๋ค.
-
index๊ฐ len๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ์ผ๋ฉด, CreateIteratorResultObject(
undefined ,true )๋ฅผ ๋ฐํํฉ๋๋ค. -
pair๋ฅผ values์ index๋ฒ์งธ ์ํธ๋ฆฌ๋ก ์ค์ ํฉ๋๋ค.
-
object์ index๋ฅผ index + 1๋ก ์ค์ ํฉ๋๋ค.
-
์ดํฐ๋ ์ดํฐ ๊ฒฐ๊ณผ๋ฅผ pair, kind์ ๋ํด ๋ฐํํฉ๋๋ค.
์ง์ ๋ ์ธํฐํ์ด์ค์ ๋ํ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด์ ํด๋์ค ๋ฌธ์์ด์
ํด๋น ์ธํฐํ์ด์ค์ ์๋ณ์์ ๋ฌธ์์ด
" Iterator"๋ฅผ ์ฐ๊ฒฐํ ๊ฒฐ๊ณผ์
๋๋ค.
3.7.10. ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ
-
definition์ ๋น๋๊ธฐ ๋ฐ๋ณต ๊ฐ๋ฅ ์ ์ธ(๋ ์ข ๋ฅ ๋ชจ๋ ํฌํจ)์ด ์๋ค๋ฉด, ๋ฐํํ๋ค.
-
๋จ์ธ: definition์ ์ธ๋ฑ์ค๋ ํ๋กํผํฐ ๊ฒํฐ ๋๋ iterable ์ ์ธ์ด ์์ด์ผ ํ๋ค.
-
definition์ pair ๋น๋๊ธฐ ๋ฐ๋ณต ๊ฐ๋ฅ ์ ์ธ์ด ์๋ค๋ฉด,
%Symbol.asyncIterator%์entries๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
ํจ์ ์ธ์๊ฐ args๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ, steps๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
%Symbol.asyncIterator%", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ๊ฐ์ผ๋ก ๋๋ค.
-
idlArgs๋ฅผ ๋น๋๊ธฐ ๋ฐ๋ณต์ ๋ฉ์๋์ ์ธ์ ๋ณํ ๊ฒฐ๊ณผ(args ์ฌ์ฉ)๋ก ๋๋ค.
-
iterator๋ฅผ definition์ ๋ํด ์๋กญ๊ฒ ์์ฑํ ๊ธฐ๋ณธ ๋น๋๊ธฐ ๋ฐ๋ณต์ ๊ฐ์ฒด๋ก ๋๋ค. idlObject๋ฅผ target์ผ๋ก, "
key+value"๋ฅผ kind๋ก, is finished๋ false๋ก ๋๋ค. -
definition์ ๋ํด idlObject, iterator, idlArgs๋ฅผ ์ธ์๋ก ํ์ฌ, ๋น๋๊ธฐ ๋ฐ๋ณต์ ์ด๊ธฐํ ๋จ๊ณ๊ฐ ์ ์๋์ด ์์ผ๋ฉด ์คํํ๋ค.
-
iterator๋ฅผ ๋ฐํํ๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, 0, "
entries", ยซ ยป, realm)๋ก ๋๋ค. -
DefineMethodProperty(target,
%Symbol.asyncIterator%, F, false)๋ฅผ ์ํํ๋ค. -
! CreateDataPropertyOrThrow(target, "
entries", F)๋ฅผ ์ํํ๋ค.
-
-
definition์ pair ๋น๋๊ธฐ ๋ฐ๋ณต ๊ฐ๋ฅ ์ ์ธ์ด ์๋ค๋ฉด,
keys๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
ํจ์ ์ธ์๊ฐ args๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ, steps๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
keys", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ๊ฐ์ผ๋ก ๋๋ค.
-
idlArgs๋ฅผ ๋น๋๊ธฐ ๋ฐ๋ณต์ ๋ฉ์๋์ ์ธ์ ๋ณํ ๊ฒฐ๊ณผ(args ์ฌ์ฉ)๋ก ๋๋ค.
-
iterator๋ฅผ definition์ ๋ํด ์๋กญ๊ฒ ์์ฑํ ๊ธฐ๋ณธ ๋น๋๊ธฐ ๋ฐ๋ณต์ ๊ฐ์ฒด๋ก ๋๋ค. idlObject๋ฅผ target์ผ๋ก, "
key"๋ฅผ kind๋ก, is finished๋ false๋ก ๋๋ค. -
definition์ ๋ํด idlObject, iterator, idlArgs๋ฅผ ์ธ์๋ก ํ์ฌ, ๋น๋๊ธฐ ๋ฐ๋ณต์ ์ด๊ธฐํ ๋จ๊ณ๊ฐ ์ ์๋์ด ์์ผ๋ฉด ์คํํ๋ค.
-
iterator๋ฅผ ๋ฐํํ๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, 0, "
keys, ยซ ยป, realm)๋ก ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
keys", F)๋ฅผ ์ํํ๋ค.
-
-
values(๊ทธ๋ฆฌ๊ณ ํ์์%Symbol.asyncIterator%) ๋ฉ์๋๋ฅผ ์ ์ํ๋ค:-
ํจ์ ์ธ์๊ฐ args๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ, steps๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋๋ค:
-
jsValue๊ฐ ํ๋ซํผ ๊ฐ์ฒด๋ผ๋ฉด, ๋ณด์ ๊ฒ์ฆ์ ์ํํ๋ค. jsValue, "
values", "method"๋ฅผ ์ ๋ฌํ๋ค. -
jsValue๊ฐ definition์ ๊ตฌํํ์ง ์๋๋ค๋ฉด, ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค(throw)
TypeError. -
idlObject๋ฅผ jsValue์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL interface ํ์ ๊ฐ์ผ๋ก ๋๋ค.
-
idlArgs๋ฅผ ๋น๋๊ธฐ ๋ฐ๋ณต์ ๋ฉ์๋์ ์ธ์ ๋ณํ ๊ฒฐ๊ณผ(args ์ฌ์ฉ)๋ก ๋๋ค.
-
iterator๋ฅผ definition์ ๋ํด ์๋กญ๊ฒ ์์ฑํ ๊ธฐ๋ณธ ๋น๋๊ธฐ ๋ฐ๋ณต์ ๊ฐ์ฒด๋ก ๋๋ค. idlObject๋ฅผ target์ผ๋ก, "
value"๋ฅผ kind๋ก, is finished๋ false๋ก ๋๋ค. -
definition์ ๋ํด idlObject, iterator, idlArgs๋ฅผ ์ธ์๋ก ํ์ฌ, ๋น๋๊ธฐ ๋ฐ๋ณต์ ์ด๊ธฐํ ๋จ๊ณ๊ฐ ์ ์๋์ด ์์ผ๋ฉด ์คํํ๋ค.
-
iterator๋ฅผ ๋ฐํํ๋ค.
-
F๋ฅผ CreateBuiltinFunction(steps, 0, "
values", ยซ ยป, realm)๋ก ๋๋ค. -
! CreateDataPropertyOrThrow(target, "
values", F)๋ฅผ ์ํํ๋ค. -
definition์ value ๋น๋๊ธฐ ๋ฐ๋ณต ๊ฐ๋ฅ ์ ์ธ์ด ์์ผ๋ฉด, ! DefineMethodProperty(target,
%Symbol.asyncIterator%, F, false)๋ฅผ ์ํํ๋ค.
-
-
idlArgs๋ฅผ ๋น ๋ฆฌ์คํธ๋ก ์ค์ ํฉ๋๋ค.
-
argCount๋ฅผ definition์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ธ์ ๊ฐ์๋ก ์ค์ ํ๊ฑฐ๋, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ธ์ ๋ฆฌ์คํธ๊ฐ ์์ผ๋ฉด 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
i๋ฅผ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
i < argCount์ผ ๋์:
-
๋ง์ฝ i โฅ args์ ํฌ๊ธฐ์ด๊ฑฐ๋, args[i]๊ฐ
undefined ์ด๋ฉด, ๋ค์์ ์ํํฉ๋๋ค:-
๋ง์ฝ i๋ฒ์งธ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ธ์๊ฐ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ ์ธ๋์ด ์๋ค๋ฉด, ๊ทธ ๊ธฐ๋ณธ๊ฐ์ idlArgs์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ๋ ์ง ์์ผ๋ฉด, idlArgs์ "missing" ํน์ ๊ฐ์ ์ถ๊ฐํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, idlArgs์ ์ถ๊ฐํฉ๋๋ค. ECMAScript ๊ฐ์ ํด๋น ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ์ฌ args[i]๋ฅผ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ์ธ์ ๋ฆฌ์คํธ i๋ฒ์งธ ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๊ฐํฉ๋๋ค.
-
i๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
idlArgs๋ฅผ ๋ฐํํฉ๋๋ค.
์ด ์๊ณ ๋ฆฌ์ฆ์ ์ค๋ฒ๋ก๋ ํด๊ฒฐ ์๊ณ ๋ฆฌ์ฆ์ ์ค๋ฒ๋ก๋๊ฐ ํ์ฉ๋์ง ์๊ณ ๋ชจ๋ ์ธ์๊ฐ ์ต์ ์ธ ๊ฒฝ์ฐ๋ก ํนํํ ๊ฒ์ ๋๋ค.
3.7.10.1. ๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด
๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ ์ง์ ๋ ์ธํฐํ์ด์ค, target, ์ดํฐ๋ ์ด์ kind์ ๋ํด [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์ด ํด๋น ์ธํฐํ์ด์ค์ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด์ธ ๊ฐ์ฒด์ ๋๋ค.
๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋ ๋ด๋ถ ๊ฐ์ ๊ฐ์ง๋๋ค:
-
target: ์ดํฐ๋ ์ด์ ํ ๊ฐ์ ๊ฐ์ง ๊ฐ์ฒด
-
kind: ์ดํฐ๋ ์ด์ ์ข ๋ฅ
-
ongoing promise:
Promise๋๋ null -
is finished: ๋ถ๋ฆฌ์ธ ๊ฐ
์ฐธ๊ณ : ๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๋
ํด๋์ค ๋ฌธ์์ด์ ๊ฐ์ง์ง ์์ต๋๋ค.
Object.prototype.toString()์
์ง์ ๋ ์ธํฐํ์ด์ค์ ๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด์ ํธ์ถํ๋ฉด,
ํด๋น ์ธํฐํ์ด์ค์ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด์ ํด๋์ค ๋ฌธ์์ด์ด ์ฌ์ฉ๋ฉ๋๋ค.
3.7.10.2. ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด ๋ ์ง์ ๋ ์ธํฐํ์ด์ค์ ๋ํด, ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ ๊ฐ์ง ๋ชจ๋ ์ธํฐํ์ด์ค์ ์กด์ฌํ๋ ๊ฐ์ฒด์ ๋๋ค. ํด๋น ์ธํฐํ์ด์ค์ ๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด์ ํ๋กํ ํ์ ์ญํ ์ ํฉ๋๋ค.
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด์ [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์
%AsyncIteratorPrototype%์ด์ด์ผ
ํฉ๋๋ค.
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด๋
์์ฑ์ด { [[Writable]]: next ๋ฐ์ดํฐ
ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์ผ ํ๋ฉฐ, ๊ทธ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(nextSteps, 0,
"next", ยซ ยป)์ด์ด์ผ ํ๋ค.
์ฌ๊ธฐ์ nextSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค:
-
interface๋ฅผ ํด๋น ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด๊ฐ ์กด์ฌํ๋ ์ธํฐํ์ด์ค๋ก ์ค์ ํฉ๋๋ค.
-
thisValidationPromiseCapability๋ฅผ ! NewPromiseCapability(
%Promise%)๋ก ์ค์ ํฉ๋๋ค. -
thisValue๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
object๋ฅผ Completion(ToObject(thisValue))๋ก ์ค์ ํฉ๋๋ค.
-
IfAbruptRejectPromise(object, thisValidationPromiseCapability)๋ฅผ ์คํํฉ๋๋ค.
-
object๊ฐ ํ๋ซํผ ๊ฐ์ฒด์ด๋ฉด ๋ณด์ ๊ฒ์ฌ ์ํ์ ๋ค์ ์ธ์๋ก ํ์ฌ ์คํํฉ๋๋ค:
-
ํ๋ซํผ ๊ฐ์ฒด object,
-
์๋ณ์ "
next", -
ํ์ "
method"
์ฌ๊ธฐ์ ์์ธ e๊ฐ ๋ฐ์ํ๋ค๋ฉด:
-
-
object๊ฐ interface์ ๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด:
-
nextSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค:
-
nextPromiseCapability๋ฅผ ! NewPromiseCapability(
%Promise%)๋ก ์ค์ ํฉ๋๋ค. -
object์ is finished๊ฐ true๋ผ๋ฉด:
-
result๋ฅผ CreateIteratorResultObject(
undefined ,true )๋ก ์ค์ ํฉ๋๋ค. -
! Call(nextPromiseCapability.[[Resolve]],
undefined , ยซ result ยป)๋ฅผ ์คํํฉ๋๋ค. -
nextPromiseCapability.[[Promise]]๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
kind๋ฅผ object์ kind๋ก ์ค์ ํฉ๋๋ค.
-
nextPromise๋ฅผ ๋ค์ ์ดํฐ๋ ์ด์ ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ object์ target๊ณผ object์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
fulfillSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. next๊ฐ ์ฃผ์ด์ก์ ๋:
-
object์ ongoing promise ๋ฅผ null๋ก ์ค์ ํฉ๋๋ค.
-
next๊ฐ ์ดํฐ๋ ์ด์ ์ข ๋ฃ๋ผ๋ฉด:
-
object์ is finished๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
-
CreateIteratorResultObject(
undefined ,true )๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, interface์ ์ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ค๋ฉด:
-
๋จ์ธ: next๋ ๊ฐ ์์ด๋ค.
-
์ดํฐ๋ ์ดํฐ ๊ฒฐ๊ณผ๋ฅผ next, kind์ ๋ํด ๋ฐํํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
๋จ์ธ: interface์ ๊ฐ ๋น๋๊ธฐ ์ดํฐ๋ฌ๋ธ ์ ์ธ์ด ์๋ค.
-
๋จ์ธ: next๋ ์ ์ธ์ ๋์ค๋ ํ์ ์ ๊ฐ์ด๋ค.
-
value๋ฅผ next ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
CreateIteratorResultObject(value,
false )๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
-
onFulfilled๋ฅผ CreateBuiltinFunction(fulfillSteps, 1, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค.
-
rejectSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค. reason์ด ์ฃผ์ด์ง ๊ฒฝ์ฐ:
-
object์ ongoing promise ๋ฅผ null๋ก ์ค์ ํฉ๋๋ค.
-
object์ is finished๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
-
Throw reason์ ์คํํฉ๋๋ค.
-
-
onRejected๋ฅผ CreateBuiltinFunction(rejectSteps, 1, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค.
-
PerformPromiseThen(nextPromise, onFulfilled, onRejected, nextPromiseCapability)๋ฅผ ์คํํฉ๋๋ค.
-
nextPromiseCapability.[[Promise]]๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
ongoingPromise๋ฅผ object์ ongoing promise๋ก ์ค์ ํฉ๋๋ค.
-
ongoingPromise๊ฐ null์ด ์๋๋ฉด:
-
afterOngoingPromiseCapability๋ฅผ ! NewPromiseCapability(
%Promise%)๋ก ์ค์ ํฉ๋๋ค. -
onSettled๋ฅผ CreateBuiltinFunction(nextSteps, 0, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค.
-
PerformPromiseThen(ongoingPromise, onSettled, onSettled, afterOngoingPromiseCapability)๋ฅผ ์คํํฉ๋๋ค.
-
object์ ongoing promise๋ฅผ afterOngoingPromiseCapability.[[Promise]]๋ก ์ค์ ํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
object์ ongoing promise๋ฅผ nextSteps ์คํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
-
object์ ongoing promise๋ฅผ ๋ฐํํฉ๋๋ค.
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ return ์๊ณ ๋ฆฌ์ฆ์ด
ํด๋น ์ธํฐํ์ด์ค์ ๋ํด ์ ์๋์ด ์๋ค๋ฉด,
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด๋
์์ฑ์ด { [[Writable]]: return ๋ฐ์ดํฐ
ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์ผ ํ๋ฉฐ, ๊ทธ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(returnSteps, 1,
"return", ยซ ยป)์ด์ด์ผ ํ๋ค.
์ฌ๊ธฐ์ returnSteps๋ ํ๋์ ์ธ์ value๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค:
-
interface๋ฅผ ํด๋น ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์ ๊ฐ์ฒด๊ฐ ์กด์ฌํ๋ ์ธํฐํ์ด์ค๋ก ์ค์ ํฉ๋๋ค.
-
returnPromiseCapability๋ฅผ ! NewPromiseCapability(
%Promise%)๋ก ์ค์ ํฉ๋๋ค. -
thisValue๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
object๋ฅผ Completion(ToObject(thisValue))๋ก ์ค์ ํฉ๋๋ค.
-
IfAbruptRejectPromise(object, returnPromiseCapability)๋ฅผ ์คํํฉ๋๋ค.
-
object๊ฐ ํ๋ซํผ ๊ฐ์ฒด์ด๋ฉด ๋ณด์ ๊ฒ์ฌ ์ํ์ ๋ค์ ์ธ์๋ก ํ์ฌ ์คํํฉ๋๋ค:
-
ํ๋ซํผ ๊ฐ์ฒด object,
-
์๋ณ์ "
return", -
ํ์ "
method"
์ฌ๊ธฐ์ ์์ธ e๊ฐ ๋ฐ์ํ๋ค๋ฉด:
-
-
object๊ฐ interface์ ๊ธฐ๋ณธ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๊ฐ์ฒด๊ฐ ์๋๋ฉด:
-
returnSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค:
-
returnPromiseCapability๋ฅผ ! NewPromiseCapability(
%Promise%)๋ก ๋ค์ ์ค์ ํฉ๋๋ค. -
object์ is finished๊ฐ true๋ผ๋ฉด:
-
result๋ฅผ CreateIteratorResultObject(value,
true )๋ก ์ค์ ํฉ๋๋ค. -
! Call(returnPromiseCapability.[[Resolve]],
undefined , ยซ result ยป)๋ฅผ ์คํํฉ๋๋ค. -
returnPromiseCapability.[[Promise]]๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
object์ is finished๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
-
๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ๋ฆฌํด ์๊ณ ๋ฆฌ์ฆ์ interface, object์ target, object, value๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
ongoingPromise๋ฅผ object์ ongoing promise๋ก ์ค์ ํฉ๋๋ค.
-
ongoingPromise๊ฐ null์ด ์๋๋ฉด:
-
afterOngoingPromiseCapability๋ฅผ ! NewPromiseCapability(
%Promise%)๋ก ์ค์ ํฉ๋๋ค. -
onSettled๋ฅผ CreateBuiltinFunction(returnSteps, 0, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค.
-
PerformPromiseThen(ongoingPromise, onSettled, onSettled, afterOngoingPromiseCapability)๋ฅผ ์คํํฉ๋๋ค.
-
object์ ongoing promise๋ฅผ afterOngoingPromiseCapability.[[Promise]]๋ก ์ค์ ํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
object์ ongoing promise๋ฅผ returnSteps ์คํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
-
fulfillSteps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ์ค์ ํฉ๋๋ค:
-
CreateIteratorResultObject(value,
true )๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
onFulfilled๋ฅผ CreateBuiltinFunction(fulfillSteps, 0, "", ยซ ยป)๋ก ์ค์ ํฉ๋๋ค.
-
PerformPromiseThen(object์ ongoing promise, onFulfilled,
undefined , returnPromiseCapability)๋ฅผ ์คํํฉ๋๋ค. -
returnPromiseCapability.[[Promise]]๋ฅผ ๋ฐํํฉ๋๋ค.
์ง์ ๋ ์ธํฐํ์ด์ค์ ๋ํ ๋น๋๊ธฐ ์ดํฐ๋ ์ดํฐ ํ๋กํ ํ์
๊ฐ์ฒด์ ํด๋์ค ๋ฌธ์์ด์
ํด๋น ์ธํฐํ์ด์ค์ ์๋ณ์์ ๋ฌธ์์ด
" AsyncIterator"๋ฅผ ์ฐ๊ฒฐํ ๊ฒฐ๊ณผ์
๋๋ค.
3.7.11. ๋งต๋ผ์ดํฌ ์ ์ธ
๋ง์ฝ ์ธํฐํ์ด์ค A๊ฐ ๋งต๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด, A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด์ ์ถ๊ฐ ํ๋กํผํฐ๊ฐ ์กด์ฌํฉ๋๋ค. ์ด ์ถ๊ฐ ํ๋กํผํฐ๋ค์ ์๋ ํ์ ์น์ ์์ ์ค๋ช ํฉ๋๋ค.
3.7.11.1. size
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ size ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Getter]]: G, [[Enumerable]]:
true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ฉฐ, ์ฌ๊ธฐ์ G๋ ์๋์ ์ ์๋, ์ธํฐํ์ด์ค์ ๋งต ํฌ๊ธฐ getter์ด๋ค. -
๋งต ํฌ๊ธฐ getter๋ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(sizeSteps, 0, "
get size", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ sizeSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
size" ๋ฐ ํ์ "getter"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
map์ ํฌ๊ธฐ๋ฅผ, JavaScript ๊ฐ์ผ๋ก ๋ณํํ์ฌ ๋ฐํํ๋ค.
-
3.7.11.2. %Symbol.iterator%
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ์ด๋ฆ์ด %Symbol.iterator%
์ฌ๋ฒ์ธ ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ์กด์ฌํด์ผ ํ๋ฉฐ,
์ด ํ๋กํผํฐ๋ { [[Writable]]: entries ํ๋กํผํฐ์ ๊ฐ์ธ ํจ์ ๊ฐ์ฒด์ด๋ค.
key+value", "key", "value")๊ฐ ์ฃผ์ด์ก์ ๋:
-
closure๋ฅผ ์ถ์ ํด๋ก์ (Abstract Closure)๋ก ์์ฑํฉ๋๋ค. ํ๋ผ๋ฏธํฐ ์์ด map๊ณผ kind๋ฅผ ์บก์ฒํ๋ฉฐ, ํธ์ถ ์ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
๊ฐ key โ value์ ๋ํด map์์:
-
key์ value๋ฅผ ๊ฐ๊ฐ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
kind๊ฐ "
key"์ด๋ฉด result๋ฅผ key๋ก ์ค์ ํฉ๋๋ค. -
๊ทธ ์ธ kind๊ฐ "
value"์ด๋ฉด result๋ฅผ value๋ก ์ค์ ํฉ๋๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ result๋ฅผ CreateArrayFromList(ยซ key, value ยป)๋ก ์ค์ ํฉ๋๋ค.
-
? GeneratorYield(CreateIteratorResultObject(result,
false ))๋ฅผ ์คํํฉ๋๋ค.
์ฐธ๊ณ : map์ ํฌ๊ธฐ์ ์ํธ๋ฆฌ ์์๋ Yield๋ก ์ธํด ์ด ์ถ์ ์ฐ์ฐ์ด ์ผ์ ์ค์ง๋๋ ๋์ ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค.
-
-
undefined ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
CreateIteratorFromClosure(closure, "
%MapIteratorPrototype%",%MapIteratorPrototype%)๋ฅผ ๋ฐํํฉ๋๋ค.
3.7.11.3. entries
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ entries ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(entriesSteps, 0, "
entries", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ entriesSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
entries" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
map์์ ์ข ๋ฅ๊ฐ "
key+value"์ธ ๋งต ๋ฐ๋ณต์๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
3.7.11.4. keys
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ keys ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(keysSteps, 0, "
keys", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ keysSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
keys" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
map์์ ์ข ๋ฅ๊ฐ "
key"์ธ ๋งต ๋ฐ๋ณต์๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
3.7.11.5. values
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ values ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(valuesSteps, 0, "
values", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ valuesSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
values" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
map์์ ์ข ๋ฅ๊ฐ "
value"์ธ ๋งต ๋ฐ๋ณต์๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
3.7.11.6. forEach
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ forEach ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(forEachSteps, 1, "
forEach", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ forEachSteps๋ ์ธ์ callbackFn ๋ฐ thisArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
forEach" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
IsCallable(callbackFn)์ด
false ์ด๋ฉด,TypeError๋ฅผ ๋์ง๋ค. -
map์ ๊ฐ key โ value์ ๋ํด ๋ฐ๋ณตํ๋ค:
-
jsKey์ jsValue๋ฅผ ๊ฐ๊ฐ JavaScript ๊ฐ์ผ๋ก ๋ณํ๋ key ๋ฐ value๋ก ๋๋ค.
-
? Call(callbackFn, thisArg, ยซ jsValue, jsKey, O ยป)์ ์ํํ๋ค.
-
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
3.7.11.7. get
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ get ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(getSteps, 1, "
get", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ getSteps๋ ํ๋์ ์ธ์ keyArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
get" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
keyType์ maplike ์ ์ธ์ ์ง์ ๋ ํค ํ์ ์ผ๋ก ๋๋ค.
-
key๋ฅผ keyArg๊ฐ ํ์ keyType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
key๊ฐ -0์ด๋ฉด, key๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
map[key]๊ฐ ์กด์ฌํ๋ฉด, map[key]๋ฅผ JavaScript ๊ฐ์ผ๋ก ๋ณํํ์ฌ ๋ฐํํ๋ค.
-
3.7.11.8. has
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ has ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(hasSteps, 1, "
has", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ hasSteps๋ ํ๋์ ์ธ์ keyArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
has" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
keyType์ maplike ์ ์ธ์ ์ง์ ๋ ํค ํ์ ์ผ๋ก ๋๋ค.
-
key๋ฅผ keyArg๊ฐ ํ์ keyType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
key๊ฐ -0์ด๋ฉด, key๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
map[key]๊ฐ ์กด์ฌํ๋ฉด,
true ๋ฅผ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉดfalse ๋ฅผ ๋ฐํํ๋ค.
-
3.7.11.9. set
๋ง์ฝ A๊ฐ ์๋ณ์ "set"์ ๊ฐ์ง ๋ฉค๋ฒ๋ฅผ ์ ์ธํ์ง ์์๊ณ ,
A๊ฐ ์ฝ๊ธฐ-์ฐ๊ธฐ ๋งต๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ๋ค์ ํน์ฑ์ ๊ฐ์ง๋ set ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(setSteps, 2, "
set", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ setSteps๋ ์ธ์ keyArg ๋ฐ valueArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
set" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
keyType์ maplike ์ ์ธ์ ์ง์ ๋ ํค ํ์ ์ผ๋ก, valueType์ ๊ฐ ํ์ ์ผ๋ก ๋๋ค.
-
key๋ฅผ keyArg๊ฐ ํ์ keyType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
key๊ฐ -0์ด๋ฉด, key๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
value๋ฅผ valueArg๊ฐ ํ์ valueType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
map[key]์ value๋ก ์ค์ ํ๋ค.
-
O๋ฅผ ๋ฐํํ๋ค.
-
์ธํฐํ์ด์ค๊ฐ set ๋ฉ์๋๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ,
๋ง์ฐฌ๊ฐ์ง๋ก -0 ํค๋ฅผ +0์ผ๋ก ๋งคํํด์ผ ํ๋ฉฐ,
this๋ฅผ ๋ฐํํด์ผ ํ๋ค.
3.7.11.10. delete
๋ง์ฝ A๊ฐ ์๋ณ์ "delete"๋ฅผ ๊ฐ์ง ๋ฉค๋ฒ๋ฅผ ์ ์ธํ์ง ์์๊ณ ,
A๊ฐ ์ฝ๊ธฐ-์ฐ๊ธฐ ๋งต๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ๋ค์ ํน์ฑ์ ๊ฐ์ง๋ delete ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(deleteSteps, 1, "
delete", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ deleteSteps๋ ํ๋์ ์ธ์ keyArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
delete" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
keyType์ maplike ์ ์ธ์ ์ง์ ๋ ํค ํ์ ์ผ๋ก ๋๋ค.
-
key๋ฅผ keyArg๊ฐ ํ์ keyType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
key๊ฐ -0์ด๋ฉด, key๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
map[key]๊ฐ ์กด์ฌํ๋ฉด retVal์
true ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดfalse ๋ก ๋๋ค. -
map[key]๋ฅผ ์ ๊ฑฐํ๋ค.
-
retVal๋ฅผ ๋ฐํํ๋ค.
-
์ธํฐํ์ด์ค๊ฐ delete ๋ฉ์๋๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ,
๋ง์ฐฌ๊ฐ์ง๋ก -0 ํค๋ฅผ +0์ผ๋ก ๋งคํํด์ผ ํ๋ฉฐ,
ํค๊ฐ ์กด์ฌํ๋์ง ์ฌ๋ถ๋ฅผ ๋ํ๋ด๋ boolean์
๋ฐํํด์ผ ํ๋ค.
3.7.11.11. clear
๋ง์ฝ A๊ฐ ์๋ณ์ "clear"๋ฅผ ๊ฐ์ง ๋ฉค๋ฒ๋ฅผ ์ ์ธํ์ง ์์๊ณ ,
A๊ฐ ์ฝ๊ธฐ-์ฐ๊ธฐ ๋งต๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ๋ค์ ํน์ฑ์ ๊ฐ์ง๋ clear ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(clearSteps, 0, "
clear", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ clearSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
clear" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
map์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ๋งต ์ํธ๋ฆฌ๋ก ๋๋ค.
-
map์ ๋น์ด๋ค.
Note: ํ์ฌ ์ผ์ ์ค๋จ๋ ์ฑ ์ด ๋งต์ ์ํ ์ค์ธ ๊ธฐ์กด ๋ฐ๋ณต์๊ฐ ์์ ์ ์์ผ๋ฏ๋ก, map์ ๋ณด์กด๋๋ค.
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
์ธํฐํ์ด์ค๊ฐ clear ๋ฉ์๋๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ,
๋งต
์ํธ๋ฆฌ ๊ฐ์ฒด๋ฅผ (์ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ๋์ ) ๋ณด์กดํด์ผ ํ๋ฉฐ,
undefined๋ฅผ
๋ฐํํด์ผ ํ๋ค.
3.7.12. ์ ๋ผ์ดํฌ ์ ์ธ
๋ง์ฝ ์ธํฐํ์ด์ค A๊ฐ ์ ๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด, A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด์ ์ถ๊ฐ ํ๋กํผํฐ๊ฐ ์กด์ฌํฉ๋๋ค. ์ด ์ถ๊ฐ ํ๋กํผํฐ๋ค์ ์๋ ํ์ ์น์ ์์ ์ค๋ช ํฉ๋๋ค.
3.7.12.1. size
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ size ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Getter]]: G, [[Enumerable]]:
true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ฉฐ, ์ฌ๊ธฐ์ G๋ ์๋์ ์ ์๋, ์ธํฐํ์ด์ค์ ์ธํธ ํฌ๊ธฐ getter์ด๋ค. -
์ธํธ ํฌ๊ธฐ getter๋ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(sizeSteps, 0, "
get size", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ sizeSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
size" ๋ฐ ํ์ "getter"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
set์ ํฌ๊ธฐ๋ฅผ, JavaScript ๊ฐ์ผ๋ก ๋ณํํ์ฌ ๋ฐํํ๋ค.
-
3.7.12.2. %Symbol.iterator%
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ์ด๋ฆ์ด %Symbol.iterator%
์ฌ๋ฒ์ธ ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ์กด์ฌํด์ผ ํ๋ฉฐ,
์ด ํ๋กํผํฐ๋ { [[Writable]]: values ํ๋กํผํฐ์ ๊ฐ์ธ ํจ์ ๊ฐ์ฒด์ด๋ค.
key+value" ๋๋ "value")๊ฐ ์ฃผ์ด์ก์ ๋:
-
closure๋ฅผ ์ถ์ ํด๋ก์ (Abstract Closure)๋ก ์์ฑํฉ๋๋ค. ํ๋ผ๋ฏธํฐ ์์ด set๊ณผ kind๋ฅผ ์บก์ฒํ๋ฉฐ, ํธ์ถ ์ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
๊ฐ entry์ ๋ํด set์์:
-
entry๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํฉ๋๋ค.
-
kind๊ฐ "
value"์ด๋ฉด result๋ฅผ entry๋ก ์ค์ ํฉ๋๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ result๋ฅผ CreateArrayFromList(ยซ entry, entry ยป)๋ก ์ค์ ํฉ๋๋ค.
-
? GeneratorYield(CreateIteratorResultObject(result,
false ))๋ฅผ ์คํํฉ๋๋ค.
์ฐธ๊ณ : set์ ํฌ๊ธฐ์ ์ํธ๋ฆฌ ์์๋ Yield๋ก ์ธํด ์ด ์ถ์ ์ฐ์ฐ์ด ์ผ์ ์ค์ง๋ ๋์ ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค.
-
-
undefined ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
CreateIteratorFromClosure(closure, "
%SetIteratorPrototype%",%SetIteratorPrototype%)๋ฅผ ๋ฐํํฉ๋๋ค.
3.7.12.3. entries
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ entries ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(entriesSteps, 0, "
entries", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ entriesSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
entries" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
set์์ ์ข ๋ฅ๊ฐ "
key+value"์ธ ์ธํธ ๋ฐ๋ณต์๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
3.7.12.4. keys
keys ๋ฐ์ดํฐ ํ๋กํผํฐ๋
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์ ์กด์ฌํด์ผ ํ๋ฉฐ,
{ [[Writable]]: values ํ๋กํผํฐ์ ๊ฐ์ธ ํจ์ ๊ฐ์ฒด์ด๋ค.
3.7.12.5. values
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ values ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(valuesSteps, 0, "
values", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ valuesSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
values" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
set์์ ์ข ๋ฅ๊ฐ "
value"์ธ ์ธํธ ๋ฐ๋ณต์๋ฅผ ์์ฑํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค.
-
3.7.12.6. forEach
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ forEach ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(forEachSteps, 1, "
forEach", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ forEachSteps๋ ์ธ์ callbackFn ๋ฐ thisArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
forEach" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
IsCallable(callbackFn)์ด
false ์ด๋ฉด,TypeError๋ฅผ ๋์ง๋ค. -
set์ ๊ฐ value์ ๋ํด ๋ฐ๋ณตํ๋ค:
-
jsValue๋ฅผ JavaScript ๊ฐ์ผ๋ก ๋ณํ๋ value๋ก ๋๋ค.
-
? Call(callbackFn, thisArg, ยซ jsValue, jsValue, Oยป)์ ์ํํ๋ค.
-
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
3.7.12.7. has
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋
๋ค์ ํน์ฑ์ ๊ฐ์ง๋ has ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(hasSteps, 1, "
has", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ hasSteps๋ ํ๋์ ์ธ์ valueArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
has" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
valueType์ setlike ์ ์ธ์ ์ง์ ๋ ๊ฐ ํ์ ์ผ๋ก ๋๋ค.
-
value๋ฅผ valueArg๊ฐ ํ์ valueType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
value๊ฐ -0์ด๋ฉด, value๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
set์ด value๋ฅผ ํฌํจํ๋ฉด
true ๋ฅผ ๋ฐํํ๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉดfalse ๋ฅผ ๋ฐํํ๋ค.
-
3.7.12.8. add
๋ง์ฝ A๊ฐ ์๋ณ์ "add"๋ฅผ ๊ฐ์ง ๋ฉค๋ฒ๋ฅผ ์ ์ธํ์ง ์์๊ณ ,
A๊ฐ ์ฝ๊ธฐ-์ฐ๊ธฐ ์
๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ๋ค์ ํน์ฑ์ ๊ฐ์ง๋ add ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(addSteps, 1, "
add", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ addSteps๋ ํ๋์ ์ธ์ valueArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
add" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
valueType์ setlike ์ ์ธ์ ์ง์ ๋ ๊ฐ ํ์ ์ผ๋ก ๋๋ค.
-
value๋ฅผ valueArg๊ฐ ํ์ valueType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
value๊ฐ -0์ด๋ฉด, value๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
value๋ฅผ set์ ์ถ๊ฐํ๋ค.
-
O๋ฅผ ๋ฐํํ๋ค.
-
์ธํฐํ์ด์ค๊ฐ add ๋ฉ์๋๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ,
๋ง์ฐฌ๊ฐ์ง๋ก -0 ๊ฐ์ +0์ผ๋ก ๋งคํํด์ผ ํ๋ฉฐ,
์ค์ ๋ ๊ฐ์ ๋ฐํํด์ผ ํ๋ค.
3.7.12.9. delete
๋ง์ฝ A๊ฐ ์๋ณ์ "delete"๋ฅผ ๊ฐ์ง ๋ฉค๋ฒ๋ฅผ ์ ์ธํ์ง ์์๊ณ ,
A๊ฐ ์ฝ๊ธฐ-์ฐ๊ธฐ ์
๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ๋ค์ ํน์ฑ์ ๊ฐ์ง๋ delete ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(deleteSteps, 1, "
delete", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ deleteSteps๋ ํ๋์ ์ธ์ valueArg๋ฅผ ๋ฐ๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
delete" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
valueType์ setlike ์ ์ธ์ ์ง์ ๋ ๊ฐ ํ์ ์ผ๋ก ๋๋ค.
-
value๋ฅผ valueArg๊ฐ ํ์ valueType์ IDL ๊ฐ์ผ๋ก ๋ณํ๋ ๊ฐ์ผ๋ก ๋๋ค.
-
value๊ฐ -0์ด๋ฉด, value๋ฅผ +0์ผ๋ก ์ค์ ํ๋ค.
-
set์ด value๋ฅผ ํฌํจํ๋ฉด retVal๋ฅผ
true ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดfalse ๋ก ๋๋ค. -
set์์ value๋ฅผ ์ ๊ฑฐํ๋ค.
-
retVal๋ฅผ ๋ฐํํ๋ค.
-
์ธํฐํ์ด์ค๊ฐ delete ๋ฉ์๋๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ,
๋ง์ฐฌ๊ฐ์ง๋ก -0 ๊ฐ์ +0์ผ๋ก ๋งคํํด์ผ ํ๋ฉฐ,
๊ฐ์ด ์กด์ฌํ๋์ง ์ฌ๋ถ๋ฅผ ๋ํ๋ด๋ boolean์
๋ฐํํด์ผ ํ๋ค.
3.7.12.10. clear
๋ง์ฝ A๊ฐ ์๋ณ์ "clear"๋ฅผ ๊ฐ์ง ๋ฉค๋ฒ๋ฅผ ์ ์ธํ์ง ์์๊ณ ,
A๊ฐ ์ฝ๊ธฐ-์ฐ๊ธฐ ์
๋ผ์ดํฌ ์ ์ธ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด,
A์ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด์๋ ๋ค์ ํน์ฑ์ ๊ฐ์ง๋ clear ๋ฐ์ดํฐ ํ๋กํผํฐ๊ฐ ๋ฐ๋์ ์กด์ฌํด์ผ ํฉ๋๋ค:
-
ํ๋กํผํฐ๋ { [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true } ์์ฑ์ ๊ฐ์ง๋ค. -
ํ๋กํผํฐ์ ๊ฐ์ ๋ด์ฅ ํจ์ ๊ฐ์ฒด CreateBuiltinFunction(clearSteps, 0, "
clear", ยซ ยป)์ด๋ฉฐ, ์ฌ๊ธฐ์ clearSteps๋ ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.-
O๋ฅผ A์ ๋ํด ์๋ณ์ "
clear" ๋ฐ ํ์ "method"๋ก ๊ตฌํ ๊ฒ์ฌ๋this ๊ฐ์ผ๋ก ๋๋ค. -
set์ O์ ๋ํ ์ฐธ์กฐ๋ฅผ ๋ํ๋ด๋ IDL ๊ฐ์ ์ธํธ ์ํธ๋ฆฌ๋ก ๋๋ค.
-
set์ ๋น์ด๋ค.
Note: ํ์ฌ ์ผ์ ์ค๋จ๋ ์ฑ ์ด ์ธํธ๋ฅผ ์ํ ์ค์ธ ๊ธฐ์กด ๋ฐ๋ณต์๊ฐ ์์ ์ ์์ผ๋ฏ๋ก, set์ ๋ณด์กด๋๋ค.
-
undefined ๋ฅผ ๋ฐํํ๋ค.
-
์ธํฐํ์ด์ค๊ฐ clear ๋ฉ์๋๋ฅผ ์ ์ธํ๋ ๊ฒฝ์ฐ,
์ธํธ
์ํธ๋ฆฌ ๊ฐ์ฒด๋ฅผ (์ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ๋์ ) ๋ณด์กดํด์ผ ํ๋ฉฐ,
undefined๋ฅผ
๋ฐํํด์ผ ํ๋ค.
3.8. ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ํ๋ซํผ ๊ฐ์ฒด
๋ช ์ธ์๋ "object๊ฐ interface ๊ฐ์ฒด์ด๋ค" ๋ฑ ๋ค์ํ ๋ฐฉ์์ผ๋ก "object๊ฐ interface๋ฅผ ๊ตฌํํ๋ค"๋ ๊ฐ๋ ์ ์ฐธ์กฐํ ์ ์์ต๋๋ค.
๋ชจ๋ ํ๋ซํผ ๊ฐ์ฒด๋ realm๊ณผ ์ฐ๊ด๋์ด ์์ต๋๋ค. ์ด๊ธฐ ๊ฐ์ฒด๋ค๋ ๋ง์ฐฌ๊ฐ์ง์ ๋๋ค. ์ด realm์ ํ๋ซํผ ๊ฐ์ฒด์ [[Realm]] ์ฌ๋กฏ์ ์ ์ฅ๋ฉ๋๋ค. Web IDL์ ์ฌ์ฉํ๋ ๋ช ์ธ์๋ ๊ฐ ํ๋ซํผ ๊ฐ์ฒด๊ฐ ์ด๋ค realm(ํน์ ๊ทธ์ ๋์ํ๋ ๊ธ๋ก๋ฒ ๊ฐ์ฒด)์ ์ํ๋์ง ๋ช ์ํด์ผ ํฉ๋๋ค. ํนํ, ์๋ ์๊ณ ๋ฆฌ์ฆ์ ์ ํ๋ซํผ ๊ฐ์ฒด๋ฅผ ์ ๋ฌ๋ฐ์ realm์ ์ฐ๊ด์ํต๋๋ค.
-
์ธํฐํ์ด์ค๋ฅผ ๋ด๋ถ์ ์ผ๋ก ๊ตฌํํ๋ ์ ๊ฐ์ฒด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ interface, realm,
undefined ๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
๋จ์ธ: interface๋ realm์ ๋ ธ์ถ๋์ด ์๋ค.
-
newTarget์ด
undefined ์ด๋ฉด:-
prototype์ realm์ interface์ ๋ํ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ:
-
๋จ์ธ: IsCallable(newTarget)๊ฐ true์ด๋ค.
-
prototype์ ? Get(newTarget, "prototype")์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
prototype์ด ๊ฐ์ฒด๊ฐ ์๋๋ฉด:
-
targetRealm์ ? GetFunctionRealm(newTarget)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
prototype์ targetRealm์ interface์ ๋ํ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
-
-
slots๋ฅผ ยซ [[Prototype]], [[Extensible]], [[Realm]], [[PrimaryInterface]] ยป๋ก ์ค์ ํฉ๋๋ค.
-
interface๊ฐ
DOMException์ด๋ฉด, [[ErrorData]]๋ฅผ slots์ ์ถ๊ฐํฉ๋๋ค. -
instance๋ฅผ MakeBasicObject(slots)๋ก ์์ฑํฉ๋๋ค.
-
instance.[[Realm]]์ realm์ ํ ๋นํฉ๋๋ค.
-
instance.[[PrimaryInterface]]์ interface๋ฅผ ํ ๋นํฉ๋๋ค.
-
instance.[[Prototype]]์ prototype์ ํ ๋นํฉ๋๋ค.
-
interfaces๋ฅผ interface์ ํฌํจ๋ ์์ ์ธํฐํ์ด์ค ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค.
-
๊ฐ ์ธํฐํ์ด์ค ancestor interface์ ๋ํด interfaces์์:
-
unforgeables๋ฅผ realm์ ancestor interface ์ธํฐํ์ด์ค ๊ฐ์ฒด์ [[Unforgeables]] ์ฌ๋กฏ ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
keys๋ฅผ ! unforgeables.[[OwnPropertyKeys]]()์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๊ฐ key์ ๋ํด keys์์:
-
descriptor๋ฅผ ! unforgeables.[[GetOwnProperty]](key)๋ก ์ค์ ํฉ๋๋ค.
-
! DefinePropertyOrThrow(instance, key, descriptor)๋ฅผ ์คํํฉ๋๋ค.
-
-
-
interface๊ฐ [
Global] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด:-
์ ๊ท ์ฐ์ฐ ์ ์ํ๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ interface, instance, realm์ ๋ํด ์คํํฉ๋๋ค.
-
์ ๊ท ์์ฑ ์ ์ํ๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ interface, instance, realm์ ๋ํด ์คํํฉ๋๋ค.
-
์ดํฐ๋ ์ด์ ๋ฉ์๋ ์ ์ํ๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ interface, instance, realm์ ๋ํด ์คํํฉ๋๋ค.
-
๋น๋๊ธฐ ์ดํฐ๋ ์ด์ ๋ฉ์๋ ์ ์ํ๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ interface, instance, realm์ ๋ํด ์คํํฉ๋๋ค.
-
๊ธ๋ก๋ฒ ํ๋กํผํฐ ์ฐธ์กฐ ์ ์ํ๊ธฐ ์๊ณ ๋ฆฌ์ฆ์ instance, realm์ ๋ํด ์คํํฉ๋๋ค.
-
instance.[[SetPrototypeOf]]๋ฅผ ยงโฏ3.8.1 [[SetPrototypeOf]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, interfaces์ ์ธํฐํ์ด์ค๊ฐ ์๊ณ , ์ธ๋ฑ์ค ํ๋กํผํฐ ์ง์ ๋๋ ์ด๋ฆ ํ๋กํผํฐ ์ง์ ์ธํฐํ์ด์ค๊ฐ ํฌํจ๋์ด ์๋ค๋ฉด:
-
instance.[[GetOwnProperty]]๋ฅผ ยงโฏ3.9.1 [[GetOwnProperty]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
instance.[[Set]]์ ยงโฏ3.9.2 [[Set]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
instance.[[DefineOwnProperty]]๋ฅผ ยงโฏ3.9.3 [[DefineOwnProperty]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
instance.[[Delete]]๋ฅผ ยงโฏ3.9.4 [[Delete]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
instance.[[PreventExtensions]]๋ฅผ ยงโฏ3.9.5 [[PreventExtensions]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
instance.[[OwnPropertyKeys]]๋ฅผ ยงโฏ3.9.6 [[OwnPropertyKeys]]์์ ์ ์๋ ๋๋ก ์ค์ ํฉ๋๋ค.
-
-
instance๋ฅผ ๋ฐํํฉ๋๋ค.
-
interfaces๋ฅผ ๋ชฉ๋ก์ผ๋ก ํ์ฌ, realm์ ๋ ธ์ถ๋ ๋ชจ๋ ์ธํฐํ์ด์ค๋ฅผ ํฌํจ์ํต๋๋ค.
-
interfaces๋ฅผ ์ ๋ ฌํฉ๋๋ค. ๋ง์ฝ interfaces์ ํญ๋ชฉ A์ B์ ๋ํด, A๊ฐ ์์๋ฐ์๋ค๋ฉด, A์ ์ธ๋ฑ์ค๊ฐ B๋ณด๋ค ๋๊ฒ ์ ๋ ฌํฉ๋๋ค.
-
๊ฐ interface์ ๋ํด interfaces์์:
-
interface๊ฐ [
LegacyNoInterfaceObject] ๋๋ [LegacyNamespace] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์ง ์์๋ค๋ฉด:-
id๋ฅผ interface์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
interfaceObject๋ฅผ ์ธํฐํ์ด์ค ๊ฐ์ฒด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ interface, id, realm์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
DefineMethodProperty(target, id, interfaceObject, false)๋ฅผ ์คํํฉ๋๋ค.
-
interface๊ฐ [
LegacyWindowAlias] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์ด ์๊ณ , target์ดWindow์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ณ ์๋ค๋ฉด:-
๊ฐ [
LegacyWindowAlias]์ ์๋ณ์๋ค์ ํฌํจ๋ ์๋ณ์ id์ ๋ํด:-
DefineMethodProperty(target, id, interfaceObject, false)๋ฅผ ์คํํฉ๋๋ค.
-
-
-
-
interface๊ฐ [
LegacyFactoryFunction] ํ์ฅ ์์ฑ์ผ๋ก ์ ์ธ๋์๋ค๋ฉด:-
๊ฐ [
LegacyFactoryFunction]์ ์๋ณ์๋ค์ ํฌํจ๋ ์๋ณ์ id์ ๋ํด:-
legacyFactoryFunction์ ๋ ๊ฑฐ์ ํฉํ ๋ฆฌ ํจ์ ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ id, interface, realm์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
DefineMethodProperty(target, id, legacyFactoryFunction, false)๋ฅผ ์คํํฉ๋๋ค.
-
-
-
-
๊ฐ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค interface์ ๋ํด, realm์ ๋ ธ์ถ๋๊ณ , ์์๊ฐ ์ ์๋์ด ์๋ ๊ฒฝ์ฐ:
-
id๋ฅผ interface์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
interfaceObject๋ฅผ ๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ interface, id, realm์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
DefineMethodProperty(target, id, interfaceObject, false)๋ฅผ ์คํํฉ๋๋ค.
-
-
๊ฐ ๋ค์์คํ์ด์ค namespace์ ๋ํด, realm์ ๋ ธ์ถ๋ ๊ฒฝ์ฐ:
-
id๋ฅผ namespace์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
namespaceObject๋ฅผ ๋ค์์คํ์ด์ค ๊ฐ์ฒด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ namespace, realm์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
DefineMethodProperty(target, id, namespaceObject, false)๋ฅผ ์คํํฉ๋๋ค.
-
์๋ก ๋ค๋ฅธ ํ๋ซํผ ๊ฐ์ฒด๊ฐ ์๋ก ๋ค๋ฅธ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ฅผ ๊ฐ์ง๋๋ผ๋, [[PrimaryInterface]] ๋ด๋ถ ์ฌ๋กฏ์ ๊ฐ์ ์ธํฐํ์ด์ค๋ฅผ ์ฐธ์กฐํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๊ฐ์ ์ค๋ฆฌ์ง์ iframe์ด ์๊ณ , iframe์ ๋ฉ์๋๊ฐ ๋ฉ์ธ ํ์ด์ง์ ๊ฐ์ ์ข ๋ฅ์ ์์์ ํธ์ถ๋์ด๋ ์์ธ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค.
์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ ๊ตฌํ ์๊ณ ๋ฆฌ์ฆ ํ๊ฐ์ ์ง์ ์ฐธ์ฌํ์ง ์์ต๋๋ค. ๋์ , ์ธํฐํ์ด์ค ๋ฏน์ค์ธ์ด ํฌํจ๋ ๊ฐ ์ธํฐํ์ด์ค๋ ๋ฏน์ค์ธ์ ๊ฐ ๋ฉค๋ฒ์ ๋ํด ์์ ์ "๋ณต์ฌ๋ณธ"์ ๊ฐ์ง๋ฉฐ, ํด๋น operation function์ ์์ ์๊ฐ ๊ตฌํํ๋ ์ธํฐํ์ด์ค๊ฐ ๋ฏน์ค์ธ์ ํฌํจํ๋์ง ํ์ธํฉ๋๋ค.
ํ๋ซํผ ๊ฐ์ฒด๊ฐ ์ฐ๊ด๋ realm์ ๊ฐ์ฒด ์์ฑ ํ ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค. ํ๋ซํผ ๊ฐ์ฒด์ ์ฐ๊ด๋ realm์ด ๋ณ๊ฒฝ๋๋ฉด, [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์ ์ฆ์ ํด๋น ํ๋ซํผ ๊ฐ์ฒด์ ์ realm์ ์ฃผ ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค ํ๋กํ ํ์ ๊ฐ์ฒด๋ก ์ ๋ฐ์ดํธ๋์ด์ผ ํฉ๋๋ค.
๋ํ, [Global] ํ์ฅ ์์ฑ์ ๊ฐ์ง
์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋
ํ๋ซํผ ๊ฐ์ฒด๋ ๋ค์์์ ์ ์ธ์ ์ผ๋ก ํ๋กํผํฐ๋ฅผ ์ป์ต๋๋ค:
๋์ ๊ทธ ํ๋กํผํฐ๋ค์ ๋ช ๋ นํ์ผ๋ก ์ ์ํด์ผ ํฉ๋๋ค.
3.8.1. [[SetPrototypeOf]]
[[SetPrototypeOf]] ๋ด๋ถ ๋ฉ์๋๊ฐ ํ๋ซํผ ๊ฐ์ฒด O์ ๋ํด ํธ์ถ๋๋ฉฐ, O๊ฐ
์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ณ ๊ทธ ์ธํฐํ์ด์ค์
[Global] ํ์ฅ
์์ฑ์ด ์์ผ๋ฉฐ
JavaScript ์ธ์ด ๊ฐ V๋ก ํธ์ถ๋๋ฉด, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
O์ ์ฐ๊ด๋ realm์ ๊ธ๋ก๋ฒ ํ๋กํ ํ์ ์ฒด์ธ์ด ๋ณ๊ฒฝ ๊ฐ๋ฅ ์ด true์ด๋ฉด, ? OrdinarySetPrototypeOf(O, V)๋ฅผ ๋ฐํํฉ๋๋ค.
-
? SetImmutablePrototype(O, V)๋ฅผ ๋ฐํํฉ๋๋ค.
์ฐธ๊ณ : Window
๊ฐ์ฒด์ ๊ฒฝ์ฐ, WindowProxy
๊ฐ์ฒด์ ์กด์ฌ๋ก ์ธํด [[SetPrototypeOf]]๊ฐ Window
๊ฐ์ฒด์ ์ง์ ํธ์ถ๋๋ ๊ฒ์ด ๊ด์ฐฐ๋์ง ์์ผ๋ฏ๋ก ์ด ๊ตฌํ ์ฌ๋ถ๋ ๊ด์ฐฐ ๋ถ๊ฐํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋ค๋ฅธ ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ๊ฒฝ์ฐ์๋ ํ์ํฉ๋๋ค.
3.9. ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด
๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด๋ ์์ ์ ์ธ๋ฑ์ค ํ๋กํผํฐ์ ์ด๋ฆ ํ๋กํผํฐ์ ํด๋นํ๋ ์ถ๊ฐ ํ๋กํผํฐ๋ฅผ ๊ฐ๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค. ์ด๋ฌํ ํ๋กํผํฐ๋ ๊ฐ์ฒด์ ์ค์ own ํ๋กํผํฐ๊ฐ ์๋์ง๋ง, [[GetOwnProperty]] ๋ด๋ถ ๋ฉ์๋๋ฅผ ํตํด ๋ ธ์ถ๋์ด ๊ฐ์ฒด์ own ํ๋กํผํฐ์ฒ๋ผ ๋์ํฉ๋๋ค.
ํ๋์ ๊ฐ์ฒด๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ ์ฌ๋ฌ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฒ์ด ํ์ฉ๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์ด ๊ฒฝ์ฐ, ๊ฐ์ฒด์ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค์ ๋ํด ์ ์๊ฐ ์ถฉ๋ํ๋ค๋ฉด, ๊ฐ์ฒด๊ฐ ์ด๋ค ์ถ๊ฐ ํ๋กํผํฐ๋ฅผ ๊ฐ๋์ง, ์ธ๋ฑ์ค ํ๋กํผํฐ์ ๊ด๋ จํ ์ ํํ ๋์์ ์ ์๋์ง ์์ต๋๋ค. ์ด๋ฆ ํ๋กํผํฐ๋ ๋ง์ฐฌ๊ฐ์ง์ ๋๋ค.
ํ์๋ ์ธํฐํ์ด์ค์์ ์ ์๋ ์ธ๋ฑ์ค ํ๋กํผํฐ getter๊ฐ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด๊ฐ ๊ตฌํํ๋ ์ธํฐํ์ด์ค ์ค ๊ฐ์ฅ ํ์๋ ์ธํฐํ์ด์ค์ ๋์์ ์ ์ํฉ๋๋ค. ๊ฐ์ฒด๋ฅผ ๋ฐฐ์ด ์ธ๋ฑ์ค๋ก ์ธ๋ฑ์ฑํ ๋ ํด๋น getter๊ฐ ๋์ํฉ๋๋ค. ์ธ๋ฑ์ค ํ๋กํผํฐ setter๋ ๋ง์ฐฌ๊ฐ์ง๋ก ๊ฐ์ฅ ํ์๋ ์ธํฐํ์ด์ค์ ์ ์๋ฅผ ๋ฐ๋ฆ ๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ์์ ์ธํฐํ์ด์ค์ ํน์ ์ฐ์ฐ ์ ์๊ฐ ์ค๋ฒ๋ผ์ด๋๋ ์ ์์ต๋๋ค.
ํ๋กํผํฐ ์ด๋ฆ O๊ฐ ๊ตฌํํ๋ ์ธํฐํ์ด์ค ์ค ์ด๋ค ์ธํฐํ์ด์ค์ ์ธํฐํ์ด์ค ๋ฉค๋ฒ๊ฐ ํด๋น ์๋ณ์๋ก ์กด์ฌํ๊ณ , ๊ทธ ์ธํฐํ์ด์ค ๋ฉค๋ฒ๊ฐ ํด๋น ์ธํฐํ์ด์ค๋ค ์ค ํ๋์์ ์์กฐ ๋ถ๊ฐ(unforgeable)์ผ ๊ฒฝ์ฐ, ํด๋น ํ๋ซํผ ๊ฐ์ฒด O์ ์์กฐ ๋ถ๊ฐ ํ๋กํผํฐ ์ด๋ฆ์ด ๋ฉ๋๋ค.
getter ์ง์์ ยงโฏ3.9.1 [[GetOwnProperty]]์์, setter ์ง์์ ยงโฏ3.9.3 [[DefineOwnProperty]] ๋ฐ ยงโฏ3.9.2 [[Set]]์์ ์ฒ๋ฆฌ๋ฉ๋๋ค.
๋ํ, ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด๋ ๋ค์์์ ์ ์๋ ๋ด๋ถ ๋ฉ์๋๋ฅผ ๊ฐ์ต๋๋ค:
3.9.1. [[GetOwnProperty]]
๋ชจ๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด O์ [[GetOwnProperty]] ๋ด๋ถ ๋ฉ์๋๋ ํ๋กํผํฐ ์ด๋ฆ P๋ก ํธ์ถ๋ ๋ ๋ค์๊ณผ ๊ฐ์ด ๋์ํด์ผ ํฉ๋๋ค:
-
? LegacyPlatformObjectGetOwnProperty(O, P,
false )๋ฅผ ๋ฐํํฉ๋๋ค.
3.9.2. [[Set]]
๋ชจ๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด O์ [[Set]] ๋ด๋ถ ๋ฉ์๋๋ ํ๋กํผํฐ ์ด๋ฆ P, ๊ฐ V, ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ Receiver๋ก ํธ์ถ๋ ๋ ๋ค์๊ณผ ๊ฐ์ด ๋์ํด์ผ ํฉ๋๋ค:
-
O์ Receiver๊ฐ ๊ฐ์ ๊ฐ์ฒด๋ผ๋ฉด:
-
O๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ณ , P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค๋ผ๋ฉด:
-
์ธ๋ฑ์ค ํ๋กํผํฐ setter ํธ์ถ์ O์ P์ V๋ก ์คํํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
O๊ฐ ์ด๋ฆ ํ๋กํผํฐ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ณ , P๊ฐ ๋ฌธ์์ด(String)์ด๋ผ๋ฉด:
-
์ด๋ฆ ํ๋กํผํฐ setter ํธ์ถ์ O์ P์ V๋ก ์คํํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
-
ownDesc๋ฅผ ? LegacyPlatformObjectGetOwnProperty(O, P,
true )์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. -
? OrdinarySetWithOwnDescriptor(O, P, V, Receiver, ownDesc)๋ฅผ ์ํํฉ๋๋ค.
3.9.3. [[DefineOwnProperty]]
๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด O์ [[DefineOwnProperty]] ๋ด๋ถ ๋ฉ์๋๋ ํ๋กํผํฐ ํค P์ ํ๋กํผํฐ ๋์คํฌ๋ฆฝํฐ(Property Descriptor) Desc๋ก ํธ์ถ๋ ๋ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํด์ผ ํฉ๋๋ค:
-
O๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๊ณ P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค๋ผ๋ฉด:
-
IsDataDescriptor(Desc)์ ๊ฒฐ๊ณผ๊ฐ
false ๋ผ๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
O๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์๋๋ค๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
์ธ๋ฑ์ค ํ๋กํผํฐ setter ํธ์ถ์ O์ P์ Desc.[[Value]]๋ก ์คํํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
O๊ฐ ๋ช ๋ช ๋ ์์ฑ์ ์ง์ํ๊ณ , O๊ฐ [
Global] ํ์ฅ ์์ฑ์ด ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์์ผ๋ฉฐ, P๊ฐ String์ด๊ณ , P๊ฐ O์ ์์กฐ ๋ถ๊ฐ๋ฅํ ์์ฑ ์ด๋ฆ์ด ์๋๋ฉด:-
P๊ฐ ์ง์๋๋ ์์ฑ ์ด๋ฆ์ด ์๋๋ฉด creating์ true๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ก ๋ก๋๋ค.
-
O๊ฐ [
LegacyOverrideBuiltIns] ํ์ฅ ์์ฑ์ด ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๊ฑฐ๋, O๊ฐ P๋ผ๋ ์ด๋ฆ์ ๊ณ ์ ์์ฑ์ ๊ฐ์ง ์์ผ๋ฉด:-
creating์ด false์ด๊ณ O๊ฐ ๋ช ๋ช ๋ ์์ฑ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์์ผ๋ฉด,
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
O๊ฐ ๊ตฌํํ๋ ์ธํฐํ์ด์ค์ ๋ช ๋ช ๋ ์์ฑ setter๊ฐ ์์ผ๋ฉด:
-
IsDataDescriptor(Desc)๋ฅผ ํธ์ถํ ๊ฒฐ๊ณผ๊ฐ
false ์ด๋ฉด,false ๋ฅผ ๋ฐํํฉ๋๋ค. -
P์ Desc.[[Value]]๋ฅผ ์ฌ์ฉํ์ฌ O์์ ๋ช ๋ช ๋ ์์ฑ setter๋ฅผ ํธ์ถํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
-
-
! OrdinaryDefineOwnProperty(O, P, Desc)๋ฅผ ๋ฐํํฉ๋๋ค.
3.9.4. [[Delete]]
๋ชจ๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด O์ [[Delete]] ๋ด๋ถ ๋ฉ์๋๋ ์์ฑ ์ด๋ฆ P๋ก ํธ์ถ๋ ๋ ๋ค์๊ณผ ๊ฐ์ด ๋์ํด์ผ ํฉ๋๋ค.
-
O๊ฐ ์ธ๋ฑ์ค ์์ฑ์ ์ง์ํ๊ณ P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด:
-
index๊ฐ ์ง์๋๋ ์์ฑ ์ธ๋ฑ์ค๊ฐ ์๋๋ฉด,
true ๋ฅผ ๋ฐํํฉ๋๋ค. -
false ๋ฅผ ๋ฐํํฉ๋๋ค.
-
O๊ฐ ๋ช ๋ช ๋ ์์ฑ์ ์ง์ํ๊ณ , O๊ฐ [
Global] ํ์ฅ ์์ฑ์ด ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์์ผ๋ฉฐ ์์ฑ ์ด๋ฆ P์ ๊ฐ์ฒด O๋ก ๋ช ๋ช ๋ ์์ฑ ๊ฐ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ํธ์ถํ ๊ฒฐ๊ณผ๊ฐ true์ด๋ฉด:-
O๊ฐ ๋ช ๋ช ๋ ์์ฑ ์ญ์ ์๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ์ง ์์ผ๋ฉด,
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
operation์ ๋ช ๋ช ๋ ์์ฑ ์ญ์ ์๋ฅผ ์ ์ธํ๋ ๋ฐ ์ฌ์ฉ๋ ์ฐ์ฐ์ผ๋ก ๋ก๋๋ค.
-
operation์ด ์๋ณ์ ์์ด ์ ์๋์๋ค๋ฉด:
-
์ธํฐํ์ด์ค ์ค๋ช ์ ๋์ด๋ ๋จ๊ณ๋ฅผ ์ํํ์ฌ ๊ธฐ์กด ๋ช ๋ช ๋ ์์ฑ์ ์ญ์ ํฉ๋๋ค. ์ด๋ P๋ฅผ ์ด๋ฆ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
-
๋จ๊ณ์์ ์ญ์ ๊ฐ ์คํจํ๋ค๊ณ ๋ํ๋ด๋ฉด,
false ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
๊ทธ๋ ์ง ์์ผ๋ฉด, operation์ ์๋ณ์์ ํจ๊ป ์ ์๋์์ต๋๋ค:
-
operation์ ๋ฉ์๋ ๋จ๊ณ๋ฅผ ์ํํ๋, O๋ฅผ this๋ก, ยซ P ยป๋ฅผ ์ธ์ ๊ฐ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
-
operation์ด ๋ฐํ ํ์ ์
boolean์ผ๋ก ์ ์ธํ๊ณ ๋จ๊ณ๊ฐfalse ๋ฅผ ๋ฐํํ๋ค๋ฉด,false ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
O์ ์ด๋ฆ์ด P์ธ ๊ณ ์ ์์ฑ์ด ์์ผ๋ฉด:
-
์์ฑ์ ๊ตฌ์ฑํ ์ ์์ผ๋ฉด,
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
๊ทธ๋ ์ง ์์ผ๋ฉด, O์์ ํด๋น ์์ฑ์ ์ ๊ฑฐํฉ๋๋ค.
-
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
3.9.5. [[PreventExtensions]]
๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์ [[PreventExtensions]] ๋ด๋ถ ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
false ๋ฅผ ๋ฐํํฉ๋๋ค.
์ฐธ๊ณ : ์ด๋ ๊ฒ ํ๋ฉด ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด๊ฐ [[PreventExtensions]]๊ฐ ์คํจํ๋๋ก ๋ง๋ค์ด ๊ณ์ ํ์ฅ ๊ฐ๋ฅํ๊ฒ ์ ์ง๋ฉ๋๋ค.
3.9.6. [[OwnPropertyKeys]]
์ด ๋ฌธ์๋ ํ๋ซํผ ๊ฐ์ฒด๊ฐ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ ๋ (๋๋ ์์ธ๋ฅผ ๋ํ๋ด๋ ํ๋ซํผ ๊ฐ์ฒด์ ๋ํด) ์ ์ฒด ํ๋กํผํฐ ์ด๊ฑฐ ์์๋ฅผ ์ ์ํ์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด์ ๋ํด์๋ ์๋์ ๊ฐ์ด [[OwnPropertyKeys]] ๋ด๋ถ ๋ฉ์๋๋ฅผ ์ ์ํฉ๋๋ค.
๋ ๊ฑฐ์ ํ๋ซํผ ๊ฐ์ฒด O์ [[OwnPropertyKeys]] ๋ด๋ถ ๋ฉ์๋๊ฐ ํธ์ถ๋ ๋, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
keys๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ String๊ณผ Symbol ๊ฐ์ ๋น ๋ชฉ๋ก์ผ๋ก ์์ฑํฉ๋๋ค.
-
O๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ฉด, ๊ฐ O์ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค index์ ๋ํด, ์ซ์ ์ค๋ฆ์ฐจ์์ผ๋ก append ! ToString(index)์ keys์ ์ถ๊ฐํฉ๋๋ค.
-
O๊ฐ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ง์ํ๋ฉด, ๊ฐ O์ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ P ์ค ์ด๋ฆ ํ๋กํผํฐ ๊ฐ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋ผ visibleํ ๊ฒ์ ๋ํด, append P๋ฅผ keys์ ์ถ๊ฐํฉ๋๋ค.
-
๊ฐ O์ own ํ๋กํผํฐ ํค ์ค String ํ์ P์ ๋ํด, ํ๋กํผํฐ ์์ฑ ์๊ฐ ์ค๋ฆ์ฐจ์์ผ๋ก append P๋ฅผ keys์ ์ถ๊ฐํฉ๋๋ค.
-
๊ฐ O์ own ํ๋กํผํฐ ํค ์ค Symbol ํ์ P์ ๋ํด, ํ๋กํผํฐ ์์ฑ ์๊ฐ ์ค๋ฆ์ฐจ์์ผ๋ก append P๋ฅผ keys์ ์ถ๊ฐํฉ๋๋ค.
-
๋จ์ธ: keys์๋ ์ค๋ณต ํญ๋ชฉ์ด ์๋ค.
-
keys๋ฅผ ๋ฐํํฉ๋๋ค.
3.9.7. ์ถ์ ์ฐ์ฐ
ํ๋กํผํฐ ์ด๋ฆ P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ธ์ง ํ๋จํ๊ธฐ ์ํด, ๋ค์ ์๊ณ ๋ฆฌ์ฆ์ ์ ์ฉํ๋ค:
-
P๊ฐ ๋ฌธ์์ด์ด ์๋๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
index๋ฅผ CanonicalNumericIndexString(P)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
index๊ฐ
undefined ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
IsInteger(index)๊ฐ
false ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
index๊ฐ โ0์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
index < 0์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
index โฅ 232 โ 1์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค.์ฐธ๊ณ : 232 โ 1์ ์๋ฐ์คํฌ๋ฆฝํธ์์ ํ์ฉ๋๋ ์ต๋ ๋ฐฐ์ด ๊ธธ์ด์ ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
๋ช
๋ช
๋
์์ฑ ๊ฐ์์ฑ ์๊ณ ๋ฆฌ์ฆ์
์ฃผ์ด์ง ๋ช
๋ช
๋ ์์ฑ์ด ๊ฐ์ฒด์ ๋
ธ์ถ๋๋์ง ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
์ผ๋ถ ๋ช
๋ช
๋ ์์ฑ์
[LegacyOverrideBuiltIns]
ํ์ฅ
์์ฑ์ด ์ฌ์ฉ๋์๋์ง์ ๋ฐ๋ผ ๊ฐ์ฒด์ ๋
ธ์ถ๋์ง ์์ต๋๋ค.
์๊ณ ๋ฆฌ์ฆ์ ์์ฑ ์ด๋ฆ P์ ๊ฐ์ฒด O๋ฅผ ์ฌ์ฉํ์ฌ ๋ค์๊ณผ ๊ฐ์ด ๋์ํฉ๋๋ค:
-
P๊ฐ O์ ์ง์๋๋ ์์ฑ ์ด๋ฆ์ด ์๋๋ฉด, false๋ฅผ ๋ฐํํฉ๋๋ค.
-
O์ ์ด๋ฆ์ด P์ธ ๊ณ ์ ์์ฑ์ด ์์ผ๋ฉด, false๋ฅผ ๋ฐํํฉ๋๋ค.
์ฐธ๊ณ : ์ฌ๊ธฐ์๋ O์ ์์กฐ ๋ถ๊ฐ๋ฅํ ์์ฑ์ด ์๋ ๊ฒฝ์ฐ๋ ํฌํจ๋ฉ๋๋ค. ์ค์ ๋ก ์ด๋ฌํ ์์ฑ์ ๊ฐ์ฒด์ ์ง์๋๋ ์์ฑ ์ด๋ฆ์ด ์๊ธฐ๊ธฐ ์ ์ ํญ์ ์ค์ ๋๋ฉฐ, ์ผ๋จ ์ค์ ๋๋ฉด ํด๋น ๋ช ๋ช ๋ ์์ฑ์ด ๋ณด์ด์ง ์๊ฒ ๋๊ธฐ ๋๋ฌธ์ ๋๋ค.
-
O๊ฐ [
LegacyOverrideBuiltIns] ํ์ฅ ์์ฑ์ด ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด, true๋ฅผ ๋ฐํํฉ๋๋ค. -
prototype์ O.[[GetPrototypeOf]]()๋ก ๋ก๋๋ค.
-
prototype์ด null์ด ์๋ ๋์:
-
prototype์ด ๋ช ๋ช ๋ ์์ฑ ๊ฐ์ฒด๊ฐ ์๋๊ณ , prototype์ ์ด๋ฆ์ด P์ธ ๊ณ ์ ์์ฑ์ด ์์ผ๋ฉด, false๋ฅผ ๋ฐํํฉ๋๋ค.
-
prototype์ prototype.[[GetPrototypeOf]]()๋ก ์ค์ ํฉ๋๋ค.
-
-
true๋ฅผ ๋ฐํํฉ๋๋ค.
์ด ์๊ณ ๋ฆฌ์ฆ์ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ๊ฐ์ง ๊ฐ์ฒด์ ํ๋กํผํฐ ํด์ ์์๊ฐ ๋ค์๊ณผ ๊ฐ์ด ์ด๋ฃจ์ด์ง๋๋ก ๋ณด์ฅํฉ๋๋ค:
-
์ธ๋ฑ์ค ํ๋กํผํฐ.
-
own ํ๋กํผํฐ(์์กฐ ๋ถ๊ฐ ์์ฑ๊ณผ ์ฐ์ฐ ํฌํจ).
-
[
LegacyOverrideBuiltIns]์ด ์ง์ ๋ ๊ฒฝ์ฐ:-
์ด๋ฆ ํ๋กํผํฐ.
-
ํ๋กํ ํ์ ์ฒด์ธ์์ ์ค๋ ํ๋กํผํฐ.
-
-
[
LegacyOverrideBuiltIns]์ด ์๋ ๊ฒฝ์ฐ:-
ํ๋กํ ํ์ ์ฒด์ธ์์ ์ค๋ ํ๋กํผํฐ.
-
์ด๋ฆ ํ๋กํผํฐ.
-
ํ๋ซํผ ๊ฐ์ฒด O์์ ํ๋กํผํฐ ์ด๋ฆ P์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ก ์ธ๋ฑ์ค ํ๋กํผํฐ setter ํธ์ถ์ ํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
index๊ฐ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค๊ฐ ์๋๋ฉด creating์ true๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ก ์ค์ ํฉ๋๋ค.
-
operation์ ์ธ๋ฑ์ค ํ๋กํผํฐ setter๋ฅผ ์ ์ธํ operation์ผ๋ก ์ค์ ํฉ๋๋ค.
-
T๋ฅผ operation์ ๋ ๋ฒ์งธ ์ธ์์ ํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ V๋ฅผ T ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
operation์ด ์๋ณ์ ์์ด ์ ์๋์ด ์๋ค๋ฉด:
-
creating์ด true์ด๋ฉด ์ธํฐํ์ด์ค ์ค๋ช ์ ๋ฐ๋ผ ์ ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ์ค์ ๋จ๊ณ(์ธ๋ฑ์ค index, ๊ฐ value)๋ฅผ ์ํํฉ๋๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ(creating์ด false) ์ธํฐํ์ด์ค ์ค๋ช ์ ๋ฐ๋ผ ๊ธฐ์กด ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ์ค์ ๋จ๊ณ(์ธ๋ฑ์ค index, ๊ฐ value)๋ฅผ ์ํํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, operation์ด ์๋ณ์์ ํจ๊ป ์ ์๋์ด ์๋ค๋ฉด ๋ฉ์๋ ๋จ๊ณ๋ฅผ operation์ ๋ํด O๋ฅผ this๋ก, ์ธ์๊ฐ ยซ index, value ยป๋ก ์คํํฉ๋๋ค.
ํ๋ซํผ ๊ฐ์ฒด O์์ ํ๋กํผํฐ ์ด๋ฆ P์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ V๋ก ์ด๋ฆ ํ๋กํผํฐ setter ํธ์ถ์ ํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
creating์ P๊ฐ ์ง์๋๋ ํ๋กํผํฐ ์ด๋ฆ์ด ์๋๋ฉด true๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉด false๋ก ์ค์ ํฉ๋๋ค.
-
operation์ ์ด๋ฆ ํ๋กํผํฐ setter๋ฅผ ์ ์ธํ operation์ผ๋ก ์ค์ ํฉ๋๋ค.
-
T๋ฅผ operation์ ๋ ๋ฒ์งธ ์ธ์์ ํ์ ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ V๋ฅผ T ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
operation์ด ์๋ณ์ ์์ด ์ ์๋์ด ์๋ค๋ฉด:
-
creating์ด true์ด๋ฉด ์ธํฐํ์ด์ค ์ค๋ช ์ ๋ฐ๋ผ ์ ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ์ค์ ๋จ๊ณ(P, value)๋ฅผ ์ํํฉ๋๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ(creating์ด false) ์ธํฐํ์ด์ค ์ค๋ช ์ ๋ฐ๋ผ ๊ธฐ์กด ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ์ค์ ๋จ๊ณ(P, value)๋ฅผ ์ํํฉ๋๋ค.
-
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, operation์ด ์๋ณ์์ ํจ๊ป ์ ์๋์ด ์๋ค๋ฉด ๋ฉ์๋ ๋จ๊ณ๋ฅผ operation์ ๋ํด O๋ฅผ this๋ก, ์ธ์๊ฐ ยซ P, value ยป๋ก ์คํํฉ๋๋ค.
LegacyPlatformObjectGetOwnProperty ์ถ์ ์ฐ์ฐ์ ๊ฐ์ฒด O, ํ๋กํผํฐ ์ด๋ฆ P, ๋ถ๋ฆฌ์ธ ignoreNamedProps ๊ฐ์ ๋ฐ์ ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค:
-
O๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ๋ฅผ ์ง์ํ๊ณ , P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค๋ผ๋ฉด:
-
index๊ฐ ์ง์๋๋ ํ๋กํผํฐ ์ธ๋ฑ์ค๋ผ๋ฉด:
-
operation์ ์ธ๋ฑ์ค ํ๋กํผํฐ getter๋ฅผ ์ ์ธํ operation์ผ๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
operation์ด ์๋ณ์ ์์ด ์ ์๋์ด ์๋ค๋ฉด value๋ฅผ ์ธํฐํ์ด์ค ์ค๋ช ์ ๋ฐ๋ผ ์ธ๋ฑ์ค ํ๋กํผํฐ ๊ฐ ๊ฒฐ์ (index)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, operation์ด ์๋ณ์์ ํจ๊ป ์ ์๋์ด ์๋ค๋ฉด value๋ฅผ ๋ฉ์๋ ๋จ๊ณ๋ฅผ operation์ ๋ํด O๋ฅผ this๋ก, ์ธ์๊ฐ ยซ index ยป๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
desc๋ฅผ ํ๋๊ฐ ์๋ ์๋ก์ด ํ๋กํผํฐ ๋์คํฌ๋ฆฝํฐ(Property Descriptor)๋ก ์์ฑํฉ๋๋ค.
-
desc.[[Value]]๋ฅผ value๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
O๊ฐ ์ธ๋ฑ์ค ํ๋กํผํฐ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด desc.[[Writable]]์
true ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดfalse ๋ก ์ค์ ํฉ๋๋ค. -
desc.[[Enumerable]] ๋ฐ desc.[[Configurable]]์
true ๋ก ์ค์ ํฉ๋๋ค. -
desc๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
ignoreNamedProps๋ฅผ true๋ก ์ค์ ํฉ๋๋ค.
-
O๊ฐ ์ด๋ฆ ํ๋กํผํฐ๋ฅผ ์ง์ํ๊ณ , ignoreNamedProps๊ฐ false์ด๋ฉด:
-
์ด๋ฆ ํ๋กํผํฐ ๊ฐ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ํ๋กํผํฐ ์ด๋ฆ P์ ๊ฐ์ฒด O๋ก ์คํํ ๊ฒฐ๊ณผ๊ฐ true์ด๋ฉด:
-
operation์ ์ด๋ฆ ํ๋กํผํฐ getter๋ฅผ ์ ์ธํ operation์ผ๋ก ์ค์ ํฉ๋๋ค.
-
value๋ฅผ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
operation์ด ์๋ณ์ ์์ด ์ ์๋์ด ์๋ค๋ฉด value๋ฅผ ์ธํฐํ์ด์ค ์ค๋ช ์ ๋ฐ๋ผ ์ด๋ฆ ํ๋กํผํฐ ๊ฐ ๊ฒฐ์ (P)์ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, operation์ด ์๋ณ์์ ํจ๊ป ์ ์๋์ด ์๋ค๋ฉด value๋ฅผ ๋ฉ์๋ ๋จ๊ณ๋ฅผ operation์ ๋ํด O๋ฅผ this๋ก, ์ธ์๊ฐ ยซ P ยป๋ก ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
desc๋ฅผ ํ๋๊ฐ ์๋ ์๋ก์ด ํ๋กํผํฐ ๋์คํฌ๋ฆฝํฐ(Property Descriptor)๋ก ์์ฑํฉ๋๋ค.
-
desc.[[Value]]๋ฅผ value๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
O๊ฐ ์ด๋ฆ ํ๋กํผํฐ setter๊ฐ ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด desc.[[Writable]]์
true ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดfalse ๋ก ์ค์ ํฉ๋๋ค. -
O๊ฐ [
LegacyUnenumerableNamedProperties] ํ์ฅ ์์ฑ์ด ์๋ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ฉด desc.[[Enumerable]]์false ๋ก, ๊ทธ๋ ์ง ์์ผ๋ฉดtrue ๋ก ์ค์ ํฉ๋๋ค. -
desc.[[Configurable]]์
true ๋ก ์ค์ ํฉ๋๋ค. -
desc๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
-
OrdinaryGetOwnProperty(O, P)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10. ๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด
๊ด์ฐฐ ๊ฐ๋ฅํ
๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด๋ ์๋ฐ์คํฌ๋ฆฝํธ์
ํ๋ก์(Proxy) ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ํ ์ข
๋ฅ๋ก,
์ด ์ ์์ ์ ์๋ ํ๋ก์ ํธ๋ฉ์ ์ฌ์ฉํด ์์ฑ๋ฉ๋๋ค. ์๋ฐ์คํฌ๋ฆฝํธ ๋ช
์ธ๋
ํ๋ก์ ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด๊ฐ Array ์ธ์คํด์ค๋ฅผ ํ๋ก์ ๋์์ผ๋ก ๊ฐ์ง ๋ ํน๋ณ ์ฒ๋ฆฌ๋ฅผ ํฌํจํ๋ฏ๋ก,
๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด
ํ์
์ด ์๋ฐ์คํฌ๋ฆฝํธ ์ฝ๋์ ์ด๋ฌํ ํน๋ณ ์ฒ๋ฆฌ๊ฐ ์ ์ง๋ ์ฑ ๋
ธ์ถ๋๋๋ก ํ๊ธฐ ์ํด ์ด๋ ๊ฒ ์ ์ํฉ๋๋ค.
๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ํ๋ก์ ํธ๋ฉ์ ์ผ๋ฐ Array ์ธ์คํด์ค์ ๋ถ๋ณ์ฑ ์ธ์๋ ๋ค์์ ๋ถ๋ณ์ฑ์ ๋ณด์ฅํฉ๋๋ค:
-
๋ฐฐ์ด์ ๊ตฌ๋ฉ(hole)์ด ์์ด, 0๋ถํฐ
observableArray.lengthโ 1 ์ฌ์ด ๋ชจ๋ ํ๋กํผํฐ๊ฐ ์ง์ ๋ Web IDL ํ์ ์ ํธํ๋๋ ๊ฐ์ผ๋ก ์ฑ์์ง๋๋ค. ํด๋น ๋ฒ์๋ฅผ ๋ฒ์ด๋๋ ๋ฐฐ์ด ์ธ๋ฑ์ค ํ๋กํผํฐ๋ ์กด์ฌํ์ง ์์ต๋๋ค. -
์ค์ํ ํ๋กํผํฐ์ ํ๋กํผํฐ ๋์คํฌ๋ฆฝํฐ๋ ๊ธฐ๋ณธ ์ค์ ์์ ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค. ์ธ๋ฑ์ค ํ๋กํผํฐ๋ ํญ์ configurable, enumerable, writable ๋ฐ์ดํฐ ํ๋กํผํฐ๋ก ์ ์ง๋๊ณ ,
lengthํ๋กํผํฐ๋ non-configurable, non-enumerable, writable ๋ฐ์ดํฐ ํ๋กํผํฐ๋ก ์ ์ง๋ฉ๋๋ค. -
Object.preventExtensions()๋ฑ์ผ๋ก ๋ฐฐ์ด์ ์ถ๊ฐ ํ๋กํผํฐ๊ฐ ์ถ๊ฐ๋๋ ๊ฒ์ ๋ง์ ์ ์์ต๋๋ค.
-
innerArray๋ฅผ ! ArrayCreate(0)์ผ๋ก ๋๋ค.
-
handler๋ฅผ OrdinaryObjectCreate(
null , ยซ [[Type]], [[SetAlgorithm]], [[DeleteAlgorithm]], [[BackingList]] ยป)๋ก ๋๋ค. -
handler.[[Type]]์ T๋ก ์ค์ ํ๋ค.
-
handler.[[SetAlgorithm]]์ setAlgorithm์ผ๋ก ์ค์ ํ๋ค.
-
handler.[[DeleteAlgorithm]]์ deleteAlgorithm์ผ๋ก ์ค์ ํ๋ค.
-
defineProperty๋ฅผ CreateBuiltinFunction(ยงโฏ3.10.1 defineProperty์ ๋จ๊ณ, 3, "", ยซ ยป, realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
defineProperty", defineProperty)๋ฅผ ์คํํ๋ค. -
deleteProperty๋ฅผ CreateBuiltinFunction(ยงโฏ3.10.2 deleteProperty์ ๋จ๊ณ, 2, "", ยซ ยป, realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
deleteProperty", deleteProperty)๋ฅผ ์คํํ๋ค. -
get์ CreateBuiltinFunction(ยงโฏ3.10.3 get์ ๋จ๊ณ, 3, "", ยซ ยป, realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
get", get)์ ์คํํ๋ค. -
getOwnPropertyDescriptor๋ฅผ CreateBuiltinFunction(ยงโฏ3.10.4 getOwnPropertyDescriptor์ ๋จ๊ณ, 2, "", ยซ ยป, realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
getOwnPropertyDescriptor", getOwnPropertyDescriptor)๋ฅผ ์คํํ๋ค. -
has๋ฅผ CreateBuiltinFunction(ยงโฏ3.10.5 has์ ๋จ๊ณ, 2, "", ยซ ยป, realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
has", has)๋ฅผ ์คํํ๋ค. -
ownKeys๋ฅผ CreateBuiltinFunction(ยงโฏ3.10.6 ownKeys์ ๋จ๊ณ, 1, "", ยซ ยป, realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
ownKeys", ownKeys)๋ฅผ ์คํํ๋ค. -
preventExtensions๋ฅผ CreateBuiltinFunction(ยงโฏ3.10.7 preventExtensions์ ๋จ๊ณ, ยซ ยป, 0, "", realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
preventExtensions", preventExtensions)๋ฅผ ์คํํ๋ค. -
set์ CreateBuiltinFunction(ยงโฏ3.10.8 set์ ๋จ๊ณ, ยซ ยป, 4, "", realm)๋ก ๋๋ค.
-
! CreateDataPropertyOrThrow(handler, "
set", set)์ ์คํํ๋ค. -
! ProxyCreate(innerArray, handler)๋ฅผ ๋ฐํํ๋ค.
3.10.1. defineProperty
defineProperty ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O, P,
descriptorObj๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
descriptor๋ฅผ ! ToPropertyDescriptor(descriptorObj)๋ก ์ค์ ํฉ๋๋ค.
-
P๊ฐ "length"์ด๋ฉด:
-
IsAccessorDescriptor(descriptor) ๊ฐ์ด
true ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Configurable]]๊ฐ ์กด์ฌํ๊ณ ๊ฐ์ด
true ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Enumerable]]๊ฐ ์กด์ฌํ๊ณ ๊ฐ์ด
true ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Writable]]๊ฐ ์กด์ฌํ๊ณ ๊ฐ์ด
false ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Value]]๊ฐ ์กด์ฌํ๋ฉด ๊ธธ์ด ์ค์ ์๊ณ ๋ฆฌ์ฆ์ handler, descriptor.[[Value]]๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด:
-
IsAccessorDescriptor(descriptor) ๊ฐ์ด
true ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Configurable]]๊ฐ ์กด์ฌํ๊ณ ๊ฐ์ด
false ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Enumerable]]๊ฐ ์กด์ฌํ๊ณ ๊ฐ์ด
false ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Writable]]๊ฐ ์กด์ฌํ๊ณ ๊ฐ์ด
false ์ด๋ฉดfalse ๋ฅผ ๋ฐํํฉ๋๋ค. -
descriptor.[[Value]]๊ฐ ์กด์ฌํ๋ฉด ์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ์ handler, P, descriptor.[[Value]]๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
? O.[[DefineOwnProperty]](P, descriptor)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.2. deleteProperty
deleteProperty ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O, P๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
P๊ฐ "length"์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด:
-
oldLen์ handler.[[BackingList]]์ ํฌ๊ธฐ๋ก ์ค์ ํฉ๋๋ค.
-
index โ oldLen โ 1์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
handler.[[DeleteAlgorithm]] ์๊ณ ๋ฆฌ์ฆ ๋จ๊ณ๋ฅผ handler.[[BackingList]][index]์ index๋ก ์คํํฉ๋๋ค.
-
handler.[[BackingList]]์ ๋ง์ง๋ง ์์ดํ ์ ์ ๊ฑฐํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
? O.[[Delete]](P)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.3.
get
get ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O, P, Receiver๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
length๋ฅผ handler.[[BackingList]]์ ํฌ๊ธฐ๋ก ์ค์ ํฉ๋๋ค.
-
P๊ฐ "length"์ด๋ฉด length๋ฅผ ๋ฐํํฉ๋๋ค.
-
P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด:
-
? O.[[Get]](P, Receiver)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.4. getOwnPropertyDescriptor
getOwnPropertyDescriptor ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O, P๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
length๋ฅผ handler.[[BackingList]]์ ํฌ๊ธฐ๋ก ์ค์ ํฉ๋๋ค.
-
P๊ฐ "length"์ด๋ฉด ! FromPropertyDescriptor(PropertyDescriptor{[[Configurable]]:
false , [[Enumerable]]:false , [[Writable]]:true , [[Value]]: length })๋ฅผ ๋ฐํํฉ๋๋ค. -
P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด
-
index โฅ length์ด๋ฉด
undefined ๋ฅผ ๋ฐํํฉ๋๋ค. -
jsValue๋ฅผ ๋ณํ ํ์ฌ ์ป์ handler.[[BackingList]][index]์ JavaScript ๊ฐ์ผ๋ก ํ๋ค.
-
์ ๋จ๊ณ๋ ์ ๋ ์์ธ๋ฅผ ๋ฐ์์ํค์ง ์์ต๋๋ค.
-
FromPropertyDescriptor(PropertyDescriptor{[[Configurable]]:
true , [[Enumerable]]:true , [[Writable]]:true , [[Value]]: jsValue })๋ฅผ ๋ฐํํฉ๋๋ค.
-
FromPropertyDescriptor(? O.[[GetOwnProperty]](P))๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.5.
has
has ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O, P๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
P๊ฐ "length"์ด๋ฉด
true ๋ฅผ ๋ฐํํฉ๋๋ค. -
P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด:
-
? O.[[HasProperty]](P)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.6.
ownKeys
ownKeys ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
length๋ฅผ handler.[[BackingList]]์ ํฌ๊ธฐ๋ก ์ค์ ํฉ๋๋ค.
-
keys๋ฅผ ๋น ๋ชฉ๋ก์ผ๋ก ์ค์ ํฉ๋๋ค.
-
i๋ฅผ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
While i < length ๋์:
-
CreateArrayFromList(keys)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.7. preventExtensions
preventExtensions ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด):
-
false ๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.8.
set
set ํ๋ก์ ํธ๋ฉ์ ๋จ๊ณ(๊ด์ฐฐ ๊ฐ๋ฅํ ๋ฐฐ์ด ์ด๊ทธ์กฐํฑ ๊ฐ์ฒด์ ๋ํด, O, P, V,
Receiver๊ฐ ์ฃผ์ด์ง ๊ฒฝ์ฐ):
-
handler๋ฅผ
this ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค. -
P๊ฐ "length"์ด๋ฉด ๊ธธ์ด ์ค์ ์๊ณ ๋ฆฌ์ฆ์ handler, V๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
P๊ฐ ๋ฐฐ์ด ์ธ๋ฑ์ค์ด๋ฉด ์ธ๋ฑ์ค ๊ฐ ์ค์ ์๊ณ ๋ฆฌ์ฆ์ handler, P, V๋ก ์คํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
? O.[[Set]](P, V, Receiver)๋ฅผ ๋ฐํํฉ๋๋ค.
3.10.9. ์ถ์ ์ฐ์ฐ
-
uint32Len โ numberLen์ด๋ฉด
RangeError์์ธ๋ฅผ throwํฉ๋๋ค. -
oldLen์ handler.[[BackingList]]์ ํฌ๊ธฐ๋ก ์ค์ ํฉ๋๋ค.
-
uint32Len > oldLen์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
indexToDelete๋ฅผ oldLen โ 1๋ก ์ค์ ํฉ๋๋ค.
-
While indexToDelete โฅ uint32Len ๋์:
-
handler.[[DeleteAlgorithm]] ์๊ณ ๋ฆฌ์ฆ ๋จ๊ณ๋ฅผ handler.[[BackingList]][indexToDelete]์ indexToDelete๋ก ์คํํฉ๋๋ค.
-
handler.[[BackingList]]์ ๋ง์ง๋ง ์์ดํ ์ ์ ๊ฑฐํฉ๋๋ค.
-
indexToDelete๋ฅผ indexToDelete โ 1๋ก ์ค์ ํฉ๋๋ค.
-
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
-
oldLen์ handler.[[BackingList]]์ ํฌ๊ธฐ๋ก ์ค์ ํฉ๋๋ค.
-
index > oldLen์ด๋ฉด
false ๋ฅผ ๋ฐํํฉ๋๋ค. -
idlValue๋ฅผ V๋ฅผ handler.[[Type]] ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
index < oldLen์ด๋ฉด:
-
handler.[[DeleteAlgorithm]] ์๊ณ ๋ฆฌ์ฆ ๋จ๊ณ๋ฅผ handler.[[BackingList]][index]์ index๋ก ์คํํฉ๋๋ค.
-
-
handler.[[SetAlgorithm]] ์๊ณ ๋ฆฌ์ฆ ๋จ๊ณ๋ฅผ idlValue์ index๋ก ์คํํฉ๋๋ค.
-
index = oldLen์ด๋ฉด idlValue๋ฅผ handler.[[BackingList]]์ ์ถ๊ฐํฉ๋๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, handler.[[BackingList]][index]๋ฅผ idlValue๋ก ์ค์ ํฉ๋๋ค.
-
true ๋ฅผ ๋ฐํํฉ๋๋ค.
3.11. ์ฝ๋ฐฑ ์ธํฐํ์ด์ค
ยงโฏ2.12 ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฐ์ฒด์์ ์ค๋ช ํ ๊ฒ์ฒ๋ผ, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ ์คํฌ๋ฆฝํธ์์ ์์์ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ก ๊ตฌํ๋ ์ ์์ต๋๋ค. ์๋์ ๊ฒฝ์ฐ๋ค์ ์ฃผ์ด์ง ๊ฐ์ฒด์์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์ ์ฐ์ฐ์ด ์ด๋ป๊ฒ ํธ์ถ๋๋์ง ์ค๋ช ํฉ๋๋ค:
-
๊ฐ์ฒด๊ฐ ํธ์ถ ๊ฐ๋ฅ(callable)ํ๋ฉด, ์ฐ์ฐ์ ๊ตฌํ์ฒด๋ ๊ทธ ํธ์ถ ๊ฐ๋ฅํ ๊ฐ์ฒด ์์ฒด์ ๋๋ค.
-
๊ทธ ์ธ์ ๊ฒฝ์ฐ, ์ฐ์ฐ์ ๊ตฌํ์ฒด๋ ๊ฐ์ฒด์ ๋ด๋ถ [[Get]] ๋ฉ์๋๋ฅผ ์ฐ์ฐ์ ์๋ณ์๋ฅผ ํ๋กํผํฐ ์ด๋ฆ์ผ๋ก ํ์ฌ ํธ์ถํ ๊ฒฐ๊ณผ๋ฅผ ํธ์ถํ๋ ๊ฒ์ ๋๋ค.
์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ ํด๋น ๊ฐ์ฒด๊ฐ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผ๋๊ธฐ ์ํด ๊ทธ ์ธํฐํ์ด์ค์ ์ ์ธ๋ ์์์ ํด๋นํ๋ ํ๋กํผํฐ๋ฅผ ๊ฐ์ง ํ์๊ฐ ์์ต๋๋ค.
Web IDL ์ธ์ ๋ฆฌ์คํธ๋ ๊ฐ ๊ฐ์ด IDL ๊ฐ์ด๊ฑฐ๋ โ๋๋ฝ(missing)โ์ด๋ผ๋ ํน์ ๊ฐ(์ ํ์ ์ธ์๊ฐ ๋๋ฝ๋จ์ ๋ํ๋)์ธ ๊ฐ ๋ชฉ๋ก(list)์ ๋๋ค.
-
jsArgs๋ฅผ ๋น ๋ชฉ๋ก์ผ๋ก ์์ฑํฉ๋๋ค.
-
i๋ฅผ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
count๋ฅผ 0์ผ๋ก ์ค์ ํฉ๋๋ค.
-
i < args์ ํฌ๊ธฐ์ธ ๋์:
-
args[i]๊ฐ ํน์ ๊ฐ โmissingโ์ด๋ฉด, jsArgs์
undefined ๋ฅผ ์ถ๊ฐํฉ๋๋ค. -
๊ทธ ์ธ์ ๊ฒฝ์ฐ, args[i]๋ IDL ๊ฐ์ ๋๋ค:
-
convertResult๋ฅผ args[i]๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ์์ธ๊ฐ ๋ฐ์ํ๋ฉด ๋ค์ throwํฉ๋๋ค.
-
convertResult๋ฅผ jsArgs์ ์ถ๊ฐํฉ๋๋ค.
-
count๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
i๋ฅผ i + 1๋ก ์ค์ ํฉ๋๋ค.
-
-
jsArgs๋ฅผ count ๊ฐ์ ํญ๋ชฉ๋ง ๋จ๋๋ก ์๋ผ๋ ๋๋ค.
-
jsArgs๋ฅผ ๋ฐํํฉ๋๋ค.
์ฌ์ฉ์ ๊ฐ์ฒด์ ์ฐ์ฐ ํธ์ถํ๊ธฐ: ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ํ์ ๊ฐ value, ์ฐ์ฐ ์ด๋ฆ opName, Web IDL ์ธ์ ๋ฆฌ์คํธ args, ์ ํ์ ์ฝ๋ฐฑ this ๊ฐ thisArg๊ฐ ์ฃผ์ด์ก์ ๋, ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค. ์ด ๋จ๊ณ๋ค์ IDL ๊ฐ์ ๋ฐํํ๊ฑฐ๋ ์์ธ๋ฅผ throwํฉ๋๋ค.
-
completion์ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
thisArg๊ฐ ์ฃผ์ด์ง์ง ์์๋ค๋ฉด thisArg๋ฅผ
undefined ๋ก ์ค์ ํฉ๋๋ค. -
O๋ฅผ value์ ํด๋นํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
realm์ O์ ์ฐ๊ฒฐ๋ realm์ผ๋ก ์ค์ ํฉ๋๋ค.
-
relevant settings๋ฅผ realm์ ์ค์ ๊ฐ์ฒด(settings object)๋ก ์ค์ ํฉ๋๋ค.
-
stored settings๋ฅผ value์ ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ก ์ค์ ํฉ๋๋ค.
-
์คํฌ๋ฆฝํธ ์คํ ์ค๋น๋ฅผ relevant settings๋ก ์คํํฉ๋๋ค.
-
์ฝ๋ฐฑ ์คํ ์ค๋น๋ฅผ stored settings๋ก ์คํํฉ๋๋ค.
-
X๋ฅผ O๋ก ์ค์ ํฉ๋๋ค.
-
IsCallable(O)๊ฐ false์ด๋ฉด:
-
getResult๋ฅผ Completion(Get(O, opName))๋ก ์ค์ ํฉ๋๋ค.
-
getResult๊ฐ ๋น์ ์ ์๋ฃ(abrupt completion)์ด๋ฉด, completion์ getResult๋ฅผ ํ ๋นํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
X๋ฅผ getResult.[[Value]]๋ก ์ค์ ํฉ๋๋ค.
-
IsCallable(X)๊ฐ
false ์ด๋ฉด, completion์ Completion Record { [[Type]]: throw, [[Value]]: ์๋ก ์์ฑ๋TypeError๊ฐ์ฒด, [[Target]]: ๋น ๊ฐ }๋ก ์ค์ ํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค. -
thisArg๋ฅผ O๋ก ์ค์ ํฉ๋๋ค(์ฃผ์ด์ง ๊ฐ์ ๋ฎ์ด์).
-
-
jsArgs๋ฅผ args๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ์ธ์ ๋ฆฌ์คํธ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณํ ์ค ์์ธ ๋ฐ์ ์, completion์ ์์ธ๋ฅผ ๋ํ๋ด๋ completion ๊ฐ์ผ๋ก ์ค์ ํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
callResult๋ฅผ Completion(Call(X, thisArg, jsArgs))๋ก ์ค์ ํฉ๋๋ค.
-
callResult๊ฐ ๋น์ ์ ์๋ฃ(abrupt completion)์ด๋ฉด completion์ callResult๋ฅผ ํ ๋นํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
completion์ callResult.[[Value]]๋ฅผ ์ฐ์ฐ์ ๋ฐํ ํ์ ๊ณผ ๋์ผํ ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณํ ์ค ์์ธ ๋ฐ์ ์ completion์ ์์ธ๋ฅผ ๋ํ๋ด๋ completion ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
Return: ์ด ์์ ์์ completion์ IDL ๊ฐ์ด๊ฑฐ๋ ๋น์ ์ ์๋ฃ์.
-
์ฝ๋ฐฑ ์คํ ํ ์ ๋ฆฌ(clean up)๋ฅผ stored settings๋ก ์คํํฉ๋๋ค.
-
์คํฌ๋ฆฝํธ ์คํ ํ ์ ๋ฆฌ(clean up)๋ฅผ relevant settings๋ก ์คํํฉ๋๋ค.
-
completion์ด IDL ๊ฐ์ด๋ฉด completion์ ๋ฐํํฉ๋๋ค.
-
completion์ด ๋น์ ์ ์๋ฃ์ด๊ณ , ์ฐ์ฐ์ด ๋ฐํ ํ์ ์ด ํ๋ผ๋ฏธ์ค ํ์ ์ด ์๋ ๊ฒฝ์ฐ, completion.[[Value]]๋ฅผ throwํฉ๋๋ค.
-
rejectedPromise๋ฅผ ! Call(
%Promise.reject%,%Promise%, ยซcompletion.[[Value]]ยป)๋ก ์ค์ ํฉ๋๋ค. -
rejectedPromise๋ฅผ ์ฐ์ฐ์ ๋ฐํ ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
3.11.1. ๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด
ํน์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค๊ฐ ํน์ realm์ ๋ ธ์ถ๋๊ณ , ํด๋น ์ธํฐํ์ด์ค์ ์์๊ฐ ์ ์๋์ด ์๋ค๋ฉด, ๋์ํ๋ ํ๋กํผํฐ๊ฐ ๊ทธ realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ์กด์ฌํฉ๋๋ค. ํ๋กํผํฐ ์ด๋ฆ์ ํด๋น ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์ ์๋ณ์์ด๋ฉฐ, ๊ทธ ๊ฐ์ ๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด์ ๋๋ค.
ํน์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค์ ๋ํ ๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด๋ ๋ด์ฅ ํจ์ ๊ฐ์ฒด์ ๋๋ค. ํด๋น ๊ฐ์ฒด์๋ ๊ทธ ์ธํฐํ์ด์ค์ ์ ์๋ ์์์ ๋์ํ๋ ํ๋กํผํฐ๊ฐ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ยงโฏ3.7.5 ์์ ์ฐธ๊ณ .
์ฐธ๊ณ : ๋ ๊ฑฐ์ ์ฝ๋ฐฑ
์ธํฐํ์ด์ค ๊ฐ์ฒด๋ ํจ์ ๊ฐ์ฒด์ด๋ฏ๋ก,
typeof ์ฐ์ฐ์๋ฅผ ๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด์ ์ ์ฉํ๋ฉด "function"์ด ๋ฐํ๋ฉ๋๋ค.
ํน์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค interface ์ ๋ํด ์๋ณ์ id ์ realm realm ์ด ์ฃผ์ด์ก์ ๋, ๋ ๊ฑฐ์ ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ฒด ๋ฅผ ์์ฑ ํ๋ ์ ์ฐจ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-
steps๋ฅผ ๋ค์ ๋จ๊ณ๋ก ๋๋ค:
-
F๋ฅผ CreateBuiltinFunction(steps, 0, id, ยซ ยป, realm)์ ๊ฒฐ๊ณผ๋ก ๋๋ค.
-
์์ ์ ์๋ฅผ interface์ F, realm์ ๋ํด ์ํํ๋ค.
-
F๋ฅผ ๋ฐํํ๋ค.
3.12. ์ฝ๋ฐฑ ํจ์ ํธ์ถํ๊ธฐ
์๋ฐ์คํฌ๋ฆฝํธ ํธ์ถ ๊ฐ๋ฅ(callable) ๊ฐ์ฒด๊ฐ ์ฝ๋ฐฑ ํจ์ ๊ฐ์ผ๋ก ์ฌ์ฉ๋ ๋๋, ์ฝ๋ฐฑ ์ธํฐํ์ด์ค ๊ฐ์ ์ฐ์ฐ์ ํธ์ถํ๋ ๋ฐฉ์(์ด์ ์น์ ์ฐธ์กฐ)๊ณผ ์ ์ฌํ๊ฒ ํธ์ถ๋ฉ๋๋ค.
์ฝ๋ฐฑ ํจ์ ํ์
๊ฐ
callable์ Web IDL ์ธ์ ๋ฆฌ์คํธ args, ์์ธ ๋์
exceptionBehavior("report" ๋๋ "rethrow")์ ์ ํ์ ์ฝ๋ฐฑ this
๊ฐ thisArg๋ก ์ฝ๋ฐฑ ํจ์ ํธ์ถํ๊ธฐ:
๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค. ์ด ๋จ๊ณ๋ IDL ๊ฐ์ ๋ฐํํ๊ฑฐ๋ ์์ธ๋ฅผ throwํฉ๋๋ค.
exceptionBehavior ์ธ์๋ callable์ ๋ฐํ ํ์
์ด ํ๋ผ๋ฏธ์ค ํ์
์ด ์๋ ๋๋ง ์ ๊ณต๋์ด์ผ ํ๋ฉฐ, callable์ ๋ฐํ ํ์
์ด undefined
๋๋ any๊ฐ ์๋๋ผ๋ฉด
๋ฐ๋์ "rethrow"์ฌ์ผ ํฉ๋๋ค.
rethrow"๊ฐ ๊ณต๊ธ๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผํด์ผ ํฉ๋๋ค.
-
completion์ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
thisArg๊ฐ ์ฃผ์ด์ง์ง ์์๋ค๋ฉด thisArg๋ฅผ
undefined ๋ก ์ค์ ํฉ๋๋ค. -
F๋ฅผ callable์ ํด๋นํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
IsCallable(F)๊ฐ
false ์ด๋ฉด:-
์ฐธ๊ณ : ์ด๊ฒ์ ์ฝ๋ฐฑ ํจ์๊ฐ [
LegacyTreatNonObjectAsNull] ํน์ฑ์ด ๋ถ์ attribute์์ ์จ ๊ฒฝ์ฐ์๋ง ๋ฐ์ํ ์ ์์ต๋๋ค. -
undefined ๋ฅผ ์ฝ๋ฐฑ ํจ์์ ๋ฐํ ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
-
realm์ F์ ์ฐ๊ฒฐ๋ realm์ผ๋ก ์ค์ ํฉ๋๋ค.
-
relevant settings๋ฅผ realm์ ์ค์ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
stored settings๋ฅผ callable์ ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ก ์ค์ ํฉ๋๋ค.
-
์คํฌ๋ฆฝํธ ์คํ ์ค๋น๋ฅผ relevant settings๋ก ์คํํฉ๋๋ค.
-
์ฝ๋ฐฑ ์คํ ์ค๋น๋ฅผ stored settings๋ก ์คํํฉ๋๋ค.
-
jsArgs๋ฅผ args๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ์ธ์ ๋ฆฌ์คํธ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณํ ์ค ์์ธ๊ฐ ๋ฐ์ํ๋ฉด completion์ ์์ธ๋ฅผ ๋ํ๋ด๋ completion ๊ฐ์ผ๋ก ์ค์ ํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
callResult๋ฅผ Completion(Call(F, thisArg, jsArgs))๋ก ์ค์ ํฉ๋๋ค.
-
callResult๊ฐ ๋น์ ์ ์๋ฃ(abrupt completion)์ด๋ฉด completion์ callResult๋ก ์ค์ ํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
completion์ callResult.[[Value]]๋ฅผ callable์ ๋ฐํ ํ์ ๊ณผ ๋์ผํ ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณํ ์ค ์์ธ๊ฐ ๋ฐ์ํ๋ฉด completion์ ์์ธ๋ฅผ ๋ํ๋ด๋ completion ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
Return: ์ด ์์ ์์ completion์ IDL ๊ฐ์ด๊ฑฐ๋ ๋น์ ์ ์๋ฃ์ ๋๋ค.
-
์ฝ๋ฐฑ ์คํ ํ ์ ๋ฆฌ(clean up)๋ฅผ stored settings๋ก ์คํํฉ๋๋ค.
-
์คํฌ๋ฆฝํธ ์คํ ํ ์ ๋ฆฌ(clean up)๋ฅผ relevant settings๋ก ์คํํฉ๋๋ค.
-
completion์ด IDL ๊ฐ์ด๋ฉด completion์ ๋ฐํํฉ๋๋ค.
-
๋จ์ธ: completion์ ๋น์ ์ ์๋ฃ์ด๋ค.
-
exceptionBehavior๊ฐ "
rethrow"์ด๋ฉด completion.[[Value]]๋ฅผ throwํฉ๋๋ค. -
๊ทธ ์ธ exceptionBehavior๊ฐ "
report"์ผ ๊ฒฝ์ฐ:-
๋จ์ธ: callable์ ๋ฐํ ํ์ ์
undefined๋๋any์ด๋ค. -
์์ธ ๋ณด๊ณ ๋ฅผ completion.[[Value]]์ ๋ํด realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด๋ก ์คํํฉ๋๋ค.
-
์ ์ผํ
undefinedIDL ๊ฐ์ ๋ฐํํฉ๋๋ค.
-
-
๋จ์ธ: callable์ ๋ฐํ ํ์ ์ ํ๋ผ๋ฏธ์ค ํ์ ์ด๋ค.
-
rejectedPromise๋ฅผ ! Call(
%Promise.reject%,%Promise%, ยซcompletion.[[Value]]ยป)๋ก ์ค์ ํฉ๋๋ค. -
rejectedPromise๋ฅผ ์ฝ๋ฐฑ ํจ์์ ๋ฐํ ํ์ ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
-
์ผ๋ถ ์ฝ๋ฐฑ ํจ์๋ ์์ฑ์(constructor)๋ก ์ฌ์ฉ๋ ์ ์์ต๋๋ค. ์ด๋ฐ ์ฝ๋ฐฑ ํจ์๋ ํ๋ผ๋ฏธ์ค ํ์ ๋ฐํ ํ์ ์ ๊ฐ์ง ์์์ผ ํฉ๋๋ค.
์ฝ๋ฐฑ ํจ์ ํ์ ๊ฐ callable์ Web IDL ์ธ์ ๋ฆฌ์คํธ args๋ก ์ฝ๋ฐฑ ํจ์ ์์ฑ์ ํธ์ถ์ ํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ์ํํฉ๋๋ค. ์ด ๋จ๊ณ๋ IDL ๊ฐ์ ๋ฐํํ๊ฑฐ๋ ์์ธ๋ฅผ throwํฉ๋๋ค.
-
completion์ ์ด๊ธฐํ๋์ง ์์ ๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
F๋ฅผ callable์ ํด๋นํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
IsConstructor(F)๊ฐ
false ์ด๋ฉดTypeError์์ธ๋ฅผ throwํฉ๋๋ค. -
realm์ F์ ์ฐ๊ฒฐ๋ realm์ผ๋ก ์ค์ ํฉ๋๋ค.
-
relevant settings๋ฅผ realm์ ์ค์ ๊ฐ์ฒด๋ก ์ค์ ํฉ๋๋ค.
-
stored settings๋ฅผ callable์ ์ฝ๋ฐฑ ์ปจํ ์คํธ๋ก ์ค์ ํฉ๋๋ค.
-
์คํฌ๋ฆฝํธ ์คํ ์ค๋น๋ฅผ relevant settings๋ก ์คํํฉ๋๋ค.
-
์ฝ๋ฐฑ ์คํ ์ค๋น๋ฅผ stored settings๋ก ์คํํฉ๋๋ค.
-
jsArgs๋ฅผ args๋ฅผ ์๋ฐ์คํฌ๋ฆฝํธ ์ธ์ ๋ฆฌ์คํธ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณํ ์ค ์์ธ๊ฐ ๋ฐ์ํ๋ฉด completion์ ์์ธ๋ฅผ ๋ํ๋ด๋ completion ๊ฐ์ผ๋ก ์ค์ ํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
callResult๋ฅผ Completion(Construct(F, jsArgs))๋ก ์ค์ ํฉ๋๋ค.
-
callResult๊ฐ ๋น์ ์ ์๋ฃ(abrupt completion)์ด๋ฉด completion์ callResult๋ก ์ค์ ํ๊ณ return ๋จ๊ณ๋ก ์ ํํฉ๋๋ค.
-
completion์ callResult.[[Value]]๋ฅผ callable์ ๋ฐํ ํ์ ๊ณผ ๋์ผํ ํ์ ์ IDL ๊ฐ์ผ๋ก ๋ณํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค. ๋ณํ ์ค ์์ธ๊ฐ ๋ฐ์ํ๋ฉด completion์ ์์ธ๋ฅผ ๋ํ๋ด๋ completion ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค.
-
Return: ์ด ์์ ์์ completion์ IDL ๊ฐ์ด๊ฑฐ๋ ๋น์ ์ ์๋ฃ์ ๋๋ค.
-
์ฝ๋ฐฑ ์คํ ํ ์ ๋ฆฌ(clean up)๋ฅผ stored settings๋ก ์คํํฉ๋๋ค.
-
์คํฌ๋ฆฝํธ ์คํ ํ ์ ๋ฆฌ(clean up)๋ฅผ relevant settings๋ก ์คํํฉ๋๋ค.
-
completion์ด ๋น์ ์ ์๋ฃ์ด๋ฉด completion.[[Value]]๋ฅผ throwํฉ๋๋ค.
-
completion์ ๋ฐํํฉ๋๋ค.
-
3.13. ๋ค์์คํ์ด์ค
ํน์ ๋ค์์คํ์ด์ค๊ฐ ํน์ realm์ ๋ ธ์ถ๋๋ ๊ฒฝ์ฐ, ํด๋น realm์ ๊ธ๋ก๋ฒ ๊ฐ์ฒด์ ๋์ํ๋ ํ๋กํผํฐ๊ฐ ์กด์ฌํฉ๋๋ค. ํ๋กํผํฐ ์ด๋ฆ์ ๋ค์์คํ์ด์ค์ ์๋ณ์์ด๊ณ , ๊ฐ์ ๋ค์์คํ์ด์ค ๊ฐ์ฒด๋ผ ๋ถ๋ฅด๋ ๊ฐ์ฒด์ ๋๋ค.
๋ค์์คํ์ด์ค ๊ฐ์ฒด์ ํน์ฑ์ ยงโฏ3.13.1 ๋ค์์คํ์ด์ค ๊ฐ์ฒด์์ ์ค๋ช ํฉ๋๋ค.
3.13.1. ๋ค์์คํ์ด์ค ๊ฐ์ฒด
ํน์ ๋ค์์คํ์ด์ค namespace์ realm realm์ ๋ํด ๋ค์์คํ์ด์ค ๊ฐ์ฒด๋ ๋ค์๊ณผ ๊ฐ์ด ์์ฑ๋ฉ๋๋ค:
-
namespaceObject๋ฅผ OrdinaryObjectCreate(realm.[[Intrinsics]].[[
%Object.prototype%]])๋ก ์์ฑํฉ๋๋ค. -
์ ๊ท ์์ฑ ์ ์ ์๊ณ ๋ฆฌ์ฆ์ namespace, namespaceObject, realm์ ๋ํด ์คํํฉ๋๋ค.
-
์ ๊ท ์ฐ์ฐ ์ ์ ์๊ณ ๋ฆฌ์ฆ์ namespace, namespaceObject, realm์ ๋ํด ์คํํฉ๋๋ค.
-
์์ ์ ์ ์๊ณ ๋ฆฌ์ฆ์ namespace, namespaceObject, realm์ ๋ํด ์คํํฉ๋๋ค.
-
๊ฐ ๋ ธ์ถ๋ ์ธํฐํ์ด์ค interface ์ค, [
LegacyNamespace] ํ์ฅ ์์ฑ์ด ์๊ณ , ๊ทธ ์ธ์๊ฐ namespace์ ์๋ณ์์ธ ๊ฒฝ์ฐ:-
id๋ฅผ interface์ ์๋ณ์๋ก ์ค์ ํฉ๋๋ค.
-
interfaceObject๋ฅผ ์ธํฐํ์ด์ค ๊ฐ์ฒด ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ interface, id, realm์ ๋ํด ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
DefineMethodProperty(namespaceObject, id, interfaceObject, false)๋ฅผ ์คํํฉ๋๋ค.
-
-
namespaceObject๋ฅผ ๋ฐํํฉ๋๋ค.
๋ค์์คํ์ด์ค ๊ฐ์ฒด์ class string์ ๋ค์์คํ์ด์ค์ ์๋ณ์์ ๋๋ค.
3.14. ์์ธ
3.14.1.
DOMException
์ปค์คํ
๋ฐ์ธ๋ฉ
JavaScript ๋ฐ์ธ๋ฉ์์, DOMException์
๋ํ ์ธํฐํ์ด์ค ํ๋กํ ํ์
๊ฐ์ฒด๋
๊ทธ [[Prototype]] ๋ด๋ถ ์ฌ๋กฏ์ด, ์ธํฐํ์ด์ค
ํ๋กํ ํ์
๊ฐ์ฒด ์์ฑ ์ถ์
์ฐ์ฐ์์ ์ ์๋ ๋๋ก, ๊ณ ์ ๊ฐ์ฒด %Error.prototype%์ผ๋ก
์ค์ ๋๋ค.
๋ํ ๋ชจ๋ ๋ด์ฅ ์์ธ์ฒ๋ผ [[ErrorData]] ๋ฐ [[Stack]] ์ฌ๋กฏ๋ ๊ฐ์ง๋ค.
์ถ๊ฐ๋ก, ๊ตฌํ์ด ๋ค์ดํฐ๋ธ Error
๊ฐ์ฒด์ ๊ทธ ๋ฐ์ ํน๋ณํ ๊ธฐ๋ฅ์ด๋
๋นํ์ค ์์ฑ(line ๋ฐ column ์์ฑ ๋ฑ)์ ์ ๊ณตํ๋ค๋ฉด,
๊ทธ๊ฒ๋ค๋ DOMException
๊ฐ์ฒด์ ๋
ธ์ถํด์ผ ํ๋ค.
3.14.2. ์์ธ ๊ฐ์ฒด
๋จ์ ์์ธ๋ ํด๋น ํ์ ์ ๋ค์ดํฐ๋ธ ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ฒด๋ก ํํ๋ฉ๋๋ค.
DOMException์
ํ๋ซํผ ๊ฐ์ฒด๋ก ํํ๋๋ฉฐ,
DOMException
์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํฉ๋๋ค.
3.14.3. ์์ธ ์์ฑ ๋ฐ throw
-
message๋ฅผ ์์ธ ์ํฉ์ ์ ํฉํ ๊ตฌํ์ฒด ์ ์(implementation-defined) ๋ฉ์์ง๋ก ์ค์ ํฉ๋๋ค. ํธ์ถ ๋ช ์ธ๊ฐ ๊ตฌํ์ฒด๊ฐ ๋ฉ์์ง๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐ ์ฐธ๊ณ ํ ์ ์๋ ์ ๋ณด๋ฅผ ํฌํจํ ์ ์์ต๋๋ค.
๊ตฌํ์ฒด๋ ๋ฏผ๊ฐํ๊ฑฐ๋ ๋ณด์ ์ ๋ณด๊ฐ ๋์ถ๋์ง ์๋๋ก ์ฃผ์ํด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ํฌ๋ก์ค ์ค๋ฆฌ์ง ํ๋ ์์ URL, ์ฌ์ฉ์๋ฅผ ์๋ณํ ์ ์๋ ์ ๋ณด ๋ฑ์ด ํฌํจ๋์ง ์์์ผ ํฉ๋๋ค.
-
args๋ฅผ ยซ message ยป๋ก ์ค์ ํฉ๋๋ค.
-
constructor๋ฅผ ํ์ฌ realm.[[Intrinsics]].[[%T%]]๋ก ์ค์ ํฉ๋๋ค.
DOMException์
์์ธ ์์ฑ ์๊ณ ๋ฆฌ์ฆ(name:
name):
-
๋จ์ธ: name์ด
DOMException์ด๋ฆ ํ ์ด๋ธ์ ํฌํจ๋์ด ์๋ค. -
ex๋ฅผ new
DOMException์ผ๋ก ํ์ฌ realm์์ ์์ฑํฉ๋๋ค. -
ex์ name์ name์ผ๋ก ์ค์ ํฉ๋๋ค.
-
ex์ message๋ฅผ ์์ธ ์ํฉ์ ์ ํฉํ ๊ตฌํ์ฒด ์ ์ ๋ฉ์์ง๋ก ์ค์ ํฉ๋๋ค. ํธ์ถ ๋ช ์ธ๊ฐ ๊ตฌํ์ฒด๊ฐ ๋ฉ์์ง๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐ ์ฐธ๊ณ ํ ์ ์๋ ์ ๋ณด๋ฅผ ํฌํจํ ์ ์์ต๋๋ค.
๊ตฌํ์ฒด๋ ๋ฏผ๊ฐํ๊ฑฐ๋ ๋ณด์ ์ ๋ณด๊ฐ ๋์ถ๋์ง ์๋๋ก ์ฃผ์ํด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ํฌ๋ก์ค ์ค๋ฆฌ์ง ํ๋ ์์ URL, ์ฌ์ฉ์๋ฅผ ์๋ณํ ์ ์๋ ์ ๋ณด ๋ฑ์ด ํฌํจ๋์ง ์์์ผ ํฉ๋๋ค.
-
ex๋ฅผ ๋ฐํํฉ๋๋ค.
DOMException
ํ์ ์ธํฐํ์ด์ค์ ์์ธ ์์ฑ
์๊ณ ๋ฆฌ์ฆ(์ธํฐํ์ด์ค ์๋ณ์ type, ์ถ๊ฐ ์ด๊ธฐํ ์ง์นจ ํฌํจ):
-
ex๋ฅผ new type ์ธํฐํ์ด์ค์ ์ธ์คํด์ค๋ก ํ์ฌ realm์์ ์์ฑํฉ๋๋ค.
-
ex์ name์ type์ผ๋ก ์ค์ ํฉ๋๋ค.
-
ex์ message๋ฅผ ์์ธ ์ํฉ์ ์ ํฉํ ๊ตฌํ์ฒด ์ ์ ๋ฉ์์ง๋ก ์ค์ ํฉ๋๋ค. ํธ์ถ ๋ช ์ธ๊ฐ ๊ตฌํ์ฒด๊ฐ ๋ฉ์์ง๋ฅผ ๊ตฌ์ฑํ๋ ๋ฐ ์ฐธ๊ณ ํ ์ ์๋ ์ ๋ณด๋ฅผ ํฌํจํ ์ ์์ต๋๋ค.
๊ตฌํ์ฒด๋ ๋ฏผ๊ฐํ๊ฑฐ๋ ๋ณด์ ์ ๋ณด๊ฐ ๋์ถ๋์ง ์๋๋ก ์ฃผ์ํด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ํฌ๋ก์ค ์ค๋ฆฌ์ง ํ๋ ์์ URL, ์ฌ์ฉ์๋ฅผ ์๋ณํ ์ ์๋ ์ ๋ณด ๋ฑ์ด ํฌํจ๋์ง ์์์ผ ํฉ๋๋ค.
-
ํธ์ถ์๊ฐ ๊ธฐ์ ํ ์ถ๊ฐ ์ด๊ธฐํ ์์ ์ ex์ ๋ํด ์ํํฉ๋๋ค.
-
ex๋ฅผ ๋ฐํํฉ๋๋ค.
-
O๋ฅผ ๋์ผํ ์ธ์๋ก ์์ธ ์์ฑ ์๊ณ ๋ฆฌ์ฆ์ ์คํํ ๊ฒฐ๊ณผ๋ก ์ค์ ํฉ๋๋ค.
-
O๋ฅผ throwํฉ๋๋ค.
์ ์๊ณ ๋ฆฌ์ฆ์ ์์ธ๋ฅผ ๋ํ๋ด๋ ๊ฐ์ฒด๊ฐ ํจ์ ๊ฐ์ฒด ๋ฐ์ผ๋ก ์ ํ๋ ๋, ๊ทธ realm๊ณผ ์ฐ๊ฒฐ๋ ๊ฒ๋ค๋ก ์ ํํ๋ค. ์ด๋ ํด๋น ํจ์ ๊ฐ์ฒด์ realm(์ฆ, ํจ์๊ฐ ์คํ๋๋ ์์ ์ ํ์ฌ realm)์ด๋ค. ์๋ฅผ ๋ค์ด, ๋ค์ IDL์ ์๊ฐํด ๋ณด์:
[Exposed =Window ]interface MathUtils { // x๊ฐ ์์๋ฉด, "NotSupportedError" DOMException์ throwํฉ๋๋ค.double computeSquareRoot (double x ); };
myMU๊ฐ ๋ค๋ฅธ realm์์ ์จ MathUtils ๊ฐ์ฒด๋ผ๋ฉด, ๋ฉ์๋๋ฅผ ํธ์ถํ ๋ throw๋ ์์ธ๋ ํด๋น ๋ฉ์๋์ realm์์ ์์ฑ๋ ์์ธ๊ฐ
๋ฉ๋๋ค:
const myMU= window. getMathUtils(); // ์ด realm์ MathUtils ๊ฐ์ฒด const otherMU= otherWindow. getMathUtils(); // ๋ค๋ฅธ realm์ MathUtils ๊ฐ์ฒด myMUinstanceof Object; // true otherMUinstanceof Object; // false otherMUinstanceof otherWindow. Object; // true try { otherMU. doComputation. call( myMU, - 1 ); } catch ( e) { console. assert( ! ( einstanceof DOMException)); console. assert( einstanceof otherWindow. DOMException); }
3.14.4. ์์ธ ์ฒ๋ฆฌ
๋ณ๋๋ก ๋ช ์๋์ง ์๋ ํ, ๋ณธ ๋ฌธ์์ ์๊ตฌ์ฌํญ์ ๋ฐ๋ผ ์๋ฐ์คํฌ๋ฆฝํธ ๋ฐํ์ ์๋ฏธ๋ก ์ด ํธ์ถ๋๊ณ ์์ธ๊ฐ throw๋์ด ์ข ๋ฃ๋ ๋, ํด๋น ์์ธ๋ ํธ์ถ์์๊ฒ ์ ํ๋์ด์ผ ํ๋ฉฐ, ํธ์ถ์์์ ์กํ์ง ์์ผ๋ฉด ๊ทธ ์์ ํธ์ถ์์๊ฒ ๊ณ์ ์ ํ๋์ด์ผ ํฉ๋๋ค.
๋ฌธ์ ๊ท์ฝ์ ๋ฐ๋ผ, ๋ณธ ๋ฌธ์์์ ๋ช ์ธ๋ ์๊ณ ๋ฆฌ์ฆ์ throw๋ ์์ธ๋ฅผ ๊ฐ๋ก์ฑ๊ฑฐ๋, ์์ธ๊ฐ throw๋ ๊ฒฝ์ฐ์ ์ ํํ ์ฒ๋ฆฌ ๋จ๊ณ๋ฅผ ๋ช ์ํ๊ฑฐ๋, ๋น์ ์ ์๋ฃ(abrupt completion)์ ๋ช ์์ ์ผ๋ก ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
๋ค์ IDL ์กฐ๊ฐ(fragment)์
๋ ์ธํฐํ์ด์ค์ ํ๋์ ์์ธ๋ฅผ ์ ์ํฉ๋๋ค.
ExceptionThrower์ valueOf ์์ฑ์
๊ฐ์ ์ป์ผ๋ ค ํ ๋๋ง๋ค ์์ธ๋ฅผ throwํ๋๋ก ์ ์๋์ด ์์ต๋๋ค.
[Exposed =Window ]interface Dahut {attribute DOMString type ; }; [Exposed =Window ]interface ExceptionThrower { // ์ด ์์ฑ์ ํญ์ NotSupportedError๋ฅผ throwํ๋ฉฐ ๊ฐ์ ๋ฐํํ์ง ์์ต๋๋ค.attribute long valueOf ; };
์ด ์ธํฐํ์ด์ค๋ฅผ ์ง์ํ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๊ตฌํ์ฒด๊ฐ ์๋ค๊ณ ๊ฐ์ ํ ๋, ๋ค์ ์ฝ๋๋ ์์ธ๊ฐ ์ด๋ป๊ฒ ์ฒ๋ฆฌ๋๋์ง ๋ณด์ฌ์ค๋๋ค:
var d= getDahut(); // Dahut ์ธ์คํด์ค ์ป๊ธฐ var et= getExceptionThrower(); // ExceptionThrower ์ธ์คํด์ค ์ป๊ธฐ try { d. type= { toString: function () { throw "abc" ; } }; } catch ( e) { // ์ฌ๊ธฐ์ ๋ฌธ์์ด "abc"๊ฐ catch๋ฉ๋๋ค. ๋ค์ดํฐ๋ธ ๊ฐ์ฒด๋ฅผ ๋ฌธ์์ด๋ก ๋ณํํ๋ ๊ณผ์ ์์ // ์ต๋ช ํจ์๊ฐ ํธ์ถ๋๊ณ , [[DefaultValue]], ToPrimitive, ToString ์๊ณ ๋ฆฌ์ฆ์ // ์์ธ ์ฒ๋ฆฌ๋ฅผ catchํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค. } try { d. type= { toString: { } }; } catch ( e) { // ์ฌ๊ธฐ์ ์์ธ๊ฐ catch๋ฉ๋๋ค. ๋ค์ดํฐ๋ธ ๊ฐ์ฒด์ toString ํ๋กํผํฐ ๊ฐ์ ๋ํด // [[Call]]์ ์๋ํ๋ฉด์ ๋ฐ์ํฉ๋๋ค. } try { d. type= Symbol(); } catch ( e) { // ์ฌ๊ธฐ์ ์์ธ๊ฐ catch๋ฉ๋๋ค. Symbol ๊ฐ์ ๋ํด ์๋ฐ์คํฌ๋ฆฝํธ ToString ์ถ์ ์ฐ์ฐ์ ์๋ํ๊ณ ์๊ธฐ ๋๋ฌธ์ ๋๋ค. } d. type= et; // ์ฌ๊ธฐ์๋ ์กํ์ง ์์ "NotSupportedError" DOMException์ด throw๋ฉ๋๋ค. // [[DefaultValue]] ์๊ณ ๋ฆฌ์ฆ์ด ExceptionThrower ๊ฐ์ฒด์ "valueOf" ํ๋กํผํฐ ๊ฐ์ ์ป์ผ๋ ค ์๋ํ๊ธฐ ๋๋ฌธ์ ๋๋ค. // ์ด ์์ธ๋ ์ด ์ฝ๋ ๋ธ๋ก ๋ฐ์ผ๋ก ์ ํ๋ฉ๋๋ค.
4. ๊ณตํต ์ ์
์ด ์ ์์๋ ๋ชจ๋ ์ ํฉ ๊ตฌํ์ฒด๊ฐ ์ง์ํด์ผ ํ๋ ๋ช ๊ฐ์ง ๊ณตํต ์ ์๋ฅผ ๋ช ์ธํฉ๋๋ค.
4.1. ArrayBufferView
typedef (Int8Array or Int16Array or Int32Array or Uint8Array or Uint16Array or Uint32Array or Uint8ClampedArray or BigInt64Array or BigUint64Array or Float16Array or Float32Array or Float64Array or DataView )ArrayBufferView ;
ArrayBufferView
ํ์
์ ArrayBuffer๋
SharedArrayBuffer
([AllowShared]์ด
์ฌ์ฉ๋ ๋)์ ๋ํ ๋ทฐ๋ฅผ ์ ๊ณตํ๋ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
4.2. BufferSource
typedef (ArrayBuffer or ArrayBufferView )BufferSource ;
BufferSource
ํ์
์ ๊ฐ์ฒด ์์ฒด๊ฐ ArrayBuffer์ด๊ฑฐ๋,
ArrayBuffer์
๋ํ ๋ทฐ๋ฅผ ์ ๊ณตํ๋ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
์ฐธ๊ณ : [AllowShared]
๋ BufferSource์
ํจ๊ป ์ฌ์ฉํ ์ ์์ต๋๋ค.
ArrayBuffer๊ฐ
์ด๋ฅผ ์ง์ํ์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค.
๋์ AllowSharedBufferSource๋ฅผ
์ฌ์ฉํ์ธ์.
4.3. AllowSharedBufferSource
typedef (ArrayBuffer or SharedArrayBuffer or [AllowShared ]ArrayBufferView )AllowSharedBufferSource ;
AllowSharedBufferSource
ํ์
์ ๊ฐ์ฒด ์์ฒด๊ฐ ArrayBuffer์ด๊ฑฐ๋
SharedArrayBuffer์ด๊ฑฐ๋,
ArrayBuffer
๋๋ SharedArrayBuffer์
๋ํ ๋ทฐ๋ฅผ ์ ๊ณตํ๋ ๊ฐ์ฒด๋ฅผ ๋ํ๋ด๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
4.4. DOMException
DOMException
ํ์
์ ๋ค์ IDL ์กฐ๊ฐ์ผ๋ก ์ ์๋ ์ธํฐํ์ด์ค
ํ์
์
๋๋ค:
[Exposed=*,Serializable ]interface DOMException { // but see below note about JavaScript bindingconstructor (optional DOMString = "",message optional DOMString = "Error");name readonly attribute DOMString name ;readonly attribute DOMString message ;readonly attribute unsigned short code ;const unsigned short INDEX_SIZE_ERR = 1;const unsigned short = 2;DOMSTRING_SIZE_ERR const unsigned short HIERARCHY_REQUEST_ERR = 3;const unsigned short WRONG_DOCUMENT_ERR = 4;const unsigned short INVALID_CHARACTER_ERR = 5;const unsigned short = 6;NO_DATA_ALLOWED_ERR const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;const unsigned short NOT_FOUND_ERR = 8;const unsigned short NOT_SUPPORTED_ERR = 9;const unsigned short INUSE_ATTRIBUTE_ERR = 10;const unsigned short INVALID_STATE_ERR = 11;const unsigned short SYNTAX_ERR = 12;const unsigned short INVALID_MODIFICATION_ERR = 13;const unsigned short NAMESPACE_ERR = 14;const unsigned short INVALID_ACCESS_ERR = 15;const unsigned short = 16;VALIDATION_ERR const unsigned short TYPE_MISMATCH_ERR = 17;const unsigned short SECURITY_ERR = 18;const unsigned short NETWORK_ERR = 19;const unsigned short ABORT_ERR = 20;const unsigned short URL_MISMATCH_ERR = 21;const unsigned short QUOTA_EXCEEDED_ERR = 22;const unsigned short TIMEOUT_ERR = 23;const unsigned short INVALID_NODE_TYPE_ERR = 24;const unsigned short DATA_CLONE_ERR = 25; };
์ฐธ๊ณ : ยง 3.14.1 DOMException ์ฌ์ฉ์ ์ ์ ๋ฐ์ธ๋ฉ์์ ๋ ผ์ํ ๊ฒ์ฒ๋ผ, JavaScript ๋ฐ์ธ๋ฉ์ ์ธํฐํ์ด์ค ํ์ ์ ๋ํ ์ผ๋ฐ ์๊ตฌ์ฌํญ์ ๋์ด์๋ ์ถ๊ฐ ์๊ตฌ์ฌํญ์ ๋ถ๊ณผํ๋ค.
๊ฐ DOMException
๊ฐ์ฒด์๋ ์ฐ๊ด๋ name ๋ฐ
message๊ฐ ์์ผ๋ฉฐ, ๋ ๋ค ๋ฌธ์์ด์ด๋ค.
new DOMException(message, name)
์์ฑ์ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:
name ๊ฒํฐ ๋จ๊ณ๋
this์ name์ ๋ฐํํ๋ ๊ฒ์ด๋ค.
message ๊ฒํฐ ๋จ๊ณ๋
this์ message๋ฅผ ๋ฐํํ๋ ๊ฒ์ด๋ค.
code ๊ฒํฐ ๋จ๊ณ๋ this์
name์ ๋ํด
DOMException ์ด๋ฆ ํ์ ํ์๋ ๋ ๊ฑฐ์
์ฝ๋๋ฅผ ๋ฐํํ๊ฑฐ๋, ๊ทธ๋ฌํ ํญ๋ชฉ์ด ํ์ ์์ผ๋ฉด 0์ ๋ฐํํ๋ ๊ฒ์ด๋ค.
DOMException
๊ฐ์ฒด๋ ์ง๋ ฌํ ๊ฐ๋ฅ ๊ฐ์ฒด์ด๋ค.
value ๋ฐ serialized๊ฐ ์ฃผ์ด์ก์ ๋, ๊ทธ ์ง๋ ฌํ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:
- serialized.[[Name]]์ value์ name์ผ๋ก ์ค์ ํ๋ค.
- serialized.[[Message]]๋ฅผ value์ message๋ก ์ค์ ํ๋ค.
- serialized.[[Stack]]์ value.[[Stack]]์์ ํ์๋ ๊ตฌํ ์ ์ ๋ฌธ์์ด๋ก ์ค์ ํ๋ค.
- ์ฌ์ฉ์ ์์ด์ ํธ๋ ์์ง ๋ช
์๋์ง ์์ ๋ชจ๋ ๊ด์ฌ ์๋ ๋ถ์ ๋ฐ์ดํฐ, ํนํ
line๋ฐcolumn์์ฑ์ ์ง๋ ฌํ๋ ํํ์ serialized์ ์ฒจ๋ถํด์ผ ํ๋ค.
value ๋ฐ serialized๊ฐ ์ฃผ์ด์ก์ ๋, ๊ทธ ์ญ์ง๋ ฌํ ๋จ๊ณ๋ ๋ค์๊ณผ ๊ฐ๋ค:
- value์ name์ serialized.[[Name]]์ผ๋ก ์ค์ ํ๋ค.
- value์ message๋ฅผ serialized.[[Message]]๋ก ์ค์ ํ๋ค.
- value.[[Stack]]์ serialized.[[Stack]]์ผ๋ก ์ค์ ํ๋ค.
- ๋ค๋ฅธ ๋ฐ์ดํฐ๊ฐ serialized์ ์ฒจ๋ถ๋์ด ์์ผ๋ฉด, ๊ทธ๊ฒ์ ์ญ์ง๋ ฌํํ์ฌ value์ ์ฒจ๋ถํ๋ค.
4.5. Function
callback Function =any (any ...);arguments
Function ์ฝ๋ฐฑ ํจ์
ํ์
์ ์ธ์์ ์ด๋ค ์ ํ๋ ์์ผ๋ฉฐ ๋ฐํ๊ฐ๋ ์ ํ์ด ์๋ ํจ์ ๊ฐ์ ๋ํ๋ด๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
4.6. VoidFunction
callback VoidFunction =undefined ();
VoidFunction
์ฝ๋ฐฑ ํจ์
ํ์
์ ์ธ์๋ฅผ ๋ฐ์ง ์์ผ๋ฉฐ ๋ฐํ๊ฐ๋ ์๋ ํจ์ ๊ฐ์ ๋ํ๋ด๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
5. ํ์ฅ์ฑ
์ด ์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
์ธ์ด ๋ฐ์ธ๋ฉ ์๊ตฌ์ฌํญ์ ๋ํ ํ์ฅ์, ๋ณธ ๋ฌธ์์์ ์ ์๋ ๊ฒ๊ณผ ์ถฉ๋ํ์ง ์๋ ํ์ฅ ์์ฑ์ ์ฌ์ฉํ์ฌ ๋ช ์ธํ ์ ์์ต๋๋ค. ๊ฐ์ธ์ด๋ ํ๋ก์ ํธ๋ณ ์ฌ์ฉ์ ์ํ ํ์ฅ์ ๋ค๋ฅธ ๋ช ์ธ์ ๋์ค๋ IDL ์กฐ๊ฐ์ ํฌํจํ์ง ์์์ผ ํ๋ฉฐ, ๋ค๋ฅธ ๋ช ์ธ์์ ์ฌ์ฉ์ด ํ์ํ ํ์ฅ์ Web IDL ์์ ๊ทธ๋ฃน(์์ฑ ์์ ๊ธฐ์ค W3C Web Platform Working Group)๊ณผ ํ์ํ์ฌ ๋ณธ ๋ฌธ์์ ํฅํ ๋ฒ์ ์ ํฌํจ๋ ์ ์๋๋ก ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
IDL ์ธ์ด์ ๋ค๋ฅธ ์ธก๋ฉด์ ๋ํ ํ์ฅ์ ๊ฐ๋ ฅํ ๊ถ์ฅ๋์ง ์์ต๋๋ค.
6. ๋ ๊ฑฐ์ ๊ตฌ์ฑ ์์
์ด ์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
๋ ๊ฑฐ์ Web IDL ๊ตฌ์ฑ ์์๋ ์ค์ง ๋ ๊ฑฐ์ ์น ํ๋ซํผ ๊ธฐ๋ฅ์ ๋ช
์ธํ๊ธฐ ์ํด ์กด์ฌํฉ๋๋ค.
์ผ๋ฐ์ ์ผ๋ก "Legacy"๋ผ๋ ์ ๋์ฌ๊ฐ ๋ถ์ต๋๋ค.
๋ ๊ฑฐ์ Web IDL ๊ตฌ์ฑ ์์๋ ๋ ๊ฑฐ์ ์น ํ๋ซํผ ๊ธฐ๋ฅ์ ๋์์ ๋ช
์ธํ๊ธฐ ์ํด ํ์ํ๊ฑฐ๋ ํด๋น ๊ธฐ๋ฅ๊ณผ์ ์ผ๊ด์ฑ์ ์ํด์๋ง ๋ช
์ธ์์ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ฐ๋ ฅํ ๊ถ์ฅ๋ฉ๋๋ค.
๋ ๊ฑฐ์ Web IDL ๊ตฌ์ฑ ์์ ์ฌ์ฉ์ ์ํ๋ ํธ์ง์๋ ์งํ ์ ์ ์ด์๋ฅผ
๋ฑ๋กํ์ฌ ๋
ผ์ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๊ตฌ์ฑ ์์๋ฅผ ๋ ๊ฑฐ์๋ก ํ์ํ๋ ๊ฒ์ ๊ณง ๋ณธ ๋ฌธ์์์ ์ ๊ฑฐ๋ ๊ฒ์์ ์๋ฏธํ์ง๋ ์์ต๋๋ค. ๋ค๋ง, ์ด๊ฒ์ด ํฅํ ๋ณธ ๋ฌธ์์์ ์ ๊ฑฐ๋ ์ข์ ํ๋ณด์์ ์์ฌํ๋ฉฐ, ์ฌ๋ฌ ํด๋ฆฌ์คํฑ์ ๋ฐ๋ผ ํด๋น ๊ตฌ์ฑ ์์๊ฐ ๋ช ์ธํ๋ ค๋ ์น ํ๋ซํผ ๊ธฐ๋ฅ์ด ์์ ํ ์ ๊ฑฐ๋๊ฑฐ๋ ๋ ๊ฑฐ์ Web IDL ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ๋ ๋ช ์ธํ ์ ์๊ฒ ๋๋ฉด ์ ๊ฑฐ๋ ์ ์์์ ์๋ฏธํฉ๋๋ค.
7. ์ด ๋ช ์ธ ์ฐธ์กฐ
์ด ์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
์ฌ๋ฌ IDL ์กฐ๊ฐ์ ์ฌ์ฉํ์ฌ ์น ํ๋ซํผ ์ธํฐํ์ด์ค๋ฅผ ์ ์ํ๋ ๋ค๋ฅธ ๋ช ์ธ๋ค์ด ๋ณธ ๋ช ์ธ๋ฅผ ์ฐธ์กฐํ ๊ฒ์ผ๋ก ์์๋ฉ๋๋ค. ๊ทธ๋ฐ ๋ช ์ธ๋ค์ ์๋์ ๊ฐ์ ๋ฌธ์ฅ์ ํฌํจํ์ฌ, IDL์ด ๋ณธ ๋ช ์ธ์์ ์ค๋ช ํ ๋๋ก ํด์๋์ด์ผ ํจ์ ๋ช ์ํ๋ ๊ฒ์ด ์ข์ต๋๋ค:
์ด ๋ช ์ธ์ ๋ถ๋ก A์ ์๋ IDL ์กฐ๊ฐ์, ๋ณธ ๋ช ์ธ์ ๊ท๋ฒ์ ์ฐธ์กฐ์์ ์ ์๋ IDL ์กฐ๊ฐ๋ค๊ณผ ํจ๊ป, โWeb IDLโ ๋ช ์ธ์์ ์ค๋ช ํ ๋๋ก ์ ํฉํ IDL ์กฐ๊ฐ ์งํฉ์ ๋ํด ์๊ตฌ๋๋ ๋๋ก ํด์๋์ด์ผ ํ๋ค. [WEBIDL]
๋ํ, ์ฐธ์กฐ ๋ช ์ธ์์ ์ฌ์ฉ์ ์์ด์ ํธ์ ์ ํฉ์ฑ ํด๋์ค๋ ๋ณธ ๋ช ์ธ์ ์ ํฉ ๊ตฌํ์ฒด ํด๋์ค๋ก ์ฐ๊ฒฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค:
์ ํฉํ FooML ์ฌ์ฉ์ ์์ด์ ํธ๋ ๋ํ ๋ณธ ๋ช ์ธ์ ๋ถ๋ก A์ IDL ์กฐ๊ฐ์ ๋ํ ์ ํฉ ๊ตฌํ์ฒด์ฌ์ผ ํ๋ฉฐ, ์ด๋ โWeb IDLโ ๋ช ์ธ์์ ์ค๋ช ํ ๋๋ก ํด์๋์ด์ผ ํ๋ค. [WEBIDL]
8. ํ๋ผ์ด๋ฒ์ ๋ฐ ๋ณด์ ๊ณ ๋ ค์ฌํญ
์ด ๋ช ์ธ๋ ์๋ฐ์คํฌ๋ฆฝํธ์ IDL ๊ฐ ์ฌ์ด์ ๋ณํ ๊ณ์ธต์ ์ ์ํฉ๋๋ค. ์ด ๊ณ์ธต์ ์๋ชป ๊ตฌํํ๋ฉด ๋ณด์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
์ด ๋ช
์ธ๋ ๋ํ any ๋ฐ
object IDL
ํ์
์ ํตํด ์๋ฐ์คํฌ๋ฆฝํธ ๊ฐ์ ์ง์ ์ฌ์ฉํ ์ ์๋๋ก ํฉ๋๋ค. ์ด๋ฌํ ๊ฐ๋ค์ ๋ณด์ ๋ฌธ์ ๋ฅผ ํผํ๊ธฐ ์ํด ์ ์คํ๊ฒ ๋ค๋ฃจ์ด์ผ ํฉ๋๋ค. ํนํ, ์ฌ์ฉ์ ์คํฌ๋ฆฝํธ๋ ์ด๋ฌํ ๊ฐ์ ๊ฑฐ์ ๋ชจ๋ ์กฐ์์ ์๋ตํ์ฌ
์คํ๋ ์ ์์ผ๋ฉฐ, ์ด๋ฅผ ์ฌ์ฉํ๋ ๋ช
์ธ๋ ๊ตฌํ์ฒด์ ๊ธฐ๋์น๋ฅผ ๋ฌดํจํํ ์ ์์ต๋๋ค.
์ด ๋ช
์ธ๋ SharedArrayBuffer
๊ฐ์ฒด์์ ์ํธ์์ฉ๋ ๊ฐ๋ฅํ๊ฒ ํ๋๋ฐ, ์ด๋ฌํ ๊ฐ์ฒด๋ ํ์ด๋ฐ ๊ณต๊ฒฉ์ ๊ตฌ์ถํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ด ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ ๋ช
์ธ์์๋ ์ด๋ฌํ ๊ณต๊ฒฉ์ ๊ณ ๋ คํด์ผ ํฉ๋๋ค.
๊ฐ์ฌ์ ๊ธ
์ด ์ ์ ์ฐธ๊ณ ์ฉ์ ๋๋ค.
ํธ์ง์๋ค์ ๋ค์ ๋ถ๋ค๊ป ์ด ๋ช ์ธ์ ๊ธฐ์ฌํด ์ฃผ์ ๊ฒ์ ๋ํด ๊ฐ์ฌ์ ๋ง์์ ์ ํฉ๋๋ค: Glenn Adams, David Andersson, Jake Archibald, Tab Atkins-Bittner, L. David Baron, Art Barstow, Nils Barth, Robin Berjon, David Bruant, Jan-Ivar Bruaroey, Marcos Cรกceres, Giovanni Campagna, Franรงois Daoust, Domenic Denicola, Chris Dumez, Michael Dyck, Daniel Ehrenberg, Brendan Eich, Joรฃo Eiras, Gorm Haug Eriksen, Sigbjorn Finne, David Flanagan, Aryeh Gregor, Dimitry Golubovsky, James Graham, Aryeh Gregor, Tiancheng โTimothyโ Gu, Kartikaya Gupta, Marcin Hanclik, Jed Hartman, Stefan Haustein, Dominique Hazaรซl-Massieux, Ian Hickson, Bjรถrn Hรถhrmann, Kyle Huey, Lachlan Hunt, Oliver Hunt, Jim Jewett, Wolfgang Keller, Anne van Kesteren, Olav Junker Kjรฆr, Takayoshi Kochi, Magnus Kristiansen, Raphael Kubo da Costa, Takeshi Kurosawa, Yves Lafon, Travis Leithead, Jim Ley, Kevin Lindsey, Jens Lindstrรถm, Peter Linss, ๅๅบท่ฑช (Kang-Hao Lu), Kyle Machulis, Darien Maillet Valentine, Mark Miller, Ms2ger, Andrew Oakley, ๅฒกๅ ๅฒ็ด (Shiki Okasaka), Jason Orendorff, Olli Pettay, Simon Pieters, Andrei Popescu, Franรงois Remy, Tim Renouf, Jeremy Roman, Tim Ruffles, Alex Russell, Takashi Sakamoto, Doug Schepers, Jonas Sicking, Garrett Smith, Sam Sneddon, Jungkee Song, Josh Soref, Maciej Stachowiak, Austin Sullivan, Anton Tayanovskyy, triple-underscore, Peter Van der Beken, Jeff Walden, Allen Wirfs-Brock, Jeffrey Yasskin ๊ทธ๋ฆฌ๊ณ , Collin Xu.
ํธ์ง์๊ฐ ๋ช ์ธ ๊ด๋ฆฌ๋ฅผ ํ ์ ์์๋ ๊ธฐ๊ฐ ๋์ ์ด ๋ฌธ์๋ฅผ ๊ด๋ฆฌํด ์ค Sam Weinig์๊ฒ๋ ํน๋ณํ ๊ฐ์ฌ๋ฅผ ์ ํฉ๋๋ค.
์ด ํํ ํ์ค์ Edgar Chen (Mozilla, echen@mozilla.com)๊ณผ Tiancheng "Timothy" Gu (timothygu99@gmail.com)๊ฐ ์งํํ์์ผ๋ฉฐ, Boris Zbarsky (bzbarsky@mit.edu), Cameron McCormack (cam@mcc.id.au), ๊ทธ๋ฆฌ๊ณ Tobie Langel (tobie@unlockopen.com)์ ์ค์ํ ๊ธฐ์ฌ๊ฐ ์์์ต๋๋ค.
IDL ๋ฌธ๋ฒ
์ด ์ ์์๋ ์์ ๊ธฐํธ
๋ฌธ๋ฒ์ ๊ฐ ์์ฑ์(production)์ ์ค๋ฅธ์ชฝ์ 0์ด ์๋ ๊ฐ์์ ํฐ๋ฏธ๋๊ณผ ๋นํฐ๋ฏธ๋ ๊ธฐํธ๊ฐ ์๊ฑฐ๋, ๊ธฐํธ๊ฐ ์์์ ๋ํ๋ด๋ ์ก์ค๋ก (ฮต)์ด ์์ต๋๋ค. ๋๋ฌธ์๋ก ์์ํ๋ ๊ธฐํธ๋ ๋นํฐ๋ฏธ๋ ๊ธฐํธ์ ๋๋ค. ๊ณ ์ ํญ ๊ธ๊ผด๋ก ํ์๋๋ ๊ธฐํธ๋ ํฐ๋ฏธ๋ ๊ธฐํธ์ ๋๋ค. ์๋ฌธ์๋ก ์์ํ๋ ์ฐ์ธ๋ฆฌํ ๊ธ๊ผด์ ๊ธฐํธ๋ ํฐ๋ฏธ๋ ๊ธฐํธ๋ก, ๋ค์๊ณผ ๊ฐ์ด Perl 5 ์ ๊ทํํ์ ๋ฌธ๋ฒ([PERLRE])์ ์ฌ์ฉํด ๋งค์นญ๋ฉ๋๋ค:
=
|
/-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/
|
|
=
|
/-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/
|
|
=
|
/[_-]?[A-Za-z][0-9A-Z_a-z-]*/
|
|
=
|
/"[^"]*"/
|
|
=
|
/[\t\n\r ]+/
|
|
=
|
/\/\/.*|\/\*(.|\n)*?\*\//
|
|
=
|
/[^\t\n\r 0-9A-Za-z]/
|
ํ ํฌ๋์ด์ ๋ ์ค์นผ๋ผ ๊ฐ ์ํ์ค์ ๋ํด ๋์ํฉ๋๋ค.
ํ ํฌ๋์ด์งํ ๋๋ ๊ฐ๋ฅํ ๊ฐ์ฅ ๊ธด ์ผ์น ํญ๋ชฉ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ์
๋ ฅ ํ
์คํธ๊ฐ โa1โ์ด๋ฉด ํ๋์ long"์ด ์๋๋๋ค.
โ.โ๋ ํฐ๋ฏธ๋ ์ฌ๋ณผ
IDL ๋ฌธ๋ฒ์ ๊ณ ์ ํญ ํฐ๋ฏธ๋ ์ฌ๋ณผ๊ณผ A"์ธ ๊ฒ๊ณผ "a"์ธ ๊ฒ์ ๊ตฌ๋ถ๋ฉ๋๋ค. ๋ํ
ํ์ฅ ์์ฑ
[legacyfactoryfunction]์
[LegacyFactoryFunction]
ํ์ฅ ์์ฑ์ผ๋ก ์ธ์๋์ง ์์ต๋๋ค.
์์์ ์ผ๋ก, ํ์ฑ๋๋ ์
๋ ฅ ํ
์คํธ์ ๋ชจ๋ ํฐ๋ฏธ๋ ์ฌ์ด์๋ ์์ ๊ฐ์์
์๋์ LL(1) ๋ฌธ๋ฒ์
Definitions ::ExtendedAttributeList Definition Definitions ฮตDefinition ::CallbackOrInterfaceOrMixin Namespace Partial Dictionary Enum Typedef IncludesStatement ArgumentNameKeyword ::attribute callback const constructor deleter dictionary enum getter includes inherit interface iterable maplike mixin namespace partial readonly required setlike setter static stringifier typedef unrestricted CallbackOrInterfaceOrMixin ::callback CallbackRestOrInterface interface InterfaceOrMixin InterfaceOrMixin ::InterfaceRest MixinRest InterfaceRest ::identifier Inheritance { InterfaceMembers } ; Partial ::partial PartialDefinition PartialDefinition ::interface PartialInterfaceOrPartialMixin PartialDictionary Namespace PartialInterfaceOrPartialMixin ::PartialInterfaceRest MixinRest PartialInterfaceRest ::identifier { PartialInterfaceMembers } ; InterfaceMembers ::ExtendedAttributeList InterfaceMember InterfaceMembers ฮตInterfaceMember ::PartialInterfaceMember Constructor PartialInterfaceMembers ::ExtendedAttributeList PartialInterfaceMember PartialInterfaceMembers ฮตPartialInterfaceMember ::Const Operation Stringifier StaticMember Iterable AsyncIterable ReadOnlyMember ReadWriteAttribute ReadWriteMaplike ReadWriteSetlike InheritAttribute Inheritance ::: identifier ฮตMixinRest ::mixin identifier { MixinMembers } ; MixinMembers ::ExtendedAttributeList MixinMember MixinMembers ฮตMixinMember ::Const RegularOperation Stringifier OptionalReadOnly AttributeRest IncludesStatement ::identifier includes identifier ; CallbackRestOrInterface ::CallbackRest interface identifier { CallbackInterfaceMembers } ; CallbackInterfaceMembers ::ExtendedAttributeList CallbackInterfaceMember CallbackInterfaceMembers ฮตCallbackInterfaceMember ::Const RegularOperation Const ::const ConstType identifier = ConstValue ; ConstValue ::BooleanLiteral FloatLiteral integer BooleanLiteral ::true false FloatLiteral ::decimal -Infinity Infinity NaN ConstType ::PrimitiveType identifier ReadOnlyMember ::readonly ReadOnlyMemberRest ReadOnlyMemberRest ::AttributeRest MaplikeRest SetlikeRest ReadWriteAttribute ::AttributeRest InheritAttribute ::inherit AttributeRest AttributeRest ::attribute TypeWithExtendedAttributes AttributeName ; AttributeName ::AttributeNameKeyword identifier AttributeNameKeyword ::required OptionalReadOnly ::readonly ฮตDefaultValue ::ConstValue string [ ] { } null undefined Operation ::RegularOperation SpecialOperation RegularOperation ::Type OperationRest SpecialOperation ::Special RegularOperation Special ::getter setter deleter OperationRest ::OptionalOperationName ( ArgumentList ) ; OptionalOperationName ::OperationName ฮตOperationName ::OperationNameKeyword identifier OperationNameKeyword ::includes ArgumentList ::Argument Arguments ฮตArguments ::, Argument Arguments ฮตArgument ::ExtendedAttributeList ArgumentRest ArgumentRest ::optional TypeWithExtendedAttributes ArgumentName Default Type Ellipsis ArgumentName ArgumentName ::ArgumentNameKeyword identifier Ellipsis ::... ฮตConstructor ::constructor ( ArgumentList ) ; Stringifier ::stringifier StringifierRest StringifierRest ::OptionalReadOnly AttributeRest ; StaticMember ::static StaticMemberRest StaticMemberRest ::OptionalReadOnly AttributeRest RegularOperation Iterable ::iterable < TypeWithExtendedAttributes OptionalType > ; OptionalType ::, TypeWithExtendedAttributes ฮตAsyncIterable ::async_iterable < TypeWithExtendedAttributes OptionalType > OptionalArgumentList ; OptionalArgumentList ::( ArgumentList ) ฮตReadWriteMaplike ::MaplikeRest MaplikeRest ::maplike < TypeWithExtendedAttributes , TypeWithExtendedAttributes > ; ReadWriteSetlike ::SetlikeRest SetlikeRest ::setlike < TypeWithExtendedAttributes > ; Namespace ::namespace identifier { NamespaceMembers } ; NamespaceMembers ::ExtendedAttributeList NamespaceMember NamespaceMembers ฮตNamespaceMember ::RegularOperation readonly AttributeRest Const Dictionary ::dictionary identifier Inheritance { DictionaryMembers } ; DictionaryMembers ::DictionaryMember DictionaryMembers ฮตDictionaryMember ::ExtendedAttributeList DictionaryMemberRest DictionaryMemberRest ::required TypeWithExtendedAttributes identifier ; Type identifier Default ; PartialDictionary ::dictionary identifier { DictionaryMembers } ; Default ::= DefaultValue ฮตEnum ::enum identifier { EnumValueList } ; EnumValueList ::string EnumValueListComma EnumValueListComma ::, EnumValueListString ฮตEnumValueListString ::string EnumValueListComma ฮตCallbackRest ::identifier = Type ( ArgumentList ) ; Typedef ::typedef TypeWithExtendedAttributes identifier ; Type ::SingleType UnionType Null TypeWithExtendedAttributes ::ExtendedAttributeList Type SingleType ::DistinguishableType any PromiseType UnionType ::( UnionMemberType or UnionMemberType UnionMemberTypes ) UnionMemberType ::ExtendedAttributeList DistinguishableType UnionType Null UnionMemberTypes ::or UnionMemberType UnionMemberTypes ฮตDistinguishableType ::PrimitiveType Null StringType Null identifier Null sequence < TypeWithExtendedAttributes > Null async_sequence < TypeWithExtendedAttributes > Null object Null symbol Null BufferRelatedType Null FrozenArray < TypeWithExtendedAttributes > Null ObservableArray < TypeWithExtendedAttributes > Null RecordType Null undefined Null PrimitiveType ::UnsignedIntegerType UnrestrictedFloatType boolean byte octet bigint UnrestrictedFloatType ::unrestricted FloatType FloatType FloatType ::float double UnsignedIntegerType ::unsigned IntegerType IntegerType IntegerType ::short long OptionalLong OptionalLong ::long ฮตStringType ::ByteString DOMString USVString PromiseType ::Promise < Type > RecordType ::record < StringType , TypeWithExtendedAttributes > Null ::? ฮตBufferRelatedType ::ArrayBuffer SharedArrayBuffer DataView Int8Array Int16Array Int32Array Uint8Array Uint16Array Uint32Array Uint8ClampedArray BigInt64Array BigUint64Array Float16Array Float32Array Float64Array ExtendedAttributeList ::[ ExtendedAttribute ExtendedAttributes ] ฮตExtendedAttributes ::, ExtendedAttribute ExtendedAttributes ฮตExtendedAttribute ::( ExtendedAttributeInner ) ExtendedAttributeRest [ ExtendedAttributeInner ] ExtendedAttributeRest { ExtendedAttributeInner } ExtendedAttributeRest Other ExtendedAttributeRest ExtendedAttributeRest ::ExtendedAttribute ฮตExtendedAttributeInner ::( ExtendedAttributeInner ) ExtendedAttributeInner [ ExtendedAttributeInner ] ExtendedAttributeInner { ExtendedAttributeInner } ExtendedAttributeInner OtherOrComma ExtendedAttributeInner ฮตOther ::integer decimal identifier string other - -Infinity . ... : ; < = > ? * ByteString DOMString FrozenArray Infinity NaN ObservableArray Promise USVString any bigint boolean byte double false float long null object octet or optional record sequence short symbol true unsigned undefined ArgumentNameKeyword BufferRelatedType OtherOrComma ::Other , IdentifierList ::identifier Identifiers Identifiers ::, identifier Identifiers ฮตIntegerList ::integer Integers Integers ::, integer Integers ฮตExtendedAttributeNoArgs ::identifier ExtendedAttributeArgList ::identifier ( ArgumentList ) ExtendedAttributeIdent ::identifier = identifier ExtendedAttributeString ::identifier = string ExtendedAttributeInteger ::identifier = integer ExtendedAttributeDecimal ::identifier = decimal ExtendedAttributeWildcard ::identifier = * ExtendedAttributeIdentList ::identifier = ( IdentifierList ) ExtendedAttributeIntegerList ::identifier = ( IntegerList ) ExtendedAttributeNamedArgList ::identifier = identifier ( ArgumentList )
์ฐธ๊ณ :
๋ฌธ์ ๊ด๋ก
์ด ๋ฌธ์์์๋ ๋ค์๊ณผ ๊ฐ์ ์์ฒด ๊ด๋ก๋ฅผ ์ฌ์ฉํฉ๋๋ค:
-
์ฉ์ด์ ์ ์ ์ธ์คํด์ค: ์์ ์ฉ์ด
-
์ด ๋ฌธ์ ๋๋ ๋ค๋ฅธ ๊ณณ์์ ์ ์๋ ์ฉ์ด์ ๋ํ ๋งํฌ: ์์ ์ฉ์ด
-
๋ฌธ๋ฒ ํฐ๋ฏธ๋:
sometoken -
๋ฌธ๋ฒ ๋นํฐ๋ฏธ๋:
ExampleGrammarNonTerminal -
๋ฌธ๋ฒ ์ฌ๋ณผ:
identifier -
IDL ํ์ :
unsigned long -
JavaScript ํด๋์ค:
Map -
JavaScript ์ธ์ด ํ์ : Object
-
์ฝ๋ ์ค๋ํซ:
a = b + obj.f() -
์ค์นผ๋ผ ๊ฐ: U+0030 (0)
-
ํ์ฅ ์์ฑ: [
ExampleExtendedAttribute] -
์์ ๋ฐ ์๊ณ ๋ฆฌ์ฆ ๋ด ๋ณ์๋ช : exampleVariableName.
-
IDL ๋น๊ณต์ ๋ฌธ๋ฒ ์์:
[
extended_attributes ]interface identifier { /* interface_members... */ };(์ฃผ๋ณ ์ค๋ช ์์ ๋ ผ์๋๋ ๋ฌธ๋ฒ์ ํน์ ๋ถ๋ถ์ ๊ฐ์กฐ๋ฉ๋๋ค.)
-
IDL ๋ฌธ๋ฒ ์ค๋ํซ:
ExampleGrammarNonTerminal ::OtherNonTerminal sometoken other AnotherNonTerminal ฮต //nothing -
๋น๊ท๋ฒ์ ์ฃผ์:
์ฐธ๊ณ : ์ด๊ฒ์ ์ฃผ์์ ๋๋ค.
-
๋น๊ท๋ฒ์ ์์:
-
๊ท๋ฒ์ ๊ฒฝ๊ณ :
์ด๊ฒ์ ๊ฒฝ๊ณ ์ ๋๋ค.
-
์ฝ๋ ๋ธ๋ก:
// ์ด๊ฒ์ IDL ์ฝ๋ ๋ธ๋ก์ ๋๋ค. [
Exposed =Window ]interface Example {attribute long something ; };// ์ด๊ฒ์ JavaScript ์ฝ๋ ๋ธ๋ก์ ๋๋ค. window. onload= function () { window. alert( "loaded" ); };
์ด ๋ฌธ์์ ์๊ณ ๋ฆฌ์ฆ์์๋ ๋ค์๊ณผ ๊ฐ์ ๊ด๋ก๋ฅผ ์ฌ์ฉํฉ๋๋ค:
-
์๊ณ ๋ฆฌ์ฆ์ JavaScript ๋ช ์ธ์ ๊ด๋ก๋ฅผ ์ฌ์ฉํ๋ฉฐ, ! ๋ฐ ? ํ๊ธฐ๋ฅผ ์ฌ์ฉํ์ฌ Completion Record๋ฅผ ์ธ๋ํํฉ๋๋ค.
-
์๊ณ ๋ฆฌ์ฆ์ ๊ฐ ๋ฐํ/์์ธ ๋์ง๊ธฐ์ Completion Record ๋ฐํ์ ์ํธ ๊ตํ์ ์ผ๋ก ๋ค๋ฃจ๊ธฐ๋ ํฉ๋๋ค. ์ฆ, ๋ฐํ/๋์ง๊ธฐ ์ฉ์ด๋ฅผ ์ฌ์ฉํ๋ ์๊ณ ๋ฆฌ์ฆ์ Completion Record๋ฅผ ๋ฐํํ๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผํ ์ ์๊ณ , Completion Record ๋ฅผ ๋ฐํํ๋ ์๊ณ ๋ฆฌ์ฆ์ ๊ฐ์ ๋ฐํํ๊ฑฐ๋ ์์ธ๋ฅผ ๋์ง๋ ๊ฒ์ผ๋ก ๊ฐ์ฃผํ ์ ์์ต๋๋ค. ์ด์ ์ ์ฌํ๊ฒ, ์์ธ๋ฅผ ์ฒ๋ฆฌํ๊ธฐ ์ํด ์์ธ๊ฐ ๋์ ธ์ก์ ๋์ ๋์์ ์ ์ํ๊ณ , Completion Record์ [[Type]] ํ๋๊ฐ "throw"์ธ์ง ํ์ธํ๋ ๊ฒ์ ๋๋ฑํฉ๋๋ค.
-
Completion Record๋ JavaScript ๊ฐ์ด ์๋ Web IDL ๊ฐ๊ณผ ๊ฐ์ ๊ฐ์ ํฌํจํ ์ ์๋๋ก ํ์ฅ๋ฉ๋๋ค.
์ ํฉ์ฑ
์ด ๋ช ์ธ์์ ๋ชจ๋ ๋ด์ฉ์ ๋ํ, ์์, ์ฐธ๊ณ ๋ฐ ์ ๋ณด์ฉ์ผ๋ก ํ์๋ ์น์ ์ ์ ์ธํ๋ฉด ๊ท๋ฒ์ ์ ๋๋ค.
์ด ๋ช ์ธ์๋ Infra ํ์ค์ ์์กดํฉ๋๋ค. [INFRA]
์ด ๋ช ์ธ์์์๋ ๋ค์๊ณผ ๊ฐ์ ์ ํฉ์ฑ ํด๋์ค๊ฐ ์ ์๋ฉ๋๋ค:
- ์ ํฉํ IDL ์กฐ๊ฐ ์งํฉ
-
IDL ์กฐ๊ฐ๋ค์ ์งํฉ์, ํจ๊ป ๊ณ ๋ คํ์ ๋, ์ด ๋ช ์ธ์์์ IDL ์กฐ๊ฐ์ ์ ์ฉ๋๋ must-, required-, shall- ์์ค์ ๊ธฐ์ค์ ๋ชจ๋ ์ถฉ์กฑ์ํค๋ฉด ์ ํฉํ IDL ์กฐ๊ฐ ์งํฉ์ผ๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
- ์ ํฉํ ๊ตฌํ
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ ์ง์ํ๋ ๋ชจ๋ ์ธ์ด ๋ฐ์ธ๋ฉ์ ๋ํด ๊ตฌํ์ ์ ์ฉ๋๋ must-, required-, shall- ์์ค์ ๊ธฐ์ค์ ์ด ๋ช ์ธ์์์ ๋ชจ๋ ์ถฉ์กฑ์ํค๋ฉด, ํด๋น ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ ํฉํ ๊ตฌํ์ผ๋ก, ํด๋น ์ ํฉํ IDL ์กฐ๊ฐ ์งํฉ์ ๋ํด ๊ฐ์ฃผ๋ฉ๋๋ค.
- ์ ํฉํ JavaScript ๊ตฌํ
-
์ฌ์ฉ์ ์์ด์ ํธ๊ฐ JavaScript ์ธ์ด ๋ฐ์ธ๋ฉ์ ๋ํด ๊ตฌํ์ ์ ์ฉ๋๋ must-, required-, shall- ์์ค์ ๊ธฐ์ค์ ์ด ๋ช ์ธ์์์ ๋ชจ๋ ์ถฉ์กฑ์ํค๋ฉด, ํด๋น ์ฌ์ฉ์ ์์ด์ ํธ๋ ์ ํฉํ JavaScript ๊ตฌํ์ผ๋ก, ํด๋น ์ ํฉํ IDL ์กฐ๊ฐ ์งํฉ์ ๋ํด ๊ฐ์ฃผ๋ฉ๋๋ค.
์ง์ ์ฌ์ฐ๊ถ
Copyright ยฉ WHATWG (Apple, Google, Mozilla, Microsoft). ์ด ์ ์๋ฌผ์ ํฌ๋ฆฌ์์ดํฐ๋ธ ์ปค๋จผ์ฆ ์ ์์ ํ์ 4.0 ๊ตญ์ ๋ผ์ด์ ์ค์ ๋ฐ๋ผ ๋ผ์ด์ ์ค๊ฐ ๋ถ์ฌ๋ฉ๋๋ค. ์ผ๋ถ ๋ด์ฉ์ด ์์ค ์ฝ๋์ ํตํฉ๋ ๋ฒ์ ๋ด์์๋, ํด๋น ์์ค ์ฝ๋์ ๋ถ๋ถ์ BSD 3-Clause ๋ผ์ด์ ์ค์ ๋ฐ๋ผ ๋ณ๋๋ก ๋ผ์ด์ ์ค๋ฉ๋๋ค.
์ด๊ฒ์ด ํํ ํ์ค์ ๋๋ค. ํนํ ๊ฒํ ์ฉ ๋ฒ์ ์ ๊ด์ฌ์ด ์๋ ๋ถ์ ํํ ํ์ค ๊ฒํ ์ด์์ ์ฐธ๊ณ ํ์๊ธฐ ๋ฐ๋๋๋ค.