![]() |
Declaring an attribute as part of an interface is equivalent to declaring one or two accessor operations: one to retrieve the value of the attribute (a get or read operation) and (unless the attribute specifies readonly) one to set the value of the attribute (a set or write operation).
Attributes are declared as follows:
[ readonly ] attribute type-spec declarators;where:
- type-spec specifies any valid IDL type (except a sequence).
- declarators is a list of identifiers, delimited by commas. An array declarator cannot be used directly when declaring an attribute, but the type of an attribute can be a user-defined type that is an array. Although the type of an attribute cannot be a sequence, it can be a user-defined type that is a sequence. The optional readonly keyword specifies that the value of the attribute can be accessed but not modified. (In other words, a readonly attribute has no set operation.) Below are examples of attribute declarations, which are specified within the body of an interface statement:
interface Goodbye: Hello { void sayBye(); attribute short xpos; attribute char c1, c2; readonly attribute float xyz; };Attributes are inherited from base interfaces. An inherited attribute name cannot be redefined to be a different type.