text:
import {
  ComponentFactoryResolver,
  ComponentRef,
  ElementRef,
  ErrorHandler,
  EventEmitter,
  Input,
  NgZone,
  ReflectiveInjector,
  Renderer,
  ViewContainerRef
} from '@angular/core';

import { AnimationOptions } from '../animations/animation';
import { App } from '../components/app/app';
import { Config } from '../config/config';
import {
  DIRECTION_BACK,
  DIRECTION_FORWARD,
  INIT_ZINDEX,
  NavOptions,
  NavResult,
  STATE_ATTACHED,
  STATE_DESTROYED,
  STATE_INITIALIZED,
  STATE_NEW,
  TransitionInstruction,
  convertToViews,
} from './nav-util';

import { setZIndex } from './nav-util';
import { DeepLinker } from './deep-linker';
import { DomController } from '../platform/dom-controller';
import { GestureController } from '../gestures/gesture-controller';
import { assert, isBlank, isNumber, isPresent, isTrueProperty } from '../util/util';
import { ViewController, isViewController } from './view-controller';
import { Ion } from '../components/ion';
import { NavigationContainer } from './navigation-container';
import { NavController } from './nav-controller';
import { NavParams } from './nav-params';
import { Platform } from '../platform/platform';
import { SwipeBackGesture } from './swipe-back';
import { Transition } from '../transitions/transition';
import { TransitionController } from '../transitions/transition-controller';

/**
 * @hidden
 * This class is for internal use only. It is not exported publicly.
 */
export class NavControllerBase extends Ion implements NavController {

  _children: NavigationContainer[];
  _ids: number = -1;
  _init = false;
  _isPortal: boolean;
  _queue: TransitionInstruction[] = [];
  _sbEnabled: boolean;
  _sbGesture: SwipeBackGesture;
  _sbTrns: Transition;
  _trnsId: number = null;
  _trnsTm: boolean = false;
  _viewport: ViewContainerRef;
  _views: ViewController[] = [];
  _zIndexOffset: number = 0;
  _destroyed: boolean;

  viewDidLoad: EventEmitter<any> = new EventEmitter();
  viewWillEnter: EventEmitter<any> = new EventEmitter();
  viewDidEnter: EventEmitter<any> = new EventEmitter();
  viewWillLeave: EventEmitter<any> = new EventEmitter();
  viewDidLeave: EventEmitter<any> = new EventEmitter();
  viewWillUnload: EventEmitter<any> = new EventEmitter();

  id: string;
  name: string;

  @Input()
  get swipeBackEnabled(): boolean {
    return this._sbEnabled;
  }
  set swipeBackEnabled(val: boolean) {
    this._sbEnabled = isTrueProperty(val);
    this._swipeBackCheck();
  }

  constructor(
    public parent: any,
    public _app: App,
    public config: Config,
    public plt: Platform,
    elementRef: ElementRef,
    public _zone: NgZone,
    renderer: Renderer,
    public _cfr: ComponentFactoryResolver,
    public _gestureCtrl: GestureController,
    public _trnsCtrl: TransitionController,
    public _linker: DeepLinker,
    private _domCtrl: DomController,
    private _errHandler: ErrorHandler
  ) {
    super(config, elementRef, renderer);

    this._sbEnabled = config.getBoolean('swipeBackEnabled');
    this._children = [];
    this.id = 'n' + (++ctrlIds);
    this._destroyed = false;
  }

  push(page: any, params?: any, opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      insertStart: -1,
      insertViews: [{ page: page, params: params }],
      opts: opts,
    }, done);
  }

  insert(insertIndex: number, page: any, params?: any, opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      insertStart: insertIndex,
      insertViews: [{ page: page, params: params }],
      opts: opts,
    }, done);
  }

  insertPages(insertIndex: number, insertPages: any[], opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      insertStart: insertIndex,
      insertViews: insertPages,
      opts: opts,
    }, done);
  }

  pop(opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      removeStart: -1,
      removeCount: 1,
      opts: opts,
    }, done);
  }

  popTo(indexOrViewCtrl: any, opts?: NavOptions, done?: () => void): Promise<any> {
    let config: TransitionInstruction = {
      removeStart: -1,
      removeCount: -1,
      opts: opts
    };
    if (isViewController(indexOrViewCtrl)) {
      config.removeView = indexOrViewCtrl;
      config.removeStart = 1;
    } else if (isNumber(indexOrViewCtrl)) {
      config.removeStart = indexOrViewCtrl + 1;
    }
    return this._queueTrns(config, done);
  }

  popToRoot(opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      removeStart: 1,
      removeCount: -1,
      opts: opts,
    }, done);
  }

  popAll(): Promise<any[]> {
    let promises: any[] = [];
    for (var i = this._views.length - 1; i >= 0; i--) {
      promises.push(this.pop(null));
    }
    return Promise.all(promises);
  }

  remove(startIndex: number, removeCount: number = 1, opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      removeStart: startIndex,
      removeCount: removeCount,
      opts: opts,
    }, done);
  }

  removeView(viewController: ViewController, opts?: NavOptions, done?: () => void): Promise<any> {
    return this._queueTrns({
      removeView: viewController,
      removeStart: 0,
      removeCount: 1,
      opts: opts,
    }, done);
  }

  setRoot(pageOrViewCtrl: any, params?: any, opts?: NavOptions, done?: () => void): Promise<any> {
    return this.setPages([{ page: pageOrViewCtrl, params: params }], opts, done);
  }

  setPages(viewControllers: any[], opts?: NavOptions, done?: () => void): Promise<any> {
    if (isBlank(opts)) {
      opts = {};
    }
    // if animation wasn't set to true then default it to NOT animate
    if (opts.animate !== true) {
      opts.animate = false;
    }
    return this._queueTrns({
      insertStart: 0,
      insertViews: viewControllers,
      removeStart: 0,
      removeCount: -1,
      opts: opts
    }, done);
  }

  // _queueTrns() adds a navigation stack change to the queue and schedules it to run:
  // 1. _nextTrns(): consumes the next transition in the queue
  // 2. _viewInit(): initializes enteringView if required
  // 3. _viewTest(): ensures canLeave/canEnter returns true, so the operation can continue
  // 4. _postViewInit(): add/remove the views from the navigation stack
  // 5. _transitionInit(): initializes the visual transition if required and schedules it to run
  // 6. _viewAttachToDOM(): attaches the enteringView to the DOM
  // 7. _transitionStart(): called once the transition actually starts, it initializes the Animation underneath.
  // 8. _transitionFinish(): called once the transition finishes
  // 9. _cleanup(): syncs the navigation internal state with the DOM. For example it removes the pages from the DOM or hides/show them.
  _queueTrns(ti: TransitionInstruction, done: () => void): Promise<boolean> {
    const promise = new Promise<boolean>((resolve, reject) => {
      ti.resolve = resolve;
      ti.reject = reject;
    });
    ti.done = done;

    // Normalize empty
    if (ti.insertViews && ti.insertViews.length === 0) {
      ti.insertViews = undefined;
    }

    // Enqueue transition instruction
    this._queue.push(ti);

    // if there isn't a transition already happening
    // then this will kick off this transition
    this._nextTrns();

    return promise;
  }

  _success(result: NavResult, ti: TransitionInstruction) {
    if (this._queue === null) {
      this._fireError('nav controller was destroyed', ti);
      return;
    }
    this._init = true;
    this._trnsId = null;

    // ensure we're not transitioning here
    this.setTransitioning(false);
    this._swipeBackCheck();
    // let's see if there's another to kick off
    this._nextTrns();

    if (ti.done) {
      ti.done(
        result.hasCompleted,
        result.requiresTransition,
        result.enteringName,
        result.leavingName,
        result.direction
      );
    }
    ti.resolve(result.hasCompleted);
  }

  _failed(rejectReason: any, ti: TransitionInstruction) {
    if (this._queue === null) {
      this._fireError('nav controller was destroyed', ti);
      return;
    }
    this._trnsId = null;
    this._queue.length = 0;

    // let's see if there's another to kick off
    this.setTransitioning(false);
    this._swipeBackCheck();
    this._nextTrns();

    this._fireError(rejectReason, ti);
  }

  _fireError(rejectReason: any, ti: TransitionInstruction) {
    if (ti.done) {
      ti.done(false, false, rejectReason);
    }
    if (ti.reject && !this._destroyed) {
      ti.reject(rejectReason);
    } else {
      ti.resolve(false);
    }
  }

  _nextTrns(): boolean {
    // this is the framework's bread 'n butta function
    // only one transition is allowed at any given time
    if (this.isTransitioning()) {
      return false;
    }

    // there is no transition happening right now
    // get the next instruction
    const ti = this._queue.shift();
    if (!ti) {
      return false;
    }

    // set that this nav is actively transitioning
    let enteringView: ViewController;
    let leavingView: ViewController;

    this._startTI(ti)
      .then(() => this._loadLazyLoading(ti))
      .then(() => {
        leavingView = this.getActive();
        enteringView = this._getEnteringView(ti, leavingView);

        if (!leavingView && !enteringView) {
          throw 'no views in the stack to be removed';
        }

        if (enteringView && enteringView._state === STATE_NEW) {
          this._viewInit(enteringView);
        }

        // Needs transition?
        ti.requiresTransition = (ti.enteringRequiresTransition || ti.leavingRequiresTransition) && enteringView !== leavingView;
      })
      .then(() => this._viewTest(enteringView, leavingView, ti))
      .then(() => this._postViewInit(enteringView, leavingView, ti))
      .then(() => this._transition(enteringView, leavingView, ti))
      .then((result) => this._success(result, ti))
      .catch((rejectReason) => this._failed(rejectReason, ti));

    return true;
  }

  _startTI(ti: TransitionInstruction): Promise<void> {
    const viewsLength = this._views.length;

    if (isPresent(ti.removeView)) {
      assert(isPresent(ti.removeStart), 'removeView needs removeStart');
      assert(isPresent(ti.removeCount), 'removeView needs removeCount');

      const index = this.indexOf(ti.removeView);
      if (index < 0) {
        return Promise.reject('removeView was not found');
      }
      ti.removeStart += index;
    }
    if (isPresent(ti.removeStart)) {
      if (ti.removeStart < 0) {
        ti.removeStart = (viewsLength - 1);
      }
      if (ti.removeCount < 0) {
        ti.removeCount = (viewsLength - ti.removeStart);
      }
      ti.leavingRequiresTransition = (ti.removeCount > 0) && ((ti.removeStart + ti.removeCount) === viewsLength);
    }

    if (ti.insertViews) {
      // allow -1 to be passed in to auto push it on the end
      // and clean up the index if it's larger then the size of the stack
      if (ti.insertStart < 0 || ti.insertStart > viewsLength) {
        ti.insertStart = viewsLength;
      }
      ti.enteringRequiresTransition = (ti.insertStart === viewsLength);
    }
    this.setTransitioning(true);
    return Promise.resolve();
  }

  _loadLazyLoading(ti: TransitionInstruction): Promise<void> {
    const insertViews = ti.insertViews;
    if (insertViews) {
      assert(insertViews.length > 0, 'length can not be zero');
      return convertToViews(this._linker, insertViews).then((viewControllers) => {
        assert(insertViews.length === viewControllers.length, 'lengths does not match');

        viewControllers = viewControllers.filter(v => v !== null);
        if (viewControllers.length === 0) {
          throw 'invalid views to insert';
        }
        // Check all the inserted view are correct
        for (var i = 0; i < viewControllers.length; i++) {
          var view = viewControllers[i];
          var nav = view._nav;
          if (nav && nav !== this) {
            throw 'inserted view was already inserted';
          }
          if (view._state === STATE_DESTROYED) {
            throw 'inserted view was already destroyed';
          }
        }
        ti.insertViews = viewControllers;
      });
    }
    return Promise.resolve();
  }

  _getEnteringView(ti: TransitionInstruction, leavingView: ViewController): ViewController {
    const insertViews = ti.insertViews;
    if (insertViews) {
      // grab the very last view of the views to be inserted
      // and initialize it as the new entering view
      return insertViews[insertViews.length - 1];
    }

    const removeStart = ti.removeStart;
    if (isPresent(removeStart)) {
      var views = this._views;
      var removeEnd = removeStart + ti.removeCount;
      var i: number;
      var view: ViewController;
      for (i = views.length - 1; i >= 0; i--) {
        view = views[i];
        if ((i < removeStart || i >= removeEnd) && view !== leavingView) {
          return view;
        }
      }
    }
    return null;
  }

  _postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction) {
    assert(leavingView || enteringView, 'Both leavingView and enteringView are null');
    assert(ti.resolve, 'resolve must be valid');
    assert(ti.reject, 'reject must be valid');

    const opts = ti.opts || {};
    const insertViews = ti.insertViews;
    const removeStart = ti.removeStart;
    const removeCount = ti.removeCount;
    let view: ViewController;
    let i: number;
    let destroyQueue: ViewController[];

    // there are views to remove
    if (isPresent(removeStart)) {
      assert(removeStart >= 0, 'removeStart can not be negative');
      assert(removeCount >= 0, 'removeCount can not be negative');

      destroyQueue = [];
      for (i = 0; i < removeCount; i++) {
        view = this._views[i + removeStart];
        if (view && view !== enteringView && view !== leavingView) {
          destroyQueue.push(view);
        }
      }
      // default the direction to "back"
      opts.direction = opts.direction || DIRECTION_BACK;
    }

    const finalBalance = this._views.length + (insertViews ? insertViews.length : 0) - (removeCount ? removeCount : 0);
    assert(finalBalance >= 0, 'final balance can not be negative');
    if (finalBalance === 0 && !this._isPortal) {
      console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`,
        this, this.getNativeElement());

      throw 'navigation stack needs at least one root page';
    }

    // At this point the transition can not be rejected, any throw should be an error
    // there are views to insert
    if (insertViews) {
      // manually set the new view's id if an id was passed in the options
      if (isPresent(opts.id)) {
        enteringView.id = opts.id;
      }

      // add the views to the
      for (i = 0; i < insertViews.length; i++) {
        view = insertViews[i];
        this._insertViewAt(view, ti.insertStart + i);
      }

      if (ti.enteringRequiresTransition) {
        // default to forward if not already set
        opts.direction = opts.direction || DIRECTION_FORWARD;
      }
    }

    // if the views to be removed are in the beginning or middle
    // and there is not a view that needs to visually transition out
    // then just destroy them and don't transition anything
    // batch all of lifecycles together
    // let's make sure, callbacks are zoned
    if (destroyQueue && destroyQueue.length > 0) {
      this._zone.run(() => {
        for (i = 0; i < destroyQueue.length; i++) {
          view = destroyQueue[i];
          this._willLeave(view, true);
          this._didLeave(view);
          this._willUnload(view);
        }
      });

      // once all lifecycle events has been delivered, we can safely detroy the views
      for (i = 0; i < destroyQueue.length; i++) {
        this._destroyView(destroyQueue[i]);
      }
    }

    // set which animation it should use if it wasn't set yet
    if (ti.requiresTransition && !opts.animation) {
      if (isPresent(ti.removeStart)) {
        opts.animation = (leavingView || enteringView).getTransitionName(opts.direction);
      } else {
        opts.animation = (enteringView || leavingView).getTransitionName(opts.direction);
      }
    }
    ti.opts = opts;
  }

  /**
   * DOM WRITE
   */
  _viewInit(enteringView: ViewController) {
    assert(enteringView, 'enteringView must be non null');
    assert(enteringView._state === STATE_NEW, 'enteringView state must be NEW');

     // render the entering view, and all child navs and views
    // entering view has not been initialized yet
    const componentProviders = ReflectiveInjector.resolve([
      { provide: NavController, useValue: this },
      { provide: ViewController, useValue: enteringView },
      { provide: NavParams, useValue: enteringView.getNavParams() }
    ]);
    const componentFactory = this._linker.resolveComponent(enteringView.component);
    const childInjector = ReflectiveInjector.fromResolvedProviders(componentProviders, this._viewport.parentInjector);

    // create ComponentRef and set it to the entering view
    enteringView.init(componentFactory.create(childInjector, []));
    enteringView._state = STATE_INITIALIZED;
    this._preLoad(enteringView);
  }

  _viewAttachToDOM(view: ViewController, componentRef: ComponentRef<any>, viewport: ViewContainerRef) {
    assert(view._state === STATE_INITIALIZED, 'view state must be INITIALIZED');
    assert(componentRef, 'componentRef can not be null');

    // fire willLoad before change detection runs
    this._willLoad(view);

    // render the component ref instance to the DOM
    // ******** DOM WRITE ****************
    viewport.insert(componentRef.hostView, viewport.length);
    view._state = STATE_ATTACHED;

    if (view._cssClass) {
      // the ElementRef of the actual ion-page created
      var pageElement = componentRef.location.nativeElement;

      // ******** DOM WRITE ****************
      this._renderer.setElementClass(pageElement, view._cssClass, true);
    }

    componentRef.changeDetectorRef.detectChanges();

    // successfully finished loading the entering view
    // fire off the "didLoad" lifecycle events
    this._zone.run(this._didLoad.bind(this, view));
  }

  _viewTest(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction): Promise<void> {
    // Only test canLeave/canEnter if there is transition
    if (!ti.requiresTransition) {
      return Promise.resolve();
    }

    const promises: Promise<any>[] = [];

    if (leavingView) {
      promises.push(leavingView._lifecycleTest('Leave'));
    }
    if (enteringView) {
      promises.push(enteringView._lifecycleTest('Enter'));
    }

    if (promises.length === 0) {
      return Promise.resolve();
    }

    // darn, async promises, gotta wait for them to resolve
    return Promise.all(promises).then((values: any[]) => {
      if (values.some(result => result === false)) {
        throw 'canEnter/Leave returned false';
      }
    }).catch((reason) => {
      // Do not
      ti.reject = null;
      throw reason;
    });
  }

  _transition(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction): Promise<NavResult> {
    if (!ti.requiresTransition) {
      // transition is not required, so we are already done!
      // they're inserting/removing the views somewhere in the middle or
      // beginning, so visually nothing needs to animate/transition
      // resolve immediately because there's no animation that's happening
      return Promise.resolve({
        hasCompleted: true,
        requiresTransition: false
      });
    }

    const opts = ti.opts;

    // figure out if this transition is the root one or a
    // child of a parent nav that has the root transition
    this._trnsId = this._trnsCtrl.getRootTrnsId(this);
    if (this._trnsId === null) {
      // this is the root transition, meaning all child navs and their views
      // should be added as a child transition to this one
      this._trnsId = this._trnsCtrl.nextId();
    }

    // create the transition options
    const animationOpts: AnimationOptions = {
      animation: opts.animation,
      direction: opts.direction,
      duration: (opts.animate === false ? 0 : opts.duration),
      easing: opts.easing,
      isRTL: this._config.plt.isRTL,
      ev: opts.ev,
    };

    // create the transition animation from the TransitionController
    // this will either create the root transition, or add it as a child transition
    const transition = this._trnsCtrl.get(this._trnsId, enteringView, leavingView, animationOpts);

    // ensure any swipeback transitions are cleared out
    this._sbTrns && this._sbTrns.destroy();
    this._sbTrns = null;

    // swipe to go back root transition
    if (transition.isRoot() && opts.progressAnimation) {
      this._sbTrns = transition;
    }

    // transition start has to be registered before attaching the view to the DOM!
    const promise = new Promise<void>(resolve => transition.registerStart(resolve)).then(() => {
      return this._transitionStart(transition, enteringView, leavingView, opts);
    });

    if (enteringView && (enteringView._state === STATE_INITIALIZED)) {
      // render the entering component in the DOM
      // this would also render new child navs/views
      // which may have their very own async canEnter/Leave tests
      // ******** DOM WRITE ****************
      this._viewAttachToDOM(enteringView, enteringView._cmp, this._viewport);
    }

    if (!transition.hasChildren) {
      // lowest level transition, so kick it off and let it bubble up to start all of them
      transition.start();
    }
    return promise;
  }

  _transitionStart(transition: Transition, enteringView: ViewController, leavingView: ViewController, opts: NavOptions): Promise<NavResult> {
    assert(this.isTransitioning(), 'isTransitioning() has to be true');

    this._trnsId = null;

    // set the correct zIndex for the entering and leaving views
    // ******** DOM WRITE ****************
    setZIndex(this, enteringView, leavingView, opts.direction, this._renderer);

    // always ensure the entering view is viewable
    // ******** DOM WRITE ****************
    enteringView && enteringView._domShow(true, this._renderer);

    // always ensure the leaving view is viewable
    // ******** DOM WRITE ****************
    leavingView && leavingView._domShow(true, this._renderer);

    // initialize the transition
    transition.init();

    // we should animate (duration > 0) if the pushed page is not the first one (startup)
    // or if it is a portal (modal, actionsheet, etc.)
    const isFirstPage = !this._init && this._views.length === 1;
    const shouldNotAnimate = isFirstPage && !this._isPortal;
    const canNotAnimate = this._config.get('animate') === false;
    if (shouldNotAnimate || canNotAnimate) {
      opts.animate = false;
    }

    if (opts.animate === false) {
      // if it was somehow set to not animation, then make the duration zero
      transition.duration(0);
    }

    // create a callback that needs to run within zone
    // that will fire off the willEnter/Leave lifecycle events at the right time
    transition.beforeAddRead(this._viewsWillLifecycles.bind(this, enteringView, leavingView));

    // get the set duration of this transition
    const duration = transition.getDuration();

    // create a callback for when the animation is done
    const promise = new Promise(resolve => {
      transition.onFinish(resolve);
    });

    if (transition.isRoot()) {
      // this is the top most, or only active transition, so disable the app
      // add XXms to the duration the app is disabled when the keyboard is open

      if (duration > DISABLE_APP_MINIMUM_DURATION && opts.disableApp !== false) {
        // if this transition has a duration and this is the root transition
        // then set that the app is actively disabled
        this._app.setEnabled(false, duration + ACTIVE_TRANSITION_OFFSET, opts.minClickBlockDuration);
      } else {
        console.debug('transition is running but app has not been disabled');
      }

      // cool, let's do this, start the transition
      if (opts.progressAnimation) {
        // this is a swipe to go back, just get the transition progress ready
        // kick off the swipe animation start
        transition.progressStart();

      } else {
        // only the top level transition should actually start "play"
        // kick it off and let it play through
        // ******** DOM WRITE ****************
        transition.play();
      }
    }

    return promise.then(() => this._zone.run(() => {
      return this._transitionFinish(transition, opts);
    }));
  }

  _transitionFinish(transition: Transition, opts: NavOptions): NavResult {

    const hasCompleted = transition.hasCompleted;
    const enteringView = transition.enteringView;
    const leavingView = transition.leavingView;

    // mainly for testing
    let enteringName: string;
    let leavingName: string;

    if (hasCompleted) {
      // transition has completed (went from 0 to 1)
      if (enteringView) {
        enteringName = enteringView.name;
        this._didEnter(enteringView);
      }

      if (leavingView) {
        leavingName = leavingView.name;
        this._didLeave(leavingView);
      }

      this._cleanup(enteringView);
    } else {
      // If transition does not complete, we have to cleanup anyway, because
      // previous pages in the stack are not hidden probably.
      this._cleanup(leavingView);
    }

    if (transition.isRoot()) {
      // this is the root transition
      // it's safe to destroy this transition
      this._trnsCtrl.destroy(transition.trnsId);

      // it's safe to enable the app again
      this._app.setEnabled(true);
      // mark ourselves as not transitioning - `deepLinker navchange` requires this
      // TODO - probably could be resolved in a better way
      this.setTransitioning(false);

      if (!this.hasChildren() && opts.updateUrl !== false) {
        // notify deep linker of the nav change
        // if a direction was provided and should update url
        this._linker.navChange(opts.direction);
      }

      if (opts.keyboardClose !== false) {
        // the keyboard is still open!
        // no problem, let's just close for them
        this.plt.focusOutActiveElement();
      }
    }

    return {
      hasCompleted: hasCompleted,
      requiresTransition: true,
      enteringName: enteringName,
      leavingName: leavingName,
      direction: opts.direction
    };
  }

  _viewsWillLifecycles(enteringView: ViewController, leavingView: ViewController) {
    if (enteringView || leavingView) {
      this._zone.run(() => {
        // Here, the order is important. WillLeave must be called before WillEnter.
        leavingView && this._willLeave(leavingView, !enteringView);
        enteringView && this._willEnter(enteringView);
      });
    }
  }

  _insertViewAt(view: ViewController, index: number) {
    const existingIndex = this._views.indexOf(view);
    if (existingIndex > -1) {
      // this view is already in the stack!!
      // move it to its new location
      assert(view._nav === this, 'view is not part of the nav');
      this._views.splice(index, 0, this._views.splice(existingIndex, 1)[0]);
    } else {
      assert(!view._nav || (this._isPortal && view._nav === this), 'nav is used');
      // this is a new view to add to the stack
      // create the new entering view
      view._setNav(this);

      // give this inserted view an ID
      this._ids++;
      if (!view.id) {
        view.id = `${this.id}-${this._ids}`;
      }

      // insert the entering view into the correct index in the stack
      this._views.splice(index, 0, view);
    }
  }

  _removeView(view: ViewController) {
    assert(view._state === STATE_ATTACHED || view._state === STATE_DESTROYED, 'view state should be loaded or destroyed');

    const views = this._views;
    const index = views.indexOf(view);
    assert(index > -1, 'view must be part of the stack');
    if (index >= 0) {
      views.splice(index, 1);
    }
  }

  _destroyView(view: ViewController) {
    view._destroy(this._renderer);
    this._removeView(view);
  }

  /**
   * DOM WRITE
   */
  _cleanup(activeView: ViewController) {
    // ok, cleanup time!! Destroy all of the views that are
    // INACTIVE and come after the active view
    // only do this if the views exist, though
    if (!this._destroyed) {
      const activeViewIndex = this._views.indexOf(activeView);
      const views = this._views;
      let reorderZIndexes = false;
      let view: ViewController;
      let i: number;

      for (i = views.length - 1; i >= 0; i--) {
        view = views[i];
        if (i > activeViewIndex) {
          // this view comes after the active view
          // let's unload it
          this._willUnload(view);
          this._destroyView(view);

        } else if (i < activeViewIndex && !this._isPortal) {
          // this view comes before the active view
          // and it is not a portal then ensure it is hidden
          view._domShow(false, this._renderer);
        }
        if (view._zIndex <= 0) {
          reorderZIndexes = true;
        }
      }

      if (!this._isPortal && reorderZIndexes) {
        for (i = 0; i < views.length; i++) {
          view = views[i];
          // ******** DOM WRITE ****************
          view._setZIndex(view._zIndex + INIT_ZINDEX + 1, this._renderer);
        }
      }
    }
  }

  _preLoad(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');

    view._preLoad();
  }

  _willLoad(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');

    try {
      view._willLoad();
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  _didLoad(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');
    assert(NgZone.isInAngularZone(), 'callback should be zoned');

    try {
      view._didLoad();
      this.viewDidLoad.emit(view);
      this._app.viewDidLoad.emit(view);
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  _willEnter(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');
    assert(NgZone.isInAngularZone(), 'callback should be zoned');

    try {
      view._willEnter();
      this.viewWillEnter.emit(view);
      this._app.viewWillEnter.emit(view);
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  _didEnter(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');
    assert(NgZone.isInAngularZone(), 'callback should be zoned');

    try {
      view._didEnter();
      this.viewDidEnter.emit(view);
      this._app.viewDidEnter.emit(view);
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  _willLeave(view: ViewController, willUnload: boolean) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');
    assert(NgZone.isInAngularZone(), 'callback should be zoned');

    try {
      view._willLeave(willUnload);
      this.viewWillLeave.emit(view);
      this._app.viewWillLeave.emit(view);
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  _didLeave(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');
    assert(NgZone.isInAngularZone(), 'callback should be zoned');

    try {
      view._didLeave();
      this.viewDidLeave.emit(view);
      this._app.viewDidLeave.emit(view);
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  _willUnload(view: ViewController) {
    assert(this.isTransitioning(), 'nav controller should be transitioning');
    assert(NgZone.isInAngularZone(), 'callback should be zoned');

    try {
      view._willUnload();
      this.viewWillUnload.emit(view);
      this._app.viewWillUnload.emit(view);
    } catch (e) {
      this._errHandler && this._errHandler.handleError(e);
    }
  }

  hasChildren(): boolean {
    return this._children && this._children.length > 0;
  }

  getActiveChildNavs(): any[] {
    return this._children;
  }

  getAllChildNavs(): any[] {
    return this._children;
  }

  registerChildNav(container: NavigationContainer) {
    this._children.push(container);
  }

  unregisterChildNav(nav: any) {
    this._children = this._children.filter(child => child !== nav);
  }

  destroy() {
    const views = this._views;
    let view: ViewController;
    for (var i = 0; i < views.length; i++) {
      view = views[i];
      view._willUnload();
      view._destroy(this._renderer);
    }

    // release swipe back gesture and transition
    this._sbGesture && this._sbGesture.destroy();
    this._sbTrns && this._sbTrns.destroy();
    this._queue = this._views = this._sbGesture = this._sbTrns = null;

    // Unregister navcontroller
    if (this.parent && this.parent.unregisterChildNav) {
      this.parent.unregisterChildNav(this);
    }

    this._destroyed = true;
  }

  swipeBackStart() {
    if (this.isTransitioning() || this._queue.length > 0) {
      return;
    }

    // default the direction to "back";
    const opts: NavOptions = {
      direction: DIRECTION_BACK,
      progressAnimation: true
    };

    this._queueTrns({
      removeStart: -1,
      removeCount: 1,
      opts: opts,
    }, null);
  }

  swipeBackProgress(stepValue: number) {
    if (this._sbTrns && this._sbGesture) {
      // continue to disable the app while actively dragging
      this._app.setEnabled(false, ACTIVE_TRANSITION_DEFAULT);
      this.setTransitioning(true);

      // set the transition animation's progress
      this._sbTrns.progressStep(stepValue);
    }
  }

  swipeBackEnd(shouldComplete: boolean, currentStepValue: number, velocity: number) {
    if (this._sbTrns && this._sbGesture) {
      // the swipe back gesture has ended
      var dur = this._sbTrns.getDuration() / (Math.abs(velocity) + 1);
      this._sbTrns.progressEnd(shouldComplete, currentStepValue, dur);
    }
  }

  _swipeBackCheck() {
    if (this.canSwipeBack()) {
      if (!this._sbGesture) {
        this._sbGesture = new SwipeBackGesture(this.plt, this, this._gestureCtrl, this._domCtrl);
      }
      this._sbGesture.listen();

    } else if (this._sbGesture) {
      this._sbGesture.unlisten();
    }
  }

  canSwipeBack(): boolean {
    return (this._sbEnabled &&
            !this._isPortal &&
            !this._children.length &&
            !this.isTransitioning() &&
            this._app.isEnabled() &&
            this.canGoBack());
  }

  canGoBack(): boolean {
    const activeView = this.getActive();
    return !!(activeView && activeView.enableBack());
  }

  isTransitioning(): boolean {
    return this._trnsTm;
  }

  setTransitioning(isTransitioning: boolean) {
    this._trnsTm = isTransitioning;
  }

  getActive(): ViewController {
    return this._views[this._views.length - 1];
  }

  isActive(view: ViewController): boolean {
    return (view === this.getActive());
  }

  getByIndex(index: number): ViewController {
    return this._views[index];
  }

  getPrevious(view?: ViewController): ViewController {
    // returns the view controller which is before the given view controller.
    if (!view) {
      view = this.getActive();
    }
    const views = this._views;
    return views[views.indexOf(view) - 1];
  }

  first(): ViewController {
    // returns the first view controller in this nav controller's stack.
    return this._views[0];
  }

  last(): ViewController {
    // returns the last page in this nav controller's stack.
    return this._views[this._views.length - 1];
  }

  indexOf(view: ViewController): number {
    // returns the index number of the given view controller.
    return this._views.indexOf(view);
  }

  length(): number {
    return this._views.length;
  }

  /**
   * Return the stack of views in this NavController.
   */
  getViews(): Array<ViewController> {
    return this._views;
  }

  /**
   * Return a view controller
   */
  getViewById(id: string): ViewController {
    for (const vc of this._views) {
      if (vc && vc.id === id) {
        return vc;
      }
    }
    return null;
  }

  isSwipeBackEnabled(): boolean {
    return this._sbEnabled;
  }

  dismissPageChangeViews() {
    for (let view of this._views) {
      if (view.data && view.data.dismissOnPageChange) {
        view.dismiss().catch(() => {});
      }
    }
  }

  setViewport(val: ViewContainerRef) {
    this._viewport = val;
  }

  resize() {
    const active = this.getActive();
    if (!active) {
      return;
    }
    const content = active.getIONContent();
    content && content.resize();
  }

  goToRoot(_opts: NavOptions): Promise<any> {
    return Promise.reject(new Error('goToRoot needs to be implemented by child class'));
  }

  /*
   * @private
   */
  getType() {
    return 'nav';
  }

  /*
   * @private
   */
  getSecondaryIdentifier(): string {
    return null;
  }

  /**
   * Returns the active child navigation.
   */
  getActiveChildNav(): any {
    console.warn('(getActiveChildNav) is deprecated and will be removed in the next major release. Use getActiveChildNavs instead.');
    return this._children[this._children.length - 1];
  }
}

let ctrlIds = -1;

const DISABLE_APP_MINIMUM_DURATION = 64;
const ACTIVE_TRANSITION_DEFAULT = 5000;
const ACTIVE_TRANSITION_OFFSET = 2000;


text:
/* eslint-env jest */

import { join } from 'path'
import {
  renderViaHTTP,
  nextServer,
  startApp,
  stopApp,
  nextBuild,
  waitFor,
  findPort,
  launchApp,
  killApp,
} from 'next-test-utils'
import webdriver from 'next-webdriver'
import cheerio from 'cheerio'

let appDir = join(__dirname, '../base')
let appWithPartytownMissingDir = join(__dirname, '../partytown-missing')
let server
let appPort

const runTests = (isDev = false) => {
  // TODO: We will refactor the next/script to be strict mode resilient
  // Don't skip the test case for dev mode (strict mode) once refactoring is finished
  it('priority afterInteractive', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/')
      await waitFor(1000)

      async function test(id) {
        const script = await browser.elementById(id)
        const dataAttr = await script.getAttribute('data-nscript')
        const endScripts = await browser.elementsByCss(
          `#__NEXT_DATA__ ~ #${id}`
        )

        // Renders script tag
        expect(script).toBeDefined()
        expect(dataAttr).toBeDefined()

        // Script is inserted at the end
        expect(endScripts.length).toBe(1)
      }

      // afterInteractive script in page
      await test('scriptAfterInteractive')
      // afterInteractive script in _document
      await test('documentAfterInteractive')
    } finally {
      if (browser) await browser.close()
    }
  })

  it('priority lazyOnload', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/page3')

      await browser.waitForElementByCss('#onload-div')
      await waitFor(1000)

      const logs = await browser.log('browser')
      const filteredLogs = logs.filter(
        (log) =>
          !log.message.includes('Failed to load resource') &&
          !log.message === 'error' &&
          !log.message === 'Event'
      )
      expect(filteredLogs.length).toBe(0)

      async function test(id) {
        const script = await browser.elementById(id)
        const dataAttr = await script.getAttribute('data-nscript')
        const endScripts = await browser.elementsByCss(
          `#__NEXT_DATA__ ~ #${id}`
        )

        // Renders script tag
        expect(script).toBeDefined()
        expect(dataAttr).toBeDefined()

        // Script is inserted at the end
        expect(endScripts.length).toBe(1)
      }

      // lazyOnload script in page
      await test('scriptLazyOnload')
      // lazyOnload script in _document
      await test('documentLazyOnload')
    } finally {
      if (browser) await browser.close()
    }
  })

  it('priority beforeInteractive', async () => {
    const html = await renderViaHTTP(appPort, '/page1')
    const $ = cheerio.load(html)

    function test(id) {
      const script = $(`#${id}`)

      // Renders script tag
      expect(script.length).toBe(1)
      expect(script.attr('data-nscript')).toBeDefined()

      // Script is inserted before NextScripts
      expect(
        $(`#${id} ~ script[src^="/_next/static/chunks/main"]`).length
      ).toBeGreaterThan(0)
    }

    test('scriptBeforeInteractive')
  })

  // Warning - Will be removed in the next major release
  it('priority beforeInteractive - older version', async () => {
    const html = await renderViaHTTP(appPort, '/page6')
    const $ = cheerio.load(html)

    function test(id) {
      const script = $(`#${id}`)

      // Renders script tag
      expect(script.length).toBe(1)
      expect(script.attr('data-nscript')).toBeDefined()

      // Script is inserted before NextScripts
      expect(
        $(`#${id} ~ script[src^="/_next/static/chunks/main"]`).length
      ).toBeGreaterThan(0)
    }

    test('scriptBeforePageRenderOld')
  })

  it('priority beforeInteractive on navigate', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/')

      // beforeInteractive scripts should load once
      let documentBIScripts = await browser.elementsByCss(
        '[src$="scriptBeforeInteractive"]'
      )
      expect(documentBIScripts.length).toBe(2)

      await browser.waitForElementByCss('[href="/page1"]')
      await browser.click('[href="/page1"]')

      await browser.waitForElementByCss('.container')

      // Ensure beforeInteractive script isn't duplicated on navigation
      documentBIScripts = await browser.elementsByCss(
        '[src$="scriptBeforeInteractive"]'
      )
      expect(documentBIScripts.length).toBe(2)
    } finally {
      if (browser) await browser.close()
    }
  })

  it('onload fires correctly', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/page4')
      await waitFor(3000)

      const text = await browser.elementById('onload-div-1').text()
      expect(text).toBe('aaabbbccc')

      // Navigate to different page and back
      await browser.waitForElementByCss('[href="/page9"]')
      await browser.click('[href="/page9"]')
      await browser.waitForElementByCss('[href="/page4"]')
      await browser.click('[href="/page4"]')

      await browser.waitForElementByCss('#onload-div-1')
      const sameText = await browser.elementById('onload-div-1').text()
      // onload should only be fired once, not on sequential re-mount
      expect(sameText).toBe('')
    } finally {
      if (browser) await browser.close()
    }
  })

  it('priority beforeInteractive with inline script', async () => {
    const html = await renderViaHTTP(appPort, '/page5')
    const $ = cheerio.load(html)

    const script = $('#inline-before')
    expect(script.length).toBe(1)

    // css bundle is only generated in production, so only perform inline script position check in production
    if (!isDev) {
      // Script is inserted before CSS
      expect(
        $(`#inline-before ~ link[href^="/_next/static/css"]`).length
      ).toBeGreaterThan(0)
    }
  })

  it('priority beforeInteractive with inline script should execute', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/page7')
      await waitFor(1000)

      const logs = await browser.log()
      // not only should inline script run, but also should only run once
      expect(
        logs.filter((log) =>
          log.message.includes('beforeInteractive inline script run')
        ).length
      ).toBe(1)
    } finally {
      if (browser) await browser.close()
    }
  })

  it('Does not duplicate inline scripts', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/')

      // Navigate away and back to page
      await browser.waitForElementByCss('[href="/page5"]')
      await browser.click('[href="/page5"]')
      await browser.waitForElementByCss('[href="/"]')
      await browser.click('[href="/"]')
      await browser.waitForElementByCss('[href="/page5"]')
      await browser.click('[href="/page5"]')

      await browser.waitForElementByCss('.container')
      await waitFor(1000)

      const text = await browser.elementById('text').text()

      expect(text).toBe('abc')
    } finally {
      if (browser) await browser.close()
    }
  })

  it('Error message is shown if Partytown is not installed locally', async () => {
    const { stdout, stderr } = await nextBuild(appWithPartytownMissingDir, [], {
      stdout: true,
      stderr: true,
    })
    const output = stdout + stderr

    expect(output.replace(/\n|\r/g, '')).toMatch(
      /It looks like you're trying to use Partytown with next\/script but do not have the required package\(s\) installed.Please install Partytown by running:.*?(npm|pnpm|yarn) (install|add) (--save-dev|--dev) @builder.io\/partytownIf you are not trying to use Partytown, please disable the experimental "nextScriptWorkers" flag in next.config.js./
    )
  })

  it('onReady fires after load event and then on every subsequent re-mount', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/page8')

      const text = await browser.elementById('text').text()

      expect(text).toBe('aaa')

      // Navigate to different page and back
      await browser.waitForElementByCss('[href="/page9"]')
      await browser.click('[href="/page9"]')
      await browser.waitForElementByCss('[href="/page8"]')
      await browser.click('[href="/page8"]')

      await browser.waitForElementByCss('.container')
      const sameText = await browser.elementById('text').text()

      expect(sameText).toBe('aaa') // onReady should fire again
    } finally {
      if (browser) await browser.close()
    }
  })

  // https://github.com/vercel/next.js/issues/39993
  it('onReady should only fires once after loaded (issue #39993)', async () => {
    let browser
    try {
      browser = await webdriver(appPort, '/page10')

      // wait for remote script to be loaded
      await waitFor(1000)
      expect(await browser.eval(`window.remoteScriptsOnReadyCalls`)).toBe(1)
      expect(await browser.eval(`window.inlineScriptsOnReadyCalls`)).toBe(1)
    } finally {
      if (browser) await browser.close()
    }
  })
}

describe('Next.js Script - Primary Strategies - Strict Mode', () => {
  beforeAll(async () => {
    appPort = await findPort()
    server = await launchApp(appDir, appPort)
  })

  afterAll(async () => {
    if (server) await killApp(server)
  })

  runTests(true)
})

describe('Next.js Script - Primary Strategies - Production Mode', () => {
  beforeAll(async () => {
    await nextBuild(appDir)

    const app = nextServer({
      dir: appDir,
      dev: false,
      quiet: true,
    })

    server = await startApp(app)
    appPort = server.address().port
  })
  afterAll(async () => {
    await stopApp(server)
  })

  runTests(false)
})

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Charlotte.Tools
{
	public class MutexObject : IDisposable
	{
		private Mutex _m;

		public MutexObject(string name)
		{
			_m = new Mutex(false, name);
		}

		public bool waitForMillis(int millis)
		{
			return _m.WaitOne(millis);
		}

		public void waitForever()
		{
			_m.WaitOne();
		}

		public void release()
		{
			_m.ReleaseMutex();
		}

		public void Dispose()
		{
			if (_m != null)
			{
				_m.Dispose();
				_m = null;
			}
		}

		public static IDisposable section(string name)
		{
			MutexObject mo = new MutexObject(name);

			mo.waitForever();

			return new DLeave(delegate
			{
				mo.release();
				mo.Dispose();
			});
		}

		public static IDisposable section(MutexObject mo)
		{
			mo.waitForever();

			return new DLeave(delegate
			{
				mo.release();
			});
		}
	}
}


text:
namespace Stripe
{
    using System;
    using Newtonsoft.Json;
    using Stripe.Infrastructure;

    public class SubscriptionScheduleListOptions : ListOptionsWithCreated
    {
        [JsonProperty("canceled_at")]
        [JsonConverter(typeof(AnyOfConverter))]
        public AnyOf<DateTime?, DateRangeOptions> CanceledAt { get; set; }

        [JsonProperty("completed_at")]
        [JsonConverter(typeof(AnyOfConverter))]
        public AnyOf<DateTime?, DateRangeOptions> CompletedAt { get; set; }

        [JsonProperty("customer")]
        public string Customer { get; set; }

        [JsonProperty("released_at")]
        [JsonConverter(typeof(AnyOfConverter))]
        public AnyOf<DateTime?, DateRangeOptions> ReleasedAt { get; set; }

        [JsonProperty("scheduled")]
        public bool? Scheduled { get; set; }
    }
}


text:
import React from 'react';
import {
  ActivityIndicator,
  Image,
  PixelRatio,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
  Dimensions,
} from 'react-native';

import globalVariables from '../globalVariables.js';
import moment from 'moment';
import Icon from 'react-native-vector-icons/Ionicons';
import Storage from './Storage.js';
import Login from './Login.js';
const { width, height } = Dimensions.get('window');

var LookCellFooter = React.createClass({
  getDefaultProps() {
    return {
     look: {},
     onSelect:()=>{},
    };
  },
  getInitialState() {
    return {
      hypes_count: this.props.look.hypes_count||0,
      isHype:false,
    };
  },
  module:{
    userHyped:null,
    user:null,
  },
  componentWillMount() {
    if(!this.props.look){
      return false;
    }
    // globalVariables.getUser((user)=>{
    //   if(!user)return;
    //     this.module.user=user;
    //   }
    // );
    globalVariables.getUserHyped((hyped)=>{
      if(!hyped)return;
        this.module.userHyped=hyped;
        this.setState({isHype:!!hyped[this.props.look.id]});
      }
    );
  },
  shouldComponentUpdate: function(nextProps, nextState) {
    return JSON.stringify(nextState)!=JSON.stringify(this.state);
  },
  render() {
    if(!this.props.look){
      return false;
    }

    return (
      <View style={styles.flexContainer}>
       <TouchableOpacity activeOpacity={0.8} onPress={this.onSelect} style={styles.cell}>
          <Icon name="ios-flame-outline" color={this.state.isHype?globalVariables.base:globalVariables.textBase} size={25}/>
          <Text style={[styles.text,{color:this.state.isHype?globalVariables.base:globalVariables.textBase}]}>
            {this.state.hypes_count}
          </Text>
      </TouchableOpacity>
      <View style={styles.separator} />
      <TouchableOpacity activeOpacity={0.8} onPress={this.props.onSelect} style={styles.cell}>
          <Icon name="ios-text-outline" color={globalVariables.textBase} size={25}/>
          <Text style={styles.text}>
            {this.props.look.comments_count}
          </Text>
      </TouchableOpacity>
      <View style={styles.separator} />
      <View style={styles.cell}>
        <Icon name="ios-heart-outline" color={globalVariables.textBase} size={23}/>
        <Text style={styles.text}>
          {this.props.look.loves_count}
        </Text>
      </View>
    </View>
    );
  },
  onSelect() {
     globalVariables.getUser((user)=>{
      if(!user){
        this.props.navigator.push({
          component: Login,
          backButtonTitle:' ',
          // backButtonIcon:this.state.backIcon,
          title: 'Login',
          passProps: {
            navigator:this.props.navigator,
          },
        });
        return;
      }else if(this.props.look && this.props.look.id){
        var hypes_count=this.state.isHype?this.state.hypes_count-1:this.state.hypes_count+1
        this.setState({
          hypes_count:hypes_count,
          isHype:!this.state.isHype,
        });
        globalVariables.queryRromServer(globalVariables.apiLookServer+(this.props.look.id)+"/hype",this.processsResults);
      }
    });
  },
  processsResults(data) {
    if (data && data.status=="unhyped") {
      delete this.module.userHyped[this.props.look.id];
      if(this.state.isHype){
        this.setState({
          hypes_count:this.state.hypes_count-1,
          isHype:false,
        });
      }
    }else if(data && data.status=="hyped") {
      this.module.userHyped[this.props.look.id]=this.props.look.id;
      if(!this.state.isHype){
        this.setState({
          hypes_count:this.state.hypes_count+1,
          isHype:true,
        });
      }
    }

    if (data && data.status){
      globalVariables.setUserHyped(this.module.userHyped);
    }
  }
});

const styles = StyleSheet.create({
  flexContainer: {
      flexDirection: 'row',
      opacity:0.97,
      padding: 5,
      backgroundColor: globalVariables.background,
      height:55,
  },
  cell: {
    flexDirection: 'row',
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  text:{
    color:globalVariables.textBase,
    fontSize:14,
    marginLeft:10,
  },
  separator: {
    backgroundColor: globalVariables.textBase2,
    height: 15 ,
    width:0.5,
    marginVertical: 15,
  },
  separator2: {
    backgroundColor: globalVariables.textBase2,
    height: 0.5 ,
    width:width-20,
    marginVertical: 10,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default LookCellFooter;


text:
class EdiOpsTransactionsController < ApplicationController
  helper_method :sort_column, :sort_direction, :edi_ops_transaction_path

  def index
    @q = params[:q]
    @qf = params[:qf]
    @qd = params[:qd]
    @edi_ops_transactions = EdiOpsTransaction.order_by(sort_column.to_sym.send(sort_direction)).search(@q, @qf, @qd).page(params[:page]).per(20)
  end

  def edit
    @edi_ops_transaction = EdiOpsTransaction.find(params[:id])
  end

  def update
    @edi_ops_transaction =  EdiOpsTransaction.find(params[:id])

    if @edi_ops_transaction.update_attributes(params[:edi_ops_transaction])
      redirect_to edi_ops_transactions_path
    else
      render "edit"
    end
  end

  private
    def sort_direction
      %w[asc desc].include?(params[:direction]) ?  params[:direction] : "asc"
    end

    def sort_column
      EdiOpsTransaction.fields.include?(params[:sort]) ? params[:sort] : "submitted_timestamp"
    end
end


text:
import {Component, OnInit} from 'angular2/core';

@Component({
	selector: 'home',
	template: `<h1>Home</h1>`
})

export class HomeComponent implements OnInit {

	constructor() { }

	ngOnInit() { }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements. See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership. The ASF licenses this file
  to you 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

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied. See the License for the
  specific language governing permissions and limitations
  under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>odata-server-sample</artifactId>
	<packaging>war</packaging>
	<name>${project.artifactId}</name>

	<parent>
		<groupId>org.apache.olingo</groupId>
		<artifactId>odata-samples</artifactId>
		<version>4.3.0-SNAPSHOT</version>
		<relativePath>..</relativePath>
	</parent>

	<properties>
		<version.slf4j>1.7.7</version.slf4j>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-deploy-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.apache.olingo</groupId>
			<artifactId>odata-server-api</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.olingo</groupId>
			<artifactId>odata-server-core</artifactId>
			<version>${project.version}</version>
			<scope>runtime</scope>
		</dependency>

		<dependency>
			<groupId>org.apache.olingo</groupId>
			<artifactId>odata-commons-api</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.olingo</groupId>
			<artifactId>odata-commons-core</artifactId>
			<version>${project.version}</version>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${version.slf4j}</version>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>${version.slf4j}</version>
			<scope>runtime</scope>
		</dependency>
	</dependencies>

</project>


text:
<?php
// This is ok ($initialized is used in condition)
class testStaticVarInMethod
{
    public function run()
    {
        static $initialized = false;
        if (!$initialized) {
            self::init();
            $initialized = true;
        }
    }

    public static function init()
    {
    }
}

// Not ok
class testStaticUnused
{
    public function run()
    {
        static $initialized = false;
        $initialized = true;
    }
}

class testStaticUsedIn
{
    public function run()
    {
        static $initialized = false;
        if ($initialized) return;
        $initialized = true;
        $this->innerMethod();
    }

    private function innerMethod()
    {
    }
}


text:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

// componets
import { DummyComponent } from './dummy.component';
import { DummyDirective } from './dummy.directive';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [
    DummyDirective,

    DummyComponent
  ]
})
export class DummyModule { }


text:
function arc4random()
    ccall((:arc4random, libxbraid), UInt32, ())
end

function arc4random_addrandom(arg1, arg2::Cint)
    ccall((:arc4random_addrandom, libxbraid), Nothing, (Ptr{Cuchar}, Cint), arg1, arg2)
end

function arc4random_buf(__buf, __nbytes::Csize_t)
    ccall((:arc4random_buf, libxbraid), Nothing, (Ptr{Nothing}, Csize_t), __buf, __nbytes)
end

function arc4random_stir()
    ccall((:arc4random_stir, libxbraid), Nothing, ())
end

function arc4random_uniform(__upper_bound::UInt32)
    ccall((:arc4random_uniform, libxbraid), UInt32, (UInt32,), __upper_bound)
end

function _braid_ErrorHandler(filename, line::braid_Int, ierr::braid_Int, msg)
    ccall((:_braid_ErrorHandler, libxbraid), Nothing, (Cstring, braid_Int, braid_Int, Cstring), filename, line, ierr, msg)
end

function StatusGetT(status::braid_Status, t_ptr)
    ccall((:braid_StatusGetT, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, t_ptr)
end

function StatusGetTIndex(status::braid_Status, idx_ptr)
    ccall((:braid_StatusGetTIndex, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, idx_ptr)
end

function StatusGetIter(status::braid_Status, iter_ptr)
    ccall((:braid_StatusGetIter, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, iter_ptr)
end

function StatusGetLevel(status::braid_Status, level_ptr)
    ccall((:braid_StatusGetLevel, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, level_ptr)
end

function StatusGetNRefine(status::braid_Status, nrefine_ptr)
    ccall((:braid_StatusGetNRefine, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, nrefine_ptr)
end

function StatusGetNTPoints(status::braid_Status, ntpoints_ptr)
    ccall((:braid_StatusGetNTPoints, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, ntpoints_ptr)
end

function StatusGetResidual(status::braid_Status, rnorm_ptr)
    ccall((:braid_StatusGetResidual, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, rnorm_ptr)
end

function StatusGetDone(status::braid_Status, done_ptr)
    ccall((:braid_StatusGetDone, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, done_ptr)
end

function StatusGetTILD(status::braid_Status, t_ptr, iter_ptr, level_ptr, done_ptr)
    ccall((:braid_StatusGetTILD, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}, Ptr{braid_Int}, Ptr{braid_Int}, Ptr{braid_Int}), status, t_ptr, iter_ptr, level_ptr, done_ptr)
end

function StatusGetWrapperTest(status::braid_Status, wtest_ptr)
    ccall((:braid_StatusGetWrapperTest, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, wtest_ptr)
end

function StatusGetCallingFunction(status::braid_Status, cfunction_ptr)
    ccall((:braid_StatusGetCallingFunction, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, cfunction_ptr)
end

function StatusGetCTprior(status::braid_Status, ctprior_ptr)
    ccall((:braid_StatusGetCTprior, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, ctprior_ptr)
end

function StatusGetCTstop(status::braid_Status, ctstop_ptr)
    ccall((:braid_StatusGetCTstop, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, ctstop_ptr)
end

function StatusGetFTprior(status::braid_Status, ftprior_ptr)
    ccall((:braid_StatusGetFTprior, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, ftprior_ptr)
end

function StatusGetFTstop(status::braid_Status, ftstop_ptr)
    ccall((:braid_StatusGetFTstop, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, ftstop_ptr)
end

function StatusGetTpriorTstop(status::braid_Status, t_ptr, ftprior_ptr, ftstop_ptr, ctprior_ptr, ctstop_ptr)
    ccall((:braid_StatusGetTpriorTstop, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}, Ptr{braid_Real}, Ptr{braid_Real}, Ptr{braid_Real}, Ptr{braid_Real}), status, t_ptr, ftprior_ptr, ftstop_ptr, ctprior_ptr, ctstop_ptr)
end

function StatusGetTstop(status::braid_Status, tstop_ptr)
    ccall((:braid_StatusGetTstop, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, tstop_ptr)
end

function StatusGetTstartTstop(status::braid_Status, tstart_ptr, tstop_ptr)
    ccall((:braid_StatusGetTstartTstop, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}, Ptr{braid_Real}), status, tstart_ptr, tstop_ptr)
end

function StatusGetTol(status::braid_Status, tol_ptr)
    ccall((:braid_StatusGetTol, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, tol_ptr)
end

function StatusGetRNorms(status::braid_Status, nrequest_ptr, rnorms_ptr)
    ccall((:braid_StatusGetRNorms, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}, Ptr{braid_Real}), status, nrequest_ptr, rnorms_ptr)
end

function StatusGetOldFineTolx(status::braid_Status, old_fine_tolx_ptr)
    ccall((:braid_StatusGetOldFineTolx, libxbraid), braid_Int, (braid_Status, Ptr{braid_Real}), status, old_fine_tolx_ptr)
end

function StatusSetOldFineTolx(status::braid_Status, old_fine_tolx::braid_Real)
    ccall((:braid_StatusSetOldFineTolx, libxbraid), braid_Int, (braid_Status, braid_Real), status, old_fine_tolx)
end

function StatusSetTightFineTolx(status::braid_Status, tight_fine_tolx::braid_Real)
    ccall((:braid_StatusSetTightFineTolx, libxbraid), braid_Int, (braid_Status, braid_Real), status, tight_fine_tolx)
end

function StatusSetRFactor(status::braid_Status, rfactor::braid_Real)
    ccall((:braid_StatusSetRFactor, libxbraid), braid_Int, (braid_Status, braid_Real), status, rfactor)
end

function StatusSetRSpace(status::braid_Status, r_space::braid_Real)
    ccall((:braid_StatusSetRSpace, libxbraid), braid_Int, (braid_Status, braid_Real), status, r_space)
end

function StatusGetMessageType(status::braid_Status, messagetype_ptr)
    ccall((:braid_StatusGetMessageType, libxbraid), braid_Int, (braid_Status, Ptr{braid_Int}), status, messagetype_ptr)
end

function StatusSetSize(status::braid_Status, size::braid_Real)
    ccall((:braid_StatusSetSize, libxbraid), braid_Int, (braid_Status, braid_Real), status, size)
end

function AccessStatusGetT(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetT, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Real}), s, v1)
end

function AccessStatusGetTIndex(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetTIndex, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetIter(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetIter, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetLevel(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetLevel, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetNRefine(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetNRefine, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetNTPoints(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetNTPoints, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetResidual(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetResidual, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Real}), s, v1)
end

function AccessStatusGetDone(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetDone, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetTILD(s::braid_AccessStatus, v1, v2, v3, v4)
    ccall((:braid_AccessStatusGetTILD, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Real}, Ptr{braid_Int}, Ptr{braid_Int}, Ptr{braid_Int}), s, v1, v2, v3, v4)
end

function AccessStatusGetWrapperTest(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetWrapperTest, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function AccessStatusGetCallingFunction(s::braid_AccessStatus, v1)
    ccall((:braid_AccessStatusGetCallingFunction, libxbraid), braid_Int, (braid_AccessStatus, Ptr{braid_Int}), s, v1)
end

function CoarsenRefStatusGetT(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetT, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Real}), s, v1)
end

function CoarsenRefStatusGetTIndex(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetTIndex, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Int}), s, v1)
end

function CoarsenRefStatusGetIter(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetIter, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Int}), s, v1)
end

function CoarsenRefStatusGetLevel(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetLevel, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Int}), s, v1)
end

function CoarsenRefStatusGetNRefine(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetNRefine, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Int}), s, v1)
end

function CoarsenRefStatusGetNTPoints(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetNTPoints, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Int}), s, v1)
end

function CoarsenRefStatusGetCTprior(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetCTprior, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Real}), s, v1)
end

function CoarsenRefStatusGetCTstop(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetCTstop, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Real}), s, v1)
end

function CoarsenRefStatusGetFTprior(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetFTprior, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Real}), s, v1)
end

function CoarsenRefStatusGetFTstop(s::braid_CoarsenRefStatus, v1)
    ccall((:braid_CoarsenRefStatusGetFTstop, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Real}), s, v1)
end

function CoarsenRefStatusGetTpriorTstop(s::braid_CoarsenRefStatus, v1, v2, v3, v4, v5)
    ccall((:braid_CoarsenRefStatusGetTpriorTstop, libxbraid), braid_Int, (braid_CoarsenRefStatus, Ptr{braid_Real}, Ptr{braid_Real}, Ptr{braid_Real}, Ptr{braid_Real}, Ptr{braid_Real}), s, v1, v2, v3, v4, v5)
end

function StepStatusGetT(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetT, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Real}), s, v1)
end

function StepStatusGetTIndex(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetTIndex, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Int}), s, v1)
end

function StepStatusGetIter(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetIter, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Int}), s, v1)
end

function StepStatusGetLevel(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetLevel, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Int}), s, v1)
end

function StepStatusGetNRefine(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetNRefine, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Int}), s, v1)
end

function StepStatusGetNTPoints(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetNTPoints, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Int}), s, v1)
end

function StepStatusGetTstop(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetTstop, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Real}), s, v1)
end

function StepStatusGetTstartTstop(s::braid_StepStatus, v1, v2)
    ccall((:braid_StepStatusGetTstartTstop, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Real}, Ptr{braid_Real}), s, v1, v2)
end

function StepStatusGetTol(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetTol, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Real}), s, v1)
end

function StepStatusGetRNorms(s::braid_StepStatus, v1, v2)
    ccall((:braid_StepStatusGetRNorms, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Int}, Ptr{braid_Real}), s, v1, v2)
end

function StepStatusGetOldFineTolx(s::braid_StepStatus, v1)
    ccall((:braid_StepStatusGetOldFineTolx, libxbraid), braid_Int, (braid_StepStatus, Ptr{braid_Real}), s, v1)
end

function StepStatusSetOldFineTolx(s::braid_StepStatus, v1::braid_Real)
    ccall((:braid_StepStatusSetOldFineTolx, libxbraid), braid_Int, (braid_StepStatus, braid_Real), s, v1)
end

function StepStatusSetTightFineTolx(s::braid_StepStatus, v1::braid_Real)
    ccall((:braid_StepStatusSetTightFineTolx, libxbraid), braid_Int, (braid_StepStatus, braid_Real), s, v1)
end

function StepStatusSetRFactor(s::braid_StepStatus, v1::braid_Real)
    ccall((:braid_StepStatusSetRFactor, libxbraid), braid_Int, (braid_StepStatus, braid_Real), s, v1)
end

function StepStatusSetRSpace(s::braid_StepStatus, v1::braid_Real)
    ccall((:braid_StepStatusSetRSpace, libxbraid), braid_Int, (braid_StepStatus, braid_Real), s, v1)
end

function BufferStatusGetMessageType(s::braid_BufferStatus, v1)
    ccall((:braid_BufferStatusGetMessageType, libxbraid), braid_Int, (braid_BufferStatus, Ptr{braid_Int}), s, v1)
end

function BufferStatusSetSize(s::braid_BufferStatus, v1::braid_Real)
    ccall((:braid_BufferStatusSetSize, libxbraid), braid_Int, (braid_BufferStatus, braid_Real), s, v1)
end

function Init(comm_world::MPI.Comm, comm::MPI.Comm, tstart::braid_Real, tstop::braid_Real, ntime::Integer, app, step::braid_PtFcnStep, init::braid_PtFcnInit, clone::braid_PtFcnClone, free::braid_PtFcnFree, sum::braid_PtFcnSum, spatialnorm::braid_PtFcnSpatialNorm, access::braid_PtFcnAccess, bufsize::braid_PtFcnBufSize, bufpack::braid_PtFcnBufPack, bufunpack::braid_PtFcnBufUnpack, core)
    ccall(
        (:braid_Init, libxbraid),
        braid_Int,
        (Ref{Cint}, Ref{Cint}, braid_Real, braid_Real, braid_Int, braid_App, braid_PtFcnStep, braid_PtFcnInit, braid_PtFcnClone, braid_PtFcnFree, braid_PtFcnSum, braid_PtFcnSpatialNorm, braid_PtFcnAccess, braid_PtFcnBufSize, braid_PtFcnBufPack, braid_PtFcnBufUnpack, Ref{braid_Core}),
        comm_world.val, comm.val, tstart, tstop, ntime, app, step, init, clone, free, sum, spatialnorm, access, bufsize, bufpack, bufunpack, core
        )
end

function Drive(core::braid_Core)
    ccall((:braid_Drive, libxbraid), braid_Int, (braid_Core,), core)
end

function Destroy(core::braid_Core)
    ccall((:braid_Destroy, libxbraid), braid_Int, (braid_Core,), core)
end

function PrintStats(core::braid_Core)
    ccall((:braid_PrintStats, libxbraid), braid_Int, (braid_Core,), core)
end

function SetMaxLevels(core::braid_Core, max_levels::Integer)
    ccall((:braid_SetMaxLevels, libxbraid), braid_Int, (braid_Core, braid_Int), core, max_levels)
end

function SetSkip(core::braid_Core, skip::Integer)
    ccall((:braid_SetSkip, libxbraid), braid_Int, (braid_Core, braid_Int), core, skip)
end

function SetRefine(core::braid_Core, refine::Integer)
    ccall((:braid_SetRefine, libxbraid), braid_Int, (braid_Core, braid_Int), core, refine)
end

function SetMaxRefinements(core::braid_Core, max_refinements::Integer)
    ccall((:braid_SetMaxRefinements, libxbraid), braid_Int, (braid_Core, braid_Int), core, max_refinements)
end

function SetTPointsCutoff(core::braid_Core, tpoints_cutoff::Integer)
    ccall((:braid_SetTPointsCutoff, libxbraid), braid_Int, (braid_Core, braid_Int), core, tpoints_cutoff)
end

function SetMinCoarse(core::braid_Core, min_coarse::Integer)
    ccall((:braid_SetMinCoarse, libxbraid), braid_Int, (braid_Core, braid_Int), core, min_coarse)
end

function SetAbsTol(core::braid_Core, atol::braid_Real)
    ccall((:braid_SetAbsTol, libxbraid), braid_Int, (braid_Core, braid_Real), core, atol)
end

function SetRelTol(core::braid_Core, rtol::braid_Real)
    ccall((:braid_SetRelTol, libxbraid), braid_Int, (braid_Core, braid_Real), core, rtol)
end

function SetNRelax(core::braid_Core, level::Integer, nrelax::Integer)
    ccall((:braid_SetNRelax, libxbraid), braid_Int, (braid_Core, braid_Int, braid_Int), core, level, nrelax)
end

function SetCFactor(core::braid_Core, level::Integer, cfactor::Integer)
    ccall((:braid_SetCFactor, libxbraid), braid_Int, (braid_Core, braid_Int, braid_Int), core, level, cfactor)
end

function SetMaxIter(core::braid_Core, max_iter::Integer)
    ccall((:braid_SetMaxIter, libxbraid), braid_Int, (braid_Core, braid_Int), core, max_iter)
end

function SetFMG(core::braid_Core)
    ccall((:braid_SetFMG, libxbraid), braid_Int, (braid_Core,), core)
end

function SetNFMG(core::braid_Core, k::Integer)
    ccall((:braid_SetNFMG, libxbraid), braid_Int, (braid_Core, braid_Int), core, k)
end

function SetNFMGVcyc(core::braid_Core, nfmg_Vcyc::Integer)
    ccall((:braid_SetNFMGVcyc, libxbraid), braid_Int, (braid_Core, braid_Int), core, nfmg_Vcyc)
end

function SetStorage(core::braid_Core, storage::Integer)
    ccall((:braid_SetStorage, libxbraid), braid_Int, (braid_Core, braid_Int), core, storage)
end

function SetTemporalNorm(core::braid_Core, tnorm::Integer)
    ccall((:braid_SetTemporalNorm, libxbraid), braid_Int, (braid_Core, braid_Int), core, tnorm)
end

function SetResidual(core::braid_Core, residual::braid_PtFcnResidual)
    ccall((:braid_SetResidual, libxbraid), braid_Int, (braid_Core, braid_PtFcnResidual), core, residual)
end

function SetFullRNormRes(core::braid_Core, residual::braid_PtFcnResidual)
    ccall((:braid_SetFullRNormRes, libxbraid), braid_Int, (braid_Core, braid_PtFcnResidual), core, residual)
end

function SetTimeGrid(core::braid_Core, tgrid::braid_PtFcnTimeGrid)
    ccall((:braid_SetTimeGrid, libxbraid), braid_Int, (braid_Core, braid_PtFcnTimeGrid), core, tgrid)
end

function SetSpatialCoarsen(core::braid_Core, scoarsen::braid_PtFcnSCoarsen)
    ccall((:braid_SetSpatialCoarsen, libxbraid), braid_Int, (braid_Core, braid_PtFcnSCoarsen), core, scoarsen)
end

function SetSpatialRefine(core::braid_Core, srefine::braid_PtFcnSRefine)
    ccall((:braid_SetSpatialRefine, libxbraid), braid_Int, (braid_Core, braid_PtFcnSRefine), core, srefine)
end

function SetPrintLevel(core::braid_Core, print_level::Integer)
    ccall((:braid_SetPrintLevel, libxbraid), braid_Int, (braid_Core, braid_Int), core, print_level)
end

function SetPrintFile(core::braid_Core, printfile_name)
    ccall((:braid_SetPrintFile, libxbraid), braid_Int, (braid_Core, Cstring), core, printfile_name)
end

function SetDefaultPrintFile(core::braid_Core)
    ccall((:braid_SetDefaultPrintFile, libxbraid), braid_Int, (braid_Core,), core)
end

function SetAccessLevel(core::braid_Core, access_level::Integer)
    ccall((:braid_SetAccessLevel, libxbraid), braid_Int, (braid_Core, braid_Int), core, access_level)
end

function SplitCommworld(comm_world::MPI.Comm, px::braid_Int, comm_x::MPI.Comm, comm_t::MPI.Comm)
    ccall((:braid_SplitCommworld, libxbraid), braid_Int, (Ref{Nothing}, braid_Int, Ref{Nothing}, Ref{Nothing}), comm_world.val, px, comm_x.val, comm_t.val)
end

function SetShell(core::braid_Core, sinit::braid_PtFcnSInit, sclone::braid_PtFcnSClone, sfree::braid_PtFcnSFree)
    ccall((:braid_SetShell, libxbraid), braid_Int, (braid_Core, braid_PtFcnSInit, braid_PtFcnSClone, braid_PtFcnSFree), core, sinit, sclone, sfree)
end

function GetNumIter(core::braid_Core, niter_ptr)
    ccall((:braid_GetNumIter, libxbraid), braid_Int, (braid_Core, Ptr{braid_Int}), core, niter_ptr)
end

function GetRNorms(core::braid_Core, nrequest_ptr, rnorms)
    ccall((:braid_GetRNorms, libxbraid), braid_Int, (braid_Core, Ptr{braid_Int}, Ptr{braid_Real}), core, nrequest_ptr, rnorms)
end

function GetNLevels(core::braid_Core, nlevels_ptr)
    ccall((:braid_GetNLevels, libxbraid), braid_Int, (braid_Core, Ptr{braid_Int}), core, nlevels_ptr)
end

function GetSpatialAccuracy(status::braid_StepStatus, loose_tol::braid_Real, tight_tol::braid_Real, tol_ptr)
    ccall((:braid_GetSpatialAccuracy, libxbraid), braid_Int, (braid_StepStatus, braid_Real, braid_Real, Ptr{braid_Real}), status, loose_tol, tight_tol, tol_ptr)
end

function SetSeqSoln(core::braid_Core, seq_soln::Integer)
    ccall((:braid_SetSeqSoln, libxbraid), braid_Int, (braid_Core, braid_Int), core, seq_soln)
end


text:
package org.switchyard.component.soap;

import org.switchyard.BaseHandler;
import org.switchyard.Exchange;
import org.switchyard.ExchangePattern;
import org.switchyard.HandlerException;
import org.switchyard.Message;
import org.switchyard.Property;
import org.switchyard.common.xml.XMLHelper;
import org.switchyard.component.soap.util.SOAPUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * A mock up WebService provider.
 *
 * @author Magesh Kumar B <mageshbk@jboss.com> (C) 2011 Red Hat Inc.
 */
public class SOAPProvider extends BaseHandler {

    @Override
    public void handleMessage(Exchange exchange) throws HandlerException {
        Message message = exchange.createMessage();
        if (exchange.getContract().getProviderOperation().getExchangePattern().equals(ExchangePattern.IN_OUT)) {
            Message receivedMessage = exchange.getMessage();
            Node request = receivedMessage.getContent(Node.class);
            Element name = XMLHelper.getFirstChildElementByName(request, "arg0");
            Element fault = XMLHelper.getFirstChildElementByName(request, "CustomFaultMessage");

            String toWhom = "";
            if (name != null) {
                toWhom = name.getTextContent();
            }
            String response = null;
            if (toWhom.length() == 0) {
                if (fault != null) {
                    // for testing sendFault() with the message which is not SOAP/Fault format
                    message.setContent(fault);
                } else {
                    response = "<SOAP-ENV:fault xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                                + "   <faultcode>SOAP-ENV:Server.AppError</faultcode>"
                                + "   <faultstring>Invalid name</faultstring>"
                                + "   <detail>"
                                + "      <message>Looks like you did not specify a name!</message>"
                                + "      <errorcode>1000</errorcode>"
                                + "   </detail>"
                                + "</SOAP-ENV:fault>";
                    setContent(message, response);
                }
                exchange.sendFault(message);
            } else {
                Property soapActionProp = exchange.getContext().getProperty("Soapaction");
                if (soapActionProp == null) {
                    soapActionProp = exchange.getContext().getProperty("SOAPAction");
                }
                String soapAction = "";
                if (soapActionProp != null) {
                    soapAction = (String) soapActionProp.getValue();
                } else {
                    soapActionProp = exchange.getContext().getProperty("Content-Type");
                    if (soapActionProp == null) {
                        soapActionProp = exchange.getContext().getProperty("Content-type");
                    }
                    if (soapActionProp != null) {
                        soapAction = (String) soapActionProp.getValue();
                    }
                }
                response = "<test:sayHelloResponse xmlns:test=\"urn:switchyard-component-soap:test-ws:1.0\">"
                             + "   <return>Hello " + toWhom + "! The soapAction received is " + soapAction + "</return>"
                             + "</test:sayHelloResponse>";
                setContent(message, response);
                exchange.send(message);
            }
        }
    }

    private void setContent(Message message, String response) {
        try {
            Document responseDom = SOAPUtil.parseAsDom(response);
            message.setContent(responseDom.getDocumentElement());
        } catch (Exception e) {
            // Generate fault
        }
    }
}


text:
<?php

/* {{ form_row(form.children['oro_attachment___upload_image_mime_types']) }} */
class __TwigTemplate_4fd71d78c42265c45b6a5a74390c58df873a9ac451e63f7cffa666b610cf8aa2 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $__internal_55b8ee02ea2f89de4efdfb66e147d54657252745ef9460a019cc45c70175a5de = $this->env->getExtension("native_profiler");
        $__internal_55b8ee02ea2f89de4efdfb66e147d54657252745ef9460a019cc45c70175a5de->enter($__internal_55b8ee02ea2f89de4efdfb66e147d54657252745ef9460a019cc45c70175a5de_prof = new Twig_Profiler_Profile($this->getTemplateName(), "template", "{{ form_row(form.children['oro_attachment___upload_image_mime_types']) }}"));

        // line 1
        echo $this->env->getExtension('form')->renderer->searchAndRenderBlock($this->getAttribute($this->getAttribute((isset($context["form"]) ? $context["form"] : $this->getContext($context, "form")), "children", array()), "oro_attachment___upload_image_mime_types", array(), "array"), 'row');

        $__internal_55b8ee02ea2f89de4efdfb66e147d54657252745ef9460a019cc45c70175a5de->leave($__internal_55b8ee02ea2f89de4efdfb66e147d54657252745ef9460a019cc45c70175a5de_prof);

    }

    public function getTemplateName()
    {
        return "{{ form_row(form.children['oro_attachment___upload_image_mime_types']) }}";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  22 => 1,);
    }
}


text:
namespace arangodb { namespace fuerte { inline namespace v1 {

namespace {
template <typename SocketT, typename F>
void resolveConnect(detail::ConnectionConfiguration const& config,
                    asio_ns::ip::tcp::resolver& resolver,
                    SocketT& socket,
                    F&& done) {
  auto cb = [&socket, done = std::forward<F>(done)]
  (asio_ns::error_code const& ec,
   asio_ns::ip::tcp::resolver::iterator it) {
    if (ec) { // error
      done(ec);
      return;
    }

    // A successful resolve operation is guaranteed to pass a
    // non-empty range to the handler.
    auto cb = [done](asio_ns::error_code const& ec,
                     asio_ns::ip::tcp::resolver::iterator const&) {
      done(ec);
    };
    asio_ns::async_connect(socket, it, std::move(cb));
  };

  // windows does not like async_resolve
#ifdef _WIN32
  asio_ns::error_code ec;
  auto it = resolver.resolve(config._host, config._port, ec);
  cb(ec, it);
#else
  // Resolve the host asynchronous into a series of endpoints
  resolver.async_resolve(config._host, config._port, std::move(cb));
#endif
}
}

template<SocketType T>
struct Socket {};

template<>
struct Socket<SocketType::Tcp>  {
  Socket(EventLoopService&,
         asio_ns::io_context& ctx)
    : resolver(ctx), socket(ctx) {}

  ~Socket() {
    try {
      resolver.cancel();
      shutdown();
    } catch(...) {}
  }

  template<typename F>
  void connect(detail::ConnectionConfiguration const& config, F&& done) {
    resolveConnect(config, resolver, socket, std::forward<F>(done));
  }

  void shutdown() {
    if (socket.is_open()) {
      asio_ns::error_code ec; // prevents exceptions
      socket.cancel(ec);
      ec.clear();
      socket.shutdown(asio_ns::ip::tcp::socket::shutdown_both, ec);
      ec.clear();
      socket.close(ec);
    }
  }

  asio_ns::ip::tcp::resolver resolver;
  asio_ns::ip::tcp::socket socket;
};

template<>
struct Socket<fuerte::SocketType::Ssl> {
  Socket(EventLoopService& loop, asio_ns::io_context& ctx)
  : resolver(ctx), socket(ctx, loop.sslContext()) {}

  ~Socket() {
    try {
      resolver.cancel();
      shutdown();
    } catch(...) {}
  }

  template<typename F>
  void connect(detail::ConnectionConfiguration const& config, F&& done) {
    auto cb = [this, &config, done = std::forward<F>(done)](asio_ns::error_code const& ec) {
      if (ec) {
        done(ec);
        return;
      }

      // Perform SSL handshake and verify the remote host's certificate.
      socket.next_layer().set_option(asio_ns::ip::tcp::no_delay(true));
      if (config._verifyHost) {
        socket.set_verify_mode(asio_ns::ssl::verify_peer);
        socket.set_verify_callback(asio_ns::ssl::rfc2818_verification(config._host));
      } else {
        socket.set_verify_mode(asio_ns::ssl::verify_none);
      }

      socket.async_handshake(asio_ns::ssl::stream_base::client, std::move(done));
    };

    resolveConnect(config, resolver, socket.next_layer(), std::move(cb));
  }

  void shutdown() {
    if (socket.lowest_layer().is_open()) {
      asio_ns::error_code ec; // ignored
      socket.lowest_layer().cancel(ec);
      ec.clear();
      socket.shutdown(ec);
      ec.clear();
      socket.lowest_layer().shutdown(asio_ns::ip::tcp::socket::shutdown_both, ec);
      ec.clear();
      socket.lowest_layer().close(ec);
    }
  }

  asio_ns::ip::tcp::resolver resolver;
  asio_ns::ssl::stream<asio_ns::ip::tcp::socket> socket;
};

#ifdef ASIO_HAS_LOCAL_SOCKETS
template<>
struct Socket<fuerte::SocketType::Unix> {

  Socket(EventLoopService&, asio_ns::io_context& ctx) : socket(ctx) {}
  ~Socket() {
    shutdown();
  }

  template<typename CallbackT>
  void connect(detail::ConnectionConfiguration const& config, CallbackT done) {
    asio_ns::local::stream_protocol::endpoint ep(config._host);
    socket.async_connect(ep, [done](asio_ns::error_code const& ec) {
      done(ec);
    });
  }
  void shutdown() {
    if (socket.is_open()) {
      asio_ns::error_code error; // prevents exceptions
      socket.cancel(error);
      socket.shutdown(asio_ns::ip::tcp::socket::shutdown_both, error);
      socket.close(error);
    }
  }

  asio_ns::local::stream_protocol::socket socket;
};
#endif // ASIO_HAS_LOCAL_SOCKETS

}}}  // namespace arangodb::fuerte::v1
#endif


text:
require_relative "api_controller"

module FastlaneCI
  # Controller for providing all data relating to system settings
  class SettingJSONController < APIController
    HOME = "/data/settings"

    get HOME do
      return json(Services.setting_service.settings)
    end

    post "#{HOME}/:setting_key" do
      key = params[:setting_key]
      value = params[:value]

      setting = Services.setting_service.find_setting(setting_key: key.to_sym)

      if setting.nil?
        json_error!(
          error_message: "`#{params[:setting_key]}` not found.",
          error_key: "InvalidParameter.KeyNotFound",
          error_code: 404
        )
      end

      # TODO: security aspect, how do we make sure this can't be abused?
      # We don't want to hash/encrypt all of them, as this would make it harder for
      # people to manually update those files
      setting.value = value
      Services.setting_service.update_setting!(setting: setting)

      return json({ status: :success })
    end

    delete "#{HOME}/:setting_key" do
      begin
        # TODO: security for parameters as in the POST code
        Services.setting_service.reset_setting!(setting_key: params[:setting_key])
        return json({ status: :success })
      rescue SettingServiceKeyNotFoundError
        json_error!(
          error_message: "`#{params[:setting_key]}` not found.",
          error_key: "InvalidParameter.KeyNotFound",
          error_code: 404
        )
      end
    end
  end
end


text:
{% if content contains "data-flickr-embed='true" or content contains 'data-flickr-embed="true' %}
	<script src='https://embedr.flickr.com/assets/client-code.js' charset='utf-8' async='async'></script>
{% endif %}

{% capture content %}{{ content | replace:'<script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>', '' | replace:'data-header="true"', 'data-header="false"' | replace:'data-footer="true"','data-footer="false"' }}{% endcapture %}


text:
package com.mumu.core.operations.dense;

import com.mumu.core.operations.OpTest;
import no.uib.cipr.matrix.DenseMatrix;
import no.uib.cipr.matrix.DenseVector;
import no.uib.cipr.matrix.Vector;

public class NormalizationOpTest extends OpTest {
    public void testNormalization() {

        double[] betaData = {0,0};
        Vector beta = new DenseVector(betaData);
        double[] gammaData = {0.045765,  0.02327648};
        Vector gamma = new DenseVector(gammaData);
        double eps = 1e-06;

        double[][] data = {{0.01842667, 0.02363018},
                           {0.07906121, -0.07539749}};
        DenseMatrix inputs = new DenseMatrix(data);
        NormalizationOp op = new NormalizationOp(beta, gamma, eps);
        op.batchOp(inputs);

        System.out.println(inputs);

    }

}


text:
#pragma once
#include <aws/macie2/Macie2_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>

namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;

namespace Utils
{
namespace Json
{
  class JsonValue;
} // namespace Json
} // namespace Utils
namespace Macie2
{
namespace Model
{
  class AWS_MACIE2_API CreateMemberResult
  {
  public:
    CreateMemberResult();
    CreateMemberResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
    CreateMemberResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline const Aws::String& GetArn() const{ return m_arn; }

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline void SetArn(const Aws::String& value) { m_arn = value; }

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline void SetArn(Aws::String&& value) { m_arn = std::move(value); }

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline void SetArn(const char* value) { m_arn.assign(value); }

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline CreateMemberResult& WithArn(const Aws::String& value) { SetArn(value); return *this;}

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline CreateMemberResult& WithArn(Aws::String&& value) { SetArn(std::move(value)); return *this;}

    /**
     *
The Amazon Resource Name (ARN) of the account that was associated with the
     * master account.

     */
    inline CreateMemberResult& WithArn(const char* value) { SetArn(value); return *this;}

  private:

    Aws::String m_arn;
  };

} // namespace Model
} // namespace Macie2
} // namespace Aws


text:
package com.yetu.play.authenticator.utils

import java.util.UUID
import com.google.inject.{AbstractModule, Guice}
import com.google.inject.util.Modules
import com.mohiva.play.silhouette.api.{LoginInfo, Environment}
import com.mohiva.play.silhouette.impl.authenticators.SessionAuthenticator
import com.mohiva.play.silhouette.impl.providers.OAuth2Info
import com.mohiva.play.silhouette.test.FakeEnvironment
import com.yetu.play.authenticator.AuthenticatorGlobal
import com.yetu.play.authenticator.controllers.{ApplicationController, SocialAuthController}
import com.yetu.play.authenticator.models.User
import com.yetu.play.authenticator.models.daos.{UserDAOImpl, OAuth2InfoDAO}
import net.codingwell.scalaguice.ScalaModule
import com.yetu.play.authenticator.utils.di.SilhouetteModule

import FakeGlobal._
import play.api.Application
import play.api.mvc.RequestHeader
import play.api.mvc.Handler

/**
 * Provides a fake global to override the Guice injector.
 */
class FakeGlobal extends AuthenticatorGlobal {

  /**
   * Overrides the Guice injector.
   */
  override val injector = Guice.createInjector(Modules.`override`(new SilhouetteModule).`with`(new FakeModule))
  val oauth2InfoDao = injector.getInstance[OAuth2InfoDAO](classOf[OAuth2InfoDAO])
  val userDao  = injector.getInstance[UserDAOImpl](classOf[UserDAOImpl])
  oauth2InfoDao.save(FakeGlobal.identity.loginInfo, FakeGlobal.oauth2Info)
  userDao.save(identity)

  /**
   * A fake Guice module.
   */
  class FakeModule extends AbstractModule with ScalaModule {
    def configure() = {
      bind[Environment[User, SessionAuthenticator]].toInstance(env)
    }
  }

  override def onStart(app: Application): Unit = {}

  val socialAuthController = injector.getInstance[SocialAuthController](classOf[SocialAuthController])
  val applicationController = injector.getInstance[ApplicationController](classOf[ApplicationController])

  override def onRouteRequest(req: RequestHeader): Option[Handler] = {
    (req.method, req.path) match {

      case ("GET",  FakeGlobal.routeHelloTest)     => Some(applicationController.hello)
      case ("GET",  FakeGlobal.routeSignOut)       => Some(applicationController.signOut)
      case ("GET",  FakeGlobal.routeAuthenticate)  => Some(socialAuthController.authenticate("yetu"))
      case ("POST", FakeGlobal.routeApiLogout)    => Some(applicationController.apiLogout)
      case _ => None
    }
  }

}

object FakeGlobal {

  /**
   * An identity.
   */
  val identity = User(
    userUUID = UUID.randomUUID(),
    loginInfo = LoginInfo("provider", "user@user.com"),
    firstName = None,
    lastName = None,
    fullName = None,
    email = None,
    avatarURL = None
  )

  val oauth2Info = OAuth2Info("random_access_token")

  val routeHelloTest = "/helloTestRoute"
  val routeSignOut = "/signOut"
  val routeAuthenticate = "/authenticate/yetu"
  val routeApiLogout = "/api/logout"

  /**
   * A Silhouette fake environment.
   */
  implicit val env = FakeEnvironment[User, SessionAuthenticator](Seq(identity.loginInfo -> identity))

}


text:
namespace llvm {

class Module;

/// Pass to perform split of global variables.
class GlobalSplitPass : public PassInfoMixin<GlobalSplitPass> {
public:
  PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};

} // end namespace llvm

#endif // LLVM_TRANSFORMS_IPO_GLOBALSPLIT_H