📄 ref.legal-values.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>legal_values</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="The eCos Component Writer's Guide"HREF="cdl-guide.html"><LINKREL="UP"TITLE="CDL Language Specification"HREF="reference.html"><LINKREL="PREVIOUS"TITLE="include_files"HREF="ref.include-files.html"><LINKREL="NEXT"TITLE="library"HREF="ref.library.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">The <SPANCLASS="APPLICATION">eCos</SPAN> Component Writer's Guide</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="ref.include-files.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="ref.library.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="REF.LEGAL-VALUES"><SPANCLASS="PROPERTY">legal_values</SPAN></H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN4615"></A><H2>Name</H2>Property <SPANCLASS="PROPERTY">legal_values</SPAN> -- Impose constraints on the possible values for an option.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN4619"><H2>Synopsis</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="SYNOPSIS">cdl_option <name> { legal_values <list expression> …}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN4621"></A><H2>Description</H2><P>Options with the <TTCLASS="LITERAL">data</TT> or<TTCLASS="LITERAL">booldata</TT> flavors can have an arbitrary sequence ofcharacters as their data. In nearly all cases some restrictions haveto be imposed, for example the data should correspond to a numberwithin a certain range, or it should be one of a small number ofconstants. The <SPANCLASS="PROPERTY">legal_values</SPAN> property can be used to impose suchconstraints. The arguments to the property should be a <SPANCLASS="APPLICATION">CDL</SPAN> listexpression, see <AHREF="language.values.html#LANGUAGE.LIST-EXPRESSION">the Section called <I>List Expressions</I> in Chapter 3</A> for thesyntactic details. Common examples include:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> legal_values 0 to 0x7fff legal_values 9600 19200 38400 legal_values { "RAM" "ROM" }</PRE></TD></TR></TABLE><P>The <SPANCLASS="PROPERTY">legal_values</SPAN> property can only be used for options with the<TTCLASS="LITERAL">data</TT> or <TTCLASS="LITERAL">booldata</TT> flavors, sinceit makes little sense to further constrain the legal values of aboolean option. An option can have at most one <SPANCLASS="PROPERTY">legal_values</SPAN>property.</P><DIVCLASS="TIP"><BLOCKQUOTECLASS="TIP"><P><B>Tip: </B>If the first entry in a <SPANCLASS="PROPERTY">legal_values</SPAN> list expression is a negativenumber, for example<TTCLASS="LITERAL">legal_values -1 to 1</TT> then this canbe misinterpreted as an option instead of as part of the expression.Currently the <SPANCLASS="PROPERTY">legal_values</SPAN> property does not take any options, butthis may change in future. Option processing halts at the sequence<TTCLASS="LITERAL">--</TT>, so the desired range can be expressed safelyusing <TTCLASS="LITERAL">legal_values -- -1 to 1</TT></P></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Architectural HAL packages should provide constants which can be usedin <SPANCLASS="PROPERTY">legal_values</SPAN> list expressions. For example it should be possibleto specify a numeric range such as<TTCLASS="LITERAL">0 to CYGARC_MAXINT</TT>, rather thanhard-wiring numbers such as <TTCLASS="LITERAL">0x7fffffff</TT> which maynot be valid on all targets. Current HAL packages do not define suchconstants. </P></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>The <SPANCLASS="PROPERTY">legal_values</SPAN> property is restricted mainly to numerical rangesand simple enumerations, and cannot cope with more complicated dataitems. Future versions of the configuration system will provideadditional data validation facilities, for example a<TTCLASS="LITERAL">check_proc</TT> property which specifies a Tcl scriptthat can be used to perform the validation.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN4651"></A><H2>Example</H2><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET { display "Default Standard Time offset" flavor data legal_values -- -90000 to 90000 default_value -- 0 description " This option controls the offset from UTC in seconds when in local Standard Time. This value can be positive or negative. It can also be set at run time using the cyg_libc_time_setzoneoffsets() function."}</PRE></TD></TR></TABLE></DIV><DIVCLASS="REFSECT1"><ANAME="AEN4654"></A><H2>See Also</H2><P>Properties <AHREF="ref.calculated.html"><SPANCLASS="PROPERTY">calculated</SPAN></A>,<AHREF="ref.default-value.html"><SPANCLASS="PROPERTY">default_value</SPAN></A>, and<AHREF="ref.flavor.html"><SPANCLASS="PROPERTY">flavor</SPAN></A>.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="ref.include-files.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="cdl-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="ref.library.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><SPANCLASS="PROPERTY">include_files</SPAN></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="reference.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><SPANCLASS="PROPERTY">library</SPAN></TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -