Bug 1386962 - Remove template code from XPIDL generated header files. r=froydnj.

XPIDL generated header files contain a |#if 0| block for every interface,
providing the skeleton of the class as it must be implemented in C++. This is
potentially useful, but also very verbose.

This patch removes this code. In a Linux64 debug build, this reduces the total
size of the $OBJDIR/dist/include/nsI*.h files from 11,023,499 bytes to
8,442,350 bytes, a 23.5% reduction. It didn't speed up compilation, though.

--HG--
extra : rebase_source : 65e1e46cffe7c831d83c3308d7ce58c801618dda
This commit is contained in:
Nicholas Nethercote 2017-08-03 17:05:01 +10:00
Родитель fe98b4e219
Коммит 4f49ba4241
1 изменённых файлов: 1 добавлений и 71 удалений

Просмотреть файл

@ -294,53 +294,6 @@ iface_forward_safe = """
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_%(macroname)s(_to) """
iface_template_prolog = """
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class %(implclass)s : public %(name)s
{
public:
NS_DECL_ISUPPORTS
NS_DECL_%(macroname)s
%(implclass)s();
private:
~%(implclass)s();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS(%(implclass)s, %(name)s)
%(implclass)s::%(implclass)s()
{
/* member initializers and constructor code */
}
%(implclass)s::~%(implclass)s()
{
/* destructor code */
}
"""
example_tmpl = """%(returntype)s %(implclass)s::%(nativeName)s(%(paramList)s)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
"""
iface_template_epilog = """/* End of implementation class template. */
#endif
"""
attr_infallible_tmpl = """\
inline %(realtype)s%(nativename)s(%(args)s)
{
@ -525,30 +478,7 @@ def write_interface(iface, fd):
"\\\n %(asNative)s override { return !_to ? NS_ERROR_NULL_POINTER : _to->%(nativeName)s(%(paramList)s); } ",
"\\\n %(asNative)s override; ")
fd.write(iface_template_prolog % names)
for member in iface.members:
if isinstance(member, xpidl.ConstMember) or isinstance(member, xpidl.CDATA):
continue
fd.write("/* %s */\n" % member.toIDL())
if isinstance(member, xpidl.Attribute):
fd.write(example_tmpl % {'implclass': implclass,
'returntype': attributeReturnType(member, 'NS_IMETHODIMP'),
'nativeName': attributeNativeName(member, True),
'paramList': attributeParamlist(member, True)})
if not member.readonly:
fd.write(example_tmpl % {'implclass': implclass,
'returntype': attributeReturnType(member, 'NS_IMETHODIMP'),
'nativeName': attributeNativeName(member, False),
'paramList': attributeParamlist(member, False)})
elif isinstance(member, xpidl.Method):
fd.write(example_tmpl % {'implclass': implclass,
'returntype': methodReturnType(member, 'NS_IMETHODIMP'),
'nativeName': methodNativeName(member),
'paramList': paramlistAsNative(member, empty='')})
fd.write('\n')
fd.write(iface_template_epilog)
fd.write('\n\n')
def main(outputfile):