hc
2023-03-13 2ec15ae1cb4be1b4fcb56c6d621123d7ebdaad6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash -e
 
handle_size() {
   # Should be int
   echo -n \`\`\"[$1${2:+, $2}]\"\'\'
}
 
handle_digit() {
   echo -n \`\`\"[$1${2:+, $2}]\"\'\'
}
 
handle_range() {
   # Max should >= min
   echo -n \`\`\"[$1, $2]\"\'\'
}
 
handle_hide() {
   # Max should >= min
   echo -n \`\`\"[$1, $2]\"\'\'
}
 
handle_struct() {
   echo -n @desc: alias=\"$1\", type=\"struct\", ui_module=\"${2:-normal_ui_style}\", hide=\"${3:-0}\"
}
 
handle_struct_list() {
   echo -n @desc: alias=\"$1\", type=\"struct_list\", size=\"$2\", ui_module=\"${3:-normal_ui_style}\"
}
 
handle_number() {
   echo -n @desc: alias=\"$1\", type=\"$2\", size=\"[1,1]\", range=\"$3\", default=\"$4\", digit=\"$5\", hide=\"${6:-0}\"
}
 
handle_array() {
   echo -n @desc: alias=\"$1\", type=\"$2\", size=\"$3\", range=\"$4\", default=\"$5\", digit=\"$6\", dynamic=\"$7\", hide=\"${8:-0}\"
}
 
handle_array_mark() {
   echo -n @desc: alias=\"$1\", type=\"$2\", size=\"$3\", range=\"$4\", default=\"$5\", digit=\"$6\", dynamic=\"$7\", ui_module=\"${8:-normal_ui_style}\"
}
 
handle_string_mark() {
   echo -n @desc: alias=\"$1\", type=\"string\", size=\"$2\", range=\"$3\", default=\"$4\", dynamic=\"$5\", ui_module_param=\"${6:-normal_ui_style}\"
}
 
handle_number_mark() {
   echo -n @desc: alias=\"$1\", type=\"$2\", range=\"$3\", default=\"$4\", digit=\"$5\", ui_module_param=\"${6:-normal_ui_style}\"
}
 
handle_array_table() {
   echo -n @desc: alias=\"$1\", type=\"struct\", ui_module=\"$2\", index=\"$3\", hide=\"${4:-0}\"
}
 
handle_string() {
   echo -n @desc: alias=\"$1\", type=\"string\", size=\"$2\", range=\"$3\", default=\"$4\", dynamic=\"$5\"
}
 
handle_enum() {
   echo -n @desc: type=\"enum\", alias=\"$1\", enum_def=\"$2\", default=\"$3\"
}
 
handle_bool() {
   echo -n @desc: type=\"bool\", alias=\"$1\", default=\"$2\", hide=\"${3:-0}\"
}
 
echo "$@" >> ./m4.log
MACRO=$1
shift
case $MACRO in
   M4_SIZE)
       handle_size "$@"
       ;;
   M4_DIGIT)
       handle_digit "$@"
       ;;
   M4_RANGE)
       handle_range "$@"
       ;;
   M4_STRUCT_DESC)
       handle_struct "$@"
       ;;
   M4_STRUCT_LIST_DESC)
       handle_struct_list "$@"
       ;;
   M4_NUMBER_DESC)
       handle_number "$@"
       ;;
   M4_HIDE)
       handle_hide "$@"
       ;;
    M4_ARRAY_DESC)
        handle_array "$@"
        ;;
    M4_ARRAY_MARK_DESC)
        handle_array_mark "$@"
        ;;
    M4_STRING_MARK_DESC)
        handle_string_mark "$@"
        ;;
    M4_NUMBER_MARK_DESC)
        handle_number_mark "$@"
        ;;
    M4_ARRAY_TABLE_DESC)
        handle_array_table "$@"
        ;;
   M4_STRING_DESC)
       handle_string "$@"
       ;;
   M4_ENUM_DESC)
       handle_enum "$@"
       ;;
   M4_BOOL_DESC)
       handle_bool "$@"
        ;;
   *)
       exit 0
       ;;
esac