# HG changeset patch # User Paul Boddie # Date 1477863202 -3600 # Node ID 6bb416f1c55048661a55770eecf7eb1e9076fe6d # Parent 950b6015806195b949fa1e8f0872794215309cf1 Renamed the bool module to boolean, simplifying class naming rules again. diff -r 950b60158061 -r 6bb416f1c550 generator.py --- a/generator.py Sun Oct 30 22:17:00 2016 +0100 +++ b/generator.py Sun Oct 30 22:33:22 2016 +0100 @@ -52,9 +52,11 @@ function_type = "__builtins__.core.function" + # NOTE: These must be synchronised with the library. + predefined_constant_members = ( - ("__builtins__.bool", "False"), - ("__builtins__.bool", "True"), + ("__builtins__.boolean", "False"), + ("__builtins__.boolean", "True"), ("__builtins__.none", "None"), ("__builtins__.notimplemented", "NotImplemented"), ) diff -r 950b60158061 -r 6bb416f1c550 lib/__builtins__/__init__.py --- a/lib/__builtins__/__init__.py Sun Oct 30 22:17:00 2016 +0100 +++ b/lib/__builtins__/__init__.py Sun Oct 30 22:33:22 2016 +0100 @@ -73,7 +73,7 @@ # Classes. -from __builtins__.bool import bool, False, True +from __builtins__.boolean import bool, False, True from __builtins__.buffer import buffer from __builtins__.complex import complex from __builtins__.dict import dict diff -r 950b60158061 -r 6bb416f1c550 lib/__builtins__/bool.py --- a/lib/__builtins__/bool.py Sun Oct 30 22:17:00 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#!/usr/bin/env python - -""" -Boolean objects. - -Copyright (C) 2015, 2016 Paul Boddie - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; either version 3 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see . -""" - -class boolean(object): - def __bool__(self): - "Identity operation." - return self - def __str__(self): - return self is True and "True" or "False" - -False = boolean() -True = boolean() - -def bool(obj): - return obj.__bool__() - -# vim: tabstop=4 expandtab shiftwidth=4 diff -r 950b60158061 -r 6bb416f1c550 lib/__builtins__/boolean.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/__builtins__/boolean.py Sun Oct 30 22:33:22 2016 +0100 @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +""" +Boolean objects. + +Copyright (C) 2015, 2016 Paul Boddie + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +""" + +class boolean(object): + def __bool__(self): + "Identity operation." + return self + def __str__(self): + return self is True and "True" or "False" + +False = boolean() +True = boolean() + +def bool(obj): + return obj.__bool__() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 950b60158061 -r 6bb416f1c550 modules.py --- a/modules.py Sun Oct 30 22:17:00 2016 +0100 +++ b/modules.py Sun Oct 30 22:33:22 2016 +0100 @@ -302,7 +302,7 @@ module_name = "__builtins__.%s" % name if self.name != module_name: self.queue_module(module_name, True) - return Reference("", "__builtins__.%s.%s" % (name, name == "bool" and "boolean" or name)) + return Reference("", "__builtins__.%s.%s" % (name, name)) def get_object(self, path, defer=True): diff -r 950b60158061 -r 6bb416f1c550 templates/progops.c --- a/templates/progops.c Sun Oct 30 22:17:00 2016 +0100 +++ b/templates/progops.c Sun Oct 30 22:33:22 2016 +0100 @@ -125,5 +125,5 @@ int __BOOL(__attr attr) { - return attr.value == __builtins___bool_True.value; + return attr.value == __builtins___boolean_True.value; } diff -r 950b60158061 -r 6bb416f1c550 translator.py --- a/translator.py Sun Oct 30 22:17:00 2016 +0100 +++ b/translator.py Sun Oct 30 22:33:22 2016 +0100 @@ -178,7 +178,7 @@ def __str__(self): if self.value in ("False", "True"): - return encode_path("__builtins__.bool.%s" % self.value) + return encode_path("__builtins__.boolean.%s" % self.value) elif self.value == "None": return encode_path("__builtins__.none.%s" % self.value) elif self.value == "NotImplemented": @@ -287,7 +287,7 @@ # NOTE: This makes assumptions about the __builtins__ structure. - return self.importer.get_object("__builtins__.%s.%s" % (name, name == "bool" and "boolean" or name)) + return self.importer.get_object("__builtins__.%s.%s" % (name, name)) def is_method(self, path):