- Key = (Target, Toolchain)\r
- if Key not in Class._CACHE_ or Arch not in Class._CACHE_[Key] \\r
- or MetaFile not in Class._CACHE_[Key][Arch]:\r
- AutoGenObject = super(AutoGen, Class).__new__(Class)\r
- # call real constructor\r
- if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
- return None\r
- if Key not in Class._CACHE_:\r
- Class._CACHE_[Key] = {}\r
- if Arch not in Class._CACHE_[Key]:\r
- Class._CACHE_[Key][Arch] = {}\r
- Class._CACHE_[Key][Arch][MetaFile] = AutoGenObject\r
- else:\r
- AutoGenObject = Class._CACHE_[Key][Arch][MetaFile]\r
+ Key = (Target, Toolchain, Arch, MetaFile)\r
+ try:\r
+ # if it exists, just return it directly\r
+ return cls.__ObjectCache[Key]\r
+ except:\r
+ # it didnt exist. create it, cache it, then return it\r
+ cls.__ObjectCache[Key] = super(AutoGen, cls).__new__(cls)\r
+ return cls.__ObjectCache[Key]\r