13 # Contributors: |
13 # Contributors: |
14 # |
14 # |
15 # Description: |
15 # Description: |
16 # Generates the ws32_stubs.h header file and the ws32switchU.def |
16 # Generates the ws32_stubs.h header file and the ws32switchU.def |
17 # file from the ws322U def file. |
17 # file from the ws322U def file. |
18 # |
18 # |
19 # |
19 # |
20 |
20 |
21 use strict; |
21 use strict; |
22 my $COPYRIGHT = "Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies)."; |
22 |
|
23 my $COPYRIGHT = <<"EndCopyrightAndLicense"; |
|
24 /* |
|
25 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
26 * All rights reserved. |
|
27 * This component and the accompanying materials are made available |
|
28 * under the terms of "Eclipse Public License v1.0" |
|
29 * which accompanies this distribution, and is available |
|
30 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
31 */ |
|
32 EndCopyrightAndLicense |
23 |
33 |
24 my $SOURCE_DEF_SIZE = 0; |
34 my $SOURCE_DEF_SIZE = 0; |
25 my $WS32_DEF = "../BWINS/"; |
35 my $WS32_DEF = "../BWINS/"; |
26 my $WS32_DEF2 = "../BWINS/"; |
36 my $WS32_DEF2 = "../BWINS/"; |
27 my $WS32SWITCH_HEADER = ""; |
37 my $WS32SWITCH_HEADER = ""; |
29 |
39 |
30 &main(); |
40 &main(); |
31 exit(0); |
41 exit(0); |
32 |
42 |
33 sub main() { |
43 sub main() { |
34 my $maxOrdinal = 1; |
44 my $maxOrdinal = 1; |
35 my $def2MaxOrdinal = 1; |
45 my $def2MaxOrdinal = 1; |
36 |
46 |
37 $WS32_DEF .= $ARGV[0]; |
47 $WS32_DEF .= $ARGV[0]; |
38 $WS32SWITCH_HEADER = $ARGV[1]; |
48 $WS32SWITCH_HEADER = $ARGV[1]; |
39 $WS32SWITCH_DEF .= $ARGV[2]; |
49 $WS32SWITCH_DEF .= $ARGV[2]; |
40 |
50 |
41 open DEF, $WS32_DEF or |
51 open DEF, $WS32_DEF or |
42 die "Cannot open $WS32_DEF\n"; |
52 die "Cannot open $WS32_DEF\n"; |
43 |
53 |
44 |
|
45 my ($dev, $ino, $mode, $nlink, $uid, $gid, |
|
46 $rdev, $size, $atime, $mtime, $ctime, |
|
47 $blksize, $blocks) |
|
48 = stat($WS32_DEF); |
|
49 # the file size could be checked by the switcher build to verify that the stub is up to date. |
|
50 $SOURCE_DEF_SIZE= $size; |
|
51 |
|
52 open HEADER_OUT, ">${WS32SWITCH_HEADER}" or |
|
53 die "Cannot create $WS32SWITCH_HEADER\n"; |
|
54 |
54 |
55 open DEF_OUT, ">${WS32SWITCH_DEF}" or |
55 my ($dev, $ino, $mode, $nlink, $uid, $gid, |
56 die "Cannot create $WS32SWITCH_DEF\n"; |
56 $rdev, $size, $atime, $mtime, $ctime, |
|
57 $blksize, $blocks) |
|
58 = stat($WS32_DEF); |
|
59 # the file size could be checked by the switcher build to verify that the stub is up to date. |
|
60 $SOURCE_DEF_SIZE= $size; |
57 |
61 |
58 &printHeaderStart(\*HEADER_OUT); |
62 open HEADER_OUT, ">${WS32SWITCH_HEADER}" or |
59 &printDefStart(\*DEF_OUT); |
63 die "Cannot create $WS32SWITCH_HEADER\n"; |
60 |
64 |
61 while (<DEF>) { |
65 open DEF_OUT, ">${WS32SWITCH_DEF}" or |
62 chomp; |
66 die "Cannot create $WS32SWITCH_DEF\n"; |
63 if (/^\s+\?/) { |
|
64 if (s/.*;/;/) { |
|
65 &printDefEntry(\*DEF_OUT, $maxOrdinal, $_); |
|
66 &printHeaderEntry(\*HEADER_OUT,$maxOrdinal,$_); |
|
67 } else { |
|
68 &printDefEntry(\*DEF_OUT, $maxOrdinal, ""); |
|
69 &printHeaderEntry(\*HEADER_OUT,$maxOrdinal, "(noname)"); |
|
70 } |
|
71 $maxOrdinal++; |
|
72 } |
|
73 } |
|
74 &printHeaderEnd(\*HEADER_OUT,$maxOrdinal); |
|
75 &printDefEnd(\*DEF_OUT); |
|
76 |
67 |
77 |
68 &printHeaderStart(\*HEADER_OUT); |
|
69 &printDefStart(\*DEF_OUT); |
78 |
70 |
79 close DEF; |
71 while (<DEF>) { |
80 close HEADER_OUT; |
72 chomp; |
81 close DEF_OUT; |
73 if (/^\s+\?/) { |
|
74 if (s/.*;/;/) { |
|
75 &printDefEntry(\*DEF_OUT, $maxOrdinal, $_); |
|
76 &printHeaderEntry(\*HEADER_OUT,$maxOrdinal,$_); |
|
77 } else { |
|
78 &printDefEntry(\*DEF_OUT, $maxOrdinal, ""); |
|
79 &printHeaderEntry(\*HEADER_OUT,$maxOrdinal, "(noname)"); |
|
80 } |
|
81 $maxOrdinal++; |
|
82 } |
|
83 } |
|
84 &printHeaderEnd(\*HEADER_OUT,$maxOrdinal); |
|
85 &printDefEnd(\*DEF_OUT); |
|
86 |
|
87 |
|
88 |
|
89 close DEF; |
|
90 close HEADER_OUT; |
|
91 close DEF_OUT; |
82 } |
92 } |
83 |
93 |
84 sub printDefStart(\$) { |
94 sub printDefStart(\$) { |
85 my ($fh) = @_; |
95 my ($fh) = @_; |
86 print $fh "EXPORTS\n"; |
96 print $fh "EXPORTS\n"; |
87 } |
97 } |
88 |
98 |
89 sub printDefEntry(\$\$\$) { |
99 sub printDefEntry(\$\$\$) { |
90 my ($fh, $ordinal, $comment) = @_; |
100 my ($fh, $ordinal, $comment) = @_; |
91 print $fh "\tcall_vector_${ordinal} @ ${ordinal} NONAME $comment\n"; |
101 print $fh "\tcall_vector_${ordinal} @ ${ordinal} NONAME $comment\n"; |
92 } |
102 } |
93 |
103 |
94 sub printDefEnd(\$) { |
104 sub printDefEnd(\$) { |
95 my ($fh) = @_; |
105 my ($fh) = @_; |
96 print $fh "\n"; |
106 print $fh "\n"; |
97 } |
107 } |
98 |
108 |
99 sub printHeaderStart(\$) { |
109 sub printHeaderStart(\$) { |
100 my ($fh) = @_; |
110 my ($fh) = @_; |
101 |
111 |
102 print $fh "// Generated from \"$WS32_DEF\" file size: $SOURCE_DEF_SIZE\n" . |
112 print $fh "$COPYRIGHT\n" . |
103 "// $COPYRIGHT\n" . |
113 "/* Generated from \"$WS32_DEF\" file size: $SOURCE_DEF_SIZE */\n\n" . |
104 "\n" . |
114 "extern \"C\" {\n" . |
105 "extern \"C\" {\n" . |
115 "void common_dispatch();\n" . |
106 "void common_dispatch();\n" . |
116 "\n"; |
107 "\n"; |
|
108 } |
117 } |
109 |
118 |
110 sub printHeaderEntry(\$\$\$) { |
119 sub printHeaderEntry(\$\$\$) { |
111 my ($fh, $ordinal, $comment) = @_; |
120 my ($fh, $ordinal, $comment) = @_; |
112 |
121 |
113 print $fh "__declspec(dllexport)\n" . |
122 print $fh "__declspec(dllexport)\n" . |
114 "__declspec(naked)\n" . |
123 "__declspec(naked)\n" . |
115 "void call_vector_${ordinal} ()\n" . |
124 "void call_vector_${ordinal} ()\n" . |
116 "\t{\n" . |
125 "\t{\n" . |
117 "\t// ${comment}\n" . |
126 "\t// ${comment}\n" . |
118 "\t_asm mov eax, $ordinal\n" . |
127 "\t_asm mov eax, $ordinal\n" . |
119 "\t_asm jmp common_dispatch\n" . |
128 "\t_asm jmp common_dispatch\n" . |
120 "\t}\n\n"; |
129 "\t}\n\n"; |
121 } |
130 } |
122 |
131 |
123 sub printHeaderEnd(\$\$) { |
132 sub printHeaderEnd(\$\$) { |
124 my ($fh, $maxOrdinal) = @_; |
133 my ($fh, $maxOrdinal) = @_; |
125 print $fh "}\n" . |
134 print $fh "}\n" . |
126 "#define MAX_ORDINAL $maxOrdinal\n\n"; |
135 "#define MAX_ORDINAL $maxOrdinal\n\n"; |
127 } |
136 } |