michael@0: #!/usr/local/bin/perl michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: michael@0: # This is used to generate stub entry points. We generate a file to michael@0: # be included in the declaraion and a file to be used for expanding macros michael@0: # to represent the implementation of the stubs. michael@0: michael@0: # michael@0: # if "$entry_count" is ever changed and the .inc files regenerated then michael@0: # the following issues need to be addressed: michael@0: # michael@0: # 1) The current Linux ARM code has a limitation of only having 256-3 stubs, michael@0: # as a result of the limitations of immediate values in ARM assembly. michael@0: # michael@0: # This number is verified by the IDL parser in xpcom/idl-parser/xpidl.py, as michael@0: # well as in xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp, to michael@0: # prevent generating interfaces or loading xpt files that would cause the michael@0: # stubs to run off the entries. michael@0: # If you change this number, please update that location. michael@0: michael@0: # 3 entries are already 'used' by the 3 methods of nsISupports. michael@0: # 3+247+5=255 This should get us in under the Linux ARM limitation michael@0: $entry_count = 247; michael@0: $sentinel_count = 5; michael@0: michael@0: $decl_name = "xptcstubsdecl.inc"; michael@0: $def_name = "xptcstubsdef.inc"; michael@0: michael@0: ## michael@0: ## Write the declarations include file michael@0: ## michael@0: michael@0: die "Can't open $decl_name" if !open(OUTFILE, ">$decl_name"); michael@0: michael@0: print OUTFILE "/* generated file - DO NOT EDIT */\n\n"; michael@0: print OUTFILE "/* includes ",$entry_count," stub entries, and ", michael@0: $sentinel_count," sentinel entries */\n\n"; michael@0: print OUTFILE "/*\n"; michael@0: print OUTFILE "* declarations of normal stubs...\n"; michael@0: print OUTFILE "* 0 is QueryInterface\n"; michael@0: print OUTFILE "* 1 is AddRef\n"; michael@0: print OUTFILE "* 2 is Release\n"; michael@0: print OUTFILE "*/\n"; michael@0: print OUTFILE "#if !defined(__ia64) || (!defined(__hpux) && !defined(__linux__) && !defined(__FreeBSD__))\n"; michael@0: for($i = 0; $i < $entry_count; $i++) { michael@0: print OUTFILE "NS_IMETHOD Stub",$i+3,"();\n"; michael@0: } michael@0: print OUTFILE "#else\n"; michael@0: for($i = 0; $i < $entry_count; $i++) { michael@0: print OUTFILE "NS_IMETHOD Stub",$i+3,"(uint64_t,uint64_t,\n"; michael@0: print OUTFILE " uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t);\n"; michael@0: michael@0: } michael@0: print OUTFILE "#endif\n"; michael@0: michael@0: print OUTFILE "\n/* declarations of sentinel stubs */\n"; michael@0: michael@0: for($i = 0; $i < $sentinel_count; $i++) { michael@0: print OUTFILE "NS_IMETHOD Sentinel",$i,"();\n"; michael@0: } michael@0: close(OUTFILE); michael@0: michael@0: michael@0: ## michael@0: ## Write the definitions include file. This assumes a macro will be used to michael@0: ## expand the entries written... michael@0: ## michael@0: michael@0: die "Can't open $def_name" if !open(OUTFILE, ">$def_name"); michael@0: michael@0: ## Disabled for bug 275004 - followup to fix is Bug 419604 michael@0: my $warn_inc_is_generated = 0; michael@0: if ($warn_inc_is_generated) { michael@0: print OUTFILE "/* generated file - DO NOT EDIT */\n\n"; michael@0: print OUTFILE "/* includes ",$entry_count," stub entries, and ", michael@0: $sentinel_count," sentinel entries */\n\n"; michael@0: } michael@0: michael@0: for($i = 0; $i < $entry_count; $i++) { michael@0: print OUTFILE "STUB_ENTRY(",$i+3,")\n"; michael@0: } michael@0: michael@0: for($i = 0; $i < $sentinel_count; $i++) { michael@0: print OUTFILE "SENTINEL_ENTRY(",$i,")\n"; michael@0: }