1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/scdv_switch/generate_stubs.pl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,118 @@
1.4 +#!/bin/perl -w
1.5 +
1.6 +# Copyright (c) 2004-2009 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 scdv_stubs.h header file and the scdvswitchu.def
1.20 +# file from the scdvu def file.
1.21 +#
1.22 +#
1.23 +
1.24 +use strict;
1.25 +my $COPYRIGHT = "Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).";
1.26 +
1.27 +my $SCDV_DEF = "../bwins/scdvu.def";
1.28 +my $SCDVSWITCH_HEADER = "scdv_stubs.h";
1.29 +my $SCDVSWITCH_DEF = "../bwins/scdvswitchu.def";
1.30 +my $SOURCE_DEF_SIZE = 0;
1.31 +
1.32 +&main();
1.33 +exit(0);
1.34 +
1.35 +sub main() {
1.36 + my $maxOrdinal = 1;
1.37 +
1.38 + open DEF, $SCDV_DEF or
1.39 + die "Cannot open $SCDV_DEF\n";
1.40 +
1.41 + my ($dev, $ino, $mode, $nlink, $uid, $gid,
1.42 + $rdev, $size, $atime, $mtime, $ctime,
1.43 + $blksize, $blocks)
1.44 + = stat($SCDV_DEF);
1.45 + # the file size could be checked by the switcher build to verify that the stub is up to date.
1.46 + $SOURCE_DEF_SIZE= $size;
1.47 +
1.48 + open HEADER_OUT, ">${SCDVSWITCH_HEADER}" or
1.49 + die "Cannot create $SCDVSWITCH_HEADER\n";
1.50 +
1.51 + open DEF_OUT, ">${SCDVSWITCH_DEF}" or
1.52 + die "Cannot create $SCDVSWITCH_DEF\n";
1.53 +
1.54 + &printHeaderStart(\*HEADER_OUT);
1.55 + &printDefStart(\*DEF_OUT);
1.56 +
1.57 + while (<DEF>) {
1.58 + chomp;
1.59 + if (/^\s+\?/) {
1.60 + if (s/.*;/;/) {
1.61 + &printDefEntry(\*DEF_OUT, $maxOrdinal, $_);
1.62 + &printHeaderEntry(\*HEADER_OUT,$maxOrdinal,$_);
1.63 + } else {
1.64 + &printDefEntry(\*DEF_OUT, $maxOrdinal, "");
1.65 + &printHeaderEntry(\*HEADER_OUT,$maxOrdinal, "(noname)");
1.66 + }
1.67 + $maxOrdinal++;
1.68 + }
1.69 + }
1.70 + &printHeaderEnd(\*HEADER_OUT,$maxOrdinal);
1.71 + &printDefEnd(\*DEF_OUT);
1.72 +
1.73 + close DEF;
1.74 + close HEADER_OUT;
1.75 + close DEF_OUT;
1.76 +}
1.77 +
1.78 +sub printDefStart(\$) {
1.79 + my ($fh) = @_;
1.80 + print $fh "EXPORTS\n";
1.81 +}
1.82 +
1.83 +sub printDefEntry(\$\$\$) {
1.84 + my ($fh, $ordinal, $comment) = @_;
1.85 + print $fh "\tcall_vector_${ordinal} @ ${ordinal} NONAME $comment\n";
1.86 +}
1.87 +
1.88 +sub printDefEnd(\$) {
1.89 + my ($fh) = @_;
1.90 + print $fh "\n";
1.91 +}
1.92 +
1.93 +sub printHeaderStart(\$) {
1.94 + my ($fh) = @_;
1.95 +
1.96 + print $fh "// Generated from \"$SCDV_DEF\" file size: $SOURCE_DEF_SIZE\n" .
1.97 + "// $COPYRIGHT\n" .
1.98 + "\n" .
1.99 + "extern \"C\" {\n" .
1.100 + "void common_dispatch();\n" .
1.101 + "\n";
1.102 +}
1.103 +
1.104 +sub printHeaderEntry(\$\$\$) {
1.105 + my ($fh, $ordinal, $comment) = @_;
1.106 +
1.107 + print $fh "__declspec(dllexport)\n" .
1.108 + "__declspec(naked)\n" .
1.109 + "void call_vector_${ordinal} ()\n" .
1.110 + "\t{\n" .
1.111 + "\t// ${comment}\n" .
1.112 + "\t_asm mov eax, $ordinal\n" .
1.113 + "\t_asm jmp common_dispatch\n" .
1.114 + "\t}\n\n";
1.115 +}
1.116 +
1.117 +sub printHeaderEnd(\$\$) {
1.118 + my ($fh, $maxOrdinal) = @_;
1.119 + print $fh "}\n" .
1.120 + "#define MAX_ORDINAL $maxOrdinal\n\n";
1.121 +}