<commit_before>//
//  ObjcAssociatedObjectHelpers.h
//  ObjcAssociatedObjectHelpers
//
//  Created by <NAME> on 01/10/2012.
//  Copyright (c) 2012 jcrooke. All rights reserved.
//

#import <objc/runtime.h>
#import <TargetConditionals.h>
#import <Availability.h>

/** Need Clang ARC */
#if !__has_feature(objc_arc)
#error Associated object macros require Clang ARC to be enabled
#endif

/** Platform minimum requirements (associated object availability) */
#if ( TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR ) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0
#error Associated references available from iOS 4.0
#elif TARGET_OS_MAC && !( TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR ) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
#error Associated references available from OS X 10.6
#endif

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Quotation helper
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define __QUOTE(x) #x
#define QUOTE(x) __QUOTE(x)

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Assign readwrite
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_OBJ_ASSIGN(getterName, setterName) \
static void* getterName##Key = QUOTE(getterName); \
- (void)setterName:(id)object { \
    objc_AssociationPolicy policy = OBJC_ASSOCIATION_ASSIGN; \
    @synchronized(self) { \
        objc_setAssociatedObject(self, getterName##Key, object, policy); \
    } \
} \
- (id) getterName { \
    id ret = nil; \
    @synchronized(self) { \
        ret = objc_getAssociatedObject(self, getterName##Key); \
    }; \
    return ret; \
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Readwrite Object
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_OBJ(getterName, setterName) \
static void* getterName##Key = QUOTE(getterName); \
- (void)setterName:(id)object { \
    objc_AssociationPolicy policy = \
    [object conformsToProtocol:@protocol(NSCopying)] ? OBJC_ASSOCIATION_COPY : OBJC_ASSOCIATION_RETAIN; \
    @synchronized(self) { \
        objc_setAssociatedObject(self, getterName##Key, object, policy); \
    } \
} \
- (id) getterName { \
    id ret = nil; \
    @synchronized(self) { \
        ret = objc_getAssociatedObject(self, getterName##Key); \
    }; \
    return ret; \
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Lazy readonly object
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_OBJ_LAZY(getterName, class) \
static void* getterName##Key = QUOTE(getterName); \
- (id) associatedDictionary { \
    id object = nil; \
    @synchronized(self) { \
        object = objc_getAssociatedObject(self, getterName##Key); \
        if (!object) { \
            object = [[class alloc] init]; \
            objc_setAssociatedObject(self, getterName##Key, object, OBJC_ASSOCIATION_RETAIN); \
        } \
    } \
    return object; \
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Primitive
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_PRIMITIVE(getterName, setterName, type) \
static void* getterName##Key = QUOTE(getterName); \
- (void)setterName:(type)structure { \
    @synchronized(self) { \
        NSValue *value = [NSValue value:&structure withObjCType:@encode(type)]; \
        objc_setAssociatedObject(self, getterName##Key, value, OBJC_ASSOCIATION_RETAIN); \
    } \
} \
- (type) getterName { \
    type ret; \<commit_msg>Fixing SYNTHESIZE_ASC_OBJ_LAZY<commit_after>//
//  ObjcAssociatedObjectHelpers.h
//  ObjcAssociatedObjectHelpers
//
//  Created by <NAME>rooke on 01/10/2012.
//  Copyright (c) 2012 jcrooke. All rights reserved.
//

#import <objc/runtime.h>
#import <TargetConditionals.h>
#import <Availability.h>

/** Need Clang ARC */
#if !__has_feature(objc_arc)
#error Associated object macros require Clang ARC to be enabled
#endif

/** Platform minimum requirements (associated object availability) */
#if ( TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR ) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0
#error Associated references available from iOS 4.0
#elif TARGET_OS_MAC && !( TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR ) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
#error Associated references available from OS X 10.6
#endif

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Quotation helper
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define __QUOTE(x) #x
#define QUOTE(x) __QUOTE(x)

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Assign readwrite
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_OBJ_ASSIGN(getterName, setterName) \
static void* getterName##Key = QUOTE(getterName); \
- (void)setterName:(id)object { \
    objc_AssociationPolicy policy = OBJC_ASSOCIATION_ASSIGN; \
    @synchronized(self) { \
        objc_setAssociatedObject(self, getterName##Key, object, policy); \
    } \
} \
- (id) getterName { \
    id ret = nil; \
    @synchronized(self) { \
        ret = objc_getAssociatedObject(self, getterName##Key); \
    }; \
    return ret; \
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Readwrite Object
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_OBJ(getterName, setterName) \
static void* getterName##Key = QUOTE(getterName); \
- (void)setterName:(id)object { \
    objc_AssociationPolicy policy = \
    [object conformsToProtocol:@protocol(NSCopying)] ? OBJC_ASSOCIATION_COPY : OBJC_ASSOCIATION_RETAIN; \
    @synchronized(self) { \
        objc_setAssociatedObject(self, getterName##Key, object, policy); \
    } \
} \
- (id) getterName { \
    id ret = nil; \
    @synchronized(self) { \
        ret = objc_getAssociatedObject(self, getterName##Key); \
    }; \
    return ret; \
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Lazy readonly object
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_OBJ_LAZY(getterName, class) \
static void* getterName##Key = QUOTE(getterName); \
- (id)getterName { \
    id object = nil; \
    @synchronized(self) { \
        object = objc_getAssociatedObject(self, getterName##Key); \
        if (!object) { \
            object = [[class alloc] init]; \
            objc_setAssociatedObject(self, getterName##Key, object, OBJC_ASSOCIATION_RETAIN); \
        } \
    } \
    return object; \
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#pragma mark Primitive
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define SYNTHESIZE_ASC_PRIMITIVE(getterName, setterName, type) \
static void* getterName##Key = QUOTE(getterName); \
- (void)setterName:(type)structure { \
    @synchronized(self) { \
        NSValue *value = [NSValue value:&structure withObjCType:@encode(type)]; \
        objc_setAssociatedObject(self, getterName##Key, value, OBJC_ASSOCIATION_RETAIN); \
    } \
} \
- (type) getterName { \
    type ret; \
{'fraction_non_alphanumeric': 0.3108559220189611, 'fraction_numerical': 0.005875283749499266, 'mean_word_length': 4.856137607505864, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5560300', 'n_tokens_mistral': 2440, 'n_tokens_neox': 2272, 'n_words': 408}