1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/wins_switching/generate_stubs.pl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,136 @@
1.4 +#!/bin/perl -w
1.5 +
1.6 +# Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
1.7 +# All rights reserved.
1.8 +# This component and the accompanying materials are made available
1.9 +# under the terms of "Eclipse Public License v1.0"
1.10 +# which accompanies this distribution, and is available
1.11 +# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.12 +#
1.13 +# Initial Contributors:
1.14 +# Nokia Corporation - initial contribution.
1.15 +#
1.16 +# Contributors:
1.17 +#
1.18 +# Description:
1.19 +# Generates the ws32_stubs.h header file and the ws32switchU.def
1.20 +# file from the ws322U def file.
1.21 +#
1.22 +#
1.23 +
1.24 +use strict;
1.25 +
1.26 +my $COPYRIGHT = <<"EndCopyrightAndLicense";
1.27 +/*
1.28 + * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
1.29 + * All rights reserved.
1.30 + * This component and the accompanying materials are made available
1.31 + * under the terms of "Eclipse Public License v1.0"
1.32 + * which accompanies this distribution, and is available
1.33 + * at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.34 + */
1.35 +EndCopyrightAndLicense
1.36 +
1.37 +my $SOURCE_DEF_SIZE = 0;
1.38 +my $WS32_DEF = "../BWINS/";
1.39 +my $WS32_DEF2 = "../BWINS/";
1.40 +my $WS32SWITCH_HEADER = "";
1.41 +my $WS32SWITCH_DEF = "../BWINS/";
1.42 +
1.43 +&main();
1.44 +exit(0);
1.45 +
1.46 +sub main() {
1.47 + my $maxOrdinal = 1;
1.48 + my $def2MaxOrdinal = 1;
1.49 +
1.50 + $WS32_DEF .= $ARGV[0];
1.51 + $WS32SWITCH_HEADER = $ARGV[1];
1.52 + $WS32SWITCH_DEF .= $ARGV[2];
1.53 +
1.54 + open DEF, $WS32_DEF or
1.55 + die "Cannot open $WS32_DEF\n";
1.56 +
1.57 +
1.58 + my ($dev, $ino, $mode, $nlink, $uid, $gid,
1.59 + $rdev, $size, $atime, $mtime, $ctime,
1.60 + $blksize, $blocks)
1.61 + = stat($WS32_DEF);
1.62 + # the file size could be checked by the switcher build to verify that the stub is up to date.
1.63 + $SOURCE_DEF_SIZE= $size;
1.64 +
1.65 + open HEADER_OUT, ">${WS32SWITCH_HEADER}" or
1.66 + die "Cannot create $WS32SWITCH_HEADER\n";
1.67 +
1.68 + open DEF_OUT, ">${WS32SWITCH_DEF}" or
1.69 + die "Cannot create $WS32SWITCH_DEF\n";
1.70 +
1.71 + &printHeaderStart(\*HEADER_OUT);
1.72 + &printDefStart(\*DEF_OUT);
1.73 +
1.74 + while (<DEF>) {
1.75 + chomp;
1.76 + if (/^\s+\?/) {
1.77 + if (s/.*;/;/) {
1.78 + &printDefEntry(\*DEF_OUT, $maxOrdinal, $_);
1.79 + &printHeaderEntry(\*HEADER_OUT,$maxOrdinal,$_);
1.80 + } else {
1.81 + &printDefEntry(\*DEF_OUT, $maxOrdinal, "");
1.82 + &printHeaderEntry(\*HEADER_OUT,$maxOrdinal, "(noname)");
1.83 + }
1.84 + $maxOrdinal++;
1.85 + }
1.86 + }
1.87 + &printHeaderEnd(\*HEADER_OUT,$maxOrdinal);
1.88 + &printDefEnd(\*DEF_OUT);
1.89 +
1.90 +
1.91 +
1.92 + close DEF;
1.93 + close HEADER_OUT;
1.94 + close DEF_OUT;
1.95 +}
1.96 +
1.97 +sub printDefStart(\$) {
1.98 + my ($fh) = @_;
1.99 + print $fh "EXPORTS\n";
1.100 +}
1.101 +
1.102 +sub printDefEntry(\$\$\$) {
1.103 + my ($fh, $ordinal, $comment) = @_;
1.104 + print $fh "\tcall_vector_${ordinal} @ ${ordinal} NONAME $comment\n";
1.105 +}
1.106 +
1.107 +sub printDefEnd(\$) {
1.108 + my ($fh) = @_;
1.109 + print $fh "\n";
1.110 +}
1.111 +
1.112 +sub printHeaderStart(\$) {
1.113 + my ($fh) = @_;
1.114 +
1.115 + print $fh "$COPYRIGHT\n" .
1.116 + "/* Generated from \"$WS32_DEF\" file size: $SOURCE_DEF_SIZE */\n\n" .
1.117 + "extern \"C\" {\n" .
1.118 + "void common_dispatch();\n" .
1.119 + "\n";
1.120 +}
1.121 +
1.122 +sub printHeaderEntry(\$\$\$) {
1.123 + my ($fh, $ordinal, $comment) = @_;
1.124 +
1.125 + print $fh "__declspec(dllexport)\n" .
1.126 + "__declspec(naked)\n" .
1.127 + "void call_vector_${ordinal} ()\n" .
1.128 + "\t{\n" .
1.129 + "\t// ${comment}\n" .
1.130 + "\t_asm mov eax, $ordinal\n" .
1.131 + "\t_asm jmp common_dispatch\n" .
1.132 + "\t}\n\n";
1.133 +}
1.134 +
1.135 +sub printHeaderEnd(\$\$) {
1.136 + my ($fh, $maxOrdinal) = @_;
1.137 + print $fh "}\n" .
1.138 + "#define MAX_ORDINAL $maxOrdinal\n\n";
1.139 +}