gdbus-codegen: Split license string

The license string which is embedded in the C header and body
preambles has been moved to a global variable. This way it can be
reused in both sections.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
This commit is contained in:
Iñigo Martínez 2018-01-03 10:26:12 +01:00
parent 6dafc1ce13
commit a3d223d0e9

View File

@ -25,6 +25,13 @@ from . import config
from . import utils
from . import dbustypes
LICENSE_STR = '''/*
* Generated by gdbus-codegen {!s}. DO NOT EDIT.
*
* The license of this code is the same as for the D-Bus interface description
* it was derived from.
*/\n'''
# ----------------------------------------------------------------------------------------------------
class CodeGenerator:
@ -55,14 +62,8 @@ class CodeGenerator:
# ----------------------------------------------------------------------------------------------------
def generate_intro(self):
self.c.write('/*\n'
' * Generated by gdbus-codegen %s. DO NOT EDIT.\n'
' *\n'
' * The license of this code is the same as for the D-Bus interface description\n'
' * it was derived from.\n'
' */\n'
'\n'
%(config.VERSION))
self.c.write(LICENSE_STR.format(config.VERSION))
self.c.write('\n')
self.c.write('#ifdef HAVE_CONFIG_H\n'
'# include "config.h"\n'
'#endif\n'
@ -220,20 +221,15 @@ class CodeGenerator:
'}\n'
'\n')
self.h.write('/*\n'
' * Generated by gdbus-codegen %s. DO NOT EDIT.\n'
' *\n'
' * The license of this code is the same as for the D-Bus interface description\n'
' * it was derived from.\n'
' */\n'
'\n'
'#ifndef __%s__\n'
'#define __%s__\n'
'\n'%(config.VERSION, self.header_guard, self.header_guard))
self.h.write('#include <gio/gio.h>\n'
'\n'
'G_BEGIN_DECLS\n'
'\n')
self.h.write(LICENSE_STR.format(config.VERSION))
self.h.write('\n')
self.h.write('#ifndef __{!s}__\n'.format(self.header_guard))
self.h.write('#define __{!s}__\n'.format(self.header_guard))
self.h.write('\n')
self.h.write('#include <gio/gio.h>\n')
self.h.write('\n')
self.h.write('G_BEGIN_DECLS\n')
self.h.write('\n')
# ----------------------------------------------------------------------------------------------------