VirtualBox

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

Last change on this file since 28 was 13, checked in by bird, 17 years ago

Made it (winapi wrapping) work.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1# $Id: kPrf2WinApi-pre.sed 13 2008-04-20 10:13:43Z 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# This file is part of kProfiler.
11#
12# kProfiler is free software; you can redistribute it and/or
13# modify it under the terms of the GNU Lesser General Public
14# License as published by the Free Software Foundation; either
15# version 2.1 of the License, or (at your option) any later version.
16#
17# kProfiler is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# Lesser General Public License for more details.
21#
22# You should have received a copy of the GNU Lesser General Public
23# License along with kProfiler; if not, write to the Free Software
24# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25#
26
27
28# Drop all preprocessor lines (#if/#else/#endif/#define/#undef/#pragma/comments)
29# (we don't bother with multi line comments ATM.)
30/^[[:space:]]*#/b drop_line
31/^[[:space:]]*\/\//b drop_line
32
33# Drop empty lines.
34/^[[:space:]]*$/b drop_line
35
36# Drop trailing comments and trailing whitespace
37s/[[:space:]][[:space:]]*\/\.*$//g
38s,[[:space:]][[:space:]]*/\*[^*/]*\*/[[:space:]]*$,,g
39s/[[:space:]][[:space:]]*$//g
40
41# Pick out the WINBASEAPI stuff (WinBase.h)
42/^WINBASEAPI/b winapi
43/^NTSYSAPI/b winapi
44/^WINAPI$/b winapi_perhaps
45/^APIENTRY$/b winapi_perhaps
46h
47d
48b end
49
50# No WINBASEAPI, so we'll have to carefully check the hold buffer.
51:winapi_perhaps
52x
53/^[A-Z][A-Z0-9_][A-Z0-9_]*[A-Z0-9]$/!b drop_line
54G
55s/\r/ /g
56s/\n/ /g
57b winapi
58
59# Make it one line and a bit standardized
60:winapi
61/;/b winapi_got_it
62N
63b winapi
64:winapi_got_it
65s/\n/ /g
66s/[[:space:]][[:space:]]*\/\*[^*/]*\*\/[[:space:]]*//g
67s/[[:space:]][[:space:]]*(/(/g
68s/)[[:space:]][[:space:]]*/)/g
69s/(\([^[:space:]]\)/( \1/g
70s/\([^[:space:]]\))/\1 )/g
71s/[*]\([^[:space:]]\)/* \1/g
72s/\([^[:space:]]\)[*]/\1 */g
73s/[[:space:]][[:space:]]*/ /g
74s/[[:space:]][[:space:]]*,/,/g
75s/,/, /g
76s/,[[:space:]][[:space:]]*/, /g
77
78# Drop the nasty bit of the sal.h / SpecString.h stuff.
79s/[[:space:]]__[a-z][a-z_]*([^()]*)[[:space:]]*/ /g
80s/[[:space:]]__out[a-z_]*[[:space:]]*/ /g
81s/[[:space:]]__in[a-z_]*[[:space:]]*/ /g
82s/[[:space:]]__deref[a-z_]*[[:space:]]*/ /g
83s/[[:space:]]__reserved[[:space:]]*/ /g
84s/[[:space:]]__nullnullterminated[[:space:]]*/ /g
85s/[[:space:]]__checkReturn[[:space:]]*/ /g
86
87# Drop some similar stuff.
88s/[[:space:]]OPTIONAL[[:space:]]/ /g
89s/[[:space:]]OPTIONAL,/ ,/g
90
91# The __declspec() bit isn't necessary
92s/WINBASEAPI *//
93s/NTSYSAPI *//
94s/DECLSPEC_NORETURN *//
95s/__declspec([^()]*) *//
96
97# Normalize spaces.
98s/[[:space:]]/ /g
99
100# Clear the hold space
101x
102s/^.*$//
103x
104b end
105
106:drop_line
107s/^.*$//
108h
109d
110
111:end
112
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