xpcom/reflect/xptcall/public/genstubs.pl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #!/usr/local/bin/perl
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 # This is used to generate stub entry points. We generate a file to
     8 # be included in the declaraion and a file to be used for expanding macros
     9 # to represent the implementation of the stubs.
    11 #
    12 # if "$entry_count" is ever changed and the .inc files regenerated then
    13 # the following issues need to be addressed:
    14 #
    15 # 1) The current Linux ARM code has a limitation of only having 256-3 stubs,
    16 #    as a result of the limitations of immediate values in ARM assembly.
    17 #
    18 # This number is verified by the IDL parser in xpcom/idl-parser/xpidl.py, as
    19 # well as in xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp, to
    20 # prevent generating interfaces or loading xpt files that would cause the
    21 # stubs to run off the entries.
    22 # If you change this number, please update that location.
    24 # 3 entries are already 'used' by the 3 methods of nsISupports.
    25 # 3+247+5=255 This should get us in under the Linux ARM limitation
    26 $entry_count    = 247;
    27 $sentinel_count = 5;
    29 $decl_name = "xptcstubsdecl.inc";
    30 $def_name  = "xptcstubsdef.inc";
    32 ##
    33 ## Write the declarations include file
    34 ##
    36 die "Can't open $decl_name" if !open(OUTFILE, ">$decl_name");
    38 print OUTFILE "/* generated file - DO NOT EDIT */\n\n";
    39 print OUTFILE "/* includes ",$entry_count," stub entries, and ",
    40               $sentinel_count," sentinel entries */\n\n";
    41 print OUTFILE "/*\n";
    42 print OUTFILE "*  declarations of normal stubs...\n";
    43 print OUTFILE "*  0 is QueryInterface\n";
    44 print OUTFILE "*  1 is AddRef\n";
    45 print OUTFILE "*  2 is Release\n";
    46 print OUTFILE "*/\n";
    47 print OUTFILE "#if !defined(__ia64) || (!defined(__hpux) && !defined(__linux__) && !defined(__FreeBSD__))\n";
    48 for($i = 0; $i < $entry_count; $i++) {
    49     print OUTFILE "NS_IMETHOD Stub",$i+3,"();\n";
    50 }
    51 print OUTFILE "#else\n";
    52 for($i = 0; $i < $entry_count; $i++) {
    53     print OUTFILE "NS_IMETHOD Stub",$i+3,"(uint64_t,uint64_t,\n";
    54     print OUTFILE " uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t);\n";
    56 }
    57 print OUTFILE "#endif\n";
    59 print OUTFILE "\n/* declarations of sentinel stubs */\n";
    61 for($i = 0; $i < $sentinel_count; $i++) {
    62     print OUTFILE "NS_IMETHOD Sentinel",$i,"();\n";
    63 }
    64 close(OUTFILE);
    67 ##
    68 ## Write the definitions include file. This assumes a macro will be used to
    69 ## expand the entries written...
    70 ##
    72 die "Can't open $def_name" if !open(OUTFILE, ">$def_name");
    74 ## Disabled for bug 275004 - followup to fix is Bug 419604
    75 my $warn_inc_is_generated = 0;
    76 if ($warn_inc_is_generated) {
    77 print OUTFILE "/* generated file - DO NOT EDIT */\n\n";
    78 print OUTFILE "/* includes ",$entry_count," stub entries, and ",
    79               $sentinel_count," sentinel entries */\n\n";
    80 }
    82 for($i = 0; $i < $entry_count; $i++) {
    83     print OUTFILE "STUB_ENTRY(",$i+3,")\n";
    84 }
    86 for($i = 0; $i < $sentinel_count; $i++) {
    87     print OUTFILE "SENTINEL_ENTRY(",$i,")\n";
    88 }

mercurial