VirtualBox

source: kStuff/trunk/kProfiler2/kPrf2WinApi-pre.sed

Last change on this file was 29, checked in by bird, 16 years ago

Finally got around execute the switch to the MIT license.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1# $Id: kPrf2WinApi-pre.sed 29 2009-07-01 20:30:29Z bird $
2## @file
3# This SED script will try normalize a windows header
4# in order to make it easy to pick out function prototypes.
5#
6
7#
8# Copyright (c) 2008 Knut St. Osmundsen <[email protected]>
9#
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:
18#
19# The above copyright notice and this permission notice shall be
20# included in all copies or substantial portions of the Software.
21#
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.
30#
31
32
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
37
38# Drop empty lines.
39/^[[:space:]]*$/b drop_line
40
41# Drop trailing comments and trailing whitespace
42s/[[:space:]][[:space:]]*\/\.*$//g
43s,[[:space:]][[:space:]]*/\*[^*/]*\*/[[:space:]]*$,,g
44s/[[:space:]][[:space:]]*$//g
45
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
51h
52d
53b end
54
55# No WINBASEAPI, so we'll have to carefully check the hold buffer.
56:winapi_perhaps
57x
58/^[A-Z][A-Z0-9_][A-Z0-9_]*[A-Z0-9]$/!b drop_line
59G
60s/\r/ /g
61s/\n/ /g
62b winapi
63
64# Make it one line and a bit standardized
65:winapi
66/;/b winapi_got_it
67N
68b winapi
69:winapi_got_it
70s/\n/ /g
71s/[[:space:]][[:space:]]*\/\*[^*/]*\*\/[[:space:]]*//g
72s/[[:space:]][[:space:]]*(/(/g
73s/)[[:space:]][[:space:]]*/)/g
74s/(\([^[:space:]]\)/( \1/g
75s/\([^[:space:]]\))/\1 )/g
76s/[*]\([^[:space:]]\)/* \1/g
77s/\([^[:space:]]\)[*]/\1 */g
78s/[[:space:]][[:space:]]*/ /g
79s/[[:space:]][[:space:]]*,/,/g
80s/,/, /g
81s/,[[:space:]][[:space:]]*/, /g
82
83# Drop the nasty bit of the sal.h / SpecString.h stuff.
84s/[[:space:]]__[a-z][a-z_]*([^()]*)[[:space:]]*/ /g
85s/[[:space:]]__out[a-z_]*[[:space:]]*/ /g
86s/[[:space:]]__in[a-z_]*[[:space:]]*/ /g
87s/[[:space:]]__deref[a-z_]*[[:space:]]*/ /g
88s/[[:space:]]__reserved[[:space:]]*/ /g
89s/[[:space:]]__nullnullterminated[[:space:]]*/ /g
90s/[[:space:]]__checkReturn[[:space:]]*/ /g
91
92# Drop some similar stuff.
93s/[[:space:]]OPTIONAL[[:space:]]/ /g
94s/[[:space:]]OPTIONAL,/ ,/g
95
96# The __declspec() bit isn't necessary
97s/WINBASEAPI *//
98s/NTSYSAPI *//
99s/DECLSPEC_NORETURN *//
100s/__declspec([^()]*) *//
101
102# Normalize spaces.
103s/[[:space:]]/ /g
104
105# Clear the hold space
106x
107s/^.*$//
108x
109b end
110
111:drop_line
112s/^.*$//
113h
114d
115
116:end
117
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette