Lichen

Change of generator.py

929:bbcea70e1cde
generator.py
     1.1 --- a/generator.py	Sun Jun 27 22:10:02 2021 +0200
     1.2 +++ b/generator.py	Sun Jun 27 22:12:23 2021 +0200
     1.3 @@ -1200,18 +1200,36 @@
     1.4          for name in parameters:
     1.5              l.append("__attr %s" % name)
     1.6  
     1.7 -        print >>f_code, """\
     1.8 +        # Special-case the integer type.
     1.9 +
    1.10 +        if path == self.int_type:
    1.11 +            print >>f_code, """\
    1.12 +__attr %s(__attr __self, __attr number_or_string)
    1.13 +{
    1.14 +    if (!__BOOL(__fn_native_int_is_int(__self, number_or_string)))
    1.15 +        __raise_value_error(number_or_string);
    1.16 +
    1.17 +    return number_or_string;
    1.18 +}
    1.19 +""" % (
    1.20 +                encode_instantiator_pointer(path),
    1.21 +                )
    1.22 +
    1.23 +        # Generic instantiation support.
    1.24 +
    1.25 +        else:
    1.26 +            print >>f_code, """\
    1.27  __attr %s(__attr __self%s)
    1.28  {
    1.29      return %s(__NEWINSTANCE(%s)%s);
    1.30  }
    1.31  """ % (
    1.32 -            encode_instantiator_pointer(path),
    1.33 -            l and ", %s" % ",".join(l) or "",
    1.34 -            encode_function_pointer(initialiser),
    1.35 -            encode_path(path),
    1.36 -            parameters and ", %s" % ", ".join(parameters) or ""
    1.37 -            )
    1.38 +                encode_instantiator_pointer(path),
    1.39 +                l and ", %s" % ",".join(l) or "",
    1.40 +                encode_function_pointer(initialiser),
    1.41 +                encode_path(path),
    1.42 +                parameters and ", %s" % ", ".join(parameters) or ""
    1.43 +                )
    1.44  
    1.45          # Signature: __new_typename(__attr __self, ...)
    1.46