Re-enabled use of AROS.Boot file due to lack of general enthusiasm for
[tangerine.git] / test / oop / hidd.cs
blobf26b08d733609b436fa56a458d7be64ec69d8c4c
1 /*
2 This is an example for a pseudolanguage to use out OOP
3 system in C.
4 */
6 class HIDD
8 version 41.0;
10 /* This is a global constant for this class */
11 const ClassTable = 0;
14 FindHIDD takes three arguments: A string with the type
15 and the subtype of the HIDD (eg. "gfx"/"printer")
16 and a list of attributes.
18 It returns an array of HIDDs which match the specified
19 attributes.
21 Array findHIDD
23 String type,
24 String subType,
25 TagArray attrs
28 hiddTableLock.lock ();
30 Array hiddTable = classTable.get (type);
31 Array hidds = Array (hiddTable.len ());
33 ULONG t;
34 for (t=0; hiddTable[t]; t++)
36 if (!strcasecmp (hiddTable[t].subType, subType)
37 && hiddTable[t].match (attrs)
40 hidds.append (hiddTable[t])
44 hiddTableLock.unlock ();
46 return hidds;
49 /* These are global class variables */
50 static HashTable hiddTable = HashTable (256, HashTable.calcStringHashCode);
51 static Semaphore hiddTableLock = Semaphore ();
54 class Window
56 /* Position and size of the window. The attribute can be read
57 and written from outside. */
58 [RW] UWORD x, y, width, height;
59 [RW] UWORD minWidth, minHeight, maxWidth, maxHeight;
61 /* Before writing to width, execute this code */
62 pre W width
64 if (width < 0)
65 Raise IllegalValue ("width (%d) too small, must be > 0", width);
67 if (width < minWidth)
68 /* This could also raise an error */
69 width = minWidth;
71 if (width > maxWidth)
72 width = maxWidth;
75 post W width
77 this.resize (this.width, this.height);
80 ...