kDefs.h: Added risc-v to the K_ARCH_XXX defines.
[kstuff-mirror.git] / kProfiler2 / kPrf2WinApi-pre.sed
blobbd4e2ad8547efe549c5dc4e0b02143c6d6f52a7e
1 # $Id$
2 ## @file
3 # This SED script will try normalize a windows header
4 # in order to make it easy to pick out function prototypes.
8 # Copyright (c) 2008 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net>
10 # Permission is hereby granted, free of charge, to any person
11 # obtaining a copy of this software and associated documentation
12 # files (the "Software"), to deal in the Software without
13 # restriction, including without limitation the rights to use,
14 # copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following
17 # conditions:
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
24 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 # OTHER DEALINGS IN THE SOFTWARE.
33 # Drop all preprocessor lines (#if/#else/#endif/#define/#undef/#pragma/comments)
34 # (we don't bother with multi line comments ATM.)
35 /^[[:space:]]*#/b drop_line
36 /^[[:space:]]*\/\//b drop_line
38 # Drop empty lines.
39 /^[[:space:]]*$/b drop_line
41 # Drop trailing comments and trailing whitespace
42 s/[[:space:]][[:space:]]*\/\.*$//g
43 s,[[:space:]][[:space:]]*/\*[^*/]*\*/[[:space:]]*$,,g
44 s/[[:space:]][[:space:]]*$//g
46 # Pick out the WINBASEAPI stuff (WinBase.h)
47 /^WINBASEAPI/b winapi
48 /^NTSYSAPI/b winapi
49 /^WINAPI$/b winapi_perhaps
50 /^APIENTRY$/b winapi_perhaps
53 b end
55 # No WINBASEAPI, so we'll have to carefully check the hold buffer.
56 :winapi_perhaps
58 /^[A-Z][A-Z0-9_][A-Z0-9_]*[A-Z0-9]$/!b drop_line
60 s/\r/ /g
61 s/\n/ /g
62 b winapi
64 # Make it one line and a bit standardized
65 :winapi
66 /;/b winapi_got_it
68 b winapi
69 :winapi_got_it
70 s/\n/ /g
71 s/[[:space:]][[:space:]]*\/\*[^*/]*\*\/[[:space:]]*//g
72 s/[[:space:]][[:space:]]*(/(/g
73 s/)[[:space:]][[:space:]]*/)/g
74 s/(\([^[:space:]]\)/( \1/g
75 s/\([^[:space:]]\))/\1 )/g
76 s/[*]\([^[:space:]]\)/* \1/g
77 s/\([^[:space:]]\)[*]/\1 */g
78 s/[[:space:]][[:space:]]*/ /g
79 s/[[:space:]][[:space:]]*,/,/g
80 s/,/, /g
81 s/,[[:space:]][[:space:]]*/, /g
83 # Drop the nasty bit of the sal.h / SpecString.h stuff.
84 s/[[:space:]]__[a-z][a-z_]*([^()]*)[[:space:]]*/ /g
85 s/[[:space:]]__out[a-z_]*[[:space:]]*/ /g
86 s/[[:space:]]__in[a-z_]*[[:space:]]*/ /g
87 s/[[:space:]]__deref[a-z_]*[[:space:]]*/ /g
88 s/[[:space:]]__reserved[[:space:]]*/ /g
89 s/[[:space:]]__nullnullterminated[[:space:]]*/ /g
90 s/[[:space:]]__checkReturn[[:space:]]*/ /g
92 # Drop some similar stuff.
93 s/[[:space:]]OPTIONAL[[:space:]]/ /g
94 s/[[:space:]]OPTIONAL,/ ,/g
96 # The __declspec() bit isn't necessary
97 s/WINBASEAPI *//
98 s/NTSYSAPI *//
99 s/DECLSPEC_NORETURN *//
100 s/__declspec([^()]*) *//
102 # Normalize spaces.
103 s/[[:space:]]/ /g
105 # Clear the hold space
107 s/^.*$//
109 b end
111 :drop_line
112 s/^.*$//
116 :end