text:
<!DOCTYPE html>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />

//@tag core
/**
 * Base class that provides a common interface for publishing events. Subclasses are expected to to have a property
 * "events" with all the events defined, and, optionally, a property "listeners" with configured listeners defined.
 *
 * For example:
 *
 *     Ext.define('Employee', {
 *         mixins: {
 *             observable: 'Ext.util.Observable'
 *         },
 *
 *         constructor: function (config) {
 *             // The Observable constructor copies all of the properties of `config` on
 *             // to `this` using {@link Ext#apply}. Further, the `listeners` property is
 *             // processed to add listeners.
 *             //
 *             this.mixins.observable.constructor.call(this, config);
 *
 *             this.addEvents(
 *                 'fired',
 *                 'quit'
 *             );
 *         }
 *     });
 *
 * This could then be used like this:
 *
 *     var newEmployee = new Employee({
 *         name: employeeName,
 *         listeners: {
 *             quit: function() {
 *                 // By default, "this" will be the object that fired the event.
 *                 alert(this.name + " has quit!");
 *             }
 *         }
 *     });
 */
Ext.define('Ext.util.Observable', function(Observable) {

    // Private Destroyable class which removes listeners
    var emptyArray = [],
        arrayProto = Array.prototype,
        arraySlice = arrayProto.slice,
        ExtEvent = Ext.util.Event,
        ListenerRemover = function(observable) {

            // Passed a ListenerRemover: return it
            if (observable instanceof ListenerRemover) {
                return observable;
            }

            this.observable = observable;

            // Called when addManagedListener is used with the event source as the second arg:
            // (owner, eventSource, args...)
            if (arguments[1].isObservable) {
                this.managedListeners = true;
            }
            this.args = arraySlice.call(arguments, 1);
        };

    ListenerRemover.prototype.destroy = function() {
        this.observable[this.managedListeners ? 'mun' : 'un'].apply(this.observable, this.args);
    };

    return {

        /* Begin Definitions */

        requires: ['Ext.util.Event', 'Ext.EventManager'],

        statics: {
            /**
            * Removes **all** added captures from the Observable.
            *
            * @param {Ext.util.Observable} o The Observable to release
            * @static
            */
            releaseCapture: function(o) {
                o.fireEvent = this.prototype.fireEvent;
            },

            /**
            * Starts capture on the specified Observable. All events will be passed to the supplied function with the event
            * name + standard signature of the event **before** the event is fired. If the supplied function returns false,
            * the event will not fire.
            *
            * @param {Ext.util.Observable} o The Observable to capture events from.
            * @param {Function} fn The function to call when an event is fired.
            * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed. Defaults to
            * the Observable firing the event.
            * @static
            */
            capture: function(o, fn, scope) {
                o.fireEvent = Ext.Function.createInterceptor(o.fireEvent, fn, scope);
            },

            /**
            * Sets observability on the passed class constructor.
            *
            * This makes any event fired on any instance of the passed class also fire a single event through
            * the **class** allowing for central handling of events on many instances at once.
            *
            * Usage:
            *
            *     Ext.util.Observable.observe(Ext.data.Connection);
            *     Ext.data.Connection.on('beforerequest', function(con, options) {
            *         console.log('Ajax request made to ' + options.url);
            *     });
            *
            * @param {Function} c The class constructor to make observable.
            * @param {Object} listeners An object containing a series of listeners to add. See {@link #addListener}.
            * @static
            */
            observe: function(cls, listeners) {
                if (cls) {
                    if (!cls.isObservable) {
                        Ext.applyIf(cls, new this());
                        this.capture(cls.prototype, cls.fireEvent, cls);
                    }
                    if (Ext.isObject(listeners)) {
                        cls.on(listeners);
                    }
                }
                return cls;
            },

            /**
            * Prepares a given class for observable instances. This method is called when a
            * class derives from this class or uses this class as a mixin.
            * @param {Function} T The class constructor to prepare.
            * @private
            */
            prepareClass: function (T, mixin) {
                // T.hasListeners is the object to track listeners on class T. This object's
                // prototype (__proto__) is the "hasListeners" of T.superclass.

                // Instances of T will create "hasListeners" that have T.hasListeners as their
                // immediate prototype (__proto__).

                if (!T.HasListeners) {
                    // We create a HasListeners "class" for this class. The "prototype" of the
                    // HasListeners class is an instance of the HasListeners class associated
                    // with this class's super class (or with Observable).
                    var HasListeners = function () {},
                        SuperHL = T.superclass.HasListeners || (mixin && mixin.HasListeners) ||
                                Observable.HasListeners;

                    // Make the HasListener class available on the class and its prototype:
                    T.prototype.HasListeners = T.HasListeners = HasListeners;

                    // And connect its "prototype" to the new HasListeners of our super class
                    // (which is also the class-level "hasListeners" instance).
                    HasListeners.prototype = T.hasListeners = new SuperHL();
                }
            }
        },

        /* End Definitions */

        /**
        * @cfg {Object} listeners
        *
        * A config object containing one or more event handlers to be added to this object during initialization. This
        * should be a valid listeners config object as specified in the {@link #addListener} example for attaching multiple
        * handlers at once.
        *
        * **DOM events from Ext JS {@link Ext.Component Components}**
        *
        * While _some_ Ext JS Component classes export selected DOM events (e.g. "click", "mouseover" etc), this is usually
        * only done when extra value can be added. For example the {@link Ext.view.View DataView}'s **`{@link
        * Ext.view.View#itemclick itemclick}`** event passing the node clicked on. To access DOM events directly from a
        * child element of a Component, we need to specify the `element` option to identify the Component property to add a
        * DOM listener to:
        *
        *     new Ext.panel.Panel({
        *         width: 400,
        *         height: 200,
        *         dockedItems: [{
        *             xtype: 'toolbar'
        *         }],
        *         listeners: {
        *             click: {
        *                 element: 'el', //bind to the underlying el property on the panel
        *                 fn: function(){ console.log('click el'); }
        *             },
        *             dblclick: {
        *                 element: 'body', //bind to the underlying body property on the panel
        *                 fn: function(){ console.log('dblclick body'); }
        *             }
        *         }
        *     });
        */

        /**
        * @property {Boolean} isObservable
        * `true` in this class to identify an object as an instantiated Observable, or subclass thereof.
        */
        isObservable: true,

        /**
        * @private
        * Initial suspended call count. Incremented when {@link #suspendEvents} is called, decremented when {@link #resumeEvents} is called.
        */
        eventsSuspended: 0,

        /**
        * @property {Object} hasListeners
        * @readonly
        * This object holds a key for any event that has a listener. The listener may be set
        * directly on the instance, or on its class or a super class (via {@link #observe}) or
        * on the {@link Ext.app.EventBus MVC EventBus}. The values of this object are truthy
        * (a non-zero number) and falsy (0 or undefined). They do not represent an exact count
        * of listeners. The value for an event is truthy if the event must be fired and is
        * falsy if there is no need to fire the event.
        *
        * The intended use of this property is to avoid the expense of fireEvent calls when
        * there are no listeners. This can be particularly helpful when one would otherwise
        * have to call fireEvent hundreds or thousands of times. It is used like this:
        *
        *      if (this.hasListeners.foo) {
        *          this.fireEvent('foo', this, arg1);
        *      }
        */

        constructor: function(config) {
            var me = this;

            Ext.apply(me, config);

            // The subclass may have already initialized it.
            if (!me.hasListeners) {
                me.hasListeners = new me.HasListeners();
            }

            me.events = me.events || {};
            if (me.listeners) {
                me.on(me.listeners);
                me.listeners = null; //Set as an instance property to pre-empt the prototype in case any are set there.
            }

            if (me.bubbleEvents) {
                me.enableBubble(me.bubbleEvents);
            }
        },

        onClassExtended: function (T) {
            if (!T.HasListeners) {
                // Some classes derive from us and some others derive from those classes. All
                // of these are passed to this method.
                Observable.prepareClass(T);
            }
        },

        // @private
        // Matches options property names within a listeners specification object  - property names which are never used as event names.
        eventOptionsRe : /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|element|destroyable|vertical|horizontal|freezeEvent|priority)$/,

        /**
        * Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is
        * destroyed.
        *
        * @param {Ext.util.Observable/Ext.Element} item The item to which to add a listener/listeners.
        * @param {Object/String} ename The event name, or an object containing event name properties.
        * @param {Function} fn (optional) If the `ename` parameter was an event name, this is the handler function.
        * @param {Object} scope (optional) If the `ename` parameter was an event name, this is the scope (`this` reference)
        * in which the handler function is executed.
        * @param {Object} options (optional) If the `ename` parameter was an event name, this is the
        * {@link Ext.util.Observable#addListener addListener} options.
        * @return {Object} **Only when the `destroyable` option is specified. **
        *
        *  A `Destroyable` object. An object which implements the `destroy` method which removes all listeners added in this call. For example:
        *
        *     this.btnListeners =  = myButton.mon({
        *         destroyable: true
        *         mouseover:   function() { console.log('mouseover'); },
        *         mouseout:    function() { console.log('mouseout'); },
        *         click:       function() { console.log('click'); }
        *     });
        *
        * And when those listeners need to be removed:
        *
        *     Ext.destroy(this.btnListeners);
        *
        * or
        *
        *     this.btnListeners.destroy();
        */
        addManagedListener : function(item, ename, fn, scope, options, /* private */ noDestroy) {
            var me = this,
                managedListeners = me.managedListeners = me.managedListeners || [],
                config, passedOptions;

            if (typeof ename !== 'string') {
                // When creating listeners using the object form, allow caller to override the default of
                // using the listeners object as options.
                // This is used by relayEvents, when adding its relayer so that it does not contibute
                // a spurious options param to the end of the arg list.
                passedOptions = arguments.length > 4 ? options : ename;

                options = ename;
                for (ename in options) {
                    if (options.hasOwnProperty(ename)) {
                        config = options[ename];
                        if (!me.eventOptionsRe.test(ename)) {
                            // recurse, but pass the noDestroy parameter as true so that lots of individual Destroyables are not created.
                            // We create a single one at the end if necessary.
                            me.addManagedListener(item, ename, config.fn || config, config.scope || options.scope || scope, config.fn ? config : passedOptions, true);
                        }
                    }
                }
                if (options && options.destroyable) {
                    return new ListenerRemover(me, item, options);
                }
            }
            else {
                if (typeof fn === 'string') {
                    scope = scope || me;
                    //<debug>
                    if (!(scope[fn])) {
                        Ext.Error.raise('No method named "' + fn + '"');
                    }
                    //</debug>
                    fn = scope[fn];
                }
                managedListeners.push({
                    item: item,
                    ename: ename,
                    fn: fn,
                    scope: scope,
                    options: options
                });

                item.on(ename, fn, scope, options);

                // The 'noDestroy' flag is sent if we're looping through a hash of listeners passing each one to addManagedListener separately
                if (!noDestroy && options && options.destroyable) {
                    return new ListenerRemover(me, item, ename, fn, scope);
                }
            }
        },

        /**
        * Removes listeners that were added by the {@link #mon} method.
        *
        * @param {Ext.util.Observable/Ext.Element} item The item from which to remove a listener/listeners.
        * @param {Object/String} ename The event name, or an object containing event name properties.
        * @param {Function} fn (optional) If the `ename` parameter was an event name, this is the handler function.
        * @param {Object} scope (optional) If the `ename` parameter was an event name, this is the scope (`this` reference)
        * in which the handler function is executed.
        */
        removeManagedListener : function(item, ename, fn, scope) {
            var me = this,
                options,
                config,
                managedListeners,
                length,
                i;

            if (typeof ename !== 'string') {
                options = ename;
                for (ename in options) {
                    if (options.hasOwnProperty(ename)) {
                        config = options[ename];
                        if (!me.eventOptionsRe.test(ename)) {
                            me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope || scope);
                        }
                    }
                }
            } else {

                managedListeners = me.managedListeners ? me.managedListeners.slice() : [];

                for (i = 0, length = managedListeners.length; i < length; i++) {
                    me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope);
                }
            }
        },

        /**
        * Fires the specified event with the passed parameters (minus the event name, plus the `options` object passed
        * to {@link #addListener}).
        *
        * An event may be set to bubble up an Observable parent hierarchy (See {@link Ext.Component#getBubbleTarget}) by
        * calling {@link #enableBubble}.
        *
        * @param {String} eventName The name of the event to fire.
        * @param {Object...} args Variable number of parameters are passed to handlers.
        * @return {Boolean} returns false if any of the handlers return false otherwise it returns true.
        */
        fireEvent: function(eventName) {
            return this.fireEventArgs(eventName, Array.prototype.slice.call(arguments, 1));
        },

        /**
        * Fires the specified event with the passed parameter list.
        *
        * An event may be set to bubble up an Observable parent hierarchy (See {@link Ext.Component#getBubbleTarget}) by
        * calling {@link #enableBubble}.
        *
        * @param {String} eventName The name of the event to fire.
        * @param {Object[]} args An array of parameters which are passed to handlers.
        * @return {Boolean} returns false if any of the handlers return false otherwise it returns true.
        */
        fireEventArgs: function(eventName, args) {
            eventName = eventName.toLowerCase();
            var me = this,
                events = me.events,
                event = events && events[eventName],
                ret = true;

            // Only continue firing the event if there are listeners to be informed.
            // Bubbled events will always have a listener count, so will be fired.
            if (event && me.hasListeners[eventName]) {
                ret = me.continueFireEvent(eventName, args || emptyArray, event.bubble);
            }
            return ret;
        },

        /**
        * Continue to fire event.
        * @private
        *
        * @param {String} eventName
        * @param {Array} args
        * @param {Boolean} bubbles
        */
        continueFireEvent: function(eventName, args, bubbles) {
            var target = this,
                queue, event,
                ret = true;

            do {
                if (target.eventsSuspended) {
                    if ((queue = target.eventQueue)) {
                        queue.push([eventName, args, bubbles]);
                    }
                    return ret;
                } else {
                    event = target.events[eventName];
                    // Continue bubbling if event exists and it is `true` or the handler didn't returns false and it
                    // configure to bubble.
                    if (event && event != true) {
                        if ((ret = event.fire.apply(event, args)) === false) {
                            break;
                        }
                    }
                }
            } while (bubbles && (target = target.getBubbleParent()));
            return ret;
        },

        /**
        * Gets the bubbling parent for an Observable
        * @private
        * @return {Ext.util.Observable} The bubble parent. null is returned if no bubble target exists
        */
        getBubbleParent: function() {
            var me = this, parent = me.getBubbleTarget && me.getBubbleTarget();
            if (parent && parent.isObservable) {
                return parent;
            }
            return null;
        },

        /**
        * Appends an event handler to this object.  For example:
        *
        *     myGridPanel.on("mouseover", this.onMouseOver, this);
        *
        * The method also allows for a single argument to be passed which is a config object
        * containing properties which specify multiple events. For example:
        *
        *     myGridPanel.on({
        *         cellClick: this.onCellClick,
        *         mouseover: this.onMouseOver,
        *         mouseout: this.onMouseOut,
        *         scope: this // Important. Ensure "this" is correct during handler execution
        *     });
        *
        * One can also specify options for each event handler separately:
        *
        *     myGridPanel.on({
        *         cellClick: {fn: this.onCellClick, scope: this, single: true},
        *         mouseover: {fn: panel.onMouseOver, scope: panel}
        *     });
        *
        * *Names* of methods in a specified scope may also be used. Note that
        * `scope` MUST be specified to use this option:
        *
        *     myGridPanel.on({
        *         cellClick: {fn: 'onCellClick', scope: this, single: true},
        *         mouseover: {fn: 'onMouseOver', scope: panel}
        *     });
        *
        * @param {String/Object} eventName The name of the event to listen for.
        * May also be an object who's property names are event names.
        *
        * @param {Function} [fn] The method the event invokes, or *if `scope` is specified, the *name* of the method within
        * the specified `scope`.  Will be called with arguments
        * given to {@link Ext.util.Observable#fireEvent} plus the `options` parameter described below.
        *
        * @param {Object} [scope] The scope (`this` reference) in which the handler function is
        * executed. **If omitted, defaults to the object which fired the event.**
        *
        * @param {Object} [options] An object containing handler configuration.
        *
        * **Note:** Unlike in ExtJS 3.x, the options object will also be passed as the last
        * argument to every event handler.
        *
        * This object may contain any of the following properties:
        *
        * @param {Object} options.scope
        *   The scope (`this` reference) in which the handler function is executed. **If omitted,
        *   defaults to the object which fired the event.**
        *
        * @param {Number} options.delay
        *   The number of milliseconds to delay the invocation of the handler after the event fires.
        *
        * @param {Boolean} options.single
        *   True to add a handler to handle just the next firing of the event, and then remove itself.
        *
        * @param {Number} options.buffer
        *   Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
        *   by the specified number of milliseconds. If the event fires again within that time,
        *   the original handler is _not_ invoked, but the new handler is scheduled in its place.
        *
        * @param {Ext.util.Observable} options.target
        *   Only call the handler if the event was fired on the target Observable, _not_ if the event
        *   was bubbled up from a child Observable.
        *
        * @param {String} options.element
        *   **This option is only valid for listeners bound to {@link Ext.Component Components}.**
        *   The name of a Component property which references an element to add a listener to.
        *
        *   This option is useful during Component construction to add DOM event listeners to elements of
        *   {@link Ext.Component Components} which will exist only after the Component is rendered.
        *   For example, to add a click listener to a Panel's body:
        *
        *       new Ext.panel.Panel({
        *           title: 'The title',
        *           listeners: {
        *               click: this.handlePanelClick,
        *               element: 'body'
        *           }
        *       });
        *
        * @param {Boolean} [options.destroyable=false]
        *   When specified as `true`, the function returns A `Destroyable` object. An object which implements the `destroy` method which removes all listeners added in this call.
        *
        * @param {Number} [options.priority]
        *   An optional numeric priority that determines the order in which event handlers
        *   are run. Event handlers with no priority will be run as if they had a priority
        *   of 0. Handlers with a higher priority will be prioritized to run sooner than
        *   those with a lower priority.  Negative numbers can be used to set a priority
        *   lower than the default. Internally, the framework uses a range of 1000 or
        *   greater, and -1000 or lesser for handers that are intended to run before or
        *   after all others, so it is recommended to stay within the range of -999 to 999
        *   when setting the priority of event handlers in application-level code.
        *
        * **Combining Options**
        *
        * Using the options argument, it is possible to combine different types of listeners:
        *
        * A delayed, one-time listener.
        *
        *     myPanel.on('hide', this.handleClick, this, {
        *         single: true,
        *         delay: 100
        *     });
        *
        * @return {Object} **Only when the `destroyable` option is specified. **
        *
        *  A `Destroyable` object. An object which implements the `destroy` method which removes all listeners added in this call. For example:
        *
        *     this.btnListeners =  = myButton.on({
        *         destroyable: true
        *         mouseover:   function() { console.log('mouseover'); },
        *         mouseout:    function() { console.log('mouseout'); },
        *         click:       function() { console.log('click'); }
        *     });
        *
        * And when those listeners need to be removed:
        *
        *     Ext.destroy(this.btnListeners);
        *
        * or
        *
        *     this.btnListeners.destroy();
        */
        addListener: function(ename, fn, scope, options) {
            var me = this,
                config, event,
                prevListenerCount = 0;

            // Object listener hash passed
            if (typeof ename !== 'string') {
                options = ename;
                for (ename in options) {
                    if (options.hasOwnProperty(ename)) {
                        config = options[ename];
                        if (!me.eventOptionsRe.test(ename)) {
                            /* This would be an API change so check removed until https://sencha.jira.com/browse/EXTJSIV-7183 is fully implemented in 4.2
                            // Test must go here as well as in the simple form because of the attempted property access here on the config object.
                            //<debug>
                            if (!config || (typeof config !== 'function' && !config.fn)) {
                                Ext.Error.raise('No function passed for event ' + me.$className + '.' + ename);
                            }
                            //</debug>
                            */
                            me.addListener(ename, config.fn || config, config.scope || options.scope, config.fn ? config : options);
                        }
                    }
                }
                if (options && options.destroyable) {
                    return new ListenerRemover(me, options);
                }
            }
            // String, function passed
            else {
                ename = ename.toLowerCase();
                event = me.events[ename];
                if (event && event.isEvent) {
                    prevListenerCount = event.listeners.length;
                } else {
                    me.events[ename] = event = new ExtEvent(me, ename);
                }
                //<debug>
                if (!fn) {
                    Ext.Error.raise('No function passed for event ' + me.$className + '.' + ename);
                }
                //</debug>

                // Allow listeners: { click: 'onClick', scope: myObject }
                if (typeof fn === 'string') {
                    scope = scope || me;
                    //<debug>
                    if (!(scope[fn])) {
                        Ext.Error.raise('No method named "' + fn + '"');
                    }
                    //</debug>
                    fn = scope[fn];
                }
                event.addListener(fn, scope, options);

                // If a new listener has been added (Event.addListener rejects duplicates of the same fn+scope)
                // then increment the hasListeners counter
                if (event.listeners.length !== prevListenerCount) {
                    me.hasListeners._incr_(ename);
                }
                if (options && options.destroyable) {
                    return new ListenerRemover(me, ename, fn, scope, options);
                }
            }
        },

        /**
        * Removes an event handler.
        *
        * @param {String} eventName The type of event the handler was associated with.
        * @param {Function} fn The handler to remove. **This must be a reference to the function passed into the
        * {@link Ext.util.Observable#addListener} call.**
        * @param {Object} scope (optional) The scope originally specified for the handler. It must be the same as the
        * scope argument specified in the original call to {@link Ext.util.Observable#addListener} or the listener will not be removed.
        */
        removeListener: function(ename, fn, scope) {
            var me = this,
                config,
                event,
                options;

            if (typeof ename !== 'string') {
                options = ename;
                for (ename in options) {
                    if (options.hasOwnProperty(ename)) {
                        config = options[ename];
                        if (!me.eventOptionsRe.test(ename)) {
                            me.removeListener(ename, config.fn || config, config.scope || options.scope);
                        }
                    }
                }
            } else {
                ename = ename.toLowerCase();
                event = me.events[ename];
                if (event && event.isEvent) {
                    if (event.removeListener(fn, scope)) {
                        me.hasListeners._decr_(ename);
                    }
                }
            }
        },

        /**
        * Removes all listeners for this object including the managed listeners
        */
        clearListeners: function() {
            var events = this.events,
                hasListeners = this.hasListeners,
                event,
                key;

            for (key in events) {
                if (events.hasOwnProperty(key)) {
                    event = events[key];
                    if (event.isEvent) {
                        delete hasListeners[key];
                        event.clearListeners();
                    }
                }
            }

            this.clearManagedListeners();
        },

        //<debug>
        purgeListeners : function() {
            if (Ext.global.console) {
                Ext.global.console.warn('Observable: purgeListeners has been deprecated. Please use clearListeners.');
            }
            return this.clearListeners.apply(this, arguments);
        },
        //</debug>

        /**
        * Removes all managed listeners for this object.
        */
        clearManagedListeners : function() {
            var managedListeners = this.managedListeners || [],
                i = 0,
                len = managedListeners.length;

            for (; i < len; i++) {
                this.removeManagedListenerItem(true, managedListeners[i]);
            }

            this.managedListeners = [];
        },

        /**
        * Remove a single managed listener item
        * @private
        * @param {Boolean} isClear True if this is being called during a clear
        * @param {Object} managedListener The managed listener item
        * See removeManagedListener for other args
        */
        removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){
            if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {
                managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope);
                if (!isClear) {
                    Ext.Array.remove(this.managedListeners, managedListener);
                }
            }
        },

        //<debug>
        purgeManagedListeners : function() {
            if (Ext.global.console) {
                Ext.global.console.warn('Observable: purgeManagedListeners has been deprecated. Please use clearManagedListeners.');
            }
            return this.clearManagedListeners.apply(this, arguments);
        },
        //</debug>

        /**
        * Adds the specified events to the list of events which this Observable may fire.
        *
        * @param {Object/String...} eventNames Either an object with event names as properties with
        * a value of `true`. For example:
        *
        *     this.addEvents({
        *         storeloaded: true,
        *         storecleared: true
        *     });
        *
        * Or any number of event names as separate parameters. For example:
        *
        *     this.addEvents('storeloaded', 'storecleared');
        *
        */
        addEvents: function(o) {
            var me = this,
                events = me.events || (me.events = {}),
                arg, args, i;

            if (typeof o == 'string') {
                for (args = arguments, i = args.length; i--; ) {
                    arg = args[i];
                    if (!events[arg]) {
                        events[arg] = true;
                    }
                }
            } else {
                Ext.applyIf(me.events, o);
            }
        },

        /**
        * Checks to see if this object has any listeners for a specified event, or whether the event bubbles. The answer
        * indicates whether the event needs firing or not.
        *
        * @param {String} eventName The name of the event to check for
        * @return {Boolean} `true` if the event is being listened for or bubbles, else `false`
        */
        hasListener: function(ename) {
            return !!this.hasListeners[ename.toLowerCase()];
        },

        /**
        * Suspends the firing of all events. (see {@link #resumeEvents})
        *
        * @param {Boolean} queueSuspended Pass as true to queue up suspended events to be fired
        * after the {@link #resumeEvents} call instead of discarding all suspended events.
        */
        suspendEvents: function(queueSuspended) {
            this.eventsSuspended += 1;
            if (queueSuspended && !this.eventQueue) {
                this.eventQueue = [];
            }
        },

        /**
         * Suspends firing of the named event(s).
         *
         * After calling this method to suspend events, the events will no longer fire when requested to fire.
         *
         * **Note that if this is called multiple times for a certain event, the converse method
         * {@link #resumeEvent} will have to be called the same number of times for it to resume firing.**
         *
         * @param  {String...} eventName Multiple event names to suspend.
         */
        suspendEvent: function(eventName) {
            var len = arguments.length,
                i, event;

            for (i = 0; i < len; i++) {
                event = this.events[arguments[i]];

                // If it exists, and is an Event object (not still a boolean placeholder), suspend it
                if (event && event.suspend) {
                    event.suspend();
                }
            }
        },

        /**
         * Resumes firing of the named event(s).
         *
         * After calling this method to resume events, the events will fire when requested to fire.
         *
         * **Note that if the {@link #suspendEvent} method is called multiple times for a certain event,
         * this converse method will have to be called the same number of times for it to resume firing.**
         *
         * @param  {String...} eventName Multiple event names to resume.
         */
        resumeEvent: function() {
            var len = arguments.length,
                i, event;

            for (i = 0; i < len; i++) {

                // If it exists, and is an Event object (not still a boolean placeholder), resume it
                event = this.events[arguments[i]];
                if (event && event.resume) {
                    event.resume();
                }
            }
        },

        /**
        * Resumes firing events (see {@link #suspendEvents}).
        *
        * If events were suspended using the `queueSuspended` parameter, then all events fired
        * during event suspension will be sent to any listeners now.
        */
        resumeEvents: function() {
            var me = this,
                queued = me.eventQueue,
                qLen, q;

            if (me.eventsSuspended && ! --me.eventsSuspended) {
                delete me.eventQueue;

                if (queued) {
                    qLen = queued.length;
                    for (q = 0; q < qLen; q++) {
                        me.continueFireEvent.apply(me, queued[q]);
                    }
                }
            }
        },

        /**
        * Relays selected events from the specified Observable as if the events were fired by `this`.
        *
        * For example if you are extending Grid, you might decide to forward some events from store.
        * So you can do this inside your initComponent:
        *
        *     this.relayEvents(this.getStore(), ['load']);
        *
        * The grid instance will then have an observable 'load' event which will be passed the
        * parameters of the store's load event and any function fired with the grid's load event
        * would have access to the grid using the `this` keyword.
        *
        * @param {Object} origin The Observable whose events this object is to relay.
        * @param {String[]} events Array of event names to relay.
        * @param {String} [prefix] A common prefix to prepend to the event names. For example:
        *
        *     this.relayEvents(this.getStore(), ['load', 'clear'], 'store');
        *
        * Now the grid will forward 'load' and 'clear' events of store as 'storeload' and 'storeclear'.
        *
        * @return {Object} A `Destroyable` object. An object which implements the `destroy` method which, when destroyed, removes all relayers. For example:
        *
        *     this.storeRelayers = this.relayEvents(this.getStore(), ['load', 'clear'], 'store');
        *
        * Can be undone by calling
        *
        *     Ext.destroy(this.storeRelayers);
        *
        * or
        *     this.store.relayers.destroy();
        */
        relayEvents : function(origin, events, prefix) {
            var me = this,
                len = events.length,
                i = 0,
                oldName,
                relayers = {};

            for (; i < len; i++) {
                oldName = events[i];

                // Build up the listener hash.
                relayers[oldName] = me.createRelayer(prefix ? prefix + oldName : oldName);
            }
            // Add the relaying listeners as ManagedListeners so that they are removed when this.clearListeners is called (usually when _this_ is destroyed)
            // Explicitly pass options as undefined so that the listener does not get an extra options param
            // which then has to be sliced off in the relayer.
            me.mon(origin, relayers, null, null, undefined);

            // relayed events are always destroyable.
            return new ListenerRemover(me, origin, relayers);
        },

        /**
        * @private
        * Creates an event handling function which refires the event from this object as the passed event name.
        * @param {String} newName The name under which to refire the passed parameters.
        * @param {Array} beginEnd (optional) The caller can specify on which indices to slice.
        * @returns {Function}
        */
        createRelayer: function(newName, beginEnd) {
            var me = this;
            return function() {
                return me.fireEventArgs.call(me, newName, beginEnd ? Array.prototype.slice.apply(arguments, beginEnd) : arguments);
            };
        },

        /**
        * Enables events fired by this Observable to bubble up an owner hierarchy by calling `this.getBubbleTarget()` if
        * present. There is no implementation in the Observable base class.
        *
        * This is commonly used by Ext.Components to bubble events to owner Containers.
        * See {@link Ext.Component#getBubbleTarget}. The default implementation in Ext.Component returns the
        * Component's immediate owner. But if a known target is required, this can be overridden to access the
        * required target more quickly.
        *
        * Example:
        *
        *     Ext.define('Ext.overrides.form.field.Base', {
        *         override: 'Ext.form.field.Base',
        *
        *         //  Add functionality to Field's initComponent to enable the change event to bubble
        *         initComponent: function () {
        *             this.callParent();
        *             this.enableBubble('change');
        *         }
        *     });
        *
        *     var myForm = Ext.create('Ext.form.Panel', {
        *         title: 'User Details',
        *         items: [{
        *             ...
        *         }],
        *         listeners: {
        *             change: function() {
        *                 // Title goes red if form has been modified.
        *                 myForm.header.setStyle('color', 'red');
        *             }
        *         }
        *     });
        *
        * @param {String/String[]} eventNames The event name to bubble, or an Array of event names.
        */
        enableBubble: function(eventNames) {
            if (eventNames) {
                var me = this,
                    names = (typeof eventNames == 'string') ? arguments : eventNames,
                    length = names.length,
                    events = me.events,
                    ename, event, i;

                for (i = 0; i < length; ++i) {
                    ename = names[i].toLowerCase();
                    event = events[ename];

                    if (!event || typeof event == 'boolean') {
                        events[ename] = event = new ExtEvent(me, ename);
                    }

                    // Event must fire if it bubbles (We don't know if anyone up the
                    // bubble hierarchy has listeners added)
                    me.hasListeners._incr_(ename);

                    event.bubble = true;
                }
            }
        }
    };
}, function() {
    var Observable = this,
        proto = Observable.prototype,
        HasListeners = function () {},
        prepareMixin = function (T) {
            if (!T.HasListeners) {
                var proto = T.prototype;

                // Classes that use us as a mixin (best practice) need to be prepared.
                Observable.prepareClass(T, this);

                // Now that we are mixed in to class T, we need to watch T for derivations
                // and prepare them also.
                T.onExtended(function (U) {
                    //<debug>
                    Ext.classSystemMonitor && Ext.classSystemMonitor('extend mixin', arguments);
                    //</debug>

                    Observable.prepareClass(U);
                });

                // Also, if a class uses us as a mixin and that class is then used as
                // a mixin, we need to be notified of that as well.
                if (proto.onClassMixedIn) {
                    // play nice with other potential overrides...
                    Ext.override(T, {
                        onClassMixedIn: function (U) {
                            prepareMixin.call(this, U);
                            this.callParent(arguments);
                        }
                    });
                } else {
                    // just us chickens, so add the method...
                    proto.onClassMixedIn = function (U) {
                        prepareMixin.call(this, U);
                    };
                }
            }
        },
        globalEvents;

    HasListeners.prototype = {
        //$$: 42  // to make sure we have a proper prototype
        _decr_: function (ev) {
            if (! --this[ev]) {
                // Delete this entry, since 0 does not mean no one is listening, just
                // that no one is *directly* listening. This allows the eventBus or
                // class observers to "poke" through and expose their presence.
                delete this[ev];
            }
        },
        _incr_: function (ev) {
            if (this.hasOwnProperty(ev)) {
                // if we already have listeners at this level, just increment the count...
                ++this[ev];
            } else {
                // otherwise, start the count at 1 (which hides whatever is in our prototype
                // chain)...
                this[ev] = 1;
            }
        }
    };

    proto.HasListeners = Observable.HasListeners = HasListeners;

    Observable.createAlias({
        /**
         * @method
         * Shorthand for {@link #addListener}.
         * @inheritdoc Ext.util.Observable#addListener
         */
        on: 'addListener',
        /**
         * @method
         * Shorthand for {@link #removeListener}.
         * @inheritdoc Ext.util.Observable#removeListener
         */
        un: 'removeListener',
        /**
         * @method
         * Shorthand for {@link #addManagedListener}.
         * @inheritdoc Ext.util.Observable#addManagedListener
         */
        mon: 'addManagedListener',
        /**
         * @method
         * Shorthand for {@link #removeManagedListener}.
         * @inheritdoc Ext.util.Observable#removeManagedListener
         */
        mun: 'removeManagedListener'
    });

    //deprecated, will be removed in 5.0
    Observable.observeClass = Observable.observe;

    /**
     * @member Ext
     * @property {Ext.util.Observable} globalEvents
     * An instance of `{@link Ext.util.Observable}` through which Ext fires global events.
     *
     * This Observable instance fires the following events:
     *
     * *  **`idle`**
     *
     *    Fires when an event handler finishes its run, just before returning to browser control.
     *
     *    This includes DOM event handlers, Ajax (including JSONP) event handlers, and {@link Ext.util.TaskRunner TaskRunners}
     *
     *    This can be useful for performing cleanup, or update tasks which need to happen only
     *    after all code in an event handler has been run, but which should not be executed in a timer
     *    due to the intervening browser reflow/repaint which would take place.
     *
     * * **`ready`**
     *
     *    Fires when the DOM is ready, and all required classes have been loaded. Functionally
     *    the same as {@link Ext#onReady}, but must be called with the `single` option:
     *
     *         Ext.on({
     *             ready: function() {
     *                 console.log('document is ready!');
     *             },
     *             single: true
     *         });
     *
     * * **`resumelayouts`**
     *
     *    Fires after global layout processing has been resumed in {@link Ext.AbstractComponent#resumeLayouts}.
     */
    Ext.globalEvents = globalEvents = new Observable({
        events: {
            idle: Ext.EventManager.idleEvent,
            ready: Ext.EventManager.readyEvent
        }
    });

    /**
     * @member Ext
     * @method on
     * Shorthand for the {@link Ext.util.Observable#addListener} method of the
     * {@link Ext#globalEvents} Observable instance.
     * @inheritdoc Ext.util.Observable#addListener
     */
    Ext.on = function() {
        return globalEvents.addListener.apply(globalEvents, arguments);
    };

    /**
     * @member Ext
     * @method
     * Shorthand for the {@link Ext.util.Observable#removeListener} method of the
     * {@link Ext#globalEvents} Observable instance.
     * @inheritdoc Ext.util.Observable#removeListener
     */
    Ext.un = function() {
        return globalEvents.removeListener.apply(globalEvents, arguments);
    };

    // this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)
    // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
    // private
    function getMethodEvent(method){
        var e = (this.methodEvents = this.methodEvents || {})[method],
            returnValue,
            v,
            cancel,
            obj = this,
            makeCall;

        if (!e) {
            this.methodEvents[method] = e = {};
            e.originalFn = this[method];
            e.methodName = method;
            e.before = [];
            e.after = [];

            makeCall = function(fn, scope, args){
                if((v = fn.apply(scope || obj, args)) !== undefined){
                    if (typeof v == 'object') {
                        if(v.returnValue !== undefined){
                            returnValue = v.returnValue;
                        }else{
                            returnValue = v;
                        }
                        cancel = !!v.cancel;
                    }
                    else
                        if (v === false) {
                            cancel = true;
                        }
                        else {
                            returnValue = v;
                        }
                }
            };

            this[method] = function(){
                var args = Array.prototype.slice.call(arguments, 0),
                    b, i, len;
                returnValue = v = undefined;
                cancel = false;

                for(i = 0, len = e.before.length; i < len; i++){
                    b = e.before[i];
                    makeCall(b.fn, b.scope, args);
                    if (cancel) {
                        return returnValue;
                    }
                }

                if((v = e.originalFn.apply(obj, args)) !== undefined){
                    returnValue = v;
                }

                for(i = 0, len = e.after.length; i < len; i++){
                    b = e.after[i];
                    makeCall(b.fn, b.scope, args);
                    if (cancel) {
                        return returnValue;
                    }
                }
                return returnValue;
            };
        }
        return e;
    }

    Ext.apply(proto, {
        onClassMixedIn: prepareMixin,

        // these are considered experimental
        // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
        // adds an 'interceptor' called before the original method
        beforeMethod : function(method, fn, scope){
            getMethodEvent.call(this, method).before.push({
                fn: fn,
                scope: scope
            });
        },

        // adds a 'sequence' called after the original method
        afterMethod : function(method, fn, scope){
            getMethodEvent.call(this, method).after.push({
                fn: fn,
                scope: scope
            });
        },

        removeMethodListener: function(method, fn, scope){
            var e = this.getMethodEvent(method),
                i, len;
            for(i = 0, len = e.before.length; i < len; i++){
                if(e.before[i].fn == fn && e.before[i].scope == scope){
                    Ext.Array.erase(e.before, i, 1);
                    return;
                }
            }
            for(i = 0, len = e.after.length; i < len; i++){
                if(e.after[i].fn == fn && e.after[i].scope == scope){
                    Ext.Array.erase(e.after, i, 1);
                    return;
                }
            }
        },

        toggleEventLogging: function(toggle) {
            Ext.util.Observable[toggle ? 'capture' : 'releaseCapture'](this, function(en) {
                if (Ext.isDefined(Ext.global.console)) {
                    Ext.global.console.log(en, arguments);
                }
            });
        }
    });
});


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <title>amp-story</title>
  <link rel="canonical" href="animations-presets.html">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">

  <amp-story
    title="Animations-presets amp-story examples"
    publisher="The AMP Team"
    publisher-logo-src="https://example.com/logo/1x1.png"
    poster-portrait-src="https://example.com/my-story/poster/3x4.jpg"
    poster-square-src="https://example.com/my-story/poster/1x1.jpg"
    poster-landscape-src="https://example.com/my-story/poster/4x3.jpg"
    standalone>

    <amp-story-page id="pulse-page">
      <amp-story-grid-layer template="thirds">

pulse

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="fade-in-page">
      <amp-story-grid-layer template="thirds">

fade-in

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="scale-fade-up-page">
      <amp-story-grid-layer template="thirds">

scale-fade-up

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="scale-fade-down-page">
      <amp-story-grid-layer template="thirds">

scale-fade-down

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="twirl-in-page">
      <amp-story-grid-layer template="thirds">

twirl-in

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="fly-in-left-page">
      <amp-story-grid-layer template="thirds">

fly-in-left

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="fly-in-right-page">
      <amp-story-grid-layer template="thirds">

fly-in-right

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="fly-in-top-page">
      <amp-story-grid-layer template="thirds">

fly-in-top

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="fly-in-bottom-page">
      <amp-story-grid-layer template="thirds">

fly-in-bottom

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="rotate-in-left-page">
      <amp-story-grid-layer template="thirds">

rotate-in-left

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="rotate-in-right-page">
      <amp-story-grid-layer template="thirds">

rotate-in-right

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="whoosh-in-left-page">
      <amp-story-grid-layer template="thirds">

whoosh-in-left

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="whoosh-in-right-page">
      <amp-story-grid-layer template="thirds">

whoosh-in-right

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="drop-page">
      <amp-story-grid-layer template="thirds">

drop-in

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="zoom-in">
      <amp-story-grid-layer template="fill">
        <amp-img animate-in="zoom-in" animate-in-duration="4s" layout="responsive" src="https://picsum.photos/720/320?image=1026"
          width="720" height="320">
        </amp-img>
      </amp-story-grid-layer>
      <amp-story-grid-layer template="fill">

zoom-in

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="zoom-out">
      <amp-story-grid-layer template="fill">
        <amp-img animate-in="zoom-out" scale-start="3" scale-end="1" animate-in-duration="4s" layout="responsive" src="https://picsum.photos/720/320?image=1026"
          width="720" height="320">
        </amp-img>
      </amp-story-grid-layer>
      <amp-story-grid-layer template="fill">

zoom-out

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="pan-left">
      <amp-story-grid-layer template="fill">
        <amp-img animate-in="pan-left" id="img-pan-left" translate-x="600px" animate-in-duration="4s" layout="fixed" src="https://picsum.photos/720/320?image=1026"
          width="720" height="320">
        </amp-img>
      </amp-story-grid-layer>
      <amp-story-grid-layer template="fill">

pan-left

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="pan-right">
      <amp-story-grid-layer template="fill">
        <amp-img animate-in="pan-right" animate-in-duration="4s" translate-x="200px" layout="fixed" src="https://picsum.photos/720/320?image=1026" width="720"
          height="320">
        </amp-img>
      </amp-story-grid-layer>
      <amp-story-grid-layer template="fill">

pan-right

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="pan-up">
      <amp-story-grid-layer template="fill">
        <amp-img animate-in="pan-up" animate-in-duration="4s" translate-y="100px" layout="fixed" src="https://picsum.photos/720/320?image=1026" width="720"
          height="320">
        </amp-img>
      </amp-story-grid-layer>
      <amp-story-grid-layer template="fill">

pan-up

      </amp-story-grid-layer>
    </amp-story-page>

    <amp-story-page id="pan-down">
      <amp-story-grid-layer template="fill">
        <amp-img animate-in="pan-down" animate-in-duration="4s" translate-y="100px" layout="fixed" src="https://picsum.photos/720/320?image=1026" width="720"
          height="320">
        </amp-img>
      </amp-story-grid-layer>
      <amp-story-grid-layer template="fill">

pan-down

      </amp-story-grid-layer>
    </amp-story-page>
  </amp-story>

redpajama_set_name: RedPajamaGithub


text:
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

import { NgbdDatepickerAdapter } from './datepicker-adapter';

@NgModule({
  imports: [BrowserModule, FormsModule, NgbModule],
  declarations: [NgbdDatepickerAdapter],
  exports: [NgbdDatepickerAdapter],
  bootstrap: [NgbdDatepickerAdapter]
})
export class NgbdDatepickerAdapterModule {}


text:
/****************************************************************************
 *   PROJECT: Maintain a heap map for heap debugging, 1 bit per 32-bit word
 *            The space overhead is a maximum of 1/32 of the address space.
 *   FILE:    sqHeapMap.c
 *   CONTENT:
 *
 *   AUTHOR:  Eliot Miranda
 *   ADDRESS:
 *   EMAIL:   eliot.miranda@gmail.com
 *
 *   NOTES: The idea is to check for heap pointer integrity.  We scan the heap
 *          setting a bit in the map for each object's base header.  We then
 *          scan the heap checking that each pointer points to a base header by
 *          checking for a 1 in the heap map.
 *
 *          We can also check for leaks by scanning a third time and clearing
 *          the header bit.  Any remaining set bits indicate an unreferenced
 *          object that should have been collected.
 *
 ****************************************************************************/

#include "sqMemoryAccess.h"

#include <stdlib.h>
#include <string.h>

#define ulong unsigned long
#define uchar unsigned char

#if SQ_IMAGE32
/*
 * 32-bit address space = 2^32 bytes = 2^30 words.  If we have 256 root pages
 * then each page needs to cover 2^30 / 256 words = 8 megawords.  Each 8-bit
 * byte in the leak map covers 8 words.  So each page needs to be 8M / 8 bytes
 * = 512k bytes per page.
 */

#define NUMPAGES 256

static uchar *mapPages[256] = { 0, };

#define PAGESIZE (1024*1024)
#define PAGESHIFT 24
#define PAGEMASK 0xFFFFFF
#define LOGWORDSIZE 2
#define LOGBITSPERBYTE 3
#define PAGEINDEX(a) ((a) >> PAGESHIFT)
#define BYTEINDEX(a) (((a) & PAGEMASK) >> (LOGWORDSIZE + LOGBITSPERBYTE))
#define BITINDEX(a) (((a) >> LOGWORDSIZE) & ((1<<LOGBITSPERBYTE)-1))

/*
 * Answer non-zero if the heapMap is set at wordPointer, 0 otherwise
 */
int
heapMapAtWord(void *wordPointer)
{
	ulong address = (ulong)wordPointer;
	uchar *page = mapPages[PAGEINDEX(address)];
	if ((address & ((1<<LOGWORDSIZE)-1)))
		error("misaligned word");
	return page
		? page[BYTEINDEX(address)] & (1 << BITINDEX(address))
		: 0;
}

/*
 * Set the value in the map at wordPointer to bit.
 */
void
heapMapAtWordPut(void *wordPointer, int bit)
{
	ulong address = (ulong)wordPointer;
	uchar *page = mapPages[PAGEINDEX(address)];
	if ((address & ((1<<LOGWORDSIZE)-1)))
		error("misaligned word");
	if (!page) {
		if (!(page = malloc(PAGESIZE))) {
			perror("malloc");
			exit(1);
		}
		mapPages[PAGEINDEX(address)] = page;
		memset(page,0,PAGESIZE);
	}
	if (bit)
		page[BYTEINDEX(address)] |= 1 << BITINDEX(address);
	else
		page[BYTEINDEX(address)] &= (uchar)-1 ^ (1 << BITINDEX(address));
}

/*
 * Clear the heap map to zero.
 */
void
clearHeapMap(void)
{
	int i;

	for (i = 0; i < NUMPAGES; i++)
		if (mapPages[i])
			memset(mapPages[i],0,PAGESIZE);
}
#else
# error 64-bit verison not yet implemented (hint: you need another level of indirection to make the table small enough)
#endif


text:
using System.Text;

namespace Microsoft.PythonTools.Parsing.Ast {
    public class ConditionalExpression : Expression {
        private readonly Expression _testExpr;
        private readonly Expression _trueExpr;
        private readonly Expression _falseExpr;

        public ConditionalExpression(Expression testExpression, Expression trueExpression, Expression falseExpression) {
            this._testExpr = testExpression;
            this._trueExpr = trueExpression;
            this._falseExpr = falseExpression;
        }

        public override string NodeName {
            get {
                return "conditional expression";
            }
        }

        public Expression FalseExpression {
            get { return _falseExpr; }
        }

        public Expression Test {
            get { return _testExpr; }
        }

        public Expression TrueExpression {
            get { return _trueExpr; }
        }

        public override void Walk(PythonWalker walker) {
            if (walker.Walk(this)) {
                if (_testExpr != null) {
                    _testExpr.Walk(walker);
                }
                if (_trueExpr != null) {
                    _trueExpr.Walk(walker);
                }
                if (_falseExpr != null) {
                    _falseExpr.Walk(walker);
                }
            }
            walker.PostWalk(this);
        }

        internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
            _trueExpr.AppendCodeString(res, ast, format);
            res.Append(this.GetProceedingWhiteSpace(ast));
            res.Append("if");
            if (!ast.HasVerbatim) {
                res.Append(' ');
            }
            _testExpr.AppendCodeString(res, ast, format);
            res.Append(this.GetSecondWhiteSpace(ast));
            if (!this.IsIncompleteNode(ast)) {
                res.Append("else");
                if (!ast.HasVerbatim) {
                    res.Append(' ');
                }
                _falseExpr.AppendCodeString(res, ast, format);
            }
        }

        public override string GetLeadingWhiteSpace(PythonAst ast) {
            return _trueExpr.GetLeadingWhiteSpace(ast);
        }

        public override void SetLeadingWhiteSpace(PythonAst ast, string whiteSpace) {
            _trueExpr.SetLeadingWhiteSpace(ast, whiteSpace);
        }
    }
}


text:
package org.boon.datarepo;

import org.boon.criteria.internal.Criteria;
import org.boon.criteria.Selector;
import org.boon.sort.Sort;
import org.boon.criteria.internal.Visitor;
import org.boon.datarepo.spi.SearchIndex;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface SearchableCollection<KEY, ITEM> extends Collection<ITEM> {

    ITEM get( KEY key );

    KEY getKey( ITEM item );

    void invalidateIndex( String property, ITEM item );

    void validateIndex( String property, ITEM item );

    public void validateIndexes( ITEM item );

    int count( KEY key, String property, int value );

    int count( KEY key, String property, short value );

    int count( KEY key, String property, byte value );

    int count( KEY key, String property, long value );

    int count( KEY key, String property, char value );

    int count( KEY key, String property, float value );

    int count( KEY key, String property, double value );

    int count( KEY key, String property, Object value );

    <T> T max( KEY key, String property, Class<T> type );

    String maxString( KEY key, String property );

    Number maxNumber( KEY key, String property );

    int maxInt( KEY key, String property );

    long maxLong( KEY key, String property );

    double maxDouble( KEY key, String property );

    <T> T min( KEY key, String property, Class<T> type );

    String minString( KEY key, String property );

    Number minNumber( KEY key, String property );

    int minInt( KEY key, String property );

    long minLong( KEY key, String property );

    double minDouble( KEY key, String property );

    ResultSet<ITEM> results( Criteria... expressions );

    List<ITEM> query( Criteria... expressions );

    List<ITEM> query( List<Criteria> expressions );

    List<ITEM> sortedQuery( String sortBy, Criteria... expressions );

    List<ITEM> sortedQuery( Sort sortBy, Criteria... expressions );

    List<Map<String, Object>> queryAsMaps( Criteria... expressions );

    List<Map<String, Object>> query( List<Selector> selectors, Criteria... expressions );

    List<Map<String, Object>> sortedQuery( String sortBy, List<Selector> selectors, Criteria... expressions );

    List<Map<String, Object>> sortedQuery( Sort sortBy, List<Selector> selectors, Criteria... expressions );

    void query( Visitor<KEY, ITEM> visitor, Criteria... expressions );

    void sortedQuery( Visitor<KEY, ITEM> visitor, String sortBy, Criteria... expressions );

    void sortedQuery( Visitor<KEY, ITEM> visitor, Sort sortBy, Criteria... expressions );

    boolean delete( ITEM item );

    void addSearchIndex( String name, SearchIndex<?, ?> si );

    void addLookupIndex( String name, LookupIndex<?, ?> si );

    List<ITEM> all();

    void removeByKey( KEY key );

}


text:
<?php
# $Id: data_table.example2.php 999 2011-08-05 19:00:48Z lbayuk $
# phplot / contrib / data_table example 2: Line plot with data table on the side
require_once 'phplot.php';
require_once 'data_table.php';

$data = array();
for ($i = 0; $i < 20; $i++)
  $data[] = array('', $i, 2 * $i, $i * $i);

// The $settings array configures the data table:
$settings = array(
    'headers' => array(NULL, 'X', '2Y', 'Y^2'),
    'position' => array(640, 20),
    'width' => 150,
    'data' => $data,
    'font' => 3,
);

$plot = new PHPlot(800, 600);
$plot->SetTitle('Line Plot with Data Table on Right Side');
$plot->SetDataValues($data);
$plot->SetDataType('data-data');
$plot->SetPlotType('linepoints');
$plot->SetPlotAreaPixels(NULL, NULL, 630, NULL);
$plot->SetCallback('draw_graph', 'draw_data_table', $settings);
$plot->SetLegend(array('2Y', 'Y^2'));
$plot->DrawGraph();


text:
package org.onetwo.boot.plugin.core;

import org.onetwo.common.spring.SpringUtils;
import org.onetwo.common.utils.StringUtils;
import org.springframework.context.ApplicationContext;

public interface PluginMeta {

	String PLUGIN_POSTFIX = "Plugin";

	String getName();
	String getVersion();

	static PluginMeta by(Class<? extends WebPlugin> webPluginClass){
		return by(webPluginClass, "1.0.0");
	}
	static PluginMeta byName(String pluginName, Class<? extends WebPlugin> webPluginClass){
		return by(pluginName, webPluginClass, "1.0.0", PLUGIN_POSTFIX);
	}

	/***
	 * 使用短横杠命名方法
	 * @author weishao zeng
	 * @param webPluginClass
	 * @return
	 */
	static PluginMeta useKebabCaseBy(Class<? extends WebPlugin> webPluginClass){
		return by(webPluginClass, "1.0.0", "-");
	}

	static PluginMeta by(Class<? extends WebPlugin> webPluginClass, String version){
		return by(webPluginClass, version, null);
	}

	static PluginMeta by(Class<? extends WebPlugin> webPluginClass, String version, String sperator){
		String clsName = webPluginClass.getSimpleName();
		String pluginName = null;

		if (StringUtils.isNotBlank(sperator)) {
			pluginName = StringUtils.convertWithSeperator(clsName, sperator);
		} else {
			pluginName = StringUtils.uncapitalize(clsName);
		}

		if(pluginName.endsWith(PLUGIN_POSTFIX)){
			pluginName = StringUtils.substringBefore(pluginName, PLUGIN_POSTFIX);
		}

		return by(pluginName, webPluginClass, version, sperator);
	}
	static PluginMeta by(String pluginName, Class<? extends WebPlugin> webPluginClass, String version, String sperator){
		return new SimplePluginMeta(pluginName, version);
	}

	public static String resolvePluginContextPath(ApplicationContext applicationContext, final String pluginContextPath){
		String path = SpringUtils.resolvePlaceholders(applicationContext, pluginContextPath);
		if(StringUtils.isNotBlank(path)){
			path = StringUtils.appendStartWithSlash(path);
		}
		return path;
	}
}


text:
A simple **React.js**-**Node.js**-**PostgreSQL** web application implementing basic CRUD operations through RESTful APIs.

As always, clean and good-looking code following RESTful best practices. These are the rules.

## Install and Run

    $ npm install -g grunt
    $ npm install
    $ grunt default

Then, in another tab:

    $ npm start

You can now point your browser to `http://localhost:3000/`. Assure PostgreSQL is up and running.

## Tests

Start the backend in another console, then run:

    $ npm test

Assure PostgreSQL is up and running.

## Implemented APIs

- `GET /api/users`:

  Returns an array of users:

        @param:    void
        @return:   {
                       error: boolean,
                       results: [
                           user: {
                               id: int,
                               name: string,
                               age: int,
                               email: string
                           }
                        ]
                    }

  If an id is provided as query parameter, eg. `http://<hostname>:<port>/users?id=12345`, then the result is the following:

        @param:    id: int
        @return:   {
                       error: boolean,
                       user: {
                           id: int,
                           name: string,
                           age: int,
                           email: string
                       }
                   }

- `POST /api/users`:

  Insert a new user entry into the database:

        @param:    user: {
                       [id: int,]
                       name: string,
                       age: int,
                       email: string
                   }
        @return:   { error: boolean }

- `PUT /api/users`:

  Update an user entry:

        @param:    { id: int }
        @return:   { error: boolean }

- `DELETE /api/users`:

  Delete an user entry from the database:

        @param:    user: {
                       id: int,
                       name: string,
                       age: int,
                       [email: string]
                   }
        @return:   { error: boolean }


text:
'use strict';

const chai = require('chai');
const should = chai.should();
const sleigh = require('../app/sleigh.js');

describe('sleigh', () => {

  /*
  it('stays put when not moved', () => {
    sleigh.move('').should.equal(0);
  });

  it('can calculate distance for single movement', () => {
    sleigh.move('R1').should.equal(1);
  });

  it('can calculate distance for compound movement', () => {
    sleigh.move('L2, R300').should.equal(302);
  });
  */
  it('stops when visits first place twice', () => {
    sleigh.move('R2, L10, L1, L1, L5, L1').should.equal(11);
  });
});


text:
package com.gwtjs.icustom.lottery;

import java.util.List;

/**
 * @author aGuang
 *
 */
public class CopyOfSample1 {

	public static void main(String[] args) {

		String s1 = "02 03 04 06 09 12 16 18 20 23 24 31";
		String s2 = "01 03 09 10 14 17 19 20 23 25 30 33";
		String s3 = "09 10 11 12 14 16 17 21 23 24 27 32";
		String s4 = "05 06 07 10 14 17 19 21 22 23 26 32";
		String s5 = "04 11 15 17 19 22 23 24 26 27 29 33";
		String s6 = "01 06 10 12 14 15 18 22 23 25 28 33";
		String s7 = "01 06 10 12 14 15 18 22 23 25 28 33";
		String s8 = "01 03 04 07 10 11 12 23 26 28 30 33";
		String s9 = "05 06 09 10 11 15 16 19 25 26 27 33";
		String s10 = "02 04 05 06 07 08 15 20 25 27 30 31";
		String s11 = "02 04 05 06 07 08 15 20 25 27 30 31";
		//String s12 = "8 13";// 有人双胆全包
		//String s13 = "7 27";// 有人双胆全包
		/*String s14 = "32 33 34 35";// 有人四胆全包
		String s15 = "1 7 9 17 34 35";*/// 杀号
		Combination com = new Combination();
		List<int[]> list = null;
		try {
			list = com.combine(Combination.bigLottery, 6);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		System.out.println("1:"+list.size());

		// 三连号
		list = Combination.filterContinuation(list, 4, 6);
		System.out.println("过滤三连号:"+list.size());

		// 过滤以上合买复式,重点是第二个参数,表示有多少个号相同就抛弃,例如4个号相同就抛弃,即能中3个
		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s1, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 4, 6,
				Combination.initOther(s2, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s3, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s4, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 4, 6,
				Combination.initOther(s5, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s6, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s7, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s8, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s9, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 3, 6,
				Combination.initOther(s10, Combination.typeBig));
		System.out.println(list.size());

		list = Combination.filterOther(list, 4, 6,
				Combination.initOther(s11, Combination.typeBig));
		System.out.println(list.size());

		/*list = Combination.filterOther(list, 4, 5,
				Combination.initOther(s14, Combination.typeBig));
		System.out.println(list.size());*/

		/*list = Combination.filterOther(list, 2, 5,
				Combination.initOther(s12, Combination.typeBig));
		System.out.println(list.size());
				*/

		/*list = Combination.filterOther(list, 2, 5,
				Combination.initOther(s13, Combination.typeBig));
		System.out.println(list.size());
				*/

		/*list = Combination.filterOther(list, 1, 5,
				Combination.initOther(s15, Combination.typeBig));
		System.out.println(list.size());*/
		// 打印结果
		Combination.printf(list);
		// String real="6 9 15 24 25 26";
		// Combination.checkResult(list,real,Combination.typeDouble);

	}

}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">

		<title>selection</title>

		<link type="text/css" href="../../../mxui/data/grid/grid.css" rel="stylesheet" />

Here is some content that can fold over the page strangely

				Some more content

I am above the splitter.

								TOP

								Bottom


text:
require 'test_helper'

class JukeboxxrTest < Minitest::Test
  def test_that_it_has_a_version_number
    refute_nil ::Jukeboxxr::VERSION
  end

  def test_it_does_something_useful
    assert false
  end
end


text:
package com.google.sampling.experiential.dao;

import java.sql.SQLException;

import com.google.sampling.experiential.dao.dataaccess.InformedConsent;

public interface CSInformedConsentDao {
  void insertInformedConsent(InformedConsent informedConsent, Integer experimentVersion) throws SQLException;
}


text:
function [streamFileData, chanlocs] = nfblab_loadfile(streamFile)

    if ~isstruct(streamFile)
        [~,~,ext] = fileparts(streamFile);
        if strcmpi(ext, '.set')
            streamFileData = load('-mat', streamFile);
            streamFileData = streamFileData.EEG;
            if ischar(streamFileData.data)
                streamFileData.data = floatread(streamFileData.data, [streamFileData.nbchan Inf]);
            end
        elseif strcmpi(ext, '.edf')
            streamFileData = pop_biosig(streamFile);
        elseif strcmpi(ext, '.xdf')
            streamFileData = pop_loadxdf(streamFile , 'streamtype', 'EEG', 'exclude_markerstreams', {});
        end
    else
        streamFileData = streamFile;
    end
    streamFileData = eeg_checkset(streamFileData);

    if ~isempty(streamFileData.chanlocs)
        for iChan = 1:length(streamFileData.chanlocs)
            posSpace = find(streamFileData.chanlocs(iChan).labels == ' ');
            posDash  = find(streamFileData.chanlocs(iChan).labels == '-');
            if ~isempty(posSpace) && ~isempty(posDash)
                streamFileData.chanlocs(iChan).labels = streamFileData.chanlocs(iChan).labels(posSpace+1:posDash-1);
            end
        end
        if isempty(streamFileData.chanlocs(1).X)
            streamFileData = pop_chanedit(streamFileData, 'lookup','standard-10-5-cap385.elp');
        end
    end

    %chans = [1:streamFileData.nbchan];
    try
        disp('Warning: Overwriting channel labels with those contained in the data file');
        chanlocs = streamFileData.chanlocs;
    catch, end


text:
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });

function preload() {

    //  Phaser can load JSON files.

    //  It does this using an XMLHttpRequest.

    //  If loading a file from outside of the domain in which the game is running
    //  a 'Access-Control-Allow-Origin' header must be present on the server.

    game.load.json('version', 'http://phaser.io/version.json');

}

function create() {

    game.stage.backgroundColor = '#0072bc';

    var phaserJSON = game.cache.getJSON('version');

    var text = game.add.text(100, 100, "Current Phaser version: " + phaserJSON.version, { fill: '#ffffff' });
    text.setShadow(2, 2, 'rgba(0,0,0,0.5)', 0);

    var text2 = game.add.text(100, 200, "Name: " + phaserJSON.name, { fill: '#ffffff' });
    text2.setShadow(2, 2, 'rgba(0,0,0,0.5)', 0);

    var text3 = game.add.text(100, 300, "Released: " + phaserJSON.released, { fill: '#ffffff' });
    text3.setShadow(2, 2, 'rgba(0,0,0,0.5)', 0);

}


text:
.SUFFIXES:
.PHONY: default clean

include environment.mk

EXTRACTED_JAVA_SOURCES = \
    org/mockito/AdditionalAnswers.java \
    org/mockito/AdditionalMatchers.java \
    org/mockito/Answers.java \
    org/mockito/ArgumentCaptor.java \
    org/mockito/ArgumentMatcher.java \
    org/mockito/BDDMockito.java \
    org/mockito/Captor.java \
    org/mockito/InOrder.java \
    org/mockito/Incubating.java \
    org/mockito/InjectMocks.java \
    org/mockito/Matchers.java \
    org/mockito/Mock.java \
    org/mockito/MockSettings.java \
    org/mockito/MockingDetails.java \
    org/mockito/Mockito.java \
    org/mockito/MockitoAnnotations.java \
    org/mockito/MockitoDebugger.java \
    org/mockito/ReturnValues.java \
    org/mockito/Spy.java \
    org/mockito/configuration/AnnotationEngine.java \
    org/mockito/configuration/DefaultMockitoConfiguration.java \
    org/mockito/configuration/IMockitoConfiguration.java \
    org/mockito/exceptions/PrintableInvocation.java \
    org/mockito/exceptions/Reporter.java \
    org/mockito/exceptions/base/MockitoAssertionError.java \
    org/mockito/exceptions/base/MockitoException.java \
    org/mockito/exceptions/misusing/CannotStubVoidMethodWithReturnValue.java \
    org/mockito/exceptions/misusing/CannotVerifyStubOnlyMock.java \
    org/mockito/exceptions/misusing/FriendlyReminderException.java \
    org/mockito/exceptions/misusing/InvalidUseOfMatchersException.java \
    org/mockito/exceptions/misusing/MissingMethodInvocationException.java \
    org/mockito/exceptions/misusing/MockitoConfigurationException.java \
    org/mockito/exceptions/misusing/NotAMockException.java \
    org/mockito/exceptions/misusing/NullInsteadOfMockException.java \
    org/mockito/exceptions/misusing/UnfinishedStubbingException.java \
    org/mockito/exceptions/misusing/UnfinishedVerificationException.java \
    org/mockito/exceptions/misusing/WrongTypeOfReturnValue.java \
    org/mockito/exceptions/stacktrace/StackTraceCleaner.java \
    org/mockito/exceptions/verification/ArgumentsAreDifferent.java \
    org/mockito/exceptions/verification/NeverWantedButInvoked.java \
    org/mockito/exceptions/verification/NoInteractionsWanted.java \
    org/mockito/exceptions/verification/SmartNullPointerException.java \
    org/mockito/exceptions/verification/TooLittleActualInvocations.java \
    org/mockito/exceptions/verification/TooManyActualInvocations.java \
    org/mockito/exceptions/verification/VerificationInOrderFailure.java \
    org/mockito/exceptions/verification/WantedButNotInvoked.java \
    org/mockito/exceptions/verification/junit/ArgumentsAreDifferent.java \
    org/mockito/internal/InOrderImpl.java \
    org/mockito/internal/InternalMockHandler.java \
    org/mockito/internal/MockitoCore.java \
    org/mockito/internal/configuration/CaptorAnnotationProcessor.java \
    org/mockito/internal/configuration/ClassPathLoader.java \
    org/mockito/internal/configuration/DefaultAnnotationEngine.java \
    org/mockito/internal/configuration/DefaultInjectionEngine.java \
    org/mockito/internal/configuration/FieldAnnotationProcessor.java \
    org/mockito/internal/configuration/GlobalConfiguration.java \
    org/mockito/internal/configuration/InjectingAnnotationEngine.java \
    org/mockito/internal/configuration/MockAnnotationProcessor.java \
    org/mockito/internal/configuration/MockitoAnnotationsMockAnnotationProcessor.java \
    org/mockito/internal/configuration/SpyAnnotationEngine.java \
    org/mockito/internal/configuration/injection/ConstructorInjection.java \
    org/mockito/internal/configuration/injection/MockInjection.java \
    org/mockito/internal/configuration/injection/MockInjectionStrategy.java \
    org/mockito/internal/configuration/injection/PropertyAndSetterInjection.java \
    org/mockito/internal/configuration/injection/SpyOnInjectedFieldsHandler.java \
    org/mockito/internal/configuration/injection/filter/FinalMockCandidateFilter.java \
    org/mockito/internal/configuration/injection/filter/MockCandidateFilter.java \
    org/mockito/internal/configuration/injection/filter/NameBasedCandidateFilter.java \
    org/mockito/internal/configuration/injection/filter/OngoingInjecter.java \
    org/mockito/internal/configuration/injection/filter/TypeBasedCandidateFilter.java \
    org/mockito/internal/configuration/injection/scanner/InjectMocksScanner.java \
    org/mockito/internal/configuration/injection/scanner/MockScanner.java \
    org/mockito/internal/configuration/plugins/DefaultPluginSwitch.java \
    org/mockito/internal/configuration/plugins/PluginFileReader.java \
    org/mockito/internal/configuration/plugins/PluginFinder.java \
    org/mockito/internal/configuration/plugins/PluginLoader.java \
    org/mockito/internal/configuration/plugins/PluginRegistry.java \
    org/mockito/internal/configuration/plugins/Plugins.java \
    org/mockito/internal/creation/DelegatingMethod.java \
    org/mockito/internal/creation/MockSettingsImpl.java \
    org/mockito/internal/creation/settings/CreationSettings.java \
    org/mockito/internal/debugging/Localized.java \
    org/mockito/internal/debugging/LocationImpl.java \
    org/mockito/internal/debugging/MockitoDebuggerImpl.java \
    org/mockito/internal/debugging/VerboseMockInvocationLogger.java \
    org/mockito/internal/exceptions/MockitoLimitations.java \
    org/mockito/internal/exceptions/VerificationAwareInvocation.java \
    org/mockito/internal/exceptions/stacktrace/ConditionalStackTraceFilter.java \
    org/mockito/internal/exceptions/stacktrace/DefaultStackTraceCleaner.java \
    org/mockito/internal/exceptions/stacktrace/DefaultStackTraceCleanerProvider.java \
    org/mockito/internal/exceptions/stacktrace/StackTraceFilter.java \
    org/mockito/internal/exceptions/util/ScenarioPrinter.java \
    org/mockito/internal/handler/InvocationNotifierHandler.java \
    org/mockito/internal/handler/MockHandlerFactory.java \
    org/mockito/internal/handler/MockHandlerImpl.java \
    org/mockito/internal/handler/NullResultGuardian.java \
    org/mockito/internal/invocation/AbstractAwareMethod.java \
    org/mockito/internal/invocation/CapturesArgumensFromInvocation.java \
    org/mockito/internal/invocation/InvocationImpl.java \
    org/mockito/internal/invocation/InvocationMarker.java \
    org/mockito/internal/invocation/InvocationMatcher.java \
    org/mockito/internal/invocation/InvocationsFinder.java \
    org/mockito/internal/invocation/MatchersBinder.java \
    org/mockito/internal/invocation/MockitoMethod.java \
    org/mockito/internal/invocation/SerializableMethod.java \
    org/mockito/internal/invocation/StubInfoImpl.java \
    org/mockito/internal/invocation/UnusedStubsFinder.java \
    org/mockito/internal/invocation/finder/AllInvocationsFinder.java \
    org/mockito/internal/invocation/finder/VerifiableInvocationsFinder.java \
    org/mockito/internal/invocation/realmethod/RealMethod.java \
    org/mockito/internal/junit/FriendlyExceptionMaker.java \
    org/mockito/internal/junit/JUnitDetecter.java \
    org/mockito/internal/junit/JUnitRule.java \
    org/mockito/internal/junit/JUnitTool.java \
    org/mockito/internal/listeners/MockingProgressListener.java \
    org/mockito/internal/listeners/MockingStartedListener.java \
    org/mockito/internal/listeners/NotifiedMethodInvocationReport.java \
    org/mockito/internal/matchers/And.java \
    org/mockito/internal/matchers/Any.java \
    org/mockito/internal/matchers/AnyVararg.java \
    org/mockito/internal/matchers/ArrayEquals.java \
    org/mockito/internal/matchers/CapturesArguments.java \
    org/mockito/internal/matchers/CapturingMatcher.java \
    org/mockito/internal/matchers/CompareEqual.java \
    org/mockito/internal/matchers/CompareTo.java \
    org/mockito/internal/matchers/Contains.java \
    org/mockito/internal/matchers/ContainsExtraTypeInformation.java \
    org/mockito/internal/matchers/EndsWith.java \
    org/mockito/internal/matchers/Equality.java \
    org/mockito/internal/matchers/Equals.java \
    org/mockito/internal/matchers/EqualsWithDelta.java \
    org/mockito/internal/matchers/Find.java \
    org/mockito/internal/matchers/GreaterOrEqual.java \
    org/mockito/internal/matchers/GreaterThan.java \
    org/mockito/internal/matchers/InstanceOf.java \
    org/mockito/internal/matchers/LessOrEqual.java \
    org/mockito/internal/matchers/LessThan.java \
    org/mockito/internal/matchers/MatcherDecorator.java \
    org/mockito/internal/matchers/MatchersPrinter.java \
    org/mockito/internal/matchers/Matches.java \
    org/mockito/internal/matchers/Not.java \
    org/mockito/internal/matchers/NotNull.java \
    org/mockito/internal/matchers/Null.java \
    org/mockito/internal/matchers/Or.java \
    org/mockito/internal/matchers/Same.java \
    org/mockito/internal/matchers/StartsWith.java \
    org/mockito/internal/matchers/VarargMatcher.java \
    org/mockito/internal/matchers/apachecommons/EqualsBuilder.java \
    org/mockito/internal/matchers/apachecommons/ReflectionEquals.java \
    org/mockito/internal/progress/ArgumentMatcherStorage.java \
    org/mockito/internal/progress/ArgumentMatcherStorageImpl.java \
    org/mockito/internal/progress/HandyReturnValues.java \
    org/mockito/internal/progress/IOngoingStubbing.java \
    org/mockito/internal/progress/MockingProgress.java \
    org/mockito/internal/progress/MockingProgressImpl.java \
    org/mockito/internal/progress/SequenceNumber.java \
    org/mockito/internal/progress/ThreadSafeMockingProgress.java \
    org/mockito/internal/reporting/Discrepancy.java \
    org/mockito/internal/reporting/Pluralizer.java \
    org/mockito/internal/reporting/PrintSettings.java \
    org/mockito/internal/reporting/SmartPrinter.java \
    org/mockito/internal/runners/RunnerFactory.java \
    org/mockito/internal/runners/RunnerImpl.java \
    org/mockito/internal/runners/util/RunnerProvider.java \
    org/mockito/internal/runners/util/TestMethodsFinder.java \
    org/mockito/internal/stubbing/BaseStubbing.java \
    org/mockito/internal/stubbing/ConsecutiveStubbing.java \
    org/mockito/internal/stubbing/InvocationContainer.java \
    org/mockito/internal/stubbing/InvocationContainerImpl.java \
    org/mockito/internal/stubbing/OngoingStubbingImpl.java \
    org/mockito/internal/stubbing/StubbedInvocationMatcher.java \
    org/mockito/internal/stubbing/StubberImpl.java \
    org/mockito/internal/stubbing/VoidMethodStubbableImpl.java \
    org/mockito/internal/stubbing/answers/AnswerReturnValuesAdapter.java \
    org/mockito/internal/stubbing/answers/AnswersValidator.java \
    org/mockito/internal/stubbing/answers/CallsRealMethods.java \
    org/mockito/internal/stubbing/answers/DoesNothing.java \
    org/mockito/internal/stubbing/answers/MethodInfo.java \
    org/mockito/internal/stubbing/answers/Returns.java \
    org/mockito/internal/stubbing/answers/ReturnsArgumentAt.java \
    org/mockito/internal/stubbing/answers/ReturnsElementsOf.java \
    org/mockito/internal/stubbing/answers/ThrowsException.java \
    org/mockito/internal/stubbing/defaultanswers/ForwardsInvocations.java \
    org/mockito/internal/stubbing/defaultanswers/GloballyConfiguredAnswer.java \
    org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java \
    org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java \
    org/mockito/internal/stubbing/defaultanswers/ReturnsMocks.java \
    org/mockito/internal/stubbing/defaultanswers/ReturnsMoreEmptyValues.java \
    org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java \
    org/mockito/internal/util/Checks.java \
    org/mockito/internal/util/Decamelizer.java \
    org/mockito/internal/util/DefaultMockingDetails.java \
    org/mockito/internal/util/MockCreationValidator.java \
    org/mockito/internal/util/MockNameImpl.java \
    org/mockito/internal/util/MockUtil.java \
    org/mockito/internal/util/ObjectMethodsGuru.java \
    org/mockito/internal/util/Primitives.java \
    org/mockito/internal/util/RemoveFirstLine.java \
    org/mockito/internal/util/StringJoiner.java \
    org/mockito/internal/util/Timer.java \
    org/mockito/internal/util/collections/ArrayUtils.java \
    org/mockito/internal/util/collections/HashCodeAndEqualsMockWrapper.java \
    org/mockito/internal/util/collections/HashCodeAndEqualsSafeSet.java \
    org/mockito/internal/util/collections/IdentitySet.java \
    org/mockito/internal/util/collections/Iterables.java \
    org/mockito/internal/util/collections/ListUtil.java \
    org/mockito/internal/util/collections/Sets.java \
    org/mockito/internal/util/io/IOUtil.java \
    org/mockito/internal/util/reflection/AccessibilityChanger.java \
    org/mockito/internal/util/reflection/BeanPropertySetter.java \
    org/mockito/internal/util/reflection/Constructors.java \
    org/mockito/internal/util/reflection/FieldCopier.java \
    org/mockito/internal/util/reflection/FieldInitializationReport.java \
    org/mockito/internal/util/reflection/FieldInitializer.java \
    org/mockito/internal/util/reflection/FieldReader.java \
    org/mockito/internal/util/reflection/FieldSetter.java \
    org/mockito/internal/util/reflection/GenericMaster.java \
    org/mockito/internal/util/reflection/GenericMetadataSupport.java \
    org/mockito/internal/util/reflection/LenientCopyTool.java \
    org/mockito/internal/util/reflection/Whitebox.java \
    org/mockito/internal/verification/AtLeast.java \
    org/mockito/internal/verification/AtMost.java \
    org/mockito/internal/verification/Calls.java \
    org/mockito/internal/verification/DefaultRegisteredInvocations.java \
    org/mockito/internal/verification/InOrderContextImpl.java \
    org/mockito/internal/verification/InOrderWrapper.java \
    org/mockito/internal/verification/MockAwareVerificationMode.java \
    org/mockito/internal/verification/NoMoreInteractions.java \
    org/mockito/internal/verification/Only.java \
    org/mockito/internal/verification/RegisteredInvocations.java \
    org/mockito/internal/verification/SingleRegisteredInvocation.java \
    org/mockito/internal/verification/Times.java \
    org/mockito/internal/verification/VerificationDataImpl.java \
    org/mockito/internal/verification/VerificationModeFactory.java \
    org/mockito/internal/verification/VerificationOverTimeImpl.java \
    org/mockito/internal/verification/api/InOrderContext.java \
    org/mockito/internal/verification/api/VerificationData.java \
    org/mockito/internal/verification/api/VerificationDataInOrder.java \
    org/mockito/internal/verification/api/VerificationDataInOrderImpl.java \
    org/mockito/internal/verification/api/VerificationInOrderMode.java \
    org/mockito/internal/verification/argumentmatching/ArgumentMatchingTool.java \
    org/mockito/internal/verification/checkers/AtLeastDiscrepancy.java \
    org/mockito/internal/verification/checkers/AtLeastXNumberOfInvocationsChecker.java \
    org/mockito/internal/verification/checkers/AtLeastXNumberOfInvocationsInOrderChecker.java \
    org/mockito/internal/verification/checkers/MissingInvocationChecker.java \
    org/mockito/internal/verification/checkers/MissingInvocationInOrderChecker.java \
    org/mockito/internal/verification/checkers/NonGreedyNumberOfInvocationsInOrderChecker.java \
    org/mockito/internal/verification/checkers/NumberOfInvocationsChecker.java \
    org/mockito/internal/verification/checkers/NumberOfInvocationsInOrderChecker.java \
    org/mockito/internal/invocation/ArgumentsComparator.java \
    org/mockito/internal/invocation/ArgumentsProcessor.java \
    org/mockito/invocation/DescribedInvocation.java \
    org/mockito/invocation/Invocation.java \
    org/mockito/invocation/InvocationOnMock.java \
    org/mockito/invocation/Location.java \
    org/mockito/invocation/MockHandler.java \
    org/mockito/invocation/StubInfo.java \
    org/mockito/junit/MockitoJUnit.java \
    org/mockito/junit/MockitoJUnitRule.java \
    org/mockito/junit/MockitoRule.java \
    org/mockito/listeners/InvocationListener.java \
    org/mockito/listeners/MethodInvocationReport.java \
    org/mockito/mock/MockCreationSettings.java \
    org/mockito/mock/MockName.java \
    org/mockito/mock/SerializableMode.java \
    org/mockito/plugins/MockMaker.java \
    org/mockito/plugins/PluginSwitch.java \
    org/mockito/plugins/StackTraceCleanerProvider.java \
    org/mockito/runners/MockitoJUnitRunner.java \
    org/mockito/stubbing/Answer.java \
    org/mockito/stubbing/DeprecatedOngoingStubbing.java \
    org/mockito/stubbing/OngoingStubbing.java \
    org/mockito/stubbing/Stubber.java \
    org/mockito/stubbing/VoidMethodStubbable.java \
    org/mockito/verification/After.java \
    org/mockito/verification/Timeout.java \
    org/mockito/verification/VerificationAfterDelay.java \
    org/mockito/verification/VerificationMode.java \
    org/mockito/verification/VerificationWithTimeout.java \
    org/mockito/verification/VerificationWrapper.java

SUPERSOURCE_JAVA_SOURCES = \
    com/google/j2objc/mockito/InvocationHandlerAdapter.java \
    com/google/j2objc/mockito/IosMockMaker.java \
    org/mockito/internal/matchers/LocalizedMatcher.java \
    org/mockito/internal/stubbing/answers/ThrowsExceptionClass.java

EXTRACTED_JAVA = $(EXTRACTED_JAVA_SOURCES:%=$(EXTRACTED_JAVA_SRC_DIR)/%)
SUPERSOURCE_JAVA = $(SUPERSOURCE_JAVA_SOURCES:%=$(SUPERSOURCE_JAVA_SRC_DIR)/%)
JAVA_SOURCES_MANIFEST = $(BUILD_DIR)/java_sources.mf
OBJC_SOURCES_MANIFEST = $(BUILD_DIR)/objc_sources.mf

default: lib

CREATE_JAR_NAME = mockito-ios
CREATE_JAR_SOURCES = $(EXTRACTED_JAVA) $(SUPERSOURCE_JAVA)
CREATE_JAR_JAVAC_ARGS = -classpath $(MOCKITO_CLASSPATH)
include $(J2OBJC_ROOT)/make/create_jar.mk

TRANSLATE_JAVA_RELATIVE = $(EXTRACTED_JAVA_SOURCES) $(SUPERSOURCE_JAVA_SOURCES)
TRANSLATE_JAVA_FULL = $(EXTRACTED_JAVA) $(SUPERSOURCE_JAVA)
TRANSLATE_ARGS = -sourcepath $(MOCKITO_SOURCEPATH) -classpath $(MOCKITO_CLASSPATH)
include $(J2OBJC_ROOT)/make/translate.mk

ARCH_HEADERS = $(TRANSLATE_HEADERS:$(GEN_OBJC_DIR)/%=$(ARCH_INCLUDE_DIR)/%)

FAT_LIB_NAME = mockito
FAT_LIB_SOURCES_RELATIVE = $(TRANSLATE_SOURCES:$(GEN_OBJC_DIR)/%=%)
FAT_LIB_SOURCE_DIRS = $(GEN_OBJC_DIR)
FAT_LIB_COMPILE = $(J2OBJCC)
include $(J2OBJC_ROOT)/make/fat_lib.mk

STATIC_FRAMEWORK_NAME = Mockito
include $(J2OBJC_ROOT)/make/static_framework.mk

MOCKITO_LICENSE = LICENSE
MOCKITO_LICENSE_DIST = $(DIST_LICENSE_DIR)/mockito_license.txt

java: jar

lib: $(FAT_LIBS)
	@:

$(BUILD_DIR)/.extracted: $(MOCKITO_SRC_JAR) | $(BUILD_DIR)
	@mkdir -p $(EXTRACTED_JAVA_SRC_DIR)
	@unzip -q -o -d $(EXTRACTED_JAVA_SRC_DIR) $(MOCKITO_SRC_JAR) $(EXTRACTED_JAVA_SOURCES)
	@touch $(EXTRACTED_JAVA)
	@touch $@

$(EXTRACTED_JAVA): $(BUILD_DIR)/.extracted

$(ARCH_INCLUDE_DIR)/%.h: $(GEN_OBJC_DIR)/%.h
	@mkdir -p $(@D)
	install -m 0644 $< $@

$(MOCKITO_LICENSE_DIST): $(MOCKITO_LICENSE)
	@mkdir -p $(@D)
	@install -m 0644 $< $@

$(JAVA_SOURCES_MANIFEST): $(EXTRACTED_JAVA) $(SUPERSOURCE_JAVA) | $(BUILD_DIR)
	@echo "Building $$(basename $@)"
	@if [ -e $@ ]; then rm $@; fi
	@for i in $^; do echo $$i >> $@; done

java_sources_manifest: $(JAVA_SOURCES_MANIFEST)
	@:

$(OBJC_SOURCES_MANIFEST): $(TRANSLATE_JAVA_FULL) | $(BUILD_DIR)
	@echo "Building $$(basename $@)"
	@if [ -e $@ ]; then rm $@; fi
	@files='$(sort $(TRANSLATE_OBJC))' && for i in $$files; do \
	  echo $$i >> $@; \
	done

objc_sources_manifest: $(OBJC_SOURCES_MANIFEST)
	@:

$(BUILD_DIR):
	@mkdir -p $@

test: dist $(DIST_DIR)/j2objcc
	$(MAKE) -f tests.mk test

clean:
	@rm -rf $(BUILD_DIR) $(FAT_LIBS_DIST) $(MOCKITO_LICENSE_DIST)
	@rm -rf $(ARCH_INCLUDE_DIR)/org/mockito
	@rm -rf $(STATIC_FRAMEWORK_DIR)

dist: $(FAT_LIBS_DIST) $(ARCH_HEADERS) $(MOCKITO_LICENSE_DIST)