mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	- Allow access to poperties of the "application" OSA class directly from
the toplevel package. This already worked for elements, but now for properties too. Fixes #753925. - Even better, the toplevel class (such as Finder.Finder) now inherits the element and property dictionaries of its application class and has the necessary glue to allow you to say f = Finder.Finder() f.get(f.name)
This commit is contained in:
		
							parent
							
								
									fdbe5223b7
								
							
						
					
					
						commit
						c8882b10c4
					
				
					 2 changed files with 25 additions and 3 deletions
				
			
		|  | @ -154,7 +154,7 @@ def __ensure_WMAvailable(klass): | |||
|         Evt.WaitNextEvent(0,0) | ||||
|         return 1 | ||||
|     __ensure_WMAvailable = classmethod(__ensure_WMAvailable) | ||||
| 
 | ||||
|      | ||||
|     def __init__(self, signature=None, start=0, timeout=0): | ||||
|         """Create a communication channel with a particular application. | ||||
|          | ||||
|  | @ -284,6 +284,18 @@ def _set(self, _object, _attributes={}, **_arguments): | |||
|              | ||||
|     set = _set | ||||
| 
 | ||||
| 	# Magic glue to allow suite-generated classes to function somewhat | ||||
| 	# like the "application" class in OSA. | ||||
| 	 | ||||
|     def __getattr__(self, name): | ||||
|         if self._elemdict.has_key(name): | ||||
|             cls = self._elemdict[name] | ||||
|             return DelayedComponentItem(cls, None) | ||||
|         if self._propdict.has_key(name): | ||||
|             cls = self._propdict[name] | ||||
|             return cls() | ||||
|         raise AttributeError, name | ||||
|          | ||||
| # Tiny Finder class, for local use only | ||||
| 
 | ||||
| class _miniFinder(TalkTo): | ||||
|  |  | |||
|  | @ -523,14 +523,18 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None, | |||
|                 fp.write("getbaseclasses(%s)\n" % v) | ||||
| 
 | ||||
|     # Generate a code-to-name mapper for all of the types (classes) declared in this module | ||||
|     application_class = None | ||||
|     if allprecompinfo: | ||||
|         fp.write("\n#\n# Indices of types declared in this module\n#\n") | ||||
|         fp.write("_classdeclarations = {\n") | ||||
|         for codenamemapper in allprecompinfo: | ||||
|             for k, v in codenamemapper.getall('class'): | ||||
|                 fp.write("    %s : %s,\n" % (`k`, v)) | ||||
|             if k == 'capp': | ||||
|                 application_class = v | ||||
|         fp.write("}\n") | ||||
| 
 | ||||
|      | ||||
|     if suitelist: | ||||
|         fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1])) | ||||
|         for code, modname in suitelist[1:]: | ||||
|  | @ -538,6 +542,9 @@ def compileaete(aete, resinfo, fname, output=None, basepkgname=None, | |||
|         fp.write(",\n        aetools.TalkTo):\n") | ||||
|         fp.write("    _signature = %s\n\n"%`creatorsignature`) | ||||
|         fp.write("    _moduleName = '%s'\n\n"%packagename) | ||||
|         if application_class: | ||||
|             fp.write("    _elemdict = %s._elemdict\n" % application_class) | ||||
|             fp.write("    _propdict = %s._propdict\n" % application_class) | ||||
|     fp.close() | ||||
| 
 | ||||
| class SuiteCompiler: | ||||
|  | @ -966,14 +973,15 @@ def compileclass(self, cls): | |||
|                 self.fp.write('    """%s - %s """\n' % (ascii(name), ascii(desc))) | ||||
|                 self.fp.write('    want = %s\n' % `code`) | ||||
|         self.namemappers[0].addnamecode('class', pname, code) | ||||
|         is_application_class = (code == 'capp') | ||||
|         properties.sort() | ||||
|         for prop in properties: | ||||
|             self.compileproperty(prop) | ||||
|             self.compileproperty(prop, is_application_class) | ||||
|         elements.sort() | ||||
|         for elem in elements: | ||||
|             self.compileelement(elem) | ||||
|      | ||||
|     def compileproperty(self, prop): | ||||
|     def compileproperty(self, prop, is_application_class=False): | ||||
|         [name, code, what] = prop | ||||
|         if code == 'c@#!': | ||||
|             # Something silly with plurals. Skip it. | ||||
|  | @ -993,6 +1001,8 @@ def compileproperty(self, prop): | |||
|                 self.fp.write("    which = %s\n" % `code`) | ||||
|                 self.fp.write("    want = %s\n" % `what[0]`) | ||||
|         self.namemappers[0].addnamecode('property', pname, code) | ||||
|         if is_application_class and self.fp: | ||||
|             self.fp.write("%s = _Prop_%s()\n" % (pname, pname)) | ||||
|      | ||||
|     def compileelement(self, elem): | ||||
|         [code, keyform] = elem | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jack Jansen
						Jack Jansen