# Or "unspecified" if there is no default.
default = unspecified
- # "default" converted into a str for rendering into Python code.
- py_default = None
-
# "default" as it should appear in the documentation, as a string.
# Or None if there is no default.
doc_default = None
+ # "default" converted into a str for rendering into Python code.
+ py_default = None
+
# "default" converted into a C value, as a string.
# Or None if there is no default.
c_default = None
+ # The default value used to initialize the C variable when
+ # there is no default, but not specifying a default may
+ # result in an "uninitialized variable" warning. This can
+ # easily happen when using option groups--although
+ # properly-written code won't actually use the variable,
+ # the variable does get passed in to the _impl. (Ah, if
+ # only dataflow analysis could inline the static function!)
+ #
+ # This value is specified as a string.
+ # Every non-abstract subclass should supply a valid value.
+ c_ignored_default = 'NULL'
+
# The C converter *function* to be used, if any.
# (If this is not None, format_unit must be 'O&'.)
converter = None
parameter is a clinic.Parameter instance.
data is a CRenderData instance.
"""
+ self.parameter = parameter
name = ensure_legal_c_identifier(self.name)
# declarations
The C statement to declare this variable.
"""
declaration = [self.simple_declaration()]
- if self.c_default:
+ default = self.c_default
+ if not default and self.parameter.group:
+ default = self.c_ignored_default
+ if default:
declaration.append(" = ")
- declaration.append(self.c_default)
+ declaration.append(default)
declaration.append(";")
return "".join(declaration)
class bool_converter(CConverter):
type = 'int'
format_unit = 'p'
+ c_ignored_default = '0'
def converter_init(self):
self.default = bool(self.default)
class char_converter(CConverter):
type = 'char'
format_unit = 'c'
+ c_ignored_default = "'\0'"
@add_legacy_c_converter('B', bitwise=True)
class byte_converter(CConverter):
type = 'byte'
format_unit = 'b'
+ c_ignored_default = "'\0'"
def converter_init(self, *, bitwise=False):
if bitwise:
class short_converter(CConverter):
type = 'short'
format_unit = 'h'
+ c_ignored_default = "0"
class unsigned_short_converter(CConverter):
type = 'unsigned short'
format_unit = 'H'
+ c_ignored_default = "0"
def converter_init(self, *, bitwise=False):
if not bitwise:
class int_converter(CConverter):
type = 'int'
format_unit = 'i'
+ c_ignored_default = "0"
def converter_init(self, *, from_str=False):
if from_str:
class unsigned_int_converter(CConverter):
type = 'unsigned int'
format_unit = 'I'
+ c_ignored_default = "0"
def converter_init(self, *, bitwise=False):
if not bitwise:
class long_converter(CConverter):
type = 'long'
format_unit = 'l'
+ c_ignored_default = "0"
class unsigned_long_converter(CConverter):
type = 'unsigned long'
format_unit = 'k'
+ c_ignored_default = "0"
def converter_init(self, *, bitwise=False):
if not bitwise:
class PY_LONG_LONG_converter(CConverter):
type = 'PY_LONG_LONG'
format_unit = 'L'
+ c_ignored_default = "0"
class unsigned_PY_LONG_LONG_converter(CConverter):
type = 'unsigned PY_LONG_LONG'
format_unit = 'K'
+ c_ignored_default = "0"
def converter_init(self, *, bitwise=False):
if not bitwise:
class Py_ssize_t_converter(CConverter):
type = 'Py_ssize_t'
format_unit = 'n'
+ c_ignored_default = "0"
class float_converter(CConverter):
type = 'float'
format_unit = 'f'
+ c_ignored_default = "0.0"
class double_converter(CConverter):
type = 'double'
format_unit = 'd'
+ c_ignored_default = "0.0"
class Py_complex_converter(CConverter):
type = 'Py_complex'
format_unit = 'D'
+ c_ignored_default = "{0.0, 0.0}"
class object_converter(CConverter):
type = 'Py_buffer'
format_unit = 'y*'
impl_by_reference = True
+ c_ignored_default = "{NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL}"
def converter_init(self, *, str=False, zeroes=False, nullable=False, read_write=False):
if not str: