2 * (c) Oleg Puchinin 2006.
3 * graycardinalster@gmail.com
10 int what_is_this (char * d_op
, char ch
)
18 if (*d_op
== '#' || ch
== '\n') {
20 return OP_TYPE_DEFINE
;
24 d_words_count
= words_count (d_op
);
29 if (d_words_count
== 1) {
30 if (ww_call_cmp (d_op
, "if", 2) ||
31 ww_call_cmp (d_op
, "else", 4) ||
32 ww_call_cmp (d_op
, "do", 2) ||
33 ww_call_cmp (d_op
, "while", 5) ||
34 ww_call_cmp (d_op
, "switch", 6) ||
35 ww_case_cmp (d_op
, "case", 4))
38 if (ww_after_word (d_op
) == '(')
41 return OP_TYPE_OTHER
; // Macro or operations (e.g. "+-=*/%^" etc...)
44 d_last_ch
= last_ch (d_op
);
47 return OP_TYPE_VARIABLE
;
49 b_local_ftest
= local_ftest (d_op
);
50 if ((ch
== '{' && d_last_ch
== ')')) {
51 if (b_local_ftest
) // Paranoid.
52 return OP_TYPE_FUNCTION
;
55 if (!strncmp (d_op
, "extern ", 7))
56 return OP_TYPE_EXTERN
;
60 if (!strncmp (d_op
, "typedef ", 8)) {
61 Ret
|= OP_TYPE_TYPEDEF
;
65 if (!strncmp (d_op
, "static ", 7))
68 if (!strncmp (d_op
, "const ", 6)) // "static const struct"
71 if (!strncmp (d_op
, "union ", 6))
72 return Ret
| OP_TYPE_OTHER
;
74 if (! strncmp (d_op
, "enum ", 5))
75 return Ret
| OP_TYPE_OTHER
;
77 if (!strncmp (d_op
, "struct ", 7)) {
78 return Ret
| OP_TYPE_STRUCT
;
81 if (!strncmp (d_op
, "class ", 6))
84 if (!strncmp (d_op
, "namespace ", 10))
85 return OP_TYPE_NAMESPACE
;
87 if ((words_count (d_op
) > 1) && !b_local_ftest
)
88 return OP_TYPE_VARIABLE
;
96 if (!strncmp (d_op
, "typedef ", 8))
97 return OP_TYPE_TYPEDEF
;
100 S
= strchr (d_op
, '(');
102 return OP_TYPE_OTHER
;
105 if (words_count (S
) <= 1) {
106 S
= strchr_r (S
, ')', 0);
108 if (words_count (S
) > 1)
109 return OP_TYPE_FUNCTION
; // declaration... or not ?
112 if (d_words_count
<= 1)
113 return OP_TYPE_OTHER
;
115 if (!strncmp (d_op
, "struct ", 7) && d_words_count
== 2)
116 return OP_TYPE_OTHER
;
118 if (!strncmp (d_op
, "return ", 7))
119 return OP_TYPE_OTHER
;
121 if (!strncmp (d_op
, "delete ", 7))
122 return OP_TYPE_OTHER
;
124 return OP_TYPE_VARIABLE
;
126 // Function defenition, callback defenition... it's all ?
129 return OP_TYPE_OTHER
;