-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotation.hsp
67 lines (61 loc) · 1.68 KB
/
annotation.hsp
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
#ifndef annotation_hsp_included
#define annotation_hsp_included
#module
/*
アノテーションパーサの初期化を行う
*/
#deffunc annotation_init
annotation_attr_names = {"
runtime default
timeout -1
ignore false
"}
notesel annotation_attr_names
sdim annotation_values, 64, notemax
repeat notemax
noteget annotation_attr, cnt
split annotation_attr, " ", annotation_name, annotation_default_value
annotation_values(cnt) = annotation_default_value
loop
return
/*
アノテーション行をパースする
引数
annotation_line: アノテーションが書かれてある行の文字列
*/
#deffunc annotation_parse str annotation_line
annotation_str = submatch(annotation_line, ";@\s*(.+)", 0, 0)
matches annotation_matches, annotation_str, "(\\w+)\\s*=\\s*([\\w-\\.]+)", 0, 0, 1
repeat stat
notesel annotation_attr_names
ccnt = cnt
repeat notemax
noteget annotation_attr, cnt
split annotation_attr, " ", annotation_name, annotation_default_value
if annotation_matches(ccnt, 1) == annotation_name {
annotation_values(cnt) = annotation_matches(ccnt, 2)
}
loop
loop
return
/*
アノテーションに書かれた属性(設定項目)の値を取得する
引数
attr_name: 設定項目名
返り値
設定項目の値
*/
#defcfunc get_annotation_attr_val str attr_name
retval = ""
notesel annotation_attr_names
repeat notemax
noteget annotation_attr, cnt
split annotation_attr, " ", annotation_name, annotation_default_value
if attr_name == annotation_name {
retval = annotation_values(cnt)
break
}
loop
return retval
#global
#endif