[pygccxml-commit] source/pyplusplus/decl_wrappers mdecl_wrapper.py,NONE,1.1
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman <rom...@us...> - 2006-03-06 05:02:43
|
Update of /cvsroot/pygccxml/source/pyplusplus/decl_wrappers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8117/pyplusplus/decl_wrappers Added Files: mdecl_wrapper.py Log Message: I created new multiple declarations class. --- NEW FILE: mdecl_wrapper.py --- # Copyright 2004 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) class call_redirector_t( object ): def __init__( self, name, decls ): object.__init__( self ) self.name = name self.decls = decls def __call__( self, *arguments, **keywords ): for d in self.decls: callable = getattr(d, self.name) callable( *arguments, **keywords ) class mdecl_wrapper_t( object ): def __init__( self, decls ): object.__init__( self ) self.__dict__['_decls'] = decls def __len__( self ): return len( self._decls ) def __getitem__( self, index ): return self._decls[index] def __ensure_attribute( self, name ): invalid_decls = filter( lambda d: not hasattr( d, name ), self._decls ) if invalid_decls: raise RuntimeError( "Not all declarations have '%s' attribute." % name ) def __setattr__( self, name, value ): self.__ensure_attribute( name ) for d in self._decls: setattr( d, name, value ) def __getattr__( self, name ): return call_redirector_t( name, self._decls ) |