1.1 --- a/micropython/common.py Tue Jun 05 01:25:35 2012 +0200
1.2 +++ b/micropython/common.py Tue Jun 05 01:29:39 2012 +0200
1.3 @@ -344,23 +344,33 @@
1.4
1.5 return hasattr(node, "unit") and node.unit.parent.has_key(node.unit.name)
1.6
1.7 -def get_object_types_for_usage(usage, objtable, name, unit_name):
1.8 +def get_object_types_for_usage(usage, objtable, name, unit_name, all_attributes):
1.9
1.10 """
1.11 Return for the given attribute 'usage', using the 'objtable', the object
1.12 types which satisfy such usage, reporting any problems for the given 'name'
1.13 and 'unit_name'. Each object type is given as a tuple of the form (type,
1.14 is_static).
1.15 +
1.16 + Where 'all_attributes' is set to a true value, all attributes in a usage
1.17 + list must be matched to provide object types. Otherwise, the presence of any
1.18 + attribute from a usage list in a type's set of attributes will be enough to
1.19 + provide that type as a suitable object type.
1.20 """
1.21
1.22 all_objtypes = set()
1.23
1.24 for attrnames in usage:
1.25 attrnames = attrnames or ()
1.26 - objtypes = objtable.all_possible_objects_plus_status(attrnames)
1.27 - if not objtypes:
1.28 - print >>sys.stderr, "Warning: usage in %r for %r finds no object supporting all attributes %r" % (
1.29 - unit_name, name, attrnames.keys())
1.30 +
1.31 + # Determine whether all attributes are required.
1.32 +
1.33 + if all_attributes:
1.34 + objtypes = objtable.all_possible_objects_plus_status(attrnames)
1.35 + if not objtypes:
1.36 + print >>sys.stderr, "Warning: usage in %r for %r finds no object supporting all attributes %r" % (
1.37 + unit_name, name, attrnames.keys())
1.38 + else:
1.39 objtypes = objtable.any_possible_objects_plus_status(attrnames)
1.40 if not objtypes:
1.41 print >>sys.stderr, "Warning: usage in %r for %r finds no object supporting any attributes %r" % (