Skip to content

Commit

Permalink
WIP on converting Ti.Blob to new style proxy
Browse files Browse the repository at this point in the history
- most of the Ti.Blob suite passes now (#toString() override doesn't work)
- need to adapt older proxies to handle new TiBlob as argument
  • Loading branch information
sgtcoolguy committed Oct 31, 2018
1 parent 0d8541c commit a695e7e
Show file tree
Hide file tree
Showing 37 changed files with 221 additions and 228 deletions.
5 changes: 3 additions & 2 deletions iphone/Classes/FilesystemModule.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2015 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand All @@ -12,6 +12,7 @@
#import <TitaniumKit/TiFilesystemFileProxy.h>
#import <TitaniumKit/TiFilesystemFileStreamProxy.h>
#import <TitaniumKit/TiHost.h>
#import <TitaniumKit/TiBlob.h>

@implementation FilesystemModule

Expand Down Expand Up @@ -206,7 +207,7 @@ - (id)getAsset:(id)args
RELEASE_TO_NIL(sha)
}
}
return [[[TiBlob alloc] _initWithPageContext:[self executionContext] andImage:image] autorelease];
return [[[TiBlob alloc] initWithImage:image] autorelease];
}
return [NSNull null];
}
Expand Down
15 changes: 7 additions & 8 deletions iphone/Classes/MediaModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ - (void)takeScreenshot:(id)arg

UIGraphicsEndImageContext();

TiBlob *blob = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
TiBlob *blob = [[[TiBlob alloc] initWithImage:image] autorelease];
NSDictionary *event = [NSDictionary dictionaryWithObject:blob forKey:@"media"];
[self _fireEventToListener:@"screenshot" withObject:event listener:arg thisObject:nil];
}
Expand Down Expand Up @@ -1713,7 +1713,7 @@ - (void)showPicker:(NSDictionary *)args isCamera:(BOOL)isCamera
- (void)saveCompletedForImage:(UIImage *)image error:(NSError *)error contextInfo:(void *)contextInfo
{
NSDictionary *saveCallbacks = (NSDictionary *)contextInfo;
TiBlob *blob = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
TiBlob *blob = [[[TiBlob alloc] initWithImage:image] autorelease];

if (error != nil) {
KrollCallback *errorCallback = [saveCallbacks objectForKey:@"error"];
Expand Down Expand Up @@ -1761,7 +1761,7 @@ - (void)saveCompletedForVideo:(NSString *)path error:(NSError *)error contextInf
#if defined(USE_TI_MEDIASHOWCAMERA) || defined(USE_TI_MEDIAOPENPHOTOGALLERY) || defined(USE_TI_MEDIASTARTVIDEOEDITING)
- (void)handleTrimmedVideo:(NSURL *)theURL withDictionary:(NSDictionary *)dictionary
{
TiBlob *media = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andFile:[theURL path]] autorelease];
TiBlob *media = [[[TiBlob alloc] initWithFile:[theURL path]] autorelease];
NSMutableDictionary *eventDict = [NSMutableDictionary dictionaryWithDictionary:dictionary];
[eventDict setObject:media forKey:@"media"];
if (saveToRoll) {
Expand Down Expand Up @@ -1859,7 +1859,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker_ didFinishPickin
if (isVideo) {

UIImage *thumbnailImage = [editingInfo objectForKey:UIImagePickerControllerOriginalImage];
thumbnail = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:thumbnailImage] autorelease];
thumbnail = [[[TiBlob alloc] initWithImage:thumbnailImage] autorelease];

if (picker.allowsEditing) {
NSNumber *startTime = [editingInfo objectForKey:@"_UIImagePickerControllerVideoEditingStart"];
Expand Down Expand Up @@ -1906,7 +1906,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker_ didFinishPickin
}
}

media = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andFile:[mediaURL path]] autorelease];
media = [[[TiBlob alloc] initWithFile:[mediaURL path]] autorelease];
if ([media mimeType] == nil) {
[media setMimeType:@"video/mpeg" type:TiBlobTypeFile];
}
Expand All @@ -1918,7 +1918,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker_ didFinishPickin
UIImage *editedImage = [editingInfo objectForKey:UIImagePickerControllerEditedImage];
if ((mediaURL != nil) && (editedImage == nil)) {

media = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andFile:[mediaURL path]] autorelease];
media = [[[TiBlob alloc] initWithFile:[mediaURL path]] autorelease];
[media setMimeType:@"image/jpeg" type:TiBlobTypeFile];

if (saveToRoll) {
Expand Down Expand Up @@ -1969,8 +1969,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker_ didFinishPickin
resultImage = [TiUtils adjustRotation:editedImage ?: originalImage];
}

media = [[[TiBlob alloc] _initWithPageContext:[self pageContext]] autorelease];
[media setImage:resultImage];
media = [[[TiBlob alloc] initWithImage:resultImage] autorelease];

if (saveToRoll) {
UIImageWriteToSavedPhotosAlbum(resultImage, nil, nil, NULL);
Expand Down
3 changes: 1 addition & 2 deletions iphone/Classes/NetworkModule.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2014 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
Expand All @@ -11,7 +11,6 @@
#import "TiNetworkCookieProxy.h"
#import "TiNetworkSocketProxy.h"
#import <TitaniumKit/TiApp.h>
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiUtils.h>

NSString *const INADDR_ANY_token = @"INADDR_ANY";
Expand Down
3 changes: 2 additions & 1 deletion iphone/Classes/TiAppiOSSearchableItemAttributeSetProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#if defined(USE_TI_APPIOSSEARCHQUERY) || defined(USE_TI_APPIOSSEARCHABLEITEMATTRIBUTESET)
#import "TiAppiOSSearchableItemAttributeSetProxy.h"
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiUtils.h>

@implementation TiAppiOSSearchableItemAttributeSetProxy
Expand Down Expand Up @@ -145,7 +146,7 @@ - (void)setThumbnailURL:(id)value
//Optional image data for thumbnail for this item
- (TiBlob *)thumbnailData
{
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andData:_attributes.thumbnailData mimetype:_attributes.contentType] autorelease];
return [[[TiBlob alloc] initWithData:_attributes.thumbnailData mimetype:_attributes.contentType] autorelease];
}

- (void)setThumbnailData:(id)value
Expand Down
1 change: 0 additions & 1 deletion iphone/Classes/TiCalendarAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "TiCalendarAlert.h"
#import "TiCalendarEvent.h"
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiUtils.h>

@implementation TiCalendarAlert
Expand Down
1 change: 0 additions & 1 deletion iphone/Classes/TiCalendarCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "TiCalendarAlert.h"
#import "TiCalendarEvent.h"
#import "TiCalendarRecurrenceRule.h"
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiUtils.h>

#pragma mark -
Expand Down
1 change: 0 additions & 1 deletion iphone/Classes/TiCalendarRecurrenceRule.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#ifdef USE_TI_CALENDAR

#import "TiCalendarCalendar.h"
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiUtils.h>

#import "TiCalendarRecurrenceRule.h"
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiContactsPerson.m
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ - (TiBlob *)image
}

if (person.imageDataAvailable) {
TiBlob *imageBlob = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:[UIImage imageWithData:person.imageData]] autorelease];
TiBlob *imageBlob = [[[TiBlob alloc] initWithImage:[UIImage imageWithData:person.imageData]] autorelease];
return imageBlob;
}

Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiDatabaseResultSetProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ - (id)field:(id)args
if (results != nil) {
id result = [results objectForColumnIndex:[TiUtils intValue:[args objectAtIndex:0]]];
if ([result isKindOfClass:[NSData class]]) {
result = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andData:result mimetype:@"application/octet-stream"] autorelease];
result = [[[TiBlob alloc] initWithData:result mimetype:@"application/octet-stream"] autorelease];
}

if ([args count] > 1) {
Expand All @@ -163,7 +163,7 @@ - (id)fieldByName:(id)args
if (results != nil) {
id result = [results objectForColumn:[TiUtils stringValue:[args objectAtIndex:0]]];
if ([result isKindOfClass:[NSData class]]) {
result = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andData:result mimetype:@"application/octet-stream"] autorelease];
result = [[[TiBlob alloc] initWithData:result mimetype:@"application/octet-stream"] autorelease];
}
if ([args count] > 1) {
//cast result on the way out if type constant was passed
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiFilesystemBlobProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ - (id)rename:(id)args
return NUMBOOL(NO);
}

- (id)read:(id)args
- (TiBlob *)read:(id)args
{
NSString *mimetype = [Mimetypes mimeTypeForExtension:[[url path] lastPathComponent]];
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andData:data mimetype:mimetype] autorelease];
return [[[TiBlob alloc] initWithData:data mimetype:mimetype] autorelease];
}

- (id)append:(id)args
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiMediaItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
// FIXME: Forward declare
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiProxy.h>

Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiMediaItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ - (TiBlob *)artwork
{
MPMediaItemArtwork *artwork = [item artwork];
if (artwork != nil) {
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:[artwork imageWithSize:[artwork imageCropRect].size]] autorelease];
return [[[TiBlob alloc] initWithImage:[artwork imageWithSize:[artwork imageCropRect].size]] autorelease];
}
return nil;
}
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiMediaVideoPlayerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ - (void)requestThumbnailImagesAtTimes:(id)args

if (error == nil) {
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
TiBlob *blob = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
TiBlob *blob = [[[TiBlob alloc] initWithImage:image] autorelease];
[event setObject:blob forKey:@"image"];
[image release];
[event setObject:NUMDOUBLE(actualTime.value / actualTime.timescale) forKey:@"time"];
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiNetworkHTTPClientProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import "TiDOMDocumentProxy.h"
#import <TitaniumKit/APSHTTPClient.h>
// FIXME: Forward declare
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiProxy.h>

Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiNetworkHTTPClientProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,10 @@ - (TiBlob *)responseData
{
TiBlob *blob;
if ([[self response] saveToFile]) {
blob = [[TiBlob alloc] _initWithPageContext:[self executionContext] andFile:[[self response] filePath]];
blob = [[TiBlob alloc] initWithFile:[[self response] filePath]];
} else {
NSString *contentType = [TiUtils stringValue:[[self responseHeaders] valueForKey:@"Content-Type"]];
blob = [[TiBlob alloc] _initWithPageContext:[self executionContext] andData:[[self response] responseData] mimetype:contentType];
blob = [[TiBlob alloc] initWithData:[[self response] responseData] mimetype:contentType];
}
return [blob autorelease];
}
Expand Down
1 change: 0 additions & 1 deletion iphone/Classes/TiNetworkSocketTCPProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifdef USE_TI_NETWORKSOCKET
#import "TiNetworkSocketTCPProxy.h"
#import "NetworkModule.h"
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiBuffer.h>

static NSString *SOCK_KEY = @"socket";
Expand Down
1 change: 0 additions & 1 deletion iphone/Classes/TiNetworkTCPSocketProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "NetworkModule.h"
#import <Foundation/Foundation.h>
#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiProxy.h>

@interface TiNetworkTCPSocketProxy : TiProxy {
Expand Down
5 changes: 3 additions & 2 deletions iphone/Classes/TiNetworkTCPSocketProxy.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Copyright (c) 2009-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#ifdef USE_TI_NETWORK

#import "TiNetworkTCPSocketProxy.h"
#import <TitaniumKit/TiBlob.h>

#include <CFNetwork/CFSocketStream.h>
#import <netdb.h>
Expand Down Expand Up @@ -277,7 +278,7 @@ - (void)readFromStream:(NSInputStream *)input
free(buffer);
}

TiBlob *dataBlob = [[[TiBlob alloc] _initWithPageContext:[self executionContext] andData:data mimetype:@"application/octet-stream"] autorelease];
TiBlob *dataBlob = [[[TiBlob alloc] initWithData:data mimetype:@"application/octet-stream"] autorelease];
[self fireEvent:@"read"
withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:remoteSocket], @"from",
dataBlob, @"data",
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiUIClipboardProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ - (id)getData_:(NSString *)mimeType
case CLIPBOARD_IMAGE: {
UIImage *image = board.image;
if (image) {
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
return [[[TiBlob alloc] initWithImage:image] autorelease];
} else {
return nil;
}
Expand All @@ -209,7 +209,7 @@ - (id)getData_:(NSString *)mimeType
NSData *data = [board dataForPasteboardType:mimeTypeToUTType(mimeType)];

if (data) {
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andData:data mimetype:mimeType] autorelease];
return [[[TiBlob alloc] initWithData:data mimetype:mimeType] autorelease];
} else {
return nil;
}
Expand Down
4 changes: 2 additions & 2 deletions iphone/Classes/TiUIImageViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ - (id)toBlob:(id)args
UIImage *image = [[ImageLoader sharedLoader] loadImmediateImage:url_];

if (image != nil) {
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
return [[[TiBlob alloc] initWithImage:image] autorelease];
}

// we're on the non-UI thread, we need to block to load

image = [[ImageLoader sharedLoader] loadRemote:url_];
return [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image] autorelease];
return [[[TiBlob alloc] initWithImage:image] autorelease];
}
return nil;
}
Expand Down
1 change: 0 additions & 1 deletion iphone/Classes/TiUIWebViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
#ifdef USE_TI_UIWEBVIEW

#import <TitaniumKit/TiBlob.h>
#import <TitaniumKit/TiHost.h>
#import <TitaniumKit/TiUtils.h>

Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIiOSDocumentViewerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (id)icons
NSMutableArray *result = [NSMutableArray array];

for (UIImage *image in [self controller].icons) {
TiBlob *blob = [[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:image];
TiBlob *blob = [[TiBlob alloc] initWithImage:image];
[result addObject:image];
[blob release];
}
Expand Down
6 changes: 5 additions & 1 deletion iphone/Classes/TiUIiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
#import "TiUIiOSApplicationShortcutsProxy.h"
#endif

#ifdef USE_TI_UIIOSLIVEPHOTOBADGE
#import <TitaniumKit/TiBlob.h>
#endif

#if defined(USE_TI_UIIOSLIVEPHOTOBADGE) || defined(USE_TI_UIIOSLIVEPHOTOVIEW)
#import <PhotosUI/PhotosUI.h>
#endif
Expand Down Expand Up @@ -590,7 +594,7 @@ - (TiBlob *)createLivePhotoBadge:(id)value
return nil;
}

TiBlob *image = [[[TiBlob alloc] _initWithPageContext:[self pageContext] andImage:badge] autorelease];
TiBlob *image = [[[TiBlob alloc] initWithImage:badge] autorelease];

return image;
}
Expand Down
9 changes: 4 additions & 5 deletions iphone/Classes/UtilsModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#import <TitaniumKit/ObjcProxy.h>

// uncomment once we start returning TiBlob*
// @class TiBlob; // forward declare
@class TiBlob; // forward declare

@protocol UtilsExports <JSExport>

// TODO: Change from JSValue * to id argument once TiFile/TiBlob have been migrated to obj-c proxies
// TODO: Change JSValue* return value to TiBlob* once TiBlob has been migrated to obj-c proxy
- (JSValue *)base64decode:(JSValue *)obj;
- (JSValue *)base64encode:(JSValue *)obj;
// TODO: Change from JSValue * to id argument once TiFile has been migrated to obj-c proxies
- (TiBlob *)base64decode:(JSValue *)obj;
- (TiBlob *)base64encode:(JSValue *)obj;
- (NSString *)md5HexDigest:(JSValue *)obj;
- (NSString *)sha1:(JSValue *)obj;
- (NSString *)sha256:(JSValue *)obj;
Expand Down

0 comments on commit a695e7e

Please sign in to comment.