<commit_before>/*
 *  Copyright (c) 2014-present, Facebook, Inc.
 *  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. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */

#import "ASEnvironment.h"
#import "ASEnvironmentInternal.h"
#import <AsyncDisplayKit/ASAvailability.h>

ASEnvironmentLayoutOptionsState _ASEnvironmentLayoutOptionsStateMakeDefault()
{
  return (ASEnvironmentLayoutOptionsState) {
    // Default values can be defined in here
  };
}

ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault()
{
  return (ASEnvironmentHierarchyState) {
    // Default values can be defined in here
  };
}

extern void ASDisplayTraitsClearDisplayContext(id<ASEnvironment> rootEnvironment)
{
  ASEnvironmentState envState = [rootEnvironment environmentState];
  ASEnvironmentDisplayTraits displayTraits = envState.displayTraits;
  displayTraits.displayContext = nil;
  envState.displayTraits = displayTraits;
  [rootEnvironment setEnvironmentState:envState];
  
  for (id<ASEnvironment> child in [rootEnvironment children]) {
    ASEnvironmentStatePropagateDown(child, displayTraits);
  }
}

ASEnvironmentDisplayTraits _ASEnvironmentDisplayTraitsMakeDefault()
{
  return (ASEnvironmentDisplayTraits) {
    // Default values can be defined in here
  };
}

ASEnvironmentDisplayTraits ASEnvironmentDisplayTraitsFromUITraitCollection(UITraitCollection *traitCollection)
{
  ASEnvironmentDisplayTraits displayTraits;
  if (AS_AT_LEAST_IOS8) {
    displayTraits.displayScale = traitCollection.displayScale;
    displayTraits.horizontalSizeClass = traitCollection.horizontalSizeClass;
    displayTraits.verticalSizeClass = traitCollection.verticalSizeClass;
    displayTraits.userInterfaceIdiom = traitCollection.userInterfaceIdiom;
    if (AS_AT_LEAST_IOS9) {
      displayTraits.forceTouchCapability = traitCollection.forceTouchCapability;
    }
  }
  return displayTraits;
}

BOOL ASEnvironmentDisplayTraitsIsEqualToASEnvironmentDisplayTraits(ASEnvironmentDisplayTraits displayTraits0, ASEnvironmentDisplayTraits displayTraits1)
{
  return
  displayTraits0.verticalSizeClass == displayTraits1.verticalSizeClass &&
  displayTraits0.horizontalSizeClass == displayTraits1.horizontalSizeClass &&
  displayTraits0.displayScale == displayTraits1.displayScale &&
  displayTraits0.userInterfaceIdiom == displayTraits1.userInterfaceIdiom &&
  displayTraits0.forceTouchCapability == displayTraits1.forceTouchCapability;
}

ASEnvironmentState ASEnvironmentStateMakeDefault()
{
  return (ASEnvironmentState) {
    .layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(),
    .hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(),
    .displayTraits = _ASEnvironmentDisplayTraitsMakeDefault()
  };
}
<commit_msg>include displayContext in equality check<commit_after>/*
 *  Copyright (c) 2014-present, Facebook, Inc.
 *  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. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */

#import "ASEnvironment.h"
#import "ASEnvironmentInternal.h"
#import <AsyncDisplayKit/ASAvailability.h>

ASEnvironmentLayoutOptionsState _ASEnvironmentLayoutOptionsStateMakeDefault()
{
  return (ASEnvironmentLayoutOptionsState) {
    // Default values can be defined in here
  };
}

ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault()
{
  return (ASEnvironmentHierarchyState) {
    // Default values can be defined in here
  };
}

extern void ASDisplayTraitsClearDisplayContext(id<ASEnvironment> rootEnvironment)
{
  ASEnvironmentState envState = [rootEnvironment environmentState];
  ASEnvironmentDisplayTraits displayTraits = envState.displayTraits;
  displayTraits.displayContext = nil;
  envState.displayTraits = displayTraits;
  [rootEnvironment setEnvironmentState:envState];
  
  for (id<ASEnvironment> child in [rootEnvironment children]) {
    ASEnvironmentStatePropagateDown(child, displayTraits);
  }
}

ASEnvironmentDisplayTraits _ASEnvironmentDisplayTraitsMakeDefault()
{
  return (ASEnvironmentDisplayTraits) {
    // Default values can be defined in here
  };
}

ASEnvironmentDisplayTraits ASEnvironmentDisplayTraitsFromUITraitCollection(UITraitCollection *traitCollection)
{
  ASEnvironmentDisplayTraits displayTraits;
  if (AS_AT_LEAST_IOS8) {
    displayTraits.displayScale = traitCollection.displayScale;
    displayTraits.horizontalSizeClass = traitCollection.horizontalSizeClass;
    displayTraits.verticalSizeClass = traitCollection.verticalSizeClass;
    displayTraits.userInterfaceIdiom = traitCollection.userInterfaceIdiom;
    if (AS_AT_LEAST_IOS9) {
      displayTraits.forceTouchCapability = traitCollection.forceTouchCapability;
    }
  }
  return displayTraits;
}

BOOL ASEnvironmentDisplayTraitsIsEqualToASEnvironmentDisplayTraits(ASEnvironmentDisplayTraits displayTraits0, ASEnvironmentDisplayTraits displayTraits1)
{
  return
    displayTraits0.verticalSizeClass == displayTraits1.verticalSizeClass &&
    displayTraits0.horizontalSizeClass == displayTraits1.horizontalSizeClass &&
    displayTraits0.displayScale == displayTraits1.displayScale &&
    displayTraits0.userInterfaceIdiom == displayTraits1.userInterfaceIdiom &&
    displayTraits0.forceTouchCapability == displayTraits1.forceTouchCapability &&
    displayTraits0.displayContext == displayTraits1.displayContext;
}

ASEnvironmentState ASEnvironmentStateMakeDefault()
{
  return (ASEnvironmentState) {
    .layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(),
    .hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(),
    .displayTraits = _ASEnvironmentDisplayTraitsMakeDefault()
  };
}

{'fraction_non_alphanumeric': 0.0680619363620895, 'fraction_numerical': 0.0064658839543985025, 'mean_word_length': 6.212269938650307, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7235636', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1609, 'n_words': 324}