1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/reflect/xptcall/public/genstubs.pl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +#!/usr/local/bin/perl 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 + 1.10 +# This is used to generate stub entry points. We generate a file to 1.11 +# be included in the declaraion and a file to be used for expanding macros 1.12 +# to represent the implementation of the stubs. 1.13 + 1.14 +# 1.15 +# if "$entry_count" is ever changed and the .inc files regenerated then 1.16 +# the following issues need to be addressed: 1.17 +# 1.18 +# 1) The current Linux ARM code has a limitation of only having 256-3 stubs, 1.19 +# as a result of the limitations of immediate values in ARM assembly. 1.20 +# 1.21 +# This number is verified by the IDL parser in xpcom/idl-parser/xpidl.py, as 1.22 +# well as in xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp, to 1.23 +# prevent generating interfaces or loading xpt files that would cause the 1.24 +# stubs to run off the entries. 1.25 +# If you change this number, please update that location. 1.26 + 1.27 +# 3 entries are already 'used' by the 3 methods of nsISupports. 1.28 +# 3+247+5=255 This should get us in under the Linux ARM limitation 1.29 +$entry_count = 247; 1.30 +$sentinel_count = 5; 1.31 + 1.32 +$decl_name = "xptcstubsdecl.inc"; 1.33 +$def_name = "xptcstubsdef.inc"; 1.34 + 1.35 +## 1.36 +## Write the declarations include file 1.37 +## 1.38 + 1.39 +die "Can't open $decl_name" if !open(OUTFILE, ">$decl_name"); 1.40 + 1.41 +print OUTFILE "/* generated file - DO NOT EDIT */\n\n"; 1.42 +print OUTFILE "/* includes ",$entry_count," stub entries, and ", 1.43 + $sentinel_count," sentinel entries */\n\n"; 1.44 +print OUTFILE "/*\n"; 1.45 +print OUTFILE "* declarations of normal stubs...\n"; 1.46 +print OUTFILE "* 0 is QueryInterface\n"; 1.47 +print OUTFILE "* 1 is AddRef\n"; 1.48 +print OUTFILE "* 2 is Release\n"; 1.49 +print OUTFILE "*/\n"; 1.50 +print OUTFILE "#if !defined(__ia64) || (!defined(__hpux) && !defined(__linux__) && !defined(__FreeBSD__))\n"; 1.51 +for($i = 0; $i < $entry_count; $i++) { 1.52 + print OUTFILE "NS_IMETHOD Stub",$i+3,"();\n"; 1.53 +} 1.54 +print OUTFILE "#else\n"; 1.55 +for($i = 0; $i < $entry_count; $i++) { 1.56 + print OUTFILE "NS_IMETHOD Stub",$i+3,"(uint64_t,uint64_t,\n"; 1.57 + print OUTFILE " uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t);\n"; 1.58 + 1.59 +} 1.60 +print OUTFILE "#endif\n"; 1.61 + 1.62 +print OUTFILE "\n/* declarations of sentinel stubs */\n"; 1.63 + 1.64 +for($i = 0; $i < $sentinel_count; $i++) { 1.65 + print OUTFILE "NS_IMETHOD Sentinel",$i,"();\n"; 1.66 +} 1.67 +close(OUTFILE); 1.68 + 1.69 + 1.70 +## 1.71 +## Write the definitions include file. This assumes a macro will be used to 1.72 +## expand the entries written... 1.73 +## 1.74 + 1.75 +die "Can't open $def_name" if !open(OUTFILE, ">$def_name"); 1.76 + 1.77 +## Disabled for bug 275004 - followup to fix is Bug 419604 1.78 +my $warn_inc_is_generated = 0; 1.79 +if ($warn_inc_is_generated) { 1.80 +print OUTFILE "/* generated file - DO NOT EDIT */\n\n"; 1.81 +print OUTFILE "/* includes ",$entry_count," stub entries, and ", 1.82 + $sentinel_count," sentinel entries */\n\n"; 1.83 +} 1.84 + 1.85 +for($i = 0; $i < $entry_count; $i++) { 1.86 + print OUTFILE "STUB_ENTRY(",$i+3,")\n"; 1.87 +} 1.88 + 1.89 +for($i = 0; $i < $sentinel_count; $i++) { 1.90 + print OUTFILE "SENTINEL_ENTRY(",$i,")\n"; 1.91 +}