xpcom/reflect/xptcall/public/genstubs.pl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial