text:
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm              %s | FileCheck %s -check-prefix=NO__ERRNO
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
// RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN

// Test attributes and codegen of math builtins.

void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
  f = __builtin_fmod(f,f);    f = __builtin_fmodf(f,f);   f =  __builtin_fmodl(f,f);

// NO__ERRNO: frem double
// NO__ERRNO: frem float
// NO__ERRNO: frem x86_fp80
// HAS_ERRNO: declare double @fmod(double, double) [[NOT_READNONE:#[0-9]+]]
// HAS_ERRNO: declare float @fmodf(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_atan2(f,f);    __builtin_atan2f(f,f) ;  __builtin_atan2l(f, f);

// NO__ERRNO: declare double @atan2(double, double) [[READNONE:#[0-9]+]]
// NO__ERRNO: declare float @atan2f(float, float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @atan2(double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @atan2f(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_copysign(f,f); __builtin_copysignf(f,f); __builtin_copysignl(f,f); __builtin_copysignf128(f,f);

// NO__ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// NO__ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.copysign.f128(fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.copysign.f128(fp128, fp128) [[READNONE_INTRINSIC]]

  __builtin_fabs(f);       __builtin_fabsf(f);      __builtin_fabsl(f); __builtin_fabsf128(f);

// NO__ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]

  __builtin_frexp(f,i);    __builtin_frexpf(f,i);   __builtin_frexpl(f,i);

// NO__ERRNO: declare double @frexp(double, i32*) [[NOT_READNONE:#[0-9]+]]
// NO__ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare double @frexp(double, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]

  __builtin_huge_val();    __builtin_huge_valf();   __builtin_huge_vall(); __builtin_huge_valf128();

// NO__ERRNO-NOT: .huge
// NO__ERRNO-NOT: @huge
// HAS_ERRNO-NOT: .huge
// HAS_ERRNO-NOT: @huge

  __builtin_inf();    __builtin_inff();   __builtin_infl(); __builtin_inff128();

// NO__ERRNO-NOT: .inf
// NO__ERRNO-NOT: @inf
// HAS_ERRNO-NOT: .inf
// HAS_ERRNO-NOT: @inf

  __builtin_ldexp(f,f);    __builtin_ldexpf(f,f);   __builtin_ldexpl(f,f);

// NO__ERRNO: declare double @ldexp(double, i32) [[READNONE]]
// NO__ERRNO: declare float @ldexpf(float, i32) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @ldexpl(x86_fp80, i32) [[READNONE]]
// HAS_ERRNO: declare double @ldexp(double, i32) [[NOT_READNONE]]
// HAS_ERRNO: declare float @ldexpf(float, i32) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @ldexpl(x86_fp80, i32) [[NOT_READNONE]]

  __builtin_modf(f,d);       __builtin_modff(f,fp);      __builtin_modfl(f,l);

// NO__ERRNO: declare double @modf(double, double*) [[NOT_READNONE]]
// NO__ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]
// HAS_ERRNO: declare double @modf(double, double*) [[NOT_READNONE]]
// HAS_ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]

  __builtin_nan(c);        __builtin_nanf(c);       __builtin_nanl(c); __builtin_nanf128(c);

// NO__ERRNO: declare double @nan(i8*) [[PURE:#[0-9]+]]
// NO__ERRNO: declare float @nanf(i8*) [[PURE]]
// NO__ERRNO: declare x86_fp80 @nanl(i8*) [[PURE]]
// NO__ERRNO: declare fp128 @nanf128(i8*) [[PURE]]
// HAS_ERRNO: declare double @nan(i8*) [[PURE:#[0-9]+]]
// HAS_ERRNO: declare float @nanf(i8*) [[PURE]]
// HAS_ERRNO: declare x86_fp80 @nanl(i8*) [[PURE]]
// HAS_ERRNO: declare fp128 @nanf128(i8*) [[PURE]]

  __builtin_nans(c);        __builtin_nansf(c);       __builtin_nansl(c); __builtin_nansf128(c);

// NO__ERRNO: declare double @nans(i8*) [[PURE]]
// NO__ERRNO: declare float @nansf(i8*) [[PURE]]
// NO__ERRNO: declare x86_fp80 @nansl(i8*) [[PURE]]
// NO__ERRNO: declare fp128 @nansf128(i8*) [[PURE]]
// HAS_ERRNO: declare double @nans(i8*) [[PURE]]
// HAS_ERRNO: declare float @nansf(i8*) [[PURE]]
// HAS_ERRNO: declare x86_fp80 @nansl(i8*) [[PURE]]
// HAS_ERRNO: declare fp128 @nansf128(i8*) [[PURE]]

  __builtin_pow(f,f);        __builtin_powf(f,f);       __builtin_powl(f,f);

// NO__ERRNO: declare double @llvm.pow.f64(double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.pow.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @pow(double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @powf(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @powl(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_powi(f,f);        __builtin_powif(f,f);       __builtin_powil(f,f);

// NO__ERRNO: declare double @llvm.powi.f64(double, i32) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.powi.f32(float, i32) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.powi.f80(x86_fp80, i32) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.powi.f64(double, i32) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.powi.f32(float, i32) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.powi.f80(x86_fp80, i32) [[READNONE_INTRINSIC]]

  /* math */
  __builtin_acos(f);       __builtin_acosf(f);      __builtin_acosl(f);

// NO__ERRNO: declare double @acos(double) [[READNONE]]
// NO__ERRNO: declare float @acosf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @acosl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @acos(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @acosf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @acosl(x86_fp80) [[NOT_READNONE]]

  __builtin_acosh(f);      __builtin_acoshf(f);     __builtin_acoshl(f);

// NO__ERRNO: declare double @acosh(double) [[READNONE]]
// NO__ERRNO: declare float @acoshf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @acoshl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @acosh(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @acoshf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @acoshl(x86_fp80) [[NOT_READNONE]]

  __builtin_asin(f);       __builtin_asinf(f);      __builtin_asinl(f);

// NO__ERRNO: declare double @asin(double) [[READNONE]]
// NO__ERRNO: declare float @asinf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @asinl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @asin(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @asinf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @asinl(x86_fp80) [[NOT_READNONE]]

  __builtin_asinh(f);      __builtin_asinhf(f);     __builtin_asinhl(f);

// NO__ERRNO: declare double @asinh(double) [[READNONE]]
// NO__ERRNO: declare float @asinhf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @asinhl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @asinh(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @asinhf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @asinhl(x86_fp80) [[NOT_READNONE]]

  __builtin_atan(f);       __builtin_atanf(f);      __builtin_atanl(f);

// NO__ERRNO: declare double @atan(double) [[READNONE]]
// NO__ERRNO: declare float @atanf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @atanl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @atan(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @atanf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atanl(x86_fp80) [[NOT_READNONE]]

  __builtin_atanh(f);      __builtin_atanhf(f);     __builtin_atanhl(f);

// NO__ERRNO: declare double @atanh(double) [[READNONE]]
// NO__ERRNO: declare float @atanhf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @atanhl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @atanh(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @atanhf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atanhl(x86_fp80) [[NOT_READNONE]]

  __builtin_cbrt(f);       __builtin_cbrtf(f);      __builtin_cbrtl(f);

// NO__ERRNO: declare double @cbrt(double) [[READNONE]]
// NO__ERRNO: declare float @cbrtf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @cbrt(double) [[READNONE:#[0-9]+]]
// HAS_ERRNO: declare float @cbrtf(float) [[READNONE]]
// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]]

  __builtin_ceil(f);       __builtin_ceilf(f);      __builtin_ceill(f);

// NO__ERRNO: declare double @llvm.ceil.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.ceil.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.ceil.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.ceil.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.ceil.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.ceil.f80(x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_cos(f);        __builtin_cosf(f);       __builtin_cosl(f);

// NO__ERRNO: declare double @llvm.cos.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.cos.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.cos.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @cos(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @cosf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @cosl(x86_fp80) [[NOT_READNONE]]

  __builtin_cosh(f);       __builtin_coshf(f);      __builtin_coshl(f);

// NO__ERRNO: declare double @cosh(double) [[READNONE]]
// NO__ERRNO: declare float @coshf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @coshl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @cosh(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @coshf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @coshl(x86_fp80) [[NOT_READNONE]]

  __builtin_erf(f);        __builtin_erff(f);       __builtin_erfl(f);

// NO__ERRNO: declare double @erf(double) [[READNONE]]
// NO__ERRNO: declare float @erff(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @erfl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @erf(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @erff(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @erfl(x86_fp80) [[NOT_READNONE]]

  __builtin_erfc(f);       __builtin_erfcf(f);      __builtin_erfcl(f);

// NO__ERRNO: declare double @erfc(double) [[READNONE]]
// NO__ERRNO: declare float @erfcf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @erfcl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @erfc(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @erfcf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @erfcl(x86_fp80) [[NOT_READNONE]]

  __builtin_exp(f);        __builtin_expf(f);       __builtin_expl(f);

// NO__ERRNO: declare double @llvm.exp.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.exp.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.exp.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @exp(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @expf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @expl(x86_fp80) [[NOT_READNONE]]

  __builtin_exp2(f);       __builtin_exp2f(f);      __builtin_exp2l(f);

// NO__ERRNO: declare double @llvm.exp2.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.exp2.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.exp2.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @exp2(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @exp2f(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @exp2l(x86_fp80) [[NOT_READNONE]]

  __builtin_expm1(f);      __builtin_expm1f(f);     __builtin_expm1l(f);

// NO__ERRNO: declare double @expm1(double) [[READNONE]]
// NO__ERRNO: declare float @expm1f(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @expm1l(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @expm1(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @expm1f(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @expm1l(x86_fp80) [[NOT_READNONE]]

  __builtin_fdim(f,f);       __builtin_fdimf(f,f);      __builtin_fdiml(f,f);

// NO__ERRNO: declare double @fdim(double, double) [[READNONE]]
// NO__ERRNO: declare float @fdimf(float, float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @fdiml(x86_fp80, x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @fdim(double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @fdimf(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @fdiml(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_floor(f);      __builtin_floorf(f);     __builtin_floorl(f);

// NO__ERRNO: declare double @llvm.floor.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.floor.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.floor.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.floor.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.floor.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.floor.f80(x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_fma(f,f,f);        __builtin_fmaf(f,f,f);       __builtin_fmal(f,f,f);

// NO__ERRNO: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @fma(double, double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @fmaf(float, float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @fmal(x86_fp80, x86_fp80, x86_fp80) [[NOT_READNONE]]

// On GNU or Win, fma never sets errno, so we can convert to the intrinsic.

// HAS_ERRNO_GNU: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]

// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]

// HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// Long double is just double on win, so no f80 use/declaration.
// HAS_ERRNO_WIN-NOT: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80)

  __builtin_fmax(f,f);       __builtin_fmaxf(f,f);      __builtin_fmaxl(f,f);

// NO__ERRNO: declare double @llvm.maxnum.f64(double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.maxnum.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.maxnum.f64(double, double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.maxnum.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_fmin(f,f);       __builtin_fminf(f,f);      __builtin_fminl(f,f);

// NO__ERRNO: declare double @llvm.minnum.f64(double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.minnum.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.minnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.minnum.f64(double, double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.minnum.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.minnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_hypot(f,f);      __builtin_hypotf(f,f);     __builtin_hypotl(f,f);

// NO__ERRNO: declare double @hypot(double, double) [[READNONE]]
// NO__ERRNO: declare float @hypotf(float, float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @hypotl(x86_fp80, x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @hypot(double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @hypotf(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @hypotl(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_ilogb(f);      __builtin_ilogbf(f);     __builtin_ilogbl(f);

// NO__ERRNO: declare i32 @ilogb(double) [[READNONE]]
// NO__ERRNO: declare i32 @ilogbf(float) [[READNONE]]
// NO__ERRNO: declare i32 @ilogbl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare i32 @ilogb(double) [[NOT_READNONE]]
// HAS_ERRNO: declare i32 @ilogbf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare i32 @ilogbl(x86_fp80) [[NOT_READNONE]]

  __builtin_lgamma(f);     __builtin_lgammaf(f);    __builtin_lgammal(f);

// NO__ERRNO: declare double @lgamma(double) [[NOT_READNONE]]
// NO__ERRNO: declare float @lgammaf(float) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NOT_READNONE]]
// HAS_ERRNO: declare double @lgamma(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @lgammaf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @lgammal(x86_fp80) [[NOT_READNONE]]

  __builtin_llrint(f);     __builtin_llrintf(f);    __builtin_llrintl(f);

// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @llrint(double) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llrintf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llrintl(x86_fp80) [[NOT_READNONE]]

  __builtin_llround(f);    __builtin_llroundf(f);   __builtin_llroundl(f);

// NO__ERRNO: declare i64 @llvm.llround.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llround.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @llround(double) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llroundf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llroundl(x86_fp80) [[NOT_READNONE]]

  __builtin_log(f);        __builtin_logf(f);       __builtin_logl(f);

// NO__ERRNO: declare double @llvm.log.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.log.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.log.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @log(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @logf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @logl(x86_fp80) [[NOT_READNONE]]

  __builtin_log10(f);      __builtin_log10f(f);     __builtin_log10l(f);

// NO__ERRNO: declare double @llvm.log10.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.log10.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.log10.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @log10(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @log10f(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @log10l(x86_fp80) [[NOT_READNONE]]

  __builtin_log1p(f);      __builtin_log1pf(f);     __builtin_log1pl(f);

// NO__ERRNO: declare double @log1p(double) [[READNONE]]
// NO__ERRNO: declare float @log1pf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @log1pl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @log1p(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @log1pf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @log1pl(x86_fp80) [[NOT_READNONE]]

  __builtin_log2(f);       __builtin_log2f(f);      __builtin_log2l(f);

// NO__ERRNO: declare double @llvm.log2.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.log2.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.log2.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @log2(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @log2f(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @log2l(x86_fp80) [[NOT_READNONE]]

  __builtin_logb(f);       __builtin_logbf(f);      __builtin_logbl(f);

// NO__ERRNO: declare double @logb(double) [[READNONE]]
// NO__ERRNO: declare float @logbf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @logbl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @logb(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @logbf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @logbl(x86_fp80) [[NOT_READNONE]]

  __builtin_lrint(f);      __builtin_lrintf(f);     __builtin_lrintl(f);

// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @lrint(double) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lrintf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lrintl(x86_fp80) [[NOT_READNONE]]

  __builtin_lround(f);     __builtin_lroundf(f);    __builtin_lroundl(f);

// NO__ERRNO: declare i64 @llvm.lround.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lround.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @lround(double) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lroundf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lroundl(x86_fp80) [[NOT_READNONE]]

  __builtin_nearbyint(f);  __builtin_nearbyintf(f); __builtin_nearbyintl(f);

// NO__ERRNO: declare double @llvm.nearbyint.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.nearbyint.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.nearbyint.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.nearbyint.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.nearbyint.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.nearbyint.f80(x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_nextafter(f,f);  __builtin_nextafterf(f,f); __builtin_nextafterl(f,f);

// NO__ERRNO: declare double @nextafter(double, double) [[READNONE]]
// NO__ERRNO: declare float @nextafterf(float, float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @nextafterl(x86_fp80, x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @nextafter(double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @nextafterf(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @nextafterl(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_nexttoward(f,f); __builtin_nexttowardf(f,f);__builtin_nexttowardl(f,f);

// NO__ERRNO: declare double @nexttoward(double, x86_fp80) [[READNONE]]
// NO__ERRNO: declare float @nexttowardf(float, x86_fp80) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @nexttowardl(x86_fp80, x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @nexttoward(double, x86_fp80) [[NOT_READNONE]]
// HAS_ERRNO: declare float @nexttowardf(float, x86_fp80) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @nexttowardl(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_remainder(f,f);  __builtin_remainderf(f,f); __builtin_remainderl(f,f);

// NO__ERRNO: declare double @remainder(double, double) [[READNONE]]
// NO__ERRNO: declare float @remainderf(float, float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @remainderl(x86_fp80, x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @remainder(double, double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @remainderf(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @remainderl(x86_fp80, x86_fp80) [[NOT_READNONE]]

  __builtin_remquo(f,f,i);  __builtin_remquof(f,f,i); __builtin_remquol(f,f,i);

// NO__ERRNO: declare double @remquo(double, double, i32*) [[NOT_READNONE]]
// NO__ERRNO: declare float @remquof(float, float, i32*) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @remquol(x86_fp80, x86_fp80, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare double @remquo(double, double, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare float @remquof(float, float, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @remquol(x86_fp80, x86_fp80, i32*) [[NOT_READNONE]]

  __builtin_rint(f);       __builtin_rintf(f);      __builtin_rintl(f);

// NO__ERRNO: declare double @llvm.rint.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.rint.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.rint.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.rint.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.rint.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.rint.f80(x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_round(f);      __builtin_roundf(f);     __builtin_roundl(f);

// NO__ERRNO: declare double @llvm.round.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.round.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.round.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.round.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.round.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.round.f80(x86_fp80) [[READNONE_INTRINSIC]]

  __builtin_scalbln(f,f);    __builtin_scalblnf(f,f);   __builtin_scalblnl(f,f);

// NO__ERRNO: declare double @scalbln(double, i64) [[READNONE]]
// NO__ERRNO: declare float @scalblnf(float, i64) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @scalblnl(x86_fp80, i64) [[READNONE]]
// HAS_ERRNO: declare double @scalbln(double, i64) [[NOT_READNONE]]
// HAS_ERRNO: declare float @scalblnf(float, i64) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @scalblnl(x86_fp80, i64) [[NOT_READNONE]]

  __builtin_scalbn(f,f);     __builtin_scalbnf(f,f);    __builtin_scalbnl(f,f);

// NO__ERRNO: declare double @scalbn(double, i32) [[READNONE]]
// NO__ERRNO: declare float @scalbnf(float, i32) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @scalbnl(x86_fp80, i32) [[READNONE]]
// HAS_ERRNO: declare double @scalbn(double, i32) [[NOT_READNONE]]
// HAS_ERRNO: declare float @scalbnf(float, i32) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @scalbnl(x86_fp80, i32) [[NOT_READNONE]]

  __builtin_sin(f);        __builtin_sinf(f);       __builtin_sinl(f);

// NO__ERRNO: declare double @llvm.sin.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.sin.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.sin.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @sin(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @sinf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @sinl(x86_fp80) [[NOT_READNONE]]

  __builtin_sinh(f);       __builtin_sinhf(f);      __builtin_sinhl(f);

// NO__ERRNO: declare double @sinh(double) [[READNONE]]
// NO__ERRNO: declare float @sinhf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @sinhl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @sinh(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @sinhf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @sinhl(x86_fp80) [[NOT_READNONE]]

  __builtin_sqrt(f);       __builtin_sqrtf(f);      __builtin_sqrtl(f);

// NO__ERRNO: declare double @llvm.sqrt.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.sqrt.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.sqrt.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @sqrt(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @sqrtf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @sqrtl(x86_fp80) [[NOT_READNONE]]

  __builtin_tan(f);        __builtin_tanf(f);       __builtin_tanl(f);

// NO__ERRNO: declare double @tan(double) [[READNONE]]
// NO__ERRNO: declare float @tanf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @tanl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @tan(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @tanf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @tanl(x86_fp80) [[NOT_READNONE]]

  __builtin_tanh(f);       __builtin_tanhf(f);      __builtin_tanhl(f);

// NO__ERRNO: declare double @tanh(double) [[READNONE]]
// NO__ERRNO: declare float @tanhf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @tanhl(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @tanh(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @tanhf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @tanhl(x86_fp80) [[NOT_READNONE]]

  __builtin_tgamma(f);     __builtin_tgammaf(f);    __builtin_tgammal(f);

// NO__ERRNO: declare double @tgamma(double) [[READNONE]]
// NO__ERRNO: declare float @tgammaf(float) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @tgammal(x86_fp80) [[READNONE]]
// HAS_ERRNO: declare double @tgamma(double) [[NOT_READNONE]]
// HAS_ERRNO: declare float @tgammaf(float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @tgammal(x86_fp80) [[NOT_READNONE]]

  __builtin_trunc(f);      __builtin_truncf(f);     __builtin_truncl(f);

// NO__ERRNO: declare double @llvm.trunc.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.trunc.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.trunc.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.trunc.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.trunc.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.trunc.f80(x86_fp80) [[READNONE_INTRINSIC]]
};

// NO__ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
// NO__ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} }
// NO__ERRNO: attributes [[PURE]] = { {{.*}}readonly{{.*}} }

// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} }
// HAS_ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// HAS_ERRNO: attributes [[PURE]] = { {{.*}}readonly{{.*}} }
// HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }

// HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }


text:
import styled from 'styled-components'

import { COLORS, GRADIENT } from '../constants'

const CtaButton = styled.a`
  background-color: ${COLORS.fade};
  margin-top: 16px;
  padding: 24px;
  position: relative;
  z-index: 10;

  text-decoration: none;

  &:before {
    content: '';
    background: ${GRADIENT};
    position: absolute;
    width: 0%;
    top: 0;
    left: 0;
    height: 100%;
    transition: 0.3s linear;
    z-index: -1;
  }

  &:hover:before {
    width: 100%;
  }
`

export default CtaButton

redpajama_set_name: RedPajamaGithub


text:
from djangoappengine.db.utils import get_cursor, set_cursor, set_config

from google.appengine.api.datastore import Key

from mapreduce.datastore_range_iterators import AbstractKeyRangeIterator, _KEY_RANGE_ITERATORS
from mapreduce.input_readers import AbstractDatastoreInputReader, _get_params, BadReaderParamsError
from mapreduce import util

class DjangoModelIterator(AbstractKeyRangeIterator):
    def __iter__(self):
        k_range = self._key_range

        # Namespaces are not supported by djangoappengine
        if k_range.namespace:
            return

        model_class = util.for_name(self._query_spec.model_class_path)

        q = model_class.objects.all()

        if k_range.key_start:
            if k_range.include_start:
                q = q.filter(pk__gte=k_range.key_start.id_or_name())
            else:
                q = q.filter(pk__gt=k_range.key_start.id_or_name())

        if k_range.key_end:
            if k_range.include_end:
                q = q.filter(pk__lte=k_range.key_end.id_or_name())
            else:
                q = q.filter(pk__lt=k_range.key_end.id_or_name())

        filters = self._query_spec.filters
        if filters:
            q = q.filter(**dict([[filter[0], filter[2]] for filter in filters]))

        q = q.order_by('pk')

        q = set_config(q, batch_size=self._query_spec.batch_size)

        if self._cursor:
            q = set_cursor(q, self._cursor)

        self._query = q

        for entity in self._query.iterator():
            yield entity

    def _get_cursor(self):
        if self._query is not None:
            return get_cursor(self._query)

_KEY_RANGE_ITERATORS[DjangoModelIterator.__name__] = DjangoModelIterator

class DjangoModelInputReader(AbstractDatastoreInputReader):
    """
    An input reader that takes a Django model ('app.models.Model')
    and yields Django model instances

    Note: This ignores all entities not in the default namespace.
    """

    _KEY_RANGE_ITER_CLS = DjangoModelIterator

    @classmethod
    def _get_raw_entity_kind(cls, entity_kind):
        """Returns an datastore entity kind from a Django model."""
        model_class = util.for_name(entity_kind)
        return model_class._meta.db_table

    @classmethod
    def validate(cls, mapper_spec):
        super(DjangoModelInputReader, cls).validate(mapper_spec)

        params = _get_params(mapper_spec)

        if cls.NAMESPACE_PARAM in params:
            raise BadReaderParamsError("Namespaces are not supported.")

        entity_kind_name = params[cls.ENTITY_KIND_PARAM]
        try:
            util.for_name(entity_kind_name)
        except ImportError, e:
            raise BadReaderParamsError("Bad entity kind: %s" % e)


text:
;Testname=br3028880; Arguments=-Ox -fbin -obr3028880.o; Files=stdout stderr br3028880.o

%macro import 1
	%define %%incfile %!PROJECTBASEDIR/%{1}.inc
%endmacro

import foo


text:
"""middleware that allows anonymous users
receive messages using the now deprecated `message_set()`
interface of the user objects.

To allow anonymous users accept messages, a special
message manager is defined here, and :meth:`__deepcopy__()` method
added to the :class:`AnonymousUser` so that user could be pickled.

Secondly, it sends greeting message to anonymous users.
"""
#from askbot.models import BadgeData, Award, User
from django.conf import settings as django_settings
#from askbot.conf import settings as askbot_settings
from django.contrib.auth.models import User
from website.models import UserDetail
from website.utils.httpUtil import HttpRequestProcessor
import hashlib
from django.db import models

class ProcessPasswordMiddleWare(object):
    """Middleware that attaches messages to anonymous users, and
    makes sure that anonymous user greeting is shown just once.
    Middleware does not do anything if the anonymous user greeting
    is disabled.
    """
    def process_request(self, request):
        """Enables anonymous users to receive messages
        the same way as authenticated users, and sets
        the anonymous user greeting, if it should be shown"""
        requestProcessor = HttpRequestProcessor(request)
        username = requestProcessor.getParameter('username')
        if username == None:
            username = ''
        password = requestProcessor.getParameter('password')
        if password == None:
            password = ''
        #print "username :: " + str(username)
        #print "password :: " + str(password)

        authentication = True
        if username != '' and password != '':
            users_by_username = User.objects.filter(username__exact=username)
            users_by_email = User.objects.filter(email__exact=username)
            if users_by_username:
                user = users_by_username[0]
            elif users_by_email:
                user = users_by_email[0]
            else:
                authentication = False

            if authentication:
                if user.password == '':
                    user_details = UserDetail.objects.filter(user__exact=user)
                    if user_details:
                        user_detail = user_details[0]
                        if user_detail.old_password != '':
                            print "old_password :: " + str(user_detail.old_password)
                            salt = 'W3yZmDNLeykU2GHmPS4K3Rx40T2Q7VlC7Y5P7wi5McL5YvfzGNOahshX2lta1PbP'

                            #print "set_password :: " + password
                            salt_password = password + ':' + salt
                            md5_password = hashlib.md5(salt_password).hexdigest()

                            print "md5_password :: " + str(md5_password)
                            if md5_password == user_detail.old_password:
                                #print "validated against md5.  ok!. save the sha1 version."
                                user.set_password(password)
                                user.save()
                                user_detail.old_password = ''
                                user_detail.save()
                            else:
                                print "validated against md5.  NOT OK!  not save the sha1 version"


text:
echo -e "Gathering info please wait..."

# Get and set variables
circle_dir="./.circleci"
conf_file="./.circleci/config.yml"
vcs_provider="$(git remote get-url --push origin | perl -ne 'print $1 if /([A-Za-z]*)\.(com|org)/')"
project="$(git remote get-url --push origin | perl -ne 'print $1 if /([^\/:]*\/[^\/]*?)(.git)?$/')"
test_branch="circleci-20-test"
remote_test_branch="$(git ls-remote git@"$vcs_provider".com:"${project}".git "$test_branch")"
local_test_branch="$(git branch -a | grep "$test_branch")"

echo "git origin references \`${project}\` hosted by ${vcs_provider}, which will be used as source."

# Check if this is a GitHub or Bitbucket repo
if [ "$vcs_provider" != "github" ] && [ "$vcs_provider" != "bitbucket" ] ; then
  echo -e "CircleCI currently supports bitbucket and github only"
  exit
fi

# Set vcs_short variable
if [ "$vcs_provider" = "github" ]
  then
    vcs_short="gh"
fi

if [ "$vcs_provider" = "bitbucket" ]
  then
    vcs_short="bb"
fi

# Check if test branch exists on remote
if [ -n "$remote_test_branch" ]
  then
    echo -e "${test_branch} branch already exists on remote - please delete it before continuing."
    exit
fi

# Check if branch exists locally and create it if not
if [ -z "$local_test_branch" ]
  then
    git checkout -b ${test_branch} && echo -e "Created ${test_branch} branch and switched to it."
  else
    echo -e "${test_branch} branch already exists locally - please delete it before continuing."
    exit
fi

# Create .cirleci directory if it doesn't exist
if [ ! -d "$circle_dir" ]
  then
    mkdir "$circle_dir"
fi

# Create config.yml if it doesn't exist
if [ ! -d "$conf_file" ]
  then
    touch "$conf_file"
  else
    echo -e ".circleci/config.yml already exists. Please delete it before running this script again."
    exit
fi

# Read in API token
read -rp 'Paste your CircleCI API token here: ' circle_token

# Generate config file from translation endpoint
echo -e "Generating config file via CircleCI API"
curl -X GET https://circleci.com/api/v1.1/project/"${vcs_provider}"/"${project}"/config-translation?circle-token="$circle_token"\&branch=${test_branch} > $conf_file
echo -e "Config file written to .circleci/config.yml"

read -rp 'Would you like to commit this change and push the test branch to try the build on CircleCI? (y/n): ' choice

if [ "$choice" = "y" ]
  then
    git add "$conf_file"
    git commit -m "Adding auto-generated CircleCI 2.0 config file"
    git push origin ${test_branch}
    echo -e "Go to https://circleci.com/$vcs_short/$project to see the new build."
    echo -e "If it passes - congratulations, you're good to go. If it's red, please see the README for next steps."
  else
    echo -e "You can manually trigger a build on CircleCI by committing and pushing this branch to the remote."
    exit
fi


text:
const passport = require('passport');

exports = module.exports = {};

exports.parseChallengeName = str => (
  str.replace(/\s/g, '-')
  .replace(/[^-\w\d]/g, '')
  .replace(/[A-Z]/g, p1 => p1.toLowerCase())
);

exports.checkAuth = (req, res, next) => {
  console.log('REQUESST session:', req.session);
  if (req.isAuthenticated()) {
    console.log('USER AUTHENTICATED', req.session.passport.user.name);
    next();
  } else {
    res.end('ERROR: PLEASE LOGIN');
    // res.redirect('/#/home');
  }
};
// app.get('/checkAuth', checkAuth, (req, res) => {
//   console.log('SESSION', req.session.passport.user);
//   User.findById(req.session.passport.user, (err, user) => {
//     if(err) {
//       console.log(err);  // handle errors
//     } else {
//       res.send('this works');
//     }
//   });
// });


text:
package org.jetbrains.plugins.scala.lang.refactoring.changeSignature

import java.util
import java.util.Comparator

import com.intellij.openapi.project.Project
import com.intellij.refactoring.RefactoringHelper
import com.intellij.usageView.UsageInfo

/**
  * Nikolay.Tropin
  * 12-Jan-17
  */
class ScalaChangeSignatureRefactoringHelper extends RefactoringHelper[Unit] {
  override def prepareOperation(usages: Array[UsageInfo]): Unit = {
    def priority(usageInfo: UsageInfo) = usageInfo match {
      case _: ParameterUsageInfo => 0
      case _: MethodUsageInfo => 1
      case _: AnonFunUsageInfo => 1
      case _: ScalaNamedElementUsageInfo => 2
      case _ => 3
    }

    if (usages.exists(UsageUtil.scalaUsage)) {
      util.Arrays.sort(usages, new Comparator[UsageInfo] {
        override def compare(o1: UsageInfo, o2: UsageInfo): Int = priority(o1) - priority(o2)
      })
    }
  }

  override def performOperation(project: Project, operationData: Unit): Unit = {}
}


text:
using StageBitz.Logic.Business.Inventory;
using StageBitz.Logic.Business.ItemBrief;
using StageBitz.UserWeb.Common.Helpers;
using StageBitz.UserWeb.Controls.Common;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web.UI;

namespace StageBitz.UserWeb.Controls.Item
{
    /// <summary>
    /// Delegate for event when fires document list changed.
    /// </summary>
    public delegate void CompleteItemDocumentListDocumentChanged();

    /// <summary>
    /// The Complete Item Body Control
    /// </summary>
    public partial class CompleteItem : UserControlBase
    {
        #region Events

        /// <summary>
        /// event for notify complete item header when item is deleted from complete item list.
        /// </summary>
        public event CompleteItemDocumentListDocumentChanged CompleteItemDocumentListDocumentChanged;

        #endregion Events

        #region Enums

        /// <summary>
        /// Enum for display mode of the control.
        /// </summary>
        public enum CompleteItemDisplayMode
        {
            ItemDetails,
            ItemBriefDetails
        }

        #endregion Enums

        #region Properties

        /// <summary>
        /// Gets or sets the item brief id.
        /// </summary>
        /// <value>
        /// The item brief id.
        /// </value>
        public int ItemBriefId
        {
            get
            {
                if (ViewState["ItemBriefId"] == null)
                {
                    ViewState["ItemBriefId"] = 0;
                }

                return (int)ViewState["ItemBriefId"];
            }

            set
            {
                ViewState["ItemBriefId"] = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is read only.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is read only; otherwise, <c>false</c>.
        /// </value>
        public bool IsReadOnly
        {
            get
            {
                if (ViewState["IsReadOnly"] == null)
                {
                    return false;
                }
                else
                {
                    return (bool)ViewState["IsReadOnly"];
                }
            }

            set
            {
                ViewState["IsReadOnly"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the item id.
        /// </summary>
        /// <value>
        /// The item id.
        /// </value>
        public int ItemId
        {
            get
            {
                if (ViewState["ItemId"] == null)
                {
                    ViewState["ItemId"] = 0;
                }

                return (int)ViewState["ItemId"];
            }

            set
            {
                ViewState["ItemId"] = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is item created.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is item created; otherwise, <c>false</c>.
        /// </value>
        public bool IsItemCreated
        {
            get
            {
                if (ViewState["IsItemCreated"] == null)
                {
                    return false;
                }
                else
                {
                    return (bool)ViewState["IsItemCreated"];
                }
            }

            set
            {
                ViewState["IsItemCreated"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the validation group.
        /// </summary>
        /// <value>
        /// The validation group.
        /// </value>
        public string ValidationGroup
        {
            get
            {
                if (ViewState["ValidationGroup"] == null)
                {
                    return string.Empty;
                }
                else
                {
                    return ViewState["ValidationGroup"].ToString();
                }
            }

            set
            {
                ViewState["ValidationGroup"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the display mode.
        /// </summary>
        /// <value>
        /// The display mode.
        /// </value>
        public CompleteItemDisplayMode DisplayMode
        {
            get
            {
                if (ViewState["DisplayMode"] == null)
                {
                    return CompleteItemDisplayMode.ItemDetails;
                }
                else
                {
                    return (CompleteItemDisplayMode)ViewState["DisplayMode"];
                }
            }

            set
            {
                ViewState["DisplayMode"] = value;
            }
        }

        /// <summary>
        /// Gets the item document list.
        /// </summary>
        /// <value>
        /// The item document list.
        /// </value>
        public DocumentList ItemDocumentList
        {
            get
            {
                return documentList;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is dirty.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance is dirty; otherwise, <c>false</c>.
        /// </value>
        public bool IsDirty
        {
            get
            {
                bool isDirty = false;
                bool.TryParse(hdnIsDirty.Value, out isDirty);
                return isDirty;
            }

            set
            {
                hdnIsDirty.Value = value.ToString();
            }
        }

        #endregion Properties

        #region Event Handlers

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            documentList.FunctionPrefix = this.ClientID;
            documentPreview.FunctionPrefix = this.ClientID;
            documentPreview.IsTextboxsDisabled = IsReadOnly || ItemBriefId > 0;
            documentPreview.IsReadOnly = IsReadOnly;

            helpTipItemFiles.Position = Telerik.Web.UI.ToolTipPosition.TopRight;
            helpTipItemFiles.RelativeTo = Telerik.Web.UI.ToolTipRelativeDisplay.Mouse;

            documentPreview.InformItemIsDeleted += delegate
            {
                ShowItemDeletedPopUp();
            };
        }

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            RegisterDirtyValidationScripts();
            SendDocumentMediaIdsForCilentSideUsage();
        }

        /// <summary>
        /// Documents the preview_ on document delete clicked.
        /// </summary>
        /// <param name="documentMediaId">The document media id.</param>
        protected void documentPreview_OnDocumentDeleteClicked(int documentMediaId)
        {
            if (!PageBase.StopProcessing)
            {
                List<int> tempExclutionList = documentList.DocumentMediaIdsToExclude;
                tempExclutionList.Add(documentMediaId);
                documentList.DocumentMediaIdsToExclude = tempExclutionList;
                documentList.LoadData();
                upnlDocumentList.Update();
            }
        }

        /// <summary>
        /// Handles the OnDocumentDeleted event of the documentPreview control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void documentPreview_OnDocumentDeleted(object sender, EventArgs e)
        {
            if (!PageBase.StopProcessing)
            {
                if (this.CompleteItemDocumentListDocumentChanged != null)
                {
                    // In the case we are handling the documents in memory for first time of the item completion. Fire an event to reload header control.
                    this.CompleteItemDocumentListDocumentChanged();
                }
            }
        }

        /// <summary>
        /// Handles the OnDocumentAttributesChanged event of the documentPreview control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void documentPreview_OnDocumentAttributesChanged(object sender, EventArgs e)
        {
            if (!PageBase.StopProcessing)
            {
                documentList.LoadData();
                upnlDocumentList.Update();

                if (this.CompleteItemDocumentListDocumentChanged != null)
                {
                    // In the case we are handling the documents in memory for first time of the item completion. Fire an event to reload header control.
                    this.CompleteItemDocumentListDocumentChanged();
                }
            }
        }

        #endregion Event Handlers

        #region Public Methods

        /// <summary>
        /// Loads the control.
        /// </summary>
        public void LoadControl()
        {
            InitializeIds();
            if (ItemId > 0)
            {
                StageBitz.Data.Item item = this.GetBL<InventoryBL>().GetItem(ItemId);

                if (item != null)
                {
                    LoadItem(item);
                    documentPreview.ShouldRemoveFromDatabase = true;
                }
            }
            else if (ItemBriefId > 0)
            {
                Data.ItemVersionHistory itemVersionHistory = this.GetBL<InventoryBL>().GetItemVersionHistoryByItemBriefId(ItemBriefId);

                if (itemVersionHistory != null)
                {
                    LoadItemVersionHistory(itemVersionHistory);
                }
                else
                {
                    StageBitz.Data.ItemBrief itemBrief = this.GetBL<ItemBriefBL>().GetItemBrief(ItemBriefId);

                    if (itemBrief != null)
                    {
                        LoadItemBrief(itemBrief);
                        documentPreview.ShouldRemoveFromDatabase = false;
                    }
                }
            }

            pnlCompletedItem.Style["display"] = "block";
            documentPreview.IsTextboxsDisabled = IsReadOnly || ItemBriefId > 0;
            documentPreview.IsReadOnly = IsReadOnly;
            documentPreview.InitializeUI();

            LoadImageList();

            switch (this.DisplayMode)
            {
                case CompleteItemDisplayMode.ItemDetails:
                    divDescription.Visible = true;
                    break;

                case CompleteItemDisplayMode.ItemBriefDetails:
                    divDescription.Visible = false;
                    break;
            }
        }

        /// <summary>
        /// Loads the image list.
        /// </summary>
        public void LoadImageList()
        {
            documentList.FunctionPrefix = this.ClientID;
            documentPreview.FunctionPrefix = this.ClientID;
            documentList.LoadData();
            divDocumentList.Style["overflow-x"] = (documentList.LoadedDocumentCount > 3) ? "scroll" : "hidden";
            upnlDocumentList.Update();
        }

        /// <summary>
        /// Clears the in memory data.
        /// </summary>
        public void ClearInMemoryData()
        {
            documentList.DocumentMediaIdsToExclude = new List<int>();
        }

        #endregion Public Methods

        #region Private Methods

        /// <summary>
        /// Initializes the ids.
        /// </summary>
        private void InitializeIds()
        {
            if (ItemId > 0)
            {
                StageBitz.Data.Item item = this.GetBL<InventoryBL>().GetItem(ItemId);

                if (item != null)
                {
                    IsItemCreated = true;
                }
            }
            else if (ItemBriefId > 0)
            {
                StageBitz.Data.ItemBrief itemBrief = this.GetBL<ItemBriefBL>().GetItemBrief(ItemBriefId);

                if (itemBrief != null)
                {
                    Data.ItemBooking itemBooking = this.GetBL<InventoryBL>().GetItemBookingByRelatedTable(ItemBriefId, "ItemBrief", true);

                    Data.Item item = null;
                    if (itemBooking != null)
                    {
                        item = itemBooking.Item;
                    }

                    if (item != null)
                    {
                        ItemId = item.ItemId;
                        IsItemCreated = true;
                    }
                    else
                    {
                        IsItemCreated = false;
                    }
                }
            }
        }

        /// <summary>
        /// Sends the document media ids for cilent side usage.
        /// </summary>
        private void SendDocumentMediaIdsForCilentSideUsage()
        {
            hdnDocumentIds.Value = string.Join(",", this.ItemDocumentList.DocumentMediaIds.Select(dmi => dmi.ToString(CultureInfo.InvariantCulture)));
        }

        /// <summary>
        /// Loads the item brief.
        /// </summary>
        /// <param name="itemBrief">The item brief.</param>
        private void LoadItemBrief(Data.ItemBrief itemBrief)
        {
            documentList.RelatedTableName = "ItemBrief";
            documentList.RelatedId = itemBrief.ItemBriefId;
        }

        /// <summary>
        /// Loads the item.
        /// </summary>
        /// <param name="item">The item.</param>
        private void LoadItem(Data.Item item)
        {
            documentList.RelatedTableName = "Item";
            documentList.RelatedId = item.ItemId;
        }

        /// <summary>
        /// Loads the item version history.
        /// </summary>
        /// <param name="itemVersionHistory">The item version history.</param>
        private void LoadItemVersionHistory(Data.ItemVersionHistory itemVersionHistory)
        {
            documentList.RelatedTableName = "ItemVersionHistory";
            documentList.RelatedId = itemVersionHistory.ItemVersionHistoryId;
        }

        /// <summary>
        /// Registers the dirty validation scripts.
        /// </summary>
        private void RegisterDirtyValidationScripts()
        {
            ScriptManager.RegisterStartupScript(this, GetType(), string.Concat("DirtyValidationScript", this.ClientID),
                string.Concat("CompleteItemDirtyValidation_", this.ClientID, "();"), true);
        }

        /// <summary>
        /// Shows the item deleted pop up.
        /// </summary>
        private void ShowItemDeletedPopUp()
        {
            if (this.GetBL<InventoryBL>().IsItemDeleted(ItemId))
            {
                int companyId = (int)(this.GetBL<InventoryBL>().GetItem(ItemId).CompanyId);
                popupItemDeletedWarning.ShowItemDeleteMessagePopup(ItemId, companyId);
            }
            else if (DisplayMode == CompleteItemDisplayMode.ItemDetails && this.GetBL<InventoryBL>().IsItemInUse(ItemId))
            {
                popupItemPinned.ShowPopup();
            }

            upnlDocumentList.Update();
        }

        #endregion Private Methods
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.appcelerator.movies</id>
    <name>Movies</name>
    <version>1.0</version>
    <publisher>Appcelerator</publisher>
    <url>http://www.appcelerator.com</url>
    <description>Movies app</description>
    <copyright>2015 by Appcelerator</copyright>
    <icon>appicon.png</icon>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>false</analytics>
    <guid>11111111-1111-1111-1111-111111111111</guid>
    <property name="ti.ui.defaultunit" type="string">dp</property>
    <ios>
        <plist>
            <dict>
                <key>UISupportedInterfaceOrientations~iphone</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                </array>
                <key>UISupportedInterfaceOrientations~ipad</key>
                <array>
                    <string>UIInterfaceOrientationPortrait</string>
                    <string>UIInterfaceOrientationPortraitUpsideDown</string>
                </array>
                <key>UIRequiresPersistentWiFi</key>
                <false/>
                <key>UIPrerenderedIcon</key>
                <true/>
                <key>UIStatusBarHidden</key>
                <false/>
                <key>UIStatusBarStyle</key>
                <string>UIStatusBarStyleLightContent</string>
                <key>CFBundleURLTypes</key>
                <array/>
            </dict>
        </plist>
    </ios>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21"/>
            <application android:theme="@style/Theme.NoActionBar">
                <activity
                    android:configChanges="keyboardHidden|orientation"
                    android:label="Movies"
                    android:name=".MoviesActivity" android:theme="@style/Theme.NoActionBar">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
            </application>
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
            <uses-permission android:name="android.permission.BLUETOOTH"/>
            <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
            <uses-permission android:name="android.permission.GET_TASKS"/>
        </manifest>
    </android>
    <mobileweb/>
    <modules>
        <module platform="iphone">ti.coremotion</module>
    </modules>
    <deployment-targets>
        <target device="android">true</target>
        <target device="blackberry">false</target>
        <target device="ipad">true</target>
        <target device="iphone">true</target>
        <target device="mobileweb">false</target>
        <target device="windows">true</target>
    </deployment-targets>
    <sdk-version>4.0.0.GA</sdk-version>
    <plugins>
        <plugin version="1.0">ti.alloy</plugin>
    </plugins>
</ti:app>


text:
Copyright 2013 Patrick Grimm <patrick@lunatiki.de>
Copyright 2013 André Gaul <gaul@web-yard.de>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

]]--

return {
    insert = function(doc, options)
        local contact = {
            name = options.name,
            email = options.email
        }
        doc.attributes = doc.attributes or {}
        doc.attributes.contact = contact
    end
}


text:
FROM orchardup/php5

ADD ./wordpress /wordpress


text:
package org.nd4j.linalg.api.ops.impl.scalar.comparison;

import org.nd4j.autodiff.samediff.SDVariable;
import org.nd4j.autodiff.samediff.SameDiff;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.BaseScalarOp;

import java.util.Arrays;
import java.util.List;

/**
 * Return a binary (0 or 1) when greater than or equal to a number
 *
 * @author Adam Gibson
 */
public class ScalarGreaterThanOrEqual extends BaseScalarOp {
    public ScalarGreaterThanOrEqual() {
    }

    public ScalarGreaterThanOrEqual(INDArray x, INDArray y, INDArray z, long n, Number num) {
        super(x, y, z, n, num);
    }

    public ScalarGreaterThanOrEqual(INDArray x, Number num) {
        super(x, num);
    }

    public ScalarGreaterThanOrEqual(SameDiff sameDiff, SDVariable i_v, Number scalar) {
        super(sameDiff, i_v, scalar);
    }

    public ScalarGreaterThanOrEqual(SameDiff sameDiff, SDVariable i_v, Number scalar, boolean inPlace) {
        super(sameDiff, i_v, scalar, inPlace);
    }

    public ScalarGreaterThanOrEqual(SameDiff sameDiff, SDVariable i_v, Number scalar, boolean inPlace, Object[] extraArgs) {
        super(sameDiff, i_v, scalar, inPlace, extraArgs);
    }

    public ScalarGreaterThanOrEqual(SameDiff sameDiff, SDVariable i_v, Number scalar, Object[] extraArgs) {
        super(sameDiff, i_v, scalar, extraArgs);
    }

    @Override
    public int opNum() {
        return 16;
    }

    @Override
    public String opName() {
        return "greaterthanorequal_scalar";
    }

    @Override
    public String onnxName() {
        return "GreaterEqual";
    }

    @Override
    public String tensorflowName() {
        return "greater_equal";
    }

    @Override
    public List<SDVariable> doDiff(List<SDVariable> f1) {
        //Not continuously differentiable, but 0 gradient in most places

        return Arrays.asList(sameDiff.zerosLike(arg()));
    }

}


text:
<?php

namespace wcmf\lib\model\impl;

use wcmf\lib\model\Node;
use wcmf\lib\model\NodeSerializer;
use wcmf\lib\persistence\BuildDepth;
use wcmf\lib\persistence\PersistenceFacade;

/**
 * NodeSerializerBase is a base class for NodeSerialize implementations.
 *
 * @author ingo herwig <ingo@wemove.com>
 */
abstract class AbstractNodeSerializer implements NodeSerializer {

  private $persistenceFacade = null;

  /**
   * Constructor
   * @param $persistenceFacade
   */
  public function __construct(PersistenceFacade $persistenceFacade) {
    $this->persistenceFacade = $persistenceFacade;
  }

  /**
   * Get a Node instance based on the original values to merge the deserialized values into
   * @param $oid The object id of the Node
   * @return Node
   */
  protected function getNodeTemplate($oid) {
    // load object if existing to get the original data
    $originalNode = $this->persistenceFacade->load($oid, BuildDepth::SINGLE);

    // create the request node and copy the orignal data
    $class = get_class($this->persistenceFacade->create($oid->getType(), BuildDepth::SINGLE));
    $node = new $class;
    if ($originalNode) {
      $originalNode->copyValues($node);
    }
    return $node;
  }

  /**
   * Deserialize a node value
   * @param $node Node instance
   * @param $key The value name or type if value is an array
   * @param $value The value or child data, if value is an array
   */
  protected function deserializeValue(Node $node, $key, $value) {
    if (!is_array($value)) {
      // force set value to avoid exceptions in this stage
      $node->setValue($key, $value, true);
    }
    else {
      $role = $key;
      if ($this->isMultiValued($node, $role)) {
        // deserialize children
        foreach($value as $childData) {
          $this->deserializeNode($childData, $node, $role);
        }
      }
      else {
        $this->deserializeNode($value, $node, $role);
      }
    }
  }

  /**
   * Check if a relation is multi valued
   * @param $node The Node that has the relation
   * @param $role The role of the relation
   */
  protected function isMultiValued(Node $node, $role) {
    $isMultiValued = false;
    $mapper = $node->getMapper();
    if ($mapper->hasRelation($role)) {
      $relation = $mapper->getRelation($role);
      $isMultiValued = $relation->isMultiValued();
    }
    return $isMultiValued;
  }
}
?>


text:
/*=============================================================================
 *
 * benchmark.h: Kludge benchmarking header for tests.
 *
 *===========================================================================*/

#ifndef FAST_TOLOWER_BENCHMARK_H
#define FAST_TOLOWER_BENCHMARK_H
#include <errno.h>
#include <stdio.h>
#include <time.h>

#define USEC_PER_SEC 1000000

static struct timeval start_time;
static struct timeval stop_time;
static struct timeval pause_time;

/* Store the difference between to struct timevals: */
void timeval_subtract(
        struct timeval* result, struct timeval* start, struct timeval* end)
{
    result->tv_sec = end->tv_sec - start->tv_sec;
    if( end->tv_usec >= start->tv_usec ) {
        result->tv_usec = end->tv_usec - start->tv_usec;
    }
    else {
        result->tv_sec -= 1;
        result->tv_usec = (USEC_PER_SEC - start->tv_usec) + end->tv_usec;
    };
    return;
}

void timeval_increment(struct timeval* out, struct timeval* diff)
{
    out->tv_sec += diff->tv_sec;
    long tv_usec = out->tv_usec + diff->tv_usec;
    if( tv_usec >= USEC_PER_SEC ) {
        ++out->tv_sec;
        out->tv_usec = USEC_PER_SEC - tv_usec;
    }
    else {
        out->tv_usec = tv_usec;
    };
    return;
};

/* Start timing an algorithm: */
static inline void benchmark_start()
{
    gettimeofday(&start_time, NULL);
    return;
}

/* Pause the timer, don't count any time elapsed between pause and unpause: */
static inline void benchmark_pause()
{
    gettimeofday(&pause_time, NULL);
    return;
}

/* Unpause the timer: */
static inline void benchmark_unpause()
{
    static struct timeval unpause_time;
    static struct timeval total_pause;
    gettimeofday(&unpause_time, NULL);
    timeval_subtract(&total_pause, &pause_time, &unpause_time);
    timeval_increment(&start_time, &total_pause);
    return;
};

/* Stop the timer and spit out the total elapsed time: */
static inline struct timeval benchmark_stop()
{
    static struct timeval total_time;
    gettimeofday(&stop_time, NULL);
    timeval_subtract(&total_time, &start_time, &stop_time);
    return total_time;
}

#endif /* FAST_TOLOWER_BENCHMARK_H */
/* EOF */


text:
"""Implements the RelFS entity class."""
#------------------------------------------------------------------------------#
import BTrees.OOBTree
import persistent
from .component import Component
#------------------------------------------------------------------------------#
class EntityBase(persistent.Persistent):
    """Common base class for RelFs persistent entity."""
    #--------------------------------------------------------------------------#
    def __init__(self):
        persistent.Persistent.__init__(self)
        self._components = BTrees.OOBTree.BTree()
        self._p_changed = True

    #--------------------------------------------------------------------------#
    def has_component(self, component_class):
        """
        Indicates if this entity instance has component
        of the specified component_class.
        """
        assert isinstance(component_class, type)
        assert issubclass(component_class, Component)
        return self._components.has_key(component_class.unique_id())

    #--------------------------------------------------------------------------#
    def get_component(self, component_class):
        """
        If this entity does not have a component of the specified
        component_class, then a new default instance is added.
        Then the component of component_class is returned of this
        entity is returned.
        """
        assert isinstance(component_class, type)
        assert issubclass(component_class, Component)
        try:
            return self._components[component_class.unique_id()]
        except KeyError:
            result = component_class()
            self._components[component_class.unique_id()] = result
            self._p_changed = True
            return result

    #--------------------------------------------------------------------------#
    def find_component(self, component_class):
        """
        Returns the component with the specified component_class,
        if this entity has one, returns None otherwise.
        """
        assert isinstance(component_class, type)
        assert issubclass(component_class, Component)
        try:
            return self._components[component_class.unique_id()]
        except KeyError:
            return None

    #--------------------------------------------------------------------------#
    def find_all_components_by_name(self, *component_names):
        """
        Returns a tuple of components of this entity with the specified
        component class names if this entity has all of them.
        Returns None otherwise.
        """
        try:
            return tuple(self._components[name] for name in component_names)
        except KeyError:
            return None

    #--------------------------------------------------------------------------#
    def all_components(self):
        """
        Yields pairs of type names and instances of all components
        of this entity.
        """
        for name, component in self._components.items():
            yield name, component

    #--------------------------------------------------------------------------#
    def only_components(self, component_names):
        """
        Yields pairs of type names and instances of components with type
        names specified in the component_names list in the this entity.
        """
        for component_name in component_names:
            try:
                yield component_name, self._components[component_name]
            except KeyError:
                pass

#------------------------------------------------------------------------------#
class Entity(EntityBase):
    """Class representing a identifyiable RelFS entity."""
    #--------------------------------------------------------------------------#
    def __init__(self):
        EntityBase.__init__(self)

    #--------------------------------------------------------------------------#
    def add_component(self, some_component):
        """Adds some_component instance to this entity."""
        assert isinstance(some_component, Component)
        self._components[some_component.unique_id()] = some_component
        self._p_changed = True

#------------------------------------------------------------------------------#
class EntityContext(EntityBase):
    """Class representing shared context for RelFS entities."""
    #--------------------------------------------------------------------------#
    def __init__(self):
        EntityBase.__init__(self)


text:
namespace Urho3D
{

ToneMappingPass::ToneMappingPass(
    RenderPipelineInterface* renderPipeline, RenderBufferManager* renderBufferManager)
    : PostProcessPass(renderPipeline, renderBufferManager)
{
}

void ToneMappingPass::SetMode(ToneMappingMode mode)
{
    if (mode_ != mode)
    {
        toneMappingState_ = nullptr;
        mode_ = mode;
    }
}

void ToneMappingPass::InitializeStates()
{
    ea::string defines;
    switch (mode_)
    {
    case ToneMappingMode::Reinhard:
        defines += "REINHARD ";
        break;
    case ToneMappingMode::ReinhardWhite:
        defines += "REINHARDWHITE ";
        break;
    case ToneMappingMode::Uncharted2:
        defines += "UNCHARTED2 ";
        break;
    default:
        break;
    }

    toneMappingState_  = renderBufferManager_->CreateQuadPipelineState(
        BLEND_REPLACE, "v2/P_ToneMapping", defines);
}

void ToneMappingPass::Execute()
{
    if (!toneMappingState_)
        InitializeStates();

    if (!toneMappingState_->IsValid())
        return;

    renderBufferManager_->SwapColorBuffers(false);

    renderBufferManager_->SetOutputRenderTargers();
    renderBufferManager_->DrawFeedbackViewportQuad("Apply tone mapping", toneMappingState_, {}, {});
}

}


text:
/*!
 * Functionality for allowing views and controllers to
 * receive updates from the stack when changes are made.
 *
 * \author Stephen Plaza (plaza.stephen@gmail.com)
*/

#ifndef STACKOBSERVER_H
#define STACKOBSERVER_H

/*!
 * Interface base class for observing Stack objects.
*/
class StackObserver {
  public:
    /*!
     * Call observer update functionality when
     * the stack changes.
    */
    virtual void update() = 0;

  protected:
    /*!
     * Prevent destruction of observer through
     * the base class pointer.
    */
    virtual ~StackObserver() {}
};

#endif


text:
from django.conf.urls import url
from django.utils import timezone
from django.views.generic import ListView, DetailView

from polls import views
from polls.models import Poll

#
# urlpatterns = patterns('',
#                        url(r'^$', views.index, name='index'),
#                        url(r'^(?P<poll_id>\d+)/$', views.detail, name='detail'),
#                        url(r'^(?P<poll_id>\d+)/results/$', views.results, name='results'),
#                        url(r'^(?P<poll_id>\d+)/vote/$', views.vote, name='vote'))

urlpatterns = [
    url(r'^$', ListView.as_view(
        queryset=Poll.objects.filter(pub_date__lt=timezone.now())
                     .order_by('-pub_date')[:5],
        context_object_name='latest_poll_list',
        template_name='polls/index.html'
    ), name='index'),
    url(r'^(?P<pk>\d+)/$', DetailView.as_view(
        model=Poll,
        template_name='polls/detail.html'
    ), name='detail'),
    url(r'^(?P<pk>\d+)/results/$', DetailView.as_view(
        model=Poll,
        template_name='polls/results.html'), name='results'),
    url(r'^(?P<poll_id>\d+)/vote/$', views.vote, name='vote')]


text:
<?php

/* EPEpapetrieBundle:Panier:validation.html.twig */
class __TwigTemplate_3bca9df6d0246db862c6d5f8315d36d01e5e956feb95964bca1baddeb2e294a1 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        // line 1
        $this->parent = $this->loadTemplate("::layout/layout.html.twig", "EPEpapetrieBundle:Panier:validation.html.twig", 1);
        $this->blocks = array(
            'body' => array($this, 'block_body'),
        );
    }

    protected function doGetParent(array $context)
    {
        return "::layout/layout.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 4
    public function block_body($context, array $blocks = array())
    {
        // line 5
        echo "

            ";
        // line 9
        $this->loadTemplate("::modulesUsed/navigation.html.twig", "EPEpapetrieBundle:Panier:validation.html.twig", 9)->display($context);
        // line 10
        echo "

Valider mon panier

                        Références
                        Quantité
                        Prix unitaire
                        Total HT

                    ";
        // line 26
        $context['_parent'] = (array) $context;
        $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "produit", array()));
        foreach ($context['_seq'] as $context["_key"] => $context["produit"]) {
            // line 27
            echo "

                        ";
            // line 28
            echo twig_escape_filter($this->env, $this->getAttribute($context["produit"], "reference", array()), "html", null, true);
            echo "

                            ";
            // line 30
            echo twig_escape_filter($this->env, $this->getAttribute($context["produit"], "quantite", array()), "html", null, true);
            echo "

                        ";
            // line 32
            echo twig_escape_filter($this->env, $this->getAttribute($context["produit"], "prixHT", array()), "html", null, true);
            echo " €
                        ";
            // line 33
            echo twig_escape_filter($this->env, ($this->getAttribute($context["produit"], "prixHT", array()) * $this->getAttribute($context["produit"], "quantite", array())), "html", null, true);
            echo " €

                    ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['produit'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 36
        echo "

Total HT :

";
        // line 40
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "prixHT", array()), "html", null, true);
        echo " €

                ";
        // line 42
        $context['_parent'] = (array) $context;
        $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "tva", array()));
        foreach ($context['_seq'] as $context["key"] => $context["tva"]) {
            // line 43
            echo "
TVA ";
            echo twig_escape_filter($this->env, $context["key"], "html", null, true);
            echo " :

";
            echo twig_escape_filter($this->env, $context["tva"], "html", null, true);
            echo " €

                ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['key'], $context['tva'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 45
        echo "

Total TTC :

";
        // line 46
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "prixTTC", array()), "html", null, true);
        echo " €

Adresse de livraison

";
        // line 52
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "livraison", array()), "prenom", array()), "html", null, true);
        echo " ";
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "livraison", array()), "nom", array()), "html", null, true);
        echo "

";
        // line 53
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "livraison", array()), "adresse", array()), "html", null, true);
        echo "

";
        // line 54
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "livraison", array()), "cp", array()), "html", null, true);
        echo " ";
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "livraison", array()), "ville", array()), "html", null, true);
        echo " - ";
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "livraison", array()), "pays", array()), "html", null, true);
        echo "

Adresse de facturation

";
        // line 61
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "facturation", array()), "prenom", array()), "html", null, true);
        echo " ";
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "facturation", array()), "nom", array()), "html", null, true);
        echo "

";
        // line 62
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "facturation", array()), "adresse", array()), "html", null, true);
        echo "

";
        // line 63
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "facturation", array()), "cp", array()), "html", null, true);
        echo " ";
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "facturation", array()), "ville", array()), "html", null, true);
        echo " - ";
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "facturation", array()), "pays", array()), "html", null, true);
        echo "

            <form action=\"";
        // line 69
        echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("ep_epapetrie_validationCommande", array("id" => $this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "id", array()))), "html", null, true);
        echo "\" method=\"POST\"/>
                <input name=\"token\"  type=\"hidden\" value=\"";
        // line 70
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "token", array()), "html", null, true);
        echo "\" />
                <input name=\"prix\"  type=\"hidden\" value=\"";
        // line 71
        echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "commande", array()), "prixTTC", array()), "html", null, true);
        echo "\" />
                <input name=\"date\"  type=\"hidden\" value=\"";
        // line 72
        echo twig_escape_filter($this->env, twig_date_format_filter($this->env, $this->getAttribute((isset($context["commande"]) ? $context["commande"] : $this->getContext($context, "commande")), "date", array()), "dmyhms"), "html", null, true);
        echo "\" />
                <button type=\"submit\"  class=\"btn btn-success pull-right\">Payer</button>
            </form>

            env->getExtension('routing')->getPath("ep_epapetrie_achat");
        echo "\" class=\"btn btn-primary\">retour

";
    }

    public function getTemplateName()
    {
        return "EPEpapetrieBundle:Panier:validation.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  191 => 76,  184 => 72,  180 => 71,  176 => 70,  172 => 69,  159 => 63,  155 => 62,  149 => 61,  135 => 54,  131 => 53,  125 => 52,  116 => 46,  113 => 45,  102 => 43,  98 => 42,  93 => 40,  87 => 36,  78 => 33,  74 => 32,  69 => 30,  64 => 28,  61 => 27,  57 => 26,  39 => 10,  37 => 9,  31 => 5,  28 => 4,  11 => 1,);
    }
}


text:
function [prec, rec, ap, thresh] = instBench(dt, gt, bOpts, tp, fp, sc, numInst)
% function [prec, rec, ap, thresh] = instBench(dt, gt, bOpts, tp, fp, sc, numInst)
% dt  - a struct array with a struct for each image and with following fields
%   .boxInfo - info that will be used to cpmpute the overlap with ground truths, a struct array
%   .sc - score
% gt
%   .boxInfo - info used to compute the overlap,  a struct array
%   .diff - a logical array of size nGtx1, saying if the instance is hard or not
% bOpt
%   .minoverlap - the minimum overlap to call it a true positive
%   .overlapFn - Function to compute the overlap between ground truth and detection boxes, called like overlapFn(dt{i}, gt{i}, overlapParam);
%   .overlapParam - Parameters to compute the overlap, will be passed to the ovelapFn
%     .ovType - singleThresh, searchThresh, softIU
%     .perDetectionThreshold - use a per detection threshold for computing the overlap with the ground truth mask
%     .singleThreshold - use a single threshold to find the overlap with the ground truth mask
%     .softIU - compute a soft I/U for computing the overlap with the ground truth objects
% [tp], [fp], [sc], [numInst]
%     Optional arguments, in case the instBenchImg is being called outside of this function
% bOpts.overlapFn = @(x,y,z) bboxOverlap(cat(1, x.boxInfo(:).bbox), cat(1, y.boxInfo(:).bbox));
% bOpts.minoverlap = 0.5;
% bOpts.overlapParam = [];
% [prec, rec, ap, thresh] = instBench(dt, gt, bOpts, tp, fp, sc, numInst)

% AUTORIGHTS
% ---------------------------------------------------------
% Copyright (c) 2014, Saurabh Gupta
%
% This file is part of the Utils code and is available
% under the terms of the Simplified BSD License provided in
% LICENSE. Please retain this notice and LICENSE if you use
% this file (or any portion of it) in your project.
% ---------------------------------------------------------

  if(nargin == 3)
    %% We do not have the tp, fp, sc, and numInst, so compute them from the structures gt, and out
    for i = 1:length(gt),
      %% Sort dt by the score
      [gr, ind] = sort(dt(i).sc, 'descend');
      dtI = struct('boxInfo', dt(i).boxInfo(ind), 'sc', dt(i).sc(ind));
      [tp{i} fp{i} sc{i} numInst(i)] = instBenchImg(dtI, gt(i), bOpts);
    end
  end

  tp = cat(1, tp{:});
  fp = cat(1, fp{:});
  sc = cat(1, sc{:});

  catAll = cat(2, tp, fp, sc);
  catAll = sortrows(catAll, -3);
  tp = cumsum(catAll(:,1), 1);
  fp = cumsum(catAll(:,2), 1);
  thresh = catAll(:,3);
  npos = sum(numInst);

  % Compute precision/recall
  rec = tp./npos;
  prec = tp./(fp+tp);

  ap = VOCap(rec, prec);
end


text:
package org.ovirt.engine.ui.uicommonweb;

import org.ovirt.engine.core.common.businessentities.DisplayType;
import org.ovirt.engine.core.compat.Version;
import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
import org.ovirt.engine.ui.uicommonweb.models.vms.ISpice;

import com.google.gwt.core.client.GWT;

/**
 * Provides configuration values for client side.
 */
@SuppressWarnings("unused")
public class Configurator
{
    public enum GlusterModeEnum {
        ONLY_OVIRT,
        OVIRT_GLUSTER
    }

    private static final String DOCUMENTATION_LANG_PATH = "/en-US/";
    private static final String DOCUMENTATION_LIB_PATH = "html/";

    /**
     * Gets the value indincating whether the model state should be changed asynchronous in response on property change
     * or command execution.
     */
    private boolean privateIsAsync;

    public boolean getIsAsync()
    {
        return privateIsAsync;
    }

    protected void setIsAsync(boolean value)
    {
        privateIsAsync = value;
    }

    /**
     * Gets or sets the value specifying what is the desired Spice version.
     */
    private Version privateSpiceVersion;

    public Version getSpiceVersion()
    {
        return privateSpiceVersion;
    }

    protected void setSpiceVersion(Version value)
    {
        privateSpiceVersion = value;
    }

    private boolean privateIsAdmin;

    public boolean getIsAdmin()
    {
        return privateIsAdmin;
    }

    protected void setIsAdmin(boolean value)
    {
        privateIsAdmin = value;
    }

    private int privateSpiceDefaultUsbPort;

    public int getSpiceDefaultUsbPort()
    {
        return privateSpiceDefaultUsbPort;
    }

    protected void setSpiceDefaultUsbPort(int value)
    {
        privateSpiceDefaultUsbPort = value;
    }

    private int privateSpiceDisableUsbListenPort;

    public int getSpiceDisableUsbListenPort()
    {
        return privateSpiceDisableUsbListenPort;
    }

    protected void setSpiceDisableUsbListenPort(int value)
    {
        privateSpiceDisableUsbListenPort = value;
    }

    private boolean privateIsUsbEnabled;

    public boolean getIsUsbEnabled()
    {
        return privateIsUsbEnabled;
    }

    protected void setIsUsbEnabled(boolean value)
    {
        privateIsUsbEnabled = value;
    }

    private boolean privateSpiceAdminConsole;

    public boolean getSpiceAdminConsole()
    {
        return privateSpiceAdminConsole;
    }

    protected void setSpiceAdminConsole(boolean value)
    {
        privateSpiceAdminConsole = value;
    }

    private boolean privateSpiceFullScreen;

    public boolean getSpiceFullScreen()
    {
        return privateSpiceFullScreen;
    }

    protected void setSpiceFullScreen(boolean value)
    {
        privateSpiceFullScreen = value;
    }

    private ValidateServerCertificateEnum privateValidateServerCertificate = ValidateServerCertificateEnum.values()[0];

    public ValidateServerCertificateEnum getValidateServerCertificate()
    {
        return privateValidateServerCertificate;
    }

    protected void setValidateServerCertificate(ValidateServerCertificateEnum value)
    {
        privateValidateServerCertificate = value;
    }

    private String privateBackendPort;

    public String getBackendPort()
    {
        return privateBackendPort;
    }

    protected void setBackendPort(String value)
    {
        privateBackendPort = value;
    }

    private String privateLogLevel;

    public String getLogLevel()
    {
        return privateLogLevel;
    }

    protected void setLogLevel(String value)
    {
        privateLogLevel = value;
    }

    /**
     * Specifies the interval fronend calls backend to check for updated results for registered queries and searches.
     * Values is in milliseconds.
     */
    private int privatePollingTimerInterval;

    public int getPollingTimerInterval()
    {
        return privatePollingTimerInterval;
    }

    protected void setPollingTimerInterval(int value)
    {
        privatePollingTimerInterval = value;
    }

    private boolean isDocumentationAvailable;

    public boolean isDocumentationAvailable() {
        return isDocumentationAvailable;
    }

    protected void setDocumentationAvailable(boolean isDocumentationAvailable) {
        this.isDocumentationAvailable = isDocumentationAvailable;
    }

    private String documentationBasePath;

    public String getDocumentationBasePath() {
        return documentationBasePath;
    }

    protected void setDocumentationBasePath(String documentationBasePath) {
        this.documentationBasePath = documentationBasePath;
    }

    public String getDocumentationBaseURL() {
        return GWT.getModuleBaseURL().replaceAll(GWT.getModuleName() + "/", "") + getDocumentationBasePath()
                + DOCUMENTATION_LANG_PATH;
    }

    public String getDocumentationLibURL() {
        return getDocumentationBaseURL() + DOCUMENTATION_LIB_PATH;
    }

    public Configurator()
    {
        setSpiceVersion(new Version(4, 4));
        setSpiceDefaultUsbPort(32023);
        setSpiceDisableUsbListenPort(0);
        setBackendPort("8080");
        setLogLevel("INFO");
        setPollingTimerInterval(5000);
    }

    public boolean IsDisplayTypeSupported(DisplayType displayType)
    {
        return true;
    }

    public void Configure(SearchableListModel searchableListModel)
    {
        searchableListModel.setIsAsync(getIsAsync());
        searchableListModel.setGlusterModeEnum(GlusterModeEnum.OVIRT_GLUSTER);
    }

    public void Configure(ISpice spice)
    {
        setIsUsbEnabled(DataProvider.IsUSBEnabledByDefault());
        int usbListenPort = getIsUsbEnabled() ? getSpiceDefaultUsbPort() : getSpiceDisableUsbListenPort();
        spice.setUsbListenPort(usbListenPort);

        spice.setDesiredVersion(getSpiceVersion());
        spice.setAdminConsole(getSpiceAdminConsole());
        spice.setFullScreen(getSpiceFullScreen());
    }
}