Skip to content

Commit

Permalink
Some fixes to compile in OS X and iOS standalone targets.
Browse files Browse the repository at this point in the history
Recover libxml headers in OS X target. While including libffi as Cocoapod I
must have forgot to include this back in the OS X target (it is there in the
iOS target).

A couple of imports to avoid warnings and to correctly compile in iOS.

Marking the temporal allocations array of the closure as unused and with
precise lifetime. The unused is necessary to avoid a warning, the precise
lifetime might not be necessary, but I fear the optimizer might optimize the
variable away and break everything.

(appsquickly#102)
  • Loading branch information
drodriguez committed Dec 4, 2013
1 parent 9cb0b02 commit d2cb6a1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#import "TyphoonAssistedFactoryMethodCreator.h"

@class TyphoonAssistedFactoryMethodBlock;
#import "TyphoonAssistedFactoryMethodBlock.h"


@interface TyphoonAssistedFactoryMethodBlockCreator : TyphoonAssistedFactoryMethodCreator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
#import "TyphoonAssistedFactoryMethodClosure.h"

#include <ffi.h>
#include <objc/message.h>

#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#endif

#import "TyphoonAssistedFactoryMethodInitializer.h"
#import "TyphoonAssistedFactoryParameterInjectedWithArgumentIndex.h"
Expand All @@ -35,7 +40,7 @@ static void FactoryMethodClosure(ffi_cif *cif, void *ret, void **args, void *use
TyphoonAssistedFactoryMethodClosure *closure = (__bridge TyphoonAssistedFactoryMethodClosure *)userdata;

void **arguments = calloc(closure->_parameters.count + 2, sizeof(void *));
NSArray *tempAllocations = [closure prepareArgumentsWithValues:args into:arguments];
__unused __attribute__((objc_precise_lifetime)) NSArray *tempAllocations = [closure prepareArgumentsWithValues:args into:arguments];
ffi_call(&(closure->_initCIF), FFI_FN(objc_msgSend), ret, arguments);
free(arguments);
tempAllocations = nil;
Expand Down
8 changes: 8 additions & 0 deletions Typhoon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Source/Typhoon.pch;
HEADER_SEARCH_PATHS = "${SDKROOT}/usr/include/libxml2";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SDKROOT)/usr/include/libxml2",
);
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos";
Expand All @@ -1441,6 +1445,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Source/Typhoon.pch;
HEADER_SEARCH_PATHS = "${SDKROOT}/usr/include/libxml2";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SDKROOT)/usr/include/libxml2",
);
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos";
Expand Down

0 comments on commit d2cb6a1

Please sign in to comment.