Add some extra features arround the C++ readCard
method... such as ATR <-> card type recognition etc...
@recursive
@return none
355156
function readCard() {
	pcsc.scardRead( function(evt) {
		if ( evt ) {
			// Compute some more informations over it
			evt.reader.type = getType(evt.reader.name);

			if ( evt.card && evt.card.ATR ) {
				var item = getItem(evt.card.ATR);
				if (item && item.name) evt.card.name = item.name;
				// if (item && item.info) evt.card.info = item.info;
			}

			// IPC communication emit message
			evt.name = 'readerStateChange';
			process.send(evt);
		}
	});
}
1205191
private void addNthLastOfType() {
        for (Node node : nodes) {
            int count = 1;
            Node n = DOMHelper.getNextSiblingElement(node);
            while (n != null) {
                if (DOMHelper.getNodeName(n).equals(DOMHelper.getNodeName(node))) {
                    count++;
                }
                
                n = DOMHelper.getNextSiblingElement(n);
            }
            
            if (specifier.isMatch(count)) {
                result.add(node);
            }
        }
    }
340766
protected function init()
    {
        // build the local matrix just once
        if (empty($this->errorCodeMatrix)) {
            // get type and order from Doozr_Form_Service_Validate so we don't need to define it manually again
            $typeMatrix = Doozr_Form_Service_Validator_Generic::getValidationTypeMatrix();

            // iterate over types and construct error-code-matrix of it
            foreach ($typeMatrix as $type => $order) {
                $this->errorCodeMatrix[$type] = ($order + 1);
            }
        }

        return $this;
    }
289703
private void addLastOfType() {
		for (Node node : nodes) {
			Index index = helper.getIndexInParent(node, true);
			if (index.index == (index.size-1))
				result.add(node);
		}
	}
545358
protected function addAndroid()
    {
        $this->root->
            children()->
                arrayNode("android")->
                    canBeUnset()->
                    children()->

                        scalarNode("timeout")->defaultValue(5)->end()->

                        // WARNING: These 3 fields as they are, outside of the c2dm array
                        // are deprecrated in favour of using the c2dm array configuration
                        // At present these will be overriden by anything supplied
                        // in the c2dm array
                        scalarNode("username")->defaultValue("")->end()->
                        scalarNode("password")->defaultValue("")->end()->
                        scalarNode("source")->defaultValue("")->end()->

                        arrayNode("c2dm")->
                            canBeUnset()->
                            children()->
                                scalarNode("username")->isRequired()->end()->
                                scalarNode("password")->isRequired()->end()->
                                scalarNode("source")->defaultValue("")->end()->
                            end()->
                        end()->
                        arrayNode("gcm")->
                            canBeUnset()->
                            children()->
                                scalarNode("api_key")->isRequired()->cannotBeEmpty()->end()->
                                booleanNode("use_multi_curl")->defaultValue(true)->end()->
                                booleanNode("dry_run")->defaultFalse()->end()->
                            end()->
                        end()->
                    end()->
                end()->
            end()
        ;
    }
240905
public MethodInfo addDefaultConstructor() {
        MethodInfo mi = addConstructor(Modifiers.PUBLIC, null);
        CodeBuilder builder = new CodeBuilder(mi);
        builder.loadThis();
        builder.invokeSuperConstructor(null);
        builder.returnVoid();
        return mi;
    }
38247
public function addType($type)
    {
        if (is_string($type)) {
            $type = array($type);
        }

        foreach($type as $typ) {
            if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->_type)) {
                $this->_type[] = $typ;
            }

            if (($typ == self::ALL)) {
                $this->_type = array_keys($this->_cardLength);
            }
        }

        return $this;
    }
129889
public function toOptionArray() {
        return [
            [
                'value' => self::CARD_VISA,
                'label' => __('Visa')
            ],
            [
                'value' => self::CARD_MASTERCARD,
                'label' => __('Mastercard')
            ],
            [
                'value' => self::CARD_AMEX,
                'label' => __('American Express')
            ],
            [
                'value' => self::CARD_JCB,
                'label' => __('JCB')
            ],
            [
                'value' => self::CARD_DISCOVER,
                'label' => __('Discover')
            ],
        ];
    }
120254
public function getAvailableCardTypes() {
        $ccTypes = $this->getValue(
            self::KEY_CC_TYPES,
            $this->storeManager->getStore()
        );

        return ! empty($ccTypes) ? explode(',', $ccTypes) : [];
    }
14712
private void addFirstOfType() {
		for (Node node : nodes) {
			Index index = helper.getIndexInParent(node, true);
			if (index.index == 0)
				result.add(node);
		}
	}
542449
protected function readValue()
    {
        if ($this->newLine()) {
            $this->addValueToDirective();
        } elseif ($this->sharp()) {
            $this->current_word = mb_substr($this->current_word, 0, -1);
            $this->addValueToDirective();
        } else {
            $this->increment();
        }
        return $this;
    }
341363
private function _readDgContainer()
	{
		$length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
		$recordData = substr($this->_data, $this->_pos + 8, $length);

		// move stream pointer to next record
		$this->_pos += 8 + $length;

		// record is a container, read contents
		$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
		$this->_object->setDgContainer($dgContainer);
		$reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
		$escher = $reader->load($recordData);
	}
755353
public function addExtraIndices()
    {
        /**
         * A collection of indexed columns. The keys is the column name
         * (concatenated with a comma in the case of multi-col index), the value is
         * an array with the names of the indexes that index these columns. We use
         * it to determine which additional indexes must be created for foreign
         * keys. It could also be used to detect duplicate indexes, but this is not
         * implemented yet.
         * @var array
         */
        $_indices = [];

        $this->collectIndexedColumns('PRIMARY', $this->getPrimaryKey(), $_indices);

        $_tableIndices = array_merge($this->getIndices(), $this->getUnices());
        foreach ($_tableIndices as $_index) {
            $this->collectIndexedColumns($_index->getName(), $_index->getColumns(), $_indices);
        }

        // we're determining which tables have foreign keys that point to this table,
        // since MySQL needs an index on any column that is referenced by another table
        // (yep, MySQL _is_ a PITA)
        $counter = 0;
        foreach ($this->referrers as $foreignKey) {
            $referencedColumns = $foreignKey->getForeignColumnObjects();
            $referencedColumnsHash = $this->getColumnList($referencedColumns);
            if (empty($referencedColumns) || isset($_indices[$referencedColumnsHash])) {
                continue;
            }

            // no matching index defined in the schema, so we have to create one
            $name = sprintf('i_referenced_%s_%s', $foreignKey->getName(), ++$counter);
            if ($this->hasIndex($name)) {
                // if we have already a index with this name, then it looks like the columns of this index have just
                // been changed, so remove it and inject it again. This is the case if a referenced table is handled
                // later than the referencing table.
                $this->removeIndex($name);
            }

            $index = $this->createIndex($name, $referencedColumns);
            // Add this new index to our collection, otherwise we might add it again (bug #725)
            $this->collectIndexedColumns($index->getName(), $referencedColumns, $_indices);
        }

        // we're adding indices for this table foreign keys
        foreach ($this->foreignKeys as $foreignKey) {
            $localColumns = $foreignKey->getLocalColumnObjects();
            $localColumnsHash = $this->getColumnList($localColumns);
            if (empty($localColumns) || isset($_indices[$localColumnsHash])) {
                continue;
            }

            // No matching index defined in the schema, so we have to create one.
            // MySQL needs indices on any columns that serve as foreign keys.
            // These are not auto-created prior to 4.1.2.

            $name = substr_replace($foreignKey->getName(), 'fi_',  strrpos($foreignKey->getName(), 'fk_'), 3);
            if ($this->hasIndex($name)) {
                // if we already have an index with this name, then it looks like the columns of this index have just
                // been changed, so remove it and inject it again. This is the case if a referenced table is handled
                // later than the referencing table.
                $this->removeIndex($name);
            }

            $index = $this->createIndex($name, $localColumns);
            $this->collectIndexedColumns($index->getName(), $localColumns, $_indices);
        }
    }
91531
final protected function cards() {
		$r = []; /** @var array(string => string) $r */
		$m = $this->m(); /** @var Method $m */
		/**
		 * 2017-07-28
		 * The `$m instanceof Method` check is for the «Square» module:
		 * its server part does not use the Df_StripeClone module, but the client part does use it.
		 * So we need this the `$m instanceof Method` check to evade the error:
		 * «Cannot instantiate abstract class Df\StripeClone\Facade\Customer
		 * in mage2pro/core/Payment/Facade.php:88»: https://github.com/mage2pro/square/issues/2
		 * 
		 * 2018-11-13
		 * Currently, in all modules except one (TBCBank) $customerData is just a customer identifier (a string).
		 * But out framework supports $customerData of artibutrary structure, and the TBCBank module uses it:
		 * $data has the following structure there:
		 *	{
		 *		"4349958401": {
		 *			"CARD_NUMBER": "5***********1223",
		 *			"RECC_PMNT_EXPIRY": "1019"
		 *		},
		 *		"1779958449": {
		 *			"CARD_NUMBER": "4***********3333",
		 *			"RECC_PMNT_EXPIRY": "1120"
		 *		}
		 *	}
		 * The top-level keys are bank card tokens there, 
		 * and their values form the corresponding bank card labels.
		 * So the TBCBank module (unlike the rest modules) does not do any API requests
		 * to retrieve a customer's saved cards.
		 */
		/** @var string|null|array(string => mixed) $customerData */
		if ($m instanceof Method && ($customerData = df_ci_get($this->m()))) {
			$this->s()->init();
			$fc = FCustomer::s($m); /** @var FCustomer $fc */
			// 2018-11-14 $customer is an array for TBCBank: it is the same as $customerData (see above).
			if (!($customer = $fc->get($customerData))/** @var object|array(string => mixed) $customer */) {
				// 2017-02-24
				// We could be here, for example, if the store's administrator has changed
				// his Stripe account in the module's settings: https://mage2.pro/t/3337
				df_ci_save($this->m(), null);
			}
			else {
				$r = array_map(function(Card $c) use($m) {
					/**
					 * 2017-07-24
					 * Unfortunately, the one-liner fails on PHP 5.6.30:
					 * return ['id' => $c->id(), 'label' => (CF::s($m, $c))->label()];
					 * «syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ']'»
					 * https://github.com/mage2pro/core/issues/16
					 * See also: https://github.com/mage2pro/core/issues/15
					 *
					 * 2017-07-31
					 * Interestingly, the following code works on all PHP versions >= 5.4.0:
					 * class A {function f() {return __METHOD__;}
					 * echo (new A)->f();
					 * https://3v4l.org/nANqg
					 *
					 * The following code works on all PHP versions >= 5.0.0:
					 *	class A {
					 *		function f() {return __METHOD__;}
					 *		static function s() {return new self;}
					 *	}
					 *	echo A::s()->f();
					 * https://3v4l.org/1qr48
					 *
					 * The same is true for the following code:
					 *	class A {
					 *		function f() {return $this->_v;}
					 *		final protected function __construct($v) {$this->_v = $v;}
					 *		private $_v;
					 *		final static function s($v) {return new self($v);}
					 *	}
					 *	echo A::s('test')->f();
					 * https://3v4l.org/2E8H6
					 *
					 * So, I was unable to reproduce the issue...
					 * Maybe the problem customer uses a non-standard (patched) PHP version?
					 *
					 * 2017-11-08
					 * Note 1.
					 * One-liners like (!($e = $a->e())->b()) are really not supported by PHP < 7:
					 * https://3v4l.org/lJjvS
					 * Note 2.
					 * At the same time, some `))->` one-liners are supported by PHP >= 5.4, e.g:
					 * static function p() {return (new self())->b();}
					 * https://3v4l.org/LJlDE
					 * Note 3.
					 * If we add extra brackets to the code from the Note 2,
					 * then the code will be incompatible with PHP < 7:
					 * static function p() {return ((new self()))->b();}
					 */
					$cf = CF::s($m, $c); /** @var CF $cf */
					return ['id' => $c->id(), 'label' => $cf->label()];
				}, $fc->cardsActive($customer));
			}
		}
		// 2018-11-14
		// It is important, because otherwise this.cards.length will return `undefined` on frontend:
		// https://github.com/mage2pro/core/blob/3.11.1/Payment/view/frontend/web/card.js#L207
		return array_values($r);
	}
439114
private function initialize()
    {
        $this->undefinedCardResolution = isset($this->config['options']['undefined_card'])
            ? static::translateUndefinedCardResolution($this->config['options']['undefined_card'])
            : UndefinedCardResolution::DEFAULT_CARD;

        if (isset($this->config['options']['delimiter'])) {
            $this->delimiter = $this->config['options']['delimiter'];
        }

        foreach ($this->config['slots'] as $slotName => &$slotData) {
            $slotData['name'] = $slotName;

            if (is_string($slotData['reel'])) {
                $slotData['reel'] = $this->config['reels'][$slotData['reel']];
            }

            if (!isset($slotData['nested'])) {
                $slotData['nested'] = array();
            }

            $slotData['undefined_card'] = (!isset($slotData['undefined_card']))
                ? $this->undefinedCardResolution
                : static::translateUndefinedCardResolution($slotData['undefined_card']);

            $this->offsetSet($slotName, function () use ($slotData) {
                return new Slot($slotData);
            });
        }
    }
1214097
@Nullable
    public Card getCard() {
        if (validateAllFields()) {
            String cardNumber = mCardNumberEditText.getCardNumber();
            int[] cardDate = mExpiryDateEditText.getValidDateFields();
            String cvcValue = mCvcEditText.getText().toString();

            Card card = new Card(cardNumber, cardDate[0], cardDate[1], cvcValue);
            if (mShouldShowPostalCode) {
                card.setAddressZip(mPostalCodeEditText.getText().toString());
            }
            return card.addLoggingToken(CARD_MULTILINE_TOKEN);
        }

        return null;
    }
827552
public boolean add() {
        if (root == NIL) {
            root = nodeAllocator.newNode();
            copy(root);
            fixAggregates(root);
            return true;
        } else {
            int node = root; assert parent(root) == NIL;
            int parent;
            int cmp;
            do {
                cmp = compare(node);
                if (cmp < 0) {
                    parent = node;
                    node = left(node);
                } else if (cmp > 0) {
                    parent = node;
                    node = right(node);
                } else {
                    merge(node);
                    return false;
                }
            } while (node != NIL);

            node = nodeAllocator.newNode();
            if (node >= capacity()) {
                resize(oversize(node + 1));
            }
            copy(node);
            parent(node, parent);
            if (cmp < 0) {
                left(parent, node);
            } else {
                assert cmp > 0;
                right(parent, node);
            }

            rebalance(node);

            return true;
        }
    }