]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - doc/html/cdl-guide/language.values.html
RedBoot TX53 Release 2012-02-15
[karo-tx-redboot.git] / doc / html / cdl-guide / language.values.html
1 <!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2 <!-- This material may be distributed only subject to the terms      -->
3 <!-- and conditions set forth in the Open Publication License, v1.0  -->
4 <!-- or later (the latest version is presently available at          -->
5 <!-- http://www.opencontent.org/openpub/).                           -->
6 <!-- Distribution of the work or derivative of the work in any       -->
7 <!-- standard (paper) book form is prohibited unless prior           -->
8 <!-- permission is obtained from the copyright holder.               -->
9 <HTML
10 ><HEAD
11 ><TITLE
12 >Values and Expressions</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
14 <META
15 NAME="GENERATOR"
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17 "><LINK
18 REL="HOME"
19 TITLE="The eCos Component Writer's Guide"
20 HREF="cdl-guide.html"><LINK
21 REL="UP"
22 TITLE="The CDL Language"
23 HREF="language.html"><LINK
24 REL="PREVIOUS"
25 TITLE="An Introduction to Tcl"
26 HREF="language.tcl.html"><LINK
27 REL="NEXT"
28 TITLE="Interfaces"
29 HREF="language.interface.html"></HEAD
30 ><BODY
31 CLASS="SECT1"
32 BGCOLOR="#FFFFFF"
33 TEXT="#000000"
34 LINK="#0000FF"
35 VLINK="#840084"
36 ALINK="#0000FF"
37 ><DIV
38 CLASS="NAVHEADER"
39 ><TABLE
40 SUMMARY="Header navigation table"
41 WIDTH="100%"
42 BORDER="0"
43 CELLPADDING="0"
44 CELLSPACING="0"
45 ><TR
46 ><TH
47 COLSPAN="3"
48 ALIGN="center"
49 >The <SPAN
50 CLASS="APPLICATION"
51 >eCos</SPAN
52 > Component Writer's Guide</TH
53 ></TR
54 ><TR
55 ><TD
56 WIDTH="10%"
57 ALIGN="left"
58 VALIGN="bottom"
59 ><A
60 HREF="language.tcl.html"
61 ACCESSKEY="P"
62 >Prev</A
63 ></TD
64 ><TD
65 WIDTH="80%"
66 ALIGN="center"
67 VALIGN="bottom"
68 >Chapter 3. The CDL Language</TD
69 ><TD
70 WIDTH="10%"
71 ALIGN="right"
72 VALIGN="bottom"
73 ><A
74 HREF="language.interface.html"
75 ACCESSKEY="N"
76 >Next</A
77 ></TD
78 ></TR
79 ></TABLE
80 ><HR
81 ALIGN="LEFT"
82 WIDTH="100%"></DIV
83 ><DIV
84 CLASS="SECT1"
85 ><H1
86 CLASS="SECT1"
87 ><A
88 NAME="LANGUAGE.VALUES">Values and Expressions</H1
89 ><P
90 >It is fairly reasonable to expect that enabling or disabling a
91 configuration option such as
92 <TT
93 CLASS="VARNAME"
94 >CYGVAR_KERNEL_THREADS_DATA</TT
95 > in some way affects its
96 <SPAN
97 CLASS="emphasis"
98 ><I
99 CLASS="EMPHASIS"
100 >value</I
101 ></SPAN
102 >. This will have an effect on any
103 expressions that reference this option such as
104 <TT
105 CLASS="LITERAL"
106 >requires&nbsp;CYGVAR_KERNEL_THREADS_DATA</TT
107 >. It will
108 also affect the consequences of that option: how it affects the build
109 process and what happens to any constraints that
110 <TT
111 CLASS="VARNAME"
112 >CYGVAR_KERNEL_THREADS_DATA</TT
113 > may impose (as opposed
114 to constraints on this option imposed by others).</P
115 ><P
116 >In a language like C the handling of variables is relatively
117 straightforward. If a variable <TT
118 CLASS="VARNAME"
119 >x</TT
120 > gets referenced in
121 an expression such as <TT
122 CLASS="LITERAL"
123 >if&nbsp;(x&nbsp;!=&nbsp;0)</TT
124 >,
125 and that variable is not defined anywhere, then the code will fail to
126 build, typically with an unresolved error at link-time. Also in C
127 a variable <TT
128 CLASS="VARNAME"
129 >x</TT
130 > does not live in any hierarchy, so its
131 value for the purposes of expression evaluation is not affected by
132 anything else. C variables also have a clear type such as
133 <TT
134 CLASS="LITERAL"
135 >int</TT
136 > or <TT
137 CLASS="LITERAL"
138 >long&nbsp;double</TT
139 >. </P
140 ><P
141 >In <SPAN
142 CLASS="APPLICATION"
143 >CDL</SPAN
144 > things are not so straightforward.</P
145 ><DIV
146 CLASS="SECT2"
147 ><H2
148 CLASS="SECT2"
149 ><A
150 NAME="LANGUAGE.VALUES.VALUE">Option Values</H2
151 ><P
152 >There are four factors which go into an option's value:</P
153 ><P
154 ></P
155 ><OL
156 TYPE="1"
157 ><LI
158 ><P
159 >An option may or may not be loaded.</P
160 ></LI
161 ><LI
162 ><P
163 >If the option is loaded, it may or may not be active.</P
164 ></LI
165 ><LI
166 ><P
167 >Even if the option is active, it may or may not be enabled.</P
168 ></LI
169 ><LI
170 ><P
171 >If the option is loaded, active and enabled then it will have some
172 associated data which constitutes its value.</P
173 ></LI
174 ></OL
175 ><DIV
176 CLASS="SECT3"
177 ><H3
178 CLASS="SECT3"
179 ><A
180 NAME="LANGUAGE.VALUES.VALUE.LOADED">Is the Option Loaded?</H3
181 ><P
182 >At any one time a configuration will contain only a subset of all
183 possible packages. In fact it is impossible to combine certain
184 packages in a single configuration. For example architectural HAL
185 packages should contain a set of options defining endianness, the
186 sizes of basic data types and so on (many of which will of course be
187 constant for any given architecture). Any attempt to load two
188 architectural HAL packages into a configuration will fail because of
189 the resulting name clash. Since <SPAN
190 CLASS="APPLICATION"
191 >CDL</SPAN
192 > expressions can reference
193 options in other packages, and often need to do so, it is essential to
194 define the resulting behavior.</P
195 ><P
196 >One complication is that the component framework does not know about
197 every single option in every single package. Obviously it cannot know
198 about packages from arbitrary third parties which have not been
199 installed. Even for packages which have been installed, the current
200 repository database does not hold details of every option, only of the
201 packages themselves. If a <SPAN
202 CLASS="APPLICATION"
203 >CDL</SPAN
204 > expression contains a reference to
205 some option <TT
206 CLASS="VARNAME"
207 >CYGSEM_KERNEL_SCHED_TIMESLICE</TT
208 > then the
209 component framework will only know about this option if the kernel
210 package is actually loaded into the current configuration. If the
211 package is not loaded then theoretically the framework might guess
212 that the option is somehow related to the kernel by examining the
213 option name but this would not be robust: the option could easily be
214 part of some other package that violates the naming convention.</P
215 ><P
216 >Assume that the user is building a minimal configuration which does
217 not contain the kernel package, but does have other packages which
218 contain the following constraints:</P
219 ><TABLE
220 BORDER="5"
221 BGCOLOR="#E0E0F0"
222 WIDTH="70%"
223 ><TR
224 ><TD
225 ><PRE
226 CLASS="PROGRAMLISTING"
227 >    requires CYGPKG_KERNEL
228     requires CYGPKG_KERNEL_THREADS_DATA
229     requires !CYGSEM_KERNEL_SCHED_TIMESLICE</PRE
230 ></TD
231 ></TR
232 ></TABLE
233 ><P
234 >Clearly the first constraint is not satisfied because the kernel is
235 not loaded. The second constraint is also not satisfied. The third
236 constraint is trivially satisfied: if there is no kernel then the
237 kernel's timeslicing support cannot possibly be enabled. </P
238 ><P
239 >Any options which are not in the current configuration are handled as
240 follows: </P
241 ><P
242 ></P
243 ><OL
244 TYPE="1"
245 ><LI
246 ><P
247 >Any references to that option will evaluate to <TT
248 CLASS="LITERAL"
249 >0</TT
250 >,
251 so <TT
252 CLASS="LITERAL"
253 >requires&nbsp;!CYGSEM_KERNEL_SCHED_TIMESLICE</TT
254 > will
255 be satisfied but
256 <TT
257 CLASS="LITERAL"
258 >requires&nbsp;CYGSEM_KERNEL_THREADS_DATA</TT
259 > will not
260 be satisfied.</P
261 ></LI
262 ><LI
263 ><P
264 >An option that is not loaded has no consequences on the build process.
265 It cannot directly result in any <TT
266 CLASS="LITERAL"
267 >#define's</TT
268 > in a
269 configuration header file, nor in any files being compiled. This is
270 only reasonable: if the option is not loaded then the component
271 framework has no way of knowing about any <SPAN
272 CLASS="PROPERTY"
273 >compile</SPAN
274 > or similar
275 properties. An option that is not loaded can have indirect
276 consequences by being referenced in <SPAN
277 CLASS="APPLICATION"
278 >CDL</SPAN
279 > expressions.</P
280 ></LI
281 ><LI
282 ><P
283 >An option that is not loaded cannot impose any constraints on the rest
284 of the configuration. Again this is the only reasonable behavior: if
285 the option is not loaded then any associated <SPAN
286 CLASS="PROPERTY"
287 >requires</SPAN
288 > or
289 <SPAN
290 CLASS="PROPERTY"
291 >legal_values</SPAN
292 > properties will not be known.</P
293 ></LI
294 ></OL
295 ></DIV
296 ><DIV
297 CLASS="SECT3"
298 ><H3
299 CLASS="SECT3"
300 ><A
301 NAME="LANGUAGE.VALUES.VALUE.ACTIVE">Is the Option Active</H3
302 ><P
303 >The next issue to consider is whether or not a particular option is
304 active. Configuration options are organized in a hierarchy of
305 components and sub-components. For example the C library package
306 contains a component <TT
307 CLASS="VARNAME"
308 >CYGPKG_LIBC_STDIO</TT
309 > containing
310 all the options related to standard I/O. If a user disables the
311 component as a whole then all the options below it become inactive: it
312 makes no sense to disable all stdio functionality and then manipulate
313 the buffer sizes.</P
314 ><P
315 >Inactive is not quite the same as disabled, although the effects are
316 similar. The value of an inactive option is preserved. If the user
317 modifies a buffer size option, then disables the whole stdio
318 component, the buffer size value remains in case the stdio component
319 is re-enabled later on. Some tools such as the graphical configuration
320 tool will treat inactive options specially, for example such options
321 may be grayed out.</P
322 ><P
323 >The active or inactive state of an option may affect other packages.
324 For example a package may use the <TT
325 CLASS="FUNCTION"
326 >sprintf</TT
327 >
328 function and require support for floating point conversions, a
329 constraint that is not satisfied if the relevant option is inactive.
330 It is necessary to define exactly what it means for an option to be
331 inactive:</P
332 ><P
333 ></P
334 ><OL
335 TYPE="1"
336 ><LI
337 ><P
338 >An option is inactive if its parent is either inactive or disabled.
339 For example if <TT
340 CLASS="VARNAME"
341 >CYGPKG_LIBC_STDIO</TT
342 > is disabled then
343 all the options and sub-components become inactive; since
344 <TT
345 CLASS="VARNAME"
346 >CYGPKG_LIBC_STDIO_FLOATING_POINT</TT
347 > is now inactive,
348 <TT
349 CLASS="VARNAME"
350 >CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT</TT
351 > is inactive
352 as well.</P
353 ></LI
354 ><LI
355 ><P
356 >Options may also be inactive as a result of an <SPAN
357 CLASS="PROPERTY"
358 >active_if</SPAN
359 > property.
360 This is useful if a particular option is only relevant if two or more
361 disjoint sets of conditions need to be satisfied, since the
362 hierarchical structure can only cope with at most one such set.</P
363 ></LI
364 ><LI
365 ><P
366 >If an option is inactive then any references to that option in <SPAN
367 CLASS="APPLICATION"
368 >CDL</SPAN
369 >
370 expressions will evaluate to <TT
371 CLASS="LITERAL"
372 >0</TT
373 >. Hence a constraint
374 of the form
375 <TT
376 CLASS="LITERAL"
377 >requires&nbsp;CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT</TT
378 >
379 is not satisfied if the entire stdio component is disabled.</P
380 ></LI
381 ><LI
382 ><P
383 >An option that is inactive has no consequences on the build process.
384 No <TT
385 CLASS="LITERAL"
386 >#define</TT
387 > will be generated. Any <SPAN
388 CLASS="PROPERTY"
389 >compile</SPAN
390 > or
391 similar properties will be ignored.</P
392 ></LI
393 ><LI
394 ><P
395 >An option that is inactive cannot impose any constraints on the rest
396 of the configuration. For example
397 <TT
398 CLASS="VARNAME"
399 >CYGSEM_LIBC_STDIO_PRINTF_FLOATING_POINT</TT
400 > has a
401 dependency <TT
402 CLASS="LITERAL"
403 >requires&nbsp;CYGPKG_LIBM</TT
404 >, but if all of
405 the stdio functionality is disabled then this constraint is ignored
406 (although of course there may be other packages which have a
407 dependency on <TT
408 CLASS="VARNAME"
409 >CYGPKG_LIBM</TT
410 >.</P
411 ></LI
412 ></OL
413 ></DIV
414 ><DIV
415 CLASS="SECT3"
416 ><H3
417 CLASS="SECT3"
418 ><A
419 NAME="LANGUAGE.VALUES.VALUE.ENABLED">Is the Option Enabled? What is the Data?</H3
420 ><P
421 >The majority of configuration options are boolean in nature, so the
422 user can either enable or disable some functionality. Some options are
423 different. For example <TT
424 CLASS="VARNAME"
425 >CYGNUM_LIBC_STDIO_BUFSIZE</TT
426 > is
427 a number, and <TT
428 CLASS="VARNAME"
429 >CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE</TT
430 > is
431 a string corresponding to a device name. A few options like
432 <TT
433 CLASS="VARNAME"
434 >CYGDAT_UITRON_TASK_EXTERNS</TT
435 > can get very
436 complicated. <SPAN
437 CLASS="APPLICATION"
438 >CDL</SPAN
439 > has to cope with this variety, and define the exact
440 behavior of the system in terms of constraints and build-time
441 consequences. </P
442 ><P
443 >In <SPAN
444 CLASS="APPLICATION"
445 >CDL</SPAN
446 > the value of an option consists of two parts. There is a
447 boolean part, controlling whether or not the option is enabled. There
448 is also a data part, providing additional information. For most
449 options one of these parts is fixed, as controlled by the option's
450 <SPAN
451 CLASS="PROPERTY"
452 >flavor</SPAN
453 > property:</P
454 ><DIV
455 CLASS="INFORMALTABLE"
456 ><A
457 NAME="AEN1413"><P
458 ></P
459 ><TABLE
460 BORDER="1"
461 CLASS="CALSTABLE"
462 ><THEAD
463 ><TR
464 ><TH
465 ALIGN="LEFT"
466 VALIGN="TOP"
467 >Flavor</TH
468 ><TH
469 ALIGN="LEFT"
470 VALIGN="TOP"
471 >Enabled</TH
472 ><TH
473 ALIGN="LEFT"
474 VALIGN="TOP"
475 >Data</TH
476 ></TR
477 ></THEAD
478 ><TBODY
479 ><TR
480 ><TD
481 ALIGN="LEFT"
482 VALIGN="TOP"
483 ><TT
484 CLASS="LITERAL"
485 >none</TT
486 ></TD
487 ><TD
488 ALIGN="LEFT"
489 VALIGN="TOP"
490 >Always enabled</TD
491 ><TD
492 ALIGN="LEFT"
493 VALIGN="TOP"
494 ><TT
495 CLASS="LITERAL"
496 >1</TT
497 >, not modifiable</TD
498 ></TR
499 ><TR
500 ><TD
501 ALIGN="LEFT"
502 VALIGN="TOP"
503 ><TT
504 CLASS="LITERAL"
505 >bool</TT
506 ></TD
507 ><TD
508 ALIGN="LEFT"
509 VALIGN="TOP"
510 >User-modifiable</TD
511 ><TD
512 ALIGN="LEFT"
513 VALIGN="TOP"
514 ><TT
515 CLASS="LITERAL"
516 >1</TT
517 >, not modifiable</TD
518 ></TR
519 ><TR
520 ><TD
521 ALIGN="LEFT"
522 VALIGN="TOP"
523 ><TT
524 CLASS="LITERAL"
525 >data</TT
526 ></TD
527 ><TD
528 ALIGN="LEFT"
529 VALIGN="TOP"
530 >Always enabled</TD
531 ><TD
532 ALIGN="LEFT"
533 VALIGN="TOP"
534 >User-modifiable</TD
535 ></TR
536 ><TR
537 ><TD
538 ALIGN="LEFT"
539 VALIGN="TOP"
540 ><TT
541 CLASS="LITERAL"
542 >booldata</TT
543 ></TD
544 ><TD
545 ALIGN="LEFT"
546 VALIGN="TOP"
547 >User-modifiable</TD
548 ><TD
549 ALIGN="LEFT"
550 VALIGN="TOP"
551 >User-modifiable</TD
552 ></TR
553 ></TBODY
554 ></TABLE
555 ><P
556 ></P
557 ></DIV
558 ><P
559 >The effects of the boolean and data parts are as follows:</P
560 ><P
561 ></P
562 ><OL
563 TYPE="1"
564 ><LI
565 ><P
566 >If an option is disabled, in other words if the boolean part is false,
567 then any references to that option in <SPAN
568 CLASS="APPLICATION"
569 >CDL</SPAN
570 > expressions will evaluate
571 to <TT
572 CLASS="LITERAL"
573 >0</TT
574 >. This is the same behavior as for inactive
575 options. The data part is not relevant. The <TT
576 CLASS="LITERAL"
577 >none</TT
578 >
579 and <TT
580 CLASS="LITERAL"
581 >data</TT
582 > flavors specify that the option is always
583 enabled, in which case this rule is not applicable.</P
584 ></LI
585 ><LI
586 ><P
587 >If an option is enabled then any references to that option in <SPAN
588 CLASS="APPLICATION"
589 >CDL</SPAN
590 >
591 expressions will evaluate to the option's data part. For two of the
592 flavors, <TT
593 CLASS="LITERAL"
594 >none</TT
595 > and <TT
596 CLASS="LITERAL"
597 >bool</TT
598 >, this
599 data part is fixed to the constant <TT
600 CLASS="LITERAL"
601 >1</TT
602 > which
603 generally has the expected result.</P
604 ></LI
605 ><LI
606 ><P
607 >If a component or package is disabled then all sub-components and
608 options immediately below it in the hierarchy are inactive. By a
609 process of recursion this will affect all the nodes in the subtree.</P
610 ></LI
611 ><LI
612 ><P
613 >If an option is disabled then it can impose no constraints on the rest
614 of the configuration, in particular <SPAN
615 CLASS="PROPERTY"
616 >requires</SPAN
617 > and <SPAN
618 CLASS="PROPERTY"
619 >legal_values</SPAN
620 >
621 properties will be ignored. If an option is enabled then its
622 constraints should be satisfied, or the component framework will
623 report various conflicts. Note that the <SPAN
624 CLASS="PROPERTY"
625 >legal_values</SPAN
626 > constraint only
627 applies to the data part of the option's value, so it is only useful
628 with the <TT
629 CLASS="LITERAL"
630 >data</TT
631 > and <TT
632 CLASS="LITERAL"
633 >booldata</TT
634 >
635 flavors. Options with the <TT
636 CLASS="LITERAL"
637 >none</TT
638 > and
639 <TT
640 CLASS="LITERAL"
641 >data</TT
642 > flavors are always enabled so their
643 constraints always have to be satisfied (assuming the option is
644 active). </P
645 ></LI
646 ><LI
647 ><P
648 >If an option is disabled then it has no direct consequences at
649 build-time: no <TT
650 CLASS="LITERAL"
651 >#define</TT
652 > will be generated, no files
653 will get compiled, and so on. If an option is active and enabled then
654 all the consequences take effect. The option name and data part are
655 used to generate the <TT
656 CLASS="LITERAL"
657 >#define</TT
658 > in the appropriate
659 configuration header file, subject to various properties such as
660 <SPAN
661 CLASS="PROPERTY"
662 >no_define</SPAN
663 >, but the data part has no other effects on the build
664 system. </P
665 ></LI
666 ></OL
667 ><P
668 >By default all options and components have the <TT
669 CLASS="LITERAL"
670 >bool</TT
671 >
672 flavor: most options are boolean in nature, so making this the default
673 allows for slightly more compact <SPAN
674 CLASS="APPLICATION"
675 >CDL</SPAN
676 > scripts. Packages have the
677 <TT
678 CLASS="LITERAL"
679 >booldata</TT
680 > flavor, where the data part always
681 corresponds to the version of the package that is loaded into the
682 configuration: changing this value corresponds to unloading the old
683 version and loading in a different one.</P
684 ><DIV
685 CLASS="NOTE"
686 ><BLOCKQUOTE
687 CLASS="NOTE"
688 ><P
689 ><B
690 ><SPAN
691 CLASS="APPLICATION"
692 >CDL</SPAN
693 > Flavors: </B
694 >The concept of <SPAN
695 CLASS="APPLICATION"
696 >CDL</SPAN
697 > flavors tends to result in various discussions
698 about why it is unnecessarily complicated, and would it not have been
699 easier to do&nbsp;&#8230; However there are very good reasons why CDL
700 works the way it does.</P
701 ><P
702 >The first common suggestion is that there is no need to have separate
703 flavors <TT
704 CLASS="LITERAL"
705 >bool</TT
706 >, <TT
707 CLASS="LITERAL"
708 >data</TT
709 >, and so on. A
710 boolean option could just be handled as a data option with legal
711 values <TT
712 CLASS="LITERAL"
713 >0</TT
714 > and <TT
715 CLASS="LITERAL"
716 >1</TT
717 >. The counter
718 arguments are as follows:</P
719 ><P
720 ></P
721 ><OL
722 TYPE="1"
723 ><LI
724 ><P
725 >It would actually make <SPAN
726 CLASS="APPLICATION"
727 >CDL</SPAN
728 > scripts more verbose. By default all
729 options and components have the <TT
730 CLASS="LITERAL"
731 >bool</TT
732 > flavor, since
733 most options are boolean in nature. Without a <TT
734 CLASS="LITERAL"
735 >bool</TT
736 >
737 flavor it would be necessary to indicate explicitly what the legal
738 values are somehow, e.g. with a <SPAN
739 CLASS="PROPERTY"
740 >legal_values</SPAN
741 > property.</P
742 ></LI
743 ><LI
744 ><P
745 >The boolean part of an option's value has a very different effect from
746 the data part. If an option is disabled then it has no consequences at
747 build time, and can impose no constraints. A <TT
748 CLASS="LITERAL"
749 >data</TT
750 >
751 option always has consequences and can impose constraints. To get the
752 desired effect it would be necessary to add <SPAN
753 CLASS="APPLICATION"
754 >CDL</SPAN
755 > data indicating that
756 a value of <TT
757 CLASS="LITERAL"
758 >0</TT
759 > should be treated specially. Arguably
760 this could be made built-in default behavior, although that would
761 complicate options where <TT
762 CLASS="LITERAL"
763 >0</TT
764 > is a perfectly legal
765 number, for example
766 <TT
767 CLASS="VARNAME"
768 >CYGNUM_LIBC_TIME_STD_DEFAULT_OFFSET</TT
769 >. </P
770 ></LI
771 ><LI
772 ><P
773 >There would no replacement for a <TT
774 CLASS="LITERAL"
775 >booldata</TT
776 > option
777 for which <TT
778 CLASS="LITERAL"
779 >0</TT
780 > is a valid value. Again some additional
781 <SPAN
782 CLASS="APPLICATION"
783 >CDL</SPAN
784 > syntax would be needed to express such a concept.</P
785 ></LI
786 ></OL
787 ><P
788 >Although initially it may seem confusing that an option's value has
789 both a boolean and a data part, it is an accurate reflection of how
790 configuration options actually work. The various alternatives would
791 all make it harder to write <SPAN
792 CLASS="APPLICATION"
793 >CDL</SPAN
794 > scripts.</P
795 ><P
796 >The next common suggestion is that the data part of a value should be
797 typed in much the same way as C or C++ data types. For example it
798 should be possible to describe
799 <TT
800 CLASS="VARNAME"
801 >CYGNUM_LIBC_STDIO_BUFSIZE</TT
802 > as an integer value,
803 rather than imposing <SPAN
804 CLASS="PROPERTY"
805 >legal_values</SPAN
806 > constraints. Again there are very
807 good reasons why this approach was not taken:</P
808 ><P
809 ></P
810 ><OL
811 TYPE="1"
812 ><LI
813 ><P
814 >The possible legal values for an integer are rarely correct for a
815 <SPAN
816 CLASS="APPLICATION"
817 >CDL</SPAN
818 > option. A constraint such as
819 <TT
820 CLASS="LITERAL"
821 >1&nbsp;to&nbsp;0x7fffffff</TT
822 > is a bit more accurate,
823 although if this option indicates a buffer size it is still not
824 particularly good&nbsp;&#8212; very few targets will have enough
825 memory for such a buffer. Forcing <SPAN
826 CLASS="APPLICATION"
827 >CDL</SPAN
828 > writers to list the
829 <SPAN
830 CLASS="PROPERTY"
831 >legal_values</SPAN
832 > constraints explicitly should make them think a bit
833 more about what values are actually sensible. For example
834 <TT
835 CLASS="VARNAME"
836 >CYGNUM_LIBC_TIME_DST_DEFAULT_OFFSET</TT
837 > has legal
838 values in the range <TT
839 CLASS="LITERAL"
840 >-90000&nbsp;to&nbsp;90000</TT
841 >,
842 which helps the user to set a sensible value.</P
843 ></LI
844 ><LI
845 ><P
846 >Not all options correspond to simple data types such as integers.
847 <TT
848 CLASS="VARNAME"
849 >CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE</TT
850 > is a C string,
851 and would have to be expressed using something like
852 <TT
853 CLASS="LITERAL"
854 >char&nbsp;[]</TT
855 >. This introduces plenty of
856 opportunities for confusion, especially since square brackets may get
857 processed by the <SPAN
858 CLASS="APPLICATION"
859 >Tcl</SPAN
860 > interpreter for command substitution.</P
861 ></LI
862 ><LI
863 ><P
864 >Some configuration options can get very complicated indeed, for
865 example the default value of
866 <TT
867 CLASS="VARNAME"
868 >CYGDAT_UITRON_TASK_INITIALIZERS</TT
869 > is:</P
870 ><TABLE
871 BORDER="5"
872 BGCOLOR="#E0E0F0"
873 WIDTH="70%"
874 ><TR
875 ><TD
876 ><PRE
877 CLASS="PROGRAMLISTING"
878 >CYG_UIT_TASK( "t1", 1, task1, &amp;stack1, CYGNUM_UITRON_STACK_SIZE ), \
879 CYG_UIT_TASK( "t2", 2, task2, &amp;stack2, CYGNUM_UITRON_STACK_SIZE ), \ 
880 CYG_UIT_TASK( "t3", 3, task3, &amp;stack3, CYGNUM_UITRON_STACK_SIZE ), \
881 CYG_UIT_TASK( "t4", 4, task4, &amp;stack4, CYGNUM_UITRON_STACK_SIZE )</PRE
882 ></TD
883 ></TR
884 ></TABLE
885 ><P
886 >This would require <SPAN
887 CLASS="APPLICATION"
888 >CDL</SPAN
889 > knowing about C macros, structures, arrays,
890 static initializers, and so on. Adding such detailed knowledge about
891 the C language to the component framework is inappropriate.</P
892 ></LI
893 ><LI
894 ><P
895 ><SPAN
896 CLASS="APPLICATION"
897 >CDL</SPAN
898 > needs to be usable with languages other than C. At present this
899 includes C++, in future it may include languages such as Java. Each
900 language adds new data types and related complications, for example
901 C++ classes and inheritance. Making <SPAN
902 CLASS="APPLICATION"
903 >CDL</SPAN
904 > support a union of all data
905 types in all possible languages is not sensible.</P
906 ></LI
907 ></OL
908 ><P
909 >The <SPAN
910 CLASS="APPLICATION"
911 >CDL</SPAN
912 > approach of treating all data as a sequence of characters,
913 possibly constrained by a <SPAN
914 CLASS="PROPERTY"
915 >legal_values</SPAN
916 > property or other means, has
917 the great advantage of simplicity. It also fits in with the <SPAN
918 CLASS="APPLICATION"
919 >Tcl</SPAN
920 >
921 language that underlies <SPAN
922 CLASS="APPLICATION"
923 >CDL</SPAN
924 >.</P
925 ></BLOCKQUOTE
926 ></DIV
927 ></DIV
928 ><DIV
929 CLASS="SECT3"
930 ><H3
931 CLASS="SECT3"
932 ><A
933 NAME="LANGUAGE.VALUES.VALUE.EXAMPLES">Some Examples</H3
934 ><P
935 >The following excerpt from the C library's <SPAN
936 CLASS="APPLICATION"
937 >CDL</SPAN
938 > scripts can be used
939 to illustrate how values and flavors work in practice:</P
940 ><TABLE
941 BORDER="5"
942 BGCOLOR="#E0E0F0"
943 WIDTH="70%"
944 ><TR
945 ><TD
946 ><PRE
947 CLASS="PROGRAMLISTING"
948 >cdl_component CYGPKG_LIBC_RAND {
949     flavor        none
950     compile       stdlib/rand.cxx
951
952     cdl_option CYGSEM_LIBC_PER_THREAD_RAND {
953         requires      CYGVAR_KERNEL_THREADS_DATA
954         default_value 0
955     }
956
957     cdl_option CYGNUM_LIBC_RAND_SEED {
958         flavor        data
959         legal_values  0 to 0x7fffffff
960         default_value 1
961     }
962
963     cdl_option CYGNUM_LIBC_RAND_TRACE_LEVEL {
964         flavor        data
965         legal_values  0 to 1
966         default_value 0
967     }
968 }</PRE
969 ></TD
970 ></TR
971 ></TABLE
972 ><P
973 >If the application does not require any C library functionality then
974 it is possible to have a configuration where the C library is not
975 loaded. This can be achieved by starting with the minimal template, or
976 by starting with another template such as the default one and then
977 explicitly unloading the C library package. If this package is not
978 loaded then any references to the <TT
979 CLASS="VARNAME"
980 >CYGPKG_LIBC_RAND</TT
981 >
982 component or any of its options will have a value of
983 <TT
984 CLASS="LITERAL"
985 >0</TT
986 > for the purposes of expression evaluation. No
987 <TT
988 CLASS="LITERAL"
989 >#define's</TT
990 > will be generated for the component or
991 any of its options, and the file <TT
992 CLASS="FILENAME"
993 >stdlib/rand.cxx</TT
994 >
995 will not get compiled. There is nothing special about the C library
996 here, exactly the same would apply for say a device driver that does
997 not correspond to any of the devices on the target hardware.</P
998 ><P
999 >Assuming the C library is loaded, the next thing to consider is
1000 whether or not the component and its options are active. The component
1001 is layered immediately below the C library package itself, so if the
1002 package is loaded then it is safe to assume that the package is also
1003 enabled. Therefore the parent of <TT
1004 CLASS="VARNAME"
1005 >CYGPKG_LIBC_RAND</TT
1006 >
1007 is active and enabled, and in the absence of any <SPAN
1008 CLASS="PROPERTY"
1009 >active_if</SPAN
1010 >
1011 properties <TT
1012 CLASS="VARNAME"
1013 >CYGPKG_LIBC_RAND</TT
1014 > will be active as well.</P
1015 ><P
1016 >The component <TT
1017 CLASS="VARNAME"
1018 >CYGPKG_LIBC_RAND</TT
1019 > has the flavor
1020 <TT
1021 CLASS="LITERAL"
1022 >none</TT
1023 >. This means the component cannot be disabled.
1024 Therefore all the options in this component have an active and enabled
1025 parent, and in the absence of any <SPAN
1026 CLASS="PROPERTY"
1027 >active_if</SPAN
1028 > properties they are all
1029 active as well.</P
1030 ><P
1031 >The component's flavor <TT
1032 CLASS="LITERAL"
1033 >none</TT
1034 > serves to group
1035 together all of the configuration options related to random number
1036 generation. This is particularly useful in the context of the
1037 graphical configuration tool, but it also helps when it comes to
1038 naming the options: all of the options begin with
1039 <TT
1040 CLASS="LITERAL"
1041 >CYGxxx_LIBC_RAND</TT
1042 >, giving a clear hint about both
1043 the package and the component within that package. The flavor means
1044 that the component is always enabled and has the value
1045 <TT
1046 CLASS="LITERAL"
1047 >1</TT
1048 > for the purposes of expression evaluation. There
1049 will always be a single <TT
1050 CLASS="LITERAL"
1051 >#define</TT
1052 > of the form:</P
1053 ><TABLE
1054 BORDER="5"
1055 BGCOLOR="#E0E0F0"
1056 WIDTH="70%"
1057 ><TR
1058 ><TD
1059 ><PRE
1060 CLASS="PROGRAMLISTING"
1061 >#define CYGPKG_LIBC_RAND 1</PRE
1062 ></TD
1063 ></TR
1064 ></TABLE
1065 ><P
1066 >In addition the file <TT
1067 CLASS="FILENAME"
1068 >stdlib/rand.cxx</TT
1069 > will always
1070 get built. If the component had the default <TT
1071 CLASS="LITERAL"
1072 >bool</TT
1073 >
1074 flavor then users would be able to disable the whole component,
1075 and one less file would need to be built. However random number
1076 generation is relatively simple, so the impact on eCos build times are
1077 small. Furthermore by default the code has no dependencies on other
1078 parts of the system, so compiling the code has no unexpected side
1079 effects. Even if it was possible to disable the component, the
1080 sensible default for most applications would still leave it enabled.
1081 The net result is that the flavor <TT
1082 CLASS="LITERAL"
1083 >none</TT
1084 > is probably
1085 the most sensible one for this component. For other components the
1086 default <TT
1087 CLASS="LITERAL"
1088 >bool</TT
1089 > flavor or one of the other flavors
1090 might be more appropriate.</P
1091 ><P
1092 >Next consider option <TT
1093 CLASS="VARNAME"
1094 >CYGSEM_LIBC_PER_THREAD_RAND</TT
1095 >
1096 which can be used to get a per-thread random number seed, possibly
1097 useful if the application needs a consistent sequence of random
1098 numbers. In the absence of a <SPAN
1099 CLASS="PROPERTY"
1100 >flavor</SPAN
1101 > property this option will be
1102 boolean, and the <SPAN
1103 CLASS="PROPERTY"
1104 >default_value</SPAN
1105 > property means that it is disabled by
1106 default&nbsp;&#8212; reasonable since few applications need this
1107 particular functionality, and it does impose a constraint on the rest
1108 of the system. If the option is left disabled then no
1109 <TT
1110 CLASS="LITERAL"
1111 >#define</TT
1112 > will be generated, and if there were any
1113 <SPAN
1114 CLASS="PROPERTY"
1115 >compile</SPAN
1116 > or similar properties these would not take effect. If the
1117 option is enabled then a <TT
1118 CLASS="LITERAL"
1119 >#define</TT
1120 > will be generated,
1121 using the option's data part which is fixed at <TT
1122 CLASS="LITERAL"
1123 >1</TT
1124 >:</P
1125 ><TABLE
1126 BORDER="5"
1127 BGCOLOR="#E0E0F0"
1128 WIDTH="70%"
1129 ><TR
1130 ><TD
1131 ><PRE
1132 CLASS="PROGRAMLISTING"
1133 >#define CYGSEM_LIBC_PER_THREAD_RAND 1</PRE
1134 ></TD
1135 ></TR
1136 ></TABLE
1137 ><P
1138 >The <TT
1139 CLASS="VARNAME"
1140 >CYGSEM_LIBC_PER_THREAD_RAND</TT
1141 > option has a
1142 <SPAN
1143 CLASS="PROPERTY"
1144 >requires</SPAN
1145 > constraint on
1146 <TT
1147 CLASS="VARNAME"
1148 >CYGVAR_KERNEL_THREADS_DATA</TT
1149 >. If the C library option
1150 is enabled then the constraint should be satisfied, or else the
1151 configuration contains a conflict. If the configuration does not
1152 include the kernel package then
1153 <TT
1154 CLASS="VARNAME"
1155 >CYGVAR_KERNEL_THREADS_DATA</TT
1156 > will evaluate to
1157 <TT
1158 CLASS="LITERAL"
1159 >0</TT
1160 > and the constraint is not satisfied. Similarly if
1161 the option is inactive or disabled the constraint will not be
1162 satisfied.</P
1163 ><P
1164 ><TT
1165 CLASS="VARNAME"
1166 >CYGNUM_LIBC_RAND_SEED</TT
1167 > and
1168 <TT
1169 CLASS="VARNAME"
1170 >CYGNUM_LIBC_RAND_TRACE_LEVEL</TT
1171 > both have the
1172 <TT
1173 CLASS="LITERAL"
1174 >data</TT
1175 > flavor, so they are always enabled and the
1176 component framework will generate appropriate
1177 <TT
1178 CLASS="LITERAL"
1179 >#define's</TT
1180 >:</P
1181 ><TABLE
1182 BORDER="5"
1183 BGCOLOR="#E0E0F0"
1184 WIDTH="70%"
1185 ><TR
1186 ><TD
1187 ><PRE
1188 CLASS="PROGRAMLISTING"
1189 >#define CYGNUM_LIBC_RAND_SEED 1
1190 #define CYGNUM_LIBC_RAND_SEED_1
1191 #define CYGNUM_LIBC_RAND_TRACE_LEVEL 0
1192 #define CYGNUM_LIBC_RAND_TRACE_LEVEL_0</PRE
1193 ></TD
1194 ></TR
1195 ></TABLE
1196 ><P
1197 >Neither option has a <SPAN
1198 CLASS="PROPERTY"
1199 >compile</SPAN
1200 > or similar property, but any such
1201 properties would take effect. Any references to these options in <SPAN
1202 CLASS="APPLICATION"
1203 >CDL</SPAN
1204 >
1205 expressions would evaluate to the data part, so a hypothetical
1206 constraint of the form
1207 <TT
1208 CLASS="LITERAL"
1209 >{&nbsp;requires&nbsp;CYGNUM_LIBC_RAND_SEED&nbsp;&gt;&nbsp;42&nbsp;}</TT
1210 >
1211 would not be satisfied with the default values. Both options use a
1212 simple constant for the <SPAN
1213 CLASS="PROPERTY"
1214 >default_value</SPAN
1215 > expression. It would be
1216 possible to use a more complicated expression, for example the default
1217 for <TT
1218 CLASS="VARNAME"
1219 >CYGNUM_LIBC_RAND_TRACE_LEVEL</TT
1220 > could be
1221 determined from some global debugging option or from a debugging
1222 option that applies to the C library as a whole. Both options also
1223 have a <SPAN
1224 CLASS="PROPERTY"
1225 >legal_values</SPAN
1226 > constraint, which must be satisfied since the
1227 options are active and enabled. </P
1228 ><DIV
1229 CLASS="NOTE"
1230 ><BLOCKQUOTE
1231 CLASS="NOTE"
1232 ><P
1233 ><B
1234 >Note: </B
1235 >The value <TT
1236 CLASS="LITERAL"
1237 >0</TT
1238 > is legal for both
1239 <TT
1240 CLASS="VARNAME"
1241 >CYGNUM_LIBC_RAND_SEED</TT
1242 > and
1243 <TT
1244 CLASS="VARNAME"
1245 >CYGNUM_LIBC_RAND_TRACE_LEVEL</TT
1246 >, so in a <SPAN
1247 CLASS="APPLICATION"
1248 >CDL</SPAN
1249 >
1250 expression there is no easy way of distinguishing between the options
1251 being absent or having that particular value. This will be addressed
1252 by future enhancements to the expression syntax.</P
1253 ></BLOCKQUOTE
1254 ></DIV
1255 ></DIV
1256 ></DIV
1257 ><DIV
1258 CLASS="SECT2"
1259 ><H2
1260 CLASS="SECT2"
1261 ><A
1262 NAME="LANGUAGE.EXPRESSION">Ordinary Expressions</H2
1263 ><P
1264 >Expressions in <SPAN
1265 CLASS="APPLICATION"
1266 >CDL</SPAN
1267 > follow a conventional syntax, for example:</P
1268 ><TABLE
1269 BORDER="5"
1270 BGCOLOR="#E0E0F0"
1271 WIDTH="70%"
1272 ><TR
1273 ><TD
1274 ><PRE
1275 CLASS="PROGRAMLISTING"
1276 >    default_value CYGGLO_CODESIZE &gt; CYGGLO_SPEED
1277     default_value { (CYG_HAL_STARTUP == "RAM" &#38;&#38;
1278                      !CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS &#38;&#38;
1279                      !CYGINT_HAL_USE_ROM_MONITOR_UNSUPPORTED &#38;&#38;
1280                      !CYGSEM_HAL_POWERPC_COPY_VECTORS) ? 1 : 0 }
1281     default_value { "\"/dev/ser0\"" }</PRE
1282 ></TD
1283 ></TR
1284 ></TABLE
1285 ><P
1286 >However there is a complication in that the various arguments to a
1287 <SPAN
1288 CLASS="PROPERTY"
1289 >default_value</SPAN
1290 > property will first get processed by a <SPAN
1291 CLASS="APPLICATION"
1292 >Tcl</SPAN
1293 >
1294 interpreter, so special characters like quotes and square brackets may
1295 get processed. Such problems can be avoided by enclosing non-trivial
1296 expressions in braces, as in the second example above. The way
1297 expression parsing actually works is as follows:</P
1298 ><P
1299 ></P
1300 ><OL
1301 TYPE="1"
1302 ><LI
1303 ><P
1304 >The <SPAN
1305 CLASS="APPLICATION"
1306 >Tcl</SPAN
1307 > interpreter splits the line or lines into a command and its
1308 arguments. In the first <SPAN
1309 CLASS="PROPERTY"
1310 >default_value</SPAN
1311 > expression above the command
1312 is <TT
1313 CLASS="LITERAL"
1314 >default_value</TT
1315 > and there are three arguments,
1316 <TT
1317 CLASS="LITERAL"
1318 >CYGGLO_CODESIZE</TT
1319 >, <TT
1320 CLASS="LITERAL"
1321 >&gt;</TT
1322 > and
1323 <TT
1324 CLASS="LITERAL"
1325 >CYGGLO_SPEED</TT
1326 >. In the second and third examples
1327 there is just one argument, courtesy of the braces.</P
1328 ></LI
1329 ><LI
1330 ><P
1331 >Next option processing takes place, so any initial arguments that
1332 begin with a hyphen will be interpreted as options. This can cause
1333 problems if the expression involves a negative number, so the
1334 special argument <TT
1335 CLASS="LITERAL"
1336 >--</TT
1337 > can be used to prevent option
1338 processing on the subsequent arguments.</P
1339 ></LI
1340 ><LI
1341 ><P
1342 >All of the arguments are now concatenated, with a single space in
1343 between each one. Hence the following two expressions are equivalent,
1344 even though they will have been processed differently up to this point.</P
1345 ><TABLE
1346 BORDER="5"
1347 BGCOLOR="#E0E0F0"
1348 WIDTH="70%"
1349 ><TR
1350 ><TD
1351 ><PRE
1352 CLASS="PROGRAMLISTING"
1353 >    default_value CYGGLO_CODESIZE &gt; CYGGLO_SPEED
1354     default_value {CYGGLO_CODESIZE &gt; CYGGLO_SPEED}</PRE
1355 ></TD
1356 ></TR
1357 ></TABLE
1358 ></LI
1359 ><LI
1360 ><P
1361 >The expression parsing code now has a single string to process.</P
1362 ></LI
1363 ></OL
1364 ><P
1365 ><SPAN
1366 CLASS="APPLICATION"
1367 >CDL</SPAN
1368 > expressions consist of four types of element: references to
1369 configuration options, constant strings, integers, and floating point
1370 numbers. These are combined using a conventional set of operators: the
1371 unary operators <TT
1372 CLASS="LITERAL"
1373 >-</TT
1374 >, <TT
1375 CLASS="LITERAL"
1376 >~</TT
1377 > and
1378 <TT
1379 CLASS="LITERAL"
1380 >!</TT
1381 >; the arithmetic operators <TT
1382 CLASS="LITERAL"
1383 >+</TT
1384 >,
1385 <TT
1386 CLASS="LITERAL"
1387 >-</TT
1388 >, <TT
1389 CLASS="LITERAL"
1390 >*</TT
1391 >, <TT
1392 CLASS="LITERAL"
1393 >/</TT
1394 > and
1395 <TT
1396 CLASS="LITERAL"
1397 >%</TT
1398 >; the shift operators <TT
1399 CLASS="LITERAL"
1400 >&lt;&lt;</TT
1401 >
1402 and <TT
1403 CLASS="LITERAL"
1404 >&gt;&gt;</TT
1405 >; the comparison operators
1406 <TT
1407 CLASS="LITERAL"
1408 >==</TT
1409 >, <TT
1410 CLASS="LITERAL"
1411 >!=</TT
1412 >, <TT
1413 CLASS="LITERAL"
1414 >&lt;</TT
1415 >,
1416 <TT
1417 CLASS="LITERAL"
1418 >&lt;=</TT
1419 >, <TT
1420 CLASS="LITERAL"
1421 >&gt;</TT
1422 > and
1423 <TT
1424 CLASS="LITERAL"
1425 >&gt;=</TT
1426 >; the bitwise operators
1427 <TT
1428 CLASS="LITERAL"
1429 >&amp;</TT
1430 >, <TT
1431 CLASS="LITERAL"
1432 >^</TT
1433 > and
1434 <TT
1435 CLASS="LITERAL"
1436 >|</TT
1437 >; the logical operators <TT
1438 CLASS="LITERAL"
1439 >&#38;&#38;</TT
1440 > and
1441 <TT
1442 CLASS="LITERAL"
1443 >||</TT
1444 >; the string concatenation operator
1445 <TT
1446 CLASS="LITERAL"
1447 >.</TT
1448 >; and the ternary conditional operator
1449 <TT
1450 CLASS="LITERAL"
1451 >A&nbsp;?&nbsp;B&nbsp;:&nbsp;C</TT
1452 >. There is also support for
1453 some less widely available operators for logical equivalence and
1454 implication, and for a set of function-style operations. Bracketed
1455 sub-expressions are supported, and the operators have the usual
1456 precedence:</P
1457 ><DIV
1458 CLASS="INFORMALTABLE"
1459 ><A
1460 NAME="AEN1653"><P
1461 ></P
1462 ><TABLE
1463 BORDER="1"
1464 CLASS="CALSTABLE"
1465 ><THEAD
1466 ><TR
1467 ><TH
1468 WIDTH="33%"
1469 ALIGN="CENTER"
1470 VALIGN="TOP"
1471 >Priority</TH
1472 ><TH
1473 WIDTH="33%"
1474 ALIGN="CENTER"
1475 VALIGN="TOP"
1476 >Operators</TH
1477 ><TH
1478 WIDTH="33%"
1479 ALIGN="CENTER"
1480 VALIGN="TOP"
1481 >Category</TH
1482 ></TR
1483 ></THEAD
1484 ><TBODY
1485 ><TR
1486 ><TD
1487 WIDTH="33%"
1488 ALIGN="CENTER"
1489 VALIGN="TOP"
1490 >16</TD
1491 ><TD
1492 WIDTH="33%"
1493 ALIGN="CENTER"
1494 VALIGN="TOP"
1495 >references, constants</TD
1496 ><TD
1497 WIDTH="33%"
1498 ALIGN="CENTER"
1499 VALIGN="TOP"
1500 >basic elements</TD
1501 ></TR
1502 ><TR
1503 ><TD
1504 WIDTH="33%"
1505 ALIGN="CENTER"
1506 VALIGN="TOP"
1507 >15</TD
1508 ><TD
1509 WIDTH="33%"
1510 ALIGN="CENTER"
1511 VALIGN="TOP"
1512 ><TT
1513 CLASS="LITERAL"
1514 >f(a, b, c)</TT
1515 ></TD
1516 ><TD
1517 WIDTH="33%"
1518 ALIGN="CENTER"
1519 VALIGN="TOP"
1520 >function calls</TD
1521 ></TR
1522 ><TR
1523 ><TD
1524 WIDTH="33%"
1525 ALIGN="CENTER"
1526 VALIGN="TOP"
1527 >14</TD
1528 ><TD
1529 WIDTH="33%"
1530 ALIGN="CENTER"
1531 VALIGN="TOP"
1532 ><TT
1533 CLASS="LITERAL"
1534 >~</TT
1535 ></TD
1536 ><TD
1537 WIDTH="33%"
1538 ALIGN="CENTER"
1539 VALIGN="TOP"
1540 >bitwise not</TD
1541 ></TR
1542 ><TR
1543 ><TD
1544 WIDTH="33%"
1545 ALIGN="CENTER"
1546 VALIGN="TOP"
1547 >14</TD
1548 ><TD
1549 WIDTH="33%"
1550 ALIGN="CENTER"
1551 VALIGN="TOP"
1552 ><TT
1553 CLASS="LITERAL"
1554 >!</TT
1555 ></TD
1556 ><TD
1557 WIDTH="33%"
1558 ALIGN="CENTER"
1559 VALIGN="TOP"
1560 >logical not</TD
1561 ></TR
1562 ><TR
1563 ><TD
1564 WIDTH="33%"
1565 ALIGN="CENTER"
1566 VALIGN="TOP"
1567 >14</TD
1568 ><TD
1569 WIDTH="33%"
1570 ALIGN="CENTER"
1571 VALIGN="TOP"
1572 ><TT
1573 CLASS="LITERAL"
1574 >-</TT
1575 ></TD
1576 ><TD
1577 WIDTH="33%"
1578 ALIGN="CENTER"
1579 VALIGN="TOP"
1580 >arithmetic negation</TD
1581 ></TR
1582 ><TR
1583 ><TD
1584 WIDTH="33%"
1585 ALIGN="CENTER"
1586 VALIGN="TOP"
1587 >13</TD
1588 ><TD
1589 WIDTH="33%"
1590 ALIGN="CENTER"
1591 VALIGN="TOP"
1592 ><TT
1593 CLASS="LITERAL"
1594 >* / %</TT
1595 ></TD
1596 ><TD
1597 WIDTH="33%"
1598 ALIGN="CENTER"
1599 VALIGN="TOP"
1600 >multiplicative arithmetic</TD
1601 ></TR
1602 ><TR
1603 ><TD
1604 WIDTH="33%"
1605 ALIGN="CENTER"
1606 VALIGN="TOP"
1607 >12</TD
1608 ><TD
1609 WIDTH="33%"
1610 ALIGN="CENTER"
1611 VALIGN="TOP"
1612 ><TT
1613 CLASS="LITERAL"
1614 >+ - .</TT
1615 ></TD
1616 ><TD
1617 WIDTH="33%"
1618 ALIGN="CENTER"
1619 VALIGN="TOP"
1620 >additive arithmetic and string concatenation</TD
1621 ></TR
1622 ><TR
1623 ><TD
1624 WIDTH="33%"
1625 ALIGN="CENTER"
1626 VALIGN="TOP"
1627 >11</TD
1628 ><TD
1629 WIDTH="33%"
1630 ALIGN="CENTER"
1631 VALIGN="TOP"
1632 ><TT
1633 CLASS="LITERAL"
1634 >&lt;&lt; &gt;&gt;</TT
1635 ></TD
1636 ><TD
1637 WIDTH="33%"
1638 ALIGN="CENTER"
1639 VALIGN="TOP"
1640 >bitwise shifts</TD
1641 ></TR
1642 ><TR
1643 ><TD
1644 WIDTH="33%"
1645 ALIGN="CENTER"
1646 VALIGN="TOP"
1647 >10</TD
1648 ><TD
1649 WIDTH="33%"
1650 ALIGN="CENTER"
1651 VALIGN="TOP"
1652 ><TT
1653 CLASS="LITERAL"
1654 >&lt;= &lt; &gt; &gt;=</TT
1655 ></TD
1656 ><TD
1657 WIDTH="33%"
1658 ALIGN="CENTER"
1659 VALIGN="TOP"
1660 >inequality</TD
1661 ></TR
1662 ><TR
1663 ><TD
1664 WIDTH="33%"
1665 ALIGN="CENTER"
1666 VALIGN="TOP"
1667 >9</TD
1668 ><TD
1669 WIDTH="33%"
1670 ALIGN="CENTER"
1671 VALIGN="TOP"
1672 ><TT
1673 CLASS="LITERAL"
1674 >== !=</TT
1675 ></TD
1676 ><TD
1677 WIDTH="33%"
1678 ALIGN="CENTER"
1679 VALIGN="TOP"
1680 >comparison</TD
1681 ></TR
1682 ><TR
1683 ><TD
1684 WIDTH="33%"
1685 ALIGN="CENTER"
1686 VALIGN="TOP"
1687 >8</TD
1688 ><TD
1689 WIDTH="33%"
1690 ALIGN="CENTER"
1691 VALIGN="TOP"
1692 ><TT
1693 CLASS="LITERAL"
1694 >&#38;</TT
1695 ></TD
1696 ><TD
1697 WIDTH="33%"
1698 ALIGN="CENTER"
1699 VALIGN="TOP"
1700 >bitwise and</TD
1701 ></TR
1702 ><TR
1703 ><TD
1704 WIDTH="33%"
1705 ALIGN="CENTER"
1706 VALIGN="TOP"
1707 >7</TD
1708 ><TD
1709 WIDTH="33%"
1710 ALIGN="CENTER"
1711 VALIGN="TOP"
1712 ><TT
1713 CLASS="LITERAL"
1714 >^</TT
1715 ></TD
1716 ><TD
1717 WIDTH="33%"
1718 ALIGN="CENTER"
1719 VALIGN="TOP"
1720 >bitwise xor</TD
1721 ></TR
1722 ><TR
1723 ><TD
1724 WIDTH="33%"
1725 ALIGN="CENTER"
1726 VALIGN="TOP"
1727 >6</TD
1728 ><TD
1729 WIDTH="33%"
1730 ALIGN="CENTER"
1731 VALIGN="TOP"
1732 ><TT
1733 CLASS="LITERAL"
1734 >|</TT
1735 ></TD
1736 ><TD
1737 WIDTH="33%"
1738 ALIGN="CENTER"
1739 VALIGN="TOP"
1740 >bitwise or</TD
1741 ></TR
1742 ><TR
1743 ><TD
1744 WIDTH="33%"
1745 ALIGN="CENTER"
1746 VALIGN="TOP"
1747 >5</TD
1748 ><TD
1749 WIDTH="33%"
1750 ALIGN="CENTER"
1751 VALIGN="TOP"
1752 ><TT
1753 CLASS="LITERAL"
1754 >&#38;&#38;</TT
1755 ></TD
1756 ><TD
1757 WIDTH="33%"
1758 ALIGN="CENTER"
1759 VALIGN="TOP"
1760 >logical and</TD
1761 ></TR
1762 ><TR
1763 ><TD
1764 WIDTH="33%"
1765 ALIGN="CENTER"
1766 VALIGN="TOP"
1767 >4</TD
1768 ><TD
1769 WIDTH="33%"
1770 ALIGN="CENTER"
1771 VALIGN="TOP"
1772 ><TT
1773 CLASS="LITERAL"
1774 >||</TT
1775 ></TD
1776 ><TD
1777 WIDTH="33%"
1778 ALIGN="CENTER"
1779 VALIGN="TOP"
1780 >logical or</TD
1781 ></TR
1782 ><TR
1783 ><TD
1784 WIDTH="33%"
1785 ALIGN="CENTER"
1786 VALIGN="TOP"
1787 >3</TD
1788 ><TD
1789 WIDTH="33%"
1790 ALIGN="CENTER"
1791 VALIGN="TOP"
1792 ><TT
1793 CLASS="LITERAL"
1794 >xor, eqv</TT
1795 ></TD
1796 ><TD
1797 WIDTH="33%"
1798 ALIGN="CENTER"
1799 VALIGN="TOP"
1800 >logical equivalance</TD
1801 ></TR
1802 ><TR
1803 ><TD
1804 WIDTH="33%"
1805 ALIGN="CENTER"
1806 VALIGN="TOP"
1807 >2</TD
1808 ><TD
1809 WIDTH="33%"
1810 ALIGN="CENTER"
1811 VALIGN="TOP"
1812 ><TT
1813 CLASS="LITERAL"
1814 >implies</TT
1815 ></TD
1816 ><TD
1817 WIDTH="33%"
1818 ALIGN="CENTER"
1819 VALIGN="TOP"
1820 >logical implication</TD
1821 ></TR
1822 ><TR
1823 ><TD
1824 WIDTH="33%"
1825 ALIGN="CENTER"
1826 VALIGN="TOP"
1827 >1</TD
1828 ><TD
1829 WIDTH="33%"
1830 ALIGN="CENTER"
1831 VALIGN="TOP"
1832 ><TT
1833 CLASS="LITERAL"
1834 >? :</TT
1835 ></TD
1836 ><TD
1837 WIDTH="33%"
1838 ALIGN="CENTER"
1839 VALIGN="TOP"
1840 >conditional</TD
1841 ></TR
1842 ></TBODY
1843 ></TABLE
1844 ><P
1845 ></P
1846 ></DIV
1847 ><P
1848 >Function calls have the usual format of a name, an opening bracket,
1849 one or more arguments separated by commas, and a closing bracket. For
1850 example:</P
1851 ><TABLE
1852 BORDER="5"
1853 BGCOLOR="#E0E0F0"
1854 WIDTH="70%"
1855 ><TR
1856 ><TD
1857 ><PRE
1858 CLASS="PROGRAMLISTING"
1859 >    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, " -fno-rtti") }</PRE
1860 ></TD
1861 ></TR
1862 ></TABLE
1863 ><P
1864 >Functions will differ in the number of arguments and may impose
1865 restrictions on some or all of their arguments. For example it may be
1866 necessary for the first argument to be a reference to a configuration
1867 option. The available functions are described in <A
1868 HREF="language.values.html#LANGUAGE.FUNCTIONS"
1869 >the Section called <I
1870 >Functions</I
1871 ></A
1872 >. </P
1873 ><P
1874 >The logical <TT
1875 CLASS="LITERAL"
1876 >xor</TT
1877 > operator evaluates to true if
1878 either the left hand side or the right hand side but not both evaluate
1879 to true The logical <TT
1880 CLASS="LITERAL"
1881 >eqv</TT
1882 > operator evaluates to true
1883 if both the left and right hand sides evaluate to true, or if both
1884 evaluate to false. The <TT
1885 CLASS="LITERAL"
1886 >implies</TT
1887 > operator evaluates
1888 to true either if the left hand side is false or if the right hand
1889 side is true, in other words <TT
1890 CLASS="LITERAL"
1891 >A&nbsp;implies&nbsp;B</TT
1892 >
1893 has the same meaning as <TT
1894 CLASS="LITERAL"
1895 >!A&nbsp;||&nbsp;B</TT
1896 >. An
1897 example use would be:</P
1898 ><TABLE
1899 BORDER="5"
1900 BGCOLOR="#E0E0F0"
1901 WIDTH="70%"
1902 ><TR
1903 ><TD
1904 ><PRE
1905 CLASS="PROGRAMLISTING"
1906 >    requires { is_active(CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE) implies
1907                    (CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE &#62;= (16 * 1024)) }</PRE
1908 ></TD
1909 ></TR
1910 ></TABLE
1911 ><P
1912 >This constraint would be satisfied if either the support for a main
1913 stack size is disabled, or if that stack is at least 16K. However if
1914 such a stack were in use but was too small, a conflict would be raised.</P
1915 ><P
1916 >A valid <SPAN
1917 CLASS="APPLICATION"
1918 >CDL</SPAN
1919 > identifier in an expression, for example
1920 <TT
1921 CLASS="VARNAME"
1922 >CYGGLO_SPEED</TT
1923 >, will be interpreted as a reference to
1924 a configuration option by that name. The option does not have to be
1925 loaded into the current configuration. When the component framework
1926 evaluates the expression it will substitute in a suitable value that
1927 depends on whether or not the option is loaded, active, and enabled.
1928 The exact rules are described in <A
1929 HREF="language.values.html#LANGUAGE.VALUES.VALUE"
1930 >the Section called <I
1931 >Option Values</I
1932 ></A
1933 >.</P
1934 ><P
1935 >A constant string is any sequence of characters enclosed in quotes.
1936 Care has to be taken that these quotes are not stripped off by the
1937 <SPAN
1938 CLASS="APPLICATION"
1939 >Tcl</SPAN
1940 > interpreter before the <SPAN
1941 CLASS="APPLICATION"
1942 >CDL</SPAN
1943 > expression parser sees them.
1944 Consider the following:</P
1945 ><TABLE
1946 BORDER="5"
1947 BGCOLOR="#E0E0F0"
1948 WIDTH="70%"
1949 ><TR
1950 ><TD
1951 ><PRE
1952 CLASS="PROGRAMLISTING"
1953 >    default_value "RAM"</PRE
1954 ></TD
1955 ></TR
1956 ></TABLE
1957 ><P
1958 >The quote marks will be stripped before the <SPAN
1959 CLASS="APPLICATION"
1960 >CDL</SPAN
1961 > expression parser
1962 sees the data, so the expression will be interpreted as a reference to
1963 a configuration option <TT
1964 CLASS="VARNAME"
1965 >RAM</TT
1966 >. There is unlikely to be
1967 such an option, so the actual default value will be
1968 <TT
1969 CLASS="LITERAL"
1970 >0</TT
1971 >. Careful use of braces or other <SPAN
1972 CLASS="APPLICATION"
1973 >Tcl</SPAN
1974 > quoting
1975 mechanisms can be used to avoid such problems.</P
1976 ><P
1977 >               
1978 String constants consist of the data inside the quotes. If the data
1979 itself needs to contain quote characters then appropriate quoting is
1980 again necessary, for example:</P
1981 ><TABLE
1982 BORDER="5"
1983 BGCOLOR="#E0E0F0"
1984 WIDTH="70%"
1985 ><TR
1986 ><TD
1987 ><PRE
1988 CLASS="PROGRAMLISTING"
1989 >    default_value { "\"/dev/ser0\"" }</PRE
1990 ></TD
1991 ></TR
1992 ></TABLE
1993 ><P
1994 >An integer constant consists of a sequence of digits, optionally
1995 preceeded with the unary <TT
1996 CLASS="LITERAL"
1997 >+</TT
1998 > or <TT
1999 CLASS="LITERAL"
2000 >-</TT
2001 >
2002 operators. As usual the sequence <TT
2003 CLASS="LITERAL"
2004 >0x</TT
2005 > or
2006 <TT
2007 CLASS="LITERAL"
2008 >0X</TT
2009 > can be used for hexadecimal data, and a leading
2010 <TT
2011 CLASS="LITERAL"
2012 >0</TT
2013 > indicates octal data. Internally the component
2014 framework uses 64-bit arithmetic for integer data. If a constant is
2015 too large then double precision arithmetic will be used instead.
2016 Traditional syntax is also used for double precision numbers, for
2017 example <TT
2018 CLASS="LITERAL"
2019 >3.141592</TT
2020 > or <TT
2021 CLASS="LITERAL"
2022 >-3E6</TT
2023 >. </P
2024 ><P
2025 >Of course this is not completely accurate: <SPAN
2026 CLASS="APPLICATION"
2027 >CDL</SPAN
2028 > is not a typed
2029 language, all data is treated as if it were a string. For example the
2030 following two lines are equivalent:</P
2031 ><TABLE
2032 BORDER="5"
2033 BGCOLOR="#E0E0F0"
2034 WIDTH="70%"
2035 ><TR
2036 ><TD
2037 ><PRE
2038 CLASS="PROGRAMLISTING"
2039 >    requires CYGNUM_UITRON_SEMAS &#62; 10
2040     requires { CYGNUM_UITRON_SEMAS &#62; "10" }</PRE
2041 ></TD
2042 ></TR
2043 ></TABLE
2044 ><P
2045 >When an expression gets evaluated the operators will attempt
2046 appropriate conversions. The <TT
2047 CLASS="LITERAL"
2048 >&gt;</TT
2049 > comparison
2050 operator can be used on either integer or double precision numbers, so
2051 it will begin by attempting a string to integer conversion of both
2052 operands. If that fails it will attempt string to double conversions.
2053 If that fails as well then the component framework will report a
2054 conflict, an evaluation exception. If the conversions from string to
2055 integer are successful then the result will be either the string
2056 <TT
2057 CLASS="LITERAL"
2058 >0</TT
2059 > or the string <TT
2060 CLASS="LITERAL"
2061 >1</TT
2062 >, both of which
2063 can be converted to integers or doubles as required.</P
2064 ><P
2065 >It is worth noting that the expression
2066 <TT
2067 CLASS="LITERAL"
2068 >CYGNUM_UITRON_SEMAS&nbsp;&gt;10</TT
2069 > is not ambiguous.
2070 <SPAN
2071 CLASS="APPLICATION"
2072 >CDL</SPAN
2073 > identifiers can never begin with a digit, so it is not possible
2074 for <TT
2075 CLASS="LITERAL"
2076 >10</TT
2077 > to be misinterpreted as a reference to an
2078 identifier instead of as a string.</P
2079 ><P
2080 >Of course the implementation is slightly different again. The <SPAN
2081 CLASS="APPLICATION"
2082 >CDL</SPAN
2083 >
2084 language definition is such that all data is treated as if it were a
2085 string, with conversions to integer, double or boolean as and when
2086 required. The implementation is allowed to avoid conversions until
2087 they are necessary. For example, given
2088 <TT
2089 CLASS="LITERAL"
2090 >CYGNUM_UITRON_SEMAS&nbsp;&gt;&nbsp;10</TT
2091 > the
2092 expression parsing code will perform an immediate conversion from
2093 string to integer, storing the integer representation, and there is no
2094 need for a conversion by the comparison operator when the expression
2095 gets evaluated. Given
2096 <TT
2097 CLASS="LITERAL"
2098 >{&nbsp;CYGNUM_UITRON_SEMAS&nbsp;&gt;&nbsp;"10"&nbsp;}</TT
2099 >
2100 the parsing code will store the string representation and a conversion
2101 happens the first time the expression is evaluated. All of this is an
2102 implementation detail, and does not affect the semantics of the
2103 language. </P
2104 ><P
2105 >Different operators have different requirements, for example the
2106 bitwise or operator only makes sense if both operands have an integer
2107 representation. For operators which can work with either integer or
2108 double precision numbers, integer arithmetic will be preferred.</P
2109 ><P
2110 >The following operators only accept integer operands:
2111 unary <TT
2112 CLASS="LITERAL"
2113 >~</TT
2114 > (bitwise not), the shift operators
2115 <TT
2116 CLASS="LITERAL"
2117 >&lt;&lt;</TT
2118 > and <TT
2119 CLASS="LITERAL"
2120 >&gt;&gt;</TT
2121 >, and the
2122 bitwise operators <TT
2123 CLASS="LITERAL"
2124 >&#38;</TT
2125 >, <TT
2126 CLASS="LITERAL"
2127 >|</TT
2128 > and
2129 <TT
2130 CLASS="LITERAL"
2131 >^</TT
2132 >.</P
2133 ><P
2134 >The following operators will attempt integer arithmetic first, then
2135 double precision arithmetic: unary <TT
2136 CLASS="LITERAL"
2137 >-</TT
2138 >,
2139 the arithmetic operators <TT
2140 CLASS="LITERAL"
2141 >+</TT
2142 >, <TT
2143 CLASS="LITERAL"
2144 >-</TT
2145 >,
2146 <TT
2147 CLASS="LITERAL"
2148 >*</TT
2149 >, <TT
2150 CLASS="LITERAL"
2151 >/</TT
2152 >, and <TT
2153 CLASS="LITERAL"
2154 >%</TT
2155 >;
2156 and the comparision operators <TT
2157 CLASS="LITERAL"
2158 >&lt;</TT
2159 >,
2160 <TT
2161 CLASS="LITERAL"
2162 >&lt;=</TT
2163 >, <TT
2164 CLASS="LITERAL"
2165 >&gt;</TT
2166 > and
2167 <TT
2168 CLASS="LITERAL"
2169 >&gt;=</TT
2170 >. </P
2171 ><P
2172 >The equality <TT
2173 CLASS="LITERAL"
2174 >==</TT
2175 > and inequality
2176 <TT
2177 CLASS="LITERAL"
2178 >!=</TT
2179 > operators will first attempt integer conversion
2180 and comparison. If that fails then double precision will be attempted
2181 (although arguably using these operators on double precision data is
2182 not sensible). As a last resort string comparison will be used.</P
2183 ><P
2184 >The operators <TT
2185 CLASS="LITERAL"
2186 >!</TT
2187 >, <TT
2188 CLASS="LITERAL"
2189 >&#38;&#38;</TT
2190 > and
2191 <TT
2192 CLASS="LITERAL"
2193 >||</TT
2194 > all work with boolean data. Any string that can
2195 be converted to the integer <TT
2196 CLASS="LITERAL"
2197 >0</TT
2198 > or the double
2199 <TT
2200 CLASS="LITERAL"
2201 >0.0</TT
2202 > is treated as false, as is the empty string or
2203 the constant string <TT
2204 CLASS="LITERAL"
2205 >false</TT
2206 >. Anything else is
2207 interpreted as true. The result is either <TT
2208 CLASS="LITERAL"
2209 >0</TT
2210 > or
2211 <TT
2212 CLASS="LITERAL"
2213 >1</TT
2214 >.</P
2215 ><P
2216 >The conditional operator <TT
2217 CLASS="LITERAL"
2218 >?&nbsp;:</TT
2219 > will interpret
2220 its first operand as a boolean. It does not perform any processing on
2221 the second or third operands.</P
2222 ><P
2223 >In practice it is rarely necessary to worry about any of these
2224 details. In nearly every case <SPAN
2225 CLASS="APPLICATION"
2226 >CDL</SPAN
2227 > expressions just work as expected,
2228 and there is no need to understand the full details.</P
2229 ><DIV
2230 CLASS="NOTE"
2231 ><BLOCKQUOTE
2232 CLASS="NOTE"
2233 ><P
2234 ><B
2235 >Note: </B
2236 >The current expression syntax does not meet all the needs of component
2237 writers. Some future enhancements will definitely be made, others are
2238 more controversial. The list includes the following:</P
2239 ><P
2240 ></P
2241 ><OL
2242 TYPE="1"
2243 ><LI
2244 ><P
2245 >An option's value is determined by several different factors: whether
2246 or not it is loaded, whether or not it is active, whether or not it is
2247 enabled, and the data part. Currently there is no way of querying
2248 these individually. This is very significant in the context of options
2249 with the <TT
2250 CLASS="LITERAL"
2251 >bool</TT
2252 > or <TT
2253 CLASS="LITERAL"
2254 >booldata</TT
2255 >
2256 flavors, because there is no way of distinguishing between the option
2257 being absent/inactive/disabled or it being enabled with a data field
2258 of <TT
2259 CLASS="LITERAL"
2260 >0</TT
2261 >. There should be unary operators that allow
2262 any of the factors to be checked.</P
2263 ></LI
2264 ><LI
2265 ><P
2266 >Only the <TT
2267 CLASS="LITERAL"
2268 >==</TT
2269 > and <TT
2270 CLASS="LITERAL"
2271 >!=</TT
2272 > operators can
2273 be used for string data. More string-related facilities are needed.</P
2274 ></LI
2275 ><LI
2276 ><P
2277 >An implies operator would be useful for many goal expression, where
2278 <TT
2279 CLASS="LITERAL"
2280 >A&nbsp;implies&nbsp;B</TT
2281 > is equivalent to
2282 <TT
2283 CLASS="LITERAL"
2284 >!A&nbsp;||B</TT
2285 >.</P
2286 ></LI
2287 ><LI
2288 ><P
2289 >Similarly there is inadequate support for lists. On occasion it would
2290 be useful to write expressions involving say the list of implementors
2291 of a given CDL interface, for example a sensible default value could
2292 be the first implementor. Associated with this is a need for an
2293 indirection operator.</P
2294 ></LI
2295 ><LI
2296 ><P
2297 >Arguably extending the basic <SPAN
2298 CLASS="APPLICATION"
2299 >CDL</SPAN
2300 > expression syntax with lots of new
2301 operators is unnecessary, instead expressions should just support
2302 <SPAN
2303 CLASS="APPLICATION"
2304 >Tcl</SPAN
2305 > command substitution and then component writers could escape
2306 into <SPAN
2307 CLASS="APPLICATION"
2308 >Tcl</SPAN
2309 > scripts for complicated operations. This has some major
2310 disadvantages. First, the inference engine would no longer have any
2311 sensible way of interpreting an expression to resolve a conflict.
2312 Second, the component framework's value propagation code keeps track
2313 of which options get referenced in which expressions and avoids
2314 unnecessary re-evaluation of expressions; if expressions can involve
2315 arbitrary <SPAN
2316 CLASS="APPLICATION"
2317 >Tcl</SPAN
2318 > code then there is no simple way to eliminate
2319 unnecessary recalculations, with a potentially major impact on
2320 performance.</P
2321 ></LI
2322 ></OL
2323 ></BLOCKQUOTE
2324 ></DIV
2325 ><DIV
2326 CLASS="NOTE"
2327 ><BLOCKQUOTE
2328 CLASS="NOTE"
2329 ><P
2330 ><B
2331 >Note: </B
2332 >The current implementation of the component framework uses 64 bit
2333 arithmetic on all host platforms. Although this is adequate for
2334 current target architectures, it may cause problems in future. At some
2335 stage it is likely that an arbitrary precision integer arithmetic
2336 package will be used instead.</P
2337 ></BLOCKQUOTE
2338 ></DIV
2339 ></DIV
2340 ><DIV
2341 CLASS="SECT2"
2342 ><H2
2343 CLASS="SECT2"
2344 ><A
2345 NAME="LANGUAGE.FUNCTIONS">Functions</H2
2346 ><P
2347 >CDL expressions can contain calls to a set of built-in functions
2348 using the usual syntax, for example;</P
2349 ><TABLE
2350 BORDER="5"
2351 BGCOLOR="#E0E0F0"
2352 WIDTH="70%"
2353 ><TR
2354 ><TD
2355 ><PRE
2356 CLASS="PROGRAMLISTING"
2357 >    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, "-fno-rtti") }</PRE
2358 ></TD
2359 ></TR
2360 ></TABLE
2361 ><P
2362 >The available function calls are as follows:</P
2363 ><P
2364 ></P
2365 ><DIV
2366 CLASS="VARIABLELIST"
2367 ><DL
2368 ><DT
2369 ><TT
2370 CLASS="LITERAL"
2371 >get_data(option)</TT
2372 ></DT
2373 ><DD
2374 ><P
2375 >This function can be used to obtain just the data part of a loaded
2376 configuration option, ignoring other factors such as whether or not
2377 the option is active and enabled. It takes a single argument which
2378 should be the name of a configuration option. If the specified option
2379 is not loaded in the current configuration then the function returns
2380 0, otherwise it returns the data part. Typically this function will
2381 only be used in conjunction with <TT
2382 CLASS="FUNCTION"
2383 >is_active</TT
2384 > and
2385 <TT
2386 CLASS="FUNCTION"
2387 >is_enabled</TT
2388 > for fine-grained control over the
2389 various factors that make up an option's value.</P
2390 ></DD
2391 ><DT
2392 ><TT
2393 CLASS="LITERAL"
2394 >is_active(option)</TT
2395 ></DT
2396 ><DD
2397 ><P
2398 >This function can be used to determine whether or not a particular
2399 configuration option is active. It takes a single argument which
2400 should be the name of an option, and returns a boolean. If the
2401 specified option is not loaded then the function will return false.
2402 Otherwise it will consider the state of the option's parents and
2403 evaluate any <SPAN
2404 CLASS="PROPERTY"
2405 >active_if</SPAN
2406 > properties, and return the option's current
2407 active state. A typical use might be:</P
2408 ><TABLE
2409 BORDER="5"
2410 BGCOLOR="#E0E0F0"
2411 WIDTH="70%"
2412 ><TR
2413 ><TD
2414 ><PRE
2415 CLASS="PROGRAMLISTING"
2416 >    requires { is_active(CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE) implies
2417                    (CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE &#62;= (16 * 1024)) }</PRE
2418 ></TD
2419 ></TR
2420 ></TABLE
2421 ><P
2422 >In other words either the specified configuration option must be
2423 inactive, for example because the current application does not use
2424 any related C library or POSIX functionality, or the stack size must
2425 be at least 16K.</P
2426 ><P
2427 >The configuration system's inference engine can attempt to satisfy
2428 constraints involving <TT
2429 CLASS="FUNCTION"
2430 >is_active</TT
2431 > in various
2432 different ways, for example by enabling or disabling parent
2433 components, or by examining <SPAN
2434 CLASS="PROPERTY"
2435 >active_if</SPAN
2436 > properties and manipulating
2437 terms in the associated expressions.</P
2438 ></DD
2439 ><DT
2440 ><TT
2441 CLASS="LITERAL"
2442 >is_enabled(option)</TT
2443 ></DT
2444 ><DD
2445 ><P
2446 >This function can be used to determine whether or not a particular
2447 configuration option is enabled. It takes a single argument which
2448 should be the name of an option, and returns a boolean. If the
2449 specified option is not loaded then the function will return false.
2450 Otherwise it will return the current boolean part of the option's
2451 value. The option's active or inactive state is ignored. Typically
2452 this function will be used in conjunction with
2453 <TT
2454 CLASS="FUNCTION"
2455 >is_active</TT
2456 > and possibly
2457 <TT
2458 CLASS="FUNCTION"
2459 >get_data</TT
2460 > to provide fine-grained control over the
2461 various factors that make up an option's value.</P
2462 ></DD
2463 ><DT
2464 ><TT
2465 CLASS="LITERAL"
2466 >is_loaded(option)</TT
2467 ></DT
2468 ><DD
2469 ><P
2470 >This function can be used to determine whether or not a particular
2471 configuration option is loaded. It takes a single argument which
2472 should be the name of an option, and returns a boolean. If the
2473 argument is a package then the <TT
2474 CLASS="FUNCTION"
2475 >is_loaded</TT
2476 > function
2477 provides little or no extra information, for example the following two
2478 constraints are usually equivalent:</P
2479 ><TABLE
2480 BORDER="5"
2481 BGCOLOR="#E0E0F0"
2482 WIDTH="70%"
2483 ><TR
2484 ><TD
2485 ><PRE
2486 CLASS="PROGRAMLISTING"
2487 >    requires { CYGPKG_KERNEL }
2488     requires { is_loaded(CYGPKG_KERNEL) }</PRE
2489 ></TD
2490 ></TR
2491 ></TABLE
2492 ><P
2493 >However if the specified package is loaded but re-parented below a
2494 disabled component, or inactive as a result of an <SPAN
2495 CLASS="PROPERTY"
2496 >active_if</SPAN
2497 >
2498 property, then the first constraint would not be satisfied but the
2499 second constraint would. In other words the
2500 <TT
2501 CLASS="FUNCTION"
2502 >is_loaded</TT
2503 > makes it possible to consider in
2504 isolation one of the factors that are considered when CDL expressions
2505 are evaluated.</P
2506 ><P
2507 >The configuration system's inference engine will not automatically
2508 load or unload packages to satisfy <TT
2509 CLASS="FUNCTION"
2510 >is_loaded</TT
2511 >
2512 constraints. </P
2513 ></DD
2514 ><DT
2515 ><TT
2516 CLASS="LITERAL"
2517 >is_substr(haystack,&nbsp;needle)</TT
2518 ></DT
2519 ><DD
2520 ><P
2521 >This can be used to check whether or not a particular string is
2522 present in another string. It is used mainly for manipulating compiler
2523 flags. The function takes two arguments, both of which can be
2524 arbitrary expressions, and returns a boolean.</P
2525 ><P
2526 ><TT
2527 CLASS="FUNCTION"
2528 >is_substr</TT
2529 > has some understanding of word
2530 boundaries. If the second argument starts with a space character then
2531 that will match either a real space or the start of the string.
2532 Similarly if the second argument ends with a space character then that
2533 will match a real space or the end of the string. For example, all of
2534 the following conditions are satisfied:</P
2535 ><TABLE
2536 BORDER="5"
2537 BGCOLOR="#E0E0F0"
2538 WIDTH="70%"
2539 ><TR
2540 ><TD
2541 ><PRE
2542 CLASS="PROGRAMLISTING"
2543 >    is_substr("abracadabra", "abra")
2544     is_substr("abracadabra", " abra")
2545     is_substr("hocus pocus", " pocus")
2546     is_substr("abracadabra", "abra ")</PRE
2547 ></TD
2548 ></TR
2549 ></TABLE
2550 ><P
2551 >The first is an exact match. The second is a match because the leading
2552 space matches the start of the string. The third is an exact match,
2553 with the leading space matching an actual space. The fourth is a match
2554 because the trailing space matches the end of the string. However, the
2555 following condition is not satisfied.</P
2556 ><TABLE
2557 BORDER="5"
2558 BGCOLOR="#E0E0F0"
2559 WIDTH="70%"
2560 ><TR
2561 ><TD
2562 ><PRE
2563 CLASS="PROGRAMLISTING"
2564 >    is_substr("abracadabra", " abra ")</PRE
2565 ></TD
2566 ></TR
2567 ></TABLE
2568 ><P
2569 >This fails to match at the start of the string because the trailing
2570 space is not matched by either a real space or the end of the string.
2571 Similarly it fails to match at the end of the string.</P
2572 ><P
2573 >If a constraint involving <TT
2574 CLASS="FUNCTION"
2575 >is_substr</TT
2576 > is not
2577 satisfied and the first argument is a reference to a configuration
2578 option, the inference engine will attempt to modify that option's
2579 value. This can be achieved either by appending the second argument to
2580 the current value, or by removing all occurrences of that argument
2581 from the current value.</P
2582 ><TABLE
2583 BORDER="5"
2584 BGCOLOR="#E0E0F0"
2585 WIDTH="70%"
2586 ><TR
2587 ><TD
2588 ><PRE
2589 CLASS="PROGRAMLISTING"
2590 >    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, " -fno-rtti ") }
2591     requires { is_substr(CYGBLD_GLOBAL_CFLAGS, " -frtti ") }</PRE
2592 ></TD
2593 ></TR
2594 ></TABLE
2595 ><P
2596 >When data is removed the leading and trailing spaces will be left. For
2597 example, given an initial value of
2598 &#60;<TT
2599 CLASS="VARNAME"
2600 >CYGBLD_GLOBAL_CFLAGS</TT
2601 > of
2602 <TT
2603 CLASS="LITERAL"
2604 >-g&nbsp;-fno-rtti&nbsp;-O2</TT
2605 > the result will be
2606 <TT
2607 CLASS="LITERAL"
2608 >-g&nbsp;&nbsp;-O2</TT
2609 > rather than <TT
2610 CLASS="LITERAL"
2611 >-g-O2</TT
2612 >.</P
2613 ><P
2614 >If exact matches are needed, the function
2615 <TT
2616 CLASS="FUNCTION"
2617 >is_xsubstr</TT
2618 > can be used instead.</P
2619 ></DD
2620 ><DT
2621 ><TT
2622 CLASS="LITERAL"
2623 >is_xsubstr(haystack,&nbsp;needle)</TT
2624 ></DT
2625 ><DD
2626 ><P
2627 >This function checks whether or not the pattern string is an exact
2628 substring of the string being searched. It is similar to
2629 <TT
2630 CLASS="FUNCTION"
2631 >is_substr</TT
2632 > but uses exact matching only. In other
2633 words, leading or trailing spaces have to match exactly and will not
2634 match the beginning or end of the string being searched. The function
2635 takes two arguments, both of which can be arbitrary expressions, and
2636 returns a boolean. The difference between
2637 <TT
2638 CLASS="FUNCTION"
2639 >is_substr</TT
2640 > and <TT
2641 CLASS="FUNCTION"
2642 >is_xsubstr</TT
2643 > is
2644 illustrated by the following examples:</P
2645 ><TABLE
2646 BORDER="5"
2647 BGCOLOR="#E0E0F0"
2648 WIDTH="70%"
2649 ><TR
2650 ><TD
2651 ><PRE
2652 CLASS="PROGRAMLISTING"
2653 >    cdl_option MAGIC {
2654         flavor data
2655         default_value { "abracadabra" }
2656     }
2657     &#8230;
2658     requires { is_substr(MAGIC,  " abra") }
2659     requires { is_xsubstr(MAGIC, " abra") }</PRE
2660 ></TD
2661 ></TR
2662 ></TABLE
2663 ><P
2664 >The first goal will be satisfied because the leading space in the
2665 pattern matches the beginning of the string. The second goal will not
2666 be satisfied initialy because there is no exact match, so the
2667 inference engine is likely to update the value of
2668 <TT
2669 CLASS="VARNAME"
2670 >MAGIC</TT
2671 > to <TT
2672 CLASS="LITERAL"
2673 >abracadabra abra</TT
2674 > which
2675 does give an exact match.</P
2676 ></DD
2677 ><DT
2678 ><TT
2679 CLASS="LITERAL"
2680 >version_cmp(A,&nbsp;B)</TT
2681 ></DT
2682 ><DD
2683 ><P
2684 >This function is used primarily to check that a sufficiently recent
2685 <A
2686 HREF="package.versions.html"
2687 >version</A
2688 > of some other package
2689 is being used. It takes two arguments, both of which can be arbitrary
2690 expressions. In practice usually one of the arguments will be a
2691 reference to a package and the other will be a constant version
2692 string. The return value is -1 if the first argument is a more recent
2693 version then the second, 0 if the two arguments correspond to
2694 identical versions, and 1 if the first argument is an older version.
2695 For example the following constraint can be used to indicate that the
2696 current package depends on kernel functionality that only became
2697 available in version 1.3:</P
2698 ><TABLE
2699 BORDER="5"
2700 BGCOLOR="#E0E0F0"
2701 WIDTH="70%"
2702 ><TR
2703 ><TD
2704 ><PRE
2705 CLASS="PROGRAMLISTING"
2706 >    requires { version_cmp(CYGPKG_KERNEL, "v1.3") &#60;= 0 }</PRE
2707 ></TD
2708 ></TR
2709 ></TABLE
2710 ></DD
2711 ></DL
2712 ></DIV
2713 ><DIV
2714 CLASS="NOTE"
2715 ><BLOCKQUOTE
2716 CLASS="NOTE"
2717 ><P
2718 ><B
2719 >Note: </B
2720 >At this time it is not possible to define new functions inside a CDL
2721 script. Instead functions can only be added at the C++ level, usually
2722 by extending libcdl itself. This is partly because there is more to
2723 CDL functions than simple evaluation: associated with most functions
2724 is support for the inference engine, so that if a constraint involving
2725 a function is not currently satisfied the system may be able to find a
2726 solution automatically.</P
2727 ></BLOCKQUOTE
2728 ></DIV
2729 ></DIV
2730 ><DIV
2731 CLASS="SECT2"
2732 ><H2
2733 CLASS="SECT2"
2734 ><A
2735 NAME="LANGUAGE.GOAL-EXPRESSION">Goal Expressions</H2
2736 ><P
2737 >The arguments to certain properties, notably <SPAN
2738 CLASS="PROPERTY"
2739 >requires</SPAN
2740 > and
2741 <SPAN
2742 CLASS="PROPERTY"
2743 >active_if</SPAN
2744 >, constitute a goal expression. As with an ordinary
2745 expression, all of the arguments get combined and then the expression
2746 parser takes over. The same care has to be taken with constant strings
2747 and anything else that may get processed by the Tcl interpreter, so
2748 often a goal expression is enclosed entirely in braces and the
2749 expression parsing code sees just a single argument.</P
2750 ><P
2751 >A goal expression is basically just a sequence of ordinary
2752 expressions, for example:</P
2753 ><TABLE
2754 BORDER="5"
2755 BGCOLOR="#E0E0F0"
2756 WIDTH="70%"
2757 ><TR
2758 ><TD
2759 ><PRE
2760 CLASS="PROGRAMLISTING"
2761 >    requires { CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
2762                !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
2763                !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT }</PRE
2764 ></TD
2765 ></TR
2766 ></TABLE
2767 ><P
2768 >This consists of three separate expressions, all of which should
2769 evaluate to a non-zero result. The same expression could be written
2770 as: </P
2771 ><TABLE
2772 BORDER="5"
2773 BGCOLOR="#E0E0F0"
2774 WIDTH="70%"
2775 ><TR
2776 ><TD
2777 ><PRE
2778 CLASS="PROGRAMLISTING"
2779 >    requires { CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS  &#38;&#38;
2780                !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT &#38;&#38;
2781                !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT }</PRE
2782 ></TD
2783 ></TR
2784 ></TABLE
2785 ><P
2786 >Alternatively the following would have much the same effect:</P
2787 ><TABLE
2788 BORDER="5"
2789 BGCOLOR="#E0E0F0"
2790 WIDTH="70%"
2791 ><TR
2792 ><TD
2793 ><PRE
2794 CLASS="PROGRAMLISTING"
2795 >    requires CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
2796     requires !CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
2797     requires !CYGDBG_HAL_DEBUG_GDB_CTRLC_SUPPORT</PRE
2798 ></TD
2799 ></TR
2800 ></TABLE
2801 ><P
2802 >Selecting between these alternatives is largely a stylistic choice.
2803 The first is slightly more concise than the others. The second is more
2804 likely to appeal to mathematical purists. The third is more amenable
2805 to cutting and pasting.</P
2806 ><P
2807 >The result of evaluating a goal expression is a boolean. If any part
2808 of the goal expression evaluates to the integer <TT
2809 CLASS="LITERAL"
2810 >0</TT
2811 >
2812 or an equivalent string then the result is false, otherwise it is
2813 true. </P
2814 ><P
2815 >The term &#8220;goal&nbsp;expression&#8221; relates to the component
2816 framework's inference engine: it is a description of a goal that
2817 should be satisfied for a conflict-free configuration. If a <SPAN
2818 CLASS="PROPERTY"
2819 >requires</SPAN
2820 >
2821 constraint is not satisfied then the inference engine will examine the
2822 goal expression: if there is some way of changing the configuration
2823 that does not introduce new conflicts and that will cause the goal
2824 expression to evaluate to true, the conflict can be resolved.</P
2825 ><P
2826 >The inference engine works with one conflict and hence one goal
2827 expression at a time. This means that there can be slightly different
2828 behavior if a constraint is specified using a single <SPAN
2829 CLASS="PROPERTY"
2830 >requires</SPAN
2831 >
2832 property or several different ones. Given the above example, suppose
2833 that none of the three conditions are satisfied. If a single goal
2834 expression is used then the inference engine might be able to satisfy
2835 only two of the three parts, but since the conflict as a whole cannot
2836 be resolved no part of the solution will be applied. Instead the user
2837 will have to resolve the entire conflict. If three separate goal
2838 expressions are used then the inference engine might well find
2839 solutions to two of them, leaving less work for the user. On the other
2840 hand, if a single goal expression is used then the inference engine
2841 has a bit more information to work with, and it might well find a
2842 solution to the entire conflict where it would be unable to find
2843 separate solutions for the three parts. Things can get very
2844 complicated, and in general component writers should not worry about
2845 the subtleties of the inference engine and how to manipulate its
2846 behavior. </P
2847 ><P
2848 >It is possible to write ambiguous goal expressions, for example:</P
2849 ><TABLE
2850 BORDER="5"
2851 BGCOLOR="#E0E0F0"
2852 WIDTH="70%"
2853 ><TR
2854 ><TD
2855 ><PRE
2856 CLASS="PROGRAMLISTING"
2857 >    requires CYGNUM_LIBC_RAND_SEED -CYGNUM_LIBC_RAND_TRACE_LEVEL &gt; 5</PRE
2858 ></TD
2859 ></TR
2860 ></TABLE
2861 ><P
2862 >This could be parsed in two ways:</P
2863 ><TABLE
2864 BORDER="5"
2865 BGCOLOR="#E0E0F0"
2866 WIDTH="70%"
2867 ><TR
2868 ><TD
2869 ><PRE
2870 CLASS="PROGRAMLISTING"
2871 >    requires ((CYGNUM_LIBC_RAND_SEED - CYGNUM_LIBC_RAND_TRACE_LEVEL) &gt; 5)
2872     requires CYGNUM_LIBC_RAND_SEED &amp;&amp; ((-CYGNUM_LIBC_RAND_TRACE_LEVEL) &gt; 5)</PRE
2873 ></TD
2874 ></TR
2875 ></TABLE
2876 ><P
2877 >The goal expression parsing code will always use the largest ordinary
2878 expression for each goal, so the first interpretation will be used.
2879 In such cases it is a good idea to use brackets and avoid possible
2880 confusion. </P
2881 ></DIV
2882 ><DIV
2883 CLASS="SECT2"
2884 ><H2
2885 CLASS="SECT2"
2886 ><A
2887 NAME="LANGUAGE.LIST-EXPRESSION">List Expressions</H2
2888 ><P
2889 >The arguments to the <SPAN
2890 CLASS="PROPERTY"
2891 >legal_values</SPAN
2892 > property constitute a goal
2893 expression. As with an ordinary and goal expressions, all of the
2894 arguments get combined and then the expression parser takes over. The
2895 same care has to be taken with constant strings and anything else that
2896 may get processed by the Tcl interpreter, so often a list expression
2897 is enclosed entirely in braces and the expression parsing code sees
2898 just a single argument.</P
2899 ><P
2900 >Most list expressions take one of two forms:</P
2901 ><TABLE
2902 BORDER="5"
2903 BGCOLOR="#E0E0F0"
2904 WIDTH="70%"
2905 ><TR
2906 ><TD
2907 ><PRE
2908 CLASS="PROGRAMLISTING"
2909 >    legal_values &lt;expr1&gt; &lt;expr2&gt; &lt;expr3&gt; ...
2910     legal_values &lt;expr1&gt; to &lt;expr2&gt;</PRE
2911 ></TD
2912 ></TR
2913 ></TABLE
2914 ><P
2915 ><TT
2916 CLASS="LITERAL"
2917 >expr1</TT
2918 >, <TT
2919 CLASS="LITERAL"
2920 >expr2</TT
2921 > and so on are
2922 ordinary expressions. Often these will be constants or references to
2923 calculated options in the architectural HAL package, but it is
2924 possible to use arbitrary expressions when necessary. The first syntax
2925 indicates a list of possible values, which need not be numerical. The
2926 second syntax indicates a numerical range: both sides of the
2927 <TT
2928 CLASS="LITERAL"
2929 >to</TT
2930 > must evaluate to a numerical value; if either
2931 side involves a floating point number then any floating point number
2932 in that range is legal; otherwise only integer values are legal;
2933 ranges are inclusive, so <TT
2934 CLASS="LITERAL"
2935 >4</TT
2936 > is a valid value given a
2937 list expression <TT
2938 CLASS="LITERAL"
2939 >1&nbsp;to&nbsp;</TT
2940 >; if one or both
2941 sides of the <TT
2942 CLASS="LITERAL"
2943 >to</TT
2944 > does not evaluate to a numerical
2945 value then this will result in a run-time conflict. The following
2946 examples illustrate these possibilities:</P
2947 ><TABLE
2948 BORDER="5"
2949 BGCOLOR="#E0E0F0"
2950 WIDTH="70%"
2951 ><TR
2952 ><TD
2953 ><PRE
2954 CLASS="PROGRAMLISTING"
2955 >    legal_values { "red" "green" "blue" }
2956     legal_values 1 2 4 8 16
2957     legal_values 1 to CYGARC_MAXINT
2958     legal_values 1.0 to 2.0</PRE
2959 ></TD
2960 ></TR
2961 ></TABLE
2962 ><P
2963 >It is possible to combine the two syntaxes, for example:</P
2964 ><TABLE
2965 BORDER="5"
2966 BGCOLOR="#E0E0F0"
2967 WIDTH="70%"
2968 ><TR
2969 ><TD
2970 ><PRE
2971 CLASS="PROGRAMLISTING"
2972 >    legal_values 1 2 4 to CYGARC_MAXINT -1024 -20.0 to -10</PRE
2973 ></TD
2974 ></TR
2975 ></TABLE
2976 ><P
2977 >This indicates three legal values <TT
2978 CLASS="LITERAL"
2979 >1</TT
2980 >,
2981 <TT
2982 CLASS="LITERAL"
2983 >2</TT
2984 > and <TT
2985 CLASS="LITERAL"
2986 >-1024</TT
2987 >, one
2988 integer range <TT
2989 CLASS="LITERAL"
2990 >4&nbsp;to&nbsp;CYGARC_MAXINT</TT
2991 >, and one
2992 floating point range <TT
2993 CLASS="LITERAL"
2994 >-20.0&nbsp;to&nbsp;-10.0</TT
2995 >. In
2996 practice such list expressions are rarely useful.</P
2997 ><P
2998 >The identifier <TT
2999 CLASS="VARNAME"
3000 >to</TT
3001 > is not reserved, so it is
3002 possible to have a configuration option with that name (although it
3003 violates every naming convention). Using that option in a list
3004 expression may however give unexpected results.</P
3005 ><P
3006 >The graphical configuration tool uses the <SPAN
3007 CLASS="PROPERTY"
3008 >legal_values</SPAN
3009 > list
3010 expression to determine how best to let users manipulate the option's
3011 value. Different widgets will be appropriate for different lists, so
3012 <TT
3013 CLASS="LITERAL"
3014 >{&nbsp;"red"&nbsp;"green"&nbsp;"blue"&nbsp;}</TT
3015 > might
3016 involve a pull-down option menu, and
3017 <TT
3018 CLASS="LITERAL"
3019 >1&nbsp;to&nbsp;16</TT
3020 > could involve a spinner. The
3021 exact way in which <SPAN
3022 CLASS="PROPERTY"
3023 >legal_values</SPAN
3024 > lists get mapped on to GUI widgets
3025 is not defined and is subject to change at any time.</P
3026 ><P
3027 >As with goal expressions, list expressions can be ambiguous. Consider
3028 the following hypothetical example:</P
3029 ><TABLE
3030 BORDER="5"
3031 BGCOLOR="#E0E0F0"
3032 WIDTH="70%"
3033 ><TR
3034 ><TD
3035 ><PRE
3036 CLASS="PROGRAMLISTING"
3037 >    legal_values CYGNUM_LIBC_RAND_SEED -CYGNUM_LIBC_RAND_TRACE_LEVEL</PRE
3038 ></TD
3039 ></TR
3040 ></TABLE
3041 ><P
3042 >This could be parsed in two ways:</P
3043 ><TABLE
3044 BORDER="5"
3045 BGCOLOR="#E0E0F0"
3046 WIDTH="70%"
3047 ><TR
3048 ><TD
3049 ><PRE
3050 CLASS="PROGRAMLISTING"
3051 >    legal_values (CYGNUM_LIBC_RAND_SEED - CYGNUM_LIBC_RAND_TRACE_LEVEL)
3052     legal_values (CYGNUM_LIBC_RAND_SEED) (-CYGNUM_LIBC_RAND_TRACE_LEVEL)</PRE
3053 ></TD
3054 ></TR
3055 ></TABLE
3056 ><P
3057 >Both are legal. The list expression parsing code will always use the
3058 largest ordinary expression for each element, so the first
3059 interpretation will be used. In cases like this it is a good idea to
3060 use brackets and avoid possible confusion.</P
3061 ></DIV
3062 ></DIV
3063 ><DIV
3064 CLASS="NAVFOOTER"
3065 ><HR
3066 ALIGN="LEFT"
3067 WIDTH="100%"><TABLE
3068 SUMMARY="Footer navigation table"
3069 WIDTH="100%"
3070 BORDER="0"
3071 CELLPADDING="0"
3072 CELLSPACING="0"
3073 ><TR
3074 ><TD
3075 WIDTH="33%"
3076 ALIGN="left"
3077 VALIGN="top"
3078 ><A
3079 HREF="language.tcl.html"
3080 ACCESSKEY="P"
3081 >Prev</A
3082 ></TD
3083 ><TD
3084 WIDTH="34%"
3085 ALIGN="center"
3086 VALIGN="top"
3087 ><A
3088 HREF="cdl-guide.html"
3089 ACCESSKEY="H"
3090 >Home</A
3091 ></TD
3092 ><TD
3093 WIDTH="33%"
3094 ALIGN="right"
3095 VALIGN="top"
3096 ><A
3097 HREF="language.interface.html"
3098 ACCESSKEY="N"
3099 >Next</A
3100 ></TD
3101 ></TR
3102 ><TR
3103 ><TD
3104 WIDTH="33%"
3105 ALIGN="left"
3106 VALIGN="top"
3107 >An Introduction to Tcl</TD
3108 ><TD
3109 WIDTH="34%"
3110 ALIGN="center"
3111 VALIGN="top"
3112 ><A
3113 HREF="language.html"
3114 ACCESSKEY="U"
3115 >Up</A
3116 ></TD
3117 ><TD
3118 WIDTH="33%"
3119 ALIGN="right"
3120 VALIGN="top"
3121 >Interfaces</TD
3122 ></TR
3123 ></TABLE
3124 ></DIV
3125 ></BODY
3126 ></HTML
3127 >