-MSInstanceMessage2(UIImageTableArtwork *, UIImageTableArtwork, initWithName,inBundle, NSString *, name, NSBundle *, bundle) {
- if ((self = MSOldCall(name, bundle)) != nil) {
- $objc_setAssociatedObject(self, @selector(wb$bundle), bundle, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- } return self;
-}
-
-MSInstanceMessage2(UIImage *, UIImageTableArtwork, imageNamed,device, NSString *, name, int, device) {
- NSBundle *bundle($objc_getAssociatedObject(self, @selector(wb$bundle)));
- if (Debug_)
- NSLog(@"WB:Debug:[UIImageTableArtwork[%@] imageNamed:\"%@\" device:%i]", bundle, name, device);
- if (bundle == nil)
- return MSOldCall(name, device);
- UIImage *image = [UIImages_ objectForKey:name];
- if (image != nil)
- return reinterpret_cast<id>(image) == [NSNull null] ? MSOldCall(name, device) : image;
- if (NSString *path = $pathForFile$inBundle$(name, bundle, true, true))
- image = $getImage$(path);
- [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:name];
- if (image != nil)
- return image;
-
- image = MSOldCall(name, device);
-
- if (UIDebug_) {
+template <typename Original_>
+static UIImage *WBCacheUIImage(const Original_ &original, NSString *name, NSString *key) {
+ UIImage *image(WBCacheImage(original, [=](){ return $pathForFile$inBundle$(name, _UIKitBundle(), true, true); }, key));
+ if (image != nil && UIDebug_) {