1.1 --- a/generator.py Tue Dec 13 23:26:33 2016 +0100
1.2 +++ b/generator.py Tue Dec 13 23:28:09 2016 +0100
1.3 @@ -56,8 +56,12 @@
1.4 # NOTE: These must be synchronised with the library.
1.5
1.6 function_type = "__builtins__.core.function"
1.7 + none_type = "__builtins__.none.NoneType"
1.8 string_type = "__builtins__.str.string"
1.9 type_type = "__builtins__.core.type"
1.10 + unicode_type = "__builtins__.unicode.utf8string"
1.11 +
1.12 + none_value = "__builtins__.none.None"
1.13
1.14 predefined_constant_members = (
1.15 ("__builtins__.boolean", "False"),
1.16 @@ -494,6 +498,11 @@
1.17 else:
1.18 attrs["__key__"] = None
1.19
1.20 + # Define Unicode constant encoding details.
1.21 +
1.22 + if cls == self.unicode_type:
1.23 + attrs["encoding"] = Reference("<instance>", self.none_type)
1.24 +
1.25 # Define the structure details. An object is created for the constant,
1.26 # but an attribute is provided, referring to the object, for access to
1.27 # the constant in the program.
1.28 @@ -933,7 +942,13 @@
1.29 constant_value = "__const%d" % constant_number
1.30 return "%s /* %s */" % (constant_value, name)
1.31
1.32 - # Predefined constant references.
1.33 + # Usage of predefined constants, currently only None supported.
1.34 +
1.35 + if kind == "<instance>" and origin == self.none_type:
1.36 + attr_path = encode_predefined_reference(self.none_value)
1.37 + return "{&%s, &%s} /* %s */" % (attr_path, attr_path, name)
1.38 +
1.39 + # Predefined constant members.
1.40
1.41 if (path, name) in self.predefined_constant_members:
1.42 attr_path = encode_predefined_reference("%s.%s" % (path, name))