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