text:
/* This file was generated by upbc (the upb compiler) from the input
 * file:
 *
 *     envoy/config/cluster/v3/outlier_detection.proto
 *
 * Do not edit -- your changes will be discarded when the file is
 * regenerated. */

#ifndef ENVOY_CONFIG_CLUSTER_V3_OUTLIER_DETECTION_PROTO_UPB_H_
#define ENVOY_CONFIG_CLUSTER_V3_OUTLIER_DETECTION_PROTO_UPB_H_

#include "upb/msg.h"
#include "upb/decode.h"
#include "upb/decode_fast.h"
#include "upb/encode.h"

#include "upb/port_def.inc"

#ifdef __cplusplus
extern "C" {
#endif

struct envoy_config_cluster_v3_OutlierDetection;
typedef struct envoy_config_cluster_v3_OutlierDetection envoy_config_cluster_v3_OutlierDetection;
extern const upb_msglayout envoy_config_cluster_v3_OutlierDetection_msginit;
struct google_protobuf_Duration;
struct google_protobuf_UInt32Value;
extern const upb_msglayout google_protobuf_Duration_msginit;
extern const upb_msglayout google_protobuf_UInt32Value_msginit;

/* envoy.config.cluster.v3.OutlierDetection */

UPB_INLINE envoy_config_cluster_v3_OutlierDetection *envoy_config_cluster_v3_OutlierDetection_new(upb_arena *arena) {
  return (envoy_config_cluster_v3_OutlierDetection *)_upb_msg_new(&envoy_config_cluster_v3_OutlierDetection_msginit, arena);
}
UPB_INLINE envoy_config_cluster_v3_OutlierDetection *envoy_config_cluster_v3_OutlierDetection_parse(const char *buf, size_t size,
                        upb_arena *arena) {
  envoy_config_cluster_v3_OutlierDetection *ret = envoy_config_cluster_v3_OutlierDetection_new(arena);
  return (ret && upb_decode(buf, size, ret, &envoy_config_cluster_v3_OutlierDetection_msginit, arena)) ? ret : NULL;
}
UPB_INLINE envoy_config_cluster_v3_OutlierDetection *envoy_config_cluster_v3_OutlierDetection_parse_ex(const char *buf, size_t size,
                           upb_arena *arena, int options) {
  envoy_config_cluster_v3_OutlierDetection *ret = envoy_config_cluster_v3_OutlierDetection_new(arena);
  return (ret && _upb_decode(buf, size, ret, &envoy_config_cluster_v3_OutlierDetection_msginit, arena, options))
      ? ret : NULL;
}
UPB_INLINE char *envoy_config_cluster_v3_OutlierDetection_serialize(const envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena, size_t *len) {
  return upb_encode(msg, &envoy_config_cluster_v3_OutlierDetection_msginit, arena, len);
}

UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_consecutive_5xx(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 1); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_consecutive_5xx(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(4, 8), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_interval(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 2); }
UPB_INLINE const struct google_protobuf_Duration* envoy_config_cluster_v3_OutlierDetection_interval(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(8, 16), const struct google_protobuf_Duration*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_base_ejection_time(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 3); }
UPB_INLINE const struct google_protobuf_Duration* envoy_config_cluster_v3_OutlierDetection_base_ejection_time(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(12, 24), const struct google_protobuf_Duration*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_max_ejection_percent(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 4); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_max_ejection_percent(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(16, 32), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_consecutive_5xx(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 5); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_consecutive_5xx(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(20, 40), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_success_rate(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 6); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_success_rate(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(24, 48), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_success_rate_minimum_hosts(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 7); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_success_rate_minimum_hosts(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(28, 56), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_success_rate_request_volume(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 8); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_success_rate_request_volume(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(32, 64), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_success_rate_stdev_factor(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 9); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_success_rate_stdev_factor(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(36, 72), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_consecutive_gateway_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 10); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_consecutive_gateway_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(40, 80), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_consecutive_gateway_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 11); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_consecutive_gateway_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(44, 88), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_split_external_local_origin_errors(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_consecutive_local_origin_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 12); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_consecutive_local_origin_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(48, 96), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_consecutive_local_origin_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 13); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_consecutive_local_origin_failure(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(52, 104), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_local_origin_success_rate(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 14); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_local_origin_success_rate(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(56, 112), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_failure_percentage_threshold(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 15); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_failure_percentage_threshold(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(60, 120), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_failure_percentage(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 16); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_failure_percentage(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(64, 128), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_enforcing_failure_percentage_local_origin(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 17); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_enforcing_failure_percentage_local_origin(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(68, 136), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_failure_percentage_minimum_hosts(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 18); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_failure_percentage_minimum_hosts(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(72, 144), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_failure_percentage_request_volume(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 19); }
UPB_INLINE const struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_failure_percentage_request_volume(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(76, 152), const struct google_protobuf_UInt32Value*); }
UPB_INLINE bool envoy_config_cluster_v3_OutlierDetection_has_max_ejection_time(const envoy_config_cluster_v3_OutlierDetection *msg) { return _upb_hasbit(msg, 20); }
UPB_INLINE const struct google_protobuf_Duration* envoy_config_cluster_v3_OutlierDetection_max_ejection_time(const envoy_config_cluster_v3_OutlierDetection *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(80, 160), const struct google_protobuf_Duration*); }

UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_consecutive_5xx(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 1);
  *UPB_PTR_AT(msg, UPB_SIZE(4, 8), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_consecutive_5xx(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_consecutive_5xx(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_consecutive_5xx(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_interval(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_Duration* value) {
  _upb_sethas(msg, 2);
  *UPB_PTR_AT(msg, UPB_SIZE(8, 16), struct google_protobuf_Duration*) = value;
}
UPB_INLINE struct google_protobuf_Duration* envoy_config_cluster_v3_OutlierDetection_mutable_interval(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_config_cluster_v3_OutlierDetection_interval(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_Duration*)_upb_msg_new(&google_protobuf_Duration_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_interval(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_base_ejection_time(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_Duration* value) {
  _upb_sethas(msg, 3);
  *UPB_PTR_AT(msg, UPB_SIZE(12, 24), struct google_protobuf_Duration*) = value;
}
UPB_INLINE struct google_protobuf_Duration* envoy_config_cluster_v3_OutlierDetection_mutable_base_ejection_time(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_config_cluster_v3_OutlierDetection_base_ejection_time(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_Duration*)_upb_msg_new(&google_protobuf_Duration_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_base_ejection_time(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_max_ejection_percent(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 4);
  *UPB_PTR_AT(msg, UPB_SIZE(16, 32), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_max_ejection_percent(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_max_ejection_percent(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_max_ejection_percent(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_consecutive_5xx(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 5);
  *UPB_PTR_AT(msg, UPB_SIZE(20, 40), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_consecutive_5xx(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_consecutive_5xx(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_consecutive_5xx(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_success_rate(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 6);
  *UPB_PTR_AT(msg, UPB_SIZE(24, 48), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_success_rate(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_success_rate(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_success_rate(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_success_rate_minimum_hosts(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 7);
  *UPB_PTR_AT(msg, UPB_SIZE(28, 56), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_success_rate_minimum_hosts(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_success_rate_minimum_hosts(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_success_rate_minimum_hosts(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_success_rate_request_volume(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 8);
  *UPB_PTR_AT(msg, UPB_SIZE(32, 64), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_success_rate_request_volume(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_success_rate_request_volume(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_success_rate_request_volume(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_success_rate_stdev_factor(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 9);
  *UPB_PTR_AT(msg, UPB_SIZE(36, 72), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_success_rate_stdev_factor(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_success_rate_stdev_factor(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_success_rate_stdev_factor(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_consecutive_gateway_failure(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 10);
  *UPB_PTR_AT(msg, UPB_SIZE(40, 80), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_consecutive_gateway_failure(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_consecutive_gateway_failure(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_consecutive_gateway_failure(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_consecutive_gateway_failure(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 11);
  *UPB_PTR_AT(msg, UPB_SIZE(44, 88), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_consecutive_gateway_failure(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_consecutive_gateway_failure(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_consecutive_gateway_failure(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_split_external_local_origin_errors(envoy_config_cluster_v3_OutlierDetection *msg, bool value) {
  *UPB_PTR_AT(msg, UPB_SIZE(3, 3), bool) = value;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_consecutive_local_origin_failure(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 12);
  *UPB_PTR_AT(msg, UPB_SIZE(48, 96), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_consecutive_local_origin_failure(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_consecutive_local_origin_failure(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_consecutive_local_origin_failure(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_consecutive_local_origin_failure(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 13);
  *UPB_PTR_AT(msg, UPB_SIZE(52, 104), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_consecutive_local_origin_failure(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_consecutive_local_origin_failure(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_consecutive_local_origin_failure(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_local_origin_success_rate(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 14);
  *UPB_PTR_AT(msg, UPB_SIZE(56, 112), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_local_origin_success_rate(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_local_origin_success_rate(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_local_origin_success_rate(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_failure_percentage_threshold(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 15);
  *UPB_PTR_AT(msg, UPB_SIZE(60, 120), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_failure_percentage_threshold(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_failure_percentage_threshold(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_failure_percentage_threshold(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_failure_percentage(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 16);
  *UPB_PTR_AT(msg, UPB_SIZE(64, 128), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_failure_percentage(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_failure_percentage(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_failure_percentage(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_enforcing_failure_percentage_local_origin(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 17);
  *UPB_PTR_AT(msg, UPB_SIZE(68, 136), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_enforcing_failure_percentage_local_origin(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_enforcing_failure_percentage_local_origin(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_enforcing_failure_percentage_local_origin(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_failure_percentage_minimum_hosts(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 18);
  *UPB_PTR_AT(msg, UPB_SIZE(72, 144), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_failure_percentage_minimum_hosts(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_failure_percentage_minimum_hosts(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_failure_percentage_minimum_hosts(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_failure_percentage_request_volume(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_UInt32Value* value) {
  _upb_sethas(msg, 19);
  *UPB_PTR_AT(msg, UPB_SIZE(76, 152), struct google_protobuf_UInt32Value*) = value;
}
UPB_INLINE struct google_protobuf_UInt32Value* envoy_config_cluster_v3_OutlierDetection_mutable_failure_percentage_request_volume(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_UInt32Value* sub = (struct google_protobuf_UInt32Value*)envoy_config_cluster_v3_OutlierDetection_failure_percentage_request_volume(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_UInt32Value*)_upb_msg_new(&google_protobuf_UInt32Value_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_failure_percentage_request_volume(msg, sub);
  }
  return sub;
}
UPB_INLINE void envoy_config_cluster_v3_OutlierDetection_set_max_ejection_time(envoy_config_cluster_v3_OutlierDetection *msg, struct google_protobuf_Duration* value) {
  _upb_sethas(msg, 20);
  *UPB_PTR_AT(msg, UPB_SIZE(80, 160), struct google_protobuf_Duration*) = value;
}
UPB_INLINE struct google_protobuf_Duration* envoy_config_cluster_v3_OutlierDetection_mutable_max_ejection_time(envoy_config_cluster_v3_OutlierDetection *msg, upb_arena *arena) {
  struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_config_cluster_v3_OutlierDetection_max_ejection_time(msg);
  if (sub == NULL) {
    sub = (struct google_protobuf_Duration*)_upb_msg_new(&google_protobuf_Duration_msginit, arena);
    if (!sub) return NULL;
    envoy_config_cluster_v3_OutlierDetection_set_max_ejection_time(msg, sub);
  }
  return sub;
}

#ifdef __cplusplus
}  /* extern "C" */
#endif

#include "upb/port_undef.inc"

#endif  /* ENVOY_CONFIG_CLUSTER_V3_OUTLIER_DETECTION_PROTO_UPB_H_ */


text:
use std::io::{self, Read, Write};
use std::fmt::{self, Debug};

use typemap::TypeMap;
use plugin::Extensible;
use modifier::{Set, Modifier};

use hyper::header::Headers;

use status::{self, Status};
use {Plugin, headers};

pub use hyper::server::response::Response as HttpResponse;
use hyper::net::Fresh;

/// The response representation given to `Middleware`
pub struct Response {
    /// The response status-code.
    pub status: Option<Status>,

    /// The headers of the response.
    pub headers: Headers,

    /// A TypeMap to be used as an extensible storage for data
    /// associated with this Response.
    pub extensions: TypeMap,

    /// The body of the response.
    ///
    /// This is a Reader for generality, most data should
    /// be sent using either `serve` or `serve_file`.
    ///
    /// Arbitrary Readers can be sent by assigning to body.
    pub body: Option<Box<Read + Send>>
}

impl Response {
    /// Construct a blank Response
    pub fn new() -> Response {
        Response {
            status: None, // Start with no response code.
            body: None, // Start with no body.
            headers: Headers::new(),
            extensions: TypeMap::new()
        }
    }

    /// Construct a Response with the specified modifier pre-applied.
    pub fn with<M: Modifier<Response>>(m: M) -> Response {
        Response::new().set(m)
    }

    // `write_back` is used to put all the data added to `self`
    // back onto an `HttpResponse` so that it is sent back to the
    // client.
    //
    // `write_back` consumes the `Response`.
    #[doc(hidden)]
    pub fn write_back(self, mut http_res: HttpResponse<Fresh>) {
        *http_res.headers_mut() = self.headers;

        // Default to a 404 if no response code was set
        *http_res.status_mut() = self.status.clone().unwrap_or(status::NotFound);

        let out = match self.body {
            Some(body) => write_with_body(http_res, body),
            None => {
                http_res.headers_mut().set(headers::ContentLength(0));
                http_res.start().and_then(|res| res.end())
            }
        };

        match out {
            Err(e) => {
                error!("Error writing response: {}", e);
            },
            _ => {}
        }
    }
}

fn write_with_body(mut res: HttpResponse<Fresh>, mut body: Box<Read + Send>) -> io::Result<()> {
    let content_type = res.headers().get::<headers::ContentType>()
                           .map(|cx| cx.clone())
                           .unwrap_or_else(|| headers::ContentType("text/plain".parse().unwrap()));
    res.headers_mut().set(content_type);

    let mut res = try!(res.start());

    // FIXME: Manually inlined old_io::util::copy
    // because Box<Reader + Send> does not impl Reader.
    //
    // Tracking issue: rust-lang/rust#18542
    let mut buf = &mut [0; 1024 * 64];
    loop {
        let len = match body.read(buf) {
            Ok(0) => break,
            Ok(len) => len,
            Err(e) => { return Err(e) },
        };

        try!(res.write_all(&buf[..len]))
    }

    res.end()
}

impl Debug for Response {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        writeln!(f, "HTTP/1.1 {} {}\n{}",
            self.status.unwrap_or(status::NotFound),
            self.status.unwrap_or(status::NotFound).canonical_reason().unwrap(),
            self.headers
        )
    }
}

impl fmt::Display for Response {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        Debug::fmt(self, f)
    }
}

// Allow plugins to attach to responses.
impl Extensible for Response {
    fn extensions(&self) -> &TypeMap {
        &self.extensions
    }

    fn extensions_mut(&mut self) -> &mut TypeMap {
        &mut self.extensions
    }
}

impl Plugin for Response {}
impl Set for Response {}

redpajama_set_name: RedPajamaGithub


text:
module WebMock

  def self.included(clazz)
    WebMock::Deprecation.warning("include WebMock is deprecated. Please include WebMock::API instead")
    if clazz.instance_methods.map(&:to_s).include?('request')
      warn "WebMock#request was not included in #{clazz} to avoid name collision"
    else
      clazz.class_eval do
        def request(method, uri)
          WebMock::Deprecation.warning("WebMock#request is deprecated. Please use WebMock::API#a_request method instead")
          WebMock.a_request(method, uri)
        end
      end
    end
  end

  include WebMock::API
  extend WebMock::API

  class << self
    alias :request :a_request
  end

  def self.version
    VERSION
  end

  def self.allow_net_connect!(options = {})
    Config.instance.allow_net_connect = true
    Config.instance.net_http_connect_on_start = options[:net_http_connect_on_start]
  end

  def self.disable_net_connect!(options = {})
    Config.instance.allow_net_connect = false
    Config.instance.allow_localhost = options[:allow_localhost]
    Config.instance.allow = options[:allow]
    Config.instance.net_http_connect_on_start = options[:net_http_connect_on_start]
  end

  def self.net_connect_allowed?(uri = nil)
    if uri.is_a?(String)
      uri = WebMock::Util::URI.normalize_uri(uri)
    end
    Config.instance.allow_net_connect ||
      (Config.instance.allow_localhost && WebMock::Util::URI.is_uri_localhost?(uri)) ||
      Config.instance.allow && (Config.instance.allow.include?(uri.host) || Config.instance.allow.include?("#{uri.host}:#{uri.port}"))
  end

  def self.reset!
    WebMock::RequestRegistry.instance.reset!
    WebMock::StubRegistry.instance.reset!
  end

  def self.reset_webmock
    WebMock::Deprecation.warning("WebMock.reset_webmock is deprecated. Please use WebMock.reset! method instead")
    reset!
  end

  def self.reset_callbacks
    WebMock::CallbackRegistry.reset
  end

  def self.after_request(options={}, &block)
    WebMock::CallbackRegistry.add_callback(options, block)
  end

  def self.registered_request?(request_signature)
    WebMock::StubRegistry.instance.registered_request?(request_signature)
  end

  def self.print_executed_requests
    puts WebMock::RequestExecutionVerifier.executed_requests_message
  end

  def self.warn(message)
    $stderr.puts message
    $stderr.puts caller.join("\n") if $VERBOSE
  end

  %w(
    allow_net_connect!
    disable_net_connect!
    net_connect_allowed?
    reset_webmock
    reset_callbacks
    after_request
    registered_request?
  ).each do |method|
    self.class_eval(%Q(
      def #{method}(*args, &block)
        WebMock::Deprecation.warning("WebMock##{method} instance method is deprecated. Please use WebMock.#{method} class method instead")
        WebMock.#{method}(*args, &block)
      end
    ))
  end

end


text:
/*!
** @file pin_init.h
** @version 1.4
** @brief
**
*/
/*!
**  @addtogroup pin_init_module pin_init module documentation
**  @{
*/

#ifndef pin_init_H_
#define pin_init_H_

/* MODULE pin_init. */

/*!
 * @brief ADC method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         ADC0, ADC1
 *         peripherals.
 * @param instance - ADC instance number 0..1
 */
void init_adc_pins(uint32_t instance);
/*!
 * @brief ADC method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         ADC0, ADC1
 *         peripherals.
 * @param instance - ADC instance number 0..1
 */
void deinit_adc_pins(uint32_t instance);
/*!
 * @brief CAN method sets registers according routing settings. Call
 *         this method code to route desired pins into CAN0 periphery.
 * @param instance - CAN instance number (0 is expected)
 */
void init_can_pins(uint32_t instance);
/*!
 * @brief CAN method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for CAN0 periphery.
 * @param instance - CAN instance number (0 is expected)
 */
void deinit_can_pins(uint32_t instance);
/*!
 * @brief CMP method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         CMP0, CMP1, CMP2
 *         peripherals.
 * @param instance - CMP instance number 0..2
 */
void init_cmp_pins(uint32_t instance);
/*!
 * @brief CMP method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         CMP0, CMP1, CMP2
 *         peripherals.
 * @param instance - CMP instance number 0..2
 */
void deinit_cmp_pins(uint32_t instance);
/*!
 * @brief CMT method sets registers according routing settings. Call
 *         this method code to route desired pins into CMT periphery.
 * @param instance - CMT instance number (0 is expected)
 */
void init_cmt_pins(uint32_t instance);
/*!
 * @brief CMT method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for CMT periphery.
 * @param instance - CMT instance number (0 is expected)
 */
void deinit_cmt_pins(uint32_t instance);
/*!
 * @brief DAC method sets registers according routing settings. Call
 *         this method code to route desired pins into DAC0 periphery.
 * @param instance - DAC instance number (0 is expected)
 */
void init_dac_pins(uint32_t instance);
/*!
 * @brief DAC method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for DAC0 periphery.
 * @param instance - DAC instance number (0 is expected)
 */
void deinit_dac_pins(uint32_t instance);
/*!
 * @brief DMA method sets registers according routing settings. Call
 *         this method code to route desired pins into DMA periphery.
 * @param instance - DMA instance number (0 is expected)
 */
void init_dma_pins(uint32_t instance);
/*!
 * @brief DMA method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for DMA periphery.
 * @param instance - DMA instance number (0 is expected)
 */
void deinit_dma_pins(uint32_t instance);
/*!
 * @brief ENET method sets registers according routing settings. Call
 *         this method code to route desired pins into ENET periphery.
 * @param instance - ENET instance number (0 is expected)
 */
void init_enet_pins(uint32_t instance);
/*!
 * @brief ENET method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for ENET periphery.
 * @param instance - ENET instance number (0 is expected)
 */
void deinit_enet_pins(uint32_t instance);
/*!
 * @brief EWM method sets registers according routing settings. Call
 *         this method code to route desired pins into EWM periphery.
 * @param instance - EWM instance number (0 is expected)
 */
void init_ewm_pins(uint32_t instance);
/*!
 * @brief EWM method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for EWM periphery.
 * @param instance - EWM instance number (0 is expected)
 */
void deinit_ewm_pins(uint32_t instance);
/*!
 * @brief FB method sets registers according routing settings. Call
 *         this method code to route desired pins into FB periphery.
 * @param instance - FB instance number (0 is expected)
 */
void init_fb_pins(uint32_t instance);
/*!
 * @brief FB method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for FB periphery.
 * @param instance - FB instance number (0 is expected)
 */
void deinit_fb_pins(uint32_t instance);
/*!
 * @brief FTM method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         FTM0, FTM1, FTM2, FTM3
 *         peripherals.
 * @param instance - FTM instance number 0..3
 */
void init_ftm_pins(uint32_t instance);
/*!
 * @brief FTM method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         FTM0, FTM1, FTM2, FTM3
 *         peripherals.
 * @param instance - FTM instance number 0..3
 */
void deinit_ftm_pins(uint32_t instance);
/*!
 * @brief GPIO method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         PTA, PTB, PTC, PTD, PTE
 *         peripherals.
 * @param instance - GPIO instance number 0..4
 */
void init_gpio_pins(uint32_t instance);
/*!
 * @brief GPIO method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         PTA, PTB, PTC, PTD, PTE
 *         peripherals.
 * @param instance - GPIO instance number 0..4
 */
void deinit_gpio_pins(uint32_t instance);
/*!
 * @brief I2C method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         I2C0, I2C1, I2C2
 *         peripherals.
 * @param instance - I2C instance number 0..2
 */
void init_i2c_pins(uint32_t instance);
/*!
 * @brief I2C method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         I2C0, I2C1, I2C2
 *         peripherals.
 * @param instance - I2C instance number 0..2
 */
void deinit_i2c_pins(uint32_t instance);
/*!
 * @brief I2S method sets registers according routing settings. Call
 *         this method code to route desired pins into I2S0 periphery.
 * @param instance - I2S instance number (0 is expected)
 */
void init_i2s_pins(uint32_t instance);
/*!
 * @brief I2S method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for I2S0 periphery.
 * @param instance - I2S instance number (0 is expected)
 */
void deinit_i2s_pins(uint32_t instance);
/*!
 * @brief JTAG method sets registers according routing settings. Call
 *         this method code to route desired pins into JTAG periphery.
 * @param instance - JTAG instance number (0 is expected)
 */
void init_jtag_pins(uint32_t instance);
/*!
 * @brief JTAG method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for JTAG periphery.
 * @param instance - JTAG instance number (0 is expected)
 */
void deinit_jtag_pins(uint32_t instance);
/*!
 * @brief LLWU method sets registers according routing settings. Call
 *         this method code to route desired pins into LLWU periphery.
 * @param instance - LLWU instance number (0 is expected)
 */
void init_llwu_pins(uint32_t instance);
/*!
 * @brief LLWU method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for LLWU periphery.
 * @param instance - LLWU instance number (0 is expected)
 */
void deinit_llwu_pins(uint32_t instance);
/*!
 * @brief LPTMR method sets registers according routing settings. Call
 *         this method code to route desired pins into LPTMR0 periphery.
 * @param instance - LPTMR instance number (0 is expected)
 */
void init_lptmr_pins(uint32_t instance);
/*!
 * @brief LPTMR method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for LPTMR0 periphery.
 * @param instance - LPTMR instance number (0 is expected)
 */
void deinit_lptmr_pins(uint32_t instance);
/*!
 * @brief OSC method sets registers according routing settings. Call
 *         this method code to route desired pins into OSC periphery.
 * @param instance - OSC instance number (0 is expected)
 */
void init_osc_pins(uint32_t instance);
/*!
 * @brief OSC method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for OSC periphery.
 * @param instance - OSC instance number (0 is expected)
 */
void deinit_osc_pins(uint32_t instance);
/*!
 * @brief PDB method sets registers according routing settings. Call
 *         this method code to route desired pins into PDB0 periphery.
 * @param instance - PDB instance number (0 is expected)
 */
void init_pdb_pins(uint32_t instance);
/*!
 * @brief PDB method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for PDB0 periphery.
 * @param instance - PDB instance number (0 is expected)
 */
void deinit_pdb_pins(uint32_t instance);
/*!
 * @brief RCM method sets registers according routing settings. Call
 *         this method code to route desired pins into RCM periphery.
 * @param instance - RCM instance number (0 is expected)
 */
void init_rcm_pins(uint32_t instance);
/*!
 * @brief RCM method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for RCM periphery.
 * @param instance - RCM instance number (0 is expected)
 */
void deinit_rcm_pins(uint32_t instance);
/*!
 * @brief RTC method sets registers according routing settings. Call
 *         this method code to route desired pins into RTC periphery.
 * @param instance - RTC instance number (0 is expected)
 */
void init_rtc_pins(uint32_t instance);
/*!
 * @brief RTC method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for RTC periphery.
 * @param instance - RTC instance number (0 is expected)
 */
void deinit_rtc_pins(uint32_t instance);
/*!
 * @brief SCB method sets registers according routing settings. Call
 *         this method code to route desired pins into SystemControl periphery.
 * @param instance - SCB instance number (0 is expected)
 */
void init_scb_pins(uint32_t instance);
/*!
 * @brief SCB method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for SystemControl periphery.
 * @param instance - SCB instance number (0 is expected)
 */
void deinit_scb_pins(uint32_t instance);
/*!
 * @brief SDHC method sets registers according routing settings. Call
 *         this method code to route desired pins into SDHC periphery.
 * @param instance - SDHC instance number (0 is expected)
 */
void init_sdhc_pins(uint32_t instance);
/*!
 * @brief SDHC method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for SDHC periphery.
 * @param instance - SDHC instance number (0 is expected)
 */
void deinit_sdhc_pins(uint32_t instance);
/*!
 * @brief SIM method sets registers according routing settings. Call
 *         this method code to route desired pins into SIM periphery.
 * @param instance - SIM instance number (0 is expected)
 */
void init_sim_pins(uint32_t instance);
/*!
 * @brief SIM method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for SIM periphery.
 * @param instance - SIM instance number (0 is expected)
 */
void deinit_sim_pins(uint32_t instance);
/*!
 * @brief SPI method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         SPI0, SPI1, SPI2
 *         peripherals.
 * @param instance - SPI instance number 0..2
 */
void init_spi_pins(uint32_t instance);
/*!
 * @brief SPI method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         SPI0, SPI1, SPI2
 *         peripherals.
 * @param instance - SPI instance number 0..2
 */
void deinit_spi_pins(uint32_t instance);
/*!
 * @brief SUPPLY method sets registers according routing settings. Call
 *         this method code to route desired pins into SUPPLY periphery.
 * @param instance - SUPPLY instance number (0 is expected)
 */
void init_supply_pins(uint32_t instance);
/*!
 * @brief SUPPLY method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for SUPPLY periphery.
 * @param instance - SUPPLY instance number (0 is expected)
 */
void deinit_supply_pins(uint32_t instance);
/*!
 * @brief TPIU method sets registers according routing settings. Call
 *         this method code to route desired pins into TPIU periphery.
 * @param instance - TPIU instance number (0 is expected)
 */
void init_tpiu_pins(uint32_t instance);
/*!
 * @brief TPIU method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for TPIU periphery.
 * @param instance - TPIU instance number (0 is expected)
 */
void deinit_tpiu_pins(uint32_t instance);
/*!
 * @brief UART method sets registers according routing settings. Call
 *         this method code to route desired pins into:
 *         UART0, UART1, UART2, UART3, UART4, UART5
 *         peripherals.
 * @param instance - UART instance number 0..5
 */
void init_uart_pins(uint32_t instance);
/*!
 * @brief UART method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for:
 *         UART0, UART1, UART2, UART3, UART4, UART5
 *         peripherals.
 * @param instance - UART instance number 0..5
 */
void deinit_uart_pins(uint32_t instance);
/*!
 * @brief USB method sets registers according routing settings. Call
 *         this method code to route desired pins into USB0 periphery.
 * @param instance - USB instance number (0 is expected)
 */
void init_usb_pins(uint32_t instance);
/*!
 * @brief USB method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for USB0 periphery.
 * @param instance - USB instance number (0 is expected)
 */
void deinit_usb_pins(uint32_t instance);
/*!
 * @brief USBDCD method sets registers according routing settings. Call
 *         this method code to route desired pins into USBDCD periphery.
 * @param instance - USBDCD instance number (0 is expected)
 */
void init_usbdcd_pins(uint32_t instance);
/*!
 * @brief USBDCD method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for USBDCD periphery.
 * @param instance - USBDCD instance number (0 is expected)
 */
void deinit_usbdcd_pins(uint32_t instance);
/*!
 * @brief VREF method sets registers according routing settings. Call
 *         this method code to route desired pins into VREF periphery.
 * @param instance - VREF instance number (0 is expected)
 */
void init_vref_pins(uint32_t instance);
/*!
 * @brief VREF method sets registers according routing settings. Call
 *         this method code to disable routing of desired pins for VREF periphery.
 * @param instance - VREF instance number (0 is expected)
 */
void deinit_vref_pins(uint32_t instance);

/* END pin_init. */
#endif /* #ifndef __pin_init_H_ */
/*!
** @}
*/
/*
** ###################################################################
**
**     This file was created by Processor Expert 10.5 [05.21]
**     for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/


text:
package org.apache.asterix.runtime.evaluators.functions;

import java.io.DataOutput;

import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ADayTimeDurationSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AFloatSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
import org.apache.asterix.formats.nontagged.SerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableDate;
import org.apache.asterix.om.base.AMutableDateTime;
import org.apache.asterix.om.base.AMutableDouble;
import org.apache.asterix.om.base.AMutableDuration;
import org.apache.asterix.om.base.AMutableFloat;
import org.apache.asterix.om.base.AMutableInt16;
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
import org.apache.asterix.om.base.AMutableTime;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.exceptions.IncompatibleTypeException;
import org.apache.asterix.runtime.exceptions.OverflowException;
import org.apache.asterix.runtime.exceptions.TypeMismatchException;
import org.apache.asterix.runtime.exceptions.UnderflowException;
import org.apache.asterix.runtime.exceptions.UnsupportedTypeException;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;

@SuppressWarnings("serial")
public abstract class AbstractNumericArithmeticEval extends AbstractScalarFunctionDynamicDescriptor {

    abstract protected long evaluateInteger(long lhs, long rhs) throws HyracksDataException;

    abstract protected double evaluateDouble(double lhs, double rhs) throws HyracksDataException;

    /**
     * abstract method for arithmetic operation between a time instance (date/time/datetime)
     * and a duration (duration/year-month-duration/day-time-duration)
     *
     * @param chronon
     * @param yearMonth
     * @param dayTime
     * @return
     * @throws HyracksDataException
     */
    abstract protected long evaluateTimeDurationArithmetic(long chronon, int yearMonth, long dayTime,
            boolean isTimeOnly) throws HyracksDataException;

    /**
     * abstract method for arithmetic operation between two time instances (date/time/datetime)
     *
     * @param chronon0
     * @param chronon1
     * @return
     * @throws HyracksDataException
     */
    abstract protected long evaluateTimeInstanceArithmetic(long chronon0, long chronon1) throws HyracksDataException;

    @Override
    public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
            throws AlgebricksException {
        return new IScalarEvaluatorFactory() {
            private static final long serialVersionUID = 1L;

            @Override
            public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException {

                return new IScalarEvaluator() {
                    private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
                    private DataOutput out = resultStorage.getDataOutput();
                    private IPointable argPtr0 = new VoidPointable();
                    private IPointable argPtr1 = new VoidPointable();
                    private IScalarEvaluator evalLeft = args[0].createScalarEvaluator(ctx);
                    private IScalarEvaluator evalRight = args[1].createScalarEvaluator(ctx);
                    private double[] operandsFloating = new double[args.length];
                    private long[] operandsInteger = new long[args.length];
                    private int resultType;
                    static protected final int typeInt8 = 1;
                    static protected final int typeInt16 = 2;
                    static protected final int typeInt32 = 3;
                    static protected final int typeInt64 = 4;
                    static protected final int typeFloat = 5;
                    static protected final int typeDouble = 6;

                    protected AMutableFloat aFloat = new AMutableFloat(0);
                    protected AMutableDouble aDouble = new AMutableDouble(0);
                    protected AMutableInt64 aInt64 = new AMutableInt64(0);
                    protected AMutableInt32 aInt32 = new AMutableInt32(0);
                    protected AMutableInt16 aInt16 = new AMutableInt16((short) 0);
                    protected AMutableInt8 aInt8 = new AMutableInt8((byte) 0);

                    protected AMutableDuration aDuration = new AMutableDuration(0, 0);
                    protected AMutableDate aDate = new AMutableDate(0);
                    protected AMutableTime aTime = new AMutableTime(0);
                    protected AMutableDateTime aDatetime = new AMutableDateTime(0);

                    private ATypeTag typeTag;
                    @SuppressWarnings("rawtypes")
                    private ISerializerDeserializer serde;

                    @SuppressWarnings("unchecked")
                    @Override
                    public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
                        resultStorage.reset();
                        resultType = 0;
                        int currentType;
                        evalLeft.evaluate(tuple, argPtr0);
                        evalRight.evaluate(tuple, argPtr1);

                        for (int i = 0; i < args.length; i++) {
                            IPointable argPtr = i == 0 ? argPtr0 : argPtr1;
                            byte[] bytes = argPtr.getByteArray();
                            int offset = argPtr.getStartOffset();

                            typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
                            switch (typeTag) {
                                case TINYINT:
                                    currentType = typeInt8;
                                    operandsInteger[i] = AInt8SerializerDeserializer.getByte(bytes, offset + 1);
                                    operandsFloating[i] = operandsInteger[i];
                                    break;
                                case SMALLINT:
                                    currentType = typeInt16;
                                    operandsInteger[i] = AInt16SerializerDeserializer.getShort(bytes, offset + 1);
                                    operandsFloating[i] = operandsInteger[i];
                                    break;
                                case INTEGER:
                                    currentType = typeInt32;
                                    operandsInteger[i] = AInt32SerializerDeserializer.getInt(bytes, offset + 1);
                                    operandsFloating[i] = operandsInteger[i];
                                    break;
                                case BIGINT:
                                    currentType = typeInt64;
                                    operandsInteger[i] = AInt64SerializerDeserializer.getLong(bytes, offset + 1);
                                    operandsFloating[i] = operandsInteger[i];
                                    break;
                                case FLOAT:
                                    currentType = typeFloat;
                                    operandsFloating[i] = AFloatSerializerDeserializer.getFloat(bytes, offset + 1);
                                    break;
                                case DOUBLE:
                                    currentType = typeDouble;
                                    operandsFloating[i] = ADoubleSerializerDeserializer.getDouble(bytes, offset + 1);
                                    break;
                                case DATE:
                                case TIME:
                                case DATETIME:
                                case DURATION:
                                case YEARMONTHDURATION:
                                case DAYTIMEDURATION:
                                    evaluateTemporalArthmeticOperation(typeTag);
                                    result.set(resultStorage);
                                    return;
                                default:
                                    throw new TypeMismatchException(getIdentifier(), i, bytes[offset],
                                            ATypeTag.SERIALIZED_INT8_TYPE_TAG, ATypeTag.SERIALIZED_INT16_TYPE_TAG,
                                            ATypeTag.SERIALIZED_INT32_TYPE_TAG, ATypeTag.SERIALIZED_INT64_TYPE_TAG,
                                            ATypeTag.SERIALIZED_FLOAT_TYPE_TAG, ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG,
                                            ATypeTag.SERIALIZED_DATE_TYPE_TAG, ATypeTag.SERIALIZED_TIME_TYPE_TAG,
                                            ATypeTag.SERIALIZED_DATETIME_TYPE_TAG,
                                            ATypeTag.SERIALIZED_DURATION_TYPE_TAG,
                                            ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG,
                                            ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG);
                            }

                            if (resultType < currentType) {
                                resultType = currentType;
                            }
                        }

                        long lres;
                        double dres;
                        switch (resultType) {
                            case typeInt8:
                                serde = SerializerDeserializerProvider.INSTANCE
                                        .getSerializerDeserializer(BuiltinType.AINT8);
                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
                                if (lres > Byte.MAX_VALUE) {
                                    throw new OverflowException(getIdentifier());
                                }
                                if (lres < Byte.MIN_VALUE) {
                                    throw new UnderflowException(getIdentifier());
                                }
                                aInt8.setValue((byte) lres);
                                serde.serialize(aInt8, out);
                                break;
                            case typeInt16:
                                serde = SerializerDeserializerProvider.INSTANCE
                                        .getSerializerDeserializer(BuiltinType.AINT16);
                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
                                if (lres > Short.MAX_VALUE) {
                                    throw new OverflowException(getIdentifier());
                                }
                                if (lres < Short.MIN_VALUE) {
                                    throw new UnderflowException(getIdentifier());
                                }
                                aInt16.setValue((short) lres);
                                serde.serialize(aInt16, out);
                                break;
                            case typeInt32:
                                serde = SerializerDeserializerProvider.INSTANCE
                                        .getSerializerDeserializer(BuiltinType.AINT32);
                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
                                if (lres > Integer.MAX_VALUE) {
                                    throw new OverflowException(getIdentifier());
                                }
                                if (lres < Integer.MIN_VALUE) {
                                    throw new UnderflowException(getIdentifier());
                                }
                                aInt32.setValue((int) lres);
                                serde.serialize(aInt32, out);
                                break;
                            case typeInt64:
                                serde = SerializerDeserializerProvider.INSTANCE
                                        .getSerializerDeserializer(BuiltinType.AINT64);
                                lres = evaluateInteger(operandsInteger[0], operandsInteger[1]);
                                aInt64.setValue(lres);
                                serde.serialize(aInt64, out);
                                break;
                            case typeFloat:
                                serde = SerializerDeserializerProvider.INSTANCE
                                        .getSerializerDeserializer(BuiltinType.AFLOAT);
                                dres = evaluateDouble(operandsFloating[0], operandsFloating[1]);
                                if (dres > Float.MAX_VALUE) {
                                    throw new OverflowException(getIdentifier());
                                }
                                if (dres < -Float.MAX_VALUE) {
                                    throw new UnderflowException(getIdentifier());
                                }
                                aFloat.setValue((float) dres);
                                serde.serialize(aFloat, out);
                                break;
                            case typeDouble:
                                serde = SerializerDeserializerProvider.INSTANCE
                                        .getSerializerDeserializer(BuiltinType.ADOUBLE);
                                aDouble.setValue(evaluateDouble(operandsFloating[0], operandsFloating[1]));
                                serde.serialize(aDouble, out);
                                break;
                        }
                        result.set(resultStorage);
                    }

                    @SuppressWarnings("unchecked")
                    private void evaluateTemporalArthmeticOperation(ATypeTag leftType)
                            throws HyracksDataException {
                        byte[] bytes1 = argPtr1.getByteArray();
                        int offset1 = argPtr1.getStartOffset();
                        ATypeTag rightType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
                        byte[] bytes0 = argPtr0.getByteArray();
                        int offset0 = argPtr0.getStartOffset();

                        if (rightType == leftType) {

                            serde = SerializerDeserializerProvider.INSTANCE
                                    .getSerializerDeserializer(BuiltinType.ADURATION);

                            long leftChronon = 0, rightChronon = 0, dayTime = 0;

                            int yearMonth = 0;

                            switch (leftType) {
                                case DATE:
                                    leftChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
                                            * GregorianCalendarSystem.CHRONON_OF_DAY;
                                    rightChronon = ADateSerializerDeserializer.getChronon(bytes1, offset1 + 1)
                                            * GregorianCalendarSystem.CHRONON_OF_DAY;

                                    break;
                                case TIME:
                                    leftChronon = ATimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                    rightChronon = ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                    break;
                                case DATETIME:
                                    leftChronon = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                    rightChronon = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                    break;
                                case YEARMONTHDURATION:
                                    yearMonth = (int) evaluateTimeInstanceArithmetic(
                                            AYearMonthDurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1),
                                            AYearMonthDurationSerializerDeserializer.getYearMonth(bytes1, offset1 + 1));
                                    break;
                                case DAYTIMEDURATION:
                                    leftChronon = ADayTimeDurationSerializerDeserializer.getDayTime(bytes0,
                                            offset0 + 1);
                                    rightChronon = ADayTimeDurationSerializerDeserializer.getDayTime(bytes1,
                                            offset1 + 1);
                                    break;
                                default:
                                    throw new UnsupportedTypeException(getIdentifier(), bytes1[offset1]);
                            }

                            dayTime = evaluateTimeInstanceArithmetic(leftChronon, rightChronon);

                            aDuration.setValue(yearMonth, dayTime);

                            serde.serialize(aDuration, out);

                        } else {
                            long chronon = 0, dayTime = 0;
                            int yearMonth = 0;
                            ATypeTag resultType = null;

                            boolean isTimeOnly = false;

                            switch (leftType) {
                                case TIME:
                                    serde = SerializerDeserializerProvider.INSTANCE
                                            .getSerializerDeserializer(BuiltinType.ATIME);
                                    chronon = ATimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                    isTimeOnly = true;
                                    resultType = ATypeTag.TIME;
                                    switch (rightType) {
                                        case DAYTIMEDURATION:
                                            dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(bytes1,
                                                    offset1 + 1);
                                            break;
                                        case DURATION:
                                            dayTime = ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1);
                                            yearMonth = ADurationSerializerDeserializer.getYearMonth(bytes1,
                                                    offset1 + 1);
                                            break;
                                        default:
                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
                                                    bytes1[offset1]);
                                    }
                                    break;
                                case DATE:
                                    serde = SerializerDeserializerProvider.INSTANCE
                                            .getSerializerDeserializer(BuiltinType.ADATE);
                                    resultType = ATypeTag.DATE;
                                    chronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
                                            * GregorianCalendarSystem.CHRONON_OF_DAY;
                                case DATETIME:
                                    if (leftType == ATypeTag.DATETIME) {
                                        serde = SerializerDeserializerProvider.INSTANCE
                                                .getSerializerDeserializer(BuiltinType.ADATETIME);
                                        resultType = ATypeTag.DATETIME;
                                        chronon = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
                                    }
                                    switch (rightType) {
                                        case DURATION:
                                            yearMonth = ADurationSerializerDeserializer.getYearMonth(bytes1,
                                                    offset1 + 1);
                                            dayTime = ADurationSerializerDeserializer.getDayTime(bytes1, offset1 + 1);
                                            break;
                                        case YEARMONTHDURATION:
                                            yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(bytes1,
                                                    offset1 + 1);
                                            break;
                                        case DAYTIMEDURATION:
                                            dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(bytes1,
                                                    offset1 + 1);
                                            break;
                                        default:
                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
                                                    bytes1[offset1]);
                                    }
                                    break;
                                case YEARMONTHDURATION:
                                    yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(bytes0,
                                            offset0 + 1);
                                    switch (rightType) {
                                        case DATETIME:
                                            serde = SerializerDeserializerProvider.INSTANCE
                                                    .getSerializerDeserializer(BuiltinType.ADATETIME);
                                            resultType = ATypeTag.DATETIME;
                                            chronon = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                            break;
                                        case DATE:
                                            serde = SerializerDeserializerProvider.INSTANCE
                                                    .getSerializerDeserializer(BuiltinType.ADATE);
                                            resultType = ATypeTag.DATE;
                                            chronon = ADateSerializerDeserializer.getChronon(bytes1, offset1 + 1)
                                                    * GregorianCalendarSystem.CHRONON_OF_DAY;
                                            break;
                                        default:
                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
                                                    bytes1[offset1]);
                                    }
                                    break;
                                case DURATION:
                                    yearMonth = ADurationSerializerDeserializer.getYearMonth(bytes0, offset0 + 1);
                                    dayTime = ADurationSerializerDeserializer.getDayTime(bytes0, offset0 + 1);
                                case DAYTIMEDURATION:
                                    if (leftType == ATypeTag.DAYTIMEDURATION) {
                                        dayTime = ADayTimeDurationSerializerDeserializer.getDayTime(bytes0,
                                                offset0 + 1);
                                    }
                                    switch (rightType) {
                                        case DATETIME:
                                            serde = SerializerDeserializerProvider.INSTANCE
                                                    .getSerializerDeserializer(BuiltinType.ADATETIME);
                                            resultType = ATypeTag.DATETIME;
                                            chronon = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                            break;
                                        case DATE:
                                            serde = SerializerDeserializerProvider.INSTANCE
                                                    .getSerializerDeserializer(BuiltinType.ADATE);
                                            resultType = ATypeTag.DATE;
                                            chronon = ADateSerializerDeserializer.getChronon(bytes1, offset1 + 1)
                                                    * GregorianCalendarSystem.CHRONON_OF_DAY;
                                            break;
                                        case TIME:
                                            if (yearMonth == 0) {
                                                serde = SerializerDeserializerProvider.INSTANCE
                                                        .getSerializerDeserializer(BuiltinType.ATIME);
                                                resultType = ATypeTag.TIME;
                                                chronon = ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
                                                isTimeOnly = true;
                                                break;
                                            }
                                        default:
                                            throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
                                                    bytes1[offset1]);
                                    }
                                    break;
                                default:
                                    throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
                                            bytes1[offset1]);
                            }

                            chronon = evaluateTimeDurationArithmetic(chronon, yearMonth, dayTime, isTimeOnly);

                            switch (resultType) {
                                case DATE:
                                    if (chronon < 0 && chronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
                                        chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY - 1;
                                    } else {
                                        chronon = chronon / GregorianCalendarSystem.CHRONON_OF_DAY;
                                    }
                                    aDate.setValue((int) chronon);
                                    serde.serialize(aDate, out);
                                    break;
                                case TIME:
                                    aTime.setValue((int) chronon);
                                    serde.serialize(aTime, out);
                                    break;
                                case DATETIME:
                                    aDatetime.setValue(chronon);
                                    serde.serialize(aDatetime, out);
                                    break;
                                default:
                                    throw new IncompatibleTypeException(getIdentifier(), bytes0[offset0],
                                            bytes1[offset1]);
                            }
                        }
                    }
                };
            }
        };
    }
}