text:
#ifndef TREE234_H
#define TREE234_H

/*
 * This typedef is opaque outside tree234.c itself.
 */
typedef struct tree234_Tag tree234;

typedef int (*cmpfn234) (void *, void *);

/*
 * Create a 2-3-4 tree. If `cmp' is NULL, the tree is unsorted, and
 * lookups by key will fail: you can only look things up by numeric
 * index, and you have to use addpos234() and delpos234().
 */
tree234 *newtree234(cmpfn234 cmp);

/*
 * Free a 2-3-4 tree (not including freeing the elements).
 */
void freetree234(tree234 * t);

/*
 * Add an element e to a sorted 2-3-4 tree t. Returns e on success,
 * or if an existing element compares equal, returns that.
 */
void *add234(tree234 * t, void *e);

/*
 * Add an element e to an unsorted 2-3-4 tree t. Returns e on
 * success, NULL on failure. (Failure should only occur if the
 * index is out of range or the tree is sorted.)
 *
 * Index range can be from 0 to the tree's current element count,
 * inclusive.
 */
void *addpos234(tree234 * t, void *e, int index);

/*
 * Look up the element at a given numeric index in a 2-3-4 tree.
 * Returns NULL if the index is out of range.
 *
 * One obvious use for this function is in iterating over the whole
 * of a tree (sorted or unsorted):
 *
 *   for (i = 0; (p = index234(tree, i)) != NULL; i++) consume(p);
 *
 * or
 *
 *   int maxcount = count234(tree);
 *   for (i = 0; i < maxcount; i++) {
 *       p = index234(tree, i);
 *       assert(p != NULL);
 *       consume(p);
 *   }
 */
void *index234(tree234 * t, int index);

/*
 * Find an element e in a sorted 2-3-4 tree t. Returns NULL if not
 * found. e is always passed as the first argument to cmp, so cmp
 * can be an asymmetric function if desired. cmp can also be passed
 * as NULL, in which case the compare function from the tree proper
 * will be used.
 *
 * Three of these functions are special cases of findrelpos234. The
 * non-`pos' variants lack the `index' parameter: if the parameter
 * is present and non-NULL, it must point to an integer variable
 * which will be filled with the numeric index of the returned
 * element.
 *
 * The non-`rel' variants lack the `relation' parameter. This
 * parameter allows you to specify what relation the element you
 * provide has to the element you're looking for. This parameter
 * can be:
 *
 *   REL234_EQ     - find only an element that compares equal to e
 *   REL234_LT     - find the greatest element that compares < e
 *   REL234_LE     - find the greatest element that compares <= e
 *   REL234_GT     - find the smallest element that compares > e
 *   REL234_GE     - find the smallest element that compares >= e
 *
 * Non-`rel' variants assume REL234_EQ.
 *
 * If `rel' is REL234_GT or REL234_LT, the `e' parameter may be
 * NULL. In this case, REL234_GT will return the smallest element
 * in the tree, and REL234_LT will return the greatest. This gives
 * an alternative means of iterating over a sorted tree, instead of
 * using index234:
 *
 *   // to loop forwards
 *   for (p = NULL; (p = findrel234(tree, p, NULL, REL234_GT)) != NULL ;)
 *       consume(p);
 *
 *   // to loop backwards
 *   for (p = NULL; (p = findrel234(tree, p, NULL, REL234_LT)) != NULL ;)
 *       consume(p);
 */
enum {
    REL234_EQ, REL234_LT, REL234_LE, REL234_GT, REL234_GE
};
void *find234(tree234 * t, void *e, cmpfn234 cmp);
void *findrel234(tree234 * t, void *e, cmpfn234 cmp, int relation);
void *findpos234(tree234 * t, void *e, cmpfn234 cmp, int *index);
void *findrelpos234(tree234 * t, void *e, cmpfn234 cmp, int relation,
		    int *index);

/*
 * Delete an element e in a 2-3-4 tree. Does not free the element,
 * merely removes all links to it from the tree nodes.
 *
 * delpos234 deletes the element at a particular tree index: it
 * works on both sorted and unsorted trees.
 *
 * del234 deletes the element passed to it, so it only works on
 * sorted trees. (It's equivalent to using findpos234 to determine
 * the index of an element, and then passing that index to
 * delpos234.)
 *
 * Both functions return a pointer to the element they delete, for
 * the user to free or pass on elsewhere or whatever. If the index
 * is out of range (delpos234) or the element is already not in the
 * tree (del234) then they return NULL.
 */
void *del234(tree234 * t, void *e);
void *delpos234(tree234 * t, int index);

/*
 * Return the total element count of a tree234.
 */
int count234(tree234 * t);

#endif				/* TREE234_H */


text:
package com.javarush.test.level23.lesson08.task02;

/* Повторяем threads
Сделать так, чтобы в методе someActions вызывались только методы класса Solution.
Ожидаемый вывод в методе main:
Amigo: Mmmmm, beef
Amigo: knock knock
Amigo: Zzzzzzz...1 sec
*/
class Solution {

  private final String name;
  private final String food;
  private final String sound;

  private Solution(String name, String food, String sound) {
    this.name = name;
    this.food = food;
    this.sound = sound;
  }

  public static void main(String[] args) throws InterruptedException {
    new Solution("Amigo", "beef", "knock").live();
  }

  private void eat() {
    System.out.println(name + ": Mmmmm, " + food);
  }

  private void play() {
    System.out.println(name + ": " + sound + " " + sound);
  }

  private void sleep(long milliseconds) {
    System.out.println(name + ": Zzzzzzz..." + (milliseconds / 1000) + " sec");
  }

  private void live() throws InterruptedException {
    Thread thread = new Thread() {
      public void run() {
        try {
          someActions();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

      private void someActions() {
        eat();
        play();
        Solution.this.sleep(1000);
      }
    };
    thread.start();
    thread.join();
  }
}

redpajama_set_name: RedPajamaGithub


text:
/*
 * NAME: <your name>
 * ID: <your student ID>
 * LOGIN: <your class login>
 */

package hw4;

interface Stack_QueueInterface<T> {

/** Tests if the storage is empty.
    * @return true a storage contains no items; false otherwise.
    */
public boolean isEmpty();

/** Adds an element to a storage
    * @param newItem - item to be added
    */
public void addElement(T newItem);

/** Removes the object from the storage and returns
    * that object as the value of this function.
    * @return value of the removed object.
    */
public T removeElement();

/** Returns the size of the storage
    * @return the size of the storage
    */
public int size();

}


text:
//MIT, 2015-present, brezza92, EngineKit and contributors

using System;
using System.Collections.Generic;
using SharpConnect.MySql;
using SharpConnect.MySql.SyncPatt;
namespace MySqlTest
{

    public class TestSet2 : MySqlTestSet
    {
        [Test]
        public static void T_CallToBlankStoreProc()
        {
            //DELIMITER $$

            //DROP PROCEDURE IF EXISTS `test`.`blank_call` $$
            //CREATE PROCEDURE `test`.`blank_call` ()
            //BEGIN

            //END $$

            //DELIMITER;

            var connStr = GetMySqlConnString();
            var conn2 = new MySqlConnection(connStr);
            conn2.Open();
            conn2.ChangeDB("test");

            var cmd3 = new MySqlCommand("call blank_call()", conn2);
            var reader3 = cmd3.ExecuteReader();
            while (reader3.Read())
            {

            }
            reader3.Close();
            //---------

            conn2.Close();
        }

        static void InsertLargeData(MySqlConnection conn2)
        {
            int size = 1024 * 1000 * 22;//ok
                                        //int size = 1024 * 1000 * 10;//ok

            //int size = 1024;
            byte[] buffer = new byte[size];
            byte dd = 0;
            for (int i = 0; i < size; ++i)
            {
                buffer[i] = dd;
                dd++;
                if (dd > 200)
                {
                    dd = 0;//reset;
                }
            }

            SqlStringTemplate sql_template = new SqlStringTemplate("insert into table2(data) values(?d)");
            var cmd2 = new MySqlCommand(sql_template, conn2);
            cmd2.Parameters.AddWithValue("?d", buffer);
            cmd2.ExecuteNonQuery();//
            if (!cmd2.HasError)
            {
                uint inser_id = cmd2.LastInsertedId;
            }
            else
            {
                //error
            }

        }
        [Test]
        public static void T_LargeData()
        {
            //create data file that large than 16 MB
            //CREATE TABLE `table2` (
            //  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
            //  `data` longblob NOT NULL,
            //  PRIMARY KEY(`id`)
            //) ENGINE = MyISAM DEFAULT CHARSET = utf8

            //int size = 1024 * 50 * 1;//ok
            //int size = 1024 * 100 * 1;//ok

            //#if DEBUG

            //#endif
            var connStr = GetMySqlConnString();
            var conn2 = new MySqlConnection(connStr);
            conn2.Open();
            conn2.ChangeDB("test");

            //InsertLargeData(conn2);
            //---------
            var cmd3 = new MySqlCommand("select data from table2 where id=30", conn2);
            //var cmd3 = new MySqlCommand("select file from table3 limit 1", conn2);
            var reader3 = cmd3.ExecuteReader();
            while (reader3.Read())
            {
                byte[] data_buffer = reader3.GetBuffer(0);

                int len = data_buffer.Length;
            }
            reader3.Close();
            //---------

            conn2.Close();

        }

        [Test]
        public static void T_LongData()
        {
            var connStr = GetMySqlConnString();
            {

                var conn2 = new MySqlConnection(connStr);
                conn2.Open();
                conn2.ChangeDB("test");
                SqlStringTemplate sql_template = new SqlStringTemplate("insert into table1(name) values(?i)");
                for (int i = 0; i < 100000; ++i)
                {
                    var cmd2 = new MySqlCommand(sql_template, conn2);
                    cmd2.Parameters.AddWithValue("?i", i);
                    cmd2.ExecuteNonQuery();//
                }
                conn2.Close();
            }
            //--------------
            var conn = new MySqlConnection(connStr);
            conn.Open();
            conn.ChangeDB("test");
            {
                var cmd = new MySqlCommand("select * from table1", conn);
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {

                }
                reader.Close();
            }
            conn.Close();
        }
        [Test]
        public static void T_WaitTableLock()
        {
            var connStr = GetMySqlConnString();
            var conn2 = new MySqlConnection(connStr);
            conn2.Open();
            conn2.ChangeDB("test");
            var cmd2 = new MySqlCommand("lock tables table1 write", conn2);
            cmd2.ExecuteNonQuery();//

            //--------------
            System.Threading.ThreadPool.QueueUserWorkItem(o =>
            {
                var conn = new MySqlConnection(connStr);
                conn.Open();
                conn.ChangeDB("test");
                {
                    var cmd = new MySqlCommand("select * from table1", conn);
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {

                    }
                    reader.Close();
                }
                conn.Close();
            });

            //--------------
            int i = 0;
            while (i < 1000)
            {
                i++;
                System.Threading.Thread.Sleep(100);
            }

            var cmd3 = new MySqlCommand("unlock tables", conn2);
            cmd3.ExecuteNonQuery();//
        }
        [Test]
        public static void T_Ping()
        {

            {
                var connStr = GetMySqlConnString();
                var conn = new MySqlConnection(connStr);
                conn.Open();
                bool ping = conn.Ping();
                conn.Close();
            }

            {
                //ping, expect err (no connection)

                var connStr = GetMySqlConnString();
                var conn = new MySqlConnection(connStr);
                conn.Open();
#if DEBUG
                conn.dbugMakeSocketError();
#endif
                bool ping = conn.Ping();
                conn.Close();
            }
        }
        [Test]
        public static void T_ResetConnection()
        {
            var connStr = GetMySqlConnString();
            var conn = new MySqlConnection(connStr);
            conn.Open();

            {
                var cmd = new MySqlCommand(new SqlStringTemplate("set @x=20;", false), conn);
                cmd.ExecuteNonQuery();
            }
            {
                var cmd = new MySqlCommand(new SqlStringTemplate("set @y=@x+10;", false), conn);
                cmd.ExecuteNonQuery();
            }
            {
                var cmd = new MySqlCommand(new SqlStringTemplate("select @x,@y", false), conn);
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int x = reader.GetInt32(0);
                    int y = reader.GetInt32(1);

                    //test values
                    if (x != 20 || y != x + 10)
                    {
                        throw new NotSupportedException();
                    }
                }
                reader.Close();
            }

            //
            conn.ResetConnection();

            {
                var cmd = new MySqlCommand(new SqlStringTemplate("select @x,@y", false), conn);
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int x = reader.GetInt32(0);
                    int y = reader.GetInt32(1);

                    //test values after reset conn
                    if (x != 0 || y != 0)
                    {
                        throw new NotSupportedException();
                    }
                }
                reader.Close();
            }

            conn.Close();
        }
        [Test]
        public static void T_InsertAndSelect()
        {
            try
            {
                int n = 1;
                Test(n, TimeUnit.Ticks, out long total, out long avg, () =>
                {
                    var connStr = GetMySqlConnString();
                    var conn = new MySqlConnection(connStr);
                    conn.UseConnectionPool = true;
                    conn.Open();

                    DropTableIfExists(conn);
                    CreateTable(conn);
                    for (int i = 0; i < 100; ++i)
                    {
                        InsertData(conn);
                    }
                    SelectDataBack(conn);
                    SelectDataBack2(conn);//test select decimal back
                    conn.Close();
                });
                Report.WriteLine("avg:" + avg);
            }
            catch (Exception ex)
            {

            }

        }
        static void DropTableIfExists(MySqlConnection conn)
        {
            string sql = "drop table if exists test001";
            var cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
        }

        static void CreateTable(MySqlConnection conn)
        {
            string sql = "create table test001(col_id  int(10) unsigned not null auto_increment, col1 int(10)," +
                "col2 char(2),col3 varchar(255),col4 datetime,col5 decimal(5,2), col6 decimal(16,8), primary key(col_id) )";
            var cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
        }
        static void InsertData(MySqlConnection conn)
        {
            string sql = "insert into test001(col1,col2,col3,col4,col5,col6) values(10,'AA','123456789','0001-01-01',5.1,10.2857948)";
            var cmd = new MySqlCommand(sql, conn);
            cmd.ExecuteNonQuery();
            uint lastInsertId = cmd.LastInsertedId;
        }
        static void SelectDataBack(MySqlConnection conn)
        {
            string sql = "select * from test001";
            var cmd = new MySqlCommand(sql, conn);
#if DEBUG
            conn.dbugPleaseBreak = true;
#endif
            var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                //test immediate close
                //reader.Close();
                object o0 = reader.GetValue(0);
                object o1 = reader.GetValue(1);
                object o2 = reader.GetValue("col3");
                object o3 = reader.GetValue("col4");
                object o4 = reader.GetValue("col5");
                object o5 = reader.GetValue("col6");
            }
            reader.Close();
        }
        static void SelectDataBack2(MySqlConnection conn)
        {
            string sql = "select 1.0/3.0;";
            var cmd = new MySqlCommand(sql, conn);
            var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                object value = reader.GetValue(0);
            }
            reader.Close();
        }
    }
}


text:
<document>
  <properties>
    <author email="Kit@objectlab.co.uk">Benoit Xhenseval</author>
    <title>Tenor Handling</title>
  </properties>

    <meta name="description"
	content="Tenor are representation of some specific financial date/durations."
	/>

    <meta name="keywords"
        content="Date calculator, IMM Dates, Period Calculator, Financial Calendar, Business Calendar, java, open source" />
    <meta name="Subject" content="Date Calculators" />
    <meta name="Copyright" content="ObjectLab Financial Ltd" />
    <meta name="Language" content="English" />
    <meta name="Designer" content="ObjectLab Financial Ltd" />
    <meta name="Distribution" content="Global" />
    <meta name="robots" content="ALL"/>
    <meta name="Revisit-After" content="20 Days" />

    <subsection name="Spot">

Example that shows the calculation of a Spot date with 2 different spotLags. SpotLag is typically 2 days but this may
    vary by market and/or currencies.

    </subsection>

    <subsection name="1D - 1 Day">

Example of a 1D calculation, first of all it calculates the Spot Day (spotLag=2) and then adds 1 day to it

    </subsection>

    <subsection name="2D - 2 Day">

Example of a 2D calculation, first of all it calculates the Spot Day (spotLag=2) and then adds 2 days to it and it must
    roll forward as the calculated date falls on a weekend.

    </subsection>

    <subsection name="1W - 1 Week">

Example of a 1W calculation, first of all it calculates the Spot Day (spotLag=2) and then adds 1 week to it and it must
    roll forward as the calculated date falls on a holiday.

    </subsection>

    <subsection name="1M - 1 Month">

Example of a 1M calculation, first of all it calculates the Spot Day (spotLag=2) and then adds 1 month to it.
    Notice that it falls on the last day of the month too.

    </subsection>

    <subsection name="1Y - 1 Year">

Example of a 1Y calculation, first of all it calculates the Spot Day (spotLag=2) and then adds 1 year to it.
    Notice that it falls on a weekend and hence is moved forward (if HandlerHolidayType is 'forward').

    </subsection>

</document>


text:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsEventDispatcher.h"
#include "nsDOMEvent.h"
#include "nsIDOMEventTarget.h"
#include "nsPresContext.h"
#include "nsEventListenerManager.h"
#include "nsContentUtils.h"
#include "nsError.h"
#include "nsMutationEvent.h"
#include NEW_H
#include "nsFixedSizeAllocator.h"
#include "nsINode.h"
#include "nsPIDOMWindow.h"
#include "nsFrameLoader.h"
#include "nsDOMTouchEvent.h"
#include "nsDOMStorage.h"
#include "sampler.h"
#include "GeneratedEvents.h"

using namespace mozilla;

#define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH  (1 << 0)
#define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1)
#define NS_TARGET_CHAIN_MAY_HAVE_MANAGER        (1 << 2)

static nsEventTargetChainItem* gCachedETCI = nullptr;

// nsEventTargetChainItem represents a single item in the event target chain.
class nsEventTargetChainItem
{
private:
  nsEventTargetChainItem(nsIDOMEventTarget* aTarget,
                         nsEventTargetChainItem* aChild = nullptr);

public:
  static nsEventTargetChainItem* Create(nsFixedSizeAllocator* aAllocator,
                                        nsIDOMEventTarget* aTarget,
                                        nsEventTargetChainItem* aChild = nullptr)
  {
    void* place = nullptr;
    if (gCachedETCI) {
      place = gCachedETCI;
      gCachedETCI = gCachedETCI->mNext;
    } else {
      place = aAllocator->Alloc(sizeof(nsEventTargetChainItem));
    }
    return place
      ? ::new (place) nsEventTargetChainItem(aTarget, aChild)
      : nullptr;
  }

  static void Destroy(nsFixedSizeAllocator* aAllocator,
                      nsEventTargetChainItem* aItem)
  {
    // ::Destroy deletes ancestor chain.
    nsEventTargetChainItem* item = aItem;
    if (item->mChild) {
      item->mChild->mParent = nullptr;
      item->mChild = nullptr;
    }
    while (item) {
      nsEventTargetChainItem* parent = item->mParent;
      item->~nsEventTargetChainItem();
      item->mNext = gCachedETCI;
      gCachedETCI = item;
      --sCurrentEtciCount;
      item = parent;
    }
  }

  bool IsValid()
  {
    NS_WARN_IF_FALSE(!!(mTarget), "Event target is not valid!");
    return !!(mTarget);
  }

  nsIDOMEventTarget* GetNewTarget()
  {
    return mNewTarget;
  }

  void SetNewTarget(nsIDOMEventTarget* aNewTarget)
  {
    mNewTarget = aNewTarget;
  }

  void SetForceContentDispatch(bool aForce)
  {
    if (aForce) {
      mFlags |= NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH;
    } else {
      mFlags &= ~NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH;
    }
  }

  bool ForceContentDispatch()
  {
    return !!(mFlags & NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH);
  }

  void SetWantsWillHandleEvent(bool aWants)
  {
    if (aWants) {
      mFlags |= NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT;
    } else {
      mFlags &= ~NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT;
    }
  }

  bool WantsWillHandleEvent()
  {
    return !!(mFlags & NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT);
  }

  void SetMayHaveListenerManager(bool aMayHave)
  {
    if (aMayHave) {
      mFlags |= NS_TARGET_CHAIN_MAY_HAVE_MANAGER;
    } else {
      mFlags &= ~NS_TARGET_CHAIN_MAY_HAVE_MANAGER;
    }
  }

  bool MayHaveListenerManager()
  {
    return !!(mFlags & NS_TARGET_CHAIN_MAY_HAVE_MANAGER);
  }

  nsIDOMEventTarget* CurrentTarget()
  {
    return mTarget;
  }

  /**
   * Dispatches event through the event target chain.
   * Handles capture, target and bubble phases both in default
   * and system event group and calls also PostHandleEvent for each
   * item in the chain.
   */
  nsresult HandleEventTargetChain(nsEventChainPostVisitor& aVisitor,
                                  uint32_t aFlags,
                                  nsDispatchingCallback* aCallback,
                                  bool aMayHaveNewListenerManagers,
                                  nsCxPusher* aPusher);

  /**
   * Resets aVisitor object and calls PreHandleEvent.
   * Copies mItemFlags and mItemData to the current nsEventTargetChainItem.
   */
  nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);

  /**
   * If the current item in the event target chain has an event listener
   * manager, this method calls nsEventListenerManager::HandleEvent().
   */
  nsresult HandleEvent(nsEventChainPostVisitor& aVisitor, uint32_t aFlags,
                       bool aMayHaveNewListenerManagers,
                       nsCxPusher* aPusher)
  {
    if (WantsWillHandleEvent()) {
      mTarget->WillHandleEvent(aVisitor);
    }
    if (aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) {
      return NS_OK;
    }
    if (!mManager) {
      if (!MayHaveListenerManager() && !aMayHaveNewListenerManagers) {
        return NS_OK;
      }
      mManager =
        static_cast<nsEventListenerManager*>(mTarget->GetListenerManager(false));
    }
    if (mManager) {
      NS_ASSERTION(aVisitor.mEvent->currentTarget == nullptr,
                   "CurrentTarget should be null!");
      mManager->HandleEvent(aVisitor.mPresContext, aVisitor.mEvent,
                            &aVisitor.mDOMEvent,
                            CurrentTarget(), aFlags,
                            &aVisitor.mEventStatus,
                            aPusher);
      NS_ASSERTION(aVisitor.mEvent->currentTarget == nullptr,
                   "CurrentTarget should be null!");
    }
    return NS_OK;
  }

  /**
   * Copies mItemFlags and mItemData to aVisitor and calls PostHandleEvent.
   */
  nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor,
                           nsCxPusher* aPusher);

  static uint32_t MaxEtciCount() { return sMaxEtciCount; }

  static void ResetMaxEtciCount()
  {
    NS_ASSERTION(!sCurrentEtciCount, "Wrong time to call ResetMaxEtciCount()!");
    sMaxEtciCount = 0;
  }

  nsCOMPtr<nsIDOMEventTarget>       mTarget;
  nsEventTargetChainItem*           mChild;
  union {
    nsEventTargetChainItem*         mParent;
     // This is used only when caching ETCI objects.
    nsEventTargetChainItem*         mNext;
  };
  uint16_t                          mFlags;
  uint16_t                          mItemFlags;
  nsCOMPtr<nsISupports>             mItemData;
  // Event retargeting must happen whenever mNewTarget is non-null.
  nsCOMPtr<nsIDOMEventTarget>       mNewTarget;
  // Cache mTarget's event listener manager.
  nsRefPtr<nsEventListenerManager>  mManager;

  static uint32_t                   sMaxEtciCount;
  static uint32_t                   sCurrentEtciCount;
};

uint32_t nsEventTargetChainItem::sMaxEtciCount = 0;
uint32_t nsEventTargetChainItem::sCurrentEtciCount = 0;

nsEventTargetChainItem::nsEventTargetChainItem(nsIDOMEventTarget* aTarget,
                                               nsEventTargetChainItem* aChild)
: mTarget(aTarget), mChild(aChild), mParent(nullptr), mFlags(0), mItemFlags(0)
{
  MOZ_ASSERT(!aTarget || mTarget == aTarget->GetTargetForEventTargetChain());
  if (mChild) {
    mChild->mParent = this;
  }

  if (++sCurrentEtciCount > sMaxEtciCount) {
    sMaxEtciCount = sCurrentEtciCount;
  }
}

nsresult
nsEventTargetChainItem::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{
  aVisitor.Reset();
  nsresult rv = mTarget->PreHandleEvent(aVisitor);
  SetForceContentDispatch(aVisitor.mForceContentDispatch);
  SetWantsWillHandleEvent(aVisitor.mWantsWillHandleEvent);
  SetMayHaveListenerManager(aVisitor.mMayHaveListenerManager);
  mItemFlags = aVisitor.mItemFlags;
  mItemData = aVisitor.mItemData;
  return rv;
}

nsresult
nsEventTargetChainItem::PostHandleEvent(nsEventChainPostVisitor& aVisitor,
                                        nsCxPusher* aPusher)
{
  aPusher->Pop();
  aVisitor.mItemFlags = mItemFlags;
  aVisitor.mItemData = mItemData;
  mTarget->PostHandleEvent(aVisitor);
  return NS_OK;
}

nsresult
nsEventTargetChainItem::HandleEventTargetChain(nsEventChainPostVisitor& aVisitor, uint32_t aFlags,
                                               nsDispatchingCallback* aCallback,
                                               bool aMayHaveNewListenerManagers,
                                               nsCxPusher* aPusher)
{
  uint32_t createdELMs = nsEventListenerManager::sCreatedCount;
  // Save the target so that it can be restored later.
  nsCOMPtr<nsIDOMEventTarget> firstTarget = aVisitor.mEvent->target;

  // Capture
  nsEventTargetChainItem* item = this;
  aVisitor.mEvent->flags |= NS_EVENT_FLAG_CAPTURE;
  aVisitor.mEvent->flags &= ~NS_EVENT_FLAG_BUBBLE;
  while (item->mChild) {
    if ((!(aVisitor.mEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH) ||
         item->ForceContentDispatch()) &&
        !(aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) {
      item->HandleEvent(aVisitor, aFlags & NS_EVENT_CAPTURE_MASK,
                        aMayHaveNewListenerManagers ||
                        createdELMs != nsEventListenerManager::sCreatedCount,
                        aPusher);
    }

    if (item->GetNewTarget()) {
      // item is at anonymous boundary. Need to retarget for the child items.
      nsEventTargetChainItem* nextTarget = item->mChild;
      while (nextTarget) {
        nsIDOMEventTarget* newTarget = nextTarget->GetNewTarget();
        if (newTarget) {
          aVisitor.mEvent->target = newTarget;
          break;
        }
        nextTarget = nextTarget->mChild;
      }
    }

    item = item->mChild;
  }

  // Target
  aVisitor.mEvent->flags |= NS_EVENT_FLAG_BUBBLE;
  if (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
      (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH) ||
       item->ForceContentDispatch())) {
    // FIXME Should use aFlags & NS_EVENT_BUBBLE_MASK because capture phase
    //       event listeners should not be fired. But it breaks at least
    //       <xul:dialog>'s buttons. Bug 235441.
    item->HandleEvent(aVisitor, aFlags,
                      aMayHaveNewListenerManagers ||
                      createdELMs != nsEventListenerManager::sCreatedCount,
                      aPusher);
  }
  if (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
    item->PostHandleEvent(aVisitor, aPusher);
  }

  // Bubble
  aVisitor.mEvent->flags &= ~NS_EVENT_FLAG_CAPTURE;
  item = item->mParent;
  while (item) {
    nsIDOMEventTarget* newTarget = item->GetNewTarget();
    if (newTarget) {
      // Item is at anonymous boundary. Need to retarget for the current item
      // and for parent items.
      aVisitor.mEvent->target = newTarget;
    }

    if (!(aVisitor.mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE) || newTarget) {
      if ((!(aVisitor.mEvent->flags & NS_EVENT_FLAG_NO_CONTENT_DISPATCH) ||
           item->ForceContentDispatch()) &&
          !(aVisitor.mEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH)) {
        item->HandleEvent(aVisitor, aFlags & NS_EVENT_BUBBLE_MASK,
                          createdELMs != nsEventListenerManager::sCreatedCount,
                          aPusher);
      }
      if (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
        item->PostHandleEvent(aVisitor, aPusher);
      }
    }
    item = item->mParent;
  }
  aVisitor.mEvent->flags &= ~NS_EVENT_FLAG_BUBBLE;

  if (!(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) {
    // Dispatch to the system event group.  Make sure to clear the
    // STOP_DISPATCH flag since this resets for each event group.
    aVisitor.mEvent->flags &=
      ~(NS_EVENT_FLAG_STOP_DISPATCH | NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY);

    // Setting back the original target of the event.
    aVisitor.mEvent->target = aVisitor.mEvent->originalTarget;

    // Special handling if PresShell (or some other caller)
    // used a callback object.
    if (aCallback) {
      aPusher->Pop();
      aCallback->HandleEvent(aVisitor);
    }

    // Retarget for system event group (which does the default handling too).
    // Setting back the target which was used also for default event group.
    aVisitor.mEvent->target = firstTarget;
    HandleEventTargetChain(aVisitor, aFlags | NS_EVENT_FLAG_SYSTEM_EVENT,
                           aCallback,
                           createdELMs != nsEventListenerManager::sCreatedCount,
                           aPusher);

    // After dispatch, clear all the propagation flags so that
    // system group listeners don't affect to the event.
    aVisitor.mEvent->flags &=
      ~(NS_EVENT_FLAG_STOP_DISPATCH | NS_EVENT_FLAG_STOP_DISPATCH_IMMEDIATELY);
  }

  return NS_OK;
}

#define NS_CHAIN_POOL_SIZE 128

class ChainItemPool {
public:
  ChainItemPool() {
    if (!sEtciPool) {
      sEtciPool = new nsFixedSizeAllocator();
      if (sEtciPool) {
        static const size_t kBucketSizes[] = { sizeof(nsEventTargetChainItem) };
        static const int32_t kNumBuckets = sizeof(kBucketSizes) / sizeof(size_t);
        static const int32_t kInitialPoolSize =
          sizeof(nsEventTargetChainItem) * NS_CHAIN_POOL_SIZE;
        nsresult rv = sEtciPool->Init("EventTargetChainItem Pool", kBucketSizes,
                                      kNumBuckets, kInitialPoolSize);
        if (NS_FAILED(rv)) {
          delete sEtciPool;
          sEtciPool = nullptr;
        }
      }
    }
    if (sEtciPool) {
      ++sEtciPoolUsers;
    }
  }

  ~ChainItemPool() {
    if (sEtciPool) {
      --sEtciPoolUsers;
    }
    if (!sEtciPoolUsers) {
      if (nsEventTargetChainItem::MaxEtciCount() > NS_CHAIN_POOL_SIZE) {
        gCachedETCI = nullptr;
        delete sEtciPool;
        sEtciPool = nullptr;
        nsEventTargetChainItem::ResetMaxEtciCount();
      }
    }
  }

  static void Shutdown()
  {
    if (!sEtciPoolUsers) {
      gCachedETCI = nullptr;
      delete sEtciPool;
      sEtciPool = nullptr;
      nsEventTargetChainItem::ResetMaxEtciCount();
    }
  }

  nsFixedSizeAllocator* GetPool() { return sEtciPool; }

  static nsFixedSizeAllocator* sEtciPool;
  static int32_t               sEtciPoolUsers;
};

nsFixedSizeAllocator* ChainItemPool::sEtciPool = nullptr;
int32_t ChainItemPool::sEtciPoolUsers = 0;

void NS_ShutdownChainItemPool() { ChainItemPool::Shutdown(); }

/* static */ nsresult
nsEventDispatcher::Dispatch(nsISupports* aTarget,
                            nsPresContext* aPresContext,
                            nsEvent* aEvent,
                            nsIDOMEvent* aDOMEvent,
                            nsEventStatus* aEventStatus,
                            nsDispatchingCallback* aCallback,
                            nsCOMArray<nsIDOMEventTarget>* aTargets)
{
  SAMPLE_LABEL("nsEventDispatcher", "Dispatch");
  NS_ASSERTION(aEvent, "Trying to dispatch without nsEvent!");
  NS_ENSURE_TRUE(!NS_IS_EVENT_IN_DISPATCH(aEvent),
                 NS_ERROR_ILLEGAL_VALUE);
  NS_ASSERTION(!aTargets || !aEvent->message, "Wrong parameters!");

  // If we're dispatching an already created DOMEvent object, make
  // sure it is initialized!
  // If aTargets is non-null, the event isn't going to be dispatched.
  NS_ENSURE_TRUE(aEvent->message || !aDOMEvent || aTargets,
                 NS_ERROR_DOM_INVALID_STATE_ERR);

  nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aTarget);

  bool retargeted = false;

  if (aEvent->flags & NS_EVENT_RETARGET_TO_NON_NATIVE_ANONYMOUS) {
    nsCOMPtr<nsIContent> content = do_QueryInterface(target);
    if (content && content->IsInNativeAnonymousSubtree()) {
      nsCOMPtr<nsPIDOMEventTarget> newTarget =
        do_QueryInterface(content->FindFirstNonChromeOnlyAccessContent());
      NS_ENSURE_STATE(newTarget);

      aEvent->originalTarget = target;
      target = newTarget;
      retargeted = true;
    }
  }

  if (aEvent->flags & NS_EVENT_FLAG_ONLY_CHROME_DISPATCH) {
    nsCOMPtr<nsINode> node = do_QueryInterface(aTarget);
    if (!node) {
      nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aTarget);
      if (win) {
        node = do_QueryInterface(win->GetExtantDocument());
      }
    }

    NS_ENSURE_STATE(node);
    nsIDocument* doc = node->OwnerDoc();
    if (!nsContentUtils::IsChromeDoc(doc)) {
      nsPIDOMWindow* win = doc ? doc->GetInnerWindow() : nullptr;
      // If we can't dispatch the event to chrome, do nothing.
      nsIDOMEventTarget* piTarget = win ? win->GetParentTarget() : nullptr;
      NS_ENSURE_TRUE(piTarget, NS_OK);

      // Set the target to be the original dispatch target,
      aEvent->target = target;
      // but use chrome event handler or TabChildGlobal for event target chain.
      target = piTarget;
    }
  }

#ifdef DEBUG
  if (!nsContentUtils::IsSafeToRunScript()) {
    nsresult rv = NS_ERROR_FAILURE;
    if (target->GetContextForEventHandlers(&rv) ||
        NS_FAILED(rv)) {
      nsCOMPtr<nsINode> node = do_QueryInterface(target);
      if (node && nsContentUtils::IsChromeDoc(node->OwnerDoc())) {
        NS_WARNING("Fix the caller!");
      } else {
        NS_ERROR("This is unsafe! Fix the caller!");
      }
    }
  }

  if (aDOMEvent) {
    nsEvent* innerEvent = aDOMEvent->GetInternalNSEvent();
    NS_ASSERTION(innerEvent == aEvent,
                  "The inner event of aDOMEvent is not the same as aEvent!");
  }
#endif

  nsresult rv = NS_OK;
  bool externalDOMEvent = !!(aDOMEvent);

  // If we have a PresContext, make sure it doesn't die before
  // event dispatching is finished.
  nsRefPtr<nsPresContext> kungFuDeathGrip(aPresContext);
  ChainItemPool pool;
  NS_ENSURE_TRUE(pool.GetPool(), NS_ERROR_OUT_OF_MEMORY);

  // Create the event target chain item for the event target.
  nsEventTargetChainItem* targetEtci =
    nsEventTargetChainItem::Create(pool.GetPool(),
                                   target->GetTargetForEventTargetChain());
  NS_ENSURE_TRUE(targetEtci, NS_ERROR_OUT_OF_MEMORY);
  if (!targetEtci->IsValid()) {
    nsEventTargetChainItem::Destroy(pool.GetPool(), targetEtci);
    return NS_ERROR_FAILURE;
  }

  // Make sure that nsIDOMEvent::target and nsIDOMEvent::originalTarget
  // point to the last item in the chain.
  if (!aEvent->target) {
    // Note, CurrentTarget() points always to the object returned by
    // GetTargetForEventTargetChain().
    aEvent->target = targetEtci->CurrentTarget();
  } else {
    // XXX But if the target is already set, use that. This is a hack
    //     for the 'load', 'beforeunload' and 'unload' events,
    //     which are dispatched to |window| but have document as their target.
    //
    // Make sure that the event target points to the right object.
    aEvent->target = aEvent->target->GetTargetForEventTargetChain();
    NS_ENSURE_STATE(aEvent->target);
  }

  if (retargeted) {
    aEvent->originalTarget =
      aEvent->originalTarget->GetTargetForEventTargetChain();
    NS_ENSURE_STATE(aEvent->originalTarget);
  }
  else {
    aEvent->originalTarget = aEvent->target;
  }

  nsCOMPtr<nsIContent> content = do_QueryInterface(aEvent->originalTarget);
  bool isInAnon = (content && content->IsInAnonymousSubtree());

  NS_MARK_EVENT_DISPATCH_STARTED(aEvent);

  // Create visitor object and start event dispatching.
  // PreHandleEvent for the original target.
  nsEventStatus status = aEventStatus ? *aEventStatus : nsEventStatus_eIgnore;
  nsEventChainPreVisitor preVisitor(aPresContext, aEvent, aDOMEvent, status,
                                    isInAnon);
  targetEtci->PreHandleEvent(preVisitor);

  if (preVisitor.mCanHandle) {
    // At least the original target can handle the event.
    // Setting the retarget to the |target| simplifies retargeting code.
    nsCOMPtr<nsIDOMEventTarget> t = aEvent->target;
    targetEtci->SetNewTarget(t);
    nsEventTargetChainItem* topEtci = targetEtci;
    while (preVisitor.mParentTarget) {
      nsEventTargetChainItem* parentEtci =
        nsEventTargetChainItem::Create(pool.GetPool(), preVisitor.mParentTarget,
                                       topEtci);
      if (!parentEtci) {
        rv = NS_ERROR_OUT_OF_MEMORY;
        break;
      }
      if (!parentEtci->IsValid()) {
        rv = NS_ERROR_FAILURE;
        break;
      }

      // Item needs event retargetting.
      if (preVisitor.mEventTargetAtParent) {
        // Need to set the target of the event
        // so that also the next retargeting works.
        preVisitor.mEvent->target = preVisitor.mEventTargetAtParent;
        parentEtci->SetNewTarget(preVisitor.mEventTargetAtParent);
      }

      parentEtci->PreHandleEvent(preVisitor);
      if (preVisitor.mCanHandle) {
        topEtci = parentEtci;
      } else {
        nsEventTargetChainItem::Destroy(pool.GetPool(), parentEtci);
        parentEtci = nullptr;
        break;
      }
    }
    if (NS_SUCCEEDED(rv)) {
      if (aTargets) {
        aTargets->Clear();
        nsEventTargetChainItem* item = targetEtci;
        while(item) {
          aTargets->AppendObject(item->CurrentTarget()->GetTargetForDOMEvent());
          item = item->mParent;
        }
      } else {
        // Event target chain is created. Handle the chain.
        nsEventChainPostVisitor postVisitor(preVisitor);
        nsCxPusher pusher;
        rv = topEtci->HandleEventTargetChain(postVisitor,
                                             NS_EVENT_FLAG_BUBBLE |
                                             NS_EVENT_FLAG_CAPTURE,
                                             aCallback,
                                             false,
                                             &pusher);

        preVisitor.mEventStatus = postVisitor.mEventStatus;
        // If the DOM event was created during event flow.
        if (!preVisitor.mDOMEvent && postVisitor.mDOMEvent) {
          preVisitor.mDOMEvent = postVisitor.mDOMEvent;
        }
      }
    }
  }

  nsEventTargetChainItem::Destroy(pool.GetPool(), targetEtci);
  targetEtci = nullptr;

  NS_MARK_EVENT_DISPATCH_DONE(aEvent);

  if (!externalDOMEvent && preVisitor.mDOMEvent) {
    // An nsDOMEvent was created while dispatching the event.
    // Duplicate private data if someone holds a pointer to it.
    nsrefcnt rc = 0;
    NS_RELEASE2(preVisitor.mDOMEvent, rc);
    if (preVisitor.mDOMEvent) {
      preVisitor.mDOMEvent->DuplicatePrivateData();
    }
  }

  if (aEventStatus) {
    *aEventStatus = preVisitor.mEventStatus;
  }
  return rv;
}

/* static */ nsresult
nsEventDispatcher::DispatchDOMEvent(nsISupports* aTarget,
                                    nsEvent* aEvent,
                                    nsIDOMEvent* aDOMEvent,
                                    nsPresContext* aPresContext,
                                    nsEventStatus* aEventStatus)
{
  if (aDOMEvent) {
    nsEvent* innerEvent = aDOMEvent->GetInternalNSEvent();
    NS_ENSURE_TRUE(innerEvent, NS_ERROR_ILLEGAL_VALUE);

    bool dontResetTrusted = false;
    if (innerEvent->flags & NS_EVENT_DISPATCHED) {
      innerEvent->target = nullptr;
      innerEvent->originalTarget = nullptr;
    } else {
      aDOMEvent->GetIsTrusted(&dontResetTrusted);
    }

    if (!dontResetTrusted) {
      //Check security state to determine if dispatcher is trusted
      aDOMEvent->SetTrusted(nsContentUtils::IsCallerTrustedForWrite());
    }

    return nsEventDispatcher::Dispatch(aTarget, aPresContext, innerEvent,
                                       aDOMEvent, aEventStatus);
  } else if (aEvent) {
    return nsEventDispatcher::Dispatch(aTarget, aPresContext, aEvent,
                                       aDOMEvent, aEventStatus);
  }
  return NS_ERROR_ILLEGAL_VALUE;
}

/* static */ nsresult
nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
                               nsEvent* aEvent,
                               const nsAString& aEventType,
                               nsIDOMEvent** aDOMEvent)
{
  *aDOMEvent = nullptr;

  if (aEvent) {
    switch(aEvent->eventStructType) {
    case NS_MUTATION_EVENT:
      return NS_NewDOMMutationEvent(aDOMEvent, aPresContext,
                                    static_cast<nsMutationEvent*>(aEvent));
    case NS_GUI_EVENT:
    case NS_SCROLLPORT_EVENT:
    case NS_UI_EVENT:
      return NS_NewDOMUIEvent(aDOMEvent, aPresContext,
                              static_cast<nsGUIEvent*>(aEvent));
    case NS_SCROLLAREA_EVENT:
      return NS_NewDOMScrollAreaEvent(aDOMEvent, aPresContext,
                                      static_cast<nsScrollAreaEvent *>(aEvent));
    case NS_KEY_EVENT:
      return NS_NewDOMKeyboardEvent(aDOMEvent, aPresContext,
                                    static_cast<nsKeyEvent*>(aEvent));
    case NS_COMPOSITION_EVENT:
      return NS_NewDOMCompositionEvent(
        aDOMEvent, aPresContext, static_cast<nsCompositionEvent*>(aEvent));
    case NS_MOUSE_EVENT:
    case NS_POPUP_EVENT:
      return NS_NewDOMMouseEvent(aDOMEvent, aPresContext,
                                 static_cast<nsInputEvent*>(aEvent));
    case NS_MOUSE_SCROLL_EVENT:
      return NS_NewDOMMouseScrollEvent(aDOMEvent, aPresContext,
                                 static_cast<nsInputEvent*>(aEvent));
    case NS_WHEEL_EVENT:
      return NS_NewDOMWheelEvent(aDOMEvent, aPresContext,
                                 static_cast<widget::WheelEvent*>(aEvent));
    case NS_DRAG_EVENT:
      return NS_NewDOMDragEvent(aDOMEvent, aPresContext,
                                 static_cast<nsDragEvent*>(aEvent));
    case NS_TEXT_EVENT:
      return NS_NewDOMTextEvent(aDOMEvent, aPresContext,
                                static_cast<nsTextEvent*>(aEvent));
    case NS_SVG_EVENT:
      return NS_NewDOMSVGEvent(aDOMEvent, aPresContext,
                               aEvent);
    case NS_SVGZOOM_EVENT:
      return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext,
                                   static_cast<nsGUIEvent*>(aEvent));
    case NS_SMIL_TIME_EVENT:
      return NS_NewDOMTimeEvent(aDOMEvent, aPresContext, aEvent);

    case NS_COMMAND_EVENT:
      return NS_NewDOMCommandEvent(aDOMEvent, aPresContext,
                                   static_cast<nsCommandEvent*>(aEvent));
    case NS_SIMPLE_GESTURE_EVENT:
      return NS_NewDOMSimpleGestureEvent(aDOMEvent, aPresContext,
                                         static_cast<nsSimpleGestureEvent*>(aEvent));
    case NS_TOUCH_EVENT:
      return NS_NewDOMTouchEvent(aDOMEvent, aPresContext,
                                 static_cast<nsTouchEvent*>(aEvent));
    case NS_TRANSITION_EVENT:
      return NS_NewDOMTransitionEvent(aDOMEvent, aPresContext,
                                      static_cast<nsTransitionEvent*>(aEvent));
    case NS_ANIMATION_EVENT:
      return NS_NewDOMAnimationEvent(aDOMEvent, aPresContext,
                                     static_cast<nsAnimationEvent*>(aEvent));
    }

    // For all other types of events, create a vanilla event object.
    return NS_NewDOMEvent(aDOMEvent, aPresContext, aEvent);
  }

  // And if we didn't get an event, check the type argument.

  if (aEventType.LowerCaseEqualsLiteral("mouseevent") ||
      aEventType.LowerCaseEqualsLiteral("mouseevents") ||
      aEventType.LowerCaseEqualsLiteral("popupevents"))
    return NS_NewDOMMouseEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("mousescrollevents"))
    return NS_NewDOMMouseScrollEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("dragevent") ||
      aEventType.LowerCaseEqualsLiteral("dragevents"))
    return NS_NewDOMDragEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("keyboardevent") ||
      aEventType.LowerCaseEqualsLiteral("keyevents"))
    return NS_NewDOMKeyboardEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("compositionevent"))
    return NS_NewDOMCompositionEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("mutationevent") ||
        aEventType.LowerCaseEqualsLiteral("mutationevents"))
    return NS_NewDOMMutationEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("textevent") ||
      aEventType.LowerCaseEqualsLiteral("textevents"))
    return NS_NewDOMTextEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("popupblockedevents"))
    return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("deviceorientationevent"))
    return NS_NewDOMDeviceOrientationEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("devicemotionevent"))
    return NS_NewDOMDeviceMotionEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("uievent") ||
      aEventType.LowerCaseEqualsLiteral("uievents"))
    return NS_NewDOMUIEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("event") ||
      aEventType.LowerCaseEqualsLiteral("events") ||
      aEventType.LowerCaseEqualsLiteral("htmlevents"))
    return NS_NewDOMEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("svgevent") ||
      aEventType.LowerCaseEqualsLiteral("svgevents"))
    return NS_NewDOMSVGEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("svgzoomevent") ||
      aEventType.LowerCaseEqualsLiteral("svgzoomevents"))
    return NS_NewDOMSVGZoomEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("timeevent") ||
      aEventType.LowerCaseEqualsLiteral("timeevents"))
    return NS_NewDOMTimeEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("xulcommandevent") ||
      aEventType.LowerCaseEqualsLiteral("xulcommandevents"))
    return NS_NewDOMXULCommandEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("commandevent") ||
      aEventType.LowerCaseEqualsLiteral("commandevents"))
    return NS_NewDOMCommandEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("datacontainerevent") ||
      aEventType.LowerCaseEqualsLiteral("datacontainerevents"))
    return NS_NewDOMDataContainerEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("messageevent"))
    return NS_NewDOMMessageEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("progressevent"))
    return NS_NewDOMProgressEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("notifypaintevent"))
    return NS_NewDOMNotifyPaintEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("simplegestureevent"))
    return NS_NewDOMSimpleGestureEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("beforeunloadevent"))
    return NS_NewDOMBeforeUnloadEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("pagetransition"))
    return NS_NewDOMPageTransitionEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("scrollareaevent"))
    return NS_NewDOMScrollAreaEvent(aDOMEvent, aPresContext, nullptr);
  // FIXME: Should get spec to say what the right string is here!  This
  // is probably wrong!
  if (aEventType.LowerCaseEqualsLiteral("transitionevent"))
    return NS_NewDOMTransitionEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("animationevent"))
    return NS_NewDOMAnimationEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("popstateevent"))
    return NS_NewDOMPopStateEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("mozaudioavailableevent"))
    return NS_NewDOMAudioAvailableEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("closeevent"))
    return NS_NewDOMCloseEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("touchevent") &&
      nsDOMTouchEvent::PrefEnabled())
    return NS_NewDOMTouchEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("hashchangeevent"))
    return NS_NewDOMHashChangeEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("customevent"))
    return NS_NewDOMCustomEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("mozsmsevent"))
    return NS_NewDOMSmsEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("mozmmsevent"))
    return NS_NewDOMMozMmsEvent(aDOMEvent, aPresContext, nullptr);
  if (aEventType.LowerCaseEqualsLiteral("storageevent")) {
    return NS_NewDOMStorageEvent(aDOMEvent, aPresContext, nullptr);
  }

  return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}


text:
package consumer.service;

import java.util.List;

import consumer.model.Product;

public interface ProductService {
	List<Product> retrieveAllProduct();
}


text:
// Node classes used for different views. They are wrappers with "show"
// methods.
//
// ScopeNode is for scope view. GraphNode is for graph view, CodeNode
// is for code view and OpNode for op view.
// ScopeNode and GraphNode each maps to one TFGraphNode.
// CodeNode and OpNode each maps to one TFMultiGraphNode.

#ifndef THIRD_PARTY_TENSORFLOW_TOOLS_TFPROF_INTERNAL_TFPROF_NODE_SHOW_H_
#define THIRD_PARTY_TENSORFLOW_TOOLS_TFPROF_INTERNAL_TFPROF_NODE_SHOW_H_

#include <algorithm>
#include <string>
#include <vector>

#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/tools/tfprof/internal/tfprof_constants.h"
#include "tensorflow/tools/tfprof/internal/tfprof_node.h"
#include "tensorflow/tools/tfprof/internal/tfprof_options.h"
#include "tensorflow/tools/tfprof/internal/tfprof_utils.h"
#include "tensorflow/tools/tfprof/tfprof_output.pb.h"

namespace tensorflow {
namespace tfprof {

class ShowNode {
 public:
  explicit ShowNode(const TFGraphNode* node);
  virtual ~ShowNode() {}

  const string& name() const { return node->name(); }
  TFGraphNodeProto* mutable_proto();
  const TFGraphNodeProto& proto() const;

  void ReInit(int64 step);

  void AggregateTotalStats(ShowNode* node);

  void AddSelfToTotalStats();

  void ResetTotalStats();

  const TFGraphNode* node;
  bool account;
  string formatted_str;

 protected:
  TFGraphNodeProto proto_;
};

class GraphNode : public ShowNode {
 public:
  explicit GraphNode(TFGraphNode* node) : ShowNode(node) {}

  bool Trackable(int64 step) const { return node->trackable(step); }

  std::vector<GraphNode*> children;
  std::vector<GraphNode*> show_children;
};

class ScopeNode : public ShowNode {
 public:
  explicit ScopeNode(const TFGraphNode* node) : ShowNode(node) {}
  ~ScopeNode() override {}

  std::vector<ScopeNode*> children;
  std::vector<ScopeNode*> show_children;
};

class ShowMultiNode {
 public:
  explicit ShowMultiNode(TFMultiGraphNode* node);
  virtual ~ShowMultiNode() {}

  bool ReInit(int64 step, const std::vector<string>& type_regexes);

  const string& name() const { return node->name(); }
  TFMultiGraphNodeProto* mutable_proto();
  const TFMultiGraphNodeProto& proto() const;

  void AggregateTotalStats(ShowMultiNode* node);

  void AddSelfToTotalStats();

  void ResetTotalStats();

  TFMultiGraphNode* node;
  bool account;
  bool show;
  string formatted_str;

 protected:
  TFMultiGraphNodeProto proto_;
};

class CodeNode : public ShowMultiNode {
 public:
  explicit CodeNode(TFMultiGraphNode* node) : ShowMultiNode(node) {}
  ~CodeNode() override {}

  std::vector<CodeNode*> children;
  std::vector<CodeNode*> show_children;
};

class OpNode : public ShowMultiNode {
 public:
  explicit OpNode(TFMultiGraphNode* node) : ShowMultiNode(node) {}
  ~OpNode() override {}
};

}  // namespace tfprof
}  // namespace tensorflow

#endif  // THIRD_PARTY_TENSORFLOW_TOOLS_TFPROF_INTERNAL_TFPROF_NODE_SHOW_H_


text:
import assert from 'assert/strict';

import Audit from '../../../audits/accessibility/aria-required-children.js';

describe('Accessibility: aria-required-children audit', () => {
  it('generates an audit output', () => {
    const artifacts = {
      Accessibility: {
        violations: [{
          id: 'aria-required-children',
          nodes: [],
          help: 'http://example.com/',
        }],
      },
    };

    const output = Audit.audit(artifacts);
    assert.equal(output.score, 0);
  });

  it('generates an audit output (single node)', () => {
    const artifacts = {
      Accessibility: {
        violations: [{
          id: 'aria-required-children',
          nodes: [{node: {}, relatedNodes: []}],
          help: 'http://example.com/',
        }],
      },
    };

    const output = Audit.audit(artifacts);
    assert.equal(output.score, 0);
  });
});


text:
EGWuint egwParseStringi8cv(const EGWchar* string_in, EGWint8* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringi8cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWint8)atoi((const char*)value);
            array_out = (EGWint8*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWint8) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringi16cv(const EGWchar* string_in, EGWint16* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringi16cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWint16)atoi((const char*)value);
            array_out = (EGWint16*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWint16) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringi32cv(const EGWchar* string_in, EGWint32* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringi32cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWint32)atol((const char*)value);
            array_out = (EGWint32*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWint32) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringi64cv(const EGWchar* string_in, EGWint64* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringi64cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWint64)atoll((const char*)value);
            array_out = (EGWint64*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWint64) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringui8cv(const EGWchar* string_in, EGWuint8* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringui8cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWuint8)atoi((const char*)value);
            array_out = (EGWuint8*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWuint8) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringui16cv(const EGWchar* string_in, EGWuint16* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringui16cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWuint16)atoi((const char*)value);
            array_out = (EGWuint16*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWuint16) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringui32cv(const EGWchar* string_in, EGWuint32* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringui32cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWuint32)atoll((const char*)value);
            array_out = (EGWuint32*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWuint32) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringui64cv(const EGWchar* string_in, EGWuint64* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringui64cv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWuint64)atoll((const char*)value);
            array_out = (EGWuint64*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWuint64) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringicv(const EGWchar* string_in, EGWint* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringicv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWint)atol((const char*)value);
            array_out = (EGWint*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWint) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringuicv(const EGWchar* string_in, EGWuint* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringuicv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWuint)atol((const char*)value);
            array_out = (EGWuint*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWuint) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringfcv(const EGWchar* string_in, EGWsingle* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringfcv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWsingle)atof((const char*)value);
            array_out = (EGWsingle*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWsingle) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringdcv(const EGWchar* string_in, EGWdouble* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringdcv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWdouble)atof((const char*)value);
            array_out = (EGWdouble*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWdouble) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWuint egwParseStringtcv(const EGWchar* string_in, EGWtriple* array_out, EGWintptr strideB_out, EGWuint count) {
    const EGWchar* start = NULL;
    const EGWchar* end = NULL;
    EGWchar* value = NULL;
    EGWuint valueSize = 0;
    EGWuint processed = 0;

    while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
    if(*string_in == '\0') return processed;
    else start = end = string_in;

    while(processed < count) {
        if(!(*string_in <= ' ' || *string_in == ',' || *string_in == '\0'))
            end = ++string_in;
        else {
            if(valueSize < ((EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1)) {
                if(value) { free((void*)value); value = NULL; valueSize = 0; }
                valueSize = (EGWuint)((EGWuintptr)end - (EGWuintptr)start) + 1; valueSize = valueSize + (valueSize >> 1); // x1.5
                if(!(value = (EGWchar*)malloc((size_t)valueSize))) {
                    NSLog(@"egwParseStringtcv: Failure allocating memory for temporary storage.");
                    return processed;
                }
            }

            strncpy((char*)value, (const char*)start, (size_t)((EGWuintptr)end - (EGWuintptr)start)); value[(EGWuint)((EGWuintptr)end - (EGWuintptr)start)] = '\0';

            *array_out = (EGWtriple)atof((const char*)value);
            array_out = (EGWtriple*)((EGWintptr)array_out + (EGWintptr)sizeof(EGWtriple) + strideB_out);

            ++processed;
            while((*string_in <= ' ' || *string_in == ',') && *string_in != '\0') ++string_in;
            if(*string_in == '\0') break;
            else start = end = string_in;
        }
    }

    if(value) { free((void*)value); value = NULL; valueSize = 0; }

    return processed;
}

EGWchar* egwTrimc(EGWchar* string_in) {
    EGWchar* end = string_in;

    while(*end != '\0') ++end;
    if(end > string_in) {
        while(end >= string_in && *end <= ' ') --end;
        *(++end) = '\0';
        while(*string_in != '\0' && *string_in <= ' ') ++string_in;
    }

    return string_in;
}

EGWchar* egwQTrimc(EGWchar* string_in, EGWint lengthC_in) {
    EGWchar* end = string_in;

    if(lengthC_in < 0)
        while(*end != '\0') ++end;
    else
        end = (EGWchar*)((EGWuintptr)string_in + ((EGWuintptr)lengthC_in * (EGWuintptr)sizeof(EGWchar)));

    if(end > string_in) {
        while(end >= string_in && *end <= ' ') --end;
        *(++end) = '\0';
        while(*string_in != '\0' && *string_in <= ' ') ++string_in;
    }

    return string_in;
}

EGWuint32 egwHash32b(const EGWbyte* data_in, EGWuint lengthB_in) {
    EGWuint32 hashVal = 5381;

    while(lengthB_in--) {
        hashVal = ((hashVal << 5) + hashVal) + (const EGWuint)*data_in++;
    }

    return (hashVal ? hashVal : 1);
}

EGWuint32 egwHash32c(const EGWchar* string_in) {
    EGWuint32 hashVal = 5381;

    while(*string_in != '\0') {
        hashVal = ((hashVal << 5) + hashVal) + (const EGWuint)*string_in++;
    }

    return (hashVal ? hashVal : 1);
}

EGWuint32 egwHashAdd32(EGWuint32 hash_lhs, EGWuint32 hash_rhs) {
    hash_lhs = ((hash_lhs << 5) + hash_lhs) + hash_rhs;

    return (hash_lhs ? hash_lhs : 1);
}

EGWuint64 egwHash64b(const EGWbyte* data_in, EGWuint lengthB_in) {
    EGWuint64 hashVal = 5381;

    while(lengthB_in--) {
        hashVal = ((hashVal << 5) + hashVal) + (const EGWuint)*data_in++;
    }

    return (hashVal ? hashVal : 1);
}

EGWuint64 egwHash64c(const EGWchar* string_in) {
    EGWuint64 hashVal = 5381;

    while(*string_in != '\0') {
        hashVal = ((hashVal << 5) + hashVal) + (const EGWuint)*string_in++;
    }

    return (hashVal ? hashVal : 1);
}

EGWuint64 egwHashAdd64(EGWuint64 hash_lhs, EGWuint64 hash_rhs) {
    hash_lhs = ((hash_lhs << 5) + hash_lhs) + hash_rhs;

    return (hash_lhs ? hash_lhs : 1);
}

void egwEndianSwapb(const EGWbyte* val_in, EGWbyte* val_out, EGWuint sizeB) {
    register const EGWbyte* valEnd_in = (const EGWbyte*)((EGWuintptr)val_in + (EGWuintptr)sizeB - (EGWuintptr)sizeof(EGWbyte));
    register EGWbyte* valEnd_out = (EGWbyte*)((EGWuintptr)val_out + (EGWuintptr)sizeB - (EGWuintptr)sizeof(EGWbyte));
    register EGWbyte temp;

    while((sizeB /= 2)) {
        temp = *valEnd_in;
        *valEnd_out = *val_in;
        *val_out = temp;

        val_in = (const EGWbyte*)((EGWuintptr)val_in + (EGWuintptr)sizeof(EGWbyte));
        valEnd_in = (const EGWbyte*)((EGWuintptr)valEnd_in - (EGWuintptr)sizeof(EGWbyte));
        val_out = (EGWbyte*)((EGWuintptr)val_out + (EGWuintptr)sizeof(EGWbyte));
        valEnd_out = (EGWbyte*)((EGWuintptr)valEnd_out - (EGWuintptr)sizeof(EGWbyte));
    }
}

void egwEndianSwapbv(const EGWbyte* vals_in, EGWbyte* vals_out, EGWuint sizeB, EGWintptr strideB_in, EGWintptr strideB_out, EGWuint count) {
    while(count--) {
        register const EGWbyte* valsEnd_in = (const EGWbyte*)((EGWuintptr)vals_in + (EGWuintptr)sizeB - (EGWuintptr)sizeof(EGWbyte));
        register EGWbyte* valsEnd_out = (EGWbyte*)((EGWuintptr)vals_out + (EGWuintptr)sizeB - (EGWuintptr)sizeof(EGWbyte));
        register EGWbyte temp;

        register EGWuint sizeB_count = sizeB;
        while((sizeB_count /= 2)) {
            temp = *valsEnd_in;
            *valsEnd_out = *vals_in;
            *vals_out = temp;

            vals_in = (const EGWbyte*)((EGWuintptr)vals_in + (EGWuintptr)sizeof(EGWbyte));
            valsEnd_in = (const EGWbyte*)((EGWuintptr)valsEnd_in - (EGWuintptr)sizeof(EGWbyte));
            vals_out = (EGWbyte*)((EGWuintptr)vals_out + (EGWuintptr)sizeof(EGWbyte));
            valsEnd_out = (EGWbyte*)((EGWuintptr)valsEnd_out - (EGWuintptr)sizeof(EGWbyte));
        }

        vals_in = (const EGWbyte*)((EGWintptr)vals_in + (EGWintptr)(sizeB & 1) + (EGWintptr)(sizeB >> 1) + strideB_in);
        vals_out = (EGWbyte*)((EGWintptr)vals_out + (EGWintptr)(sizeB & 1) + (EGWintptr)(sizeB >> 1) + strideB_in);
    }
}


text:
/*
 * MotorDC.h
 *
 *  Created on: Jan 6, 2016
 *      Author: frederic.ouellet
 */

#ifndef MOTORDC_H_
#define MOTORDC_H_

#include "Arduino.h"
#include "Device.h"

class MotorDC : public Device
{
public:
	enum EDirection
	{
		STOPPED, CLOCKWISE, COUNTER_CLOCKWISE
	};
public:
	MotorDC(int pinCW, int pinCCW, int pinSpeed = -1) :
					m_pinCW(pinCW),
					m_pinCCW(pinCCW),
					m_pinSpeed(pinSpeed)
	{
	}

	virtual ~MotorDC()
	{
	}

	virtual void setup()
	{
		pinMode(m_pinCW, OUTPUT);
		pinMode(m_pinCCW, OUTPUT);

		if (m_pinSpeed >= 0)
			pinMode(m_pinSpeed, OUTPUT);

		write(STOPPED, 0);
	}

	void setSpeed(byte speed)
	{
		if (m_pinSpeed >= 0)
			analogWrite(m_pinSpeed, speed);
	}

	void write(EDirection direction, byte speed)
	{
		switch (direction)
		{
		default:
		case STOPPED:
			digitalWrite(m_pinCW, false);
			digitalWrite(m_pinCCW, false);
			break;
		case CLOCKWISE:
			digitalWrite(m_pinCCW, false);
			digitalWrite(m_pinCW, true);
			break;
		case COUNTER_CLOCKWISE:
			digitalWrite(m_pinCW, false);
			digitalWrite(m_pinCCW, true);
			break;
		}

		if (m_pinSpeed >= 0)
			analogWrite(m_pinSpeed, speed);
	}

private:
	int m_pinCW;
	int m_pinCCW;
	int m_pinSpeed;
};

#endif /* MOTORDC_H_ */


text:
<TITLE>Review for Dudley Do-Right (1999)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Dudley Do-Right (1999)

reviewed by
Mark O'Hara

Dudley Do-Right (1999)

A Film Review by Mark O'Hara

Visit Online Film Critics Society at http://www.ofcs.org

It's difficult to name more than a few successful live-action adaptations of
cartoons.

Try it.  If you said "The Flintstones" or "Dick Tracy," try again.  They may
have brought in the change at the box office, but they are not good movies.
Don't even think about "Mr. Magoo" or "Dennis the Menace."

Hugh Wilson's "Dudley Do-Right" belongs on the long-list of mediocre film
fare, a mostly failed and random collection of hopeful plot turns and
clichés.  Because of the premise, which is the inane exploits of Jay Ward's
dull-witted Canadian Mountie, the story is lightly entertaining.  And in a
few places we get to belly laugh at twists that have finally gone over the
top.

The lonesome mounted policeman (Brendan Fraser) is sure his love, Nell
Fenwick, will never return.  So Dudley busies himself with his duties.  One
night he spots his childhood companion and nemesis, Snidely Whiplash (Alfred
Molina).  Snidely is "salting" rocks with gold dust loaded into shotgun
shells.  Why?  Well, because he wants to create a fake gold rush to this
part of northern Canada, of course.

Meanwhile, Nell (Sarah Jessica Parker) has returned with her multiple
graduate degrees.  It seems she and Dudley will resume their relationship,
until Snidely captures her attention.  This seems all wrong, of course;  as
a watcher of the original in my childhood, I was expecting Snidely to be
nothing but the bad guy - a sentiment Snidely himself mentions several times
in self-reflexive asides.  (I also wanted Nell to kiss Horse, Dudley's
mount, but no luck!)  What's more odd is that Hugh Wilson shows us an
opening sequence in which the three main characters assume their roles in
childhood, Snidely as a boy wearing a black cape and stovepipe hat, already
sniping at Dudley for Nell's affections.

It turns out that Snidely is successful in his quest for  prospectors:
Semi-Happy Valley is flooded with their money, and in a wink at marketing
savvy, we see all types of merchandise with Snidely's image --  a self-hype
that dives to the depths of money-grubbing.  What will stop Snidely's taking
over the town  -- which is redubbed "Whiplash City"?  Certainly not Dudley,
as he has been drummed out of the service by his idol, Inspector Fenwick
(Robert Prosky).  We really have no idea why Dudley loses his job, except
that Snidely has connections in Ottawa, and the Inspector never had much use
for the square-jawed boob anyway.

Enter Eric Idle as a grimy prospector, only slightly removed from a grungy
Gumby character on "Monty Python."  Kim Darling prospects for gold and finds
a sizable nugget planted by Snidely.  Although he is catapulted into the
front of the news about the gold discoveries, Darling serves as a sort of
goofy mentor to Dudley, training him in the proper ways to fight Snidely's
brand of evil.  What is original here is that Dudley attempts to be good by
being bad - namely, by stealing gold from the thieves employed by Snidely!
Will our hero prevail in his circuitous search for good?

The acting in "Dudley Do-Right" is superior to the plot.  Brendan Fraser is
passable as the title character, but he was better in Jay Ward's "George of
the Jungle."  This actor is good at looking surprised and duped, another
feat he pulled off rather well in Wilson's "Blast From the Past."  (I would
add that his role in "The Mummy" this past May did not particularly
distinguish him as an action hero; he was much better as the gardener
tempted by the fictionalized version of director James Whale in "Gods and
Monsters.")  Although Fraser's hair should have been died to resemble the
cartoon character's frizzy locks, he turns in a passing performance.

Underused is a good word to describe the roles of a few other characters.
First, Robert Prosky is an old pro who is woefully absent from the film.  He
appears but briefly and speaks in a British accent, his white mustache
obscuring the British curve of his lips.  What a missed opportunity, having
such a veteran actor on the set and using him merely as decoration!

Sarah Jessica Parker's part is also underwritten.  She could appear in more
scenes, although she does a fine job in the ones that made the final cut.

Eric Idle is the one indispensable presence here.  He knows instinctively
just how much exaggeration to give a comic support role.  His Kim Darling is
a hilarious blend of silliness and incongruity, especially at the end when
he meets a sublime fate.

Some of the more pleasurable moments of viewing involve the actual cartoon
short "The Phox, the Box, and the Lox."  It's a fractured fairy tale, a lot
like the olds ones narrated by the ivory-voiced Edward Everett Horton.  The
tale of a wise-cracking, greedy fox and his quest for treasure, the story
shows some of the same twisted moralizing as its 1960's precursors - except
that the originals were more comically arch.

On the whole, it would be better to rent "Dudley Do-Right," except if no
better offerings were available on the weekend for the kiddies.  The
self-aware jokes - that trademark of Jay Ward's post-modern sense of humor -
are present to a small degree, and the ending is much more promising than
what leads to it.  Now, let's hope that Ward's main success, the ingenious
'The Adventures of Rocky and Bullwinkle," falls into the hands of a more
wildly creative producer.

Get Your Private, Free Email at http://www.hotmail.com

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
#include "ioutils.h"

#include <QtCore/QDir>
#include <QtCore/QFile>

#ifdef Q_OS_WIN
#  include <windows.h>
#else
#  include <sys/types.h>
#  include <sys/stat.h>
#  include <unistd.h>
#endif

using namespace ProFileEvaluatorInternal;

IoUtils::FileType IoUtils::fileType(const QString &fileName)
{
    Q_ASSERT(fileName.isEmpty() || isAbsolutePath(fileName));
#ifdef Q_OS_WIN
    DWORD attr = GetFileAttributesW((WCHAR*)fileName.utf16());
    if (attr == INVALID_FILE_ATTRIBUTES)
        return FileNotFound;
    return (attr & FILE_ATTRIBUTE_DIRECTORY) ? FileIsDir : FileIsRegular;
#else
    struct ::stat st;
    if (::stat(fileName.toLocal8Bit().constData(), &st))
        return FileNotFound;
    return S_ISDIR(st.st_mode) ? FileIsDir : FileIsRegular;
#endif
}

bool IoUtils::isRelativePath(const QString &path)
{
    if (path.startsWith(QLatin1Char('/')))
        return false;
#ifdef Q_OS_WIN
    if (path.startsWith(QLatin1Char('\\')))
        return false;
    // Unlike QFileInfo, this won't accept a relative path with a drive letter.
    // Such paths result in a royal mess anyway ...
    if (path.length() >= 3 && path.at(1) == QLatin1Char(':') && path.at(0).isLetter()
        && (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\')))
        return false;
#endif
    return true;
}

QStringRef IoUtils::fileName(const QString &fileName)
{
    return fileName.midRef(fileName.lastIndexOf(QLatin1Char('/')) + 1);
}

QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName)
{
    if (fileName.isEmpty())
        return QString();
    if (isAbsolutePath(fileName))
        return QDir::cleanPath(fileName);
    return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);
}

#ifdef QT_BOOTSTRAPPED
inline static bool isSpecialChar(ushort c)
{
    // Chars that should be quoted (TM). This includes:
#ifdef Q_OS_WIN
    // - control chars & space
    // - the shell meta chars "&()<>^|
    // - the potential separators ,;=
    static const uchar iqm[] = {
        0xff, 0xff, 0xff, 0xff, 0x45, 0x13, 0x00, 0x78,
        0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10
    };
#else
    static const uchar iqm[] = {
        0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8,
        0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78
    }; // 0-32 \'"$`<>|;&(){}*?#!~[]
#endif

    return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)));
}

inline static bool hasSpecialChars(const QString &arg)
{
    for (int x = arg.length() - 1; x >= 0; --x)
        if (isSpecialChar(arg.unicode()[x].unicode()))
            return true;
    return false;
}

QString IoUtils::shellQuote(const QString &arg)
{
    if (!arg.length())
        return QString::fromLatin1("\"\"");

    QString ret(arg);
    if (hasSpecialChars(ret)) {
#ifdef Q_OS_WIN
        // Quotes are escaped and their preceding backslashes are doubled.
        // It's impossible to escape anything inside a quoted string on cmd
        // level, so the outer quoting must be "suspended".
        ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\"\\1\\1\\^\"\""));
        // The argument must not end with a \ since this would be interpreted
        // as escaping the quote -- rather put the \ behind the quote: e.g.
        // rather use "foo"\ than "foo\"
        int i = ret.length();
        while (i > 0 && ret.at(i - 1) == QLatin1Char('\\'))
            --i;
        ret.insert(i, QLatin1Char('"'));
        ret.prepend(QLatin1Char('"'));
#else // Q_OS_WIN
        ret.replace(QLatin1Char('\''), QLatin1String("'\\''"));
        ret.prepend(QLatin1Char('\''));
        ret.append(QLatin1Char('\''));
#endif // Q_OS_WIN
    }
    return ret;
}
#endif


text:
<?php
namespace PayPal;

use PayPal\Core\PPMessage;

class RequestEnvelope extends PPMessage {

	/**
	 * This specifies the required detail level that is needed by a
	 * client application pertaining to a particular data component
	 * (e.g., Item, Transaction, etc.). The detail level is
	 * specified in the DetailLevelCodeType which has all the
	 * enumerated values of the detail level for each component.
	 * @access public

	 * @var string
	 */
	public $detailLevel;

	/**
	 * This should be the standard RFC 3066 language identification
	 * tag, e.g., en_US.
	 * @access public

	 * @var string
	 */
	public $errorLanguage;

	/**
	 * Constructor with arguments
	 */
	public function __construct($errorLanguage = NULL) {
		$this->errorLanguage = $errorLanguage;
	}

}


text:
class CreateBills < ActiveRecord::Migration
  def change
    create_table :bills do |t|
      t.timestamps null: false
    end
  end
end