<commit_before>/*
 Copyright (c) 2011-present, NimbusKit. All rights reserved.

 This source code is licensed under the BSD-style license found in the LICENSE file in the root
 directory of this source tree and at the http://nimbuskit.info/license url. An additional grant of
 patent rights can be found in the PATENTS file in the same directory and url.
 */

#import <Foundation/Foundation.h>

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

// All macros #ifndef'd so that they can be individually overwritten if necessary.

#ifndef _NIMBUSKIT_BASICS_H_
#define _NIMBUSKIT_BASICS_H_


#pragma mark Compiler Features

#if !defined(NI_EXTERN)
#  if defined(__cplusplus)
#   define NI_EXTERN extern "C"
#  else
#   define NI_EXTERN extern
#  endif
#endif

#if !defined(NI_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#  define NI_INLINE static inline
# elif defined(__cplusplus)
#  define NI_INLINE static inline
# elif defined(__GNUC__)
#  define NI_INLINE static __inline__
# else
#  define NI_INLINE static
# endif
#endif

#ifndef NI_DEPRECATED_METHOD
#if __has_feature(attribute_deprecated_with_message)

#define NI_DEPRECATED_METHOD(_msg)  __attribute__((deprecated(_msg)))

// Example:
// - (void)yourDeprecatedMethod:(id)arg NI_DESIGNATED_INITIALIZER;

#else
#define NI_DEPRECATED_METHOD(_msg)  __attribute__((deprecated))
#endif // #if __has_feature
#endif // #ifndef NI_DEPRECATED_METHOD


#ifndef NI_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)

#define NI_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))

// Example:
// - (instancetype)initWithArg:(id)arg NI_DESIGNATED_INITIALIZER;

#else
#define NI_DESIGNATED_INITIALIZER
#endif // #if __has_feature
#endif // #ifndef NI_DESIGNATED_INITIALIZER


// For use in sources which contain only categories. Removes need for -force_load -all_load when building libraries.
// Use once per source (.m) file (not per category).
// name must be globally unique. Generally a good idea to prefix it.
#ifndef NI_FIX_CATEGORY_BUG
#define NI_FIX_CATEGORY_BUG(name) @interface NI_FIX_CATEGORY_BUG_##name : NSObject @end \
                                  @implementation NI_FIX_CATEGORY_BUG_##name @end

// Example:
// NI_FIX_CATEGORY_BUG(NSMutableAttributedStringNimbusAttributedLabel)
// @implementation NSMutableAttributedString (NimbusAttributedLabel)

#endif


#ifndef NI_IS_FLAG_SET
#define NI_IS_FLAG_SET(value, flag) (((value) & (flag)) == (flag))

// Example:
// if (NI_IS_FLAG_SET(autoresizingMask, UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)
//   YES only if BOTH width and height are specified on the mask.

#endif


#pragma mark UIColor Generators


#ifndef NI_RGBCOLOR
#define NI_RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]

// Example:
// NI_RGBCOLOR(255, 0, 255) for a vibrant debugging color

#endif


// `a` is a floating point value [0...1].
#ifndef NI_RGBACOLOR
#define NI_RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

// Example:
// NI_RGBACOLOR(255, 0, 255, 0.5) for a semi-translucently vibrant debugging color

#endif


#ifndef NI_HEXCOLOR
#define NI_HEXCOLOR(hex) RGBCOLOR(((hex >> 16) & 0xFF), ((hex >> 8) & 0xFF), ((hex) & 0xFF))

// Example:
// NI_HEXCOLOR(0xFF00FF) for colors pasted from DigitalColor Meter (handy tool, use it!)

#endif


// `a` is a floating point value [0...1].
#ifndef NI_HEXACOLOR
#define NI_HEXACOLOR(hex,a) RGBACOLOR(((hex >> 16) & 0xFF), ((hex >> 8) & 0xFF), ((hex) & 0xFF), (a))

// Example:
// NI_HEXACOLOR(0xFF00FF, 0.5) for colors pasted from DigitalColor Meter, but with alpha

#endif


#pragma mark Tools for Debugging


#if defined(DEBUG) && !defined(NI_DISABLE_DASSERT)

#import <TargetConditionals.h>
#import <unistd.h>
#import <sys/sysctl.h>

// From: http://developer.apple.com/mac/library/qa/qa2004/qa1361.html
NI_INLINE int NIIsInDebugger(void) {
  int mib[4];
  struct kinfo_proc info;
  size_t size;

  // Initialize the flags so that, if sysctl fails for some bizarre reason, we get a predictable result.
  info.kp_proc.p_flag = 0;

  // Initialize mib, which tells sysctl the info we want, in this case we're looking for information
  // about a specific process ID.
  mib[0] = CTL_KERN;
  mib[1] = KERN_PROC;
  mib[2] = KERN_PROC_PID;
  mib[3] = getpid();

  size = sizeof(info);
  sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);<commit_msg>Add autoresizing masks.<commit_after>/*
 Copyright (c) 2011-present, NimbusKit. All rights reserved.

 This source code is licensed under the BSD-style license found in the LICENSE file in the root
 directory of this source tree and at the http://nimbuskit.info/license url. An additional grant of
 patent rights can be found in the PATENTS file in the same directory and url.
 */

#import <Foundation/Foundation.h>

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

// All macros #ifndef'd so that they can be individually overwritten if necessary.

#ifndef _NIMBUSKIT_BASICS_H_
#define _NIMBUSKIT_BASICS_H_


#pragma mark Compiler Features

#if !defined(NI_EXTERN)
#  if defined(__cplusplus)
#   define NI_EXTERN extern "C"
#  else
#   define NI_EXTERN extern
#  endif
#endif

#if !defined(NI_INLINE)
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#  define NI_INLINE static inline
# elif defined(__cplusplus)
#  define NI_INLINE static inline
# elif defined(__GNUC__)
#  define NI_INLINE static __inline__
# else
#  define NI_INLINE static
# endif
#endif

#ifndef NI_DEPRECATED_METHOD
#if __has_feature(attribute_deprecated_with_message)

#define NI_DEPRECATED_METHOD(_msg)  __attribute__((deprecated(_msg)))

// Example:
// - (void)yourDeprecatedMethod:(id)arg NI_DESIGNATED_INITIALIZER;

#else
#define NI_DEPRECATED_METHOD(_msg)  __attribute__((deprecated))
#endif // #if __has_feature
#endif // #ifndef NI_DEPRECATED_METHOD


#ifndef NI_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)

#define NI_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))

// Example:
// - (instancetype)initWithArg:(id)arg NI_DESIGNATED_INITIALIZER;

#else
#define NI_DESIGNATED_INITIALIZER
#endif // #if __has_feature
#endif // #ifndef NI_DESIGNATED_INITIALIZER


// For use in sources which contain only categories. Removes need for -force_load -all_load when building libraries.
// Use once per source (.m) file (not per category).
// name must be globally unique. Generally a good idea to prefix it.
#ifndef NI_FIX_CATEGORY_BUG
#define NI_FIX_CATEGORY_BUG(name) @interface NI_FIX_CATEGORY_BUG_##name : NSObject @end \
                                  @implementation NI_FIX_CATEGORY_BUG_##name @end

// Example:
// NI_FIX_CATEGORY_BUG(NSMutableAttributedStringNimbusAttributedLabel)
// @implementation NSMutableAttributedString (NimbusAttributedLabel)

#endif


#ifndef NI_IS_FLAG_SET
#define NI_IS_FLAG_SET(value, flag) (((value) & (flag)) == (flag))

// Example:
// if (NI_IS_FLAG_SET(autoresizingMask, UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)
//   YES only if BOTH width and height are specified on the mask.

#endif


#pragma mark UIColor Generators


#ifndef NI_RGBCOLOR
#define NI_RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]

// Example:
// NI_RGBCOLOR(255, 0, 255) for a vibrant debugging color

#endif


// `a` is a floating point value [0...1].
#ifndef NI_RGBACOLOR
#define NI_RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

// Example:
// NI_RGBACOLOR(255, 0, 255, 0.5) for a semi-translucently vibrant debugging color

#endif


#ifndef NI_HEXCOLOR
#define NI_HEXCOLOR(hex) RGBCOLOR(((hex >> 16) & 0xFF), ((hex >> 8) & 0xFF), ((hex) & 0xFF))

// Example:
// NI_HEXCOLOR(0xFF00FF) for colors pasted from DigitalColor Meter (handy tool, use it!)

#endif


// `a` is a floating point value [0...1].
#ifndef NI_HEXACOLOR
#define NI_HEXACOLOR(hex,a) RGBACOLOR(((hex >> 16) & 0xFF), ((hex >> 8) & 0xFF), ((hex) & 0xFF), (a))

// Example:
// NI_HEXACOLOR(0xFF00FF, 0.5) for colors pasted from DigitalColor Meter, but with alpha

#endif


#pragma mark Autoresizing Masks


#ifndef UIViewAutoresizingFlexibleMargins
#define UIViewAutoresizingFlexibleMargins (UIViewAutoresizingFlexibleLeftMargin \
                                           | UIViewAutoresizingFlexibleTopMargin \
                                           | UIViewAutoresizingFlexibleRightMargin \
                                           | UIViewAutoresizingFlexibleBottomMargin)
#endif

#ifndef UIViewAutoresizingFlexibleDimensions
#define UIViewAutoresizingFlexibleDimensions (UIViewAutoresizingFlexibleWidth \
                                              | UIViewAutoresizingFlexibleHeight)
#endif

#ifndef UIViewAutoresizingNavigationBar
#define UIViewAutoresizingNavigationBar (UIViewAutoresizingFlexibleWidth \
                                         | UIViewAutoresizingFlexibleBottomMargin)
#endif

#ifndef UIViewAutoresizingToolbar
#define UIViewAutoresizingToolbar (UIViewAutoresizingFlexibleWidth \
                                   | UIViewAutoresizingFlexibleTopMargin)
#endif


#pragma mark Tools for Debugging


#if defined(DEBUG) && !defined(NI_DISABLE_DASSERT)

#import <TargetConditionals.h>
#import <unistd.h>
#import <sys/sysctl.h>

// From: http://developer.apple.com/mac/library/qa/qa2004/qa1361.html
NI_INLINE int NIIsInDebugger(void) {
  int mib[4];
  struct kinfo_proc info;
  size_t size;

  // Initialize the flags so that, if sysctl fails for some bizarre reason, we get a predictable result.
  info.kp_proc.p_flag = 0;

  // Initialize mib, which tells sysctl the info we want, in this case we're looking for information
  // about a specific process ID.
  mib[0] = CTL_KERN;
  mib[1] = KERN_PROC;
  mib[2] = KERN_PROC_PID;
  mib[3] = getpid();

  size = sizeof(info);
  sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
{'fraction_non_alphanumeric': 0.10425020048115477, 'fraction_numerical': 0.018043303929430633, 'mean_word_length': 4.346730975348339, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1420308', 'n_tokens_mistral': 3700, 'n_tokens_neox': 3374, 'n_words': 903}