Added 'final' attribute to classes, made generated Py* structures static
parent
f9f5adf253
commit
fe7e33798a
|
@ -211,7 +211,7 @@ class GUniCharArg(ArgType):
|
|||
' }\n'
|
||||
'#endif\n'
|
||||
' py_ret = (Py_UNICODE)ret;\n'
|
||||
' return PyUnicode_FromUnicode(&py_ret, 1);\n')
|
||||
' return PyUnicode_FromUnicode(&py_ret, 1);')
|
||||
def write_param(self, ptype, pname, pdflt, pnull, info):
|
||||
if pdflt:
|
||||
info.varlist.add('gunichar', pname + " = '" + pdflt + "'")
|
||||
|
@ -289,9 +289,9 @@ class SizeArg(ArgType):
|
|||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add(ptype, 'ret')
|
||||
if self.llp64:
|
||||
info.codeafter.append(' return PyLong_FromUnsignedLongLong(ret);\n')
|
||||
info.codeafter.append(' return PyLong_FromUnsignedLongLong(ret);')
|
||||
else:
|
||||
info.codeafter.append(' return PyLong_FromUnsignedLong(ret);\n')
|
||||
info.codeafter.append(' return PyLong_FromUnsignedLong(ret);')
|
||||
|
||||
class SSizeArg(ArgType):
|
||||
|
||||
|
@ -313,9 +313,9 @@ class SSizeArg(ArgType):
|
|||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add(ptype, 'ret')
|
||||
if self.llp64:
|
||||
info.codeafter.append(' return PyLong_FromLongLong(ret);\n')
|
||||
info.codeafter.append(' return PyLong_FromLongLong(ret);')
|
||||
else:
|
||||
info.codeafter.append(' return PyLong_FromLong(ret);\n')
|
||||
info.codeafter.append(' return PyLong_FromLong(ret);')
|
||||
|
||||
class LongArg(ArgType):
|
||||
def write_param(self, ptype, pname, pdflt, pnull, info):
|
||||
|
@ -327,12 +327,12 @@ class LongArg(ArgType):
|
|||
info.add_parselist('l', ['&' + pname], [pname])
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add(ptype, 'ret')
|
||||
info.codeafter.append(' return PyInt_FromLong(ret);\n')
|
||||
info.codeafter.append(' return PyInt_FromLong(ret);')
|
||||
|
||||
class BoolArg(IntArg):
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add('int', 'ret')
|
||||
info.codeafter.append(' return PyBool_FromLong(ret);\n')
|
||||
info.codeafter.append(' return PyBool_FromLong(ret);')
|
||||
|
||||
class TimeTArg(ArgType):
|
||||
def write_param(self, ptype, pname, pdflt, pnull, info):
|
||||
|
@ -356,7 +356,7 @@ class ULongArg(ArgType):
|
|||
info.add_parselist('k', ['&' + pname], [pname])
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add(ptype, 'ret')
|
||||
info.codeafter.append(' return PyLong_FromUnsignedLong(ret);\n')
|
||||
info.codeafter.append(' return PyLong_FromUnsignedLong(ret);')
|
||||
|
||||
class UInt32Arg(ULongArg):
|
||||
def write_param(self, ptype, pname, pdflt, pnull, info):
|
||||
|
|
|
@ -28,14 +28,14 @@ class Coverage(object):
|
|||
def printstats(self):
|
||||
total = self.wrapped + self.not_wrapped
|
||||
fd = sys.stderr
|
||||
if total:
|
||||
fd.write("***INFO*** The coverage of %s is %.2f%% (%i/%i)\n" %
|
||||
(self.name,
|
||||
float(self.wrapped*100)/total,
|
||||
self.wrapped,
|
||||
total))
|
||||
else:
|
||||
fd.write("***INFO*** There are no declared %s.\n" % self.name)
|
||||
#if total:
|
||||
#fd.write("***INFO*** The coverage of %s is %.2f%% (%i/%i)\n" %
|
||||
#(self.name,
|
||||
#float(self.wrapped*100)/total,
|
||||
#self.wrapped,
|
||||
#total))
|
||||
#else:
|
||||
#fd.write("***INFO*** There are no declared %s.\n" % self.name)
|
||||
|
||||
functions_coverage = Coverage("global functions")
|
||||
methods_coverage = Coverage("methods")
|
||||
|
@ -94,7 +94,7 @@ class FileOutput:
|
|||
|
||||
class Wrapper:
|
||||
type_tmpl = (
|
||||
'PyTypeObject Py%(typename)s_Type = {\n'
|
||||
'static PyTypeObject Py%(typename)s_Type = {\n'
|
||||
' PyObject_HEAD_INIT(NULL)\n'
|
||||
' 0, /* ob_size */\n'
|
||||
' (char*) "%(classname)s", /* tp_name */\n'
|
||||
|
@ -1236,11 +1236,11 @@ class SourceWriter:
|
|||
def write_type_declarations(self):
|
||||
self.fp.write('/* ---------- forward type declarations ---------- */\n')
|
||||
for obj in self.parser.boxes:
|
||||
self.fp.write('PyTypeObject Py' + obj.c_name + '_Type;\n')
|
||||
self.fp.write('static PyTypeObject Py' + obj.c_name + '_Type;\n')
|
||||
for obj in self.parser.objects:
|
||||
self.fp.write('PyTypeObject Py' + obj.c_name + '_Type;\n')
|
||||
self.fp.write('static PyTypeObject Py' + obj.c_name + '_Type;\n')
|
||||
for interface in self.parser.interfaces:
|
||||
self.fp.write('PyTypeObject Py' + interface.c_name + '_Type;\n')
|
||||
self.fp.write('static PyTypeObject Py' + interface.c_name + '_Type;\n')
|
||||
self.fp.write('\n')
|
||||
|
||||
def write_body(self):
|
||||
|
@ -1403,7 +1403,7 @@ class SourceWriter:
|
|||
self.fp.write(
|
||||
' pyg_set_object_has_new_constructor(%s);\n' %
|
||||
obj.typecode)
|
||||
else:
|
||||
elif not obj.final:
|
||||
print >> sys.stderr, (
|
||||
"Warning: Constructor for %s needs to be updated to new API\n"
|
||||
" See http://live.gnome.org/PyGTK_2fWhatsNew28"
|
||||
|
|
|
@ -79,6 +79,7 @@ class ObjectDef(Definition):
|
|||
self.implements = []
|
||||
self.class_init_func = None
|
||||
self.has_new_constructor_api = False
|
||||
self.final = False
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.module = arg[1]
|
||||
|
@ -93,6 +94,8 @@ class ObjectDef(Definition):
|
|||
elif arg[0] == 'fields':
|
||||
for parg in arg[1:]:
|
||||
self.fields.append((parg[0], parg[1]))
|
||||
elif arg[0] == 'final':
|
||||
self.final = (arg[1] == 'true')
|
||||
elif arg[0] == 'implements':
|
||||
self.implements.append(arg[1])
|
||||
def merge(self, old):
|
||||
|
|
Loading…
Reference in New Issue