Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3584 | sourcerer | 1 | /* |
2 | * This file is part of LibCSS. |
||
3 | * Licensed under the MIT License, |
||
4 | * http://www.opensource.org/licenses/mit-license.php |
||
5 | * Copyright 2008 John-Mark Bell |
||
6 | */ |
||
7 | |||
8 | #ifndef css_bytecode_bytecode_h_ |
||
9 | #define css_bytecode_bytecode_h_ |
||
10 | |||
11 | #include |
||
12 | #include |
||
13 | |||
14 | #include |
||
15 | #include |
||
16 | |||
17 | typedef uint32_t css_code_t; |
||
18 | |||
19 | typedef enum css_properties_e opcode_t; |
||
20 | |||
21 | enum flag { |
||
22 | FLAG_IMPORTANT = (1<<0), |
||
23 | FLAG_INHERIT = (1<<1) |
||
24 | }; |
||
25 | |||
26 | typedef enum unit { |
||
27 | UNIT_PX = 0, |
||
28 | UNIT_EX = 1, |
||
29 | UNIT_EM = 2, |
||
30 | UNIT_IN = 3, |
||
31 | UNIT_CM = 4, |
||
32 | UNIT_MM = 5, |
||
33 | UNIT_PT = 6, |
||
34 | UNIT_PC = 7, |
||
35 | |||
36 | UNIT_PCT = (1 << 8), |
||
37 | |||
38 | UNIT_ANGLE = (1 << 9), |
||
39 | UNIT_DEG = (1 << 9) + 0, |
||
40 | UNIT_GRAD = (1 << 9) + 1, |
||
41 | UNIT_RAD = (1 << 9) + 2, |
||
42 | |||
43 | UNIT_TIME = (1 << 10), |
||
44 | UNIT_MS = (1 << 10) + 0, |
||
45 | UNIT_S = (1 << 10) + 1, |
||
46 | |||
47 | UNIT_FREQ = (1 << 11), |
||
48 | UNIT_HZ = (1 << 11) + 0, |
||
49 | UNIT_KHZ = (1 << 11) + 1 |
||
50 | } unit; |
||
51 | |||
52 | typedef uint32_t colour; |
||
53 | |||
54 | typedef enum shape { |
||
55 | SHAPE_RECT = 0 |
||
56 | } shape; |
||
57 | |||
58 | static inline css_code_t buildOPV(opcode_t opcode, uint8_t flags, uint16_t value) |
||
59 | { |
||
60 | return (opcode & 0x3ff) | (flags << 10) | ((value & 0x3fff) << 18); |
||
61 | } |
||
62 | |||
63 | static inline opcode_t getOpcode(css_code_t OPV) |
||
64 | { |
||
65 | return (OPV & 0x3ff); |
||
66 | } |
||
67 | |||
68 | static inline uint8_t getFlags(css_code_t OPV) |
||
69 | { |
||
70 | return ((OPV >> 10) & 0xff); |
||
71 | } |
||
72 | |||
73 | static inline uint16_t getValue(css_code_t OPV) |
||
74 | { |
||
75 | return (OPV >> 18); |
||
76 | } |
||
77 | |||
78 | static inline bool isImportant(css_code_t OPV) |
||
79 | { |
||
80 | return getFlags(OPV) & 0x1; |
||
81 | } |
||
82 | |||
83 | static inline bool isInherit(css_code_t OPV) |
||
84 | { |
||
85 | return getFlags(OPV) & 0x2; |
||
86 | } |
||
87 | |||
88 | #endif><>><>><>><>><>><>><>><>><>><>><>><>><>1) |
||
89 | |||
90 | |||
91 |