<commit_before>//
//  NSObjCRuntime.h
//  FoundationExtensionsApp
//
//  Created by <NAME> on 9/28/13.
//  Copyright (c) 2013 <NAME>. All rights reserved.
//

#ifndef FoundationExtensionsApp_NSObjCRuntime_h
#define FoundationExtensionsApp_NSObjCRuntime_h

#import <Foundation/NSObjCRuntime.h>

#define NUMARGS(...)  (sizeof((int[]){0, ##__VA_ARGS__})/sizeof(int)-1)

#define CArrayIterate(arr, block) ({  \
    for(typeof(*arr) * it = arr, * end = (it + (sizeof(arr)/sizeof(*arr))); it != end; ++it) {  \
        block(it);  \
    }   \
})

#define NSStringFromMethodForEnumType(_name, _type, _components...) static inline NSString *NSStringFrom##_name(int value) {    \
    NSArray *componentsStrings = [@(#_components) componentsSeparatedByString:@", "];    \
    \
    int componentsCArray[NUMARGS(_components)] = { _components };    \
    \
    NSMutableArray *components = [NSMutableArray array];    \
    CArrayIterate(componentsCArray, ^(int *valuePointer) {    \
        [components addObject:@(*valuePointer)];    \
    });    \
    \
    NSUInteger valueIndex = [components indexOfObject:@(value)];    \
    return [componentsStrings objectAtIndex:valueIndex];    \
}

#endif<commit_msg>Better NSStringFromMethodForEnumType()<commit_after>//
//  NSObjCRuntime.h
//  FoundationExtensionsApp
//
//  Created by <NAME> on 9/28/13.
//  Copyright (c) 2013 <NAME>. All rights reserved.
//

#ifndef FoundationExtensionsApp_NSObjCRuntime_h
#define FoundationExtensionsApp_NSObjCRuntime_h

#import <Foundation/NSObjCRuntime.h>

#define NUMARGS(...)  (sizeof((int[]){0, ##__VA_ARGS__})/sizeof(int)-1)

#define CArrayIterate(arr, block) ({  \
    for(typeof(*arr) * it = arr, * end = (it + (sizeof(arr)/sizeof(*arr))); it != end; ++it) {  \
        block(it);  \
    }   \
})

#define NSStringFromMethodForEnumType(_name, _type, _components...) static inline NSString *NSStringFrom##_name(int value) {    \
    NSArray *componentsStrings = [@(#_components) componentsSeparatedByString:@", "];    \
    \
    int N = NUMARGS(_components);    \
    int componentsCArray[] = { _components };    \
    \
    for (int i = 0; i < N; i++) {    \
        if (componentsCArray[i] == value) return [componentsStrings objectAtIndex:i];    \
    }    \
    \
    return nil;    \
}

#endif
{'fraction_non_alphanumeric': 0.16043956043956045, 'fraction_numerical': 0.01010989010989011, 'mean_word_length': 3.286252354048964, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, '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': '6327204', 'n_tokens_mistral': 784, 'n_tokens_neox': 744, 'n_words': 144}