text stringlengths 2 99k | meta dict |
|---|---|
/* $Date: 2005/03/07 23:59:05 $ $RCSfile: fpga_defs.h,v $ $Revision: 1.4 $ */
/*
* FPGA specific definitions
*/
#ifndef __CHELSIO_FPGA_DEFS_H__
#define __CHELSIO_FPGA_DEFS_H__
#define FPGA_PCIX_ADDR_VERSION 0xA08
#define FPGA_PCIX_ADDR_STAT 0xA0C
/* FPGA master interrupt Cause/Enable bits */
#define FPGA_PCIX_INTERRUPT_SGE_ERROR 0x1
#define FPGA_PCIX_INTERRUPT_SGE_DATA 0x2
#define FPGA_PCIX_INTERRUPT_TP 0x4
#define FPGA_PCIX_INTERRUPT_MC3 0x8
#define FPGA_PCIX_INTERRUPT_GMAC 0x10
#define FPGA_PCIX_INTERRUPT_PCIX 0x20
/* TP interrupt register addresses */
#define FPGA_TP_ADDR_INTERRUPT_ENABLE 0xA10
#define FPGA_TP_ADDR_INTERRUPT_CAUSE 0xA14
#define FPGA_TP_ADDR_VERSION 0xA18
/* TP interrupt Cause/Enable bits */
#define FPGA_TP_INTERRUPT_MC4 0x1
#define FPGA_TP_INTERRUPT_MC5 0x2
/*
* PM interrupt register addresses
*/
#define FPGA_MC3_REG_INTRENABLE 0xA20
#define FPGA_MC3_REG_INTRCAUSE 0xA24
#define FPGA_MC3_REG_VERSION 0xA28
/*
* GMAC interrupt register addresses
*/
#define FPGA_GMAC_ADDR_INTERRUPT_ENABLE 0xA30
#define FPGA_GMAC_ADDR_INTERRUPT_CAUSE 0xA34
#define FPGA_GMAC_ADDR_VERSION 0xA38
/* GMAC Cause/Enable bits */
#define FPGA_GMAC_INTERRUPT_PORT0 0x1
#define FPGA_GMAC_INTERRUPT_PORT1 0x2
#define FPGA_GMAC_INTERRUPT_PORT2 0x4
#define FPGA_GMAC_INTERRUPT_PORT3 0x8
/* MI0 registers */
#define A_MI0_CLK 0xb00
#define S_MI0_CLK_DIV 0
#define M_MI0_CLK_DIV 0xff
#define V_MI0_CLK_DIV(x) ((x) << S_MI0_CLK_DIV)
#define G_MI0_CLK_DIV(x) (((x) >> S_MI0_CLK_DIV) & M_MI0_CLK_DIV)
#define S_MI0_CLK_CNT 8
#define M_MI0_CLK_CNT 0xff
#define V_MI0_CLK_CNT(x) ((x) << S_MI0_CLK_CNT)
#define G_MI0_CLK_CNT(x) (((x) >> S_MI0_CLK_CNT) & M_MI0_CLK_CNT)
#define A_MI0_CSR 0xb04
#define S_MI0_CSR_POLL 0
#define V_MI0_CSR_POLL(x) ((x) << S_MI0_CSR_POLL)
#define F_MI0_CSR_POLL V_MI0_CSR_POLL(1U)
#define S_MI0_PREAMBLE 1
#define V_MI0_PREAMBLE(x) ((x) << S_MI0_PREAMBLE)
#define F_MI0_PREAMBLE V_MI0_PREAMBLE(1U)
#define S_MI0_INTR_ENABLE 2
#define V_MI0_INTR_ENABLE(x) ((x) << S_MI0_INTR_ENABLE)
#define F_MI0_INTR_ENABLE V_MI0_INTR_ENABLE(1U)
#define S_MI0_BUSY 3
#define V_MI0_BUSY(x) ((x) << S_MI0_BUSY)
#define F_MI0_BUSY V_MI0_BUSY(1U)
#define S_MI0_MDIO 4
#define V_MI0_MDIO(x) ((x) << S_MI0_MDIO)
#define F_MI0_MDIO V_MI0_MDIO(1U)
#define A_MI0_ADDR 0xb08
#define S_MI0_PHY_REG_ADDR 0
#define M_MI0_PHY_REG_ADDR 0x1f
#define V_MI0_PHY_REG_ADDR(x) ((x) << S_MI0_PHY_REG_ADDR)
#define G_MI0_PHY_REG_ADDR(x) (((x) >> S_MI0_PHY_REG_ADDR) & M_MI0_PHY_REG_ADDR)
#define S_MI0_PHY_ADDR 5
#define M_MI0_PHY_ADDR 0x1f
#define V_MI0_PHY_ADDR(x) ((x) << S_MI0_PHY_ADDR)
#define G_MI0_PHY_ADDR(x) (((x) >> S_MI0_PHY_ADDR) & M_MI0_PHY_ADDR)
#define A_MI0_DATA_EXT 0xb0c
#define A_MI0_DATA_INT 0xb10
/* GMAC registers */
#define A_GMAC_MACID_LO 0x28
#define A_GMAC_MACID_HI 0x2c
#define A_GMAC_CSR 0x30
#define S_INTERFACE 0
#define M_INTERFACE 0x3
#define V_INTERFACE(x) ((x) << S_INTERFACE)
#define G_INTERFACE(x) (((x) >> S_INTERFACE) & M_INTERFACE)
#define S_MAC_TX_ENABLE 2
#define V_MAC_TX_ENABLE(x) ((x) << S_MAC_TX_ENABLE)
#define F_MAC_TX_ENABLE V_MAC_TX_ENABLE(1U)
#define S_MAC_RX_ENABLE 3
#define V_MAC_RX_ENABLE(x) ((x) << S_MAC_RX_ENABLE)
#define F_MAC_RX_ENABLE V_MAC_RX_ENABLE(1U)
#define S_MAC_LB_ENABLE 4
#define V_MAC_LB_ENABLE(x) ((x) << S_MAC_LB_ENABLE)
#define F_MAC_LB_ENABLE V_MAC_LB_ENABLE(1U)
#define S_MAC_SPEED 5
#define M_MAC_SPEED 0x3
#define V_MAC_SPEED(x) ((x) << S_MAC_SPEED)
#define G_MAC_SPEED(x) (((x) >> S_MAC_SPEED) & M_MAC_SPEED)
#define S_MAC_HD_FC_ENABLE 7
#define V_MAC_HD_FC_ENABLE(x) ((x) << S_MAC_HD_FC_ENABLE)
#define F_MAC_HD_FC_ENABLE V_MAC_HD_FC_ENABLE(1U)
#define S_MAC_HALF_DUPLEX 8
#define V_MAC_HALF_DUPLEX(x) ((x) << S_MAC_HALF_DUPLEX)
#define F_MAC_HALF_DUPLEX V_MAC_HALF_DUPLEX(1U)
#define S_MAC_PROMISC 9
#define V_MAC_PROMISC(x) ((x) << S_MAC_PROMISC)
#define F_MAC_PROMISC V_MAC_PROMISC(1U)
#define S_MAC_MC_ENABLE 10
#define V_MAC_MC_ENABLE(x) ((x) << S_MAC_MC_ENABLE)
#define F_MAC_MC_ENABLE V_MAC_MC_ENABLE(1U)
#define S_MAC_RESET 11
#define V_MAC_RESET(x) ((x) << S_MAC_RESET)
#define F_MAC_RESET V_MAC_RESET(1U)
#define S_MAC_RX_PAUSE_ENABLE 12
#define V_MAC_RX_PAUSE_ENABLE(x) ((x) << S_MAC_RX_PAUSE_ENABLE)
#define F_MAC_RX_PAUSE_ENABLE V_MAC_RX_PAUSE_ENABLE(1U)
#define S_MAC_TX_PAUSE_ENABLE 13
#define V_MAC_TX_PAUSE_ENABLE(x) ((x) << S_MAC_TX_PAUSE_ENABLE)
#define F_MAC_TX_PAUSE_ENABLE V_MAC_TX_PAUSE_ENABLE(1U)
#define S_MAC_LWM_ENABLE 14
#define V_MAC_LWM_ENABLE(x) ((x) << S_MAC_LWM_ENABLE)
#define F_MAC_LWM_ENABLE V_MAC_LWM_ENABLE(1U)
#define S_MAC_MAGIC_PKT_ENABLE 15
#define V_MAC_MAGIC_PKT_ENABLE(x) ((x) << S_MAC_MAGIC_PKT_ENABLE)
#define F_MAC_MAGIC_PKT_ENABLE V_MAC_MAGIC_PKT_ENABLE(1U)
#define S_MAC_ISL_ENABLE 16
#define V_MAC_ISL_ENABLE(x) ((x) << S_MAC_ISL_ENABLE)
#define F_MAC_ISL_ENABLE V_MAC_ISL_ENABLE(1U)
#define S_MAC_JUMBO_ENABLE 17
#define V_MAC_JUMBO_ENABLE(x) ((x) << S_MAC_JUMBO_ENABLE)
#define F_MAC_JUMBO_ENABLE V_MAC_JUMBO_ENABLE(1U)
#define S_MAC_RX_PAD_ENABLE 18
#define V_MAC_RX_PAD_ENABLE(x) ((x) << S_MAC_RX_PAD_ENABLE)
#define F_MAC_RX_PAD_ENABLE V_MAC_RX_PAD_ENABLE(1U)
#define S_MAC_RX_CRC_ENABLE 19
#define V_MAC_RX_CRC_ENABLE(x) ((x) << S_MAC_RX_CRC_ENABLE)
#define F_MAC_RX_CRC_ENABLE V_MAC_RX_CRC_ENABLE(1U)
#define A_GMAC_IFS 0x34
#define S_MAC_IFS2 0
#define M_MAC_IFS2 0x3f
#define V_MAC_IFS2(x) ((x) << S_MAC_IFS2)
#define G_MAC_IFS2(x) (((x) >> S_MAC_IFS2) & M_MAC_IFS2)
#define S_MAC_IFS1 8
#define M_MAC_IFS1 0x7f
#define V_MAC_IFS1(x) ((x) << S_MAC_IFS1)
#define G_MAC_IFS1(x) (((x) >> S_MAC_IFS1) & M_MAC_IFS1)
#define A_GMAC_JUMBO_FRAME_LEN 0x38
#define A_GMAC_LNK_DLY 0x3c
#define A_GMAC_PAUSETIME 0x40
#define A_GMAC_MCAST_LO 0x44
#define A_GMAC_MCAST_HI 0x48
#define A_GMAC_MCAST_MASK_LO 0x4c
#define A_GMAC_MCAST_MASK_HI 0x50
#define A_GMAC_RMT_CNT 0x54
#define A_GMAC_RMT_DATA 0x58
#define A_GMAC_BACKOFF_SEED 0x5c
#define A_GMAC_TXF_THRES 0x60
#define S_TXF_READ_THRESHOLD 0
#define M_TXF_READ_THRESHOLD 0xff
#define V_TXF_READ_THRESHOLD(x) ((x) << S_TXF_READ_THRESHOLD)
#define G_TXF_READ_THRESHOLD(x) (((x) >> S_TXF_READ_THRESHOLD) & M_TXF_READ_THRESHOLD)
#define S_TXF_WRITE_THRESHOLD 16
#define M_TXF_WRITE_THRESHOLD 0xff
#define V_TXF_WRITE_THRESHOLD(x) ((x) << S_TXF_WRITE_THRESHOLD)
#define G_TXF_WRITE_THRESHOLD(x) (((x) >> S_TXF_WRITE_THRESHOLD) & M_TXF_WRITE_THRESHOLD)
#define MAC_REG_BASE 0x600
#define MAC_REG_ADDR(idx, reg) (MAC_REG_BASE + (idx) * 128 + (reg))
#define MAC_REG_IDLO(idx) MAC_REG_ADDR(idx, A_GMAC_MACID_LO)
#define MAC_REG_IDHI(idx) MAC_REG_ADDR(idx, A_GMAC_MACID_HI)
#define MAC_REG_CSR(idx) MAC_REG_ADDR(idx, A_GMAC_CSR)
#define MAC_REG_IFS(idx) MAC_REG_ADDR(idx, A_GMAC_IFS)
#define MAC_REG_LARGEFRAMELENGTH(idx) MAC_REG_ADDR(idx, A_GMAC_JUMBO_FRAME_LEN)
#define MAC_REG_LINKDLY(idx) MAC_REG_ADDR(idx, A_GMAC_LNK_DLY)
#define MAC_REG_PAUSETIME(idx) MAC_REG_ADDR(idx, A_GMAC_PAUSETIME)
#define MAC_REG_CASTLO(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_LO)
#define MAC_REG_MCASTHI(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_HI)
#define MAC_REG_CASTMASKLO(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_MASK_LO)
#define MAC_REG_MCASTMASKHI(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_MASK_HI)
#define MAC_REG_RMCNT(idx) MAC_REG_ADDR(idx, A_GMAC_RMT_CNT)
#define MAC_REG_RMDATA(idx) MAC_REG_ADDR(idx, A_GMAC_RMT_DATA)
#define MAC_REG_GMRANDBACKOFFSEED(idx) MAC_REG_ADDR(idx, A_GMAC_BACKOFF_SEED)
#define MAC_REG_TXFTHRESHOLDS(idx) MAC_REG_ADDR(idx, A_GMAC_TXF_THRES)
#endif
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CompositeKey.h"
#include <QFile>
#include <QtConcurrent>
#include <format/KeePass2.h>
#include "core/Global.h"
#include "crypto/kdf/AesKdf.h"
#include "crypto/CryptoHash.h"
CompositeKey::CompositeKey()
{
}
CompositeKey::CompositeKey(const CompositeKey& key)
{
*this = key;
}
CompositeKey::~CompositeKey()
{
clear();
}
void CompositeKey::clear()
{
qDeleteAll(m_keys);
m_keys.clear();
m_challengeResponseKeys.clear();
}
bool CompositeKey::isEmpty() const
{
return m_keys.isEmpty() && m_challengeResponseKeys.isEmpty();
}
CompositeKey* CompositeKey::clone() const
{
return new CompositeKey(*this);
}
CompositeKey& CompositeKey::operator=(const CompositeKey& key)
{
// handle self assignment as that would break when calling clear()
if (this == &key) {
return *this;
}
clear();
for (const Key* subKey : asConst(key.m_keys)) {
addKey(*subKey);
}
for (const auto subKey : asConst(key.m_challengeResponseKeys)) {
addChallengeResponseKey(subKey);
}
return *this;
}
/**
* Get raw key hash as bytes.
*
* The key hash does not contain contributions by challenge-response components for
* backwards compatibility with KeePassXC's pre-KDBX4 challenge-response
* implementation. To include challenge-response in the raw key,
* use \link CompositeKey::rawKey(const QByteArray*, bool*) instead.
*
* @return key hash
*/
QByteArray CompositeKey::rawKey() const
{
return rawKey(nullptr, nullptr);
}
/**
* Get raw key hash as bytes.
*
* Challenge-response key components will use the provided <tt>transformSeed</tt>
* as a challenge to acquire their key contribution.
*
* @param transformSeed transform seed to challenge or nullptr to exclude challenge-response components
* @param ok true if challenges were successful and all key components could be added to the composite key
* @return key hash
*/
QByteArray CompositeKey::rawKey(const QByteArray* transformSeed, bool* ok) const
{
CryptoHash cryptoHash(CryptoHash::Sha256);
for (const Key* key : m_keys) {
cryptoHash.addData(key->rawKey());
}
if (ok) {
*ok = true;
}
if (transformSeed) {
QByteArray challengeResult;
bool challengeOk = challenge(*transformSeed, challengeResult);
if (ok) {
*ok = challengeOk;
}
cryptoHash.addData(challengeResult);
}
return cryptoHash.result();
}
/**
* Transform this composite key.
*
* If using AES-KDF as transform function, the transformed key will not include
* any challenge-response components. Only static key components will be hashed
* for backwards-compatibility with KeePassXC's KDBX3 implementation, which added
* challenge response key components after key transformation.
* KDBX4+ KDFs transform the whole key including challenge-response components.
*
* @param kdf key derivation function
* @param result transformed key hash
* @return true on success
*/
bool CompositeKey::transform(const Kdf& kdf, QByteArray& result) const
{
if (kdf.uuid() == KeePass2::KDF_AES_KDBX3) {
// legacy KDBX3 AES-KDF, challenge response is added later to the hash
return kdf.transform(rawKey(), result);
}
QByteArray seed = kdf.seed();
Q_ASSERT(!seed.isEmpty());
bool ok = false;
return kdf.transform(rawKey(&seed, &ok), result) && ok;
}
bool CompositeKey::challenge(const QByteArray& seed, QByteArray& result) const
{
// if no challenge response was requested, return nothing to
// maintain backwards compatibility with regular databases.
if (m_challengeResponseKeys.length() == 0) {
result.clear();
return true;
}
CryptoHash cryptoHash(CryptoHash::Sha256);
for (const auto& key : m_challengeResponseKeys) {
// if the device isn't present or fails, return an error
if (!key->challenge(seed)) {
qWarning("Failed to issue challenge");
return false;
}
cryptoHash.addData(key->rawKey());
}
result = cryptoHash.result();
return true;
}
void CompositeKey::addKey(const Key& key)
{
m_keys.append(key.clone());
}
void CompositeKey::addChallengeResponseKey(QSharedPointer<ChallengeResponseKey> key)
{
m_challengeResponseKeys.append(key);
}
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: 74b0576da674cd142896a96340f59ed2
timeCreated: 1448796133
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Adminhtml edit admin user account
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Adminhtml_Block_System_Account_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
public function __construct()
{
parent::__construct();
$this->_controller = 'system_account';
$this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save Account'));
$this->_removeButton('delete');
$this->_removeButton('back');
}
public function getHeaderText()
{
return Mage::helper('adminhtml')->__('My Account');
}
}
| {
"pile_set_name": "Github"
} |
//
// error.hpp
// ~~~~~~~~~
//
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_ERROR_HPP
#define BOOST_ASIO_ERROR_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/cerrno.hpp>
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#if defined(BOOST_ASIO_WINDOWS) \
|| defined(__CYGWIN__) \
|| defined(BOOST_ASIO_WINDOWS_RUNTIME)
# include <winerror.h>
#else
# include <cerrno>
# include <netdb.h>
#endif
#if defined(GENERATING_DOCUMENTATION)
/// INTERNAL ONLY.
# define BOOST_ASIO_NATIVE_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define BOOST_ASIO_SOCKET_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define BOOST_ASIO_NETDB_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define BOOST_ASIO_GETADDRINFO_ERROR(e) implementation_defined
/// INTERNAL ONLY.
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
#elif defined(BOOST_ASIO_WINDOWS_RUNTIME)
# define BOOST_ASIO_NATIVE_ERROR(e) __HRESULT_FROM_WIN32(e)
# define BOOST_ASIO_SOCKET_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e)
# define BOOST_ASIO_NETDB_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e)
# define BOOST_ASIO_GETADDRINFO_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e)
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
#elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
# define BOOST_ASIO_NATIVE_ERROR(e) e
# define BOOST_ASIO_SOCKET_ERROR(e) WSA ## e
# define BOOST_ASIO_NETDB_ERROR(e) WSA ## e
# define BOOST_ASIO_GETADDRINFO_ERROR(e) WSA ## e
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
#else
# define BOOST_ASIO_NATIVE_ERROR(e) e
# define BOOST_ASIO_SOCKET_ERROR(e) e
# define BOOST_ASIO_NETDB_ERROR(e) e
# define BOOST_ASIO_GETADDRINFO_ERROR(e) e
# define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
#endif
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace error {
enum basic_errors
{
/// Permission denied.
access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES),
/// Address family not supported by protocol.
address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(EAFNOSUPPORT),
/// Address already in use.
address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE),
/// Transport endpoint is already connected.
already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN),
/// Operation already in progress.
already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY),
/// Broken pipe.
broken_pipe = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE),
BOOST_ASIO_NATIVE_ERROR(EPIPE)),
/// A connection has been aborted.
connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED),
/// Connection refused.
connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED),
/// Connection reset by peer.
connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET),
/// Bad file descriptor.
bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF),
/// Bad address.
fault = BOOST_ASIO_SOCKET_ERROR(EFAULT),
/// No route to host.
host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH),
/// Operation now in progress.
in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS),
/// Interrupted system call.
interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR),
/// Invalid argument.
invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL),
/// Message too long.
message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE),
/// The name was too long.
name_too_long = BOOST_ASIO_SOCKET_ERROR(ENAMETOOLONG),
/// Network is down.
network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN),
/// Network dropped connection on reset.
network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET),
/// Network is unreachable.
network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH),
/// Too many open files.
no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE),
/// No buffer space available.
no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS),
/// Cannot allocate memory.
no_memory = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
BOOST_ASIO_NATIVE_ERROR(ENOMEM)),
/// Operation not permitted.
no_permission = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
BOOST_ASIO_NATIVE_ERROR(EPERM)),
/// Protocol not available.
no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT),
/// No such device.
no_such_device = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(ERROR_BAD_UNIT),
BOOST_ASIO_NATIVE_ERROR(ENODEV)),
/// Transport endpoint is not connected.
not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN),
/// Socket operation on non-socket.
not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK),
/// Operation cancelled.
operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
BOOST_ASIO_NATIVE_ERROR(ECANCELED)),
/// Operation not supported.
operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP),
/// Cannot send after transport endpoint shutdown.
shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN),
/// Connection timed out.
timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT),
/// Resource temporarily unavailable.
try_again = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
BOOST_ASIO_NATIVE_ERROR(EAGAIN)),
/// The socket is marked non-blocking and the requested operation would block.
would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK)
};
enum netdb_errors
{
/// Host not found (authoritative).
host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND),
/// Host not found (non-authoritative).
host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN),
/// The query is valid but does not have associated address data.
no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA),
/// A non-recoverable error occurred.
no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY)
};
enum addrinfo_errors
{
/// The service is not supported for the given socket type.
service_not_found = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
/// The socket type is not supported.
socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
};
enum misc_errors
{
/// Already open.
already_open = 1,
/// End of file or stream.
eof,
/// Element not found.
not_found,
/// The descriptor cannot fit into the select system call's fd_set.
fd_set_failure
};
inline const boost::system::error_category& get_system_category()
{
return boost::system::system_category();
}
#if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
extern BOOST_ASIO_DECL
const boost::system::error_category& get_netdb_category();
extern BOOST_ASIO_DECL
const boost::system::error_category& get_addrinfo_category();
#else // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
inline const boost::system::error_category& get_netdb_category()
{
return get_system_category();
}
inline const boost::system::error_category& get_addrinfo_category()
{
return get_system_category();
}
#endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
extern BOOST_ASIO_DECL
const boost::system::error_category& get_misc_category();
static const boost::system::error_category&
system_category BOOST_ASIO_UNUSED_VARIABLE
= boost::asio::error::get_system_category();
static const boost::system::error_category&
netdb_category BOOST_ASIO_UNUSED_VARIABLE
= boost::asio::error::get_netdb_category();
static const boost::system::error_category&
addrinfo_category BOOST_ASIO_UNUSED_VARIABLE
= boost::asio::error::get_addrinfo_category();
static const boost::system::error_category&
misc_category BOOST_ASIO_UNUSED_VARIABLE
= boost::asio::error::get_misc_category();
} // namespace error
} // namespace asio
} // namespace boost
namespace boost {
namespace system {
template<> struct is_error_code_enum<boost::asio::error::basic_errors>
{
static const bool value = true;
};
template<> struct is_error_code_enum<boost::asio::error::netdb_errors>
{
static const bool value = true;
};
template<> struct is_error_code_enum<boost::asio::error::addrinfo_errors>
{
static const bool value = true;
};
template<> struct is_error_code_enum<boost::asio::error::misc_errors>
{
static const bool value = true;
};
} // namespace system
} // namespace boost
namespace boost {
namespace asio {
namespace error {
inline boost::system::error_code make_error_code(basic_errors e)
{
return boost::system::error_code(
static_cast<int>(e), get_system_category());
}
inline boost::system::error_code make_error_code(netdb_errors e)
{
return boost::system::error_code(
static_cast<int>(e), get_netdb_category());
}
inline boost::system::error_code make_error_code(addrinfo_errors e)
{
return boost::system::error_code(
static_cast<int>(e), get_addrinfo_category());
}
inline boost::system::error_code make_error_code(misc_errors e)
{
return boost::system::error_code(
static_cast<int>(e), get_misc_category());
}
} // namespace error
namespace stream_errc {
// Simulates the proposed stream_errc scoped enum.
using error::eof;
using error::not_found;
} // namespace stream_errc
namespace socket_errc {
// Simulates the proposed socket_errc scoped enum.
using error::already_open;
using error::not_found;
} // namespace socket_errc
namespace resolver_errc {
// Simulates the proposed resolver_errc scoped enum.
using error::host_not_found;
const error::netdb_errors try_again = error::host_not_found_try_again;
using error::service_not_found;
} // namespace resolver_errc
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#undef BOOST_ASIO_NATIVE_ERROR
#undef BOOST_ASIO_SOCKET_ERROR
#undef BOOST_ASIO_NETDB_ERROR
#undef BOOST_ASIO_GETADDRINFO_ERROR
#undef BOOST_ASIO_WIN_OR_POSIX
#if defined(BOOST_ASIO_HEADER_ONLY)
# include <boost/asio/impl/error.ipp>
#endif // defined(BOOST_ASIO_HEADER_ONLY)
#endif // BOOST_ASIO_ERROR_HPP
| {
"pile_set_name": "Github"
} |
# 关于我们
蚂蚁中间件团队是服务于整个蚂蚁金服集团(包括钱包、网商、小贷、芝麻、财富、国际、口碑等)的核心技术团队,致力于打造支撑每秒亿级金融交易规模的基础中间件平台,为高速发展的业务提供业界一流的,金融级高可用高性能的分布式基础服务,也将十年磨一剑的技术做产品化输出,为蚂蚁业务生态的合作伙伴提供技术赋能。 | {
"pile_set_name": "Github"
} |
/**
* marked - a markdown parser
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked
*/
;(function(root) {
'use strict';
/**
* Block-Level Grammar
*/
var block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: noop,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
nptable: noop,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
table: noop,
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
paragraph: /^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/,
text: /^[^\n]+/
};
block._label = /(?:\\[\[\]]|[^\[\]])+/;
block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/;
block.def = edit(block.def)
.replace('label', block._label)
.replace('title', block._title)
.getRegex();
block.bullet = /(?:[*+-]|\d+\.)/;
block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
block.item = edit(block.item, 'gm')
.replace(/bull/g, block.bullet)
.getRegex();
block.list = edit(block.list)
.replace(/bull/g, block.bullet)
.replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
.replace('def', '\\n+(?=' + block.def.source + ')')
.getRegex();
block._tag = '(?!(?:'
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b';
block.html = edit(block.html)
.replace('comment', /<!--[\s\S]*?-->/)
.replace('closed', /<(tag)[\s\S]+?<\/\1>/)
.replace('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/)
.replace(/tag/g, block._tag)
.getRegex();
block.paragraph = edit(block.paragraph)
.replace('hr', block.hr)
.replace('heading', block.heading)
.replace('lheading', block.lheading)
.replace('tag', '<' + block._tag)
.getRegex();
block.blockquote = edit(block.blockquote)
.replace('paragraph', block.paragraph)
.getRegex();
/**
* Normal Block Grammar
*/
block.normal = merge({}, block);
/**
* GFM Block Grammar
*/
block.gfm = merge({}, block.normal, {
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
paragraph: /^/,
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
});
block.gfm.paragraph = edit(block.paragraph)
.replace('(?!', '(?!'
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
+ block.list.source.replace('\\1', '\\3') + '|')
.getRegex();
/**
* GFM + Tables Block Grammar
*/
block.tables = merge({}, block.gfm, {
nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
});
/**
* Block Lexer
*/
function Lexer(options) {
this.tokens = [];
this.tokens.links = {};
this.options = options || marked.defaults;
this.rules = block.normal;
if (this.options.gfm) {
if (this.options.tables) {
this.rules = block.tables;
} else {
this.rules = block.gfm;
}
}
}
/**
* Expose Block Rules
*/
Lexer.rules = block;
/**
* Static Lex Method
*/
Lexer.lex = function(src, options) {
var lexer = new Lexer(options);
return lexer.lex(src);
};
/**
* Preprocessing
*/
Lexer.prototype.lex = function(src) {
src = src
.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ')
.replace(/\u00a0/g, ' ')
.replace(/\u2424/g, '\n');
return this.token(src, true);
};
/**
* Lexing
*/
Lexer.prototype.token = function(src, top) {
src = src.replace(/^ +$/gm, '');
var next,
loose,
cap,
bull,
b,
item,
space,
i,
tag,
l,
isordered;
while (src) {
// newline
if (cap = this.rules.newline.exec(src)) {
src = src.substring(cap[0].length);
if (cap[0].length > 1) {
this.tokens.push({
type: 'space'
});
}
}
// code
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
cap = cap[0].replace(/^ {4}/gm, '');
this.tokens.push({
type: 'code',
text: !this.options.pedantic
? cap.replace(/\n+$/, '')
: cap
});
continue;
}
// fences (gfm)
if (cap = this.rules.fences.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'code',
lang: cap[2],
text: cap[3] || ''
});
continue;
}
// heading
if (cap = this.rules.heading.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'heading',
depth: cap[1].length,
text: cap[2]
});
continue;
}
// table no leading pipe (gfm)
if (top && (cap = this.rules.nptable.exec(src))) {
src = src.substring(cap[0].length);
item = {
type: 'table',
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3].replace(/\n$/, '').split('\n')
};
for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = 'center';
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = 'left';
} else {
item.align[i] = null;
}
}
for (i = 0; i < item.cells.length; i++) {
item.cells[i] = item.cells[i].split(/ *\| */);
}
this.tokens.push(item);
continue;
}
// hr
if (cap = this.rules.hr.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'hr'
});
continue;
}
// blockquote
if (cap = this.rules.blockquote.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'blockquote_start'
});
cap = cap[0].replace(/^ *> ?/gm, '');
// Pass `top` to keep the current
// "toplevel" state. This is exactly
// how markdown.pl works.
this.token(cap, top);
this.tokens.push({
type: 'blockquote_end'
});
continue;
}
// list
if (cap = this.rules.list.exec(src)) {
src = src.substring(cap[0].length);
bull = cap[2];
isordered = bull.length > 1;
this.tokens.push({
type: 'list_start',
ordered: isordered,
start: isordered ? +bull : ''
});
// Get each top-level item.
cap = cap[0].match(this.rules.item);
next = false;
l = cap.length;
i = 0;
for (; i < l; i++) {
item = cap[i];
// Remove the list item's bullet
// so it is seen as the next token.
space = item.length;
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
// Outdent whatever the
// list item contains. Hacky.
if (~item.indexOf('\n ')) {
space -= item.length;
item = !this.options.pedantic
? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
: item.replace(/^ {1,4}/gm, '');
}
// Determine whether the next list item belongs here.
// Backpedal if it does not belong in this list.
if (this.options.smartLists && i !== l - 1) {
b = block.bullet.exec(cap[i + 1])[0];
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
src = cap.slice(i + 1).join('\n') + src;
i = l - 1;
}
}
// Determine whether item is loose or not.
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
// for discount behavior.
loose = next || /\n\n(?!\s*$)/.test(item);
if (i !== l - 1) {
next = item.charAt(item.length - 1) === '\n';
if (!loose) loose = next;
}
this.tokens.push({
type: loose
? 'loose_item_start'
: 'list_item_start'
});
// Recurse.
this.token(item, false);
this.tokens.push({
type: 'list_item_end'
});
}
this.tokens.push({
type: 'list_end'
});
continue;
}
// html
if (cap = this.rules.html.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: this.options.sanitize
? 'paragraph'
: 'html',
pre: !this.options.sanitizer
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: cap[0]
});
continue;
}
// def
if (top && (cap = this.rules.def.exec(src))) {
src = src.substring(cap[0].length);
if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
tag = cap[1].toLowerCase();
if (!this.tokens.links[tag]) {
this.tokens.links[tag] = {
href: cap[2],
title: cap[3]
};
}
continue;
}
// table (gfm)
if (top && (cap = this.rules.table.exec(src))) {
src = src.substring(cap[0].length);
item = {
type: 'table',
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
};
for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = 'center';
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = 'left';
} else {
item.align[i] = null;
}
}
for (i = 0; i < item.cells.length; i++) {
item.cells[i] = item.cells[i]
.replace(/^ *\| *| *\| *$/g, '')
.split(/ *\| */);
}
this.tokens.push(item);
continue;
}
// lheading
if (cap = this.rules.lheading.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'heading',
depth: cap[2] === '=' ? 1 : 2,
text: cap[1]
});
continue;
}
// top-level paragraph
if (top && (cap = this.rules.paragraph.exec(src))) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'paragraph',
text: cap[1].charAt(cap[1].length - 1) === '\n'
? cap[1].slice(0, -1)
: cap[1]
});
continue;
}
// text
if (cap = this.rules.text.exec(src)) {
// Top-level should never reach here.
src = src.substring(cap[0].length);
this.tokens.push({
type: 'text',
text: cap[0]
});
continue;
}
if (src) {
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
}
}
return this.tokens;
};
/**
* Inline-Level Grammar
*/
var inline = {
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
url: noop,
tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/,
link: /^!?\[(inside)\]\(href\)/,
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/
};
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
inline.autolink = edit(inline.autolink)
.replace('scheme', inline._scheme)
.replace('email', inline._email)
.getRegex()
inline._inside = /(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/;
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
inline.link = edit(inline.link)
.replace('inside', inline._inside)
.replace('href', inline._href)
.getRegex();
inline.reflink = edit(inline.reflink)
.replace('inside', inline._inside)
.getRegex();
/**
* Normal Inline Grammar
*/
inline.normal = merge({}, inline);
/**
* Pedantic Inline Grammar
*/
inline.pedantic = merge({}, inline.normal, {
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
});
/**
* GFM Inline Grammar
*/
inline.gfm = merge({}, inline.normal, {
escape: edit(inline.escape).replace('])', '~|])').getRegex(),
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/)
.replace('email', inline._email)
.getRegex(),
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~~(?=\S)([\s\S]*?\S)~~/,
text: edit(inline.text)
.replace(']|', '~]|')
.replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|')
.getRegex()
});
/**
* GFM + Line Breaks Inline Grammar
*/
inline.breaks = merge({}, inline.gfm, {
br: edit(inline.br).replace('{2,}', '*').getRegex(),
text: edit(inline.gfm.text).replace('{2,}', '*').getRegex()
});
/**
* Inline Lexer & Compiler
*/
function InlineLexer(links, options) {
this.options = options || marked.defaults;
this.links = links;
this.rules = inline.normal;
this.renderer = this.options.renderer || new Renderer();
this.renderer.options = this.options;
if (!this.links) {
throw new Error('Tokens array requires a `links` property.');
}
if (this.options.gfm) {
if (this.options.breaks) {
this.rules = inline.breaks;
} else {
this.rules = inline.gfm;
}
} else if (this.options.pedantic) {
this.rules = inline.pedantic;
}
}
/**
* Expose Inline Rules
*/
InlineLexer.rules = inline;
/**
* Static Lexing/Compiling Method
*/
InlineLexer.output = function(src, links, options) {
var inline = new InlineLexer(links, options);
return inline.output(src);
};
/**
* Lexing/Compiling
*/
InlineLexer.prototype.output = function(src) {
var out = '',
link,
text,
href,
cap;
while (src) {
// escape
if (cap = this.rules.escape.exec(src)) {
src = src.substring(cap[0].length);
out += cap[1];
continue;
}
// autolink
if (cap = this.rules.autolink.exec(src)) {
src = src.substring(cap[0].length);
if (cap[2] === '@') {
text = escape(this.mangle(cap[1]));
href = 'mailto:' + text;
} else {
text = escape(cap[1]);
href = text;
}
out += this.renderer.link(href, null, text);
continue;
}
// url (gfm)
if (!this.inLink && (cap = this.rules.url.exec(src))) {
cap[0] = this.rules._backpedal.exec(cap[0])[0];
src = src.substring(cap[0].length);
if (cap[2] === '@') {
text = escape(cap[0]);
href = 'mailto:' + text;
} else {
text = escape(cap[0]);
if (cap[1] === 'www.') {
href = 'http://' + text;
} else {
href = text;
}
}
out += this.renderer.link(href, null, text);
continue;
}
// tag
if (cap = this.rules.tag.exec(src)) {
if (!this.inLink && /^<a /i.test(cap[0])) {
this.inLink = true;
} else if (this.inLink && /^<\/a>/i.test(cap[0])) {
this.inLink = false;
}
src = src.substring(cap[0].length);
out += this.options.sanitize
? this.options.sanitizer
? this.options.sanitizer(cap[0])
: escape(cap[0])
: cap[0]
continue;
}
// link
if (cap = this.rules.link.exec(src)) {
src = src.substring(cap[0].length);
this.inLink = true;
out += this.outputLink(cap, {
href: cap[2],
title: cap[3]
});
this.inLink = false;
continue;
}
// reflink, nolink
if ((cap = this.rules.reflink.exec(src))
|| (cap = this.rules.nolink.exec(src))) {
src = src.substring(cap[0].length);
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
link = this.links[link.toLowerCase()];
if (!link || !link.href) {
out += cap[0].charAt(0);
src = cap[0].substring(1) + src;
continue;
}
this.inLink = true;
out += this.outputLink(cap, link);
this.inLink = false;
continue;
}
// strong
if (cap = this.rules.strong.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.strong(this.output(cap[2] || cap[1]));
continue;
}
// em
if (cap = this.rules.em.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.em(this.output(cap[2] || cap[1]));
continue;
}
// code
if (cap = this.rules.code.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.codespan(escape(cap[2].trim(), true));
continue;
}
// br
if (cap = this.rules.br.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.br();
continue;
}
// del (gfm)
if (cap = this.rules.del.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.del(this.output(cap[1]));
continue;
}
// text
if (cap = this.rules.text.exec(src)) {
src = src.substring(cap[0].length);
out += this.renderer.text(escape(this.smartypants(cap[0])));
continue;
}
if (src) {
throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
}
}
return out;
};
/**
* Compile Link
*/
InlineLexer.prototype.outputLink = function(cap, link) {
var href = escape(link.href),
title = link.title ? escape(link.title) : null;
return cap[0].charAt(0) !== '!'
? this.renderer.link(href, title, this.output(cap[1]))
: this.renderer.image(href, title, escape(cap[1]));
};
/**
* Smartypants Transformations
*/
InlineLexer.prototype.smartypants = function(text) {
if (!this.options.smartypants) return text;
return text
// em-dashes
.replace(/---/g, '\u2014')
// en-dashes
.replace(/--/g, '\u2013')
// opening singles
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
// closing singles & apostrophes
.replace(/'/g, '\u2019')
// opening doubles
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
// closing doubles
.replace(/"/g, '\u201d')
// ellipses
.replace(/\.{3}/g, '\u2026');
};
/**
* Mangle Links
*/
InlineLexer.prototype.mangle = function(text) {
if (!this.options.mangle) return text;
var out = '',
l = text.length,
i = 0,
ch;
for (; i < l; i++) {
ch = text.charCodeAt(i);
if (Math.random() > 0.5) {
ch = 'x' + ch.toString(16);
}
out += '&#' + ch + ';';
}
return out;
};
/**
* Renderer
*/
function Renderer(options) {
this.options = options || {};
}
Renderer.prototype.code = function(code, lang, escaped) {
if (this.options.highlight) {
var out = this.options.highlight(code, lang);
if (out != null && out !== code) {
escaped = true;
code = out;
}
}
if (!lang) {
return '<pre><code>'
+ (escaped ? code : escape(code, true))
+ '\n</code></pre>';
}
return '<pre><code class="'
+ this.options.langPrefix
+ escape(lang, true)
+ '">'
+ (escaped ? code : escape(code, true))
+ '\n</code></pre>\n';
};
Renderer.prototype.blockquote = function(quote) {
return '<blockquote>\n' + quote + '</blockquote>\n';
};
Renderer.prototype.html = function(html) {
return html;
};
Renderer.prototype.heading = function(text, level, raw) {
return '<h'
+ level
+ ' id="'
+ this.options.headerPrefix
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
};
Renderer.prototype.hr = function() {
return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
};
Renderer.prototype.list = function(body, ordered, start) {
var type = ordered ? 'ol' : 'ul',
startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
};
Renderer.prototype.listitem = function(text) {
return '<li>' + text + '</li>\n';
};
Renderer.prototype.paragraph = function(text) {
return '<p>' + text + '</p>\n';
};
Renderer.prototype.table = function(header, body) {
return '<table>\n'
+ '<thead>\n'
+ header
+ '</thead>\n'
+ '<tbody>\n'
+ body
+ '</tbody>\n'
+ '</table>\n';
};
Renderer.prototype.tablerow = function(content) {
return '<tr>\n' + content + '</tr>\n';
};
Renderer.prototype.tablecell = function(content, flags) {
var type = flags.header ? 'th' : 'td';
var tag = flags.align
? '<' + type + ' style="text-align:' + flags.align + '">'
: '<' + type + '>';
return tag + content + '</' + type + '>\n';
};
// span level renderer
Renderer.prototype.strong = function(text) {
return '<strong>' + text + '</strong>';
};
Renderer.prototype.em = function(text) {
return '<em>' + text + '</em>';
};
Renderer.prototype.codespan = function(text) {
return '<code>' + text + '</code>';
};
Renderer.prototype.br = function() {
return this.options.xhtml ? '<br/>' : '<br>';
};
Renderer.prototype.del = function(text) {
return '<del>' + text + '</del>';
};
Renderer.prototype.link = function(href, title, text) {
if (this.options.sanitize) {
try {
var prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return text;
}
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return text;
}
}
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, href);
}
var out = '<a href="' + href + '"';
if (title) {
out += ' title="' + title + '"';
}
out += '>' + text + '</a>';
return out;
};
Renderer.prototype.image = function(href, title, text) {
if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, href);
}
var out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
out += ' title="' + title + '"';
}
out += this.options.xhtml ? '/>' : '>';
return out;
};
Renderer.prototype.text = function(text) {
return text;
};
/**
* TextRenderer
* returns only the textual part of the token
*/
function TextRenderer() {}
// no need for block level renderers
TextRenderer.prototype.strong =
TextRenderer.prototype.em =
TextRenderer.prototype.codespan =
TextRenderer.prototype.del =
TextRenderer.prototype.text = function (text) {
return text;
}
TextRenderer.prototype.link =
TextRenderer.prototype.image = function(href, title, text) {
return '' + text;
}
TextRenderer.prototype.br = function() {
return '';
}
/**
* Parsing & Compiling
*/
function Parser(options) {
this.tokens = [];
this.token = null;
this.options = options || marked.defaults;
this.options.renderer = this.options.renderer || new Renderer();
this.renderer = this.options.renderer;
this.renderer.options = this.options;
}
/**
* Static Parse Method
*/
Parser.parse = function(src, options) {
var parser = new Parser(options);
return parser.parse(src);
};
/**
* Parse Loop
*/
Parser.prototype.parse = function(src) {
this.inline = new InlineLexer(src.links, this.options);
// use an InlineLexer with a TextRenderer to extract pure text
this.inlineText = new InlineLexer(
src.links,
merge({}, this.options, {renderer: new TextRenderer()})
);
this.tokens = src.reverse();
var out = '';
while (this.next()) {
out += this.tok();
}
return out;
};
/**
* Next Token
*/
Parser.prototype.next = function() {
return this.token = this.tokens.pop();
};
/**
* Preview Next Token
*/
Parser.prototype.peek = function() {
return this.tokens[this.tokens.length - 1] || 0;
};
/**
* Parse Text Tokens
*/
Parser.prototype.parseText = function() {
var body = this.token.text;
while (this.peek().type === 'text') {
body += '\n' + this.next().text;
}
return this.inline.output(body);
};
/**
* Parse Current Token
*/
Parser.prototype.tok = function() {
switch (this.token.type) {
case 'space': {
return '';
}
case 'hr': {
return this.renderer.hr();
}
case 'heading': {
return this.renderer.heading(
this.inline.output(this.token.text),
this.token.depth,
unescape(this.inlineText.output(this.token.text)));
}
case 'code': {
return this.renderer.code(this.token.text,
this.token.lang,
this.token.escaped);
}
case 'table': {
var header = '',
body = '',
i,
row,
cell,
j;
// header
cell = '';
for (i = 0; i < this.token.header.length; i++) {
cell += this.renderer.tablecell(
this.inline.output(this.token.header[i]),
{ header: true, align: this.token.align[i] }
);
}
header += this.renderer.tablerow(cell);
for (i = 0; i < this.token.cells.length; i++) {
row = this.token.cells[i];
cell = '';
for (j = 0; j < row.length; j++) {
cell += this.renderer.tablecell(
this.inline.output(row[j]),
{ header: false, align: this.token.align[j] }
);
}
body += this.renderer.tablerow(cell);
}
return this.renderer.table(header, body);
}
case 'blockquote_start': {
body = '';
while (this.next().type !== 'blockquote_end') {
body += this.tok();
}
return this.renderer.blockquote(body);
}
case 'list_start': {
body = '';
var ordered = this.token.ordered,
start = this.token.start;
while (this.next().type !== 'list_end') {
body += this.tok();
}
return this.renderer.list(body, ordered, start);
}
case 'list_item_start': {
body = '';
while (this.next().type !== 'list_item_end') {
body += this.token.type === 'text'
? this.parseText()
: this.tok();
}
return this.renderer.listitem(body);
}
case 'loose_item_start': {
body = '';
while (this.next().type !== 'list_item_end') {
body += this.tok();
}
return this.renderer.listitem(body);
}
case 'html': {
var html = !this.token.pre && !this.options.pedantic
? this.inline.output(this.token.text)
: this.token.text;
return this.renderer.html(html);
}
case 'paragraph': {
return this.renderer.paragraph(this.inline.output(this.token.text));
}
case 'text': {
return this.renderer.paragraph(this.parseText());
}
}
};
/**
* Helpers
*/
function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
function unescape(html) {
// explicitly match decimal, hex, and named HTML entities
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
n = n.toLowerCase();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {
return n.charAt(1) === 'x'
? String.fromCharCode(parseInt(n.substring(2), 16))
: String.fromCharCode(+n.substring(1));
}
return '';
});
}
function edit(regex, opt) {
regex = regex.source;
opt = opt || '';
return {
replace: function(name, val) {
val = val.source || val;
val = val.replace(/(^|[^\[])\^/g, '$1');
regex = regex.replace(name, val);
return this;
},
getRegex: function() {
return new RegExp(regex, opt);
}
};
}
function resolveUrl(base, href) {
if (!baseUrls[' ' + base]) {
// we can ignore everything in base after the last slash of its path component,
// but we might need to add _that_
// https://tools.ietf.org/html/rfc3986#section-3
if (/^[^:]+:\/*[^/]*$/.test(base)) {
baseUrls[' ' + base] = base + '/';
} else {
baseUrls[' ' + base] = base.replace(/[^/]*$/, '');
}
}
base = baseUrls[' ' + base];
if (href.slice(0, 2) === '//') {
return base.replace(/:[\s\S]*/, ':') + href;
} else if (href.charAt(0) === '/') {
return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
} else {
return base + href;
}
}
var baseUrls = {};
var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
function noop() {}
noop.exec = noop;
function merge(obj) {
var i = 1,
target,
key;
for (; i < arguments.length; i++) {
target = arguments[i];
for (key in target) {
if (Object.prototype.hasOwnProperty.call(target, key)) {
obj[key] = target[key];
}
}
}
return obj;
}
/**
* Marked
*/
function marked(src, opt, callback) {
// throw error in case of non string input
if (typeof src === 'undefined' || src === null) {
throw new Error('marked(): input parameter is undefined or null');
}
if (typeof src !== 'string') {
throw new Error('marked(): input parameter is of type '
+ Object.prototype.toString.call(src) + ', string expected');
}
if (callback || typeof opt === 'function') {
if (!callback) {
callback = opt;
opt = null;
}
opt = merge({}, marked.defaults, opt || {});
var highlight = opt.highlight,
tokens,
pending,
i = 0;
try {
tokens = Lexer.lex(src, opt)
} catch (e) {
return callback(e);
}
pending = tokens.length;
var done = function(err) {
if (err) {
opt.highlight = highlight;
return callback(err);
}
var out;
try {
out = Parser.parse(tokens, opt);
} catch (e) {
err = e;
}
opt.highlight = highlight;
return err
? callback(err)
: callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!pending) return done();
for (; i < tokens.length; i++) {
(function(token) {
if (token.type !== 'code') {
return --pending || done();
}
return highlight(token.text, token.lang, function(err, code) {
if (err) return done(err);
if (code == null || code === token.text) {
return --pending || done();
}
token.text = code;
token.escaped = true;
--pending || done();
});
})(tokens[i]);
}
return;
}
try {
if (opt) opt = merge({}, marked.defaults, opt);
return Parser.parse(Lexer.lex(src, opt), opt);
} catch (e) {
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
if ((opt || marked.defaults).silent) {
return '<p>An error occurred:</p><pre>'
+ escape(e.message + '', true)
+ '</pre>';
}
throw e;
}
}
/**
* Options
*/
marked.options =
marked.setOptions = function(opt) {
merge(marked.defaults, opt);
return marked;
};
marked.defaults = {
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
sanitizer: null,
mangle: true,
smartLists: false,
silent: false,
highlight: null,
langPrefix: 'lang-',
smartypants: false,
headerPrefix: '',
renderer: new Renderer(),
xhtml: false,
baseUrl: null
};
/**
* Expose
*/
marked.Parser = Parser;
marked.parser = Parser.parse;
marked.Renderer = Renderer;
marked.TextRenderer = TextRenderer;
marked.Lexer = Lexer;
marked.lexer = Lexer.lex;
marked.InlineLexer = InlineLexer;
marked.inlineLexer = InlineLexer.output;
marked.parse = marked;
if (typeof module !== 'undefined' && typeof exports === 'object') {
module.exports = marked;
} else if (typeof define === 'function' && define.amd) {
define(function() { return marked; });
} else {
root.marked = marked;
}
})(this || (typeof window !== 'undefined' ? window : global));
| {
"pile_set_name": "Github"
} |
//===- LocationSet.cpp -- Location set for modeling abstract memory object----//
//
// SVF: Static Value-Flow Analysis
//
// Copyright (C) <2013-2017> <Yulei Sui>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//===----------------------------------------------------------------------===//
/*
* @file: LocationSet.cpp
* @author: yesen
* @date: 26 Sep 2014
*
* LICENSE
*
*/
#include "MemoryModel/LocationSet.h"
#include "MemoryModel/MemModel.h"
#include <llvm/Support/CommandLine.h> // for tool output file
using namespace llvm;
static cl::opt<bool> singleStride("stride-only", cl::init(false),
cl::desc("Only use single stride in LocMemoryModel"));
/*!
* Add element num and stride pair
*/
void LocationSet::addElemNumStridePair(const NodePair& pair) {
/// The pair will not be added if any number of a stride is zero,
/// because they will not have effect on the locations represented by this LocationSet.
if (pair.first == 0 || pair.second == 0)
return;
if (singleStride) {
if (numStridePair.empty())
numStridePair.push_back(std::make_pair(SymbolTableInfo::getMaxFieldLimit(),pair.second));
else {
/// Find the GCD stride
NodeID existStride = (*numStridePair.begin()).second;
NodeID newStride = gcd(pair.second, existStride);
if (newStride != existStride) {
numStridePair.pop_back();
numStridePair.push_back(std::make_pair(SymbolTableInfo::getMaxFieldLimit(),newStride));
}
}
}
else {
numStridePair.push_back(pair);
}
}
/*!
* Return TRUE if it successfully increases any index by 1
*/
bool LocationSet::increaseIfNotReachUpperBound(std::vector<NodeID>& indices,
const ElemNumStridePairVec& pairVec) const {
assert(indices.size() == pairVec.size() && "vector size not match");
/// Check if all indices reach upper bound
bool reachUpperBound = true;
for (u32_t i = 0; i < indices.size(); i++) {
assert(pairVec[i].first > 0 && "number must be greater than 0");
if (indices[i] < (pairVec[i].first - 1))
reachUpperBound = false;
}
/// Increase index if not reach upper bound
bool increased = false;
if (reachUpperBound == false) {
u32_t i = 0;
while (increased == false) {
if (indices[i] < (pairVec[i].first - 1)) {
indices[i] += 1;
increased = true;
}
else {
indices[i] = 0;
i++;
}
}
}
return increased;
}
/*!
* Compute all possible locations according to offset and number-stride pairs.
*/
PointsTo LocationSet::computeAllLocations() const {
PointsTo result;
result.set(getOffset());
if (isConstantOffset() == false) {
const ElemNumStridePairVec& lhsVec = getNumStridePair();
std::vector<NodeID> indices;
u32_t size = lhsVec.size();
while (size) {
indices.push_back(0);
size--;
}
do {
u32_t i = 0;
NodeID ofst = getOffset();
while (i < lhsVec.size()) {
ofst += (lhsVec[i].second * indices[i]);
i++;
}
result.set(ofst);
} while (increaseIfNotReachUpperBound(indices, lhsVec));
}
return result;
}
| {
"pile_set_name": "Github"
} |
> compile
$ copy-file changes/A2.scala src/main/scala/A.scala
-> compile
$ copy-file changes/B3.scala src/main/scala/B.scala
> compile
$ delete src/main/scala/B.scala
-> compile
$ copy-file changes/B3.scala src/main/scala/B.scala
> compile
$ copy-file changes/B4.scala src/main/scala/B.scala
-> compile
$ copy-file changes/B3.scala src/main/scala/B.scala
> compile
$ copy-file changes/B5.scala src/main/scala/B.scala
-> compile
$ copy-file changes/B3.scala src/main/scala/B.scala
> compile | {
"pile_set_name": "Github"
} |
---
parsed_sample:
#Sample Data
- version: "12.2(54)SG1"
rommon: "12.2(44r)SG9"
hostname: "router1"
uptime: "2 years, 31 weeks, 6 days, 9 hours, 55 minutes"
reload_reason: "reload"
running_image: "cat4500e-entservicesk9-mz.122-54.SG1.bin"
hardware: [4948]
serial:
- "CAT1451S15C"
config_register: 2102
mac: []
| {
"pile_set_name": "Github"
} |
<h1 id="kubernetes-dashboard">[[full_name]] PR Time to Approve and Merge dashboard</h1>
<p>Links:</p>
<ul>
<li>Metric <a href="https://github.com/cncf/devstats/blob/master/metrics/kubernetes/time_metrics.sql" target="_blank">SQL file</a>.</li>
<li>TSDB <a href="https://github.com/cncf/devstats/blob/master/metrics/kubernetes/metrics.yaml" target="_blank">series definition</a>. Search for <code>time_metrics</code></li>
<li>Grafana dashboard <a href="https://github.com/cncf/devstats/blob/master/grafana/dashboards/kubernetes/pr-time-to-approve-and-merge.json" target="_blank">JSON</a>.</li>
</ul>
<h1 id="description">Description</h1>
<ul>
<li>This dashboard show median and 85th percentile time for merged PRs from open to LGTM, approve and merge.</li>
<li>LGTM happens when <code>lgtm</code> label is added on a PR.</li>
<li>Approve happens when <code>approved</code> label is added on a PR.</li>
<li>Open to LGTM time is defined as time from open to LGTM when LGTM is present or from open to approve when approve is present or from open to merge if neither lgtm nor approve is present.</li>
<li>It means that adding approved label when there is no lgtm label means LGTM too. Merging PR without approve or lgtm labels also means LGTM.</li>
<li>LGTM to approve is defined as time from LGTM to approve when approve is present or from lgtm to merge if there is no approved label. If there is no LGTM this is zero.</li>
<li>It means that merging PR means approving it.</li>
<li>Approve to merge is defined as time from approve to merge if approved label is present. It is zero otherwise.</li>
<li>You can filter by PR size. PR size is defined by <code>size/*</code> label. You can select All to get all PRs.</li>
<li>You can select PRs with a specific <code>kind/*</code> label or summary for all of them.</li>
<li>You can filter by API change. PR belongs to API change yes when it has <code>kind/api-change</code> label. You can select All to get all PRs.</li>
<li>You can select single repository group or summary for all of them.</li>
<li>Selecting period (for example week) means that dashboard will data for PRs created in those periods.</li>
<li>See <a href="https://github.com/cncf/devstats/blob/master/docs/periods.md" target="_blank">here</a> for more informations about periods.</li>
<li>See <a href="https://github.com/cncf/devstats/blob/master/docs/repository_groups.md" target="_blank">here</a> for more informations about repository groups.</li>
</ul>
| {
"pile_set_name": "Github"
} |
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`npm publish only publishes the intended files 1`] = `
Array [
"
gatsby-plugin-jsxstyle
======================
- package.json
- gatsby-node.js
- gatsby-ssr.js
- index.js
- LICENSE
",
"
jsxstyle
========
- package.json
- LICENSE
- README.md
- lib/jsxstyle.cjs.js
- lib/jsxstyle.d.ts
- lib/jsxstyle.d.ts.map
- lib/jsxstyle.es.js
- lib/jsxstyle.js
- lib/useMatchMedia.d.ts
- lib/useMatchMedia.d.ts.map
- preact/lib/jsxstyle-preact.cjs.js
- preact/lib/jsxstyle-preact.d.ts
- preact/lib/jsxstyle-preact.d.ts.map
- preact/lib/jsxstyle-preact.es.js
- preact/lib/jsxstyle-preact.js
- preact/package.json
",
"
jsxstyle-utils
==============
- package.json
- LICENSE
- README.md
- lib/addStyleToHead.d.ts
- lib/addStyleToHead.d.ts.map
- lib/componentStyles.d.ts
- lib/componentStyles.d.ts.map
- lib/dangerousStyleValue.d.ts
- lib/dangerousStyleValue.d.ts.map
- lib/getStyleCache.d.ts
- lib/getStyleCache.d.ts.map
- lib/getStyleKeysForProps.d.ts
- lib/getStyleKeysForProps.d.ts.map
- lib/hyphenateStyleName.d.ts
- lib/hyphenateStyleName.d.ts.map
- lib/jsxstyle-utils.cjs.js
- lib/jsxstyle-utils.d.ts
- lib/jsxstyle-utils.d.ts.map
- lib/jsxstyle-utils.es.js
- lib/jsxstyle-utils.js
- lib/stringHash.d.ts
- lib/stringHash.d.ts.map
- lib/types.d.ts
- lib/types.d.ts.map
",
"
jsxstyle-webpack-plugin
=======================
- package.json
- LICENSE
- README.md
- lib/loader.d.ts
- lib/loader.d.ts.map
- lib/loader.js
- lib/loader.js.map
- lib/loaderSchema.json
- lib/plugin.d.ts
- lib/plugin.d.ts.map
- lib/plugin.js
- lib/plugin.js.map
- lib/utils/ast/accessSafe.d.ts
- lib/utils/ast/accessSafe.d.ts.map
- lib/utils/ast/accessSafe.js
- lib/utils/ast/accessSafe.js.map
- lib/utils/ast/evaluateAstNode.d.ts
- lib/utils/ast/evaluateAstNode.d.ts.map
- lib/utils/ast/evaluateAstNode.js
- lib/utils/ast/evaluateAstNode.js.map
- lib/utils/ast/extractStaticTernaries.d.ts
- lib/utils/ast/extractStaticTernaries.d.ts.map
- lib/utils/ast/extractStaticTernaries.js
- lib/utils/ast/extractStaticTernaries.js.map
- lib/utils/ast/extractStyles.d.ts
- lib/utils/ast/extractStyles.d.ts.map
- lib/utils/ast/extractStyles.js
- lib/utils/ast/extractStyles.js.map
- lib/utils/ast/generatedUid.d.ts
- lib/utils/ast/generatedUid.d.ts.map
- lib/utils/ast/generatedUid.js
- lib/utils/ast/generatedUid.js.map
- lib/utils/ast/getPropValueFromAttributes.d.ts
- lib/utils/ast/getPropValueFromAttributes.d.ts.map
- lib/utils/ast/getPropValueFromAttributes.js
- lib/utils/ast/getPropValueFromAttributes.js.map
- lib/utils/ast/getSourceModule.d.ts
- lib/utils/ast/getSourceModule.d.ts.map
- lib/utils/ast/getSourceModule.js
- lib/utils/ast/getSourceModule.js.map
- lib/utils/ast/getStaticBindingsForScope.d.ts
- lib/utils/ast/getStaticBindingsForScope.d.ts.map
- lib/utils/ast/getStaticBindingsForScope.js
- lib/utils/ast/getStaticBindingsForScope.js.map
- lib/utils/ast/parse.d.ts
- lib/utils/ast/parse.d.ts.map
- lib/utils/ast/parse.js
- lib/utils/ast/parse.js.map
- lib/utils/getClassNameFromCache.d.ts
- lib/utils/getClassNameFromCache.d.ts.map
- lib/utils/getClassNameFromCache.js
- lib/utils/getClassNameFromCache.js.map
- lib/utils/getStylesByClassName.d.ts
- lib/utils/getStylesByClassName.d.ts.map
- lib/utils/getStylesByClassName.js
- lib/utils/getStylesByClassName.js.map
- lib/utils/wrapFileSystem.d.ts
- lib/utils/wrapFileSystem.d.ts.map
- lib/utils/wrapFileSystem.js
- lib/utils/wrapFileSystem.js.map
",
]
`;
| {
"pile_set_name": "Github"
} |
-- $Id: vararg.lua,v 1.25 2016/11/07 13:11:28 roberto Exp $
-- See Copyright Notice in file all.lua
print('testing vararg')
function f(a, ...)
local arg = {n = select('#', ...), ...}
for i=1,arg.n do assert(a[i]==arg[i]) end
return arg.n
end
function c12 (...)
assert(arg == _G.arg) -- no local 'arg'
local x = {...}; x.n = #x
local res = (x.n==2 and x[1] == 1 and x[2] == 2)
if res then res = 55 end
return res, 2
end
function vararg (...) return {n = select('#', ...), ...} end
local call = function (f, args) return f(table.unpack(args, 1, args.n)) end
assert(f() == 0)
assert(f({1,2,3}, 1, 2, 3) == 3)
assert(f({"alo", nil, 45, f, nil}, "alo", nil, 45, f, nil) == 5)
assert(c12(1,2)==55)
a,b = assert(call(c12, {1,2}))
assert(a == 55 and b == 2)
a = call(c12, {1,2;n=2})
assert(a == 55 and b == 2)
a = call(c12, {1,2;n=1})
assert(not a)
assert(c12(1,2,3) == false)
local a = vararg(call(next, {_G,nil;n=2}))
local b,c = next(_G)
assert(a[1] == b and a[2] == c and a.n == 2)
a = vararg(call(call, {c12, {1,2}}))
assert(a.n == 2 and a[1] == 55 and a[2] == 2)
a = call(print, {'+'})
assert(a == nil)
local t = {1, 10}
function t:f (...) local arg = {...}; return self[...]+#arg end
assert(t:f(1,4) == 3 and t:f(2) == 11)
print('+')
lim = 20
local i, a = 1, {}
while i <= lim do a[i] = i+0.3; i=i+1 end
function f(a, b, c, d, ...)
local more = {...}
assert(a == 1.3 and more[1] == 5.3 and
more[lim-4] == lim+0.3 and not more[lim-3])
end
function g(a,b,c)
assert(a == 1.3 and b == 2.3 and c == 3.3)
end
call(f, a)
call(g, a)
a = {}
i = 1
while i <= lim do a[i] = i; i=i+1 end
assert(call(math.max, a) == lim)
print("+")
-- new-style varargs
function oneless (a, ...) return ... end
function f (n, a, ...)
local b
assert(arg == _G.arg) -- no local 'arg'
if n == 0 then
local b, c, d = ...
return a, b, c, d, oneless(oneless(oneless(...)))
else
n, b, a = n-1, ..., a
assert(b == ...)
return f(n, a, ...)
end
end
a,b,c,d,e = assert(f(10,5,4,3,2,1))
assert(a==5 and b==4 and c==3 and d==2 and e==1)
a,b,c,d,e = f(4)
assert(a==nil and b==nil and c==nil and d==nil and e==nil)
-- varargs for main chunks
f = load[[ return {...} ]]
x = f(2,3)
assert(x[1] == 2 and x[2] == 3 and x[3] == nil)
f = load[[
local x = {...}
for i=1,select('#', ...) do assert(x[i] == select(i, ...)) end
assert(x[select('#', ...)+1] == nil)
return true
]]
assert(f("a", "b", nil, {}, assert))
assert(f())
a = {select(3, table.unpack{10,20,30,40})}
assert(#a == 2 and a[1] == 30 and a[2] == 40)
a = {select(1)}
assert(next(a) == nil)
a = {select(-1, 3, 5, 7)}
assert(a[1] == 7 and a[2] == nil)
a = {select(-2, 3, 5, 7)}
assert(a[1] == 5 and a[2] == 7 and a[3] == nil)
pcall(select, 10000)
pcall(select, -10000)
-- bug in 5.2.2
function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
p11, p12, p13, p14, p15, p16, p17, p18, p19, p20,
p21, p22, p23, p24, p25, p26, p27, p28, p29, p30,
p31, p32, p33, p34, p35, p36, p37, p38, p39, p40,
p41, p42, p43, p44, p45, p46, p48, p49, p50, ...)
local a1,a2,a3,a4,a5,a6,a7
local a8,a9,a10,a11,a12,a13,a14
end
-- assertion fail here
f()
print('OK')
| {
"pile_set_name": "Github"
} |
#!/bin/sh
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2020 Datadog, Inc.
# Builds Datadogpy layers for lambda functions, using Docker
set -e
# Change to the parent of the directory this script is in
cd $(dirname "$0")/..
docker build -t datadog-go-layer . --build-arg runtime=python:3.7
docker run datadog-go-layer go test -v ./...
| {
"pile_set_name": "Github"
} |
/*
* at91-ssc.c -- ALSA SoC AT91 SSC Audio Layer Platform driver
*
* Author: Frank Mandarino <fmandarino@endrelia.com>
* Endrelia Technologies Inc.
*
* Based on pxa2xx Platform drivers by
* Liam Girdwood <liam.girdwood@wolfsonmicro.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/clk.h>
#include <linux/atmel_pdc.h>
#include <sound/driver.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/initval.h>
#include <sound/soc.h>
#include <asm/arch/hardware.h>
#include <asm/arch/at91_pmc.h>
#include <asm/arch/at91_ssc.h>
#include "at91-pcm.h"
#include "at91-ssc.h"
#if 0
#define DBG(x...) printk(KERN_DEBUG "at91-ssc:" x)
#else
#define DBG(x...)
#endif
#if defined(CONFIG_ARCH_AT91SAM9260)
#define NUM_SSC_DEVICES 1
#else
#define NUM_SSC_DEVICES 3
#endif
/*
* SSC PDC registers required by the PCM DMA engine.
*/
static struct at91_pdc_regs pdc_tx_reg = {
.xpr = ATMEL_PDC_TPR,
.xcr = ATMEL_PDC_TCR,
.xnpr = ATMEL_PDC_TNPR,
.xncr = ATMEL_PDC_TNCR,
};
static struct at91_pdc_regs pdc_rx_reg = {
.xpr = ATMEL_PDC_RPR,
.xcr = ATMEL_PDC_RCR,
.xnpr = ATMEL_PDC_RNPR,
.xncr = ATMEL_PDC_RNCR,
};
/*
* SSC & PDC status bits for transmit and receive.
*/
static struct at91_ssc_mask ssc_tx_mask = {
.ssc_enable = AT91_SSC_TXEN,
.ssc_disable = AT91_SSC_TXDIS,
.ssc_endx = AT91_SSC_ENDTX,
.ssc_endbuf = AT91_SSC_TXBUFE,
.pdc_enable = ATMEL_PDC_TXTEN,
.pdc_disable = ATMEL_PDC_TXTDIS,
};
static struct at91_ssc_mask ssc_rx_mask = {
.ssc_enable = AT91_SSC_RXEN,
.ssc_disable = AT91_SSC_RXDIS,
.ssc_endx = AT91_SSC_ENDRX,
.ssc_endbuf = AT91_SSC_RXBUFF,
.pdc_enable = ATMEL_PDC_RXTEN,
.pdc_disable = ATMEL_PDC_RXTDIS,
};
/*
* DMA parameters.
*/
static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
{{
.name = "SSC0 PCM out",
.pdc = &pdc_tx_reg,
.mask = &ssc_tx_mask,
},
{
.name = "SSC0 PCM in",
.pdc = &pdc_rx_reg,
.mask = &ssc_rx_mask,
}},
#if NUM_SSC_DEVICES == 3
{{
.name = "SSC1 PCM out",
.pdc = &pdc_tx_reg,
.mask = &ssc_tx_mask,
},
{
.name = "SSC1 PCM in",
.pdc = &pdc_rx_reg,
.mask = &ssc_rx_mask,
}},
{{
.name = "SSC2 PCM out",
.pdc = &pdc_tx_reg,
.mask = &ssc_tx_mask,
},
{
.name = "SSC2 PCM in",
.pdc = &pdc_rx_reg,
.mask = &ssc_rx_mask,
}},
#endif
};
struct at91_ssc_state {
u32 ssc_cmr;
u32 ssc_rcmr;
u32 ssc_rfmr;
u32 ssc_tcmr;
u32 ssc_tfmr;
u32 ssc_sr;
u32 ssc_imr;
};
static struct at91_ssc_info {
char *name;
struct at91_ssc_periph ssc;
spinlock_t lock; /* lock for dir_mask */
unsigned short dir_mask; /* 0=unused, 1=playback, 2=capture */
unsigned short initialized; /* 1=SSC has been initialized */
unsigned short daifmt;
unsigned short cmr_div;
unsigned short tcmr_period;
unsigned short rcmr_period;
struct at91_pcm_dma_params *dma_params[2];
struct at91_ssc_state ssc_state;
} ssc_info[NUM_SSC_DEVICES] = {
{
.name = "ssc0",
.lock = __SPIN_LOCK_UNLOCKED(ssc_info[0].lock),
.dir_mask = 0,
.initialized = 0,
},
#if NUM_SSC_DEVICES == 3
{
.name = "ssc1",
.lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock),
.dir_mask = 0,
.initialized = 0,
},
{
.name = "ssc2",
.lock = __SPIN_LOCK_UNLOCKED(ssc_info[2].lock),
.dir_mask = 0,
.initialized = 0,
},
#endif
};
static unsigned int at91_ssc_sysclk;
/*
* SSC interrupt handler. Passes PDC interrupts to the DMA
* interrupt handler in the PCM driver.
*/
static irqreturn_t at91_ssc_interrupt(int irq, void *dev_id)
{
struct at91_ssc_info *ssc_p = dev_id;
struct at91_pcm_dma_params *dma_params;
u32 ssc_sr;
int i;
ssc_sr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR)
& at91_ssc_read(ssc_p->ssc.base + AT91_SSC_IMR);
/*
* Loop through the substreams attached to this SSC. If
* a DMA-related interrupt occurred on that substream, call
* the DMA interrupt handler function, if one has been
* registered in the dma_params structure by the PCM driver.
*/
for (i = 0; i < ARRAY_SIZE(ssc_p->dma_params); i++) {
dma_params = ssc_p->dma_params[i];
if (dma_params != NULL && dma_params->dma_intr_handler != NULL &&
(ssc_sr &
(dma_params->mask->ssc_endx | dma_params->mask->ssc_endbuf)))
dma_params->dma_intr_handler(ssc_sr, dma_params->substream);
}
return IRQ_HANDLED;
}
/*
* Startup. Only that one substream allowed in each direction.
*/
static int at91_ssc_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
int dir_mask;
DBG("ssc_startup: SSC_SR=0x%08lx\n",
at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR));
dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2;
spin_lock_irq(&ssc_p->lock);
if (ssc_p->dir_mask & dir_mask) {
spin_unlock_irq(&ssc_p->lock);
return -EBUSY;
}
ssc_p->dir_mask |= dir_mask;
spin_unlock_irq(&ssc_p->lock);
return 0;
}
/*
* Shutdown. Clear DMA parameters and shutdown the SSC if there
* are no other substreams open.
*/
static void at91_ssc_shutdown(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
struct at91_pcm_dma_params *dma_params;
int dir, dir_mask;
dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
dma_params = ssc_p->dma_params[dir];
if (dma_params != NULL) {
at91_ssc_write(dma_params->ssc_base + AT91_SSC_CR,
dma_params->mask->ssc_disable);
DBG("%s disabled SSC_SR=0x%08lx\n", (dir ? "receive" : "transmit"),
at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR));
dma_params->ssc_base = NULL;
dma_params->substream = NULL;
ssc_p->dma_params[dir] = NULL;
}
dir_mask = 1 << dir;
spin_lock_irq(&ssc_p->lock);
ssc_p->dir_mask &= ~dir_mask;
if (!ssc_p->dir_mask) {
/* Shutdown the SSC clock. */
DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
at91_sys_write(AT91_PMC_PCDR, 1<<ssc_p->ssc.pid);
if (ssc_p->initialized) {
free_irq(ssc_p->ssc.pid, ssc_p);
ssc_p->initialized = 0;
}
/* Reset the SSC */
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, AT91_SSC_SWRST);
/* Clear the SSC dividers */
ssc_p->cmr_div = ssc_p->tcmr_period = ssc_p->rcmr_period = 0;
}
spin_unlock_irq(&ssc_p->lock);
}
/*
* Record the SSC system clock rate.
*/
static int at91_ssc_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
int clk_id, unsigned int freq, int dir)
{
/*
* The only clock supplied to the SSC is the AT91 master clock,
* which is only used if the SSC is generating BCLK and/or
* LRC clocks.
*/
switch (clk_id) {
case AT91_SYSCLK_MCK:
at91_ssc_sysclk = freq;
break;
default:
return -EINVAL;
}
return 0;
}
/*
* Record the DAI format for use in hw_params().
*/
static int at91_ssc_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
unsigned int fmt)
{
struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
ssc_p->daifmt = fmt;
return 0;
}
/*
* Record SSC clock dividers for use in hw_params().
*/
static int at91_ssc_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
int div_id, int div)
{
struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
switch (div_id) {
case AT91SSC_CMR_DIV:
/*
* The same master clock divider is used for both
* transmit and receive, so if a value has already
* been set, it must match this value.
*/
if (ssc_p->cmr_div == 0)
ssc_p->cmr_div = div;
else
if (div != ssc_p->cmr_div)
return -EBUSY;
break;
case AT91SSC_TCMR_PERIOD:
ssc_p->tcmr_period = div;
break;
case AT91SSC_RCMR_PERIOD:
ssc_p->rcmr_period = div;
break;
default:
return -EINVAL;
}
return 0;
}
/*
* Configure the SSC.
*/
static int at91_ssc_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
int id = rtd->dai->cpu_dai->id;
struct at91_ssc_info *ssc_p = &ssc_info[id];
struct at91_pcm_dma_params *dma_params;
int dir, channels, bits;
u32 tfmr, rfmr, tcmr, rcmr;
int start_event;
int ret;
/*
* Currently, there is only one set of dma params for
* each direction. If more are added, this code will
* have to be changed to select the proper set.
*/
dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
dma_params = &ssc_dma_params[id][dir];
dma_params->ssc_base = ssc_p->ssc.base;
dma_params->substream = substream;
ssc_p->dma_params[dir] = dma_params;
/*
* The cpu_dai->dma_data field is only used to communicate the
* appropriate DMA parameters to the pcm driver hw_params()
* function. It should not be used for other purposes
* as it is common to all substreams.
*/
rtd->dai->cpu_dai->dma_data = dma_params;
channels = params_channels(params);
/*
* Determine sample size in bits and the PDC increment.
*/
switch(params_format(params)) {
case SNDRV_PCM_FORMAT_S8:
bits = 8;
dma_params->pdc_xfer_size = 1;
break;
case SNDRV_PCM_FORMAT_S16_LE:
bits = 16;
dma_params->pdc_xfer_size = 2;
break;
case SNDRV_PCM_FORMAT_S24_LE:
bits = 24;
dma_params->pdc_xfer_size = 4;
break;
case SNDRV_PCM_FORMAT_S32_LE:
bits = 32;
dma_params->pdc_xfer_size = 4;
break;
default:
printk(KERN_WARNING "at91-ssc: unsupported PCM format");
return -EINVAL;
}
/*
* The SSC only supports up to 16-bit samples in I2S format, due
* to the size of the Frame Mode Register FSLEN field.
*/
if ((ssc_p->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S
&& bits > 16) {
printk(KERN_WARNING
"at91-ssc: sample size %d is too large for I2S\n", bits);
return -EINVAL;
}
/*
* Compute SSC register settings.
*/
switch (ssc_p->daifmt
& (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_MASTER_MASK)) {
case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS:
/*
* I2S format, SSC provides BCLK and LRC clocks.
*
* The SSC transmit and receive clocks are generated from the
* MCK divider, and the BCLK signal is output on the SSC TK line.
*/
rcmr = (( ssc_p->rcmr_period << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY)
| (( AT91_SSC_START_FALLING_RF ) & AT91_SSC_START)
| (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
| (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO)
| (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
rfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
| (( AT91_SSC_FSOS_NEGATIVE ) & AT91_SSC_FSOS)
| (((bits - 1) << 16) & AT91_SSC_FSLEN)
| (((channels - 1) << 8) & AT91_SSC_DATNB)
| (( 1 << 7) & AT91_SSC_MSBF)
| (( 0 << 5) & AT91_SSC_LOOP)
| (((bits - 1) << 0) & AT91_SSC_DATALEN);
tcmr = (( ssc_p->tcmr_period << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY)
| (( AT91_SSC_START_FALLING_RF ) & AT91_SSC_START)
| (( AT91_SSC_CKI_FALLING ) & AT91_SSC_CKI)
| (( AT91_SSC_CKO_CONTINUOUS ) & AT91_SSC_CKO)
| (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
tfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
| (( 0 << 23) & AT91_SSC_FSDEN)
| (( AT91_SSC_FSOS_NEGATIVE ) & AT91_SSC_FSOS)
| (((bits - 1) << 16) & AT91_SSC_FSLEN)
| (((channels - 1) << 8) & AT91_SSC_DATNB)
| (( 1 << 7) & AT91_SSC_MSBF)
| (( 0 << 5) & AT91_SSC_DATDEF)
| (((bits - 1) << 0) & AT91_SSC_DATALEN);
break;
case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM:
/*
* I2S format, CODEC supplies BCLK and LRC clocks.
*
* The SSC transmit clock is obtained from the BCLK signal on
* on the TK line, and the SSC receive clock is generated from the
* transmit clock.
*
* For single channel data, one sample is transferred on the falling
* edge of the LRC clock. For two channel data, one sample is
* transferred on both edges of the LRC clock.
*/
start_event = channels == 1
? AT91_SSC_START_FALLING_RF
: AT91_SSC_START_EDGE_RF;
rcmr = (( 0 << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY)
| (( start_event ) & AT91_SSC_START)
| (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
| (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO)
| (( AT91_SSC_CKS_CLOCK ) & AT91_SSC_CKS);
rfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
| (( AT91_SSC_FSOS_NONE ) & AT91_SSC_FSOS)
| (( 0 << 16) & AT91_SSC_FSLEN)
| (( 0 << 8) & AT91_SSC_DATNB)
| (( 1 << 7) & AT91_SSC_MSBF)
| (( 0 << 5) & AT91_SSC_LOOP)
| (((bits - 1) << 0) & AT91_SSC_DATALEN);
tcmr = (( 0 << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY)
| (( start_event ) & AT91_SSC_START)
| (( AT91_SSC_CKI_FALLING ) & AT91_SSC_CKI)
| (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO)
| (( AT91_SSC_CKS_PIN ) & AT91_SSC_CKS);
tfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
| (( 0 << 23) & AT91_SSC_FSDEN)
| (( AT91_SSC_FSOS_NONE ) & AT91_SSC_FSOS)
| (( 0 << 16) & AT91_SSC_FSLEN)
| (( 0 << 8) & AT91_SSC_DATNB)
| (( 1 << 7) & AT91_SSC_MSBF)
| (( 0 << 5) & AT91_SSC_DATDEF)
| (((bits - 1) << 0) & AT91_SSC_DATALEN);
break;
case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS:
/*
* DSP/PCM Mode A format, SSC provides BCLK and LRC clocks.
*
* The SSC transmit and receive clocks are generated from the
* MCK divider, and the BCLK signal is output on the SSC TK line.
*/
rcmr = (( ssc_p->rcmr_period << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY)
| (( AT91_SSC_START_RISING_RF ) & AT91_SSC_START)
| (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
| (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO)
| (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
rfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
| (( AT91_SSC_FSOS_POSITIVE ) & AT91_SSC_FSOS)
| (( 0 << 16) & AT91_SSC_FSLEN)
| (((channels - 1) << 8) & AT91_SSC_DATNB)
| (( 1 << 7) & AT91_SSC_MSBF)
| (( 0 << 5) & AT91_SSC_LOOP)
| (((bits - 1) << 0) & AT91_SSC_DATALEN);
tcmr = (( ssc_p->tcmr_period << 24) & AT91_SSC_PERIOD)
| (( 1 << 16) & AT91_SSC_STTDLY)
| (( AT91_SSC_START_RISING_RF ) & AT91_SSC_START)
| (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
| (( AT91_SSC_CKO_CONTINUOUS ) & AT91_SSC_CKO)
| (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
tfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
| (( 0 << 23) & AT91_SSC_FSDEN)
| (( AT91_SSC_FSOS_POSITIVE ) & AT91_SSC_FSOS)
| (( 0 << 16) & AT91_SSC_FSLEN)
| (((channels - 1) << 8) & AT91_SSC_DATNB)
| (( 1 << 7) & AT91_SSC_MSBF)
| (( 0 << 5) & AT91_SSC_DATDEF)
| (((bits - 1) << 0) & AT91_SSC_DATALEN);
break;
case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBM_CFM:
default:
printk(KERN_WARNING "at91-ssc: unsupported DAI format 0x%x.\n",
ssc_p->daifmt);
return -EINVAL;
break;
}
DBG("RCMR=%08x RFMR=%08x TCMR=%08x TFMR=%08x\n", rcmr, rfmr, tcmr, tfmr);
if (!ssc_p->initialized) {
/* Enable PMC peripheral clock for this SSC */
DBG("Starting pid %d clock\n", ssc_p->ssc.pid);
at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid);
/* Reset the SSC and its PDC registers */
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR, AT91_SSC_SWRST);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_RPR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_RCR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_RNPR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_RNCR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TPR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TCR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNPR, 0);
at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNCR, 0);
if ((ret = request_irq(ssc_p->ssc.pid, at91_ssc_interrupt,
0, ssc_p->name, ssc_p)) < 0) {
printk(KERN_WARNING "at91-ssc: request_irq failure\n");
DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid);
return ret;
}
ssc_p->initialized = 1;
}
/* set SSC clock mode register */
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CMR, ssc_p->cmr_div);
/* set receive clock mode and format */
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, rcmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RFMR, rfmr);
/* set transmit clock mode and format */
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TCMR, tcmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TFMR, tfmr);
DBG("hw_params: SSC initialized\n");
return 0;
}
static int at91_ssc_prepare(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
struct at91_pcm_dma_params *dma_params;
int dir;
dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1;
dma_params = ssc_p->dma_params[dir];
at91_ssc_write(dma_params->ssc_base + AT91_SSC_CR,
dma_params->mask->ssc_enable);
DBG("%s enabled SSC_SR=0x%08lx\n", dir ? "receive" : "transmit",
at91_ssc_read(dma_params->ssc_base + AT91_SSC_SR));
return 0;
}
#ifdef CONFIG_PM
static int at91_ssc_suspend(struct platform_device *pdev,
struct snd_soc_cpu_dai *cpu_dai)
{
struct at91_ssc_info *ssc_p;
if(!cpu_dai->active)
return 0;
ssc_p = &ssc_info[cpu_dai->id];
/* Save the status register before disabling transmit and receive. */
ssc_p->ssc_state.ssc_sr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR,
AT91_SSC_TXDIS | AT91_SSC_RXDIS);
/* Save the current interrupt mask, then disable unmasked interrupts. */
ssc_p->ssc_state.ssc_imr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_IMR);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_IDR, ssc_p->ssc_state.ssc_imr);
ssc_p->ssc_state.ssc_cmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_CMR);
ssc_p->ssc_state.ssc_rcmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RCMR);
ssc_p->ssc_state.ssc_rfmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_RFMR);
ssc_p->ssc_state.ssc_tcmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_TCMR);
ssc_p->ssc_state.ssc_tfmr = at91_ssc_read(ssc_p->ssc.base + AT91_SSC_TFMR);
return 0;
}
static int at91_ssc_resume(struct platform_device *pdev,
struct snd_soc_cpu_dai *cpu_dai)
{
struct at91_ssc_info *ssc_p;
if(!cpu_dai->active)
return 0;
ssc_p = &ssc_info[cpu_dai->id];
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TFMR, ssc_p->ssc_state.ssc_tfmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_TCMR, ssc_p->ssc_state.ssc_tcmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RFMR, ssc_p->ssc_state.ssc_rfmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_RCMR, ssc_p->ssc_state.ssc_rcmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CMR, ssc_p->ssc_state.ssc_cmr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_IER, ssc_p->ssc_state.ssc_imr);
at91_ssc_write(ssc_p->ssc.base + AT91_SSC_CR,
((ssc_p->ssc_state.ssc_sr & AT91_SSC_RXENA) ? AT91_SSC_RXEN : 0) |
((ssc_p->ssc_state.ssc_sr & AT91_SSC_TXENA) ? AT91_SSC_TXEN : 0));
return 0;
}
#else
#define at91_ssc_suspend NULL
#define at91_ssc_resume NULL
#endif
#define AT91_SSC_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
SNDRV_PCM_RATE_96000)
#define AT91_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
struct snd_soc_cpu_dai at91_ssc_dai[NUM_SSC_DEVICES] = {
{ .name = "at91-ssc0",
.id = 0,
.type = SND_SOC_DAI_PCM,
.suspend = at91_ssc_suspend,
.resume = at91_ssc_resume,
.playback = {
.channels_min = 1,
.channels_max = 2,
.rates = AT91_SSC_RATES,
.formats = AT91_SSC_FORMATS,},
.capture = {
.channels_min = 1,
.channels_max = 2,
.rates = AT91_SSC_RATES,
.formats = AT91_SSC_FORMATS,},
.ops = {
.startup = at91_ssc_startup,
.shutdown = at91_ssc_shutdown,
.prepare = at91_ssc_prepare,
.hw_params = at91_ssc_hw_params,},
.dai_ops = {
.set_sysclk = at91_ssc_set_dai_sysclk,
.set_fmt = at91_ssc_set_dai_fmt,
.set_clkdiv = at91_ssc_set_dai_clkdiv,},
.private_data = &ssc_info[0].ssc,
},
#if NUM_SSC_DEVICES == 3
{ .name = "at91-ssc1",
.id = 1,
.type = SND_SOC_DAI_PCM,
.suspend = at91_ssc_suspend,
.resume = at91_ssc_resume,
.playback = {
.channels_min = 1,
.channels_max = 2,
.rates = AT91_SSC_RATES,
.formats = AT91_SSC_FORMATS,},
.capture = {
.channels_min = 1,
.channels_max = 2,
.rates = AT91_SSC_RATES,
.formats = AT91_SSC_FORMATS,},
.ops = {
.startup = at91_ssc_startup,
.shutdown = at91_ssc_shutdown,
.prepare = at91_ssc_prepare,
.hw_params = at91_ssc_hw_params,},
.dai_ops = {
.set_sysclk = at91_ssc_set_dai_sysclk,
.set_fmt = at91_ssc_set_dai_fmt,
.set_clkdiv = at91_ssc_set_dai_clkdiv,},
.private_data = &ssc_info[1].ssc,
},
{ .name = "at91-ssc2",
.id = 2,
.type = SND_SOC_DAI_PCM,
.suspend = at91_ssc_suspend,
.resume = at91_ssc_resume,
.playback = {
.channels_min = 1,
.channels_max = 2,
.rates = AT91_SSC_RATES,
.formats = AT91_SSC_FORMATS,},
.capture = {
.channels_min = 1,
.channels_max = 2,
.rates = AT91_SSC_RATES,
.formats = AT91_SSC_FORMATS,},
.ops = {
.startup = at91_ssc_startup,
.shutdown = at91_ssc_shutdown,
.prepare = at91_ssc_prepare,
.hw_params = at91_ssc_hw_params,},
.dai_ops = {
.set_sysclk = at91_ssc_set_dai_sysclk,
.set_fmt = at91_ssc_set_dai_fmt,
.set_clkdiv = at91_ssc_set_dai_clkdiv,},
.private_data = &ssc_info[2].ssc,
},
#endif
};
EXPORT_SYMBOL_GPL(at91_ssc_dai);
/* Module information */
MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com");
MODULE_DESCRIPTION("AT91 SSC ASoC Interface");
MODULE_LICENSE("GPL");
| {
"pile_set_name": "Github"
} |
# $NetBSD: varmod-localtime.mk,v 1.3 2020/08/23 15:13:21 rillig Exp $
#
# Tests for the :localtime variable modifier, which returns the given time,
# formatted as a local timestamp.
all:
@echo ${%Y:L:localtim=1593536400} # modifier name too short
@echo ${%Y:L:localtime=1593536400} # 2020-07-01T00:00:00Z
@echo ${%Y:L:localtimer=1593536400} # modifier name too long
| {
"pile_set_name": "Github"
} |
package br.com.swconsultoria.nfe.schema_4.retConsSitNFe;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* <p>Classe Java de KeyInfoType complex type.
*
* <p>O seguinte fragmento do esquema especifica o contedo esperado contido dentro desta classe.
*
* <pre>
* <complexType name="KeyInfoType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="X509Data" type="{http://www.w3.org/2000/09/xmldsig#}X509DataType"/>
* </sequence>
* <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "KeyInfoType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = {
"x509Data"
})
public class KeyInfoType {
@XmlElement(name = "X509Data", namespace = "http://www.w3.org/2000/09/xmldsig#", required = true)
protected X509DataType x509Data;
@XmlAttribute(name = "Id")
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlID
@XmlSchemaType(name = "ID")
protected String id;
/**
* Obtm o valor da propriedade x509Data.
*
* @return
* possible object is
* {@link X509DataType }
*
*/
public X509DataType getX509Data() {
return x509Data;
}
/**
* Define o valor da propriedade x509Data.
*
* @param value
* allowed object is
* {@link X509DataType }
*
*/
public void setX509Data(X509DataType value) {
this.x509Data = value;
}
/**
* Obtm o valor da propriedade id.
*
* @return
* possible object is
* {@link String }
*
*/
public String getId() {
return id;
}
/**
* Define o valor da propriedade id.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setId(String value) {
this.id = value;
}
}
| {
"pile_set_name": "Github"
} |
// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
//
#ifndef CGAL_COMBINATORIAL_MAP_SEWABLE_H
#define CGAL_COMBINATORIAL_MAP_SEWABLE_H
#include <CGAL/Dart_const_iterators.h>
#include <CGAL/Unique_hash_map.h>
/* Definition of functor used to test if two darts are i-sewable
* (we use functors as there are different specializations).
*/
namespace CGAL
{
#define CGAL_BETAINV(i) (i>1?i:(i==1?0:1))
namespace internal
{
// Generic case for 1<=i<=dimension, and 3<dim.
template<typename CMap, unsigned int i, unsigned int dim=CMap::dimension>
struct Is_sewable_functor
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
CGAL_assertion( 1<=i && i<=CMap::dimension );
CGAL_assertion( 3<dim );
if ( !amap->template is_free<i>(adart1) ||
!amap->template is_free<CGAL_BETAINV(i)>(adart2) )
return false;
if ( adart1==adart2 )
{
if ( i==1 ) return true;
return false;
}
// hash map to build the isomorphism between the two i-cells.
CGAL::Unique_hash_map<typename CMap::Dart_const_handle,
typename CMap::Dart_const_handle,
typename CMap::Hash_function> bijection;
typename CMap::size_type m1 = amap->get_new_mark();
typename CMap::size_type m2 = amap->get_new_mark();
CGAL::CMap_dart_const_iterator_basic_of_involution<CMap,i>
I1(*amap, adart1, m1);
CGAL::CMap_dart_const_iterator_basic_of_involution_inv<CMap,i>
I2(*amap, adart2, m2);
bool res = true;
typename CMap::size_type mbijection = amap->get_new_mark();
while ( res && I1.cont() && I2.cont() )
{
amap->mark(I1, mbijection);
bijection[I1]=I2;
CGAL_assertion( amap->template is_free<i>(I1) );
CGAL_assertion( amap->template is_free<CGAL_BETAINV(i)>(I2) );
// We can remove this constraint which is not required for
// combinatorial map definition, but which is quite "normal"
// Indeed in this case we try to i-sew an i-cell with itself (case
// of folded cells).
if ( i>1 && (I1==adart2 || I2==adart1) ) res=false;
if ( i>2)
{
if ( amap->template is_free<1>(I1) )
{
if ( !amap->template is_free<0>(I2) ) res=false;
}
else
{
if ( amap->template is_free<0>(I2) ) res=false;
else if ( amap->is_marked(amap->template beta<1>(I1), mbijection) )
{
if ( bijection[amap->template beta<1>(I1)]!=
amap->template beta<0>(I2) )
res=false;
}
}
}
for ( unsigned int j=2; res && j<=CMap::dimension; ++j )
{
if ( j+1!=i && j!=i && j!=i+1 )
{
if ( amap->is_free(I1,j) )
{
if ( !amap->is_free(I2,j) ) res=false;
}
else
{
if ( amap->is_free(I2,j) ) res=false;
else if ( amap->is_marked(amap->beta(I1,j), mbijection) )
{
if ( bijection[amap->beta(I1,j)]!=amap->beta(I2,j) ) res=false;
}
}
}
}
++I1; ++I2;
}
if ( I1.cont()!=I2.cont() )
res = false;
amap->negate_mark(m1);
amap->negate_mark(m2);
I1.rewind(); I2.rewind();
while ( amap->number_of_marked_darts(mbijection)>0 )
{
amap->unmark(I1, mbijection);
++I1; ++I2;
}
CGAL_assertion( amap->is_whole_map_marked(m1) );
CGAL_assertion( amap->is_whole_map_marked(m2) );
CGAL_assertion( amap->is_whole_map_unmarked(mbijection) );
amap->free_mark(m1);
amap->free_mark(m2);
amap->free_mark(mbijection);
return res;
}
};
// Specialization for i=0 and 3<dim.
template<typename CMap, unsigned int dim>
struct Is_sewable_functor<CMap, 0, dim>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{ return Is_sewable_functor<CMap,1, dim>::run(amap, adart2, adart1); }
};
// Specialization for i=0 and dim=1.
template<typename CMap>
struct Is_sewable_functor<CMap, 0, 1>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<0>(adart1) ||
!amap->template is_free<1>(adart2) )
return false;
return true;
}
};
// Specialization for i=1 and dim=1.
template<typename CMap>
struct Is_sewable_functor<CMap, 1, 1>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<1>(adart1) ||
!amap->template is_free<0>(adart2) )
return false;
return true;
}
};
// Specialization for i=0 and dim=2.
template<typename CMap>
struct Is_sewable_functor<CMap, 0, 2>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<0>(adart1) ||
!amap->template is_free<1>(adart2) )
return false;
return true;
}
};
// Specialization for i=1 and dim=2.
template<typename CMap>
struct Is_sewable_functor<CMap, 1, 2>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<1>(adart1) ||
!amap->template is_free<0>(adart2) )
return false;
return true;
}
};
// Specialization for i=2 and dim=2.
template<typename CMap>
struct Is_sewable_functor<CMap, 2, 2>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<2>(adart1) ||
!amap->template is_free<2>(adart2) || adart1==adart2 )
return false;
return true;
}
};
// Specialization for i=0 and dim=3.
template<typename CMap>
struct Is_sewable_functor<CMap, 0, 3>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<0>(adart1) ||
!amap->template is_free<1>(adart2) )
return false;
if ( amap->template is_free<3>(adart1) )
{
if ( !amap->template is_free<3>(adart2) ) return false;
return true;
}
// Here adart1 is not 3-free
if ( amap->template is_free<3>(adart2) ) return false;
CGAL_assertion( amap->template is_free<1>(amap->template beta<3>(adart1)) &&
amap->template is_free<0>(amap->template beta<3>(adart2)) );
return true;
}
};
// Specialization for i=1 and dim=3.
template<typename CMap>
struct Is_sewable_functor<CMap, 1, 3>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<1>(adart1) ||
!amap->template is_free<0>(adart2) )
return false;
if ( amap->template is_free<3>(adart1) )
{
if ( !amap->template is_free<3>(adart2) ) return false;
return true;
}
// Here adart1 is not 3-free
if ( amap->template is_free<3>(adart2) ) return false;
CGAL_assertion( amap->template is_free<0>(amap->template beta<3>(adart1)) &&
amap->template is_free<1>(amap->template beta<3>(adart2)) );
return true;
}
};
// Specialization for i=2 and dim=3.
template<typename CMap>
struct Is_sewable_functor<CMap, 2, 3>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<2>(adart1) ||
!amap->template is_free<2>(adart2) || adart1==adart2 )
return false;
return true;
}
};
// Specialization for i=3 and dim=3.
template<typename CMap>
struct Is_sewable_functor<CMap, 3, 3>
{
static bool run( const CMap* amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2 )
{
if ( !amap->template is_free<3>(adart1) ||
!amap->template is_free<3>(adart2) )
return false;
CGAL::CMap_dart_const_iterator_basic_of_orbit<CMap,1> I1(*amap, adart1);
CGAL::CMap_dart_const_iterator_basic_of_orbit<CMap,0> I2(*amap, adart2);
bool res=true;
while (res && I1.cont() && I2.cont())
{
CGAL_assertion( amap->template is_free<3>(I1) ||
amap->template is_free<3>(I2) );
// We can remove this constraint which is not required for
// combinatorial map definition, but which is quite "normal" as it avoid
// fold cells.
if ( I1==adart2 || I2==adart1 ) res=false;
else if ( I1.prev_operation()!=I2.prev_operation() ) res=false;
++I1; ++I2;
}
if ( I1.cont()!=I2.cont() )
res=false;
return res;
}
};
} //namespace internal
} //namespace CGAL
#endif // CGAL_COMBINATORIAL_MAP_SEWABLE_H
//******************************************************************************
| {
"pile_set_name": "Github"
} |
About Releases 关于发布包
===========
发布包是 Github 打包盒提供软件给用户的方式。可以想象成下载软件的替代品。

发布包提供下载链接和变更说明。
发布基于 [Git 标签](http://git-scm.com/book/en/v2/Git-Basics-Tagging)。标签标明了项目的历史,所以用于发布很不错。发布是通过以下方式标记的日期排列:
* 如果这是一个[注释标签](http://git-scm.com/book/en/Git-Basics-Tagging#Annotated-Tags),使用标签对象的日期。
* 如果它是一个[轻量级的标签](http://git-scm.com/book/en/Git-Basics-Tagging#Lightweight-Tags),使用对象提交的日期。
更多信息可以查看你的标签,详见["和标签工作"](https://github.com/waylau/github-help/blob/master/About%20Releases%20%E5%85%B3%E4%BA%8E%E5%8F%91%E5%B8%83%E5%8C%85.md)
##Limitations on binary files 二进制文件的限制
暂时没有对二进制文件的大小和上传带宽做限制。
*参考*:[https://help.github.com/articles/about-releases/](https://help.github.com/articles/about-releases/)
| {
"pile_set_name": "Github"
} |
# --
# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::CustomerUser::Generic;
use parent 'Kernel::Output::HTML::Base';
use strict;
use warnings;
our $ObjectManagerDisabled = 1;
sub Run {
my ( $Self, %Param ) = @_;
# check required params
my @Params = split /;/, $Param{Config}->{Required};
for my $Key (@Params) {
return if !$Key;
return if !$Param{Data}->{$Key};
}
# get all attributes
@Params = split /;/, $Param{Config}->{Attributes};
# get layout object
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
# build url
my $URL = '';
KEY:
for my $Key (@Params) {
next KEY if !$Param{Data}->{$Key};
if ($URL) {
$URL .= ', ';
}
$URL .= $LayoutObject->LinkEncode( $Param{Data}->{$Key} );
}
$URL = $Param{Config}->{URL} . $URL;
my $IconName = $Param{Config}->{IconName};
# generate block
$LayoutObject->Block(
Name => 'CustomerItemRow',
Data => {
%{ $Param{Config} },
URL => $URL,
IconName => $IconName,
},
);
return 1;
}
1;
| {
"pile_set_name": "Github"
} |
[
{
"name": "Wrap",
"type": "Normal",
"power": 60,
"duration": 2900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Hyper Beam",
"type": "Normal",
"power": 150,
"duration": 3800,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.15,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dark Pulse",
"type": "Dark",
"power": 80,
"duration": 3000,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Sludge",
"type": "Poison",
"power": 50,
"duration": 2100,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Vice Grip",
"type": "Normal",
"power": 35,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.055,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Flame Wheel",
"type": "Fire",
"power": 60,
"duration": 2700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Megahorn",
"type": "Bug",
"power": 90,
"duration": 2200,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.12,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Flamethrower",
"type": "Fire",
"power": 70,
"duration": 2200,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dig",
"type": "Ground",
"power": 100,
"duration": 4700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Cross Chop",
"type": "Fighting",
"power": 50,
"duration": 1500,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.1,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Psybeam",
"type": "Psychic",
"power": 70,
"duration": 3200,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Earthquake",
"type": "Ground",
"power": 120,
"duration": 3600,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.1,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Stone Edge",
"type": "Rock",
"power": 100,
"duration": 2300,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.1,
"critical_chance": 0.5,
"quick": false
},
{
"name": "Ice Punch",
"type": "Ice",
"power": 50,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Heart Stamp",
"type": "Psychic",
"power": 40,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Discharge",
"type": "Electric",
"power": 65,
"duration": 2500,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Flash Cannon",
"type": "Steel",
"power": 100,
"duration": 2700,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Drill Peck",
"type": "Flying",
"power": 60,
"duration": 2300,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Ice Beam",
"type": "Ice",
"power": 90,
"duration": 3300,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Blizzard",
"type": "Ice",
"power": 130,
"duration": 3100,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.11,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Heat Wave",
"type": "Fire",
"power": 95,
"duration": 3000,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.095,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Aerial Ace",
"type": "Flying",
"power": 55,
"duration": 2400,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Drill Run",
"type": "Ground",
"power": 80,
"duration": 2800,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Petal Blizzard",
"type": "Grass",
"power": 110,
"duration": 2600,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Mega Drain",
"type": "Grass",
"power": 25,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Bug Buzz",
"type": "Bug",
"power": 90,
"duration": 3700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Poison Fang",
"type": "Poison",
"power": 35,
"duration": 1700,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.05,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Night Slash",
"type": "Dark",
"power": 50,
"duration": 2200,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.07,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Bubble Beam",
"type": "Water",
"power": 45,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Submission",
"type": "Fighting",
"power": 60,
"duration": 2200,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Low Sweep",
"type": "Fighting",
"power": 40,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Aqua Jet",
"type": "Water",
"power": 45,
"duration": 2600,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Aqua Tail",
"type": "Water",
"power": 50,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Seed Bomb",
"type": "Grass",
"power": 55,
"duration": 2100,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Psyshock",
"type": "Psychic",
"power": 65,
"duration": 2700,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Ancient Power",
"type": "Rock",
"power": 70,
"duration": 3500,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Rock Tomb",
"type": "Rock",
"power": 70,
"duration": 3200,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Rock Slide",
"type": "Rock",
"power": 80,
"duration": 2700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Power Gem",
"type": "Rock",
"power": 80,
"duration": 2900,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Shadow Sneak",
"type": "Ghost",
"power": 50,
"duration": 2900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Shadow Punch",
"type": "Ghost",
"power": 40,
"duration": 1700,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Ominous Wind",
"type": "Ghost",
"power": 50,
"duration": 2300,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Shadow Ball",
"type": "Ghost",
"power": 100,
"duration": 3000,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Magnet Bomb",
"type": "Steel",
"power": 70,
"duration": 2800,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Iron Head",
"type": "Steel",
"power": 60,
"duration": 1900,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Parabolic Charge",
"type": "Electric",
"power": 25,
"duration": 2800,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.05,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Thunder Punch",
"type": "Electric",
"power": 45,
"duration": 1800,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Thunder",
"type": "Electric",
"power": 100,
"duration": 2400,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.11,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Thunderbolt",
"type": "Electric",
"power": 80,
"duration": 2500,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Twister",
"type": "Dragon",
"power": 45,
"duration": 2800,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dragon Pulse",
"type": "Dragon",
"power": 90,
"duration": 3600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.085,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dragon Claw",
"type": "Dragon",
"power": 50,
"duration": 1700,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Disarming Voice",
"type": "Fairy",
"power": 70,
"duration": 3900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Draining Kiss",
"type": "Fairy",
"power": 60,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.05,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dazzling Gleam",
"type": "Fairy",
"power": 100,
"duration": 3500,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Moonblast",
"type": "Fairy",
"power": 130,
"duration": 3900,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.095,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Play Rough",
"type": "Fairy",
"power": 90,
"duration": 2900,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.1,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Cross Poison",
"type": "Poison",
"power": 40,
"duration": 1500,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.07,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Sludge Bomb",
"type": "Poison",
"power": 80,
"duration": 2300,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Sludge Wave",
"type": "Poison",
"power": 110,
"duration": 3200,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.095,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Gunk Shot",
"type": "Poison",
"power": 130,
"duration": 3100,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.12,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Bone Club",
"type": "Ground",
"power": 40,
"duration": 1600,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Bulldoze",
"type": "Ground",
"power": 80,
"duration": 3500,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Mud Bomb",
"type": "Ground",
"power": 55,
"duration": 2300,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Signal Beam",
"type": "Bug",
"power": 75,
"duration": 2900,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.05,
"quick": false
},
{
"name": "X Scissor",
"type": "Bug",
"power": 45,
"duration": 1600,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Flame Charge",
"type": "Fire",
"power": 70,
"duration": 3800,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.05,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Flame Burst",
"type": "Fire",
"power": 70,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.07,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Fire Blast",
"type": "Fire",
"power": 140,
"duration": 4200,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.11,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Brine",
"type": "Water",
"power": 60,
"duration": 2300,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Water Pulse",
"type": "Water",
"power": 70,
"duration": 3200,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Scald",
"type": "Water",
"power": 80,
"duration": 3700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Hydro Pump",
"type": "Water",
"power": 130,
"duration": 3300,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.11,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Psychic",
"type": "Psychic",
"power": 100,
"duration": 2800,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Psystrike",
"type": "Psychic",
"power": 100,
"duration": 4400,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.1,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Icy Wind",
"type": "Ice",
"power": 60,
"duration": 3300,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.055,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Giga Drain",
"type": "Grass",
"power": 50,
"duration": 3900,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Fire Punch",
"type": "Fire",
"power": 55,
"duration": 2200,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Solar Beam",
"type": "Grass",
"power": 180,
"duration": 4900,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.12,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Leaf Blade",
"type": "Grass",
"power": 70,
"duration": 2400,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.09,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Power Whip",
"type": "Grass",
"power": 90,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.12,
"quick": false
},
{
"name": "Air Cutter",
"type": "Flying",
"power": 60,
"duration": 2700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Hurricane",
"type": "Flying",
"power": 110,
"duration": 2700,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.11,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Brick Break",
"type": "Fighting",
"power": 40,
"duration": 1600,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.075,
"critical_chance": 0.25,
"quick": false
},
{
"name": "Swift",
"type": "Normal",
"power": 60,
"duration": 2800,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Horn Attack",
"type": "Normal",
"power": 40,
"duration": 1850,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Stomp",
"type": "Normal",
"power": 55,
"duration": 1700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.065,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Hyper Fang",
"type": "Normal",
"power": 80,
"duration": 2500,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Body Slam",
"type": "Normal",
"power": 50,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.085,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Rest",
"type": "Normal",
"power": 50,
"duration": 1900,
"energy_delta": -33,
"accuracy_chance": 1,
"quick": false
},
{
"name": "Struggle",
"type": "Normal",
"power": 35,
"duration": 2200,
"accuracy_chance": 1,
"stamina_loss": 0.1,
"quick": false
},
{
"name": "Scald Blastoise",
"type": "Water",
"power": 50,
"duration": 4700,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.08,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Hydro Pump Blastoise",
"type": "Water",
"power": 90,
"duration": 4500,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.11,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Wrap Green",
"type": "Normal",
"power": 25,
"duration": 2900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Wrap Pink",
"type": "Normal",
"power": 25,
"duration": 2900,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.06,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Fury Cutter",
"type": "Bug",
"power": 3,
"duration": 400,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Bug Bite",
"type": "Bug",
"power": 5,
"duration": 500,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Bite",
"type": "Dark",
"power": 6,
"duration": 500,
"energy_delta": 4,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Sucker Punch",
"type": "Dark",
"power": 7,
"duration": 700,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Dragon Breath",
"type": "Dragon",
"power": 6,
"duration": 500,
"energy_delta": 4,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Thunder Shock",
"type": "Electric",
"power": 5,
"duration": 600,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Spark",
"type": "Electric",
"power": 6,
"duration": 700,
"energy_delta": 9,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Low Kick",
"type": "Fighting",
"power": 6,
"duration": 600,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Karate Chop",
"type": "Fighting",
"power": 8,
"duration": 800,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Ember",
"type": "Fire",
"power": 10,
"duration": 1000,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Wing Attack",
"type": "Flying",
"power": 8,
"duration": 800,
"energy_delta": 9,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Peck",
"type": "Flying",
"power": 10,
"duration": 1000,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Lick",
"type": "Ghost",
"power": 5,
"duration": 500,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Shadow Claw",
"type": "Ghost",
"power": 9,
"duration": 700,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Vine Whip",
"type": "Grass",
"power": 7,
"duration": 600,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Razor Leaf",
"type": "Grass",
"power": 13,
"duration": 1000,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Mud Shot",
"type": "Ground",
"power": 5,
"duration": 600,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Ice Shard",
"type": "Ice",
"power": 12,
"duration": 1200,
"energy_delta": 12,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Frost Breath",
"type": "Ice",
"power": 10,
"duration": 900,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Quick Attack",
"type": "Normal",
"power": 8,
"duration": 800,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Scratch",
"type": "Normal",
"power": 6,
"duration": 500,
"energy_delta": 4,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Tackle",
"type": "Normal",
"power": 5,
"duration": 500,
"energy_delta": 5,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Pound",
"type": "Normal",
"power": 7,
"duration": 600,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Cut",
"type": "Normal",
"power": 5,
"duration": 500,
"energy_delta": 5,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Poison Jab",
"type": "Poison",
"power": 10,
"duration": 800,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Acid",
"type": "Poison",
"power": 9,
"duration": 800,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Psycho Cut",
"type": "Psychic",
"power": 5,
"duration": 600,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Rock Throw",
"type": "Rock",
"power": 12,
"duration": 900,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Metal Claw",
"type": "Steel",
"power": 8,
"duration": 700,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Bullet Punch",
"type": "Steel",
"power": 9,
"duration": 900,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Water Gun",
"type": "Water",
"power": 5,
"duration": 500,
"energy_delta": 5,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Splash",
"type": "Water",
"duration": 1730,
"energy_delta": 20,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Water Gun Fast Blastoise",
"type": "Water",
"power": 10,
"duration": 1000,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": false
},
{
"name": "Mud Slap",
"type": "Ground",
"power": 15,
"duration": 1400,
"energy_delta": 12,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Zen Headbutt",
"type": "Psychic",
"power": 12,
"duration": 1100,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Confusion",
"type": "Psychic",
"power": 20,
"duration": 1600,
"energy_delta": 15,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Poison Sting",
"type": "Poison",
"power": 5,
"duration": 600,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Bubble",
"type": "Water",
"power": 12,
"duration": 1200,
"energy_delta": 14,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Feint Attack",
"type": "Dark",
"power": 10,
"duration": 900,
"energy_delta": 9,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Steel Wing",
"type": "Steel",
"power": 11,
"duration": 800,
"energy_delta": 6,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Fire Fang",
"type": "Fire",
"power": 11,
"duration": 900,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Rock Smash",
"type": "Fighting",
"power": 15,
"duration": 1300,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Transform",
"type": "Normal",
"duration": 2230,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Counter",
"type": "Fighting",
"power": 12,
"duration": 900,
"energy_delta": 8,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Powder Snow",
"type": "Ice",
"power": 6,
"duration": 1000,
"energy_delta": 15,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Close Combat",
"type": "Fighting",
"power": 100,
"duration": 2300,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dynamic Punch",
"type": "Fighting",
"power": 90,
"duration": 2700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Focus Blast",
"type": "Fighting",
"power": 140,
"duration": 3500,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Aurora Beam",
"type": "Ice",
"power": 80,
"duration": 3550,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Charge Beam",
"type": "Electric",
"power": 8,
"duration": 1100,
"energy_delta": 15,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Volt Switch",
"type": "Electric",
"power": 20,
"duration": 2300,
"energy_delta": 25,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Wild Charge",
"type": "Electric",
"power": 90,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Zap Cannon",
"type": "Electric",
"power": 140,
"duration": 3700,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Dragon Tail",
"type": "Dragon",
"power": 15,
"duration": 1100,
"energy_delta": 9,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Avalanche",
"type": "Ice",
"power": 90,
"duration": 2700,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Air Slash",
"type": "Flying",
"power": 14,
"duration": 1200,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Brave Bird",
"type": "Flying",
"power": 90,
"duration": 2000,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Sky Attack",
"type": "Flying",
"power": 70,
"duration": 2000,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Sand Tomb",
"type": "Ground",
"power": 80,
"duration": 4000,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Rock Blast",
"type": "Rock",
"power": 50,
"duration": 2100,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Infestation",
"type": "Bug",
"power": 10,
"duration": 1100,
"energy_delta": 14,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Struggle Bug",
"type": "Bug",
"power": 15,
"duration": 1500,
"energy_delta": 15,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Silver Wind",
"type": "Bug",
"power": 70,
"duration": 3700,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Astonish",
"type": "Ghost",
"power": 8,
"duration": 1100,
"energy_delta": 14,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Hex",
"type": "Ghost",
"power": 10,
"duration": 1200,
"energy_delta": 15,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Night Shade",
"type": "Ghost",
"power": 60,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Iron Tail",
"type": "Steel",
"power": 15,
"duration": 1100,
"energy_delta": 7,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Gyro Ball",
"type": "Steel",
"power": 80,
"duration": 3300,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Heavy Slam",
"type": "Steel",
"power": 70,
"duration": 2100,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Fire Spin",
"type": "Fire",
"power": 14,
"duration": 1100,
"energy_delta": 10,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Overheat",
"type": "Fire",
"power": 160,
"duration": 4000,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Bullet Seed",
"type": "Grass",
"power": 8,
"duration": 1100,
"energy_delta": 14,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Grass Knot",
"type": "Grass",
"power": 90,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Energy Ball",
"type": "Grass",
"power": 90,
"duration": 3900,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Extrasensory",
"type": "Psychic",
"power": 12,
"duration": 1100,
"energy_delta": 12,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Futuresight",
"type": "Psychic",
"power": 120,
"duration": 2700,
"energy_delta": -100,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Mirror Coat",
"type": "Psychic",
"power": 60,
"duration": 2600,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Outrage",
"type": "Dragon",
"power": 110,
"duration": 3900,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Snarl",
"type": "Dark",
"power": 12,
"duration": 1100,
"energy_delta": 12,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"quick": true
},
{
"name": "Crunch",
"type": "Dark",
"power": 70,
"duration": 3200,
"energy_delta": -33,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Foul Play",
"type": "Dark",
"power": 70,
"duration": 2000,
"energy_delta": -50,
"accuracy_chance": 1,
"stamina_loss": 0.04,
"critical_chance": 0.05,
"quick": false
},
{
"name": "Hidden Power",
"type": "Normal",
"power": 15,
"duration": 1500,
"energy_delta": 15,
"accuracy_chance": 1,
"stamina_loss": 0.01,
"critical_chance": 0.05,
"quick": true
}
]
| {
"pile_set_name": "Github"
} |
# Internal c++ interfaces
The following interfaces are defined here:
* [`Chain`](chain.h) — used by wallet to access blockchain and mempool state. Added in [#14437](https://github.com/bitcoin/bitcoin/pull/14437), [#14711](https://github.com/bitcoin/bitcoin/pull/14711), [#15288](https://github.com/bitcoin/bitcoin/pull/15288), and [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
* [`ChainClient`](chain.h) — used by node to start & stop `Chain` clients. Added in [#14437](https://github.com/bitcoin/bitcoin/pull/14437).
* [`Node`](node.h) — used by GUI to start & stop bitcoin node. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).
* [`Wallet`](wallet.h) — used by GUI to access wallets. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).
* [`Handler`](handler.h) — returned by `handleEvent` methods on interfaces above and used to manage lifetimes of event handlers.
* [`Init`](init.h) — used by multiprocess code to access interfaces above on startup. Added in [#10102](https://github.com/bitcoin/bitcoin/pull/10102).
The interfaces above define boundaries between major components of bitcoin code (node, wallet, and gui), making it possible for them to run in different processes, and be tested, developed, and understood independently. These interfaces are not currently designed to be stable or to be used externally.
| {
"pile_set_name": "Github"
} |
# procfs
This procfs package provides functions to retrieve system, kernel and process
metrics from the pseudo-filesystem proc.
*WARNING*: This package is a work in progress. Its API may still break in
backwards-incompatible ways without warnings. Use it at your own risk.
[](https://godoc.org/github.com/prometheus/procfs)
[](https://travis-ci.org/prometheus/procfs)
[](https://goreportcard.com/report/github.com/prometheus/procfs)
| {
"pile_set_name": "Github"
} |
$aoApps = Get-AppxPackage
foreach ($oApp in $aoApps) {
if ($oApp.Name -eq "Microsoft.MicrosoftEdge") {
$oManifest = Get-AppxPackageManifest $oApp
foreach ($sId in $oManifest.package.applications.application.id) {
$oApp.PackageFamilyName + "!" + $sId
}
}
} | {
"pile_set_name": "Github"
} |
#ifndef CAFFE_BNLL_LAYER_HPP_
#define CAFFE_BNLL_LAYER_HPP_
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/layers/neuron_layer.hpp"
namespace caffe {
/**
* @brief Computes @f$ y = x + \log(1 + \exp(-x)) @f$ if @f$ x > 0 @f$;
* @f$ y = \log(1 + \exp(x)) @f$ otherwise.
*
* @param bottom input Blob vector (length 1)
* -# @f$ (N \times C \times H \times W) @f$
* the inputs @f$ x @f$
* @param top output Blob vector (length 1)
* -# @f$ (N \times C \times H \times W) @f$
* the computed outputs @f$
* y = \left\{
* \begin{array}{ll}
* x + \log(1 + \exp(-x)) & \mbox{if } x > 0 \\
* \log(1 + \exp(x)) & \mbox{otherwise}
* \end{array} \right.
* @f$
*/
template <typename Dtype>
class BNLLLayer : public NeuronLayer<Dtype> {
public:
explicit BNLLLayer(const LayerParameter& param)
: NeuronLayer<Dtype>(param) {}
virtual inline const char* type() const { return "BNLL"; }
protected:
/// @copydoc BNLLLayer
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
/**
* @brief Computes the error gradient w.r.t. the BNLL inputs.
*
* @param top output Blob vector (length 1), providing the error gradient with
* respect to the outputs
* -# @f$ (N \times C \times H \times W) @f$
* containing error gradients @f$ \frac{\partial E}{\partial y} @f$
* with respect to computed outputs @f$ y @f$
* @param propagate_down see Layer::Backward.
* @param bottom input Blob vector (length 2)
* -# @f$ (N \times C \times H \times W) @f$
* the inputs @f$ x @f$; Backward fills their diff with
* gradients @f$
* \frac{\partial E}{\partial x}
* @f$ if propagate_down[0]
*/
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
};
} // namespace caffe
#endif // CAFFE_BNLL_LAYER_HPP_
| {
"pile_set_name": "Github"
} |
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xnio.nio;
import static org.xnio.nio.Log.log;
import java.io.IOException;
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.xnio.Bits;
import org.xnio.Xnio;
import org.xnio.XnioIoThread;
import org.xnio.XnioWorker;
import org.xnio.channels.ReadTimeoutException;
import org.xnio.channels.StreamSinkChannel;
import org.xnio.channels.StreamSourceChannel;
import org.xnio.channels.WriteTimeoutException;
import org.xnio.conduits.Conduits;
import org.xnio.conduits.ReadReadyHandler;
import org.xnio.conduits.StreamSinkConduit;
import org.xnio.conduits.StreamSourceConduit;
import org.xnio.conduits.WriteReadyHandler;
final class NioSocketConduit extends NioHandle implements StreamSourceConduit, StreamSinkConduit {
private final SocketChannel socketChannel;
private final NioSocketStreamConnection connection;
private ReadReadyHandler readReadyHandler;
private WriteReadyHandler writeReadyHandler;
@SuppressWarnings("unused")
private volatile int readTimeout;
private long lastRead;
@SuppressWarnings("rawtypes")
private static final AtomicIntegerFieldUpdater<NioSocketConduit> readTimeoutUpdater = AtomicIntegerFieldUpdater.newUpdater(NioSocketConduit.class, "readTimeout");
@SuppressWarnings("unused")
private volatile int writeTimeout;
private long lastWrite;
@SuppressWarnings("rawtypes")
private static final AtomicIntegerFieldUpdater<NioSocketConduit> writeTimeoutUpdater = AtomicIntegerFieldUpdater.newUpdater(NioSocketConduit.class, "writeTimeout");
NioSocketConduit(final WorkerThread workerThread, final SelectionKey selectionKey, final NioSocketStreamConnection connection) {
super(workerThread, selectionKey);
this.connection = connection;
this.socketChannel = (SocketChannel) selectionKey.channel();
}
void handleReady(int ops) {
try {
if (ops == 0) {
// the dreaded bug
final SelectionKey key = getSelectionKey();
final int interestOps = key.interestOps();
if (interestOps != 0) {
ops = interestOps;
} else {
// urp
forceTermination();
return;
}
}
if (Bits.allAreSet(ops, SelectionKey.OP_READ)) try {
if (isReadShutdown()) suspendReads();
readReadyHandler.readReady();
} catch (Throwable ignored) {
}
if (Bits.allAreSet(ops, SelectionKey.OP_WRITE)) try {
if (isWriteShutdown()) suspendWrites();
writeReadyHandler.writeReady();
} catch (Throwable ignored) {
}
} catch (CancelledKeyException ignored) {}
}
public XnioWorker getWorker() {
return getWorkerThread().getWorker();
}
void forceTermination() {
final ReadReadyHandler read = readReadyHandler;
if (read != null) read.forceTermination();
final WriteReadyHandler write = writeReadyHandler;
if (write != null) write.forceTermination();
}
void terminated() {
final ReadReadyHandler read = readReadyHandler;
if (read != null) read.terminated();
final WriteReadyHandler write = writeReadyHandler;
if (write != null) write.terminated();
}
// Write methods
int getAndSetWriteTimeout(int newVal) {
return writeTimeoutUpdater.getAndSet(this, newVal);
}
int getWriteTimeout() {
return writeTimeout;
}
private void checkWriteTimeout(final boolean xfer) throws WriteTimeoutException {
int timeout = writeTimeout;
if (timeout > 0) {
if (xfer) {
lastWrite = System.nanoTime();
} else {
long lastRead = this.lastWrite;
if (lastRead > 0L && ((System.nanoTime() - lastRead) / 1000000L) > (long) timeout) {
throw log.writeTimeout();
}
}
}
}
public final long transferFrom(final FileChannel src, final long position, final long count) throws IOException {
long res = src.transferTo(position, count, socketChannel);
checkWriteTimeout(res > 0L);
return res;
}
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException {
return Conduits.transfer(source, count, throughBuffer, this);
}
public int write(final ByteBuffer src) throws IOException {
int res = socketChannel.write(src);
checkWriteTimeout(res > 0);
return res;
}
public long write(final ByteBuffer[] srcs, final int offset, final int length) throws IOException {
if (length == 1) {
return write(srcs[offset]);
}
long res = socketChannel.write(srcs, offset, length);
checkWriteTimeout(res > 0L);
return res;
}
@Override
public int writeFinal(ByteBuffer src) throws IOException {
return Conduits.writeFinalBasic(this, src);
}
@Override
public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException {
return Conduits.writeFinalBasic(this, srcs, offset, length);
}
public boolean flush() throws IOException {
return true;
}
public void terminateWrites() throws IOException {
if (connection.writeClosed()) try {
if (getSelectionKey().isValid()) {
suspend(SelectionKey.OP_WRITE);
}
if (socketChannel.isOpen()) try {
socketChannel.socket().shutdownOutput();
} catch (SocketException ignored) {
// IBM incorrectly throws this exception on ENOTCONN; it's probably less harmful just to swallow it
}
} catch (ClosedChannelException ignored) {
} finally {
writeTerminated();
}
}
public void truncateWrites() throws IOException {
terminateWrites();
}
void writeTerminated() {
final WriteReadyHandler writeReadyHandler = this.writeReadyHandler;
if (writeReadyHandler != null) try {
writeReadyHandler.terminated();
} catch (Throwable ignored) {}
}
public boolean isWriteShutdown() {
return connection.isWriteShutdown();
}
public void resumeWrites() {
resume(SelectionKey.OP_WRITE);
}
public void suspendWrites() {
suspend(SelectionKey.OP_WRITE);
}
public void wakeupWrites() {
wakeup(SelectionKey.OP_WRITE);
}
public boolean isWriteResumed() {
return isResumed(SelectionKey.OP_WRITE);
}
public void awaitWritable() throws IOException {
Xnio.checkBlockingAllowed();
if (isWriteShutdown()) {
return;
}
SelectorUtils.await((NioXnio)getWorker().getXnio(), socketChannel, SelectionKey.OP_WRITE);
}
public void awaitWritable(final long time, final TimeUnit timeUnit) throws IOException {
Xnio.checkBlockingAllowed();
if (isWriteShutdown()) {
return;
}
SelectorUtils.await((NioXnio)getWorker().getXnio(), socketChannel, SelectionKey.OP_WRITE, time, timeUnit);
}
public XnioIoThread getWriteThread() {
return getWorkerThread();
}
public void setWriteReadyHandler(final WriteReadyHandler handler) {
writeReadyHandler = handler;
}
// Read methods
int getAndSetReadTimeout(int newVal) {
return readTimeoutUpdater.getAndSet(this, newVal);
}
int getReadTimeout() {
return readTimeout;
}
private void checkReadTimeout(final boolean xfer) throws ReadTimeoutException {
int timeout = readTimeout;
if (timeout > 0) {
if (xfer) {
lastRead = System.nanoTime();
} else {
long lastRead = this.lastRead;
if (lastRead > 0L && ((System.nanoTime() - lastRead) / 1000000L) > (long) timeout) {
throw log.readTimeout();
}
}
}
}
public long transferTo(final long position, final long count, final FileChannel target) throws IOException {
long res = target.transferFrom(socketChannel, position, count);
checkReadTimeout(res > 0L);
return res;
}
public long transferTo(final long count, final ByteBuffer throughBuffer, final StreamSinkChannel target) throws IOException {
return Conduits.transfer(this, count, throughBuffer, target);
}
public int read(final ByteBuffer dst) throws IOException {
int res;
try {
res = socketChannel.read(dst);
} catch (ClosedChannelException e) {
return -1;
}
if (res != -1) checkReadTimeout(res > 0);
else terminateReads();
return res;
}
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException {
if (length == 1) {
return read(dsts[offset]);
}
long res;
try {
res = socketChannel.read(dsts, offset, length);
} catch (ClosedChannelException e) {
return -1L;
}
if (res != -1L) checkReadTimeout(res > 0L);
else terminateReads();
return res;
}
public void terminateReads() throws IOException {
if (connection.readClosed()) try {
if (getSelectionKey().isValid()) {
suspend(SelectionKey.OP_READ);
}
if (socketChannel.isOpen()) try {
socketChannel.socket().shutdownInput();
} catch (SocketException ignored) {
// IBM incorrectly throws this exception on ENOTCONN; it's probably less harmful just to swallow it
}
} catch (ClosedChannelException ignored) {
} finally {
readTerminated();
}
}
void readTerminated() {
final ReadReadyHandler readReadyHandler = this.readReadyHandler;
if (readReadyHandler != null) try {
readReadyHandler.terminated();
} catch (Throwable ignored) {}
}
public boolean isReadShutdown() {
return connection.isReadShutdown();
}
public void resumeReads() {
resume(SelectionKey.OP_READ);
}
public void suspendReads() {
suspend(SelectionKey.OP_READ);
}
public void wakeupReads() {
wakeup(SelectionKey.OP_READ);
}
public boolean isReadResumed() {
return isResumed(SelectionKey.OP_READ);
}
public void awaitReadable() throws IOException {
Xnio.checkBlockingAllowed();
SelectorUtils.await((NioXnio)getWorker().getXnio(), socketChannel, SelectionKey.OP_READ);
}
public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException {
Xnio.checkBlockingAllowed();
SelectorUtils.await((NioXnio)getWorker().getXnio(), socketChannel, SelectionKey.OP_READ, time, timeUnit);
}
public XnioIoThread getReadThread() {
return getWorkerThread();
}
public void setReadReadyHandler(final ReadReadyHandler handler) {
this.readReadyHandler = handler;
}
SocketChannel getSocketChannel() {
return socketChannel;
}
}
| {
"pile_set_name": "Github"
} |
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
#include "hal/Encoder.h"
namespace hal {
bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
HAL_FPGAEncoderHandle* fpgaEncoderHandle,
HAL_CounterHandle* counterHandle);
class Encoder {
public:
friend bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
HAL_FPGAEncoderHandle* fpgaEncoderHandle,
HAL_CounterHandle* counterHandle);
Encoder(HAL_Handle digitalSourceHandleA,
HAL_AnalogTriggerType analogTriggerTypeA,
HAL_Handle digitalSourceHandleB,
HAL_AnalogTriggerType analogTriggerTypeB, bool reverseDirection,
HAL_EncoderEncodingType encodingType, int32_t* status);
~Encoder();
// CounterBase interface
int32_t Get(int32_t* status) const;
int32_t GetRaw(int32_t* status) const;
int32_t GetEncodingScale(int32_t* status) const;
void Reset(int32_t* status);
double GetPeriod(int32_t* status) const;
void SetMaxPeriod(double maxPeriod, int32_t* status);
bool GetStopped(int32_t* status) const;
bool GetDirection(int32_t* status) const;
double GetDistance(int32_t* status) const;
double GetRate(int32_t* status) const;
void SetMinRate(double minRate, int32_t* status);
void SetDistancePerPulse(double distancePerPulse, int32_t* status);
void SetReverseDirection(bool reverseDirection, int32_t* status);
void SetSamplesToAverage(int32_t samplesToAverage, int32_t* status);
int32_t GetSamplesToAverage(int32_t* status) const;
void SetIndexSource(HAL_Handle digitalSourceHandle,
HAL_AnalogTriggerType analogTriggerType,
HAL_EncoderIndexingType type, int32_t* status);
int32_t GetFPGAIndex() const { return m_index; }
int32_t GetEncodingScale() const { return m_encodingScale; }
double DecodingScaleFactor() const;
double GetDistancePerPulse() const { return m_distancePerPulse; }
HAL_EncoderEncodingType GetEncodingType() const { return m_encodingType; }
private:
void SetupCounter(HAL_Handle digitalSourceHandleA,
HAL_AnalogTriggerType analogTriggerTypeA,
HAL_Handle digitalSourceHandleB,
HAL_AnalogTriggerType analogTriggerTypeB,
bool reverseDirection, HAL_EncoderEncodingType encodingType,
int32_t* status);
HAL_FPGAEncoderHandle m_encoder = HAL_kInvalidHandle;
HAL_CounterHandle m_counter = HAL_kInvalidHandle;
int32_t m_index = 0;
double m_distancePerPulse = 1.0;
HAL_EncoderEncodingType m_encodingType;
int32_t m_encodingScale;
};
} // namespace hal
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingRight="16dip"
android:background="?attr/actionBarItemBackground"
android:enabled="false">
<ImageView android:id="@id/abs__up"
android:src="?attr/homeAsUpIndicator"
android:layout_gravity="center_vertical|left"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
android:orientation="vertical">
<TextView android:id="@+id/abs__action_bar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end" />
<TextView android:id="@+id/abs__action_bar_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/abs__action_bar_subtitle_top_margin"
android:layout_marginBottom="@dimen/abs__action_bar_subtitle_bottom_margin"
android:singleLine="true"
android:ellipsize="end"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
| {
"pile_set_name": "Github"
} |
;;; calc-menu.el --- a menu for Calc
;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
(defvar calc-arithmetic-menu
(list "Arithmetic"
(list "Basic"
["-(1:)" calc-change-sign
:keys "n" :active (>= (calc-stack-size) 1)]
["(2:) + (1:)" calc-plus
:keys "+" :active (>= (calc-stack-size) 2)]
["(2:) - (1:)" calc-minus
:keys "-" :active (>= (calc-stack-size) 2)]
["(2:) * (1:)" calc-times
:keys "*" :active (>= (calc-stack-size) 2)]
["(2:) / (1:)" calc-divide
:keys "/" :active (>= (calc-stack-size) 2)]
["(2:) ^ (1:)" calc-power
:keys "^" :active (>= (calc-stack-size) 2)]
["(2:) ^ (1/(1:))"
(progn
(require 'calc-ext)
(let ((calc-inverse-flag t))
(call-interactively 'calc-power)))
:keys "I ^"
:active (>= (calc-stack-size) 2)
:help "The (1:)th root of (2:)"]
["abs(1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-abs))
:keys "A"
:active (>= (calc-stack-size) 1)
:help "Absolute value"]
["1/(1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-inv))
:keys "&"
:active (>= (calc-stack-size) 1)]
["sqrt(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-sqrt))
:keys "Q"
:active (>= (calc-stack-size) 1)]
["idiv(2:,1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-idiv))
:keys "\\"
:active (>= (calc-stack-size) 2)
:help "The integer quotient of (2:) over (1:)"]
["(2:) mod (1:)"
(progn
(require 'calc-misc)
(call-interactively 'calc-mod))
:keys "%"
:active (>= (calc-stack-size) 2)
:help "The remainder when (2:) is divided by (1:)"])
(list "Rounding"
["floor(1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-floor))
:keys "F"
:active (>= (calc-stack-size) 1)
:help "The greatest integer less than or equal to (1:)"]
["ceiling(1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-ceiling))
:keys "I F"
:active (>= (calc-stack-size) 1)
:help "The smallest integer greater than or equal to (1:)"]
["round(1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-round))
:keys "R"
:active (>= (calc-stack-size) 1)
:help "The nearest integer to (1:)"]
["truncate(1:)"
(progn
(require 'calc-arith)
(call-interactively 'calc-trunc))
:keys "I R"
:active (>= (calc-stack-size) 1)
:help "The integer part of (1:)"])
(list "Complex Numbers"
["Re(1:)"
(progn
(require 'calc-cplx)
(call-interactively 'calc-re))
:keys "f r"
:active (>= (calc-stack-size) 1)]
["Im(1:)"
(progn
(require 'calc-cplx)
(call-interactively 'calc-im))
:keys "f i"
:active (>= (calc-stack-size) 1)]
["conj(1:)"
(progn
(require 'calc-cplx)
(call-interactively 'calc-conj))
:keys "J"
:active (>= (calc-stack-size) 1)
:help "The complex conjugate of (1:)"]
["length(1:)"
(progn (require 'calc-arith)
(call-interactively 'calc-abs))
:keys "A"
:active (>= (calc-stack-size) 1)
:help "The length (absolute value) of (1:)"]
["arg(1:)"
(progn
(require 'calc-cplx)
(call-interactively 'calc-argument))
:keys "G"
:active (>= (calc-stack-size) 1)
:help "The argument (polar angle) of (1:)"])
(list "Conversion"
["Convert (1:) to a float"
(progn
(require 'calc-ext)
(call-interactively 'calc-float))
:keys "c f"
:active (>= (calc-stack-size) 1)]
["Convert (1:) to a fraction"
(progn
(require 'calc-ext)
(call-interactively 'calc-fraction))
:keys "c F"
:active (>= (calc-stack-size) 1)])
(list "Binary"
["Set word size"
(progn
(require 'calc-bin)
(call-interactively 'calc-word-size))
:keys "b w"]
["Clip (1:) to word size"
(progn
(require 'calc-bin)
(call-interactively 'calc-clip))
:keys "b c"
:active (>= (calc-stack-size) 1)
:help "Reduce (1:) modulo 2^wordsize"]
["(2:) and (1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-and))
:keys "b a"
:active (>= (calc-stack-size) 2)
:help "Bitwise AND [modulo 2^wordsize]"]
["(2:) or (1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-or))
:keys "b o"
:active (>= (calc-stack-size) 2)
:help "Bitwise inclusive OR [modulo 2^wordsize]"]
["(2:) xor (1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-xor))
:keys "b x"
:active (>= (calc-stack-size) 2)
:help "Bitwise exclusive OR [modulo 2^wordsize]"]
["diff(2:,1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-diff))
:keys "b d"
:active (>= (calc-stack-size) 2)
:help "Bitwise difference [modulo 2^wordsize]"]
["not (1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-not))
:keys "b n"
:active (>= (calc-stack-size) 1)
:help "Bitwise NOT [modulo 2^wordsize]"]
["left shift(1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-lshift-binary))
:keys "b l"
:active (>= (calc-stack-size) 1)
:help "Shift (1:)[modulo 2^wordsize] one bit left"]
["right shift(1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-rshift-binary))
:keys "b r"
:active (>= (calc-stack-size) 1)
:help "Shift (1:)[modulo 2^wordsize] one bit right, putting 0s on the left"]
["arithmetic right shift(1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-rshift-arith))
:keys "b R"
:active (>= (calc-stack-size) 1)
:help "Shift (1:)[modulo 2^wordsize] one bit right, duplicating the leftmost bit"]
["rotate(1:)"
(progn
(require 'calc-bin)
(call-interactively 'calc-rotate-binary))
:keys "b t"
:active (>= (calc-stack-size) 1)
:help "Rotate (1:)[modulo 2^wordsize] one bit left"])
"-------"
["Help on Arithmetic"
(calc-info-goto-node "Arithmetic")])
"Menu for Calc's arithmetic functions.")
(defvar calc-scientific-function-menu
(list "Scientific Functions"
(list "Constants"
["pi"
(progn
(require 'calc-math)
(call-interactively 'calc-pi))
:keys "P"]
["e"
(progn
(require 'calc-math)
(let ((calc-hyperbolic-flag t))
(call-interactively 'calc-pi)))
:keys "H P"]
["phi"
(progn
(require 'calc-math)
(let ((calc-inverse-flag t)
(calc-hyperbolic-flag t))
(call-interactively 'calc-pi)))
:keys "I H P"
:help "The golden ratio"]
["gamma"
(progn
(require 'calc-math)
(let ((calc-inverse-flag t))
(call-interactively 'calc-pi)))
:keys "I P"
:help "Euler's constant"])
(list "Logs and Exps"
["ln(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-ln))
:keys "L"
:active (>= (calc-stack-size) 1)
:help "The natural logarithm"]
["e^(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-exp))
:keys "E"
:active (>= (calc-stack-size) 1)]
["log(1:) [base 10]"
(progn
(require 'calc-math)
(call-interactively 'calc-log10))
:keys "H L"
:active (>= (calc-stack-size) 1)
:help "The common logarithm"]
["10^(1:)"
(progn
(require 'calc-math)
(let ((calc-inverse-flag t))
(call-interactively 'calc-log10)))
:keys "I H L"
:active (>= (calc-stack-size) 1)]
["log(2:) [base(1:)]"
(progn
(require 'calc-math)
(call-interactively 'calc-log))
:keys "B"
:active (>= (calc-stack-size) 2)
:help "The logarithm with an arbitrary base"]
["(2:) ^ (1:)"
calc-power
:keys "^"
:active (>= (calc-stack-size) 2)])
(list "Trigonometric Functions"
["sin(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-sin))
:keys "S"
:active (>= (calc-stack-size) 1)]
["cos(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-cos))
:keys "C"
:active (>= (calc-stack-size) 1)]
["tan(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-tan))
:keys "T"
:active (>= (calc-stack-size) 1)]
["arcsin(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arcsin))
:keys "I S"
:active (>= (calc-stack-size) 1)]
["arccos(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arccos))
:keys "I C"
:active (>= (calc-stack-size) 1)]
["arctan(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arctan))
:keys "I T"
:active (>= (calc-stack-size) 1)]
["arctan2(2:,1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arctan2))
:keys "f T"
:active (>= (calc-stack-size) 2)]
"--Angle Measure--"
["Radians"
(progn
(require 'calc-math)
(calc-radians-mode))
:keys "m r"
:style radio
:selected (eq calc-angle-mode 'rad)]
["Degrees"
(progn
(require 'calc-math)
(calc-degrees-mode))
:keys "m d"
:style radio
:selected (eq calc-angle-mode 'deg)]
["HMS"
(progn
(require 'calc-math)
(calc-hms-mode))
:keys "m h"
:style radio
:selected (eq calc-angle-mode 'hms)])
(list "Hyperbolic Functions"
["sinh(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-sinh))
:keys "H S"
:active (>= (calc-stack-size) 1)]
["cosh(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-cosh))
:keys "H C"
:active (>= (calc-stack-size) 1)]
["tanh(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-tanh))
:keys "H T"
:active (>= (calc-stack-size) 1)]
["arcsinh(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arcsinh))
:keys "I H S"
:active (>= (calc-stack-size) 1)]
["arccosh(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arccosh))
:keys "I H C"
:active (>= (calc-stack-size) 1)]
["arctanh(1:)"
(progn
(require 'calc-math)
(call-interactively 'calc-arctanh))
:keys "I H T"
:active (>= (calc-stack-size) 1)])
(list "Advanced Math Functions"
["Gamma(1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-gamma))
:keys "f g"
:active (>= (calc-stack-size) 1)
:help "The Euler Gamma function"]
["GammaP(2:,1:)"
(progn
(require 'calc-funcs)
(call-interactively 'calc-inc-gamma))
:keys "f G"
:active (>= (calc-stack-size) 2)
:help "The lower incomplete Gamma function"]
["Beta(2:,1:)"
(progn
(require 'calc-funcs)
(call-interactively 'calc-beta))
:keys "f b"
:active (>= (calc-stack-size) 2)
:help "The Euler Beta function"]
["BetaI(3:,2:,1:)"
(progn
(require 'calc-funcs)
(call-interactively 'calc-inc-beta))
:keys "f B"
:active (>= (calc-stack-size) 3)
:help "The incomplete Beta function"]
["erf(1:)"
(progn
(require 'calc-funcs)
(call-interactively 'calc-erf))
:keys "f e"
:active (>= (calc-stack-size) 1)
:help "The error function"]
["BesselJ(2:,1:)"
(progn
(require 'calc-funcs)
(call-interactively 'calc-bessel-J))
:keys "f j"
:active (>= (calc-stack-size) 2)
:help "The Bessel function of the first kind (of order (2:))"]
["BesselY(2:,1:)"
(progn
(require 'calc-funcs)
(call-interactively 'calc-bessel-Y))
:keys "f y"
:active (>= (calc-stack-size) 2)
:help "The Bessel function of the second kind (of order (2:))"])
(list "Combinatorial Functions"
["gcd(2:,1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-gcd))
:keys "k g"
:active (>= (calc-stack-size) 2)]
["lcm(2:,1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-lcm))
:keys "k l"
:active (>= (calc-stack-size) 2)]
["factorial(1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-factorial))
:keys "!"
:active (>= (calc-stack-size) 1)]
["(2:) choose (1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-choose))
:keys "k c"
:active (>= (calc-stack-size) 2)]
["permutations(2:,1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-perm))
:keys "H k c"
:active (>= (calc-stack-size) 2)]
["Primality test for (1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-prime-test))
:keys "k p"
:active (>= (calc-stack-size) 1)
:help "For large (1:), a probabilistic test"]
["Factor (1:) into primes"
(progn
(require 'calc-comb)
(call-interactively 'calc-prime-factors))
:keys "k f"
:active (>= (calc-stack-size) 1)]
["Next prime after (1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-next-prime))
:keys "k n"
:active (>= (calc-stack-size) 1)]
["Previous prime before (1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-prev-prime))
:keys "I k n"
:active (>= (calc-stack-size) 1)]
["phi(1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-totient))
:keys "k n"
:active (>= (calc-stack-size) 1)
:help "Euler's totient function"]
["random(1:)"
(progn
(require 'calc-comb)
(call-interactively 'calc-random))
:keys "k r"
:active (>= (calc-stack-size) 1)
:help "A random number >=1 and < (1:)"])
"----"
["Help on Scientific Functions"
(calc-info-goto-node "Scientific Functions")])
"Menu for Calc's scientific functions.")
(defvar calc-algebra-menu
(list "Algebra"
(list "Simplification"
["Simplify (1:)"
(progn
(require 'calc-alg)
(call-interactively 'calc-simplify))
:keys "a s"
:active (>= (calc-stack-size) 1)]
["Simplify (1:) with extended rules"
(progn
(require 'calc-alg)
(call-interactively 'calc-simplify-extended))
:keys "a e"
:active (>= (calc-stack-size) 1)
:help "Apply possibly unsafe simplifications"])
(list "Manipulation"
["Expand formula (1:)"
(progn
(require 'calc-alg)
(call-interactively 'calc-expand-formula))
:keys "a \""
:active (>= (calc-stack-size) 1)
:help "Expand (1:) into its defining formula, if possible"]
["Evaluate variables in (1:)"
(progn
(require 'calc-ext)
(call-interactively 'calc-evaluate))
:keys "="
:active (>= (calc-stack-size) 1)]
["Make substitution in (1:)"
(progn
(require 'calc-alg)
(call-interactively 'calc-substitute))
:keys "a b"
:active (>= (calc-stack-size) 1)
:help
"Substitute all occurrences of a sub-expression with a new sub-expression"])
(list "Polynomials"
["Factor (1:)"
(progn
(require 'calc-alg)
(call-interactively 'calc-factor))
:keys "a f"
:active (>= (calc-stack-size) 1)]
["Collect terms in (1:)"
(progn
(require 'calc-alg)
(call-interactively 'calc-collect))
:keys "a c"
:active (>= (calc-stack-size) 1)
:help "Arrange as a polynomial in a given variable"]
["Expand (1:)"
(progn
(require 'calc-alg)
(call-interactively 'calc-expand))
:keys "a x"
:active (>= (calc-stack-size) 1)
:help "Apply distributive law everywhere"]
["Find roots of (1:)"
(progn
(require 'calcalg2)
(call-interactively 'calc-poly-roots))
:keys "a P"
:active (>= (calc-stack-size) 1)])
(list "Calculus"
["Differentiate (1:)"
(progn
(require 'calcalg2)
(call-interactively 'calc-derivative))
:keys "a d"
:active (>= (calc-stack-size) 1)]
["Integrate (1:) [indefinite]"
(progn
(require 'calcalg2)
(call-interactively 'calc-integral))
:keys "a i"
:active (>= (calc-stack-size) 1)]
["Integrate (1:) [definite]"
(progn
(require 'calcalg2)
(let ((var (read-string "Integration variable: ")))
(calc-tabular-command 'calcFunc-integ "Integration"
"intg" nil var nil nil)))
:keys "C-u a i"
:active (>= (calc-stack-size) 1)]
["Integrate (1:) [numeric]"
(progn
(require 'calcalg2)
(call-interactively 'calc-num-integral))
:keys "a I"
:active (>= (calc-stack-size) 1)
:help "Integrate using the open Romberg method"]
["Taylor expand (1:)"
(progn
(require 'calcalg2)
(call-interactively 'calc-taylor))
:keys "a t"
:active (>= (calc-stack-size) 1)]
["Minimize (2:) [initial guess = (1:)]"
(progn
(require 'calcalg3)
(call-interactively 'calc-find-minimum))
:keys "a N"
:active (>= (calc-stack-size) 2)
:help "Find a local minimum"]
["Maximize (2:) [initial guess = (1:)]"
(progn
(require 'calcalg3)
(call-interactively 'calc-find-maximum))
:keys "a X"
:active (>= (calc-stack-size) 2)
:help "Find a local maximum"])
(list "Solving"
["Solve equation (1:)"
(progn
(require 'calcalg2)
(call-interactively 'calc-solve-for))
:keys "a S"
:active (>= (calc-stack-size) 1)]
["Solve equation (2:) numerically [initial guess = (1:)]"
(progn
(require 'calcalg3)
(call-interactively 'calc-find-root))
:keys "a R"
:active (>= (calc-stack-size) 2)]
["Find roots of polynomial (1:)"
(progn
(require 'calcalg2)
(call-interactively 'calc-poly-roots))
:keys "a P"
:active (>= (calc-stack-size) 1)])
(list "Curve Fitting"
["Fit (1:)=[x values, y values] to a curve"
(progn
(require 'calcalg3)
(call-interactively 'calc-curve-fit))
:keys "a F"
:active (>= (calc-stack-size) 1)])
"----"
["Help on Algebra"
(calc-info-goto-node "Algebra")])
"Menu for Calc's algebraic facilities.")
(defvar calc-graphics-menu
(list "Graphics"
["Graph 2D [(1:)= y values, (2:)= x values]"
(progn
(require 'calc-graph)
(call-interactively 'calc-graph-fast))
:keys "g f"
:active (>= (calc-stack-size) 2)]
["Graph 3D [(1:)= z values, (2:)= y values, (3:)= x values]"
(progn
(require 'calc-graph)
(call-interactively 'calc-graph-fast-3d))
:keys "g F"
:active (>= (calc-stack-size) 3)]
"----"
["Help on Graphics"
(calc-info-goto-node "Graphics")])
"Menu for Calc's graphics.")
(defvar calc-vectors-menu
(list "Matrices/Vectors"
(list "Matrices"
["(2:) + (1:)" calc-plus
:keys "+" :active (>= (calc-stack-size) 2)]
["(2:) - (1:)" calc-minus
:keys "-" :active (>= (calc-stack-size) 2)]
["(2:) * (1:)" calc-times
:keys "*" :active (>= (calc-stack-size) 2)]
["(1:)^(-1)"
(progn
(require 'calc-arith)
(call-interactively 'calc-inv))
:keys "&"
:active (>= (calc-stack-size) 1)]
["Create an identity matrix"
(progn
(require 'calc-vec)
(call-interactively 'calc-ident))
:keys "v i"]
["transpose(1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-transpose))
:keys "v t"
:active (>= (calc-stack-size) 1)]
["det(1:)"
(progn
(require 'calc-mtx)
(call-interactively 'calc-mdet))
:keys "V D"
:active (>= (calc-stack-size) 1)]
["trace(1:)"
(progn
(require 'calc-mtx)
(call-interactively 'calc-mtrace))
:keys "V T"
:active (>= (calc-stack-size) 1)]
["LUD decompose (1:)"
(progn
(require 'calc-mtx)
(call-interactively 'calc-mlud))
:keys "V L"
:active (>= (calc-stack-size) 1)]
["Extract a row from (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-mrow))
:keys "v r"
:active (>= (calc-stack-size) 1)]
["Extract a column from (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-mcol))
:keys "v c"
:active (>= (calc-stack-size) 1)])
(list "Vectors"
["Extract the first element of (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-head))
:keys "v h"
:active (>= (calc-stack-size) 1)]
["Extract an element from (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-mrow))
:keys "v r"
:active (>= (calc-stack-size) 1)]
["Reverse (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-reverse-vector))
:keys "v v"
:active (>= (calc-stack-size) 1)]
["Unpack (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-unpack))
:keys "v u"
:active (>= (calc-stack-size) 1)
:help "Separate the elements of (1:)"]
["(2:) cross (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-cross))
:keys "V C"
:active (>= (calc-stack-size) 2)
:help "The cross product in R^3"]
["(2:) dot (1:)"
calc-mult
:keys "*"
:active (>= (calc-stack-size) 2)
:help "The dot product"]
["Map a function across (1:)"
(progn
(require 'calc-map)
(call-interactively 'calc-map))
:keys "V M"
:active (>= (calc-stack-size) 1)
:help "Apply a function to each element"])
(list "Vectors As Sets"
["Remove duplicates from (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-remove-duplicates))
:keys "V +"
:active (>= (calc-stack-size) 1)]
["(2:) union (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-set-union))
:keys "V V"
:active (>= (calc-stack-size) 2)]
["(2:) intersect (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-set-intersect))
:keys "V ^"
:active (>= (calc-stack-size) 2)]
["(2:) \\ (1:)"
(progn
(require 'calc-vec)
(call-interactively 'calc-set-difference))
:keys "V -"
:help "Set difference"
:active (>= (calc-stack-size) 2)])
(list "Statistics On Vectors"
["length(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-count))
:keys "u #"
:active (>= (calc-stack-size) 1)
:help "The number of data values"]
["sum(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-sum))
:keys "u +"
:active (>= (calc-stack-size) 1)
:help "The sum of the data values"]
["max(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-max))
:keys "u x"
:active (>= (calc-stack-size) 1)
:help "The maximum of the data values"]
["min(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-min))
:keys "u N"
:active (>= (calc-stack-size) 1)
:help "The minimum of the data values"]
["mean(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-mean))
:keys "u M"
:active (>= (calc-stack-size) 1)
:help "The average (arithmetic mean) of the data values"]
["mean(1:) with error"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-mean-error))
:keys "I u M"
:active (>= (calc-stack-size) 1)
:help "The average (arithmetic mean) of the data values as an error form"]
["rms(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-rms))
:keys "u R"
:active (>= (calc-stack-size) 1)
:help "The root mean square of the data values"]
["sdev(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-sdev))
:keys "u S"
:active (>= (calc-stack-size) 1)
:help "The sample sdev, sqrt[sum((values - mean)^2)/(N-1)]"]
["variance(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-variance))
:keys "H u S"
:active (>= (calc-stack-size) 1)
:help "The sample variance, sum((values - mean)^2)/(N-1)"]
["population sdev(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-pop-sdev))
:keys "I u S"
:active (>= (calc-stack-size) 1)
:help "The population sdev, sqrt[sum((values - mean)^2)/N]"]
["population variance(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-pop-variance))
:keys "H I u S"
:active (>= (calc-stack-size) 1)
:help "The population variance, sum((values - mean)^2)/N"]
["median(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-median))
:keys "H u M"
:active (>= (calc-stack-size) 1)
:help "The median of the data values"]
["harmonic mean(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-harmonic-mean))
:keys "H I u M"
:active (>= (calc-stack-size) 1)]
["geometric mean(1:)"
(progn
(require 'calc-stat)
(call-interactively 'calc-vector-geometric-mean))
:keys "u G"
:active (>= (calc-stack-size) 1)]
["arithmetic-geometric mean(1:)"
(progn
(require 'calc-stat)
(let ((calc-hyperbolic-flag t))
(call-interactively 'calc-vector-geometric-mean)))
:keys "H u G"
:active (>= (calc-stack-size) 1)]
;; ["RMS(1:)"
;; (progn (require 'calc-arith)
;; (call-interactively 'calc-abs))
;; :keys "A"
;; :active (>= (calc-stack-size) 1)
;; :help "The root-mean-square, or quadratic mean"]
)
["Abbreviate long vectors"
(progn
(require 'calc-mode)
(call-interactively 'calc-full-vectors))
:keys "v ."
:style toggle
:selected (not calc-full-vectors)]
"----"
["Help on Matrices/Vectors"
(calc-info-goto-node "Matrix Functions")])
"Menu for Calc's vector and matrix functions.")
(defvar calc-units-menu
(list "Units"
["Convert units in (1:)"
(progn
(require 'calc-units)
(call-interactively 'calc-convert-units ))
:keys "u c"
:active (>= (calc-stack-size) 1)]
["Convert temperature in (1:)"
(progn
(require 'calc-units)
(call-interactively 'calc-convert-temperature))
:keys "u t"
:active (>= (calc-stack-size) 1)]
["Simplify units in (1:)"
(progn
(require 'calc-units)
(call-interactively 'calc-simplify-units))
:keys "u s"
:active (>= (calc-stack-size) 1)]
["View units table"
(progn
(require 'calc-units)
(call-interactively 'calc-view-units-table))
:keys "u V"]
(list "Logarithmic Units"
["Convert (1:) to dB (power)"
(progn
(require 'calc-units)
(call-interactively 'calc-db))
:keys "l d"
:active (>= (calc-stack-size) 1)]
["Convert (2:) to dB (power) with reference level (1:)"
(progn
(require 'calc-units)
(let ((calc-option-flag t))
(call-interactively 'calc-db)))
:keys "O l d"
:active (>= (calc-stack-size) 2)]
["Convert (1:) to Np (power)"
(progn
(require 'calc-units)
(call-interactively 'calc-np))
:keys "l n"
:active (>= (calc-stack-size) 1)]
["Convert (2:) to Np (power) with reference level (1:)"
(progn
(require 'calc-units)
(let ((calc-option-flag t))
(call-interactively 'calc-np)))
:keys "O l n"
:active (>= (calc-stack-size) 2)]
["Convert (1:) to power quantity"
(progn
(require 'calc-units)
(call-interactively 'calc-lu-quant))
:keys "l q"
:active (>= (calc-stack-size) 1)]
["Convert (2:) to power quantity with reference level (1:)"
(progn
(require 'calc-units)
(let ((calc-option-flag t))
(call-interactively 'calc-lu-quant)))
:keys "O l q"
:active (>= (calc-stack-size) 2)]
"----"
["Convert (1:) to dB (field)"
(progn
(require 'calc-units)
(let ((calc-hyperbolic-flag t))
(call-interactively 'calc-db)))
:keys "H l d"
:active (>= (calc-stack-size) 1)]
["Convert (2:) to dB (field) with reference level (1:)"
(progn
(require 'calc-units)
(let ((calc-option-flag t)
(calc-hyperbolic-flag t))
(call-interactively 'calc-db)))
:keys "O H l d"
:active (>= (calc-stack-size) 2)]
["Convert (1:) to Np (field)"
(progn
(require 'calc-units)
(let ((calc-hyperbolic-flag t))
(call-interactively 'calc-np)))
:keys "H l n"
:active (>= (calc-stack-size) 1)]
["Convert (2:) to Np (field) with reference level (1:)"
(progn
(require 'calc-units)
(let ((calc-option-flag t)
(calc-hyperbolic-flag t))
(call-interactively 'calc-np)))
:keys "O H l d"
:active (>= (calc-stack-size) 2)]
["Convert (1:) to field quantity"
(progn
(require 'calc-units)
(let ((calc-hyperbolic-flag t))
(call-interactively 'calc-lu-quant)))
:keys "H l q"
:active (>= (calc-stack-size) 1)]
["Convert (2:) to field quantity with reference level (1:)"
(progn
(require 'calc-units)
(let ((calc-option-flag t)
(calc-hyperbolic-flag))
(call-interactively 'calc-lu-quant)))
:keys "O H l q"
:active (>= (calc-stack-size) 2)])
(list "Musical Notes"
["Convert (1:) to scientific pitch notation"
(progn
(require 'calc-units)
(call-interactively 'calc-spn))
:keys "l s"
:active (>= (calc-stack-size) 1)]
["Convert (1:) to midi number"
(progn
(require 'calc-units)
(call-interactively 'calc-midi))
:keys "l m"
:active (>= (calc-stack-size) 1)]
["Convert (1:) to frequency"
(progn
(require 'calc-units)
(call-interactively 'calc-freq))
:keys "l f"
:active (>= (calc-stack-size) 1)])
"----"
["Help on Units"
(calc-info-goto-node "Units")])
"Menu for Calc's units functions.")
(defvar calc-variables-menu
(list "Variables"
["Store (1:) into a variable"
(progn
(require 'calc-store)
(call-interactively 'calc-store))
:keys "s s"
:active (>= (calc-stack-size) 1)]
["Recall a variable value"
(progn
(require 'calc-store)
(call-interactively 'calc-recall ))
:keys "s r"]
["Edit the value of a variable"
(progn
(require 'calc-store)
(call-interactively 'calc-edit-variable))
:keys "s e"]
["Exchange (1:) with a variable value"
(progn
(require 'calc-store)
(call-interactively 'calc-store-exchange))
:keys "s x"
:active (>= (calc-stack-size) 1)]
["Clear variable value"
(progn
(require 'calc-store)
(call-interactively 'calc-unstore))
:keys "s u"]
["Evaluate variables in (1:)"
(progn
(require 'calc-ext)
(call-interactively 'calc-evaluate))
:keys "="
:active (>= (calc-stack-size) 1)]
["Evaluate (1:), assigning a value to a variable"
(progn
(require 'calc-store)
(call-interactively 'calc-let))
:keys "s l"
:active (>= (calc-stack-size) 1)
:help "Evaluate (1:) under a temporary assignment of a variable"]
"----"
["Help on Variables"
(calc-info-goto-node "Store and Recall")])
"Menu for Calc's variables.")
(defvar calc-stack-menu
(list "Stack"
["Remove (1:)"
calc-pop
:keys "DEL"
:active (>= (calc-stack-size) 1)]
["Switch (1:) and (2:)"
calc-roll-down
:keys "TAB"
:active (>= (calc-stack-size) 2)]
["Duplicate (1:)"
calc-enter
:keys "RET"
:active (>= (calc-stack-size) 1)]
["Edit (1:)"
(progn
(require 'calc-yank)
(call-interactively calc-edit))
:keys "`"
:active (>= (calc-stack-size) 1)]
"----"
["Help on Stack"
(calc-info-goto-node "Stack and Trail")])
"Menu for Calc's stack functions.")
(defvar calc-errors-menu
(list "Undo"
["Undo"
(progn
(require 'calc-undo)
(call-interactively 'calc-undo))
:keys "U"]
["Redo"
(progn
(require 'calc-undo)
(call-interactively 'calc-redo))
:keys "D"]
"----"
["Help on Undo"
(progn
(calc-info-goto-node "Introduction")
(Info-goto-node "Undo"))]))
(defvar calc-modes-menu
(list "Modes"
["Precision"
(progn
(require 'calc-ext)
(call-interactively 'calc-precision))
:keys "p"
:help "Set the precision for floating point calculations"]
["Fraction mode"
(progn
(require 'calc-frac)
(call-interactively 'calc-frac-mode))
:keys "m f"
:style toggle
:selected calc-prefer-frac
:help "Leave integer quotients as fractions"]
["Symbolic mode"
(lambda ()
(interactive)
(require 'calc-mode)
(calc-symbolic-mode nil))
:keys "m s"
:style toggle
:selected calc-symbolic-mode
:help "Leave functions producing inexact answers in symbolic form"]
["Infinite mode"
(lambda ()
(interactive)
(require 'calc-mode)
(calc-infinite-mode nil))
:keys "m i"
:style toggle
:selected calc-infinite-mode
:help "Let expressions like 1/0 produce infinite results"]
["Abbreviate long vectors"
(progn
(require 'calc-mode)
(call-interactively 'calc-full-vectors))
:keys "v ."
:style toggle
:selected (not calc-full-vectors)]
(list "Simplification"
["No simplification mode"
(progn
(require 'calc-mode)
(calc-no-simplify-mode t))
:keys "m O"
:style radio
:selected (eq calc-simplify-mode 'none)
:help "No simplifications are done automatically"]
["Numeric simplification mode"
(progn
(require 'calc-mode)
(calc-num-simplify-mode t))
:keys "m N"
:style radio
:selected (eq calc-simplify-mode 'num)
:help "Only numeric simplifications are done automatically"]
["Basic simplification mode"
(progn
(require 'calc-mode)
(calc-basic-simplify-mode t))
:keys "m I"
:style radio
:selected (eq calc-simplify-mode nil)
:help "Only basic simplifications are done automatically"]
["Binary simplification mode"
(progn
(require 'calc-mode)
(calc-bin-simplify-mode t))
:keys "m B"
:style radio
:selected (eq calc-simplify-mode 'binary)
:help "Basic simplifications with binary clipping are done automatically"]
["Algebraic simplification mode"
(progn
(require 'calc-mode)
(calc-alg-simplify-mode t))
:keys "m A"
:style radio
:selected (eq calc-simplify-mode 'alg)
:help "Standard algebraic simplifications are done automatically"]
["Extended simplification mode"
(progn
(require 'calc-mode)
(calc-ext-simplify-mode t))
:keys "m E"
:style radio
:selected (eq calc-simplify-mode 'ext)
:help "Extended (unsafe) simplifications are done automatically"]
["Units simplification mode"
(progn
(require 'calc-mode)
(calc-units-simplify-mode t))
:keys "m U"
:style radio
:selected (eq calc-simplify-mode 'units)
:help "Algebraic and unit simplifications are done automatically"])
(list "Angle Measure"
["Radians"
(progn
(require 'calc-math)
(call-interactively 'calc-radians-mode))
:keys "m r"
:style radio
:selected (eq calc-angle-mode 'rad)]
["Degrees"
(progn
(require 'calc-math)
(call-interactively 'calc-degrees-mode))
:keys "m d"
:style radio
:selected (eq calc-angle-mode 'deg)]
["HMS"
(progn
(require 'calc-math)
(call-interactively 'calc-hms-mode))
:keys "m h"
:style radio
:selected (eq calc-angle-mode 'hms)])
(list "Radix"
["Decimal"
(progn
(require 'calc-bin)
(call-interactively 'calc-decimal-radix))
:keys "d 0"
:style radio
:selected (and (= calc-number-radix 10)
(not calc-twos-complement-mode))]
["Binary"
(progn
(require 'calc-bin)
(call-interactively 'calc-binary-radix))
:keys "d 2"
:style radio
:selected (and (= calc-number-radix 2)
(not calc-twos-complement-mode))]
["Octal"
(progn
(require 'calc-bin)
(call-interactively 'calc-octal-radix))
:keys "d 8"
:style radio
:selected (and (= calc-number-radix 8)
(not calc-twos-complement-mode))]
["Hexadecimal"
(progn
(require 'calc-bin)
(call-interactively 'calc-hex-radix))
:keys "d 6"
:style radio
:selected (and (= calc-number-radix 16)
(not calc-twos-complement-mode))]
["Other"
(progn
(require 'calc-bin)
(call-interactively 'calc-radix))
:keys "d r"
:style radio
:selected (and
(not calc-twos-complement-mode)
(not
(or
(= calc-number-radix 10)
(= calc-number-radix 2)
(= calc-number-radix 8)
(= calc-number-radix 16))))]
["--Two's Complement--"
(lambda () ())
:style radio
:selected nil]
["Binary"
(progn
(require 'calc-bin)
(call-interactively
(lambda () (interactive) (calc-binary-radix t))))
:keys "C-u d 2"
:style radio
:selected (and (= calc-number-radix 2)
calc-twos-complement-mode)]
["Octal"
(progn
(require 'calc-bin)
(call-interactively
(lambda () (interactive) (calc-octal-radix t))))
:keys "C-u d 8"
:style radio
:selected (and (= calc-number-radix 8)
calc-twos-complement-mode)]
["Hexadecimal"
(progn
(require 'calc-bin)
(call-interactively
(lambda () (interactive) (calc-hex-radix t))))
:keys "C-u d 6"
:style radio
:selected (and (= calc-number-radix 16)
calc-twos-complement-mode)])
(list "Float Format"
["Normal"
(progn
(require 'calc-mode)
(call-interactively 'calc-normal-notation))
:keys "d n"
:style radio
:selected (eq (car-safe calc-float-format) 'float)]
["Fixed point"
(progn
(require 'calc-mode)
(call-interactively 'calc-fix-notation))
:keys "d f"
:style radio
:selected (eq (car-safe calc-float-format) 'fix)]
["Scientific notation"
(progn
(require 'calc-mode)
(call-interactively 'calc-sci-notation))
:keys "d s"
:style radio
:selected (eq (car-safe calc-float-format) 'sci)]
["Engineering notation"
(progn
(require 'calc-mode)
(call-interactively 'calc-eng-notation))
:keys "d e"
:style radio
:selected (eq (car-safe calc-float-format) 'eng)])
(list "Complex Format"
["Default"
(progn
(require 'calc-cplx)
(calc-complex-notation))
:style radio
:selected (not calc-complex-format)
:keys "d c"
:help "Display complex numbers as ordered pairs."]
["i notation"
(progn
(require 'calc-cplx)
(calc-i-notation))
:style radio
:selected (eq calc-complex-format 'i)
:keys "d i"
:help "Display complex numbers as a+bi."]
["j notation"
(progn
(require 'calc-cplx)
(calc-i-notation))
:style radio
:selected (eq calc-complex-format 'j)
:keys "d j"
:help "Display complex numbers as a+bj."]
["Other"
(calc-complex-notation)
:style radio
:selected (and calc-complex-format
(not (eq calc-complex-format 'i))
(not (eq calc-complex-format 'j)))
:active nil]
"----"
["Polar mode"
(progn
(require 'calc-cplx)
(calc-polar-mode nil))
:style toggle
:selected (eq calc-complex-mode 'polar)
:keys "m p"
:help "Prefer polar form for complex numbers."])
(list "Algebraic"
["Normal"
(progn
(require 'calc-mode)
(cond
(calc-incomplete-algebraic-mode
(calc-algebraic-mode t))
(calc-algebraic-mode
(calc-algebraic-mode nil))))
:style radio
:selected (not calc-algebraic-mode)]
["Algebraic mode"
(progn
(require 'calc-mode)
(if (or
calc-incomplete-algebraic-mode
(not calc-algebraic-mode))
(calc-algebraic-mode nil)))
:keys "m a"
:style radio
:selected (and calc-algebraic-mode
(not calc-incomplete-algebraic-mode))
:help "Keys which start numeric entry also start algebraic entry"]
["Incomplete algebraic mode"
(progn
(require 'calc-mode)
(unless calc-incomplete-algebraic-mode
(calc-algebraic-mode t)))
:keys "C-u m a"
:style radio
:selected calc-incomplete-algebraic-mode
:help "Only ( and [ begin algebraic entry"]
["Total algebraic mode"
(progn
(require 'calc-mode)
(unless (eq calc-algebraic-mode 'total)
(calc-total-algebraic-mode nil)))
:keys "m t"
:style radio
:selected (eq calc-algebraic-mode 'total)
:help "All regular letters and punctuation begin algebraic entry"])
(list "Matrix"
["Off"
(progn
(require 'calc-mode)
(calc-matrix-mode -1))
:style radio
:selected (eq calc-matrix-mode nil)
:help "Variables are not assumed to be matrix or scalar"]
["Matrix mode"
(progn
(require 'calc-mode)
(calc-matrix-mode -2))
:style radio
:selected (eq calc-matrix-mode 'matrix)
:help "Variables are assumed to be matrices"]
["Square matrix mode"
(progn
(require 'calc-mode)
(calc-matrix-mode '(4)))
:style radio
:selected (eq calc-matrix-mode 'sqmatrix)
:help "Variables are assumed to be square matrices"]
["Dimensioned matrix mode"
(let ((dim (string-to-number (read-from-minibuffer "Dimension: "))))
(if (natnump dim)
(progn
(require 'calc-mode)
(calc-matrix-mode dim))
(error "The dimension must be a positive integer")))
:style radio
:selected (and (integerp calc-matrix-mode) (> calc-matrix-mode 0))
:help "Variables are assumed to be NxN matrices"]
["Scalar mode"
(progn
(require 'calc-mode)
(calc-matrix-mode 0))
:style radio
:selected (eq calc-matrix-mode 'scalar)
:help "Variables are assumed to be scalars"])
(list "Language"
["Normal"
(progn
(require 'calc-lang)
(call-interactively 'calc-normal-language))
:keys "d N"
:style radio
:selected (eq calc-language nil)]
["Big"
(progn
(require 'calc-lang)
(call-interactively 'calc-big-language))
:keys "d B"
:style radio
:selected (eq calc-language 'big)
:help "Use textual approximations to various mathematical notations"]
["Flat"
(progn
(require 'calc-lang)
(call-interactively 'calc-flat-language))
:keys "d O"
:style radio
:selected (eq calc-language 'flat)
:help "Write matrices on a single line"]
["C"
(progn
(require 'calc-lang)
(call-interactively 'calc-c-language))
:keys "d C"
:style radio
:selected (eq calc-language 'c)]
["Pascal"
(progn
(require 'calc-lang)
(call-interactively 'calc-pascal-language))
:keys "d P"
:style radio
:selected (eq calc-language 'pascal)]
["Fortran"
(progn
(require 'calc-lang)
(call-interactively 'calc-fortran-language))
:keys "d F"
:style radio
:selected (eq calc-language 'fortran)]
["TeX"
(progn
(require 'calc-lang)
(call-interactively 'calc-tex-language))
:keys "d T"
:style radio
:selected (eq calc-language 'tex)]
["LaTeX"
(progn
(require 'calc-lang)
(call-interactively 'calc-latex-language))
:keys "d L"
:style radio
:selected (eq calc-language 'latex)]
["Eqn"
(progn
(require 'calc-lang)
(call-interactively 'calc-eqn-language))
:keys "d E"
:style radio
:selected (eq calc-language 'eqn)]
["Yacas"
(progn
(require 'calc-lang)
(call-interactively 'calc-yacas-language))
:keys "d Y"
:style radio
:selected (eq calc-language 'yacas)]
["Maxima"
(progn
(require 'calc-lang)
(call-interactively 'calc-maxima-language))
:keys "d X"
:style radio
:selected (eq calc-language 'maxima)]
["Giac"
(progn
(require 'calc-lang)
(call-interactively 'calc-giac-language))
:keys "d A"
:style radio
:selected (eq calc-language 'giac)]
["Mma"
(progn
(require 'calc-lang)
(call-interactively 'calc-mathematica-language))
:keys "d M"
:style radio
:selected (eq calc-language 'math)]
["Maple"
(progn
(require 'calc-lang)
(call-interactively 'calc-maple-language))
:keys "d W"
:style radio
:selected (eq calc-language 'maple)])
"----"
["Save mode settings" calc-save-modes :keys "m m"]
"----"
["Help on Modes"
(calc-info-goto-node "Mode settings")])
"Menu for Calc's mode settings.")
(defvar calc-help-menu
(list "Help"
["Manual"
calc-info
:keys "h i"]
["Tutorial"
calc-tutorial
:keys "h t"]
["Summary"
calc-info-summary
:keys "h s"]
"----"
["Help on Help"
(progn
(calc-info-goto-node "Introduction")
(Info-goto-node "Help Commands"))])
"Menu for Calc's help functions.")
;; Needed to make this file loadable in isolation.
;; Another option would be to use calc-load-hook.
(require 'calc)
(easy-menu-define
calc-menu
calc-mode-map
"Menu for Calc."
(list "Calc"
:visible '(eq major-mode 'calc-mode)
calc-arithmetic-menu
calc-scientific-function-menu
calc-algebra-menu
calc-graphics-menu
calc-vectors-menu
calc-units-menu
calc-variables-menu
calc-stack-menu
calc-errors-menu
calc-modes-menu
calc-help-menu
["Reset"
(progn
(require 'calc-ext)
(call-interactively 'calc-reset))
:help "Reset Calc to its initial state"]
["Quit" calc-quit]))
(provide 'calc-menu)
| {
"pile_set_name": "Github"
} |
// Copyright © 2019 The Things Network Foundation, The Things Industries B.V.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { createPaginationRequestActions, createPaginationBaseActionType } from './pagination'
import { createRequestActions } from './lib'
export const SHARED_NAME = 'USER'
export const GET_USER_BASE = 'GET_USER'
export const [
{ request: GET_USER, success: GET_USER_SUCCESS, failure: GET_USER_FAILURE },
{ request: getUser, success: getUserSuccess, failure: getUserFailure },
] = createRequestActions(GET_USER_BASE, id => ({ id }), (id, selector) => ({ selector }))
export const GET_USERS_LIST_BASE = createPaginationBaseActionType(SHARED_NAME)
export const [
{ request: GET_USERS_LIST, success: GET_USERS_LIST_SUCCESS, failure: GET_USERS_LIST_FAILURE },
{ request: getUsersList, success: getUsersSuccess, failure: getUsersFailure },
] = createPaginationRequestActions(SHARED_NAME)
export const CREATE_USER_BASE = 'CREATE_USER'
export const [
{ request: CREATE_USER, success: CREATE_USER_SUCCESS, failure: CREATE_USER_FAILURE },
{ request: createUser, success: createUserSuccess, failure: createUserFailure },
] = createRequestActions(CREATE_USER_BASE, user => ({ user }))
export const UPDATE_USER_BASE = 'UPDATE_USER'
export const [
{ request: UPDATE_USER, success: UPDATE_USER_SUCCESS, failure: UPDATE_USER_FAILURE },
{ request: updateUser, success: updateUserSuccess, failure: updateUserFailure },
] = createRequestActions(UPDATE_USER_BASE, (id, patch) => ({ id, patch }))
export const DELETE_USER_BASE = 'DELETE_USER'
export const [
{ request: DELETE_USER, success: DELETE_USER_SUCCESS, failure: DELETE_USER_FAILURE },
{ request: deleteUser, success: deleteUserSuccess, failure: deleteUserFailure },
] = createRequestActions(DELETE_USER_BASE, id => ({ id }))
| {
"pile_set_name": "Github"
} |
CREATE TABLE categoria (
codigo BIGINT(20) PRIMARY KEY AUTO_INCREMENT,
nome VARCHAR(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO categoria (nome) values ('Lazer');
INSERT INTO categoria (nome) values ('Alimentação');
INSERT INTO categoria (nome) values ('Supermercado');
INSERT INTO categoria (nome) values ('Farmácia');
INSERT INTO categoria (nome) values ('Outros'); | {
"pile_set_name": "Github"
} |
# Contributing
Contributions are appreciated! If you’d like to contribute, please help
us out by reading this short document.
## Before writing code
If you’re interested in adding a new feature, consider opening an issue
suggesting it. Then, we can discuss the feature to make sure that
everyone is on board.
If you’re interested in helping but don’t know where to start, consider
looking at open issues. [Issues marked **good first issue**][gfi]
may be especially accessible to newcomers.
[gfi]: https://github.com/sourcecred/sourcecred/issues?q=is%3Aissue+label%3A"good+first+issue"
If you find an issue that you’re interested in addressing, consider
adding a comment to that effect. This way, we can let you know if the
issue has gone stale before you put too much work into it, and other
contributors can know to focus on other issues.
## While writing code
### Semantically atomic commits
> for each desired change, make the change easy (warning: this may be
> hard), then make the easy change
>
> [—Kent Beck][kbeck-tweet]
[kbeck-tweet]: https://twitter.com/KentBeck/status/250733358307500032
Please factor your work into semantically atomic commits. Each commit
should represent a single semantic change, and the code included in the
commit should be the minimal amount of code required to implement, test,
and document that change.
For instance, perhaps you want to change the behavior of a component,
and along the way you find that it is useful to refactor a helper
function. In that case, you can create two commits: one to effect the
refactoring, and one to implement the change that has been made easy by
the refactoring.
This doesn’t mean that you have to physically write the code in this
order! The Git commit graph is malleable: you can write the code all at
once and commit it piecewise with `git add -p`; you can split and join
commits with interactive rebases; etc. What matters is the final
sequence of commits, not how you got there.
At the end of the day, you may find that you have a somewhat long
sequence of somewhat short changes. This is great. The goal is for a
reviewer to be able to say, “yep, this commit is obviously correct” as
many times in a row as are necessary for a full feature to be developed.
<details>
<summary>Why create small commits?</summary>
Writing small commits can help improve the design of your code. It is
common to realize an elegant way to split apart some functionality out
of a desire to split a commit into smaller, more localized pieces.
It is easier to review a commit that does one thing than a commit that
does many things. Not only will changes to the code be more localized,
but it will be easier for the reviewer to keep the whole context in
their mind.
Investigating and fixing bugs is much easier when commits are small.
There are more commits to look through, but an 8-fold increase in the
number of commits only entails 3 additional steps of bisection, which is
not a big deal. On the other hand, once the offending commit is
identified, the cause is more apparent if the commit is tiny than if it
is large.
</details>
### Checks
Each commit will need to pass all tests. Run `yarn test` or `npm test`
to run them all. This will run:
- **Flow** (`yarn flow`). Your code must type-check with no errors or
warnings. Using `any`-casts is permitted, but should be truly a last
resort. You should put significant effort into avoiding every
`any`-cast.
- **Unit tests** (`yarn unit`). You can also run `yarn unit --watch`
to automatically re-run tests when you change a relevant file.
- **Sharness** (`yarn sharness`). This runs shell-based tests, located
in the `sharness/` directory.
- **Prettier** (`check-pretty`). You can simply run `yarn prettify` to
reformat all files. It can be convenient to set up your editor to
run `yarn prettier --write CURRENT_FILENAME` whenever you save a
file.
- **Lint** (`yarn lint`). You’ll have to fix lint errors manually.
These are almost always unused imports or unused variables, and
sometimes catch logic errors before unit tests do. Feel free to
disable spurious lint errors on a per-line basis by inserting a
preceding line with `// eslint-disable-next-line LINT_RULE_NAME`.
- **Backend applications build** (`yarn build:backend`). This makes
sure that the CLI still builds.
- **Check for `@flow` pragmas** (`./scripts/ensure-flow.sh`). This
makes sure that every file includes a `// @flow` directive or an
explicit `// @no-flow` directive. The former is required for Flow to
consider a file. The latter has no effect, but we assert its
existence to make sure that we don’t simply forget to mark a file
for Flow. If this is failing, you probably added a new file and just
need to add `// @flow` to the top. Exceptional circumstances
excepted, all new files should have `// @flow`.
- **Check for stopships.** The sequence `STOPSHIP` (in any case) is
not allowed to appear in the codebase, except in Markdown files. You
can take advantage of this to insert a quick hack and make sure that
you remember to remove it later.
This is the same set of tests that is run on our CI system, CircleCI.
### Updating CHANGELOG.md
If your patch makes a change that would be visible or interesting to a
user of SourceCred—for example, fixing a bug—please add a description of
the change under the `[Unreleased]` heading of `CHANGELOG.md`. Your new
change should be the first entry in the section. The format of your
entry should be: `<description of change> (#<PR number>)`.
## When writing commit messages
### Summary of changes
Include a brief yet descriptive **summary** as the first line of the
message. The summary should be at most 50 characters, should be written
in the imperative mood, and should not include trailing punctuation. The
summary should either be in sentence case (i.e., the first letter of the
first word capitalized), or of the form “area: change description”. For
instance, all of the following are examples of good summaries:
- Improve error messages when GitHub query fails
- Make deploy script wait for valid response
- Upgrade Flow to v0.76.0
- new-webpack: replace old scripts in `package.json`
- fetchGithubRepo: remove vestigial data field
If you find that you can’t concisely explain your change in 50
characters, move non-essential information into the body of the commit
message. If it’s still difficult, you may be trying to change too much
at once!
<details>
<summary>Why include a summary?</summary>
The 50-character summary is critical because this is what Git
expects. Git often assumes that the first line of a commit contains a
concise description, and so workflows like interactive rebases surface
this information. The particular style of the summary is chosen to be
consistent with those commits emitted by Git itself: commands like
`git-revert` and `git-merge` are of this form, so it’s a good standard
to pick.
</details>
### Description
After the initial line, include a **description** of the change. Why is
the change important? Did you consider and reject alternate formulations
of the same idea? Are there relevant issues or discussions elsewhere? If
any of these questions provides valuable information, answer it.
Otherwise, feel free to leave it out—some changes really are
self-documenting, and there’s no need to add a vacuous description.
<details>
<summary>Why include a description?</summary>
A commit describes a _change_ from one state of the codebase to the
next. If your patch is good, the final state of the code will be clear
to anyone reading it. But this isn’t always sufficient to explain why
the change was necessary. Documenting the motivation, alternate
formulations, etc. is helpful both in the present (for reviewers) and in
the future (for people using `git-blame` to try to understand how a
piece of code came to be).
</details>
### Test plan
After the description, include a **test plan**. Describe what someone
should do to verify that your changes are correct. This can include
automated tests, manual tests, or tests of the form “verify that when
you change the code in this way, you see this effect.” Feel free to
include shell commands and expected outputs if helpful.
Sometimes, the test plan may appear trivial. It may be the case that you
only ran the standard unit tests, or that you didn’t feel that any
testing at all was necessary. In these cases, you should still include
the test plan: this signals to observers that the trivial steps are
indeed sufficient.
<details>
<summary>Why include a test plan?</summary>
The value of a test plan is many-fold. Simply writing the test plan can
force you to consider cases that you hadn’t before, in turn helping you
discover bugs or think of alternate implementations. Even if the test
plan is as simple as “standard unit tests suffice”, this indicates to
observers that no additional testing is required. The test plan is
useful for reviewers, and for anyone bisecting through the history or
trying to learn more about the development or intention of a commit.
</details>
### Wrapping
Wrap all parts of the commit message so that no line has more than **72
characters**.
<details>
<summary>Why wrap at 72 characters?</summary>
This leaves room for four spaces of padding on either side while still
fitting in an 80-character terminal. Programs like `git-log` expect that
this amount of padding exists.
(Yes, people really still use 80-character terminals. When each of your
terminals has bounded width, you can display more of them on a screen!)
</details>
### Example
Here is an example of a helpful commit message. [The commit in
question][example-commit] doesn’t change very many lines of code, but
the commit message explains the context behind the commit, links to
relevant issues, thanks people who contributed to the commit, and
describes a manual test plan. Someone reading this commit for the first
time will have a much better understanding of the change by reading this
commit message:
```
Improve error messages when GitHub query fails
Currently, the GitHub graph fetcher will characteristically fail if:
1. it times out GitHub's server
2. it triggers the semidocumented abuse detection mechanism
In case 1, an intelligible error is posted to the console. In case 2, it
produces an unintelligible TypeError, because the response is not a
valid GraphQL response (the error field is not populated; it has a
custom message instead).
As of this commit, we gracefully catch both cases, and print a message
to console directing the user to #350, which has context on GitHub query
failures. This new catch works because in case 2, the data field is
empty, so we now properly recognize `x.data === undefined` as an error
case.
Thanks to @wchargin for the investigatory work behind this commit.
Fixes #223.
Test plan:
We don't have unit tests that cover this case, but I did manually test
it by asking GitHub to fetch `ipfs/go-ipfs`, which consistently fails.
I also tested it by using an invalid length-40 GitHub API token.
```
[example-commit]: https://github.com/sourcecred/sourcecred/commit/b61b8fbdb88a64192ca837550b7a53e6c27a90e0
## When submitting a pull request
Please create pull requests against `master` by default.
If your pull request includes multiple commits, please include a
high-level summary and test plan in the pull request body. Otherwise,
the text of your pull request can simply be the body of the unique
commit message.
Please be aware that, as a rule, we do not create merge commits. If you
have a stack of commits, we can either rebase the stack onto master
(preserving the history) or squash the stack into a single commit.
### Running full tests on CI
As soon as you open your pull request, our CI will start running the
basic test suite (`yarn test --ci`). It will also try to run the full
test suite (`yarn test --ci --full`), but this will fail for PRs created
from forks because it depends on credentials that aren’t exposed to
untrusted PRs by default. This is expected—don’t worry!
Once a core team member sanity-checks your PR to make sure that it’s not
accidentally leaking credentials into logs, they can “bless” your commit
by pushing it to any branch on the main SourceCred repository. This will
restart the full test suite, which will now actually run. Once your
tests pass and the PR is approved, we’ll delete the extra branch.
## After your pull request is merged
…you’re done! :-)
| {
"pile_set_name": "Github"
} |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_Fuzzyfox_h
#define mozilla_Fuzzyfox_h
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsISupportsPrimitives.h"
#include "nsThreadUtils.h"
#include "mozilla/TimeStamp.h"
/*
* This topic publishes the new canonical time according to Fuzzyfox,
* in microseconds since the epoch. If code needs to know the current time,
* it should listen for this topic and keep track of the 'current' time,
* so as to respect Fuzzyfox and be in sync with the rest of the browser's
* timekeeping.
*/
#define FUZZYFOX_UPDATECLOCK_OBSERVER_TOPIC "fuzzyfox-update-clocks"
/*
* For Fuzzyfox's security guarentees to hold, the browser must not execute
* actions while it should be paused. We currently only pause the main thread,
* so actions that occur on other threads should be queued until the browser
* unpaused (and moreso than unpauses: until it reaches a downtick.)
* This topic indicates when any queued outbound events should be delivered.
* TODO: Bug 1484300 and 1484299 would apply this to other communication
* channels
*/
#define FUZZYFOX_FIREOUTBOUND_OBSERVER_TOPIC "fuzzyfox-fire-outbound"
namespace mozilla {
/*
* Fuzzyfox is an implementation of the Fermata concept presented in
* Trusted Browsers for Uncertain Times.
*
* Web Browsers expose explicit (performance.now()) and implicit
* (WebVTT, Video Frames) timers that, when combined with algorithmic
* improvements such as edge thresholding, produce extremely high
* resolution clocks.
*
* High Resolution clocks can be used to time network accesses, browser
* cache reads, web page rendering, access to the CPU cache, and other
* operations - and the time these operations take to perform can yield
* detailed information about user information we want to keep private.
*
* Fuzzyfox limits the information disclosure by limiting an attacker's
* ability to create a high resolution clock. It does this by introducing
* a concept called 'fuzzy time' that degrades all clocks (explicit and
* implicit). This is done through a combination of holding time constant
* during program execution and pausing program execution.
*
* @InProceedings{KS16,
* author = {David Kohlbrenner and Hovav Shacham},
* title = {Trusted Browsers for Uncertain Times},
* booktitle = {Proceedings of USENIX Security 2016},
* pages = {463-80},
* year = 2016,
* editor = {Thorsten Holz and Stefan Savage},
* month = aug,
* organization = {USENIX}
* }
* https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_kohlbrenner.pdf
*
* Fuzzyfox is an adaptation of
* W.-M. Hu, “Reducing timing channels with fuzzy time,” in
* Proceedings of IEEE Security and Privacy (“Oakland”)
* 1991, T. F. Lunt and J. McLean, Eds. IEEE Computer
* Society, May 1991, pp. 8–20.
*/
class Fuzzyfox final : public Runnable, public nsIObserver {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER
static void Start();
NS_IMETHOD
Run() override;
private:
Fuzzyfox();
~Fuzzyfox();
uint64_t ActualTime();
uint64_t PickDuration();
void UpdateClocks(uint64_t aNewTime, TimeStamp aNewTimeStamp);
uint64_t FloorToGrain(uint64_t aValue);
TimeStamp FloorToGrain(TimeStamp aValue);
uint64_t CeilToGrain(uint64_t aValue);
TimeStamp CeilToGrain(TimeStamp aValue);
bool mSanityCheck;
uint64_t mStartTime;
uint32_t mDuration;
enum Tick {
eUptick,
eDowntick,
};
Tick mTickType;
nsCOMPtr<nsIObserverService> mObs = nullptr;
nsCOMPtr<nsISupportsPRInt64> mTimeUpdateWrapper = nullptr;
static Atomic<bool, Relaxed> sFuzzyfoxEnabledPrefMapped;
};
} // namespace mozilla
#endif /* mozilla_Fuzzyfox_h */
| {
"pile_set_name": "Github"
} |
This patch allows the user to specify desired packet types (outgoing,
broadcast, unicast, etc.) on packet sockets via setsockopt.
This can reduce the load in situations where only a limited number
of packet types are necessary
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
--- a/include/uapi/linux/if_packet.h
+++ b/include/uapi/linux/if_packet.h
@@ -31,6 +31,8 @@ struct sockaddr_ll {
#define PACKET_KERNEL 7 /* To kernel space */
/* Unused, PACKET_FASTROUTE and PACKET_LOOPBACK are invisible to user space */
#define PACKET_FASTROUTE 6 /* Fastrouted frame */
+#define PACKET_MASK_ANY 0xffffffff /* mask for packet type bits */
+
/* Packet socket options */
@@ -54,6 +56,7 @@ struct sockaddr_ll {
#define PACKET_FANOUT 18
#define PACKET_TX_HAS_OFF 19
#define PACKET_QDISC_BYPASS 20
+#define PACKET_RECV_TYPE 21
#define PACKET_FANOUT_HASH 0
#define PACKET_FANOUT_LB 1
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1541,6 +1541,7 @@ static int packet_rcv_spkt(struct sk_buf
{
struct sock *sk;
struct sockaddr_pkt *spkt;
+ struct packet_sock *po;
/*
* When we registered the protocol we saved the socket in the data
@@ -1548,6 +1549,7 @@ static int packet_rcv_spkt(struct sk_buf
*/
sk = pt->af_packet_priv;
+ po = pkt_sk(sk);
/*
* Yank back the headers [hope the device set this
@@ -1560,7 +1562,7 @@ static int packet_rcv_spkt(struct sk_buf
* so that this procedure is noop.
*/
- if (skb->pkt_type == PACKET_LOOPBACK)
+ if (!(po->pkt_type & (1 << skb->pkt_type)))
goto out;
if (!net_eq(dev_net(dev), sock_net(sk)))
@@ -1767,12 +1769,12 @@ static int packet_rcv(struct sk_buff *sk
int skb_len = skb->len;
unsigned int snaplen, res;
- if (skb->pkt_type == PACKET_LOOPBACK)
- goto drop;
-
sk = pt->af_packet_priv;
po = pkt_sk(sk);
+ if (!(po->pkt_type & (1 << skb->pkt_type)))
+ goto drop;
+
if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop;
@@ -1892,12 +1894,12 @@ static int tpacket_rcv(struct sk_buff *s
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h2)) != 32);
BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*h.h3)) != 48);
- if (skb->pkt_type == PACKET_LOOPBACK)
- goto drop;
-
sk = pt->af_packet_priv;
po = pkt_sk(sk);
+ if (!(po->pkt_type & (1 << skb->pkt_type)))
+ goto drop;
+
if (!net_eq(dev_net(dev), sock_net(sk)))
goto drop;
@@ -2853,6 +2855,7 @@ static int packet_create(struct net *net
spin_lock_init(&po->bind_lock);
mutex_init(&po->pg_vec_lock);
po->prot_hook.func = packet_rcv;
+ po->pkt_type = PACKET_MASK_ANY & ~(1 << PACKET_LOOPBACK);
if (sock->type == SOCK_PACKET)
po->prot_hook.func = packet_rcv_spkt;
@@ -3442,6 +3445,16 @@ packet_setsockopt(struct socket *sock, i
po->xmit = val ? packet_direct_xmit : dev_queue_xmit;
return 0;
}
+ case PACKET_RECV_TYPE:
+ {
+ unsigned int val;
+ if (optlen != sizeof(val))
+ return -EINVAL;
+ if (copy_from_user(&val, optval, sizeof(val)))
+ return -EFAULT;
+ po->pkt_type = val & ~BIT(PACKET_LOOPBACK);
+ return 0;
+ }
default:
return -ENOPROTOOPT;
}
@@ -3493,6 +3506,13 @@ static int packet_getsockopt(struct sock
case PACKET_VNET_HDR:
val = po->has_vnet_hdr;
break;
+ case PACKET_RECV_TYPE:
+ if (len > sizeof(unsigned int))
+ len = sizeof(unsigned int);
+ val = po->pkt_type;
+
+ data = &val;
+ break;
case PACKET_VERSION:
val = po->tp_version;
break;
--- a/net/packet/internal.h
+++ b/net/packet/internal.h
@@ -117,6 +117,7 @@ struct packet_sock {
struct net_device __rcu *cached_dev;
int (*xmit)(struct sk_buff *skb);
struct packet_type prot_hook ____cacheline_aligned_in_smp;
+ unsigned int pkt_type;
};
static struct packet_sock *pkt_sk(struct sock *sk)
| {
"pile_set_name": "Github"
} |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# -*- coding: utf-8 -*-\n",
"from miasm.analysis.machine import Machine\n",
"from miasm.ir.symbexec import SymbolicExecutionEngine\n",
"from miasm.ir.ir import IRCFG\n",
"from miasm.expression.expression import LocKey\n",
"from miasm.arch.x86.regs import *\n",
"from miasm.core import asmblock\n",
"from miasm.analysis.binary import Container\n",
"from future.utils import viewitems\n",
"from miasm.ir.translators.translator import Translator\n",
"import networkx as nx\n",
"import random\n",
"import z3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!unzip -n -P infected vipasana.zip\n",
"!unzip -n -P infected asprox.zip"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"filename = 'vipasana.bin'\n",
"target_addr = 0x434DF0\n",
"#filename = 'asprox.bin'\n",
"#target_addr = 0x100091AC\n",
"idc = True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def syntax_compare(blk0, blk1):\n",
" if len(blk0.lines) != len(blk1.lines):\n",
" return False\n",
"\n",
" for l0, l1 in zip(blk0.lines, blk1.lines):\n",
" if str(l0)[0] == 'J':\n",
" instr0 = str(l0).split(' ')[0]\n",
" instr1 = str(l1).split(' ')[0]\n",
" if instr0 != instr1:\n",
" return False\n",
" else:\n",
" if str(l0) != str(l1):\n",
" return False\n",
"\n",
" return True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def semantic_compare(blk0, blk1, ir_arch0, ir_arch1, asmcfg, flag_cmp=False):\n",
" src_ircfg = IRCFG(None, ir_arch0.loc_db)\n",
" try:\n",
" ir_arch0.add_asmblock_to_ircfg(blk0, src_ircfg)\n",
" except NotImplementedError:\n",
" return False\n",
"\n",
" dst_ircfg = IRCFG(None, ir_arch1.loc_db)\n",
" try:\n",
" ir_arch1.add_asmblock_to_ircfg(blk1, dst_ircfg)\n",
" except NotImplementedError:\n",
" return False\n",
"\n",
" if len(src_ircfg.blocks) != len(dst_ircfg.blocks):\n",
" return False\n",
"\n",
" for src_lbl, dst_lbl in zip(src_ircfg.blocks, dst_ircfg.blocks):\n",
"\n",
" src_irb = src_ircfg.blocks.get(src_lbl, None)\n",
" dst_irb = dst_ircfg.blocks.get(dst_lbl, None)\n",
"\n",
" r = execute_symbolic_execution(\n",
" src_irb, dst_irb, \n",
" ir_arch0, ir_arch1, \n",
" src_ircfg, dst_ircfg,\n",
" flag_cmp)\n",
" if r is False:\n",
" return False\n",
"\n",
" return True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def execute_symbolic_execution(src_irb, dst_irb, \n",
" ir_arch0, ir_arch1, \n",
" src_ircfg, dst_ircfg,\n",
" flag_cmp):\n",
"\n",
" # Ready for Symbolic Execution\n",
" src_symbols = {}\n",
" dst_symbols = {}\n",
"\n",
" # regs\n",
" for i, r in enumerate(all_regs_ids):\n",
" src_symbols[r] = all_regs_ids_init[i]\n",
" dst_symbols[r] = all_regs_ids_init[i]\n",
"\n",
"\n",
" # Run symbolic execution\n",
" src_sb = SymbolicExecutionEngine(ir_arch0, src_symbols)\n",
"\n",
" for assignblk in src_irb:\n",
" skip_update = False\n",
" for dst, src in viewitems(assignblk):\n",
" if str(dst) in ['EIP', 'IRDst']:\n",
" skip_update = True\n",
"\n",
" if not skip_update:\n",
" src_sb.eval_updt_assignblk(assignblk)\n",
"\n",
" dst_sb = SymbolicExecutionEngine(ir_arch1, dst_symbols)\n",
"\n",
" for assignblk in dst_irb:\n",
" skip_update = False\n",
" for dst, src in viewitems(assignblk):\n",
" if str(dst) in ['EIP', 'IRDst']:\n",
" skip_update = True\n",
"\n",
" if not skip_update:\n",
" dst_sb.eval_updt_assignblk(assignblk)\n",
"\n",
" # Equivalence Checking\n",
"\n",
" src_sb.del_mem_above_stack(ir_arch0.sp)\n",
" dst_sb.del_mem_above_stack(ir_arch1.sp)\n",
"\n",
" all_memory_ids = [k for k, v in dst_sb.symbols.memory()] + [k for k, v in src_sb.symbols.memory()]\n",
"\n",
" for k in all_regs_ids + all_memory_ids:\n",
"\n",
" if str(k) == 'EIP':\n",
" continue\n",
"\n",
" if not flag_cmp and k in [zf, nf, pf, of, cf, af, df, tf]:\n",
" continue\n",
"\n",
" v0 = src_sb.symbols[k]\n",
" v1 = dst_sb.symbols[k]\n",
"\n",
" if v0 == v1:\n",
" continue\n",
"\n",
" solver = z3.Solver()\n",
" try:\n",
" z3_r_cond = Translator.to_language('z3').from_expr(v0)\n",
" except NotImplementedError:\n",
" return False\n",
"\n",
" try:\n",
" z3_l_cond = Translator.to_language('z3').from_expr(v1)\n",
" except NotImplementedError:\n",
" return False\n",
"\n",
" # TODO:\n",
" # Please add just one line of code below to check the equivalence of z3_l_cond and z3_r_cond.\n",
" # Hint: we can add a constraint to 'solver' with 'add' method, e.g., solver.add(A == B).\n",
" # From HERE ------------------------------------------\n",
"\n",
" #solver.add()\n",
"\n",
" # TO HERE ------------------------------------------\n",
"\n",
" r = solver.check()\n",
" if r == z3.unsat:\n",
" continue\n",
"\n",
" else:\n",
" #print(solver.model()) # Counterexample\n",
" return False\n",
"\n",
" return True"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open(filename, 'rb') as fstream: \n",
" cont = Container.from_stream(fstream)\n",
" \n",
"machine = Machine('x86_32')\n",
"mdis = machine.dis_engine(cont.bin_stream)\n",
"ir_arch0 = machine.ira(mdis.loc_db)\n",
"ir_arch1 = machine.ira(mdis.loc_db)\n",
"\n",
"asmcfg = mdis.dis_multiblock(target_addr)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"target_blocks = []\n",
"for cn, block in enumerate(asmcfg.blocks):\n",
" target_blocks.append(block)\n",
"\n",
"results = {}\n",
"\n",
"for src_blk in target_blocks:\n",
" src_ldl = src_blk._loc_key\n",
"\n",
" # Skip a basic block containing only single instruction\n",
" if len(src_blk.lines) == 1 and src_blk.lines[0].dstflow():\n",
" continue\n",
"\n",
" for dst_blk in target_blocks:\n",
" dst_ldl = dst_blk._loc_key\n",
"\n",
" # Skip a basic block containing only single instruction\n",
" if len(dst_blk.lines) == 1 and dst_blk.lines[0].dstflow():\n",
" continue\n",
"\n",
" if src_ldl == dst_ldl:\n",
" continue\n",
"\n",
" if (src_ldl, dst_ldl) in results.keys() or \\\n",
" (dst_ldl, src_ldl) in results.keys():\n",
" continue\n",
" \n",
" r_syntax = syntax_compare(src_blk, dst_blk)\n",
"\n",
" if r_syntax:\n",
" # If the syntax of two blocks is same, then the semantics of them is also same.\n",
" r_semantic = True\n",
" else:\n",
" # Otherwise, need to compare the semantics of them\n",
" r_semantic = semantic_compare(src_blk, dst_blk, ir_arch0, ir_arch1, asmcfg)\n",
"\n",
" results[(src_ldl, dst_ldl)] = [(r_syntax, r_semantic)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if idc:\n",
" G = nx.Graph()\n",
" G.add_nodes_from(target_blocks)\n",
"\n",
" for k, v in viewitems(results):\n",
" if v[0][0] or v[0][1]:\n",
" G.add_edge(k[0], k[1])\n",
"\n",
" # Return a list containing randomlly generated colors\n",
" def gen_random_color():\n",
"\n",
" ret = []\n",
"\n",
" r = [x for x in range(256)]\n",
" g = [x for x in range(256)]\n",
" b = [x for x in range(256)]\n",
" random.shuffle(r)\n",
" random.shuffle(g)\n",
" random.shuffle(b)\n",
"\n",
" for a2, a1, a0 in zip(r,g,b):\n",
" color = a2 << 16 | a1 << 8 | a0\n",
" ret.append(color)\n",
"\n",
" return ret\n",
"\n",
" random_colors = gen_random_color()\n",
" body = ''\n",
"\n",
" for n, conn_nodes in enumerate(nx.connected_components(G)):\n",
"\n",
" if len(conn_nodes) == 1:\n",
" continue\n",
"\n",
" for node in conn_nodes: # node is asmblk\n",
"\n",
" if isinstance(node, LocKey):\n",
" asmblk = asmcfg.loc_key_to_block(node)\n",
" if asmblk:\n",
" for l in asmblk.lines:\n",
" body += 'SetColor(0x%08x, CIC_ITEM, 0x%x);\\n'%(l.offset, random_colors[n])\n",
" else:\n",
" for l in node.lines:\n",
" body += 'SetColor(0x%08x, CIC_ITEM, 0x%x);\\n'%(l.offset, random_colors[n])\n",
" \n",
" header = '''\n",
"#include <idc.idc>\n",
"static main()\n",
"{\n",
"'''\n",
" footer = '''\n",
"}\n",
"'''\n",
"\n",
" f = open('eq-color.idc', 'w')\n",
" f.write(header+body+footer)\n",
" f.close()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
| {
"pile_set_name": "Github"
} |
/**
* External dependencies
*/
import { By } from 'selenium-webdriver';
/**
* Internal dependencies
*/
import AsyncBaseContainer from '../async-base-container';
import * as driverHelper from '../driver-helper.js';
export default class JetpackPlansSalesPage extends AsyncBaseContainer {
constructor( driver ) {
super( driver, By.css( '.cta-install #btn-mast-getstarted' ) );
}
async clickPurchaseButton() {
const selector = By.css( '.cta-install #btn-mast-getstarted' );
await driverHelper.waitTillPresentAndDisplayed( this.driver, selector );
return await driverHelper.clickWhenClickable( this.driver, selector );
}
}
| {
"pile_set_name": "Github"
} |
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
| {
"pile_set_name": "Github"
} |
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <system_error>
// class error_category
// bool operator<(const error_category& rhs) const;
#include <system_error>
#include <cassert>
int main()
{
const std::error_category& e_cat1 = std::generic_category();
const std::error_category& e_cat2 = std::generic_category();
const std::error_category& e_cat3 = std::system_category();
assert(!(e_cat1 < e_cat2) && !(e_cat2 < e_cat1));
assert((e_cat1 < e_cat3) || (e_cat3 < e_cat1));
}
| {
"pile_set_name": "Github"
} |
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by lister-gen. DO NOT EDIT.
package v1beta1
import (
v1beta1 "k8s.io/api/storage/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// StorageClassLister helps list StorageClasses.
type StorageClassLister interface {
// List lists all StorageClasses in the indexer.
List(selector labels.Selector) (ret []*v1beta1.StorageClass, err error)
// Get retrieves the StorageClass from the index for a given name.
Get(name string) (*v1beta1.StorageClass, error)
StorageClassListerExpansion
}
// storageClassLister implements the StorageClassLister interface.
type storageClassLister struct {
indexer cache.Indexer
}
// NewStorageClassLister returns a new StorageClassLister.
func NewStorageClassLister(indexer cache.Indexer) StorageClassLister {
return &storageClassLister{indexer: indexer}
}
// List lists all StorageClasses in the indexer.
func (s *storageClassLister) List(selector labels.Selector) (ret []*v1beta1.StorageClass, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1beta1.StorageClass))
})
return ret, err
}
// Get retrieves the StorageClass from the index for a given name.
func (s *storageClassLister) Get(name string) (*v1beta1.StorageClass, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1beta1.Resource("storageclass"), name)
}
return obj.(*v1beta1.StorageClass), nil
}
| {
"pile_set_name": "Github"
} |
# -*- encoding : utf-8 -*-
require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
describe "request_mailer/stopped_responses" do
let(:user) { FactoryBot.create(:user, :name => "Test Us'r") }
let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") }
let(:request) do
FactoryBot.create(:info_request,
:public_body => body,
:user => user,
:title => "Request apostrophe's data")
end
before do
allow(AlaveteliConfiguration).to receive(:site_name).
and_return("l'Information")
assign(:contact_email, "nospam@example.com")
end
it "does not add HTMLEntities to the FOI law title" do
allow(request).to receive(:law_used_human).and_return("Test's Law")
assign(:info_request, request)
render
expect(response).to match("an Test's Law request")
end
it "does not add HTMLEntities to the request title" do
assign(:info_request, request)
render
expect(response).to match("Request apostrophe's data is an old request")
end
it "does not add HTMLEntities to the user name" do
assign(:info_request, request)
render
expect(response).to match("sent to Test Us'r")
expect(response).to match("on another subject to Test Us'r")
end
it "does not add HTMLEntities to the public body name" do
assign(:info_request, request)
render
expect(response).to match("on behalf of Apostrophe's,")
end
it "does not add HTMLEntities to the contact email" do
assign(:info_request, request)
assign(:contact_email, "a'b@example.com")
render
expect(response).to match("email a'b@example.com to ask us to reopen")
end
it "does not add HTMLEntities to the site name" do
assign(:info_request, request)
render
expect(response).to match("the l'Information team")
end
end
| {
"pile_set_name": "Github"
} |
# optimization
n_epochs: 20
convert_to_sgd_epoch: 15
print_step: 600
lr_decay_start_epoch: 5
lr_decay_rate: 0.8
| {
"pile_set_name": "Github"
} |
{
"name": "example-example82",
"files": [
"index-production.html",
"script.js",
"my-customer-plus-vojta.html"
]
} | {
"pile_set_name": "Github"
} |
/* iCheck plugin Polaris skin
----------------------------------- */
.icheckbox_polaris,
.iradio_polaris {
display: block;
margin: 0;
padding: 0;
width: 29px;
height: 29px;
background: url(polaris.png) no-repeat;
border: none;
cursor: pointer;
}
.icheckbox_polaris {
background-position: 0 0;
}
.icheckbox_polaris.hover {
background-position: -31px 0;
}
.icheckbox_polaris.checked {
background-position: -62px 0;
}
.icheckbox_polaris.disabled {
background-position: -93px 0;
cursor: default;
}
.icheckbox_polaris.checked.disabled {
background-position: -124px 0;
}
.iradio_polaris {
background-position: -155px 0;
}
.iradio_polaris.hover {
background-position: -186px 0;
}
.iradio_polaris.checked {
background-position: -217px 0;
}
.iradio_polaris.disabled {
background-position: -248px 0;
cursor: default;
}
.iradio_polaris.checked.disabled {
background-position: -279px 0;
}
/* Retina support */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-moz-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-device-pixel-ratio: 1.5) {
.icheckbox_polaris,
.iradio_polaris {
background-image: url(polaris@2x.png);
-webkit-background-size: 310px 31px;
background-size: 310px 31px;
}
} | {
"pile_set_name": "Github"
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.testframework.GridTestUtils.SF;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
/**
* Tests cache values consistency for transactional cache.
*/
public class GridCacheValueConsistencyTransactionalSelfTest extends GridCacheValueConsistencyAbstractSelfTest {
/** {@inheritDoc} */
@Override protected CacheAtomicityMode atomicityMode() {
return TRANSACTIONAL;
}
/** {@inheritDoc} */
@Override protected int iterationCount() {
return SF.apply(50_000);
}
}
| {
"pile_set_name": "Github"
} |
/*
* API - General configuration related calls
*
* Copyright (C) 2015 Jaroslav Kysela
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; withm even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tvheadend.h"
#include "channels.h"
#include "access.h"
#include "memoryinfo.h"
#include "api.h"
#include "config.h"
static int
api_config_capabilities(access_t *perm, void *opaque, const char *op,
htsmsg_t *args, htsmsg_t **resp)
{
*resp = tvheadend_capabilities_list(0);
return 0;
}
static void
api_memoryinfo_grid
( access_t *perm, idnode_set_t *ins, api_idnode_grid_conf_t *conf, htsmsg_t *args )
{
memoryinfo_t *my;
LIST_FOREACH(my, &memoryinfo_entries, my_link) {
if (my->my_update)
my->my_update(my);
idnode_set_add(ins, (idnode_t*)my, &conf->filter, perm->aa_lang_ui);
}
}
void
api_config_init ( void )
{
static api_hook_t ah[] = {
{ "config/capabilities", ACCESS_OR|ACCESS_WEB_INTERFACE|ACCESS_HTSP_INTERFACE, api_config_capabilities, NULL },
{ "config/load", ACCESS_ADMIN, api_idnode_load_simple, &config },
{ "config/save", ACCESS_ADMIN, api_idnode_save_simple, &config },
{ "tvhlog/config/load", ACCESS_ADMIN, api_idnode_load_simple, &tvhlog_conf },
{ "tvhlog/config/save", ACCESS_ADMIN, api_idnode_save_simple, &tvhlog_conf },
{ "memoryinfo/class", ACCESS_ADMIN, api_idnode_class, (void *)&memoryinfo_class },
{ "memoryinfo/grid", ACCESS_ADMIN, api_idnode_grid, api_memoryinfo_grid },
{ NULL },
};
api_register_all(ah);
}
| {
"pile_set_name": "Github"
} |
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Builder function for image resizing operations."""
import functools
import tensorflow as tf
from object_detection.core import preprocessor
from object_detection.protos import image_resizer_pb2
def _tf_resize_method(resize_method):
"""Maps image resize method from enumeration type to TensorFlow.
Args:
resize_method: The resize_method attribute of keep_aspect_ratio_resizer or
fixed_shape_resizer.
Returns:
method: The corresponding TensorFlow ResizeMethod.
Raises:
ValueError: if `resize_method` is of unknown type.
"""
dict_method = {
image_resizer_pb2.BILINEAR:
tf.image.ResizeMethod.BILINEAR,
image_resizer_pb2.NEAREST_NEIGHBOR:
tf.image.ResizeMethod.NEAREST_NEIGHBOR,
image_resizer_pb2.BICUBIC:
tf.image.ResizeMethod.BICUBIC,
image_resizer_pb2.AREA:
tf.image.ResizeMethod.AREA
}
if resize_method in dict_method:
return dict_method[resize_method]
else:
raise ValueError('Unknown resize_method')
def build(image_resizer_config):
"""Builds callable for image resizing operations.
Args:
image_resizer_config: image_resizer.proto object containing parameters for
an image resizing operation.
Returns:
image_resizer_fn: Callable for image resizing. This callable always takes
a rank-3 image tensor (corresponding to a single image) and returns a
rank-3 image tensor, possibly with new spatial dimensions.
Raises:
ValueError: if `image_resizer_config` is of incorrect type.
ValueError: if `image_resizer_config.image_resizer_oneof` is of expected
type.
ValueError: if min_dimension > max_dimension when keep_aspect_ratio_resizer
is used.
"""
if not isinstance(image_resizer_config, image_resizer_pb2.ImageResizer):
raise ValueError('image_resizer_config not of type '
'image_resizer_pb2.ImageResizer.')
if image_resizer_config.WhichOneof(
'image_resizer_oneof') == 'keep_aspect_ratio_resizer':
keep_aspect_ratio_config = image_resizer_config.keep_aspect_ratio_resizer
if not (keep_aspect_ratio_config.min_dimension <=
keep_aspect_ratio_config.max_dimension):
raise ValueError('min_dimension > max_dimension')
method = _tf_resize_method(keep_aspect_ratio_config.resize_method)
return functools.partial(
preprocessor.resize_to_range,
min_dimension=keep_aspect_ratio_config.min_dimension,
max_dimension=keep_aspect_ratio_config.max_dimension,
method=method)
if image_resizer_config.WhichOneof(
'image_resizer_oneof') == 'fixed_shape_resizer':
fixed_shape_resizer_config = image_resizer_config.fixed_shape_resizer
method = _tf_resize_method(fixed_shape_resizer_config.resize_method)
return functools.partial(
preprocessor.resize_image,
new_height=fixed_shape_resizer_config.height,
new_width=fixed_shape_resizer_config.width,
method=method)
raise ValueError('Invalid image resizer option.')
| {
"pile_set_name": "Github"
} |
module.exports = {
"type": "Program",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"range": [
0,
18
],
"body": [
{
"type": "ExportDefaultDeclaration",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"range": [
0,
18
],
"declaration": {
"type": "Literal",
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 17
}
},
"range": [
15,
17
],
"value": 42,
"raw": "42"
}
}
],
"sourceType": "module",
"tokens": [
{
"type": "Keyword",
"value": "export",
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 6
}
},
"range": [
0,
6
]
},
{
"type": "Keyword",
"value": "default",
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
}
},
"range": [
7,
14
]
},
{
"type": "Numeric",
"value": "42",
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 17
}
},
"range": [
15,
17
]
},
{
"type": "Punctuator",
"value": ";",
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
}
},
"range": [
17,
18
]
}
]
}; | {
"pile_set_name": "Github"
} |
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// expected-no-diagnostics
// Various tests related to partial ordering of variadic templates.
template<typename ...Types> struct tuple;
template<typename Tuple>
struct X1 {
static const unsigned value = 0;
};
template<typename Head, typename ...Tail>
struct X1<tuple<Head, Tail...> > {
static const unsigned value = 1;
};
template<typename Head, typename ...Tail>
struct X1<tuple<Head, Tail&...> > {
static const unsigned value = 2;
};
template<typename Head, typename ...Tail>
struct X1<tuple<Head&, Tail&...> > {
static const unsigned value = 3;
};
int check0[X1<tuple<>>::value == 0? 1 : -1];
int check1[X1<tuple<int>>::value == 2? 1 : -1];
int check2[X1<tuple<int, int>>::value == 1? 1 : -1];
int check3[X1<tuple<int, int&>>::value == 2? 1 : -1];
int check4[X1<tuple<int&, int&>>::value == 3? 1 : -1];
// Partial ordering of function templates.
template<typename T1, typename T2, typename ...Rest>
int &f0(T1, T2, Rest...);
template<typename T1, typename T2>
float &f0(T1, T2);
void test_f0() {
int &ir1 = f0(1, 2.0, 'a');
float &fr1 = f0(1, 2.0);
}
template<typename T1, typename T2, typename ...Rest>
int &f1(T1, T2, Rest...);
template<typename T1, typename T2>
float &f1(T1, T2, ...);
void test_f1() {
int &ir1 = f1(1, 2.0, 'a');
}
template<typename T1, typename T2, typename ...Rest>
int &f2(T1, T2, Rest...);
float &f2(...);
void test_f2() {
int &ir1 = f2(1, 2.0, 'a');
}
| {
"pile_set_name": "Github"
} |
package Paws::Transfer::UpdateServerResponse;
use Moose;
has ServerId => (is => 'ro', isa => 'Str', required => 1);
has _request_id => (is => 'ro', isa => 'Str');
### main pod documentation begin ###
=head1 NAME
Paws::Transfer::UpdateServerResponse
=head1 ATTRIBUTES
=head2 B<REQUIRED> ServerId => Str
A system-assigned unique identifier for an SFTP server that the user
account is assigned to.
=head2 _request_id => Str
=cut
1; | {
"pile_set_name": "Github"
} |
/*-
* #%L
* thinkbig-ui-common
* %%
* Copyright (C) 2017 ThinkBig Analytics
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import * as angular from 'angular';
import {moduleName} from './module-name';
import "pascalprecht.translate";
import * as moment from "moment";
export class Utils{
constructor (private $timeout: any,
private $filter: any) {
var waitForDomRetryCounts: any = {};
var data: any= {
stickTabHeader: function ($element: any) {
var tabsWrapper: any= $element.find('md-tabs-wrapper');
this.stickTabHeader2($element, tabsWrapper);
},
stickTabHeader2: function ($element: any, $tabsWrapper: any) {
var header: any= angular.element('.page-header');
var headerHeight: any = header.height();
var window_top: any= 0;
var div_top: any= $element.find('.sticky-anchor').offset().top;
if (div_top < headerHeight) {
if (div_top < 0) {
$tabsWrapper.css('top', Math.abs(div_top) + headerHeight + 'px')
}
else {
$tabsWrapper.css('top', Math.abs(headerHeight - Math.abs(div_top)) + 'px')
}
} else {
$tabsWrapper.css('top', '0px')
}
},
maskProfanity: function (str: any) {
return str;
},
/**
*
* @param selector element selector (i.e. #TableId)
* @param callbackFn // the function to execute when the selector element is found in the DOM
*/
waitForDomElementReady: function (selector: any, callbackFn: any) {
if (waitForDomRetryCounts[selector] == undefined) {
waitForDomRetryCounts[selector] = 0;
}
var $ele: any= angular.element(selector);
if ($ele.length > 0) {
delete waitForDomRetryCounts[selector];
callbackFn();
}
else {
waitForDomRetryCounts[selector] += 1;
if (waitForDomRetryCounts[selector] <= 50) {
$timeout(data.waitForDomElementReady, 5, false, selector, callbackFn);
}
}
},
strEndsWith: function (str: any, suffix: any) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
},
endsWith: function (str: any, suffix: any) {
return this.strEndsWith(str, suffix);
},
startsWith: function (str: any, prefix: any) {
return str.indexOf(prefix) === 0;
},
camelCaseToWords: function (str: any) {
return str.match(/^[a-z]+|[A-Z][a-z]*/g).map(function (x: any) {
return x[0].toUpperCase() + x.substr(1).toLowerCase();
}).join(' ');
},
capitalizeFirstLetter: function (string: any) {
if (string && string != '') {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
return '';
},
convertDate: function (date: any) {
if (date == null) {
return "--";
}
var local: any = new Date(date);
local.setMinutes(local.getMinutes() - local.getTimezoneOffset());
return local.toISOString().slice(0, 10) + " " + local.toISOString().slice(11, 19);
},
dateDifference: function (startDate: any, endDate: any) {
if (startDate == null || endDate == null) {
return "N/A";
}
else {
var msec: any = endDate - startDate;
return this.formatTimeMinSec(msec);
}
},
dateDifferenceMs: function (startDate: any, endDate: any) {
var diff: any= endDate - startDate;
return diff;
},
formatTimeMinSec: function (timeInMSec: any) {
// return this.TimeDiffString(timeInMSec);
if (timeInMSec == null) {
return "N/A";
}
else {
if (timeInMSec < 0) {
return "0 sec";
}
var sec_num: any = timeInMSec / 1000;
sec_num = parseInt(sec_num, 10);
var hours: any= Math.floor(sec_num / 3600);
var minutes: any= Math.floor((sec_num - (hours * 3600)) / 60);
var seconds: any= sec_num - (hours * 3600) - (minutes * 60);
var str: any = seconds + " " +$filter('translate')('views.Utils.sec');
if (hours == 0) {
if (minutes != 0) {
str = minutes + " " + $filter('translate')('views.Utils.min')+ " " + str;
}
}
else {
str = hours + " " + $filter('translate')('views.Utils.hrs')+ " " + minutes + " " + $filter('translate')('views.Utils.min')+ " " + str;
}
return str;
}
},
TimeDiffString: function (timeInMs: any) {
var diffString: any = moment.utc(timeInMs).format('HH:mm:ss'); // duration
if (diffString == '00') {
diffString = '0';
}
var parts: any= diffString.split(':');
var suffixes: any= ['hr', 'min', 'sec'];
var len: any = parts.length;
var suffixIndex: any = Math.abs(len - 3);
var startIndex: any = parts.length;
var timeString: any = '';
for (var i = 0; i < parts.length; i++) {
if (i > 0) {
timeString += ' ';
}
timeString += parts[i] + ' ' + suffixes[suffixIndex];
suffixIndex++;
}
return timeString;
},
DateDiffString: function (date1: any, date2: any) {
var diff: any = date2.getTime() - date2.getTime();
return this.TimeDiffString(diff);
},
getParameterByName: function (name: any) {
var match: any = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
},
toBoolean: function (str: any) {
if (typeof str == "boolean") {
return str;
}
else if (typeof str == "string") {
return str.toLowerCase() == "true";
}
else if (typeof str == "number") {
return str == 1;
}
return false;
},
resolveStatusClass: function (status: any, exitCode: any) {
var statusClass: any = 'status-info';
switch (status) {
case "STARTED":
case "RUNNING":
case "COMPLETED":
if (exitCode && exitCode == 'FAILED') {
statusClass = 'status-errors';
}
else {
statusClass = 'status-healthy';
}
break;
case "FAILED":
statusClass = 'status-errors';
break;
default:
}
return statusClass;
}
};
return data;
}
}
angular.module(moduleName).factory('Utils', ["$timeout", "$filter",Utils]);
| {
"pile_set_name": "Github"
} |
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Handles Quoted Printable (Q) Header Encoding in Swift Mailer.
*
* @author Chris Corbyn
*/
class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_HeaderEncoder
{
/**
* Creates a new QpHeaderEncoder for the given CharacterStream.
*
* @param Swift_CharacterStream $charStream to use for reading characters
*/
public function __construct(Swift_CharacterStream $charStream)
{
parent::__construct($charStream);
}
protected function initSafeMap()
{
foreach (array_merge(
range(0x61, 0x7A), range(0x41, 0x5A),
range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F]
) as $byte) {
$this->safeMap[$byte] = chr($byte);
}
}
/**
* Get the name of this encoding scheme.
*
* Returns the string 'Q'.
*
* @return string
*/
public function getName()
{
return 'Q';
}
/**
* Takes an unencoded string and produces a QP encoded string from it.
*
* @param string $string string to encode
* @param int $firstLineOffset optional
* @param int $maxLineLength optional, 0 indicates the default of 76 chars
*
* @return string
*/
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
{
return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"],
parent::encodeString($string, $firstLineOffset, $maxLineLength)
);
}
}
| {
"pile_set_name": "Github"
} |
<component name="libraryTable">
<library name="Maven: javax.servlet.jsp:javax.servlet.jsp-api:2.3.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/jsp/javax.servlet.jsp-api/2.3.1/javax.servlet.jsp-api-2.3.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/jsp/javax.servlet.jsp-api/2.3.1/javax.servlet.jsp-api-2.3.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/jsp/javax.servlet.jsp-api/2.3.1/javax.servlet.jsp-api-2.3.1-sources.jar!/" />
</SOURCES>
</library>
</component> | {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tencentcloudapi.vod.v20180717.models;
import com.tencentcloudapi.common.AbstractModel;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import java.util.HashMap;
public class ResolutionNameInfo extends AbstractModel{
/**
* 视频短边长度,单位:像素。
*/
@SerializedName("MinEdgeLength")
@Expose
private Long MinEdgeLength;
/**
* 展示名字。
*/
@SerializedName("Name")
@Expose
private String Name;
/**
* Get 视频短边长度,单位:像素。
* @return MinEdgeLength 视频短边长度,单位:像素。
*/
public Long getMinEdgeLength() {
return this.MinEdgeLength;
}
/**
* Set 视频短边长度,单位:像素。
* @param MinEdgeLength 视频短边长度,单位:像素。
*/
public void setMinEdgeLength(Long MinEdgeLength) {
this.MinEdgeLength = MinEdgeLength;
}
/**
* Get 展示名字。
* @return Name 展示名字。
*/
public String getName() {
return this.Name;
}
/**
* Set 展示名字。
* @param Name 展示名字。
*/
public void setName(String Name) {
this.Name = Name;
}
/**
* Internal implementation, normal users should not use it.
*/
public void toMap(HashMap<String, String> map, String prefix) {
this.setParamSimple(map, prefix + "MinEdgeLength", this.MinEdgeLength);
this.setParamSimple(map, prefix + "Name", this.Name);
}
}
| {
"pile_set_name": "Github"
} |
TodoReview 2.1.0
--------------------
This is the first minor release of TodoReview and it's a feature packed one. Here are some quick bullets; the full changelog is below and documentation is at https://github.com/jonathandelgado/SublimeTodoReview
As always, please report any issues.
- BREAKING CHANGE: Removed support for @critical and @priority tags, replaced by the priority system.
- Added: Priority System. Can add (0) (or any number) to any note in any position and they will be sorted by lowest first. More info on the readme.
- Added: New command pallet option to search open files in addition to project files
- Added: New setting, `render_include_folder` - More info on the readme.
- Added: New setting, `render_spaces` - More info on the readme.
- Fixed: Sidebar not being able to open files, just folders.
- Updated Readme
Changelog:
- Updated Readme
- Added Sort by Priority
- Removed priority highlighting for priority and critical tags
- Cleaned some code
- Added ability to search open files (#19)
- Fixed Sidebar option not working on single file (#15)
- Added setting `render_spaces` (#16)
- Added setting `render_include_folder` (#12)
- Added install instructions
- Documented Sidebar Feature | {
"pile_set_name": "Github"
} |
/Makefile/1.8.2.2/Sun Jul 27 17:01:22 2008//Tr1-3-1
/car6-trb1.rgb/1.1.2.1/Sun Jul 27 17:01:22 2008/-kb/Tr1-3-1
/default.xml/1.1.2.1/Wed May 28 21:34:49 2008//Tr1-3-1
D
| {
"pile_set_name": "Github"
} |
---
title: Inappbrowser
description: Open an in-app browser window.
---
<!--
# license: Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-->
|AppVeyor|Travis CI|
|:-:|:-:|
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-inappbrowser)|[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)|
# cordova-plugin-inappbrowser
You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app.
> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content.
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
### `window.open`
The `cordova.InAppBrowser.open()` function is defined to be a drop-in replacement
for the `window.open()` function. Existing `window.open()` calls can use the
InAppBrowser window, by replacing window.open:
window.open = cordova.InAppBrowser.open;
The InAppBrowser window behaves like a standard web browser,
and can't access Cordova APIs. For this reason, the InAppBrowser is recommended
if you need to load third-party (untrusted) content, instead of loading that
into the main Cordova webview. The InAppBrowser is not subject to the
whitelist, nor is opening links in the system browser.
The InAppBrowser provides by default its own GUI controls for the user (back,
forward, done).
For backwards compatibility, this plugin also hooks `window.open`.
However, the plugin-installed hook of `window.open` can have unintended side
effects (especially if this plugin is included only as a dependency of another
plugin). The hook of `window.open` will be removed in a future major release.
Until the hook is removed from the plugin, apps can manually restore the default
behaviour:
delete window.open // Reverts the call back to its prototype's default
Although `window.open` is in the global scope, InAppBrowser is not available until after the `deviceready` event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("window.open works well");
}
## Installation
cordova plugin add cordova-plugin-inappbrowser
If you want all page loads in your app to go through the InAppBrowser, you can
simply hook `window.open` during initialization. For example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}
## cordova.InAppBrowser.open
Opens a URL in a new `InAppBrowser` instance, the current browser
instance, or the system browser.
var ref = cordova.InAppBrowser.open(url, target, options);
- __ref__: Reference to the `InAppBrowser` window when the target is set to `'_blank'`. _(InAppBrowser)_
- __url__: The URL to load _(String)_. Call `encodeURI()` on this if the URL contains Unicode characters.
- __target__: The target in which to load the URL, an optional parameter that defaults to `_self`. _(String)_
- `_self`: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the `InAppBrowser`.
- `_blank`: Opens in the `InAppBrowser`.
- `_system`: Opens in the system's web browser.
- __options__: Options for the `InAppBrowser`. Optional, defaulting to: `location=yes`. _(String)_
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive.
All platforms support:
- __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off.
Android supports these additional options:
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
- __beforeload__: set to enable the `beforeload` event to modify which pages are actually loaded in the browser. Accepted values are `get` to intercept only GET requests, `post` to intercept on POST requests or `yes` to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set `beforeload=post` it will raise an error).
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
- __closebuttoncaption__: set to a string to use as the close button's caption instead of a X. Note that you need to localize this value yourself.
- __closebuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the
close button color from default, regardless of being a text or default X. Only has effect if user has location set to `yes`.
- __footer__: set to `yes` to show a close button in the footer similar to the iOS __Done__ button.
The close button will appear the same as for the header hence use __closebuttoncaption__ and __closebuttoncolor__ to set its properties.
- __footercolor__: set to a valid hex color string, for example `#00ff00` or `#CC00ff00` (`#aarrggbb`) , and it will change the footer color from default.
Only has effect if user has __footer__ set to `yes`.
- __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser.
- __hidenavigationbuttons__: set to `yes` to hide the navigation buttons on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`.
- __hideurlbar__: set to `yes` to hide the url bar on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`.
- __navigationbuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color of both navigation buttons from default. Only has effect if user has location set to `yes` and not hidenavigationbuttons set to `yes`.
- __toolbarcolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color the toolbar from default. Only has effect if user has location set to `yes`.
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the left and close button to the right.
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`.
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
- __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)).
- __useWideViewPort__: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is `no`, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is `yes` and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to `yes`).
iOS supports these additional options:
- __usewkwebview__: set to `yes` to use WKWebView engine for the InappBrowser. Omit or set to `no` (default) to use UIWebView. Note: Using `usewkwebview=yes` requires that a WKWebView engine plugin be installed in the Cordova project (e.g. [cordova-plugin-wkwebview-engine](https://github.com/apache/cordova-plugin-wkwebview-engine) or [cordova-plugin-ionic-webview](https://github.com/ionic-team/cordova-plugin-ionic-webview)).
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
- __beforeload__: set to enable the `beforeload` event to modify which pages are actually loaded in the browser. Accepted values are `get` to intercept only GET requests, `post` to intercept on POST requests or `yes` to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set `beforeload=post` it will raise an error).
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened. For WKWebView, requires iOS 11+ on target device.
- __cleardata__: set to `yes` to have the browser's entire local storage cleared (cookies, HTML5 local storage, IndexedDB, etc.) before the new window is opened
- __closebuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default __Done__ button's color. Only applicable if toolbar is not disabled.
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
- __hidenavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled.
- __navigationbuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color. Only applicable if navigation buttons are visible.
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
- __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left.
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`) on iOS 10+.
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). Only applicable to UIWebView (`usewkwebview=no`).
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
- __presentationstyle__: Set to `pagesheet`, `formsheet` or `fullscreen` to set the [presentation style](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle) (defaults to `fullscreen`).
- __transitionstyle__: Set to `fliphorizontal`, `crossdissolve` or `coververtical` to set the [transition style](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle) (defaults to `coververtical`).
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.
- __hidespinner__: Set to `yes` or `no` to change the visibility of the loading indicator (defaults to `no`).
Windows supports these additional options:
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
- __hardwareback__: works the same way as on Android platform.
- __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window.
### Supported Platforms
- Android
- Browser
- iOS
- OSX
- Windows
### Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref2 = cordova.InAppBrowser.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes');
### OSX Quirks
At the moment the only supported target in OSX is `_system`.
`_blank` and `_self` targets are not yet implemented and are ignored silently. Pull requests and patches to get these to work are greatly appreciated.
### Browser Quirks
- Plugin is implemented via iframe,
- Navigation history (`back` and `forward` buttons in LocationBar) is not implemented.
## InAppBrowser
The object returned from a call to `cordova.InAppBrowser.open` when the target is set to `'_blank'`.
### Methods
- addEventListener
- removeEventListener
- close
- show
- hide
- executeScript
- insertCSS
## InAppBrowser.addEventListener
> Adds a listener for an event from the `InAppBrowser`. (Only available when the target is set to `'_blank'`)
ref.addEventListener(eventname, callback);
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
- __eventname__: the event to listen for _(String)_
- __loadstart__: event fires when the `InAppBrowser` starts to load a URL.
- __loadstop__: event fires when the `InAppBrowser` finishes loading a URL.
- __loaderror__: event fires when the `InAppBrowser` encounters an error when loading a URL.
- __exit__: event fires when the `InAppBrowser` window is closed.
- __beforeload__: event fires when the `InAppBrowser` decides whether to load an URL or not (only with option `beforeload` set).
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
- __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter.
## Example
```javascript
var inAppBrowserRef;
function showHelp(url) {
var target = "_blank";
var options = "location=yes,hidden=yes,beforeload=yes";
inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
inAppBrowserRef.addEventListener('loadstart', loadStartCallBack);
inAppBrowserRef.addEventListener('loadstop', loadStopCallBack);
inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack);
inAppBrowserRef.addEventListener('beforeload', beforeloadCallBack);
inAppBrowserRef.addEventListener('message', messageCallBack);
}
function loadStartCallBack() {
$('#status-message').text("loading please wait ...");
}
function loadStopCallBack() {
if (inAppBrowserRef != undefined) {
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
inAppBrowserRef.executeScript({ code: "\
var message = 'this is the message';\
var messageObj = {my_message: message};\
var stringifiedMessageObj = JSON.stringify(messageObj);\
webkit.messageHandlers.cordova_iab.postMessage(stringifiedMessageObj);"
});
$('#status-message').text("");
inAppBrowserRef.show();
}
}
function loadErrorCallBack(params) {
$('#status-message').text("");
var scriptErrorMesssage =
"alert('Sorry we cannot open that page. Message from the server is : "
+ params.message + "');"
inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack);
inAppBrowserRef.close();
inAppBrowserRef = undefined;
}
function executeScriptCallBack(params) {
if (params[0] == null) {
$('#status-message').text(
"Sorry we couldn't open that page. Message from the server is : '"
+ params.message + "'");
}
}
function beforeloadCallBack(params, callback) {
if (params.url.startsWith("http://www.example.com/")) {
// Load this URL in the inAppBrowser.
callback(params.url);
} else {
// The callback is not invoked, so the page will not be loaded.
$('#status-message').text("This browser only opens pages on http://www.example.com/");
}
}
function messageCallBack(params){
$('#status-message').text("message received: "+params.data.my_message);
}
```
### InAppBrowserEvent Properties
- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, `message` or `exit`. _(String)_
- __url__: the URL that was loaded. _(String)_
- __code__: the error code, only in the case of `loaderror`. _(Number)_
- __message__: the error message, only in the case of `loaderror`. _(String)_
- __data__: the message contents , only in the case of `message`. A stringified JSON object. _(String)_
### Supported Platforms
- Android
- Browser
- iOS
- Windows
- OSX
### Browser Quirks
`loadstart`, `loaderror`, `message` events are not fired.
### Windows Quirks
`message` event is not fired.
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event) { alert(event.url); });
## InAppBrowser.removeEventListener
> Removes a listener for an event from the `InAppBrowser`. (Only available when the target is set to `'_blank'`)
ref.removeEventListener(eventname, callback);
- __ref__: reference to the `InAppBrowser` window. _(InAppBrowser)_
- __eventname__: the event to stop listening for. _(String)_
- __loadstart__: event fires when the `InAppBrowser` starts to load a URL.
- __loadstop__: event fires when the `InAppBrowser` finishes loading a URL.
- __loaderror__: event fires when the `InAppBrowser` encounters an error loading a URL.
- __exit__: event fires when the `InAppBrowser` window is closed.
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
- __callback__: the function to execute when the event fires.
The function is passed an `InAppBrowserEvent` object.
### Supported Platforms
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var myCallback = function(event) { alert(event.url); }
ref.addEventListener('loadstart', myCallback);
ref.removeEventListener('loadstart', myCallback);
## InAppBrowser.close
> Closes the `InAppBrowser` window.
ref.close();
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
### Supported Platforms
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
ref.close();
## InAppBrowser.show
> Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible.
ref.show();
- __ref__: reference to the InAppBrowser window (`InAppBrowser`)
### Supported Platforms
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'hidden=yes');
// some time later...
ref.show();
## InAppBrowser.hide
> Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden.
ref.hide();
- __ref__: reference to the InAppBrowser window (`InAppBrowser`)
### Supported Platforms
- Android
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank');
// some time later...
ref.hide();
## InAppBrowser.executeScript
> Injects JavaScript code into the `InAppBrowser` window. (Only available when the target is set to `'_blank'`)
ref.executeScript(details, callback);
- __ref__: reference to the `InAppBrowser` window. _(InAppBrowser)_
- __injectDetails__: details of the script to run, specifying either a `file` or `code` key. _(Object)_
- __file__: URL of the script to inject.
- __code__: Text of the script to inject.
- __callback__: the function that executes after the JavaScript code is injected.
- If the injected script is of type `code`, the callback executes
with a single parameter, which is the return value of the
script, wrapped in an `Array`. For multi-line scripts, this is
the return value of the last statement, or the last expression
evaluated.
### Supported Platforms
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.executeScript({file: "myscript.js"});
});
### Browser Quirks
- only __code__ key is supported.
### Windows Quirks
Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`.
## InAppBrowser.insertCSS
> Injects CSS into the `InAppBrowser` window. (Only available when the target is set to `'_blank'`)
ref.insertCSS(details, callback);
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
- __injectDetails__: details of the script to run, specifying either a `file` or `code` key. _(Object)_
- __file__: URL of the stylesheet to inject.
- __code__: Text of the stylesheet to inject.
- __callback__: the function that executes after the CSS is injected.
### Supported Platforms
- Android
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.insertCSS({file: "mystyles.css"});
});
__
## <a id="sample"></a>Sample: Show help pages with an InAppBrowser
You can use this plugin to show helpful documentation pages within your app. Users can view online help documents and then close them without leaving the app.
Here's a few snippets that show how you do this.
* [Give users a way to ask for help](#give).
* [Load a help page](#load).
* [Let users know that you're getting their page ready](#let).
* [Show the help page](#show).
* [Handle page errors](#handle).
### <a id="give"></a>Give users a way to ask for help
There's lots of ways to do this in your app. A drop down list is a simple way to do that.
```html
<select id="help-select">
<option value="default">Need help?</option>
<option value="article">Show me a helpful article</option>
<option value="video">Show me a helpful video</option>
<option value="search">Search for other topics</option>
</select>
```
Gather the users choice in the ``onDeviceReady`` function of the page and then send an appropriate URL to a helper function in some shared library file. Our helper function is named ``showHelp()`` and we'll write that function next.
```javascript
$('#help-select').on('change', function (e) {
var url;
switch (this.value) {
case "article":
url = "https://cordova.apache.org/docs/en/latest/"
+ "reference/cordova-plugin-inappbrowser/index.html";
break;
case "video":
url = "https://youtu.be/F-GlVrTaeH0";
break;
case "search":
url = "https://www.google.com/#q=inAppBrowser+plugin";
break;
}
showHelp(url);
});
```
### <a id="load"></a>Load a help page
We'll use the ``open`` function to load the help page. We're setting the ``hidden`` property to ``yes`` so that we can show the browser only after the page content has loaded. That way, users don't see a blank browser while they wait for content to appear. When the ``loadstop`` event is raised, we'll know when the content has loaded. We'll handle that event shortly.
```javascript
function showHelp(url) {
var target = "_blank";
var options = "location=yes,hidden=yes";
inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
inAppBrowserRef.addEventListener('loadstart', loadStartCallBack);
inAppBrowserRef.addEventListener('loadstop', loadStopCallBack);
inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack);
}
```
### <a id="let"></a>Let users know that you're getting their page ready
Because the browser doesn't immediately appear, we can use the ``loadstart`` event to show a status message, progress bar, or other indicator. This assures users that content is on the way.
```javascript
function loadStartCallBack() {
$('#status-message').text("loading please wait ...");
}
```
### <a id="show"></a>Show the help page
When the ``loadstopcallback`` event is raised, we know that the content has loaded and we can make the browser visible. This sort of trick can create the impression of better performance. The truth is that whether you show the browser before content loads or not, the load times are exactly the same.
```javascript
function loadStopCallBack() {
if (inAppBrowserRef != undefined) {
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
$('#status-message').text("");
inAppBrowserRef.show();
}
}
```
You might have noticed the call to the ``insertCSS`` function. This serves no particular purpose in our scenario. But it gives you an idea of why you might use it. In this case, we're just making sure that the font size of your pages have a certain size. You can use this function to insert any CSS style elements. You can even point to a CSS file in your project.
### <a id="handle"></a>Handle page errors
Sometimes a page no longer exists, a script error occurs, or a user lacks permission to view the resource. How or if you handle that situation is completely up to you and your design. You can let the browser show that message or you can present it in another way.
We'll try to show that error in a message box. We can do that by injecting a script that calls the ``alert`` function. That said, this won't work in browsers on Windows devices so we'll have to look at the parameter of the ``executeScript`` callback function to see if our attempt worked. If it didn't work out for us, we'll just show the error message in a ``<div>`` on the page.
```javascript
function loadErrorCallBack(params) {
$('#status-message').text("");
var scriptErrorMesssage =
"alert('Sorry we cannot open that page. Message from the server is : "
+ params.message + "');"
inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack);
inAppBrowserRef.close();
inAppBrowserRef = undefined;
}
function executeScriptCallBack(params) {
if (params[0] == null) {
$('#status-message').text(
"Sorry we couldn't open that page. Message from the server is : '"
+ params.message + "'");
}
}
```
## More Usage Info
### Local Urls ( source is in the app package )
```
var iab = cordova.InAppBrowser;
iab.open('local-url.html'); // loads in the Cordova WebView
iab.open('local-url.html', '_self'); // loads in the Cordova WebView
iab.open('local-url.html', '_system'); // Security error: system browser, but url will not load (iOS)
iab.open('local-url.html', '_blank'); // loads in the InAppBrowser
iab.open('local-url.html', 'random_string'); // loads in the InAppBrowser
iab.open('local-url.html', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
```
### Whitelisted Content
```
var iab = cordova.InAppBrowser;
iab.open('http://whitelisted-url.com'); // loads in the Cordova WebView
iab.open('http://whitelisted-url.com', '_self'); // loads in the Cordova WebView
iab.open('http://whitelisted-url.com', '_system'); // loads in the system browser
iab.open('http://whitelisted-url.com', '_blank'); // loads in the InAppBrowser
iab.open('http://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser
iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
```
### Urls that are not white-listed
```
var iab = cordova.InAppBrowser;
iab.open('http://url-that-fails-whitelist.com'); // loads in the InAppBrowser
iab.open('http://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser
iab.open('http://url-that-fails-whitelist.com', '_system'); // loads in the system browser
iab.open('http://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser
iab.open('http://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser
iab.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
```
| {
"pile_set_name": "Github"
} |
/*****************************************************************
|
| AP4 - sthd Atoms
|
| Copyright 2002-2014 Axiomatic Systems, LLC
|
|
| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
|
| Unless you have obtained Bento4 under a difference license,
| this version of Bento4 is Bento4|GPL.
| Bento4|GPL is free software; you can redistribute it and/or modify
| it under the terms of the GNU General Public License as published by
| the Free Software Foundation; either version 2, or (at your option)
| any later version.
|
| Bento4|GPL is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with Bento4|GPL; see the file COPYING. If not, write to the
| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
| 02111-1307, USA.
|
****************************************************************/
#ifndef _AP4_STHD_ATOM_H_
#define _AP4_STHD_ATOM_H_
/*----------------------------------------------------------------------
| includes
+---------------------------------------------------------------------*/
#include "Ap4Atom.h"
/*----------------------------------------------------------------------
| AP4_SthdAtom
+---------------------------------------------------------------------*/
class AP4_SthdAtom : public AP4_Atom
{
public:
// class methods
static AP4_SthdAtom* Create(AP4_Size size, AP4_ByteStream& stream);
// methods
AP4_SthdAtom();
virtual AP4_Result WriteFields(AP4_ByteStream& stream);
private:
// methods
AP4_SthdAtom(AP4_UI32 size,
AP4_UI08 version,
AP4_UI32 flags,
AP4_ByteStream& stream);
};
#endif // _AP4_STHD_ATOM_H_
| {
"pile_set_name": "Github"
} |
#ifdef _MSC_VER
#pragma warning(disable : 4464) /* relative include path contains '..' */
#endif
#define T1HA_IA32AES_NAME t1ha0_ia32aes_noavx_a
#include "../src/t1ha0_ia32aes_a.h"
#define T1HA_IA32AES_NAME t1ha0_ia32aes_noavx_b
#include "../src/t1ha0_ia32aes_b.h"
| {
"pile_set_name": "Github"
} |
import { dep1 } from './js/ecmascript-module';
const { dep2 } = require('./js/commonjs-module');
module.exports = (req, res) => {
if (req && typeof dep1 === 'string' && typeof dep2 === 'string') {
res.end('mixed-modules:js:RANDOMNESS_PLACEHOLDER');
} else {
res.end('import failed');
}
};
| {
"pile_set_name": "Github"
} |
// +build !ignore_autogenerated
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by defaulter-gen. Do not edit it manually!
package v1
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// RegisterDefaults adds defaulters functions to the given scheme.
// Public to allow building arbitrary schemes.
// All generated defaulters are covering - they call all nested defaulters.
func RegisterDefaults(scheme *runtime.Scheme) error {
return nil
}
| {
"pile_set_name": "Github"
} |
#include "BLING_OPTIONS.h"
#ifdef ALLOW_AUTODIFF
# include "AUTODIFF_OPTIONS.h"
#endif
CBOP
SUBROUTINE BLING_BIO(
I PTR_O2, PTR_FE, PTR_PO4, PTR_DOP,
O G_DIC, G_ALK, G_O2, G_FE,
O G_PO4, G_DOP,
I bi, bj, imin, imax, jmin, jmax,
I myTime, myIter, myThid)
C =================================================================
C | subroutine bling_bio_nitrogen
C | o Nutrient uptake and partitioning between organic pools.
C | - Phytoplankton biomass-specific growth rate is calculated
C | as a function of light, nutrient limitation, and
C | temperature.
C | - A simple relationship between growth rate,
C | biomass, and uptake is derived by assuming that growth is
C | exactly balanced by losses.
C | o Organic matter export and remineralization.
C | - Calculate the nutrient flux to depth from bio activity
C | - Iron source from sediments
C | - Iron scavenging
C =================================================================
IMPLICIT NONE
C === Global variables ===
C phyto_sm :: Small phytoplankton biomass
C phyto_lg :: Large phytoplankton biomass
C phyto_diaz :: Diazotroph phytoplankton biomass
C *** if ADVECT_PHYTO, these are fraction of total biomass instead ***
#include "SIZE.h"
#include "DYNVARS.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "GRID.h"
#include "BLING_VARS.h"
#include "PTRACERS_SIZE.h"
#include "PTRACERS_PARAMS.h"
#ifdef ALLOW_AUTODIFF_TAMC
# include "tamc.h"
#endif
C === Routine arguments ===
C bi,bj :: tile indices
C iMin,iMax :: computation DOPain: 1rst index range
C jMin,jMax :: computation DOPain: 2nd index range
C myTime :: current time
C myIter :: current timestep
C myThid :: thread Id. number
INTEGER bi, bj, imin, imax, jmin, jmax
_RL myTime
INTEGER myIter
INTEGER myThid
C === Input ===
C PTR_O2 :: oxygen concentration
C PTR_FE :: iron concentration
C PTR_PO4 :: phosphate concentration
C PTR_DOP :: dissolved organic phosphorus concentration
_RL PTR_O2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_FE (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_PO4(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PTR_DOP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
C === Output ===
C G_xxx :: tendency term for tracer xxx
_RL G_DIC (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_ALK (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_O2 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_FE (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_PO4 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_DOP (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
#ifdef ALLOW_BLING
# ifdef USE_BLING_V1
C === Local variables ===
C i,j,k :: loop indices
C Phy_lg_local :: biomass in large phytoplankton
C Phy_sm_local :: biomass in small phytoplankton
C PO4_lim :: phosphate limitation
C Fe_lim :: iron limitation for phytoplankton
C FetoP_up :: iron to phosphorus uptake ratio
C light_lim :: light limitation
C expkT :: temperature function
C Pc_m :: light-saturated max photosynthesis rate for phyto
C Pc_tot :: carbon-specific photosynthesis rate
C theta_Fe :: Chl:C ratio
C theta_Fe_inv :: C:Chl ratio
C theta_Fe_max :: Fe-replete maximum Chl:C ratio
C alpha_Fe :: initial slope of the P-I curve
C irrk :: nut-limited efficiency of algal photosystems
C irr_inst :: instantaneous light
C irr_eff :: effective irradiance
C mld :: mixed layer depth
C mu :: net carbon-specific growth rate for phyt
C biomass_sm :: nutrient concentration in small phyto biomass
C biomass_lg :: nutrient concentration in large phyto biomass
C P_uptake :: PO4 utilization by phytoplankton
C Fe_uptake :: dissolved Fe utilization by phytoplankton
C CaCO3_uptake :: Calcium carbonate uptake for shell formation
C CaCO3_diss :: Calcium carbonate dissolution
C G_CaCO3 :: tendency of calcium carbonate
C DOP_prod :: production of dissolved organic phosphorus
C DOP_remin :: remineralization of dissolved organic phosphorus
C frac_exp :: fraction of sinking particulate organic matter
C P_spm :: particulate sinking of phosphorus
C Fe_spm :: particulate sinking of iron
C P_recycle :: recycling of newly-produced organic phosphorus
C Fe_recycle :: recycling of newly-produced organic iron
C P_reminp :: remineralization of particulate organic phosphorus
C Fe_reminsum :: iron remineralization and adsorption
C POC_flux :: particulate organic carbon flux
C NPP :: net primary production
C NCP :: net community production
C depth_l :: depth of lower interface
C *flux_u :: "*" flux through upper interface
C *flux_l :: "*" flux through lower interface
C *_export :: vertically-integrated export of "*"
C zremin :: remineralization lengthscale for nutrients
C zremin_caco3 :: remineralization lengthscale for CaCO3
C wsink :: speed of sinking particles
C POC_sed :: flux of particulate organic carbon to sediment
C Fe_sed :: sediment iron efflux
C kFe_eq_lig :: iron ligand stability constant
C FreeFe :: free (unbound) iron concentration
C Fe_ads_inorg :: iron adsorption
C Fe_ads_org :: iron adsorption (2nd order)
C
INTEGER i,j,k
INTEGER bottomlayer
_RL Phy_lg_local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Phy_sm_local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL PO4_lim(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_lim(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL FetoP_up(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL light_lim(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL expkT(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Pc_m
_RL Pc_tot
_RL theta_Fe(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL theta_Fe_inv(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL theta_Fe_max
_RL alpha_Fe
_RL irrk(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL irr_inst(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL irr_eff(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL mld(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL mu(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL biomass_sm
_RL biomass_lg
_RL P_uptake(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_uptake(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL CaCO3_uptake(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL CaCO3_diss(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL G_CaCO3(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL DOP_prod(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL DOP_remin(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL frac_exp
_RL P_spm(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_spm(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL P_recycle(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_recycle(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL P_reminp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_reminp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_reminsum(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL POC_flux(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL NPP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL NCP(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL depth_l
_RL POPflux_u
_RL POPflux_l
_RL PFEflux_u
_RL PFEflux_l
_RL CaCO3flux_u
_RL CaCO3flux_l
_RL POP_export(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL PFE_export(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL CaCO3_export(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL zremin
_RL zremin_caco3
_RL wsink
_RL POC_sed
_RL Fe_sed(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL kFe_eq_lig
_RL FreeFe
_RL Fe_ads_inorg(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_ads_org(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL Fe_burial(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL po4_adj(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL fe_adj(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL o2_adj(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
_RL dop_adj(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr)
#ifdef ML_MEAN_PHYTO
_RL tmp_p_sm_ML
_RL tmp_p_lg_ML
_RL tmp_p_diaz_ML
_RL tmp_ML
#endif
CEOP
#ifdef ALLOW_AUTODIFF_TAMC
itdkey = bi + (bj - 1)*nSx + (ikey_dynamics - 1)*nSx*nSy
#endif
c ---------------------------------------------------------------------
c Initialize output and diagnostics
DO j=jmin,jmax
DO i=imin,imax
mld(i,j) = 0. _d 0
POP_export(i,j) = 0. _d 0
PFE_export(i,j) = 0. _d 0
CaCO3_export(i,j) = 0. _d 0
ENDDO
ENDDO
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
G_DIC(i,j,k) = 0. _d 0
G_ALK(i,j,k) = 0. _d 0
G_O2(i,j,k) = 0. _d 0
G_FE(i,j,k) = 0. _d 0
G_PO4(i,j,k) = 0. _d 0
G_DOP(i,j,k) = 0. _d 0
G_CaCO3(i,j,k) = 0. _d 0
Phy_lg_local(i,j,k) = 0. _d 0
Phy_sm_local(i,j,k) = 0. _d 0
PO4_lim(i,j,k) = 0. _d 0
Fe_lim(i,j,k) = 0. _d 0
FetoP_up(i,j,k) = 0. _d 0
light_lim(i,j,k) = 0. _d 0
expkT(i,j,k) = 0. _d 0
theta_Fe(i,j,k) = 0. _d 0
theta_Fe_inv(i,j,k) = 0. _d 0
irrk(i,j,k) = 0. _d 0
irr_inst(i,j,k) = 0. _d 0
irr_eff(i,j,k) = 0. _d 0
mu(i,j,k) = 0. _d 0
P_uptake(i,j,k) = 0. _d 0
Fe_uptake(i,j,k) = 0. _d 0
CaCO3_uptake(i,j,k) = 0. _d 0
CaCO3_diss(i,j,k) = 0. _d 0
DOP_prod(i,j,k) = 0. _d 0
DOP_remin(i,j,k) = 0. _d 0
P_spm(i,j,k) = 0. _d 0
Fe_spm(i,j,k) = 0. _d 0
P_recycle(i,j,k) = 0. _d 0
Fe_recycle(i,j,k) = 0. _d 0
P_reminp(i,j,k) = 0. _d 0
Fe_reminp(i,j,k) = 0. _d 0
Fe_reminsum(i,j,k) = 0. _d 0
POC_flux(i,j,k) = 0. _d 0
NPP(i,j,k) = 0. _d 0
NCP(i,j,k) = 0. _d 0
Fe_sed(i,j,k) = 0. _d 0
Fe_ads_org(i,j,k) = 0. _d 0
Fe_ads_inorg(i,j,k) = 0. _d 0
ENDDO
ENDDO
ENDDO
c-----------------------------------------------------------
c avoid negative nutrient concentrations that can result from
c advection when low concentrations
#ifdef BLING_NO_NEG
CALL BLING_MIN_VAL(PTR_O2, 1. _d -11, o2_adj, bi, bj)
CALL BLING_MIN_VAL(PTR_FE, 1. _d -11, fe_adj, bi, bj)
CALL BLING_MIN_VAL(PTR_PO4, 1. _d -8, po4_adj, bi, bj)
CALL BLING_MIN_VAL(PTR_DOP, 1. _d -11, dop_adj, bi, bj)
#endif
c-----------------------------------------------------------
c Phytoplankton size classes
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
Phy_lg_local(i,j,k) = phyto_lg(i,j,k,bi,bj)
Phy_sm_local(i,j,k) = phyto_sm(i,j,k,bi,bj)
ENDDO
ENDDO
ENDDO
c-----------------------------------------------------------
c Mixed layer depth calculation for light, phytoplankton and dvm.
c Do not need to calculate if not using ML_MEAN_LIGHT, ML_MEAN_PHYTO,
c and USE_BLING_DVM
c (with BLING_ADJOINT_SAFE flag, USE_BLING_DVM is undefined)
#if ( defined (ML_MEAN_LIGHT) || \
defined (ML_MEAN_PHYTO) || \
defined (USE_BLING_DVM) )
CALL BLING_MIXEDLAYER(
U mld,
I bi, bj, imin, imax, jmin, jmax,
I myTime, myIter, myThid)
#endif
c Phytoplankton mixing
c The mixed layer is assumed to homogenize vertical gradients of phytoplankton.
c This allows for basic Sverdrup dynamics in a qualitative sense.
c This has not been thoroughly tested, and care should be
c taken with its interpretation.
#ifdef ML_MEAN_PHYTO
DO j=jmin,jmax
DO i=imin,imax
tmp_p_sm_ML = 0. _d 0
tmp_p_lg_ML = 0. _d 0
tmp_ML = 0. _d 0
DO k=1,Nr
IF (hFacC(i,j,k,bi,bj).gt.0. _d 0) THEN
IF ((-rf(k+1) .le. mld(i,j)).and.
& (-rf(k+1).lt.MLmix_max)) THEN
tmp_p_sm_ML = tmp_p_sm_ML+Phy_sm_local(i,j,k)*drF(k)
& *hFacC(i,j,k,bi,bj)
tmp_p_lg_ML = tmp_p_lg_ML+Phy_lg_local(i,j,k)*drF(k)
& *hFacC(i,j,k,bi,bj)
tmp_ML = tmp_ML + drF(k)
ENDIF
ENDIF
ENDDO
DO k=1,Nr
IF (hFacC(i,j,k,bi,bj).gt.0. _d 0) THEN
IF ((-rf(k+1) .le. mld(i,j)).and.
& (-rf(k+1).lt.MLmix_max)) THEN
Phy_lg_local(i,j,k) = max(1. _d -8,tmp_p_lg_ML/tmp_ML)
Phy_sm_local(i,j,k) = max(1. _d -8,tmp_p_sm_ML/tmp_ML)
ENDIF
ENDIF
ENDDO
ENDDO
ENDDO
#endif
c-----------------------------------------------------------
c light availability for biological production
CALL BLING_LIGHT(
I mld,
U irr_inst, irr_eff,
I bi, bj, imin, imax, jmin, jmax,
I myTime, myIter, myThid )
c phytoplankton photoadaptation to local light level
c This represents the fact that phytoplankton cells are adapted
c to the averaged light field to which they've been exposed over
c their lifetimes, rather than the instantaneous light. The
c timescale is set by gamma_irr_mem.
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
irr_mem(i,j,k,bi,bj) = irr_mem(i,j,k,bi,bj) +
& (irr_eff(i,j,k) - irr_mem(i,j,k,bi,bj))*
& min( 1. _d 0, gamma_irr_mem*PTRACERS_dTLev(k) )
ENDDO
ENDDO
ENDDO
c ---------------------------------------------------------------------
c Nutrient uptake and partitioning between organic pools
c Phytoplankton are assumed to grow according to the general properties
c described in Geider (1997). This formulation gives a biomass-specific
c growthrate as a function of light, nutrient limitation, and
c temperature. We modify this relationship slightly here, as described
c below, and also use the assumption of steady state growth vs. loss to
c derive a simple relationship between growth rate, biomass and uptake.
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
IF (hFacC(i,j,k,bi,bj) .gt. 0. _d 0) THEN
c ---------------------------------------------------------------------
c First, calculate the limitation terms for PO4 and Fe, and the
c Fe-limited Chl:C maximum. The light-saturated maximal photosynthesis
c rate term (Pc_m) is simply the product of a prescribed maximal
c photosynthesis rate (Pc_0), the Eppley temperature dependence, and a
c resource limitation term. The iron limitation term has a lower limit
c of Fe_lim_min and is scaled by (k_Fe2P + Fe2P_max) / Fe2P_max so that
c it approaches 1 as Fe approaches infinity. Thus, it is of comparable
c magnitude to the macro-nutrient limitation term.
c Macro-nutrient limitation
PO4_lim(i,j,k) = PTR_PO4(i,j,k)/(PTR_PO4(i,j,k)+k_PO4)
c Iron to macro-nutrient uptake. More iron is utilized relative
c to macro-nutrient under iron-replete conditions.
FetoP_up(i,j,k) = FetoP_max*PTR_FE(i,j,k)/(k_Fe+PTR_FE(i,j,k))
c Iron limitation
Fe_lim(i,j,k) = Fe_lim_min + (1-Fe_lim_min)*
& (FetoP_up(i,j,k)/(k_FetoP + FetoP_up(i,j,k)))*
& (k_FetoP+FetoP_max)/FetoP_max
c ---------------------------------------------------------------------
c Light-saturated maximal photosynthesis rate
c NB: The temperature effect of Eppley (1972) is used instead of that in
c Geider et al (1997) for both simplicity and to incorporate combined
c effects on uptake, incorporation into organic matter and photorespiration.
c Values of PCc_m are normalized to 0C rather than 20C in Geider et al. (1997)
expkT(i,j,k) = exp(kappa_eppley * theta(i,j,k,bi,bj))
c For the effective resource limitation, there is an option to replace
c the default Liebig limitation (the minimum of Michaelis-Menton
c PO4-limitation, or iron-limitation) by the product (safer for adjoint)
#ifdef MULT_NUT_LIM
Pc_m = Pc_0*expkT(i,j,k)
& *PO4_lim(i,j,k)*Fe_lim(i,j,k)*maskC(i,j,k,bi,bj)
#else
Pc_m = Pc_0*expkT(i,j,k)
& *min(PO4_lim(i,j,k), Fe_lim(i,j,k))*maskC(i,j,k,bi,bj)
#endif
c ---------------------------------------------------------------------
c Fe limitation 1) reduces photosynthetic efficiency (alpha_Fe)
c and 2) reduces the maximum achievable Chl:C ratio (theta_Fe)
c below a prescribed, Fe-replete maximum value (theta_Fe_max),
c to approach a prescribed minimum Chl:C (theta_Fe_min) under extreme
c Fe-limitation.
alpha_Fe = alpha_min + (alpha_max-alpha_min)*Fe_lim(i,j,k)
theta_Fe_max = theta_Fe_max_lo+
& (theta_Fe_max_hi-theta_Fe_max_lo)*Fe_lim(i,j,k)
theta_Fe(i,j,k) = theta_Fe_max/(1. _d 0 + alpha_Fe
& *theta_Fe_max*irr_mem(i,j,k,bi,bj)/
& (2. _d 0*Pc_m))
c for diagnostics: C:Chl ratio in g C / g Chl
IF ( theta_Fe(i,j,k) .EQ.0. ) THEN
theta_Fe_inv(i,j,k) = 0.
ELSE
theta_Fe_inv(i,j,k) = 1./theta_Fe(i,j,k)
ENDIF
c ---------------------------------------------------------------------
c Nutrient-limited efficiency of algal photosystems, irrk, is calculated
c with the iron limitation term included as a multiplier of the
c theta_Fe_max to represent the importance of Fe in forming chlorophyll
c accessory antennae, which do not affect the Chl:C but still affect the
c phytoplankton ability to use light (eg Stzrepek & Harrison, Nature 2004).
irrk(i,j,k) = Pc_m/(epsln + alpha_Fe*theta_Fe_max) +
& irr_mem(i,j,k,bi,bj)/2. _d 0
light_lim(i,j,k) = ( 1. _d 0 - exp(-irr_eff(i,j,k)
& /(epsln + irrk(i,j,k))))
c Carbon-specific photosynthesis rate
Pc_tot = Pc_m * light_lim(i,j,k)
c ---------------------------------------------------------------------
c Account for the maintenance effort that phytoplankton must exert in
c order to combat decay. This is prescribed as a fraction of the
c light-saturated photosynthesis rate, resp_frac. The result of this
c is to set a level of energy availability below which net growth
c (and therefore nutrient uptake) is zero, given by resp_frac * Pc_m.
mu(i,j,k) = max(0. _d 0, Pc_tot - resp_frac*Pc_m)
c ---------------------------------------------------------------------
c In order to convert this net carbon-specific growth rate to nutrient
c uptake rates, the quantities we are interested in, a biomass is required.
c This is determined by the balance between growth and grazing.
c Since there is no explicit biomass tracer, use the result of Dunne
c et al. (GBC, 2005) to calculate an implicit biomass from the uptake
c rate through the application of a simple idealized grazing law.
c instantaneous nutrient concentration in phyto biomass
biomass_lg = pivotal*(mu(i,j,k)/(lambda_0
& *expkT(i,j,k)))**3
biomass_sm = pivotal*(mu(i,j,k)/(lambda_0
& *expkT(i,j,k)))
c phytoplankton biomass diagnostic
c for no lag: set gamma_biomass to 0
phy_sm_local(i,j,k) = phy_sm_local(i,j,k) +
& (biomass_sm - phy_sm_local(i,j,k))
& *min(1., gamma_biomass*PTRACERS_dTLev(k))
phy_lg_local(i,j,k) = phy_lg_local(i,j,k) +
& (biomass_lg - phy_lg_local(i,j,k))
& *min(1., gamma_biomass*PTRACERS_dTLev(k))
c use the diagnostic biomass to calculate the chl concentration
c in mg/m3 (carbon = 12.01 g/mol)
chl(i,j,k,bi,bj) = max(chl_min, CtoP * 12.01 * 1. _d 3 *
& theta_Fe(i,j,k) *
& (Phy_lg_local(i,j,k) + Phy_sm_local(i,j,k)))
c Nutrient uptake
P_uptake(i,j,k) = mu(i,j,k)*(phy_sm_local(i,j,k)
& + phy_lg_local(i,j,k))
c Iron is then taken up as a function of nutrient uptake and iron
c limitation, with a maximum Fe:P uptake ratio of Fe2p_max
Fe_uptake(i,j,k) = P_uptake(i,j,k)*FetoP_up(i,j,k)
ENDIF
ENDDO
ENDDO
ENDDO
c Separate loop for adjoint stores
#ifdef ALLOW_AUTODIFF_TAMC
CADJ STORE Phy_sm_local = comlev1_bibj, key=itdkey, kind=isbyte
CADJ STORE Phy_lg_local = comlev1_bibj, key=itdkey, kind=isbyte
#endif
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
IF (hFacC(i,j,k,bi,bj) .gt. 0. _d 0) THEN
c update biomass
phyto_lg(i,j,k,bi,bj) = Phy_lg_local(i,j,k)
phyto_sm(i,j,k,bi,bj) = Phy_sm_local(i,j,k)
ENDIF
ENDDO
ENDDO
ENDDO
c ---------------------------------------------------------------------
c Partitioning between organic pools
c The uptake of nutrients is assumed to contribute to the growth of
c phytoplankton, which subsequently die and are consumed by heterotrophs.
c This can involve the transfer of nutrient elements between many
c organic pools, both particulate and dissolved, with complex histories.
c We take a simple approach here, partitioning the total uptake into two
c fractions - sinking and non-sinking - as a function of temperature,
c following Dunne et al. (2005).
c Then, the non-sinking fraction is further subdivided, such that the
c majority is recycled instantaneously to the inorganic nutrient pool,
c representing the fast turnover of labile dissolved organic matter via
c the microbial loop, and the remainder is converted to semi-labile
c dissolved organic matter. Iron and macro-nutrient are treated
c identically for the first step, but all iron is recycled
c instantaneously in the second step (i.e. there is no dissolved organic
c iron pool).
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
IF (hFacC(i,j,k,bi,bj) .gt. 0. _d 0) THEN
c sinking particulate organic matter
frac_exp = (phi_sm + phi_lg *
& (mu(i,j,k)/(lambda_0*expkT(i,j,k)))**2.)/
& (1. + (mu(i,j,k)/(lambda_0*expkT(i,j,k)))**2.)*
& exp(kappa_remin * theta(i,j,k,bi,bj))
P_spm(i,j,k) = frac_exp * P_uptake(i,j,k)
Fe_spm(i,j,k) = P_spm(i,j,k)*FetoP_up(i,j,k)
c the remainder is divided between instantaneously recycled and
c long-lived dissolved organic matter.
c (recycling = P_uptake - P_spm - DOP_prod)
DOP_prod(i,j,k) = phi_DOM*(P_uptake(i,j,k)
& - P_spm(i,j,k))
P_recycle(i,j,k) = P_uptake(i,j,k) - P_spm(i,j,k)
& - DOP_prod(i,j,k)
Fe_recycle(i,j,k) = Fe_uptake(i,j,k) - Fe_spm(i,j,k)
c Carbon flux diagnostic
POC_flux(i,j,k) = CtoP*P_spm(i,j,k)
c ---------------------------------------------------------------------
c Calcium carbonate production
c Alkalinity is consumed through the production of CaCO3. Here, this is
c simply a linear function of the implied growth rate of small
c phytoplankton, which gave a reasonably good fit to the global
c observational synthesis of Dunne (2009). This is consistent
c with the findings of Jin et al. (GBC,2006).
CaCO3_uptake(i,j,k) = phy_sm_local(i,j,k)*phi_sm
& *expkT(i,j,k)*mu(i,j,k)*CatoP
ENDIF
ENDDO
ENDDO
ENDDO
c ---------------------------------------------------------------------
c Nutrients export/remineralization, CaCO3 export/dissolution
c
c The flux at the bottom of a grid cell equals
C Fb = (Ft + prod*dz) / (1 + zremin*dz)
C where Ft is the flux at the top, and prod*dz is the integrated
C production of new sinking particles within the layer.
C Ft = 0 in the first layer.
C$TAF LOOP = parallel
DO j=jmin,jmax
C$TAF LOOP = parallel
DO i=imin,imax
C Initialize upper flux
POPflux_u = 0. _d 0
PFEflux_u = 0. _d 0
CaCO3flux_u = 0. _d 0
DO k=1,Nr
C Initialization here helps taf
Fe_ads_org(i,j,k) = 0. _d 0
c check if we are at a bottom cell
bottomlayer = 1
IF (k.LT.Nr) THEN
IF (hFacC(i,j,k+1,bi,bj).GT.0) THEN
c not a bottom cell
bottomlayer = 0
ENDIF
ENDIF
IF ( hFacC(i,j,k,bi,bj).gt.0. _d 0 ) THEN
C Sinking speed is evaluated at the bottom of the cell
depth_l=-rF(k+1)
IF (depth_l .LE. wsink0z) THEN
wsink = wsink0_2d(i,j,bi,bj)
ELSE
wsink = wsinkacc * (depth_l - wsink0z) + wsink0_2d(i,j,bi,bj)
ENDIF
C Nutrient remineralization lengthscale
C Not an e-folding scale: this term increases with remineralization.
zremin = gamma_POM_2d(i,j,bi,bj) * ( PTR_O2(i,j,k)**2 /
& (k_O2**2 + PTR_O2(i,j,k)**2) * (1-remin_min)
& + remin_min )/(wsink + epsln)
C Calcium remineralization relaxed toward the inverse of the
C ca_remin_depth constant value as the calcite saturation approaches 0.
zremin_caco3 = 1. _d 0/ca_remin_depth*(1. _d 0 - min(1. _d 0,
& omegaC(i,j,k,bi,bj) + epsln ))
C POM flux leaving the cell
POPflux_l = (POPflux_u+P_spm(i,j,k)*drF(k)
& *hFacC(i,j,k,bi,bj))/(1+zremin*drF(k)
& *hFacC(i,j,k,bi,bj))
C CaCO3 flux leaving the cell
CaCO3flux_l = (caco3flux_u+CaCO3_uptake(i,j,k)*drF(k)
& *hFacC(i,j,k,bi,bj))/(1+zremin_caco3*drF(k)
& *hFacC(i,j,k,bi,bj))
C Begin iron uptake calculations by determining ligand bound and free iron.
C Both forms are available for biology, but only free iron is scavenged
C onto particles and forms colloids.
kFe_eq_lig = kFe_eq_lig_max-(kFe_eq_lig_max-kFe_eq_lig_min)
& *(irr_inst(i,j,k)**2
& /(kFe_eq_lig_irr**2+irr_inst(i,j,k)**2))
& *max(epsln,min(1. _d 0,(PTR_FE(i,j,k)
& -kFe_eq_lig_Femin)/
& (PTR_FE(i,j,k)+epsln)*1.2 _d 0))
C Use the quadratic equation to solve for binding between iron and ligands
FreeFe = (-(1+kFe_eq_lig*(ligand-PTR_FE(i,j,k)))
& +((1+kFe_eq_lig*(ligand-PTR_FE(i,j,k)))**2+4*
& kFe_eq_lig*PTR_FE(i,j,k))**(0.5))/(2*
& kFe_eq_lig)
C Iron scavenging does not occur in anoxic water (Fe2+ is soluble), so set
C FreeFe = 0 when anoxic. FreeFe should be interpreted the free iron that
C participates in scavenging.
IF (PTR_O2(i,j,k) .LT. oxic_min) THEN
FreeFe = 0. _d 0
ENDIF
C Two mechanisms for iron uptake, in addition to biological production:
C colloidal scavenging and scavenging by organic matter.
Fe_ads_inorg(i,j,k) =
& kFe_inorg*(max(1. _d -8,FreeFe))**(1.5)
C Scavenging of iron by organic matter:
C The POM value used is the bottom boundary flux. This does not occur in
C oxic waters, but FreeFe is set to 0 in such waters earlier.
IF ( POPflux_l .GT. 0. _d 0 ) THEN
Fe_ads_org(i,j,k) =
& kFE_org*(POPflux_l/(epsln + wsink)
& * MasstoN*NtoP)**(0.58)*FreeFe
ENDIF
C If water is oxic then the iron is remineralized normally. Otherwise
C it is completely remineralized (fe 2+ is soluble, but unstable
C in oxidizing environments).
IF ( PTR_O2(i,j,k) .LT. oxic_min ) THEN
PFEflux_l = 0. _d 0
ELSE
PFEflux_l = (PFEflux_u+(Fe_spm(i,j,k)+Fe_ads_inorg(i,j,k)
& +Fe_ads_org(i,j,k))*drF(k)
& *hFacC(i,j,k,bi,bj))/(1+zremin*drF(k)
& *hFacC(i,j,k,bi,bj))
ENDIF
C Nutrient accumulation in a cell is given by the biological production
C (and instant remineralization) of particulate organic matter
C plus flux thought upper interface minus flux through lower interface.
C If this layer is adjacent to bottom topography or it is the deepest
C cell of the domain, then remineralize/dissolve in this grid cell
C i.e. do not subtract off lower boundary fluxes when calculating remin
C For the deepest cells:
IF (bottomlayer.EQ.1) THEN
POPflux_l = 0. _d 0
CACO3flux_l = 0. _d 0
C Efflux Fed out of sediments
C The phosphate flux hitting the bottom boundary
C is used to scale the return of iron to the water column.
C Maximum value added for numerical stability.
POC_sed = POPflux_l * CtoP
Fe_sed(i,j,k) = max(epsln, FetoC_sed * POC_sed * recip_drF(k)
& * recip_hFacC(i,j,k,bi,bj))
ELSE
Fe_sed(i,j,k) = 0. _d 0
ENDIF
P_reminp(i,j,k) = (POPflux_u + P_spm(i,j,k) * drF(k)
& * hFacC(i,j,k,bi,bj) - POPflux_l)
& * recip_drF(k) * recip_hFacC(i,j,k,bi,bj)
CaCO3_diss(i,j,k) = (CaCO3flux_u + CaCO3_uptake(i,j,k)
& * drF(k) * hFacC(i,j,k,bi,bj) - CaCO3flux_l)
& * recip_drF(k) * recip_hFacC(i,j,k,bi,bj)
Fe_sed(i,j,k) = 0. _d 0
Fe_reminp(i,j,k) = (PFEflux_u + (Fe_spm(i,j,k)
& + Fe_ads_inorg(i,j,k) + Fe_ads_org(i,j,k))
& * drF(k) * hFacC(i,j,k,bi,bj) - PFEflux_l)
& * recip_drF(k) * recip_hFacC(i,j,k,bi,bj)
Fe_reminsum(i,j,k) = Fe_reminp(i,j,k) + Fe_sed(i,j,k)
& - Fe_ads_org(i,j,k) - Fe_ads_inorg(i,j,k)
C Added the burial flux of sinking particulate iron here as a
C diagnostic, needed to calculate mass balance of iron.
C this is calculated last for the deepest cell
Fe_burial(i,j) = PFEflux_l
C Prepare the tracers for the next layer down
POPflux_u = POPflux_l
PFEflux_u = PFEflux_l
CaCO3flux_u = CaCO3flux_l
ENDIF
ENDDO
ENDDO
ENDDO
C-----------------------------------------------------------
C add all tendencies
DO k=1,Nr
DO j=jmin,jmax
DO i=imin,imax
C Dissolved organic matter slow remineralization
#ifdef BLING_NO_NEG
DOP_remin(i,j,k) = MAX(maskC(i,j,k,bi,bj)*gamma_DOP
& *PTR_DOP(i,j,k),0. _d 0)
#else
DOP_remin(i,j,k) = maskC(i,j,k,bi,bj)*gamma_DOP
& *PTR_DOP(i,j,k)
#endif
c Tendencies
G_PO4(i,j,k) = -P_uptake(i,j,k) + P_recycle(i,j,k)
& + DOP_remin(i,j,k)
& + (1-phi_DOM) * P_reminp(i,j,k)
G_DOP(i,j,k) = DOP_prod(i,j,k) - DOP_remin(i,j,k)
& + phi_DOM * P_reminp(i,j,k)
if ( PTR_O2(i,j,k) .GT. oxic_min ) then
G_O2(i,j,k) = -O2toP*G_PO4(i,j,k)
else
G_O2(i,j,k) = 0. _d 0
endif
G_FE(i,j,k) = - Fe_uptake(i,j,k) + Fe_reminsum(i,j,k)
& + Fe_recycle(i,j,k)
C Carbon system diagnostics
C Change in DIC from primary production, from recycling and
C remineralization, change in carbonate ions concentration
C from biological activity:
G_CaCO3(i,j,k) = CaCO3_diss(i,j,k) - CaCO3_uptake(i,j,k)
NPP(i,j,k) = P_uptake(i,j,k) * CtoP
NCP(i,j,k) = -G_PO4(i,j,k)*CtoP
G_ALK(i,j,k) = 2. _d 0*G_CaCO3(i,j,k) - NtoP*G_PO4(i,j,k)
G_DIC(i,j,k) = -NCP(i,j,k) + G_CaCO3(i,j,k)
c Carbon flux diagnostic
POC_flux(i,j,k) = CtoP * P_spm(i,j,k)
c for diagnostics: convert to mol C/m3
Phy_lg_local(i,j,k) = Phy_lg_local(i,j,k) * CtoP
Phy_sm_local(i,j,k) = Phy_sm_local(i,j,k) * CtoP
c for constraints determine POC, assuming that phytoplankton carbon
c is 30% of POC
poc(i,j,k,bi,bj) = (Phy_lg_local(i,j,k) +
& Phy_sm_local(i,j,k)) * 3.33333 _d 0
ENDDO
ENDDO
ENDDO
c ---------------------------------------------------------------------
#ifdef ALLOW_DIAGNOSTICS
IF ( useDiagnostics ) THEN
c 3d global variables
CALL DIAGNOSTICS_FILL(chl, 'BLGCHL ',0,Nr,1,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(poc, 'BLGPOC ',0,Nr,1,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(irr_mem,'BLGIMEM ',0,Nr,1,bi,bj,myThid)
c 3d local variables
CALL DIAGNOSTICS_FILL(G_DIC ,'BLGBIOC ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(G_ALK ,'BLGBIOAL',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(G_O2 ,'BLGBIOO2',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(G_Fe ,'BLGBIOFE',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(G_PO4 ,'BLGBIOP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(Phy_sm_local,'BLGPSM ',0,Nr,2,bi,bj,
& myThid)
CALL DIAGNOSTICS_FILL(Phy_lg_local,'BLGPLG ',0,Nr,2,bi,bj,
& myThid)
CALL DIAGNOSTICS_FILL(irrk, 'BLGIRRK ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(irr_eff, 'BLGIEFF ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(theta_Fe,'BLGCHL2C',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(theta_Fe_inv,'BLGC2CHL',0,Nr,2,bi,bj,
& myThid)
CALL DIAGNOSTICS_FILL(Fe_lim, 'BLGFELIM',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(PO4_lim, 'BLGPLIM ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(light_lim,'BLGLLIM ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(POC_flux,'BLGPOCF ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(NPP, 'BLGNPP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(NCP, 'BLGNCP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(Fe_spm, 'BLGFESPM',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(Fe_recycle,'BLGFEREC',0,Nr,2,bi,bj,
& myThid)
CALL DIAGNOSTICS_FILL(Fe_uptake,'BLGFEUP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(DOP_prod, 'BLGDOPP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(DOP_remin,'BLGDOPR ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(P_spm, 'BLGPSPM ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(P_recycle,'BLGPREC ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(P_reminp, 'BLGPREM ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(P_uptake, 'BLGPUP ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(mu, 'BLGMU ',0,Nr,2,bi,bj,myThid)
CALL DIAGNOSTICS_FILL(CaCO3_diss,'BLGCCdis',0,Nr,2,bi,bj,
& myThid)
CALL DIAGNOSTICS_FILL(CaCO3_uptake,'BLGCCpro',0,Nr,2,bi,bj,
& myThid)
c 2d local variables
CALL DIAGNOSTICS_FILL(mld, 'BLGMLD ',0,1,1,bi,bj,myThid)
ENDIF
#endif /* ALLOW_DIAGNOSTICS */
#endif /* USE_BLING_V1 */
#endif /* ALLOW_BLING */
RETURN
END
| {
"pile_set_name": "Github"
} |
const datas = {
tabs: {
records: {
text: 'Records',
tipso: 'record your shared page datas'
},
resume: {
text: 'Resume',
tipso: ''
},
github: {
text: 'GitHub',
tipso: ''
},
setting: {
text: 'Settings',
tipso: ''
},
about: {
text: 'About',
tipso: ''
},
logout: {
text: 'Logout',
tipso: ''
}
},
headers: {
zen: 'Zen of GitHub',
about: 'About',
feedback: 'Feedback',
logout: 'Logout'
},
archive: {
resume: {
previewModal: 'Press ESC to exit preview'
}
},
records: {
resume: {
title: 'Resume',
shareText: 'Scan QR code to share resume'
},
github: {
title: 'GitHub',
shareText: 'Scan QR code to share GitHub analysis'
},
title: {
link: 'Share link',
logs: 'View logs of last {LOGS_COUNT} times',
statistic: 'Pageview statistic'
},
common: {
pv: 'Total PV',
maxPvPerHour: 'Max PV per hour',
platform: 'Max platform',
browser: 'Max browser',
platformChartTitle: 'Platforms',
browserChartTitle: 'Browsers',
hourlyViewChartTitle: 'Hourly view count',
dailyViewChartTitle: 'Daily view count',
monthlyViewChartTitle: 'Monthly view count',
hourlyViewChart: 'Hourly',
dailyViewChart: 'Daily',
monthlyViewChart: 'Monthly',
resume: 'Resume',
copied: 'Link copied',
empty: 'No data'
}
},
setting: {
refresh: 'Update Date',
shareConfig: 'Share Config',
shareUrl: 'Share Url',
github: {
title: 'GitHub',
openShare: 'Open GitHub visualize share',
lastUpdate: 'Last update at',
updateButtonText: 'Update',
customize: {
title: 'Customize repositories',
button: 'Click to change',
confirm: 'Confirm',
checkAll: 'Check all',
filter: 'Filter repositories'
},
},
order: {
ordering: 'Module sequence and visibility',
orderingError: 'Can not order this module',
orderingFixedError: 'Fixed module can not be reordered',
orderingTip: 'Drag and drop to reorder; Click the row to toggle the visibility in sharing page',
},
resume: {
title: 'Resume',
openShare: 'Open resume share',
simplifyUrl: 'Use simplify share url',
simplifyUrlTip: 'Can\'t visit public :login/resume page if closed, using resume/:hash instead',
useGithub: 'Use GitHub analysis in resume',
autosave: 'Auto save when editing resume',
reminder: {
title: 'Remind me update my resume',
sendEmailTo: 'Send mail to',
placeholder: 'your email address'
},
}
}
}
export default datas
| {
"pile_set_name": "Github"
} |
---
layout: base
title: 'Statistics of dep in UD_Swedish_Sign_Language-SSLC'
udver: '2'
---
## Treebank Statistics: UD_Swedish_Sign_Language-SSLC: Relations: `dep`
This relation is universal.
16 nodes (1%) are attached to their parents as `dep`.
8 instances of `dep` (50%) are left-to-right (parent precedes child).
Average distance between parent and child is 3.3125.
The following 5 pairs of parts of speech are connected with `dep`: <tt><a href="swl_sslc-pos-VERB.html">VERB</a></tt>-<tt><a href="swl_sslc-pos-X.html">X</a></tt> (12; 75% instances), <tt><a href="swl_sslc-pos-ADJ.html">ADJ</a></tt>-<tt><a href="swl_sslc-pos-PRON.html">PRON</a></tt> (1; 6% instances), <tt><a href="swl_sslc-pos-NOUN.html">NOUN</a></tt>-<tt><a href="swl_sslc-pos-X.html">X</a></tt> (1; 6% instances), <tt><a href="swl_sslc-pos-VERB.html">VERB</a></tt>-<tt><a href="swl_sslc-pos-INTJ.html">INTJ</a></tt> (1; 6% instances), <tt><a href="swl_sslc-pos-VERB.html">VERB</a></tt>-<tt><a href="swl_sslc-pos-PRON.html">PRON</a></tt> (1; 6% instances).
~~~ conllu
# visual-style 6 bgColor:blue
# visual-style 6 fgColor:white
# visual-style 1 bgColor:blue
# visual-style 1 fgColor:white
# visual-style 1 6 dep color:blue
1 GÅ-IN(L) _ VERB VB _ 0 root _ _
2 TILL _ ADP PP _ 3 case _ _
3 SKOG _ NOUN NN _ 1 obl _ _
4 RÖST-ANVÄNDA _ VERB VB _ 1 conj _ _
5 VAR _ ADV AB _ 4 ccomp _ _
6 GLOSA:(PF)@z _ X ? _ 1 dep _ _
7 SÅG _ VERB VB _ 1 conj _ _
8 HÅL@b _ NOUN NN _ 7 obj _ _
9 RUND@kl _ NOUN NNKL _ 8 clf _ _
~~~
~~~ conllu
# visual-style 1 bgColor:blue
# visual-style 1 fgColor:white
# visual-style 5 bgColor:blue
# visual-style 5 fgColor:white
# visual-style 5 1 dep color:blue
1 PEK _ PRON PEK _ 5 dep _ _
2 PEK@ca _ VERB VBCA _ 5 nsubj _ _
3 PEK _ PRON PEK _ 2 conj _ _
4 LITE _ ADV AB _ 5 advmod _ _
5 BILLIG _ ADJ JJ _ 0 root _ _
~~~
~~~ conllu
# visual-style 1 bgColor:blue
# visual-style 1 fgColor:white
# visual-style 2 bgColor:blue
# visual-style 2 fgColor:white
# visual-style 2 1 dep color:blue
1 tp@& _ X ? _ 2 dep _ _
2 POJKE _ NOUN NN _ 3 nsubj _ _
3 LÄGGA-SIG _ VERB VB _ 0 root _ _
4 HUND _ NOUN NN _ 2 conj _ _
5 VARELSE(VVb)+BEFINNA@p _ VERB VBAV _ 3 conj _ _
6 SOVA(Jv) _ VERB VB _ 3 compound:svc _ _
7 TIDEN-GÅR@z _ VERB VB _ 6 advcl _ _
~~~
| {
"pile_set_name": "Github"
} |
<!doctype html>
<title>CodeMirror: Closure Stylesheets (GSS) mode</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../../doc/docs.css">
<link rel="stylesheet" href="../../lib/codemirror.css">
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<script src="../../addon/hint/show-hint.js"></script>
<script src="../../addon/hint/css-hint.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Closure Stylesheets (GSS)</a>
</ul>
</div>
<article>
<h2>Closure Stylesheets (GSS) mode</h2>
<form><textarea id="code" name="code">
/* Some example Closure Stylesheets */
@provide 'some.styles';
@require 'other.styles';
@component {
@def FONT_FAMILY "Times New Roman", Georgia, Serif;
@def FONT_SIZE_NORMAL 15px;
@def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY;
@def BG_COLOR rgb(235, 239, 249);
@def DIALOG_BORDER_COLOR rgb(107, 144, 218);
@def DIALOG_BG_COLOR BG_COLOR;
@def LEFT_HAND_NAV_WIDTH 180px;
@def LEFT_HAND_NAV_PADDING 3px;
@defmixin size(WIDTH, HEIGHT) {
width: WIDTH;
height: HEIGHT;
}
body {
background-color: BG_COLOR;
margin: 0;
padding: 3em 6em;
font: FONT_NORMAL;
color: #000;
}
#navigation a {
font-weight: bold;
text-decoration: none !important;
}
.dialog {
background-color: DIALOG_BG_COLOR;
border: 1px solid DIALOG_BORDER_COLOR;
}
.content {
position: absolute;
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */
LEFT_HAND_NAV_WIDTH,
LEFT_HAND_NAV_PADDING); /* padding right */
}
.logo {
@mixin size(150px, 55px);
background-image: url('http://www.google.com/images/logo_sm.gif');
}
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
extraKeys: {"Ctrl-Space": "autocomplete"},
lineNumbers: true,
matchBrackets: "text/x-less",
mode: "text/x-gss"
});
</script>
<p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p>
<p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p>
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p>
</article>
| {
"pile_set_name": "Github"
} |
{
"url": "http://example.com/test_pattern_config.html",
"expected": {
"cleaned_text": "This is the real content"
}
}
| {
"pile_set_name": "Github"
} |
#import "WKInterfaceObject.h"
NS_ASSUME_NONNULL_BEGIN
@interface WKInterfaceImage : WKInterfaceObject
- (void)setImage:(nullable UIImage *)image;
- (void)setImageData:(nullable NSData *)imageData;
- (void)setImageNamed:(nullable NSString *)imageName;
- (void)setTintColor:(nullable UIColor *)tintColor;
- (void)startAnimating;
- (void)startAnimatingWithImagesInRange:(NSRange)imageRange
duration:(NSTimeInterval)duration
repeatCount:(NSInteger)repeatCount;
- (void)stopAnimating;
@end
NS_ASSUME_NONNULL_END
| {
"pile_set_name": "Github"
} |
#define CONFIG_DPSS 1
| {
"pile_set_name": "Github"
} |
# -*- coding: utf-8 -*-
"""
pygments.lexers._vbscript_builtins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These are manually translated lists from
http://www.indusoft.com/pdf/VBScript%20Reference.pdf.
:copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
KEYWORDS = [
'ByRef',
'ByVal',
# dim: special rule
'call',
'case',
'class',
# const: special rule
'do',
'each',
'else',
'elseif',
'end',
'erase',
'execute',
'function',
'exit',
'for',
'function',
'GetRef',
'global',
'if',
'let',
'loop',
'next',
'new',
# option: special rule
'private',
'public',
'redim',
'select',
'set',
'sub',
'then',
'wend',
'while',
'with',
]
BUILTIN_FUNCTIONS = [
'Abs',
'Array',
'Asc',
'Atn',
'CBool',
'CByte',
'CCur',
'CDate',
'CDbl',
'Chr',
'CInt',
'CLng',
'Cos',
'CreateObject',
'CSng',
'CStr',
'Date',
'DateAdd',
'DateDiff',
'DatePart',
'DateSerial',
'DateValue',
'Day',
'Eval',
'Exp',
'Filter',
'Fix',
'FormatCurrency',
'FormatDateTime',
'FormatNumber',
'FormatPercent',
'GetObject',
'GetLocale',
'Hex',
'Hour',
'InStr',
'inStrRev',
'Int',
'IsArray',
'IsDate',
'IsEmpty',
'IsNull',
'IsNumeric',
'IsObject',
'Join',
'LBound',
'LCase',
'Left',
'Len',
'LoadPicture',
'Log',
'LTrim',
'Mid',
'Minute',
'Month',
'MonthName',
'MsgBox',
'Now',
'Oct',
'Randomize',
'RegExp',
'Replace',
'RGB',
'Right',
'Rnd',
'Round',
'RTrim',
'ScriptEngine',
'ScriptEngineBuildVersion',
'ScriptEngineMajorVersion',
'ScriptEngineMinorVersion',
'Second',
'SetLocale',
'Sgn',
'Space',
'Split',
'Sqr',
'StrComp',
'String',
'StrReverse',
'Tan',
'Time',
'Timer',
'TimeSerial',
'TimeValue',
'Trim',
'TypeName',
'UBound',
'UCase',
'VarType',
'Weekday',
'WeekdayName',
'Year',
]
BUILTIN_VARIABLES = [
'Debug',
'Dictionary',
'Drive',
'Drives',
'Err',
'File',
'Files',
'FileSystemObject',
'Folder',
'Folders',
'Match',
'Matches',
'RegExp',
'Submatches',
'TextStream',
]
OPERATORS = [
'+',
'-',
'*',
'/',
'\\',
'^',
'|',
'<',
'<=',
'>',
'>=',
'=',
'<>',
'&',
'$',
]
OPERATOR_WORDS = [
'mod',
'and',
'or',
'xor',
'eqv',
'imp',
'is',
'not',
]
BUILTIN_CONSTANTS = [
'False',
'True',
'vbAbort',
'vbAbortRetryIgnore',
'vbApplicationModal',
'vbArray',
'vbBinaryCompare',
'vbBlack',
'vbBlue',
'vbBoole',
'vbByte',
'vbCancel',
'vbCr',
'vbCritical',
'vbCrLf',
'vbCurrency',
'vbCyan',
'vbDataObject',
'vbDate',
'vbDefaultButton1',
'vbDefaultButton2',
'vbDefaultButton3',
'vbDefaultButton4',
'vbDouble',
'vbEmpty',
'vbError',
'vbExclamation',
'vbFalse',
'vbFirstFullWeek',
'vbFirstJan1',
'vbFormFeed',
'vbFriday',
'vbGeneralDate',
'vbGreen',
'vbIgnore',
'vbInformation',
'vbInteger',
'vbLf',
'vbLong',
'vbLongDate',
'vbLongTime',
'vbMagenta',
'vbMonday',
'vbMsgBoxHelpButton',
'vbMsgBoxRight',
'vbMsgBoxRtlReading',
'vbMsgBoxSetForeground',
'vbNewLine',
'vbNo',
'vbNull',
'vbNullChar',
'vbNullString',
'vbObject',
'vbObjectError',
'vbOK',
'vbOKCancel',
'vbOKOnly',
'vbQuestion',
'vbRed',
'vbRetry',
'vbRetryCancel',
'vbSaturday',
'vbShortDate',
'vbShortTime',
'vbSingle',
'vbString',
'vbSunday',
'vbSystemModal',
'vbTab',
'vbTextCompare',
'vbThursday',
'vbTrue',
'vbTuesday',
'vbUseDefault',
'vbUseSystem',
'vbUseSystem',
'vbVariant',
'vbVerticalTab',
'vbWednesday',
'vbWhite',
'vbYellow',
'vbYes',
'vbYesNo',
'vbYesNoCancel',
]
| {
"pile_set_name": "Github"
} |
require 'spec_helper'
describe Commands::Credentials::RotateApiKey do
let(:credentials) { double(Credentials) }
let(:role) { double(Role, id: 'role', credentials: credentials) }
let(:other_credentials) { double(Credentials) }
let(:other_role) { double(Role, id: 'other role', credentials: other_credentials) }
let(:client_ip) { 'my-client-ip' }
let(:role_to_rotate) { role }
let(:err_message) { 'the error message' }
let(:audit_log) { double(::Audit.logger) }
let(:audit_success) do
::Audit::Event::ApiKey.new(
authenticated_role_id: role.id,
rotated_role_id: role_to_rotate.id,
client_ip: client_ip,
success: true
)
end
let(:audit_failure) do
::Audit::Event::ApiKey.new(
authenticated_role_id: role.id,
rotated_role_id: role_to_rotate.id,
client_ip: client_ip,
success: false,
error_message: err_message
)
end
subject do
Commands::Credentials::RotateApiKey.new(
audit_log: audit_log
)
end
context 'when rotating own API key' do
it 'updates the key' do
# Normally command inputs should not be mocked, however to seperate
# the role "value" from the rotation and database operations would require
# refactoring the Credentials controller. So the correct solution is out
# of scope.
expect(credentials).to receive(:rotate_api_key)
expect(credentials).to receive(:save)
# Expect it to log a successful audit message
expect(audit_log).to receive(:log).with(audit_success)
# Call the command
subject.call(
role_to_rotate: role,
authenticated_role: role,
client_ip: client_ip
)
end
it 'bubbles up exceptions' do
# See note above. The command inputs should not typicially be mocked.
# However, the refactoring to support the correct solution is
# out of scope.
#
# Assume the database update fails. This could be caused by an
# invalid password, database issues, etc.
allow(credentials).to receive(:rotate_api_key)
allow(credentials).to receive(:save).and_raise(err_message)
# Expect it to log a failed audit message
expect(audit_log).to receive(:log).with(audit_failure)
# Expect the command to raise the original exception
expect do
subject.call(
role_to_rotate: role,
authenticated_role: role,
client_ip: client_ip
)
end.to raise_error(err_message)
end
end
context "when rotating another's API key" do
let(:role_to_rotate) { other_role }
it 'updates the key' do
# Expect it to rotate the api key on the credentials model, and to save it
expect(other_credentials).to receive(:rotate_api_key)
expect(other_credentials).to receive(:save)
# Expect it to log a successful audit message
expect(audit_log).to receive(:log).with(audit_success)
# Call the command
subject.call(
role_to_rotate: other_role,
authenticated_role: role,
client_ip: client_ip
)
end
it 'bubbles up exceptions' do
# Assume the database update fails. This could be caused by an
# invalid password, database issues, etc.
allow(other_credentials).to receive(:rotate_api_key)
allow(other_credentials).to receive(:save).and_raise(err_message)
# Expect it to log a failed audit message
expect(audit_log).to receive(:log).with(audit_failure)
# Expect the command to raise the original exception
expect do
subject.call(
role_to_rotate: other_role,
authenticated_role: role,
client_ip: client_ip
)
end.to raise_error(err_message)
end
end
end
| {
"pile_set_name": "Github"
} |
/*
* -- Version 1.1 --
*
* (C) Copyright 2003-2005
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2004-2005
* Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
*
* (C) Copyright 2005
* Stefan Strobl, GERSYS GmbH, stefan.strobl@gersys.de.
*
* History:
* 1.1 - add define CONFIG_ZERO_BOOTDELAY_CHECK
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __CONFIG_H
#define __CONFIG_H
/*
* High Level Configuration Options
*/
#define CONFIG_MPC5200 1 /* This is a MPC5200 CPU */
#define CONFIG_TQM5200 1 /* ... on a TQM5200 module */
#define CONFIG_BC3450 1 /* ... on a BC3450 mainboard */
#define CONFIG_BC3450_PS2 1 /* + a PS/2 converter onboard */
#define CONFIG_BC3450_IDE 1 /* + IDE drives (Compact Flash) */
#define CONFIG_BC3450_USB 1 /* + USB support */
# define CONFIG_FAT 1 /* + FAT support */
# define CONFIG_EXT2 1 /* + EXT2 support */
#undef CONFIG_BC3450_BUZZER /* + Buzzer onboard */
#undef CONFIG_BC3450_CAN /* + CAN transceiver */
#undef CONFIG_BC3450_DS1340 /* + a RTC DS1340 onboard */
#undef CONFIG_BC3450_DS3231 /* + a RTC DS3231 onboard tbd */
#undef CONFIG_BC3450_AC97 /* + AC97 on PSC2, tbd */
#define CONFIG_BC3450_FP 1 /* + enable FP O/P */
#undef CONFIG_BC3450_CRT /* + enable CRT O/P (Debug only!) */
/*
* Valid values for CONFIG_SYS_TEXT_BASE are:
* 0xFC000000 boot low (standard configuration with room for
* max 64 MByte Flash ROM)
* 0x00100000 boot from RAM (for testing only)
*/
#ifndef CONFIG_SYS_TEXT_BASE
#define CONFIG_SYS_TEXT_BASE 0xFC000000
#endif
#define CONFIG_SYS_MPC5XXX_CLKIN 33000000 /* ... running at 33.000000MHz */
#define CONFIG_HIGH_BATS 1 /* High BATs supported */
/*
* Serial console configuration
*/
#define CONFIG_PSC_CONSOLE 1 /* console is on PSC1 */
#define CONFIG_BAUDRATE 115200 /* ... at 115200 bps */
#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400 }
/*
* AT-PS/2 Multiplexer
*/
#ifdef CONFIG_BC3450_PS2
# define CONFIG_PS2KBD /* AT-PS/2 Keyboard */
# define CONFIG_PS2MULT /* .. on PS/2 Multiplexer */
# define CONFIG_PS2SERIAL 6 /* .. on PSC6 */
# define CONFIG_PS2MULT_DELAY (CONFIG_SYS_HZ/2) /* Initial delay */
# define CONFIG_BOARD_EARLY_INIT_R
#endif /* CONFIG_BC3450_PS2 */
/*
* PCI Mapping:
* 0x40000000 - 0x4fffffff - PCI Memory
* 0x50000000 - 0x50ffffff - PCI IO Space
*/
# define CONFIG_PCI 1
# define CONFIG_PCI_PNP 1
/* #define CONFIG_PCI_SCAN_SHOW 1 */
#define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE 1
#define CONFIG_PCI_MEM_BUS 0x40000000
#define CONFIG_PCI_MEM_PHYS CONFIG_PCI_MEM_BUS
#define CONFIG_PCI_MEM_SIZE 0x10000000
#define CONFIG_PCI_IO_BUS 0x50000000
#define CONFIG_PCI_IO_PHYS CONFIG_PCI_IO_BUS
#define CONFIG_PCI_IO_SIZE 0x01000000
/*#define CONFIG_EEPRO100 XXX - FIXME: conflicts when CONFIG_MII is enabled */
#define CONFIG_SYS_RX_ETH_BUFFER 8 /* use 8 rx buffer on eepro100 */
#define CONFIG_NS8382X 1
/*
* Video console
*/
# define CONFIG_VIDEO
# define CONFIG_VIDEO_SM501
# define CONFIG_VIDEO_SM501_32BPP
# define CONFIG_CFB_CONSOLE
# define CONFIG_VIDEO_LOGO
# define CONFIG_VGA_AS_SINGLE_DEVICE
# define CONFIG_CONSOLE_EXTRA_INFO /* display Board/Device-Infos */
# define CONFIG_VIDEO_SW_CURSOR
# define CONFIG_SPLASH_SCREEN
# define CONFIG_SYS_CONSOLE_IS_IN_ENV
/*
* Partitions
*/
#define CONFIG_MAC_PARTITION
#define CONFIG_DOS_PARTITION
#define CONFIG_ISO_PARTITION
/*
* USB
*/
#ifdef CONFIG_BC3450_USB
# define CONFIG_USB_OHCI
# define CONFIG_USB_STORAGE
#endif /* CONFIG_BC3450_USB */
/*
* POST support
*/
#define CONFIG_POST (CONFIG_SYS_POST_MEMORY | \
CONFIG_SYS_POST_CPU | \
CONFIG_SYS_POST_I2C)
#ifdef CONFIG_POST
/* preserve space for the post_word at end of on-chip SRAM */
# define MPC5XXX_SRAM_POST_SIZE MPC5XXX_SRAM_SIZE-4
#endif /* CONFIG_POST */
/*
* BOOTP options
*/
#define CONFIG_BOOTP_BOOTFILESIZE
#define CONFIG_BOOTP_BOOTPATH
#define CONFIG_BOOTP_GATEWAY
#define CONFIG_BOOTP_HOSTNAME
/*
* Command line configuration.
*/
#include <config_cmd_default.h>
#define CONFIG_CMD_ASKENV
#define CONFIG_CMD_DATE
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_ECHO
#define CONFIG_CMD_EEPROM
#define CONFIG_CMD_I2C
#define CONFIG_CMD_JFFS2
#define CONFIG_CMD_MII
#define CONFIG_CMD_NFS
#define CONFIG_CMD_PING
#define CONFIG_CMD_REGINFO
#define CONFIG_CMD_SNTP
#define CONFIG_CMD_BSP
#ifdef CONFIG_VIDEO
#define CONFIG_CMD_BMP
#endif
#ifdef CONFIG_BC3450_IDE
#define CONFIG_CMD_IDE
#endif
#if defined(CONFIG_BC3450_IDE) || defined(CONFIG_BC3450_USB)
#ifdef CONFIG_FAT
#define CONFIG_CMD_FAT
#endif
#ifdef CONFIG_EXT2
#define CONFIG_CMD_EXT2
#endif
#endif
#ifdef CONFIG_BC3450_USB
#define CONFIG_CMD_USB
#endif
#ifdef CONFIG_PCI
#define CONFIG_CMD_PCI
#endif
#ifdef CONFIG_POST
#define CONFIG_CMD_DIAG
#endif
#define CONFIG_TIMESTAMP /* display image timestamps */
#if (CONFIG_SYS_TEXT_BASE == 0xFC000000) /* Boot low */
# define CONFIG_SYS_LOWBOOT 1
#endif
/*
* Autobooting
*/
#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
#define CONFIG_ZERO_BOOTDELAY_CHECK /* check for keypress on bootdelay==0 */
#define CONFIG_PREBOOT "echo;" \
"echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \
"echo;"
#undef CONFIG_BOOTARGS
#define CONFIG_EXTRA_ENV_SETTINGS \
"netdev=eth0\0" \
"ipaddr=192.168.1.10\0" \
"serverip=192.168.1.3\0" \
"netmask=255.255.255.0\0" \
"hostname=bc3450\0" \
"rootpath=/opt/eldk/ppc_6xx\0" \
"kernel_addr=fc0a0000\0" \
"ramdisk_addr=fc1c0000\0" \
"ramargs=setenv bootargs root=/dev/ram rw\0" \
"nfsargs=setenv bootargs root=/dev/nfs rw " \
"nfsroot=$(serverip):$(rootpath)\0" \
"ideargs=setenv bootargs root=/dev/hda2 ro\0" \
"addip=setenv bootargs $(bootargs) " \
"ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask)" \
":$(hostname):$(netdev):off panic=1\0" \
"addcons=setenv bootargs $(bootargs) " \
"console=ttyS0,$(baudrate) console=tty0\0" \
"flash_self=run ramargs addip addcons;" \
"bootm $(kernel_addr) $(ramdisk_addr)\0" \
"flash_nfs=run nfsargs addip addcons; bootm $(kernel_addr)\0" \
"net_nfs=tftp 200000 $(bootfile); " \
"run nfsargs addip addcons; bootm\0" \
"ide_nfs=run nfsargs addip addcons; " \
"disk 200000 0:1; bootm\0" \
"ide_ide=run ideargs addip addcons; " \
"disk 200000 0:1; bootm\0" \
"usb_self=run usbload; run ramargs addip addcons; " \
"bootm 200000 400000\0" \
"usbload=usb reset; usb scan; usbboot 200000 0:1; " \
"usbboot 400000 0:2\0" \
"bootfile=uImage\0" \
"load=tftp 200000 $(u-boot)\0" \
"u-boot=u-boot.bin\0" \
"update=protect off FC000000 FC05FFFF;" \
"erase FC000000 FC05FFFF;" \
"cp.b 200000 FC000000 $(filesize);" \
"protect on FC000000 FC05FFFF\0" \
""
#define CONFIG_BOOTCOMMAND "run flash_self"
/*
* IPB Bus clocking configuration.
*/
#define CONFIG_SYS_IPBCLK_EQUALS_XLBCLK /* define for 133MHz speed */
/*
* PCI Bus clocking configuration
*
* Actually a PCI Clock of 66 MHz is only set (in cpu_init.c) if
* CONFIG_SYS_IPBCLK_EQUALS_XLBCLK is defined. This is because a PCI Clock
* of 66 MHz yet hasn't been tested with a IPB Bus Clock of 66 MHz.
*/
#if defined(CONFIG_SYS_IPBCLK_EQUALS_XLBCLK)
# define CONFIG_SYS_PCICLK_EQUALS_IPBCLK_DIV2 /* define for 66MHz speed */
#endif
/*
* I2C configuration
*/
#define CONFIG_HARD_I2C 1 /* I2C with hardware support */
#define CONFIG_SYS_I2C_MODULE 2 /* Select I2C module #2 */
/*
* I2C clock frequency
*
* Please notice, that the resulting clock frequency could differ from the
* configured value. This is because the I2C clock is derived from system
* clock over a frequency divider with only a few divider values. U-boot
* calculates the best approximation for CONFIG_SYS_I2C_SPEED. However the calculated
* approximation allways lies below the configured value, never above.
*/
#define CONFIG_SYS_I2C_SPEED 100000 /* 100 kHz */
#define CONFIG_SYS_I2C_SLAVE 0x7F
/*
* EEPROM configuration for I²C EEPROM M24C32
* M24C64 should work also. For other EEPROMs config should be verified.
*
* The TQM5200 module may hold an EEPROM at address 0x50.
*/
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* 1010000x (TQM) */
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 5 /* =32 Bytes per write */
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 70
/*
* RTC configuration
*/
#if defined (CONFIG_BC3450_DS1340) && !defined (CONFIG_BC3450_DS3231)
# define CONFIG_RTC_M41T11 1
# define CONFIG_SYS_I2C_RTC_ADDR 0x68
#else
# define CONFIG_RTC_MPC5200 1 /* use MPC5200 internal RTC */
# define CONFIG_BOARD_EARLY_INIT_R
#endif
/*
* Flash configuration
*/
#define CONFIG_SYS_FLASH_BASE CONFIG_SYS_TEXT_BASE /* 0xFC000000 */
/* use CFI flash driver if no module variant is spezified */
#define CONFIG_SYS_FLASH_CFI 1 /* Flash is CFI conformant */
#define CONFIG_FLASH_CFI_DRIVER 1 /* Use the common driver */
#define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_BOOTCS_START }
#define CONFIG_SYS_FLASH_EMPTY_INFO
#define CONFIG_SYS_FLASH_SIZE 0x04000000 /* 64 MByte */
#define CONFIG_SYS_MAX_FLASH_SECT 512 /* max num of sects on one chip */
#undef CONFIG_SYS_FLASH_USE_BUFFER_WRITE /* not supported yet for AMD */
#if !defined(CONFIG_SYS_LOWBOOT)
#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x00760000 + 0x00800000)
#else /* CONFIG_SYS_LOWBOOT */
#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x00060000)
#endif /* CONFIG_SYS_LOWBOOT */
#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max num of flash banks
(= chip selects) */
#define CONFIG_SYS_FLASH_ERASE_TOUT 240000 /* Flash Erase Timeout (in ms) */
#define CONFIG_SYS_FLASH_WRITE_TOUT 500 /* Flash Write Timeout (in ms) */
/* Dynamic MTD partition support */
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE /* needed for mtdparts commands */
#define CONFIG_FLASH_CFI_MTD
#define MTDIDS_DEFAULT "nor0=TQM5200-0"
#define MTDPARTS_DEFAULT "mtdparts=TQM5200-0:640k(firmware)," \
"1408k(kernel)," \
"2m(initrd)," \
"4m(small-fs)," \
"16m(big-fs)," \
"8m(misc)"
/*
* Environment settings
*/
#define CONFIG_ENV_IS_IN_FLASH 1
#define CONFIG_ENV_SIZE 0x10000
#define CONFIG_ENV_SECT_SIZE 0x20000
#define CONFIG_ENV_ADDR_REDUND (CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE)
#define CONFIG_ENV_SIZE_REDUND (CONFIG_ENV_SIZE)
/*
* Memory map
*/
#define CONFIG_SYS_MBAR 0xF0000000
#define CONFIG_SYS_SDRAM_BASE 0x00000000
#define CONFIG_SYS_DEFAULT_MBAR 0x80000000
/* Use ON-Chip SRAM until RAM will be available */
#define CONFIG_SYS_INIT_RAM_ADDR MPC5XXX_SRAM
#ifdef CONFIG_POST
/* preserve space for the post_word at end of on-chip SRAM */
# define CONFIG_SYS_INIT_RAM_SIZE MPC5XXX_SRAM_POST_SIZE
#else
# define CONFIG_SYS_INIT_RAM_SIZE MPC5XXX_SRAM_SIZE
#endif /*CONFIG_POST*/
#define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
#define CONFIG_SYS_INIT_SP_OFFSET CONFIG_SYS_GBL_DATA_OFFSET
#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
# define CONFIG_SYS_RAMBOOT 1
#endif
#define CONFIG_SYS_MONITOR_LEN (384 << 10) /* Reserve 384 kB for Monitor */
#define CONFIG_SYS_MALLOC_LEN (128 << 10) /* Reserve 128 kB for malloc() */
#define CONFIG_SYS_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
/*
* Ethernet configuration
*
* Define CONFIG_MPC5xxx_MII10 to force FEC at 10MBIT
*/
#define CONFIG_MPC5xxx_FEC 1
#define CONFIG_MPC5xxx_FEC_MII100
#undef CONFIG_MPC5xxx_MII10
#define CONFIG_PHY_ADDR 0x00
/*
* GPIO configuration on BC3450
*
* PSC1: UART1 (Service-UART) [0x xxxxxxx4]
* PSC2: UART2 [0x xxxxxx4x]
* or: AC/97 if CONFIG_BC3450_AC97 [0x xxxxxx2x]
* PSC3: USB2 [0x xxxxx1xx]
* USB: UART4(ext.)/UART5(int.) [0x xxxx2xxx]
* (this has to match
* CONFIG_USB_CONFIG which is
* used by usb_ohci.c to set
* the USB ports)
* Eth: 10/100Mbit Ethernet [0x xxx0xxxx]
* (this is reset to '5'
* in FEC driver: fec.c)
* PSC6: UART6 (int. to PS/2 contr.) [0x xx5xxxxx]
* ATA/CS: ??? [0x x1xxxxxx]
* FIXME! UM Fig 2-10 suggests [0x x0xxxxxx]
* CS1: Use Pin gpio_wkup_6 as second
* SDRAM chip select (mem_cs1)
* Timer: CAN2 / SPI
* I2C: CAN1 / I²C2 [0x bxxxxxxx]
*/
#ifdef CONFIG_BC3450_AC97
# define CONFIG_SYS_GPS_PORT_CONFIG 0xb1502124
#else /* PSC2=UART2 */
# define CONFIG_SYS_GPS_PORT_CONFIG 0xb1502144
#endif
/*
* Miscellaneous configurable options
*/
#define CONFIG_SYS_LONGHELP /* undef to save memory */
#if defined(CONFIG_CMD_KGDB)
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
#else
#define CONFIG_SYS_CBSIZE 256 /* Console I/O Buffer Size */
#endif
#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */
#define CONFIG_SYS_MAXARGS 16 /* max no of command args */
#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Arg. Buffer Size */
#define CONFIG_SYS_ALT_MEMTEST /* Enable an alternative, */
/* more extensive mem test */
#define CONFIG_SYS_MEMTEST_START 0x00100000 /* memtest works on */
#define CONFIG_SYS_MEMTEST_END 0x00f00000 /* 1 ... 15 MB in DRAM */
#define CONFIG_SYS_LOAD_ADDR 0x100000 /* default load address */
#define CONFIG_SYS_CACHELINE_SIZE 32 /* For MPC5xxx CPUs */
#if defined(CONFIG_CMD_KGDB)
# define CONFIG_SYS_CACHELINE_SHIFT 5 /* log base 2 of the above value */
#endif
/*
* Enable loopw command.
*/
#define CONFIG_LOOPW
/*
* Various low-level settings
*/
#define CONFIG_SYS_HID0_INIT HID0_ICE | HID0_ICFI
#define CONFIG_SYS_HID0_FINAL HID0_ICE
#define CONFIG_SYS_BOOTCS_START CONFIG_SYS_FLASH_BASE
#define CONFIG_SYS_BOOTCS_SIZE CONFIG_SYS_FLASH_SIZE
#ifdef CONFIG_SYS_PCICLK_EQUALS_IPBCLK_DIV2
# define CONFIG_SYS_BOOTCS_CFG 0x0008DF30 /* for pci_clk = 66 MHz */
#else
# define CONFIG_SYS_BOOTCS_CFG 0x0004DF30 /* for pci_clk = 33 MHz */
#endif
#define CONFIG_SYS_CS0_START CONFIG_SYS_FLASH_BASE
#define CONFIG_SYS_CS0_SIZE CONFIG_SYS_FLASH_SIZE
/* automatic configuration of chip selects */
#ifdef CONFIG_TQM5200
# define CONFIG_LAST_STAGE_INIT
#endif /* CONFIG_TQM5200 */
/*
* SRAM - Do not map below 2 GB in address space, because this area is used
* for SDRAM autosizing.
*/
#ifdef CONFIG_TQM5200
# define CONFIG_SYS_CS2_START 0xE5000000
# define CONFIG_SYS_CS2_SIZE 0x100000 /* 1 MByte */
# define CONFIG_SYS_CS2_CFG 0x0004D930
#endif /* CONFIG_TQM5200 */
/*
* Grafic controller - Do not map below 2 GB in address space, because this
* area is used for SDRAM autosizing.
*/
#ifdef CONFIG_TQM5200
# define SM501_FB_BASE 0xE0000000
# define CONFIG_SYS_CS1_START (SM501_FB_BASE)
# define CONFIG_SYS_CS1_SIZE 0x4000000 /* 64 MByte */
# define CONFIG_SYS_CS1_CFG 0x8F48FF70
# define SM501_MMIO_BASE CONFIG_SYS_CS1_START + 0x03E00000
#endif /* CONFIG_TQM5200 */
#define CONFIG_SYS_CS_BURST 0x00000000
#define CONFIG_SYS_CS_DEADCYCLE 0x33333311 /* 1 dead cycle for */
/* flash and SM501 */
#define CONFIG_SYS_RESET_ADDRESS 0xff000000
/*
* USB stuff
*/
#define CONFIG_USB_CLOCK 0x0001BBBB
#define CONFIG_USB_CONFIG 0x00002000 /* we're using Port 2 */
/*
* IDE/ATA stuff Supports IDE harddisk
*/
#undef CONFIG_IDE_8xx_PCCARD /* Use IDE with PC Card Adapter */
#undef CONFIG_IDE_8xx_DIRECT /* Direct IDE not supported */
#undef CONFIG_IDE_LED /* LED for ide not supported */
#define CONFIG_IDE_RESET /* reset for ide supported */
#define CONFIG_IDE_PREINIT
#define CONFIG_SYS_IDE_MAXBUS 1 /* max. 1 IDE bus */
#define CONFIG_SYS_IDE_MAXDEVICE 2 /* max. 2 drives per IDE bus */
#define CONFIG_SYS_ATA_IDE0_OFFSET 0x0000
#define CONFIG_SYS_ATA_BASE_ADDR MPC5XXX_ATA
/* Offset for data I/O */
#define CONFIG_SYS_ATA_DATA_OFFSET (0x0060)
/* Offset for normal register accesses */
#define CONFIG_SYS_ATA_REG_OFFSET (CONFIG_SYS_ATA_DATA_OFFSET)
/* Offset for alternate registers */
#define CONFIG_SYS_ATA_ALT_OFFSET (0x005C)
/* Interval between registers */
#define CONFIG_SYS_ATA_STRIDE 4
#endif /* __CONFIG_H */
| {
"pile_set_name": "Github"
} |
export { default } from './Button'
| {
"pile_set_name": "Github"
} |
/*
Copyright (c) 2013, Joel Levin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of ADNKit nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "ANKClient+ANKInteraction.h"
#import "ANKInteraction.h"
@implementation ANKClient (ANKInteraction)
- (ANKJSONRequestOperation *)fetchInteractionsForCurrentUserWithCompletion:(ANKClientCompletionBlock)completionHandler {
return [self enqueueGETPath:@"users/me/interactions"
parameters:nil
success:[self successHandlerForCollectionOfResourceClass:[ANKInteraction class] clientHandler:completionHandler]
failure:[self failureHandlerForClientHandler:completionHandler]];
}
@end
| {
"pile_set_name": "Github"
} |
"use strict";
module.exports = function(
Promise, INTERNAL, tryConvertToPromise, apiRejection) {
var isArray = require("./util.js").isArray;
var raceLater = function (promise) {
return promise.then(function(array) {
return race(array, promise);
});
};
function race(promises, parent) {
var maybePromise = tryConvertToPromise(promises);
if (maybePromise instanceof Promise) {
return raceLater(maybePromise);
} else if (!isArray(promises)) {
return apiRejection("expecting an array, a promise or a thenable\u000a\u000a See http://goo.gl/s8MMhc\u000a");
}
var ret = new Promise(INTERNAL);
if (parent !== undefined) {
ret._propagateFrom(parent, 4 | 1);
}
var fulfill = ret._fulfill;
var reject = ret._reject;
for (var i = 0, len = promises.length; i < len; ++i) {
var val = promises[i];
if (val === undefined && !(i in promises)) {
continue;
}
Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
}
return ret;
}
Promise.race = function (promises) {
return race(promises, undefined);
};
Promise.prototype.race = function () {
return race(this, undefined);
};
};
| {
"pile_set_name": "Github"
} |
## Introduction
The Material Design Lite (MDL) **typography** component is a comprehensive approach to standardizing the use of typefaces in applications and page displays. MDL typography elements are intended to replace the myriad fonts used by developers (which vary significantly in appearance) and provide a robust, uniform library of text styles from which developers can choose.
The "Roboto" typeface is the standard for MDL display; it can easily be integrated into a web page using the CSS3 `@font-face` rule. However, Roboto is most simply accessed and included using a single standard HTML `<link>` element, which can be obtained at [this Google fonts page](http://www.google.com/fonts#UsePlace:use/Collection:Roboto).
Because of the many possible variations in font display characteristics in HTML and CSS, MDL typography aims to provide simple and intuitive styles that use the Roboto font and produce visually attractive and internally consistent text results. See the typography component's [Material Design specifications page](http://www.google.com/design/spec/style/typography.html) for details.
## Basic use
Include a link to the Google stylesheet that accesses the font and its desired variations.
```html
<head>
<link
href='http://fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic'
rel='stylesheet' type='text/css'>
...
</head>
```
### To include an MDL **typography** component:
1. Code any element (`<div>`,`<p>`,`<span>`, etc.) that can contain text, including whatever content is appropriate.
```html
<p>This is a standard paragraph.</p>
```
2. Add one or more MDL classes, separated by spaces, to the element using the `class` attribute.
```html
<p class="mdl-typography--body-1">This is a standard paragraph.</p>
```
The typography component is ready for use.
#### Examples
A "headline" paragraph.
```html
<p class="mdl-typography--headline">Regular 24px</p>
```
A "title" paragraph.
```html
<p class="mdl-typography--title">Medium 20px</p>
```
A "caption" span.
```html
<span class="mdl-typography--caption">Regular 12px</span>
```
A "button" span.
```html
<span class="mdl-typography--button">Medium (All Caps) 14px</span>
```
A "display 1" table cell.
```html
<td class="mdl-typography--display-1">Regular 34px</td>
```
A "body-1" paragraph, also uppercased.
```html
<p class="mdl-typography--body-1 mdl-typography--text-uppercase">
This is a standard paragraph, but uppercased.
</p>
```
>**Note:** Because the Roboto font is intended to apply to the entire page, standard "unclassed" HTML elements (e.g., heading levels, divs, paragraphs, spans, tables, etc. with no `class` attribute) and text modifiers (e.g., strong, em, small, etc.) will use Roboto, while also retaining their inherent and/or inherited characteristics.
>
>Also note that MDL typography provides some automatic adjustments based on its display environment. For example, the `body-1` style renders at 14px on a mobile device, but 13px on a desktop. You need not do anything to activate these self-modifiers; they are built into the MDL styles.
## Configuration options
The MDL CSS classes specify the style to use. The table below lists the available classes and their effects.
| MDL class | Effect | Remarks |
|-----------|--------|---------|
| `mdl-typography--body-1` | Regular 14px (Device), Regular 13px (Desktop) | Optional |
| `mdl-typography--body-1-force-preferred-font` | Regular 14px (Device), Regular 13px (Desktop) | Optional |
| `mdl-typography--body-2` | Medium 14px (Device), Medium 13px (Desktop) | Optional |
| `mdl-typography--body-2` | mdl-typography-body-2 | Optional |
| `mdl-typography--body-2-color-contrast` | Body with color contrast | Optional |
| `mdl-typography--body-2-force-preferred-font` | Medium 14px (Device), Medium 13px (Desktop) | Optional |
| `mdl-typography--button` | Medium (All Caps) 14px | Optional |
| `mdl-typography--caption` | Regular 12px | Optional |
| `mdl-typography--caption-color-contrast` | Caption with color contrast | Optional |
| `mdl-typography--display-1` | Regular 34px | Optional |
| `mdl-typography--display-1-color-contrast` | Display with color contrast | Optional |
| `mdl-typography--display-2` | Regular 45px | Optional |
| `mdl-typography--display-3` | Regular 56px | Optional |
| `mdl-typography--display-4` | Light 112px | Optional |
| `mdl-typography--headline` | Regular 24px | Optional |
| `mdl-typography--menu` | Medium 14px (Device), Medium 13px (Desktop) | Optional |
| `mdl-typography--subhead` | Regular 16px (Device), Regular 15px (Desktop) | Optional |
| `mdl-typography--subhead-color-contrast` | Subhead with color contrast | Optional |
| `mdl-typography--table-striped` | Striped table| Optional |
| `mdl-typography--text-capitalize` | Capitalized text | Optional |
| `mdl-typography--text-center` | Center aligned text | Optional |
| `mdl-typography--text-justify` | Justified text | Optional |
| `mdl-typography--text-left` | Left aligned text | Optional |
| `mdl-typography--text-lowercase` | Lowercased text | Optional |
| `mdl-typography--text-nowrap` | No wrap text | Optional |
| `mdl-typography--text-right` | Right aligned text | Optional |
| `mdl-typography--text-uppercase` | Uppercased text | Optional |
| `mdl-typography--title` | Medium 20px | Optional |
| `mdl-typography--title-color-contrast` | Title with color contrast | Optional |
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C68" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Tnf-dk-9EF">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Segues with Peek and Pop" minToolsVersion="7.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--City Guide View Controller-->
<scene sceneID="h9p-gh-5mz">
<objects>
<viewController id="Tnf-dk-9EF" customClass="CityGuideViewController" customModule="HeroExamples" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="w8v-n5-3mO"/>
<viewControllerLayoutGuide type="bottom" id="NvN-jP-Psy"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kJb-V7-Onr">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="bV4-y8-FY0">
<rect key="frame" x="0.0" y="319" width="375" height="348"/>
<color key="backgroundColor" red="0.91683242499999995" green="0.95149029709999999" blue="0.98076589110000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="348" id="euj-5I-eEb"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="J1P-a4-Tc1">
<size key="itemSize" width="200" height="298"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="24" minY="24" maxX="24" maxY="24"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="item" id="1jz-4R-leo" customClass="CityCell" customModule="HeroExamples" customModuleProvider="target">
<rect key="frame" x="24" y="25" width="200" height="298"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="200" height="298"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="QyW-Uk-FDt">
<rect key="frame" x="0.0" y="0.0" width="200" height="298"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="4"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="City Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xBl-3a-4YU">
<rect key="frame" x="24" y="222" width="94" height="24"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Description" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ivO-PK-Dvc">
<rect key="frame" x="24" y="255" width="65" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.97638529539999996" green="0.97652524709999999" blue="0.97635465860000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<constraints>
<constraint firstItem="QyW-Uk-FDt" firstAttribute="leading" secondItem="1jz-4R-leo" secondAttribute="leading" id="2Hd-tp-Bbe"/>
<constraint firstAttribute="bottomMargin" secondItem="ivO-PK-Dvc" secondAttribute="bottom" constant="20" id="4b2-yM-aUa"/>
<constraint firstAttribute="bottom" secondItem="QyW-Uk-FDt" secondAttribute="bottom" id="CPW-nK-rEN"/>
<constraint firstItem="QyW-Uk-FDt" firstAttribute="top" secondItem="1jz-4R-leo" secondAttribute="top" id="Oqi-md-8cC"/>
<constraint firstItem="xBl-3a-4YU" firstAttribute="leading" secondItem="1jz-4R-leo" secondAttribute="leadingMargin" constant="16" id="eVY-1Q-OWl"/>
<constraint firstAttribute="trailing" secondItem="QyW-Uk-FDt" secondAttribute="trailing" id="gCs-ge-oFc"/>
<constraint firstItem="ivO-PK-Dvc" firstAttribute="leading" secondItem="1jz-4R-leo" secondAttribute="leadingMargin" constant="16" id="jHZ-RC-fgv"/>
<constraint firstItem="ivO-PK-Dvc" firstAttribute="top" secondItem="xBl-3a-4YU" secondAttribute="bottom" constant="9" id="yGL-dj-G8M"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="shadowRadius">
<real key="value" value="5"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="shadowOpacity">
<real key="value" value="0.29999999999999999"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="shadowColor">
<color key="value" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="size" keyPath="shadowOffset">
<size key="value" width="0.0" height="2"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="descriptionLabel" destination="ivO-PK-Dvc" id="dZD-3N-QFk"/>
<outlet property="imageView" destination="QyW-Uk-FDt" id="r5x-gL-3zV"/>
<outlet property="nameLabel" destination="xBl-3a-4YU" id="Hjs-pD-fX7"/>
<segue destination="zqh-r4-Svz" kind="presentation" id="S1k-xy-pA0">
<segue key="commit" inheritsFrom="parent" id="Eza-Eu-jqY"/>
<segue key="preview" inheritsFrom="commit" id="gQ9-ti-tgW"/>
</segue>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="Tnf-dk-9EF" id="Dft-dI-eGs"/>
<outlet property="delegate" destination="Tnf-dk-9EF" id="GRM-bK-W0x"/>
</connections>
</collectionView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Adventure awaits" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LCG-7f-btr">
<rect key="frame" x="24" y="84" width="251" height="44"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="32"/>
<color key="textColor" red="0.25490196079999999" green="0.28627450980000002" blue="0.30980392159999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="heroModifierString" value="fade translate(0, -150)"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="in" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D93-Tu-ctG">
<rect key="frame" x="24" y="136" width="27" height="44"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="32"/>
<color key="textColor" red="0.25490196079999999" green="0.28627450980000002" blue="0.30980392159999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="heroModifierString" value="fade translate(0, -150)"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="CANADA" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gSV-gT-qDG">
<rect key="frame" x="61" y="132" width="157" height="50"/>
<fontDescription key="fontDescription" name="AvenirNext-Medium" family="Avenir Next" pointSize="36"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="heroModifierString" value="fade translate(0, -150)"/>
<userDefinedRuntimeAttribute type="string" keyPath="heroID" value="canada"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hMq-vu-I9j">
<rect key="frame" x="4" y="28" width="48" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="0VB-Lk-PvJ"/>
<constraint firstAttribute="width" constant="48" id="qzi-YT-XHw"/>
</constraints>
<color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<state key="normal" image="ic_keyboard_arrow_down"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="24"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="heroModifierString" value="fade translate(0, -150)"/>
<userDefinedRuntimeAttribute type="string" keyPath="heroID" value="back"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="hero_dismissViewController" destination="RHl-8a-4vU" eventType="touchUpInside" id="JpC-2M-tbD"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="POPULAR DESTINATIONS" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3OK-2F-Vl7">
<rect key="frame" x="24" y="281" width="191" height="22"/>
<fontDescription key="fontDescription" name="AvenirNext-Regular" family="Avenir Next" pointSize="16"/>
<color key="textColor" red="0.25490196079999999" green="0.28627450980000002" blue="0.30980392159999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="heroModifierString" value="fade translate(0, -150)"/>
<userDefinedRuntimeAttribute type="string" keyPath="heroID" value="destinations"/>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<color key="backgroundColor" red="0.91683242499999995" green="0.95149029709999999" blue="0.98076589110000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="LCG-7f-btr" firstAttribute="leading" secondItem="kJb-V7-Onr" secondAttribute="leadingMargin" constant="8" id="7jb-7j-SvO"/>
<constraint firstItem="gSV-gT-qDG" firstAttribute="top" secondItem="LCG-7f-btr" secondAttribute="bottom" constant="4" id="8px-GD-T7c"/>
<constraint firstItem="D93-Tu-ctG" firstAttribute="top" secondItem="LCG-7f-btr" secondAttribute="bottom" constant="8" id="HxI-fa-cH5"/>
<constraint firstItem="NvN-jP-Psy" firstAttribute="top" secondItem="bV4-y8-FY0" secondAttribute="bottom" id="JVG-zd-HzG"/>
<constraint firstItem="D93-Tu-ctG" firstAttribute="leading" secondItem="kJb-V7-Onr" secondAttribute="leadingMargin" constant="8" id="LDY-Ey-eHp"/>
<constraint firstItem="gSV-gT-qDG" firstAttribute="leading" secondItem="D93-Tu-ctG" secondAttribute="trailing" constant="10" id="LN2-FQ-FYP"/>
<constraint firstItem="bV4-y8-FY0" firstAttribute="leading" secondItem="kJb-V7-Onr" secondAttribute="leading" id="Tv9-lC-aoE"/>
<constraint firstItem="bV4-y8-FY0" firstAttribute="top" secondItem="3OK-2F-Vl7" secondAttribute="bottom" constant="16" id="VFa-kT-voo"/>
<constraint firstAttribute="trailing" secondItem="bV4-y8-FY0" secondAttribute="trailing" id="bGs-sx-VfY"/>
<constraint firstItem="hMq-vu-I9j" firstAttribute="top" secondItem="w8v-n5-3mO" secondAttribute="bottom" constant="8" id="cag-Gz-HlB"/>
<constraint firstItem="hMq-vu-I9j" firstAttribute="leading" secondItem="kJb-V7-Onr" secondAttribute="leadingMargin" constant="-12" id="n2U-Wx-n77"/>
<constraint firstItem="LCG-7f-btr" firstAttribute="top" secondItem="w8v-n5-3mO" secondAttribute="bottom" constant="64" id="qdv-O4-fQ1"/>
<constraint firstItem="3OK-2F-Vl7" firstAttribute="leading" secondItem="kJb-V7-Onr" secondAttribute="leadingMargin" constant="8" id="qln-vb-XPW"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="heroID" value="cityBackground"/>
</userDefinedRuntimeAttributes>
</view>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="isHeroEnabled" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="collectionView" destination="bV4-y8-FY0" id="dEe-8j-cbG"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="RHl-8a-4vU" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-0.80000000000000004" y="-0.44977511244377816"/>
</scene>
<!--City View Controller-->
<scene sceneID="fwz-Du-JHU">
<objects>
<viewController id="zqh-r4-Svz" customClass="CityViewController" customModule="HeroExamples" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="MEI-89-uDD"/>
<viewControllerLayoutGuide type="bottom" id="zYL-Sh-0i5"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="7Z5-Vo-FmQ">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" pagingEnabled="YES" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="hLT-eh-T42">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="SP2-Vu-78w">
<size key="itemSize" width="375" height="669"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="item" id="UsK-II-tbB" customClass="CityCell" customModule="HeroExamples" customModuleProvider="target">
<rect key="frame" x="0.0" y="-1" width="375" height="669"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="375" height="669"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="oOO-ar-dfh">
<rect key="frame" x="0.0" y="0.0" width="375" height="669"/>
</imageView>
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RIc-t0-T4M">
<rect key="frame" x="0.0" y="0.0" width="375" height="669"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Description" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Q8c-oW-Hod">
<rect key="frame" x="24" y="292" width="327" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.97638529539999996" green="0.97652524709999999" blue="0.97635465860000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="City Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rsu-p5-jev">
<rect key="frame" x="24" y="246" width="144" height="37"/>
<fontDescription key="fontDescription" type="system" pointSize="31"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<constraints>
<constraint firstItem="rsu-p5-jev" firstAttribute="leading" secondItem="UsK-II-tbB" secondAttribute="leadingMargin" constant="16" id="1CW-wY-4WO"/>
<constraint firstItem="oOO-ar-dfh" firstAttribute="top" secondItem="UsK-II-tbB" secondAttribute="top" id="GNJ-3L-mwm"/>
<constraint firstAttribute="trailing" secondItem="RIc-t0-T4M" secondAttribute="trailing" id="LYz-8t-OmL"/>
<constraint firstItem="Q8c-oW-Hod" firstAttribute="top" secondItem="rsu-p5-jev" secondAttribute="bottom" constant="9" id="MQ9-Ig-gXU"/>
<constraint firstAttribute="trailingMargin" secondItem="Q8c-oW-Hod" secondAttribute="trailing" constant="16" id="SXR-51-Bo3"/>
<constraint firstAttribute="trailing" secondItem="oOO-ar-dfh" secondAttribute="trailing" id="V0W-tI-5qz"/>
<constraint firstItem="rsu-p5-jev" firstAttribute="centerY" secondItem="UsK-II-tbB" secondAttribute="centerY" constant="-70" id="aS0-JE-rHo"/>
<constraint firstItem="RIc-t0-T4M" firstAttribute="top" secondItem="UsK-II-tbB" secondAttribute="top" id="b5q-6h-6zx"/>
<constraint firstAttribute="bottom" secondItem="oOO-ar-dfh" secondAttribute="bottom" id="gen-dL-Spm"/>
<constraint firstItem="oOO-ar-dfh" firstAttribute="leading" secondItem="UsK-II-tbB" secondAttribute="leading" id="iUQ-rB-UAe"/>
<constraint firstAttribute="bottom" secondItem="RIc-t0-T4M" secondAttribute="bottom" id="luy-Ht-3hd"/>
<constraint firstItem="RIc-t0-T4M" firstAttribute="leading" secondItem="UsK-II-tbB" secondAttribute="leading" id="oib-O5-A2L"/>
<constraint firstItem="Q8c-oW-Hod" firstAttribute="leading" secondItem="UsK-II-tbB" secondAttribute="leadingMargin" constant="16" id="wgZ-Kl-P41"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="useShortDescription" value="NO"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="descriptionLabel" destination="Q8c-oW-Hod" id="Pj3-Sb-HGF"/>
<outlet property="imageView" destination="oOO-ar-dfh" id="o11-32-AYz"/>
<outlet property="nameLabel" destination="rsu-p5-jev" id="NoP-ci-iGH"/>
</connections>
</collectionViewCell>
</cells>
<connections>
<outlet property="dataSource" destination="zqh-r4-Svz" id="5aT-39-MTJ"/>
<outlet property="delegate" destination="zqh-r4-Svz" id="q5E-I7-U2G"/>
</connections>
</collectionView>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="le7-Nx-g3z">
<rect key="frame" x="4" y="28" width="48" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="715-xC-m7h"/>
<constraint firstAttribute="width" constant="48" id="o3v-HC-bwD"/>
</constraints>
<color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<state key="normal" image="ic_keyboard_arrow_down"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="24"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="heroModifierString" value="fade translate(0, -150)"/>
<userDefinedRuntimeAttribute type="string" keyPath="heroID" value="back"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="hero_dismissViewController" destination="Q5l-99-eDb" eventType="touchUpInside" id="GXK-ZH-2kP"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="hLT-eh-T42" firstAttribute="top" secondItem="7Z5-Vo-FmQ" secondAttribute="top" id="4DF-Z0-qXb"/>
<constraint firstAttribute="trailing" secondItem="hLT-eh-T42" secondAttribute="trailing" id="59o-dY-HdY"/>
<constraint firstItem="le7-Nx-g3z" firstAttribute="top" secondItem="MEI-89-uDD" secondAttribute="bottom" constant="8" id="adb-Ob-3u7"/>
<constraint firstItem="hLT-eh-T42" firstAttribute="leading" secondItem="7Z5-Vo-FmQ" secondAttribute="leading" id="p44-Lu-mgW"/>
<constraint firstItem="zYL-Sh-0i5" firstAttribute="top" secondItem="hLT-eh-T42" secondAttribute="bottom" id="swJ-dZ-51y"/>
<constraint firstItem="le7-Nx-g3z" firstAttribute="leading" secondItem="7Z5-Vo-FmQ" secondAttribute="leadingMargin" constant="-12" id="vDI-8Q-xJ7"/>
</constraints>
</view>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="isHeroEnabled" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="collectionView" destination="hLT-eh-T42" id="OGw-QS-n8P"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Q5l-99-eDb" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="800" y="0.0"/>
</scene>
</scenes>
<resources>
<image name="ic_keyboard_arrow_down" width="24" height="24"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="gQ9-ti-tgW"/>
</inferredMetricsTieBreakers>
</document>
| {
"pile_set_name": "Github"
} |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test
{
public static class TestIdentityFactory
{
public static InMemoryContext CreateContext()
{
var services = new ServiceCollection();
services.AddEntityFrameworkInMemoryDatabase();
var serviceProvider = services.BuildServiceProvider();
var db = new InMemoryContext(new DbContextOptionsBuilder().Options);
db.Database.EnsureCreated();
return db;
}
public static IServiceCollection CreateTestServices()
{
var services = new ServiceCollection();
services.AddHttpContextAccessor();
services.AddLogging();
services.AddIdentity<IdentityUser, IdentityRole>();
return services;
}
public static RoleManager<IdentityRole> CreateRoleManager(InMemoryContext context)
{
var services = CreateTestServices();
services.AddSingleton<IRoleStore<IdentityRole>>(new RoleStore<IdentityRole>(context));
return services.BuildServiceProvider().GetRequiredService<RoleManager<IdentityRole>>();
}
public static RoleManager<IdentityRole> CreateRoleManager()
{
return CreateRoleManager(CreateContext());
}
}
}
| {
"pile_set_name": "Github"
} |
package sign
import clog "github.com/coredns/coredns/plugin/pkg/log"
func init() { clog.Discard() }
| {
"pile_set_name": "Github"
} |
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:starter_architecture_flutter_firebase/app/home/jobs/empty_content.dart';
import 'package:starter_architecture_flutter_firebase/app/top_level_providers.dart';
class AuthWidget extends ConsumerWidget {
const AuthWidget({
Key key,
@required this.signedInBuilder,
@required this.nonSignedInBuilder,
}) : super(key: key);
final WidgetBuilder nonSignedInBuilder;
final WidgetBuilder signedInBuilder;
@override
Widget build(BuildContext context, ScopedReader watch) {
final authStateChanges = watch(authStateChangesProvider);
return authStateChanges.when(
data: (user) => _data(context, user),
loading: () => const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
),
error: (_, __) => const Scaffold(
body: EmptyContent(
title: 'Something went wrong',
message: 'Can\'t load data right now.',
),
),
);
}
Widget _data(BuildContext context, User user) {
if (user != null) {
return signedInBuilder(context);
}
return nonSignedInBuilder(context);
}
}
| {
"pile_set_name": "Github"
} |
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build solaris
package lif
import (
"fmt"
"testing"
)
func (ll *Link) String() string {
return fmt.Sprintf("name=%s index=%d type=%d flags=%#x mtu=%d addr=%v", ll.Name, ll.Index, ll.Type, ll.Flags, ll.MTU, llAddr(ll.Addr))
}
type linkPack struct {
af int
lls []Link
}
func linkPacks() ([]linkPack, error) {
var lastErr error
var lps []linkPack
for _, af := range [...]int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} {
lls, err := Links(af, "")
if err != nil {
lastErr = err
continue
}
lps = append(lps, linkPack{af: af, lls: lls})
}
return lps, lastErr
}
func TestLinks(t *testing.T) {
lps, err := linkPacks()
if len(lps) == 0 && err != nil {
t.Fatal(err)
}
for _, lp := range lps {
n := 0
for _, sll := range lp.lls {
lls, err := Links(lp.af, sll.Name)
if err != nil {
t.Fatal(lp.af, sll.Name, err)
}
for _, ll := range lls {
if ll.Name != sll.Name || ll.Index != sll.Index {
t.Errorf("af=%s got %v; want %v", addrFamily(lp.af), &ll, &sll)
continue
}
t.Logf("af=%s name=%s %v", addrFamily(lp.af), sll.Name, &ll)
n++
}
}
if n != len(lp.lls) {
t.Errorf("af=%s got %d; want %d", addrFamily(lp.af), n, len(lp.lls))
continue
}
}
}
| {
"pile_set_name": "Github"
} |
import React, { PropTypes } from 'react';
import extendStyles from 'enhancers/extendStyles';
const Test = props =>
<div style={props.style}>
Hello world!
</div>;
Test.propTypes = {
style: PropTypes.object,
};
export default extendStyles(Test);
| {
"pile_set_name": "Github"
} |
..
**************************************************
* *
* Automatically generated file, do not edit! *
* *
**************************************************
.. _amdgpu_synid8_ssrc64_2:
ssrc
===========================
Instruction input.
*Size:* 2 dwords.
*Operands:* :ref:`s<amdgpu_synid_s>`, :ref:`flat_scratch<amdgpu_synid_flat_scratch>`, :ref:`xnack<amdgpu_synid_xnack>`, :ref:`vcc<amdgpu_synid_vcc>`, :ref:`trap<amdgpu_synid_trap>`, :ref:`exec<amdgpu_synid_exec>`, :ref:`vccz<amdgpu_synid_vccz>`, :ref:`execz<amdgpu_synid_execz>`, :ref:`scc<amdgpu_synid_scc>`, :ref:`constant<amdgpu_synid_constant>`
| {
"pile_set_name": "Github"
} |
---
topic: sample
languages:
- js
products:
- windows
- windows-uwp
---
# Simple orientation sensor sample
Shows how to use the [Windows.Devices.Sensors.SimpleOrientationSensor](https://msdn.microsoft.com/library/windows/apps/windows.devices.sensors.simpleorientationsensor.aspx)
class for a simple device orientation sensor.
> **Note:** This sample is part of a large collection of UWP feature samples.
> If you are unfamiliar with Git and GitHub, you can download the entire collection as a
> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be
> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file,
> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq).
> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center.
This sample allows the user to view the orientation values that reflect the simple device orientation (for example, not rotated, face up, rotated 90 degrees counter-clockwise).
You can choose one of two scenarios:
- Orientation sensor data events
- Polling orientation sensor readings
**Simple Orientation Sensor Data Events**
When you choose the Enable button for the **Data Events** option, the app will begin displaying sensor readings in real time.
**Polling Simple Orientation Sensor Readings**
When you choose the Enable button for the **Polling** option, the app will retrieve the current sensor readings.
## System requirements
**Client:** Windows 10
**Server:** Windows Server 2016 Technical Preview
**Phone:** Windows 10
## Build the sample
1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
2. Start Microsoft Visual Studio 2017 and select **File** \> **Open** \> **Project/Solution**.
3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file.
4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**.
## Run the sample
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
### Deploying the sample
- Select Build > Deploy Solution.
### Deploying and running the sample
- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.
| {
"pile_set_name": "Github"
} |
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Node\Expression\Binary;
use Twig\Compiler;
class MatchesBinary extends AbstractBinary
{
public function compile(Compiler $compiler)
{
$compiler
->raw('preg_match(')
->subcompile($this->getNode('right'))
->raw(', ')
->subcompile($this->getNode('left'))
->raw(')')
;
}
public function operator(Compiler $compiler)
{
return $compiler->raw('');
}
}
class_alias('Twig\Node\Expression\Binary\MatchesBinary', 'Twig_Node_Expression_Binary_Matches');
| {
"pile_set_name": "Github"
} |
---
MXNET_VERSION: "mxnet_v1.1.0"
output_path: "skpeep/default/output/fold4_352/rcnn_dcn_default/"
symbol: resnet_v1_101_rcnn_dcn_attention_1024_pairwise_position_multi_head_16
gpus: '1'
CLASS_AGNOSTIC: true
SCALES:
- 424
- 424
default:
frequent: 100
kvstore: device
network:
pretrained: "../DeformableConvNets/model/pretrained_model/resnet_v1_101"
pretrained epoch: 0
PIXEL_MEANS:
- 103.06
- 115.90
- 123.15
IMAGE_STRIDE: 0
RCNN_FEAT_STRIDE: 16
RPN_FEAT_STRIDE: 16
FIXED_PARAMS:
- conv1
- bn_conv1
- res2
- bn2
- gamma
- beta
FIXED_PARAMS_SHARED:
- conv1
- bn_conv1
- res2
- bn2
- res3
- bn3
- res4
- bn4
- gamma
- beta
ANCHOR_RATIOS:
- 0.5
- 1
- 2
ANCHOR_SCALES:
- 4
- 8
- 16
- 32
NUM_ANCHORS: 12
dataset:
NUM_CLASSES: 2
dataset: coco
dataset_path: "../../data/coco/rsna/"
image_set: train4-pos
root_path: "../../data/coco/"
test_image_set: stage_2_test_flip
proposal: rpn
TRAIN:
lr: 0.0005
lr_step: '5.33'
warmup: false
warmup_lr: 0.00005
warmup_step: 8000
begin_epoch: 0
end_epoch: 8
model_prefix: 'rcnn_dcn_rsna_fold4_352'
RESUME: false
FLIP: true
SHUFFLE: true
ENABLE_OHEM: true
BATCH_IMAGES: 1
END2END: true
ASPECT_GROUPING: true
BATCH_ROIS: -1
BATCH_ROIS_OHEM: 128
FG_FRACTION: 0.25
FG_THRESH: 0.5
BG_THRESH_HI: 0.5
BG_THRESH_LO: 0
BBOX_REGRESSION_THRESH: 0.5
BBOX_WEIGHTS:
- 1.0
- 1.0
- 1.0
- 1.0
RPN_BATCH_SIZE: 256
RPN_FG_FRACTION: 0.5
RPN_POSITIVE_OVERLAP: 0.7
RPN_NEGATIVE_OVERLAP: 0.3
RPN_CLOBBER_POSITIVES: false
RPN_BBOX_WEIGHTS:
- 1.0
- 1.0
- 1.0
- 1.0
RPN_POSITIVE_WEIGHT: -1.0
CXX_PROPOSAL: false
RPN_NMS_THRESH: 0.7
RPN_PRE_NMS_TOP_N: 6000
RPN_POST_NMS_TOP_N: 300
RPN_MIN_SIZE: 0
BBOX_NORMALIZATION_PRECOMPUTED: true
BBOX_MEANS:
- 0.0
- 0.0
- 0.0
- 0.0
BBOX_STDS:
- 0.1
- 0.1
- 0.2
- 0.2
TEST:
HAS_RPN: true
BATCH_IMAGES: 1
CXX_PROPOSAL: false
RPN_NMS_THRESH: 0.7
RPN_PRE_NMS_TOP_N: 6000
RPN_POST_NMS_TOP_N: 300
RPN_MIN_SIZE: 0
PROPOSAL_NMS_THRESH: 0.7
PROPOSAL_PRE_NMS_TOP_N: 20000
PROPOSAL_POST_NMS_TOP_N: 2000
PROPOSAL_MIN_SIZE: 0
NMS: 0.3
test_epoch: 8
max_per_image: 5
| {
"pile_set_name": "Github"
} |
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoManager.hh"
#include "G4UnitsTable.hh"
#include "DetectorConstruction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
: fFileName("testem3")
{
Book();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
delete G4AnalysisManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::Book()
{
// Create or get analysis manager
// The choice of analysis technology is done via selection of a namespace
// in HistoManager.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetFileName(fFileName);
analysisManager->SetVerboseLevel(1);
analysisManager->SetActivation(true); // enable inactivation of histograms
// Define histograms start values
const G4String id[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10","11","12","13","14","15","16","17","18","19",
"20","21","22"};
G4String title;
// Default values (to be reset via /analysis/h1/set command)
G4int nbins = 100;
G4double vmin = 0.;
G4double vmax = 100.;
// Create all histograms as inactivated
// as we have not yet set nbins, vmin, vmax
for (G4int k=0; k<kMaxHisto; k++) {
if (k < kMaxAbsor) title = "Edep in absorber " + id[k];
if (k > kMaxAbsor) title = "Edep longit. profile (MeV/event) in absorber "
+ id[k-kMaxAbsor];
if (k == 2*kMaxAbsor+1) title = "energy flow (MeV/event)";
if (k == 2*kMaxAbsor+2) title = "lateral energy leak (MeV/event)";
G4int ih = analysisManager->CreateH1(id[k], title, nbins, vmin, vmax);
analysisManager->SetH1Activation(ih, false);
}
}
| {
"pile_set_name": "Github"
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jackrabbit.oak.security.internal;
import static org.apache.jackrabbit.oak.security.internal.ConfigurationInitializer.initializeConfiguration;
import static org.apache.jackrabbit.oak.security.internal.ConfigurationInitializer.initializeConfigurations;
import static org.apache.jackrabbit.oak.spi.security.ConfigurationParameters.EMPTY;
import org.apache.jackrabbit.oak.plugins.tree.RootProvider;
import org.apache.jackrabbit.oak.plugins.tree.TreeProvider;
import org.apache.jackrabbit.oak.plugins.tree.impl.RootProviderService;
import org.apache.jackrabbit.oak.plugins.tree.impl.TreeProviderService;
import org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl;
import org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurationImpl;
import org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl;
import org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration;
import org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl;
import org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl;
import org.apache.jackrabbit.oak.security.privilege.PrivilegeConfigurationImpl;
import org.apache.jackrabbit.oak.security.user.UserConfigurationImpl;
import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
import org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration;
import org.apache.jackrabbit.oak.spi.security.authentication.token.CompositeTokenConfiguration;
import org.apache.jackrabbit.oak.spi.security.authentication.token.TokenConfiguration;
import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
import org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants;
import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
import org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalConfiguration;
import org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration;
import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration;
import org.apache.jackrabbit.oak.spi.security.user.AuthorizableNodeName;
import org.apache.jackrabbit.oak.spi.security.user.UserAuthenticationFactory;
import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
import org.apache.jackrabbit.oak.spi.security.user.action.AuthorizableActionProvider;
import org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider;
import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
import org.jetbrains.annotations.NotNull;
public final class SecurityProviderBuilder {
private Whiteboard whiteboard;
private RootProvider rootProvider;
private TreeProvider treeProvider;
private ConfigurationParameters authenticationParams = EMPTY;
private AuthenticationConfiguration authenticationConfiguration;
private ConfigurationParameters privilegeParams = EMPTY;
private PrivilegeConfiguration privilegeConfiguration;
private ConfigurationParameters userParams = EMPTY;
private UserConfiguration userConfiguration;
private ConfigurationParameters authorizationParams = EMPTY;
private AuthorizationConfiguration authorizationConfiguration;
private ConfigurationParameters principalParams = EMPTY;
private PrincipalConfiguration principalConfiguration;
private ConfigurationParameters tokenParams = EMPTY;
private TokenConfiguration tokenConfiguration;
private ConfigurationParameters configuration;
@NotNull
public static SecurityProviderBuilder newBuilder() {
return new SecurityProviderBuilder();
}
private SecurityProviderBuilder() {
this.configuration = ConfigurationParameters.EMPTY;
}
public SecurityProviderBuilder with(@NotNull ConfigurationParameters configuration) {
this.configuration = configuration;
authenticationParams = configuration.getConfigValue(AuthenticationConfiguration.NAME, EMPTY);
privilegeParams = configuration.getConfigValue(PrivilegeConfiguration.NAME, EMPTY);
if (configuration.contains(UserConfiguration.NAME)) {
userParams = configuration.getConfigValue(UserConfiguration.NAME, EMPTY);
} else {
AuthorizableActionProvider authorizableActionProvider = new DefaultAuthorizableActionProvider();
AuthorizableNodeName authorizableNodeName = AuthorizableNodeName.DEFAULT;
UserAuthenticationFactory userAuthenticationFactory = UserConfigurationImpl
.getDefaultAuthenticationFactory();
userParams = ConfigurationParameters.of(
ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER,
authorizableActionProvider),
ConfigurationParameters.of(UserConstants.PARAM_AUTHORIZABLE_NODE_NAME, authorizableNodeName),
ConfigurationParameters.of(UserConstants.PARAM_USER_AUTHENTICATION_FACTORY,
userAuthenticationFactory));
}
if (configuration.contains(AuthorizationConfiguration.NAME)) {
authorizationParams = configuration.getConfigValue(AuthorizationConfiguration.NAME, EMPTY);
} else {
RestrictionProvider restrictionProvider = new RestrictionProviderImpl();
authorizationParams = ConfigurationParameters.of(AccessControlConstants.PARAM_RESTRICTION_PROVIDER,
restrictionProvider);
}
principalParams = configuration.getConfigValue(PrincipalConfiguration.NAME, EMPTY);
tokenParams = configuration.getConfigValue(TokenConfiguration.NAME, EMPTY);
return this;
}
public SecurityProviderBuilder with(@NotNull AuthenticationConfiguration authenticationConfiguration,
@NotNull ConfigurationParameters authenticationParams,
@NotNull PrivilegeConfiguration privilegeConfiguration, @NotNull ConfigurationParameters privilegeParams,
@NotNull UserConfiguration userConfiguration, @NotNull ConfigurationParameters userParams,
@NotNull AuthorizationConfiguration authorizationConfiguration, @NotNull ConfigurationParameters authorizationParams,
@NotNull PrincipalConfiguration principalConfiguration, @NotNull ConfigurationParameters principalParams,
@NotNull TokenConfiguration tokenConfiguration, @NotNull ConfigurationParameters tokenParams) {
this.authenticationConfiguration = authenticationConfiguration;
this.authenticationParams = authenticationParams;
this.privilegeConfiguration = privilegeConfiguration;
this.privilegeParams = privilegeParams;
this.userConfiguration = userConfiguration;
this.userParams = userParams;
this.authorizationConfiguration = authorizationConfiguration;
this.authorizationParams = authorizationParams;
this.principalConfiguration = principalConfiguration;
this.principalParams = principalParams;
this.tokenConfiguration = tokenConfiguration;
this.tokenParams = tokenParams;
return this;
}
public SecurityProvider build() {
InternalSecurityProvider securityProvider = new InternalSecurityProvider();
if (rootProvider == null) {
rootProvider = new RootProviderService();
}
if (treeProvider == null) {
treeProvider = new TreeProviderService();
}
// authentication
if (authenticationConfiguration == null) {
authenticationConfiguration = new AuthenticationConfigurationImpl();
}
securityProvider.setAuthenticationConfiguration(initializeConfiguration(authenticationConfiguration,
securityProvider, authenticationParams, rootProvider, treeProvider));
// privilege
if (privilegeConfiguration == null) {
privilegeConfiguration = new PrivilegeConfigurationImpl();
}
securityProvider.setPrivilegeConfiguration(initializeConfiguration(privilegeConfiguration, securityProvider,
privilegeParams, rootProvider, treeProvider));
// user
if (userConfiguration == null) {
userConfiguration = new UserConfigurationImpl();
}
securityProvider.setUserConfiguration(
initializeConfiguration(userConfiguration, securityProvider, userParams, rootProvider, treeProvider));
// authorization
if (authorizationConfiguration == null) {
CompositeAuthorizationConfiguration ac = new CompositeAuthorizationConfiguration();
ac.withCompositionType(configuration.getConfigValue("authorizationCompositionType", CompositeAuthorizationConfiguration.CompositionType.AND.toString()));
ac.setDefaultConfig(initializeConfiguration(new AuthorizationConfigurationImpl(),
securityProvider, rootProvider, treeProvider));
authorizationConfiguration = ac;
}
if (authorizationConfiguration instanceof CompositeAuthorizationConfiguration) {
initializeConfigurations((CompositeAuthorizationConfiguration) authorizationConfiguration, securityProvider, authorizationParams, rootProvider, treeProvider);
} else {
initializeConfiguration(authorizationConfiguration, securityProvider, authorizationParams, rootProvider, treeProvider);
}
securityProvider.setAuthorizationConfiguration(authorizationConfiguration);
// principal
if (principalConfiguration == null) {
CompositePrincipalConfiguration pc = new CompositePrincipalConfiguration();
pc.setDefaultConfig(initializeConfiguration(new PrincipalConfigurationImpl(), securityProvider, rootProvider, treeProvider));
principalConfiguration = pc;
}
if (principalConfiguration instanceof CompositePrincipalConfiguration) {
initializeConfigurations((CompositePrincipalConfiguration) principalConfiguration, securityProvider, principalParams, rootProvider, treeProvider);
} else {
initializeConfiguration(principalConfiguration, securityProvider, principalParams, rootProvider, treeProvider);
}
securityProvider.setPrincipalConfiguration(principalConfiguration);
// token
if (tokenConfiguration == null) {
CompositeTokenConfiguration tc = new CompositeTokenConfiguration();
tc.setDefaultConfig(initializeConfiguration(new TokenConfigurationImpl(), securityProvider, rootProvider, treeProvider));
tokenConfiguration = tc;
}
if (tokenConfiguration instanceof CompositeTokenConfiguration) {
initializeConfigurations((CompositeTokenConfiguration) tokenConfiguration, securityProvider, tokenParams, rootProvider, treeProvider);
} else {
initializeConfiguration(tokenConfiguration, securityProvider, tokenParams, rootProvider, treeProvider);
}
securityProvider.setTokenConfiguration(tokenConfiguration);
// whiteboard
if (whiteboard != null) {
securityProvider.setWhiteboard(whiteboard);
}
return securityProvider;
}
public SecurityProviderBuilder withWhiteboard(@NotNull Whiteboard whiteboard) {
this.whiteboard = whiteboard;
return this;
}
public SecurityProviderBuilder withRootProvider(@NotNull RootProvider rootProvider) {
this.rootProvider = rootProvider;
return this;
}
public SecurityProviderBuilder withTreeProvider(@NotNull TreeProvider treeProvider) {
this.treeProvider = treeProvider;
return this;
}
}
| {
"pile_set_name": "Github"
} |
#line 2 "bvh.cl"
/***************************************************************************
* Copyright 1998-2020 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxCoreRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#define BVHNodeData_IsLeaf(nodeData) ((nodeData) & 0x80000000u)
#define BVHNodeData_GetSkipIndex(nodeData) ((nodeData) & 0x7fffffffu)
#if (BVH_NODES_PAGE_COUNT > 1)
#define BVHNodeData_GetPageIndex(nodeData) (((nodeData) & 0x70000000u) >> 28)
#define BVHNodeData_GetNodeIndex(nodeData) ((nodeData) & 0x0fffffffu)
#endif
#if (BVH_NODES_PAGE_COUNT > 1)
void NextNode(uint *pageIndex, uint *nodeIndex) {
++(*nodeIndex);
if (*nodeIndex >= BVH_NODES_PAGE_SIZE) {
*nodeIndex = 0;
++(*pageIndex);
}
}
#endif
#define ACCELERATOR_INTERSECT_PARAM_DECL , __global const Point* restrict accelVertPage0, __global const Point* restrict accelVertPage1, __global const Point* restrict accelVertPage2, __global const Point* restrict accelVertPage3, __global const Point* restrict accelVertPage4, __global const Point* restrict accelVertPage5, __global const Point* restrict accelVertPage6, __global const Point* restrict accelVertPage7, __global const BVHArrayNode* restrict accelNodePage0, __global const BVHArrayNode* restrict accelNodePage1, __global const BVHArrayNode* restrict accelNodePage2, __global const BVHArrayNode* restrict accelNodePage3, __global const BVHArrayNode* restrict accelNodePage4, __global const BVHArrayNode* restrict accelNodePage5, __global const BVHArrayNode* restrict accelNodePage6, __global const BVHArrayNode* restrict accelNodePage7
#define ACCELERATOR_INTERSECT_PARAM , accelVertPage0, accelVertPage1, accelVertPage2, accelVertPage3, accelVertPage4, accelVertPage5, accelVertPage6, accelVertPage7, accelNodePage0, accelNodePage1, accelNodePage2, accelNodePage3, accelNodePage4, accelNodePage5, accelNodePage6, accelNodePage7
#if (BVH_NODES_PAGE_COUNT > 8)
ERROR: unsuported BVH_NODES_PAGE_COUNT !!!
#endif
void Accelerator_Intersect(
const Ray *ray,
RayHit *rayHit
ACCELERATOR_INTERSECT_PARAM_DECL
) {
#if (BVH_NODES_PAGE_COUNT == 0)
rayHit->t = ray->maxt;
rayHit->meshIndex = NULL_INDEX;
rayHit->triangleIndex = NULL_INDEX;
return;
#else
// Initialize vertex page references
#if (BVH_VERTS_PAGE_COUNT > 1)
__global const Point* restrict accelVertPages[BVH_VERTS_PAGE_COUNT];
#if defined(BVH_VERTS_PAGE0)
accelVertPages[0] = accelVertPage0;
#endif
#if defined(BVH_VERTS_PAGE1)
accelVertPages[1] = accelVertPage1;
#endif
#if defined(BVH_VERTS_PAGE2)
accelVertPages[2] = accelVertPage2;
#endif
#if defined(BVH_VERTS_PAGE3)
accelVertPages[3] = accelVertPage3;
#endif
#if defined(BVH_VERTS_PAGE4)
accelVertPages[4] = accelVertPage4;
#endif
#if defined(BVH_VERTS_PAGE5)
accelVertPages[5] = accelVertPage5;
#endif
#if defined(BVH_VERTS_PAGE6)
accelVertPages[6] = accelVertPage6;
#endif
#if defined(BVH_VERTS_PAGE7)
accelVertPages[7] = accelVertPage7;
#endif
#endif
// Initialize node page references
#if (BVH_NODES_PAGE_COUNT > 1)
__global const BVHArrayNode* restrict accelNodePages[BVH_NODES_PAGE_COUNT];
#if defined(BVH_NODES_PAGE0)
accelNodePages[0] = accelNodePage0;
#endif
#if defined(BVH_NODES_PAGE1)
accelNodePages[1] = accelNodePage1;
#endif
#if defined(BVH_NODES_PAGE2)
accelNodePages[2] = accelNodePage2;
#endif
#if defined(BVH_NODES_PAGE3)
accelNodePages[3] = accelNodePage3;
#endif
#if defined(BVH_NODES_PAGE4)
accelNodePages[4] = accelNodePage4;
#endif
#if defined(BVH_NODES_PAGE5)
accelNodePages[5] = accelNodePage5;
#endif
#if defined(BVH_NODES_PAGE6)
accelNodePages[6] = accelNodePage6;
#endif
#if defined(BVH_NODES_PAGE7)
accelNodePages[7] = accelNodePage7;
#endif
const uint rootNodeData = accelNodePage0[0].nodeData;
const uint stopPage = BVHNodeData_GetPageIndex(rootNodeData);
const uint stopNode = BVHNodeData_GetNodeIndex(rootNodeData); // Non-existent
uint currentPage = 0; // Root Node Page
#else
const uint stopNode = BVHNodeData_GetSkipIndex(accelNodePage0[0].nodeData); // Non-existent
#endif
const float3 rayOrig = MAKE_FLOAT3(ray->o.x, ray->o.y, ray->o.z);
const float3 rayDir = MAKE_FLOAT3(ray->d.x, ray->d.y, ray->d.z);
const float mint = ray->mint;
float maxt = ray->maxt;
const float3 invRayDir = 1.f / rayDir;
uint hitMeshIndex = NULL_INDEX;
uint hitTriangleIndex = NULL_INDEX;
uint currentNode = 0; // Root Node
float b1, b2;
#if (BVH_NODES_PAGE_COUNT == 1)
while (currentNode < stopNode) {
__global const BVHArrayNode* restrict node = &accelNodePage0[currentNode];
#else
while ((currentPage < stopPage) || (currentNode < stopNode)) {
__global const BVHArrayNode* restrict accelNodePage = accelNodePages[currentPage];
__global const BVHArrayNode* restrict node = &accelNodePage[currentNode];
#endif
// Read the node
__global float4* restrict data = (__global float4* restrict)node;
const float4 data0 = *data++;
const float4 data1 = *data;
//const uint nodeData = node->nodeData;
const uint nodeData = as_uint(data1.z);
if (BVHNodeData_IsLeaf(nodeData)) {
// It is a leaf, check the triangle
//const uint i0 = node->triangleLeaf.v[0];
//const uint i1 = node->triangleLeaf.v[1];
//const uint i2 = node->triangleLeaf.v[2];
const uint v0 = as_uint(data0.x);
const uint v1 = as_uint(data0.y);
const uint v2 = as_uint(data0.z);
#if (BVH_VERTS_PAGE_COUNT == 1)
// Fast path for when there is only one memory page
const float3 p0 = VLOAD3F(&accelVertPage0[v0].x);
const float3 p1 = VLOAD3F(&accelVertPage0[v1].x);
const float3 p2 = VLOAD3F(&accelVertPage0[v2].x);
#else
const uint pv0 = (v0 & 0xe0000000u) >> 29;
const uint iv0 = (v0 & 0x1fffffffu);
__global Point* restrict vp0 = accelVertPages[pv0];
const float3 p0 = VLOAD3F(&vp0[iv0].x);
const uint pv1 = (v1 & 0xe0000000u) >> 29;
const uint iv1 = (v1 & 0x1fffffffu);
__global Point* restrict vp1 = accelVertPages[pv1];
const float3 p1 = VLOAD3F(&vp1[iv1].x);
const uint pv2 = (v2 & 0xe0000000u) >> 29;
const uint iv2 = (v2 & 0x1fffffffu);
__global Point* restrict vp2 = accelVertPages[pv2];
const float3 p2 = VLOAD3F(&vp2[iv2].x);
#endif
//const uint triangleIndex = node->triangleLeaf.triangleIndex;
const uint meshIndex = as_uint(data0.w);
const uint triangleIndex = as_uint(data1.x);
Triangle_Intersect(rayOrig, rayDir, mint, &maxt, &hitMeshIndex, &hitTriangleIndex,
&b1, &b2, meshIndex, triangleIndex, p0, p1, p2);
#if (BVH_NODES_PAGE_COUNT == 1)
++currentNode;
#else
NextNode(¤tPage, ¤tNode);
#endif
} else {
// It is a node, check the bounding box
//const float3 pMin = VLOAD3F(&node->bvhNode.bboxMin[0]);
//const float3 pMax = VLOAD3F(&node->bvhNode.bboxMax[0]);
const float3 pMin = MAKE_FLOAT3(data0.x, data0.y, data0.z);
const float3 pMax = MAKE_FLOAT3(data0.w, data1.x, data1.y);
if (BBox_IntersectP(pMin, pMax, rayOrig, invRayDir, mint, maxt)) {
#if (BVH_NODES_PAGE_COUNT == 1)
++currentNode;
#else
NextNode(¤tPage, ¤tNode);
#endif
} else {
#if (BVH_NODES_PAGE_COUNT == 1)
// I don't need to use BVHNodeData_GetSkipIndex() here because
// I already know the flag (i.e. the last bit) is 0
currentNode = nodeData;
#else
currentPage = BVHNodeData_GetPageIndex(nodeData);
currentNode = BVHNodeData_GetNodeIndex(nodeData);
#endif
}
}
}
rayHit->t = maxt;
rayHit->b1 = b1;
rayHit->b2 = b2;
rayHit->meshIndex = hitMeshIndex;
rayHit->triangleIndex = hitTriangleIndex;
#endif
}
__kernel void Accelerator_Intersect_RayBuffer(
__global const Ray* restrict rays,
__global RayHit *rayHits,
const uint rayCount
ACCELERATOR_INTERSECT_PARAM_DECL
) {
// Select the ray to check
const int gid = get_global_id(0);
if (gid >= rayCount)
return;
Ray ray;
Ray_ReadAligned4_Private(&rays[gid], &ray);
// Check if I have to trace the ray
if (ray.flags & RAY_FLAGS_MASKED)
return;
RayHit rayHit;
Accelerator_Intersect(
&ray,
&rayHit
ACCELERATOR_INTERSECT_PARAM
);
// Write result
__global RayHit *memRayHit = &rayHits[gid];
memRayHit->t = rayHit.t;
memRayHit->b1 = rayHit.b1;
memRayHit->b2 = rayHit.b2;
memRayHit->meshIndex = rayHit.meshIndex;
memRayHit->triangleIndex = rayHit.triangleIndex;
}
| {
"pile_set_name": "Github"
} |
/*
* jPOS Project [http://jpos.org]
* Copyright (C) 2000-2020 jPOS Software SRL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.jpos.iso.packager;
import java.io.IOException;
import org.jpos.iso.ISOComponent;
import org.jpos.iso.ISOException;
import org.jpos.iso.ISOMsg;
import org.jpos.iso.ISOPackager;
import org.jpos.util.Log;
import java.io.InputStream;
public class FSDPackager extends Log implements ISOPackager {
public byte[] pack (ISOComponent m) throws ISOException {
return m.pack ();
}
public int unpack (ISOComponent m, byte[] b) throws ISOException {
return m.unpack (b);
}
public void unpack (ISOComponent m, InputStream in) throws ISOException {
try {
m.unpack (in);
} catch (IOException e) {
throw new ISOException (e);
}
}
public String getFieldDescription(ISOComponent m, int fldNumber) {
return null;
}
public ISOMsg createISOMsg() {
return new ISOMsg();
}
public String getDescription () {
return getClass().getName();
}
}
| {
"pile_set_name": "Github"
} |
require 'pty'
if ARGV.size == 0 then
ofile = "typescript"
else
ofile = ARGV[0]
end
logfile = File.open(ofile,"a")
system "stty -echo raw lnext ^_"
PTY.spawn("/bin/csh") do |r_pty,w_pty,pid|
Thread.new do
while true
w_pty.print STDIN.getc.chr
w_pty.flush
end
end
begin
while true
c = r_pty.sysread(512)
break if c.nil?
print c
STDOUT.flush
logfile.print c
end
rescue
# print $@,':',$!,"\n"
logfile.close
end
end
system "stty echo -raw lnext ^v"
| {
"pile_set_name": "Github"
} |
/*
* SubRip subtitle muxer
* Copyright (c) 2012 Nicolas George <nicolas.george@normalesup.org>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "internal.h"
#include "libavutil/log.h"
#include "libavutil/intreadwrite.h"
/* TODO: add options for:
- character encoding;
- LF / CRLF;
- byte order mark.
*/
typedef struct SRTContext{
unsigned index;
} SRTContext;
static int srt_write_header(AVFormatContext *avf)
{
SRTContext *srt = avf->priv_data;
if (avf->nb_streams != 1 ||
avf->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
av_log(avf, AV_LOG_ERROR,
"SRT supports only a single subtitles stream.\n");
return AVERROR(EINVAL);
}
if (avf->streams[0]->codecpar->codec_id != AV_CODEC_ID_TEXT &&
avf->streams[0]->codecpar->codec_id != AV_CODEC_ID_SUBRIP) {
av_log(avf, AV_LOG_ERROR,
"Unsupported subtitles codec: %s\n",
avcodec_get_name(avf->streams[0]->codecpar->codec_id));
return AVERROR(EINVAL);
}
avpriv_set_pts_info(avf->streams[0], 64, 1, 1000);
srt->index = 1;
return 0;
}
static int srt_write_packet(AVFormatContext *avf, AVPacket *pkt)
{
SRTContext *srt = avf->priv_data;
int64_t s = pkt->pts, e, d = pkt->duration;
int size, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
const uint8_t *p;
p = av_packet_get_side_data(pkt, AV_PKT_DATA_SUBTITLE_POSITION, &size);
if (p && size == 16) {
x1 = AV_RL32(p );
y1 = AV_RL32(p + 4);
x2 = AV_RL32(p + 8);
y2 = AV_RL32(p + 12);
}
#if FF_API_CONVERGENCE_DURATION
FF_DISABLE_DEPRECATION_WARNINGS
if (d <= 0)
/* For backward compatibility, fallback to convergence_duration. */
d = pkt->convergence_duration;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (s == AV_NOPTS_VALUE || d < 0) {
av_log(avf, AV_LOG_WARNING,
"Insufficient timestamps in event number %d.\n", srt->index);
return 0;
}
e = s + d;
avio_printf(avf->pb, "%d\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d",
srt->index,
(int)(s / 3600000), (int)(s / 60000) % 60,
(int)(s / 1000) % 60, (int)(s % 1000),
(int)(e / 3600000), (int)(e / 60000) % 60,
(int)(e / 1000) % 60, (int)(e % 1000));
if (p)
avio_printf(avf->pb, " X1:%03d X2:%03d Y1:%03d Y2:%03d",
x1, x2, y1, y2);
avio_printf(avf->pb, "\n");
avio_write(avf->pb, pkt->data, pkt->size);
avio_write(avf->pb, "\n\n", 2);
srt->index++;
return 0;
}
AVOutputFormat ff_srt_muxer = {
.name = "srt",
.long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"),
.mime_type = "application/x-subrip",
.extensions = "srt",
.priv_data_size = sizeof(SRTContext),
.write_header = srt_write_header,
.write_packet = srt_write_packet,
.flags = AVFMT_VARIABLE_FPS | AVFMT_TS_NONSTRICT,
.subtitle_codec = AV_CODEC_ID_SUBRIP,
};
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the Apache 2.0 License.
* See the accompanying LICENSE file for terms.
*/
package com.yahoo.squidb.processor;
import com.yahoo.aptutils.utils.AptUtils;
import com.yahoo.squidb.annotations.InheritedModelSpec;
import com.yahoo.squidb.annotations.TableModelSpec;
import com.yahoo.squidb.annotations.ViewModelSpec;
import com.yahoo.squidb.processor.plugins.PluginEnvironment;
import com.yahoo.squidb.processor.writers.InheritedModelFileWriter;
import com.yahoo.squidb.processor.writers.ModelFileWriter;
import com.yahoo.squidb.processor.writers.TableModelFileWriter;
import com.yahoo.squidb.processor.writers.ViewModelFileWriter;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind;
/**
* Annotation processor for generating boilerplate for subclasses of AbstractModel
* from simple template classes. Only processes classes annotated with one of the
* model spec annotations ({@link TableModelSpec}, {@link ViewModelSpec}, or {@link InheritedModelSpec})
*
* Example template class:
* <pre>
* @TableModelSpec(className="Person", tableName="people")
* public class PersonSpec {
* String firstName;
*
* String lastName;
*
* @ColumnSpec(name="creationDate")
* long birthday;
*
* @ColumnSpec(defaultValue="true")
* boolean isHappy;
* }
* </pre>
*/
public final class ModelSpecProcessor extends AbstractProcessor {
private Set<String> supportedAnnotationTypes = new HashSet<>();
private AptUtils utils;
private PluginEnvironment pluginEnv;
public ModelSpecProcessor() {
supportedAnnotationTypes.add(TableModelSpec.class.getName());
supportedAnnotationTypes.add(ViewModelSpec.class.getName());
supportedAnnotationTypes.add(InheritedModelSpec.class.getName());
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
@Override
public Set<String> getSupportedAnnotationTypes() {
return supportedAnnotationTypes;
}
@Override
public Set<String> getSupportedOptions() {
Set<String> supportedOptions = new HashSet<>();
supportedOptions.add(PluginEnvironment.PLUGINS_KEY);
supportedOptions.add(PluginEnvironment.OPTIONS_KEY);
supportedOptions.addAll(pluginEnv.getPluginSupportedOptions());
return Collections.unmodifiableSet(supportedOptions);
}
@Override
public synchronized void init(ProcessingEnvironment env) {
super.init(env);
utils = new AptUtils(env);
pluginEnv = new PluginEnvironment(utils, env.getOptions());
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
for (TypeElement annotationType : annotations) {
if (supportedAnnotationTypes.contains(annotationType.getQualifiedName().toString())) {
for (Element element : env.getElementsAnnotatedWith(annotationType)) {
if (element.getKind() == ElementKind.CLASS) {
TypeElement typeElement = (TypeElement) element;
try {
getFileWriter(typeElement).writeJava();
} catch (IOException e) {
utils.getMessager().printMessage(Kind.ERROR, "Unable to write model file", element);
}
} else {
utils.getMessager()
.printMessage(Kind.ERROR, "Unexpected element type " + element.getKind(), element);
}
}
} else {
utils.getMessager().printMessage(Kind.WARNING,
"Skipping unsupported annotation received by processor: " + annotationType);
}
}
return true;
}
private ModelFileWriter<?> getFileWriter(TypeElement typeElement) {
if (typeElement.getAnnotation(TableModelSpec.class) != null) {
return new TableModelFileWriter(typeElement, pluginEnv, utils);
} else if (typeElement.getAnnotation(ViewModelSpec.class) != null) {
return new ViewModelFileWriter(typeElement, pluginEnv, utils);
} else if (typeElement.getAnnotation(InheritedModelSpec.class) != null) {
return new InheritedModelFileWriter(typeElement, pluginEnv, utils);
} else {
throw new IllegalStateException("No model spec annotation found on type element " + typeElement);
}
}
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2018 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
* All Rights Reserved.
*/
package me.zhanghai.android.douya.item.content;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import java.util.List;
import me.zhanghai.android.douya.network.api.ApiError;
import me.zhanghai.android.douya.network.api.ApiRequest;
import me.zhanghai.android.douya.network.api.ApiService;
import me.zhanghai.android.douya.network.api.info.frodo.ReviewList;
import me.zhanghai.android.douya.network.api.info.frodo.SimpleReview;
import me.zhanghai.android.douya.review.content.BaseReviewListResource;
import me.zhanghai.android.douya.util.FragmentUtils;
public class GameGuideListResource extends BaseReviewListResource {
private static final String KEY_PREFIX = GameGuideListResource.class.getName() + '.';
private static final String EXTRA_ITEM_ID = KEY_PREFIX + "item_id";
private long mItemId;
private static final String FRAGMENT_TAG_DEFAULT = GameGuideListResource.class.getName();
private static GameGuideListResource newInstance(long itemId) {
//noinspection deprecation
return new GameGuideListResource().setArguments(itemId);
}
public static GameGuideListResource attachTo(long itemId, Fragment fragment, String tag,
int requestCode) {
FragmentActivity activity = fragment.getActivity();
GameGuideListResource instance = FragmentUtils.findByTag(activity, tag);
if (instance == null) {
instance = newInstance(itemId);
FragmentUtils.add(instance, activity, tag);
}
instance.setTarget(fragment, requestCode);
return instance;
}
public static GameGuideListResource attachTo(long itemId, Fragment fragment) {
return attachTo(itemId, fragment, FRAGMENT_TAG_DEFAULT, REQUEST_CODE_INVALID);
}
/**
* @deprecated Use {@code attachTo()} instead.
*/
public GameGuideListResource() {}
protected GameGuideListResource setArguments(long itemId) {
FragmentUtils.getArgumentsBuilder(this)
.putLong(EXTRA_ITEM_ID, itemId);
return this;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mItemId = getArguments().getLong(EXTRA_ITEM_ID);
}
@Override
protected ApiRequest<ReviewList> onCreateRequest(Integer start, Integer count) {
return ApiService.getInstance().getGameGuideList(mItemId, start, count);
}
@Override
protected BaseReviewListResource.Listener getListener() {
return new ListenerWrapper((Listener) getTarget());
}
public interface Listener {
void onLoadGameGuideListStarted(int requestCode);
void onLoadGameGuideListFinished(int requestCode);
void onLoadGameGuideListError(int requestCode, ApiError error);
/**
* @param newGameGuideList Unmodifiable.
*/
void onGameGuideListChanged(int requestCode, List<SimpleReview> newGameGuideList);
/**
* @param appendedGameGuideList Unmodifiable.
*/
void onGameGuideListAppended(int requestCode, List<SimpleReview> appendedGameGuideList);
void onGameGuideChanged(int requestCode, int position, SimpleReview newGameGuide);
void onGameGuideRemoved(int requestCode, int position);
}
private static class ListenerWrapper implements BaseReviewListResource.Listener {
private Listener mListener;
public ListenerWrapper(Listener listener) {
mListener = listener;
}
@Override
public void onLoadReviewListStarted(int requestCode) {
mListener.onLoadGameGuideListStarted(requestCode);
}
@Override
public void onLoadReviewListFinished(int requestCode) {
mListener.onLoadGameGuideListFinished(requestCode);
}
@Override
public void onLoadReviewListError(int requestCode, ApiError error) {
mListener.onLoadGameGuideListError(requestCode, error);
}
@Override
public void onReviewListChanged(int requestCode, List<SimpleReview> newReviewList) {
mListener.onGameGuideListChanged(requestCode, newReviewList);
}
@Override
public void onReviewListAppended(int requestCode, List<SimpleReview> appendedReviewList) {
mListener.onGameGuideListAppended(requestCode, appendedReviewList);
}
@Override
public void onReviewChanged(int requestCode, int position, SimpleReview newReview) {
mListener.onGameGuideChanged(requestCode, position, newReview);
}
@Override
public void onReviewRemoved(int requestCode, int position) {
mListener.onGameGuideRemoved(requestCode, position);
}
}
}
| {
"pile_set_name": "Github"
} |
<!--
File isoamso.ent produced by the XSL script entities.xsl
from input data in unicode.xml.
Please report any errors to David Carlisle
via the public W3C list www-math@w3.org.
The numeric character values assigned to each entity
(should) match the Unicode assignments in Unicode 4.0.
Entity names in this file are derived from files carrying the
following notice:
(C) International Organization for Standardization 1986
Permission to copy in any form is granted for use with
conforming SGML systems and applications as defined in
ISO 8879, provided this notice is included in all copies.
-->
<!--
Version: $Id: isoamso.ent,v 1.2 2003/12/08 15:14:43 davidc Exp $
Public identifier: ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN//XML
System identifier: http://www.w3.org/2003/entities/iso8879/isoamso.ent
The public identifier should always be used verbatim.
The system identifier may be changed to suit local requirements.
Typical invocation:
<!ENTITY % isoamso PUBLIC
"ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN//XML"
"http://www.w3.org/2003/entities/iso8879/isoamso.ent"
>
%isoamso;
-->
<!ENTITY ang "∠" ><!--ANGLE -->
<!ENTITY angmsd "∡" ><!--MEASURED ANGLE -->
<!ENTITY beth "ℶ" ><!--BET SYMBOL -->
<!ENTITY bprime "‵" ><!--REVERSED PRIME -->
<!ENTITY comp "∁" ><!--COMPLEMENT -->
<!ENTITY daleth "ℸ" ><!--DALET SYMBOL -->
<!ENTITY ell "ℓ" ><!--SCRIPT SMALL L -->
<!ENTITY empty "∅" ><!--EMPTY SET -->
<!ENTITY gimel "ℷ" ><!--GIMEL SYMBOL -->
<!ENTITY inodot "ı" ><!--LATIN SMALL LETTER DOTLESS I -->
<!ENTITY jnodot "j" ><!--LATIN SMALL LETTER J -->
<!ENTITY nexist "∄" ><!--THERE DOES NOT EXIST -->
<!ENTITY oS "Ⓢ" ><!--CIRCLED LATIN CAPITAL LETTER S -->
<!ENTITY planck "ℏ" ><!--PLANCK CONSTANT OVER TWO PI -->
<!ENTITY real "ℜ" ><!--BLACK-LETTER CAPITAL R -->
<!ENTITY sbsol "﹨" ><!--SMALL REVERSE SOLIDUS -->
<!ENTITY vprime "′" ><!--PRIME -->
<!ENTITY weierp "℘" ><!--SCRIPT CAPITAL P -->
| {
"pile_set_name": "Github"
} |
/*
* Public Key abstraction layer: wrapper functions
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#if defined(MBEDTLS_PK_C)
#include "mbedtls/pk_internal.h"
/* Even if RSA not activated, for the sake of RSA-alt */
#include "mbedtls/rsa.h"
#include <string.h>
#if defined(MBEDTLS_ECP_C)
#include "mbedtls/ecp.h"
#endif
#if defined(MBEDTLS_ECDSA_C)
#include "mbedtls/ecdsa.h"
#endif
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
#include "mbedtls/platform_util.h"
#endif
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdlib.h>
#define mbedtls_calloc calloc
#define mbedtls_free free
#endif
#include <limits.h>
#include <stdint.h>
#if defined(MBEDTLS_RSA_C)
static int rsa_can_do( mbedtls_pk_type_t type )
{
return( type == MBEDTLS_PK_RSA ||
type == MBEDTLS_PK_RSASSA_PSS );
}
static size_t rsa_get_bitlen( const void *ctx )
{
const mbedtls_rsa_context * rsa = (const mbedtls_rsa_context *) ctx;
return( 8 * mbedtls_rsa_get_len( rsa ) );
}
static int rsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len )
{
int ret;
mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
size_t rsa_len = mbedtls_rsa_get_len( rsa );
#if SIZE_MAX > UINT_MAX
if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len )
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
#endif /* SIZE_MAX > UINT_MAX */
if( sig_len < rsa_len )
return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
if( ( ret = mbedtls_rsa_pkcs1_verify( rsa, NULL, NULL,
MBEDTLS_RSA_PUBLIC, md_alg,
(unsigned int) hash_len, hash, sig ) ) != 0 )
return( ret );
/* The buffer contains a valid signature followed by extra data.
* We have a special error code for that so that so that callers can
* use mbedtls_pk_verify() to check "Does the buffer start with a
* valid signature?" and not just "Does the buffer contain a valid
* signature?". */
if( sig_len > rsa_len )
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
return( 0 );
}
static int rsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
#if SIZE_MAX > UINT_MAX
if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len )
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
#endif /* SIZE_MAX > UINT_MAX */
*sig_len = mbedtls_rsa_get_len( rsa );
return( mbedtls_rsa_pkcs1_sign( rsa, f_rng, p_rng, MBEDTLS_RSA_PRIVATE,
md_alg, (unsigned int) hash_len, hash, sig ) );
}
static int rsa_decrypt_wrap( void *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
if( ilen != mbedtls_rsa_get_len( rsa ) )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
return( mbedtls_rsa_pkcs1_decrypt( rsa, f_rng, p_rng,
MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) );
}
static int rsa_encrypt_wrap( void *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
*olen = mbedtls_rsa_get_len( rsa );
if( *olen > osize )
return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE );
return( mbedtls_rsa_pkcs1_encrypt( rsa, f_rng, p_rng, MBEDTLS_RSA_PUBLIC,
ilen, input, output ) );
}
static int rsa_check_pair_wrap( const void *pub, const void *prv )
{
return( mbedtls_rsa_check_pub_priv( (const mbedtls_rsa_context *) pub,
(const mbedtls_rsa_context *) prv ) );
}
static void *rsa_alloc_wrap( void )
{
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_context ) );
if( ctx != NULL )
mbedtls_rsa_init( (mbedtls_rsa_context *) ctx, 0, 0 );
return( ctx );
}
static void rsa_free_wrap( void *ctx )
{
mbedtls_rsa_free( (mbedtls_rsa_context *) ctx );
mbedtls_free( ctx );
}
static void rsa_debug( const void *ctx, mbedtls_pk_debug_item *items )
{
items->type = MBEDTLS_PK_DEBUG_MPI;
items->name = "rsa.N";
items->value = &( ((mbedtls_rsa_context *) ctx)->N );
items++;
items->type = MBEDTLS_PK_DEBUG_MPI;
items->name = "rsa.E";
items->value = &( ((mbedtls_rsa_context *) ctx)->E );
}
const mbedtls_pk_info_t mbedtls_rsa_info = {
MBEDTLS_PK_RSA,
"RSA",
rsa_get_bitlen,
rsa_can_do,
rsa_verify_wrap,
rsa_sign_wrap,
rsa_decrypt_wrap,
rsa_encrypt_wrap,
rsa_check_pair_wrap,
rsa_alloc_wrap,
rsa_free_wrap,
rsa_debug,
};
#endif /* MBEDTLS_RSA_C */
#if defined(MBEDTLS_ECP_C)
/*
* Generic EC key
*/
static int eckey_can_do( mbedtls_pk_type_t type )
{
return( type == MBEDTLS_PK_ECKEY ||
type == MBEDTLS_PK_ECKEY_DH ||
type == MBEDTLS_PK_ECDSA );
}
static size_t eckey_get_bitlen( const void *ctx )
{
return( ((mbedtls_ecp_keypair *) ctx)->grp.pbits );
}
#if defined(MBEDTLS_ECDSA_C)
/* Forward declarations */
static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len );
static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
static int eckey_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len )
{
int ret;
mbedtls_ecdsa_context ecdsa;
mbedtls_ecdsa_init( &ecdsa );
if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 )
ret = ecdsa_verify_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len );
mbedtls_ecdsa_free( &ecdsa );
return( ret );
}
static int eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
int ret;
mbedtls_ecdsa_context ecdsa;
mbedtls_ecdsa_init( &ecdsa );
if( ( ret = mbedtls_ecdsa_from_keypair( &ecdsa, ctx ) ) == 0 )
ret = ecdsa_sign_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len,
f_rng, p_rng );
mbedtls_ecdsa_free( &ecdsa );
return( ret );
}
#endif /* MBEDTLS_ECDSA_C */
static int eckey_check_pair( const void *pub, const void *prv )
{
return( mbedtls_ecp_check_pub_priv( (const mbedtls_ecp_keypair *) pub,
(const mbedtls_ecp_keypair *) prv ) );
}
static void *eckey_alloc_wrap( void )
{
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecp_keypair ) );
if( ctx != NULL )
mbedtls_ecp_keypair_init( ctx );
return( ctx );
}
static void eckey_free_wrap( void *ctx )
{
mbedtls_ecp_keypair_free( (mbedtls_ecp_keypair *) ctx );
mbedtls_free( ctx );
}
static void eckey_debug( const void *ctx, mbedtls_pk_debug_item *items )
{
items->type = MBEDTLS_PK_DEBUG_ECP;
items->name = "eckey.Q";
items->value = &( ((mbedtls_ecp_keypair *) ctx)->Q );
}
const mbedtls_pk_info_t mbedtls_eckey_info = {
MBEDTLS_PK_ECKEY,
"EC",
eckey_get_bitlen,
eckey_can_do,
#if defined(MBEDTLS_ECDSA_C)
eckey_verify_wrap,
eckey_sign_wrap,
#else
NULL,
NULL,
#endif
NULL,
NULL,
eckey_check_pair,
eckey_alloc_wrap,
eckey_free_wrap,
eckey_debug,
};
/*
* EC key restricted to ECDH
*/
static int eckeydh_can_do( mbedtls_pk_type_t type )
{
return( type == MBEDTLS_PK_ECKEY ||
type == MBEDTLS_PK_ECKEY_DH );
}
const mbedtls_pk_info_t mbedtls_eckeydh_info = {
MBEDTLS_PK_ECKEY_DH,
"EC_DH",
eckey_get_bitlen, /* Same underlying key structure */
eckeydh_can_do,
NULL,
NULL,
NULL,
NULL,
eckey_check_pair,
eckey_alloc_wrap, /* Same underlying key structure */
eckey_free_wrap, /* Same underlying key structure */
eckey_debug, /* Same underlying key structure */
};
#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_ECDSA_C)
static int ecdsa_can_do( mbedtls_pk_type_t type )
{
return( type == MBEDTLS_PK_ECDSA );
}
static int ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
const unsigned char *sig, size_t sig_len )
{
int ret;
((void) md_alg);
ret = mbedtls_ecdsa_read_signature( (mbedtls_ecdsa_context *) ctx,
hash, hash_len, sig, sig_len );
if( ret == MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH )
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
return( ret );
}
static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
return( mbedtls_ecdsa_write_signature( (mbedtls_ecdsa_context *) ctx,
md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng ) );
}
static void *ecdsa_alloc_wrap( void )
{
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) );
if( ctx != NULL )
mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx );
return( ctx );
}
static void ecdsa_free_wrap( void *ctx )
{
mbedtls_ecdsa_free( (mbedtls_ecdsa_context *) ctx );
mbedtls_free( ctx );
}
const mbedtls_pk_info_t mbedtls_ecdsa_info = {
MBEDTLS_PK_ECDSA,
"ECDSA",
eckey_get_bitlen, /* Compatible key structures */
ecdsa_can_do,
ecdsa_verify_wrap,
ecdsa_sign_wrap,
NULL,
NULL,
eckey_check_pair, /* Compatible key structures */
ecdsa_alloc_wrap,
ecdsa_free_wrap,
eckey_debug, /* Compatible key structures */
};
#endif /* MBEDTLS_ECDSA_C */
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
/*
* Support for alternative RSA-private implementations
*/
static int rsa_alt_can_do( mbedtls_pk_type_t type )
{
return( type == MBEDTLS_PK_RSA );
}
static size_t rsa_alt_get_bitlen( const void *ctx )
{
const mbedtls_rsa_alt_context *rsa_alt = (const mbedtls_rsa_alt_context *) ctx;
return( 8 * rsa_alt->key_len_func( rsa_alt->key ) );
}
static int rsa_alt_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hash_len,
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx;
#if SIZE_MAX > UINT_MAX
if( UINT_MAX < hash_len )
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
#endif /* SIZE_MAX > UINT_MAX */
*sig_len = rsa_alt->key_len_func( rsa_alt->key );
return( rsa_alt->sign_func( rsa_alt->key, f_rng, p_rng, MBEDTLS_RSA_PRIVATE,
md_alg, (unsigned int) hash_len, hash, sig ) );
}
static int rsa_alt_decrypt_wrap( void *ctx,
const unsigned char *input, size_t ilen,
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx;
((void) f_rng);
((void) p_rng);
if( ilen != rsa_alt->key_len_func( rsa_alt->key ) )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
return( rsa_alt->decrypt_func( rsa_alt->key,
MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) );
}
#if defined(MBEDTLS_RSA_C)
static int rsa_alt_check_pair( const void *pub, const void *prv )
{
unsigned char sig[MBEDTLS_MPI_MAX_SIZE];
unsigned char hash[32];
size_t sig_len = 0;
int ret;
if( rsa_alt_get_bitlen( prv ) != rsa_get_bitlen( pub ) )
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
memset( hash, 0x2a, sizeof( hash ) );
if( ( ret = rsa_alt_sign_wrap( (void *) prv, MBEDTLS_MD_NONE,
hash, sizeof( hash ),
sig, &sig_len, NULL, NULL ) ) != 0 )
{
return( ret );
}
if( rsa_verify_wrap( (void *) pub, MBEDTLS_MD_NONE,
hash, sizeof( hash ), sig, sig_len ) != 0 )
{
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
}
return( 0 );
}
#endif /* MBEDTLS_RSA_C */
static void *rsa_alt_alloc_wrap( void )
{
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_rsa_alt_context ) );
if( ctx != NULL )
memset( ctx, 0, sizeof( mbedtls_rsa_alt_context ) );
return( ctx );
}
static void rsa_alt_free_wrap( void *ctx )
{
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_rsa_alt_context ) );
mbedtls_free( ctx );
}
const mbedtls_pk_info_t mbedtls_rsa_alt_info = {
MBEDTLS_PK_RSA_ALT,
"RSA-alt",
rsa_alt_get_bitlen,
rsa_alt_can_do,
NULL,
rsa_alt_sign_wrap,
rsa_alt_decrypt_wrap,
NULL,
#if defined(MBEDTLS_RSA_C)
rsa_alt_check_pair,
#else
NULL,
#endif
rsa_alt_alloc_wrap,
rsa_alt_free_wrap,
NULL,
};
#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
#endif /* MBEDTLS_PK_C */
| {
"pile_set_name": "Github"
} |
--TEST--
Test for stack traces with variadics (text, 4)
--INI--
xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.trace_format=0
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.collect_vars=0
xdebug.collect_params=4
xdebug.collect_return=0
xdebug.collect_assignments=0
xdebug.force_error_reporting=0
--FILE--
<?php
function foo( $a, ...$b )
{
trigger_error( 'notice' );
}
foo( 42 );
foo( 1, false );
foo( "foo", "bar", 3.1415 );
?>
--EXPECTF--
Notice: notice in %sstacktrace_variadic_text_4.php on line 4
Call Stack:
%w%f %w%d 1. {main}() %sstacktrace_variadic_text_4.php:0
%w%f %w%d 2. foo($a = 42, ...$b = variadic()) %sstacktrace_variadic_text_4.php:7
%w%f %w%d 3. trigger_error('notice') %sstacktrace_variadic_text_4.php:4
Notice: notice in %sstacktrace_variadic_text_4.php on line 4
Call Stack:
%w%f %w%d 1. {main}() %sstacktrace_variadic_text_4.php:0
%w%f %w%d 2. foo($a = 1, ...$b = variadic(FALSE)) %sstacktrace_variadic_text_4.php:8
%w%f %w%d 3. trigger_error('notice') %sstacktrace_variadic_text_4.php:4
Notice: notice in %sstacktrace_variadic_text_4.php on line 4
Call Stack:
%w%f %w%d 1. {main}() %sstacktrace_variadic_text_4.php:0
%w%f %w%d 2. foo($a = 'foo', ...$b = variadic('bar', 3.1415)) %sstacktrace_variadic_text_4.php:9
%w%f %w%d 3. trigger_error('notice') %sstacktrace_variadic_text_4.php:4
| {
"pile_set_name": "Github"
} |
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageButton
android:layout_width="100dip"
android:layout_height="50dip"
android:src="@android:drawable/sym_action_call" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/sym_action_chat" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/sym_action_email" />
</LinearLayout>
| {
"pile_set_name": "Github"
} |
//===- VerifyDiagnosticConsumer.h - Verifying Diagnostic Client -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
#define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <limits>
#include <memory>
#include <string>
#include <vector>
namespace clang {
class FileEntry;
class LangOptions;
class SourceManager;
class TextDiagnosticBuffer;
/// VerifyDiagnosticConsumer - Create a diagnostic client which will use
/// markers in the input source to check that all the emitted diagnostics match
/// those expected.
///
/// USING THE DIAGNOSTIC CHECKER:
///
/// Indicating that a line expects an error or a warning is simple. Put a
/// comment on the line that has the diagnostic, use:
///
/// \code
/// expected-{error,warning,remark,note}
/// \endcode
///
/// to tag if it's an expected error, remark or warning, and place the expected
/// text between {{ and }} markers. The full text doesn't have to be included,
/// only enough to ensure that the correct diagnostic was emitted.
///
/// Here's an example:
///
/// \code
/// int A = B; // expected-error {{use of undeclared identifier 'B'}}
/// \endcode
///
/// You can place as many diagnostics on one line as you wish. To make the code
/// more readable, you can use slash-newline to separate out the diagnostics.
///
/// Alternatively, it is possible to specify the line on which the diagnostic
/// should appear by appending "@<line>" to "expected-<type>", for example:
///
/// \code
/// #warning some text
/// // expected-warning@10 {{some text}}
/// \endcode
///
/// The line number may be absolute (as above), or relative to the current
/// line by prefixing the number with either '+' or '-'.
///
/// If the diagnostic is generated in a separate file, for example in a shared
/// header file, it may be beneficial to be able to declare the file in which
/// the diagnostic will appear, rather than placing the expected-* directive in
/// the actual file itself. This can be done using the following syntax:
///
/// \code
/// // expected-error@path/include.h:15 {{error message}}
/// \endcode
///
/// The path can be absolute or relative and the same search paths will be used
/// as for #include directives. The line number in an external file may be
/// substituted with '*' meaning that any line number will match (useful where
/// the included file is, for example, a system header where the actual line
/// number may change and is not critical).
///
/// The simple syntax above allows each specification to match exactly one
/// error. You can use the extended syntax to customize this. The extended
/// syntax is "expected-<type> <n> {{diag text}}", where \<type> is one of
/// "error", "warning" or "note", and \<n> is a positive integer. This allows
/// the diagnostic to appear as many times as specified. Example:
///
/// \code
/// void f(); // expected-note 2 {{previous declaration is here}}
/// \endcode
///
/// Where the diagnostic is expected to occur a minimum number of times, this
/// can be specified by appending a '+' to the number. Example:
///
/// \code
/// void f(); // expected-note 0+ {{previous declaration is here}}
/// void g(); // expected-note 1+ {{previous declaration is here}}
/// \endcode
///
/// In the first example, the diagnostic becomes optional, i.e. it will be
/// swallowed if it occurs, but will not generate an error if it does not
/// occur. In the second example, the diagnostic must occur at least once.
/// As a short-hand, "one or more" can be specified simply by '+'. Example:
///
/// \code
/// void g(); // expected-note + {{previous declaration is here}}
/// \endcode
///
/// A range can also be specified by "<n>-<m>". Example:
///
/// \code
/// void f(); // expected-note 0-1 {{previous declaration is here}}
/// \endcode
///
/// In this example, the diagnostic may appear only once, if at all.
///
/// Regex matching mode may be selected by appending '-re' to type and
/// including regexes wrapped in double curly braces in the directive, such as:
///
/// \code
/// expected-error-re {{format specifies type 'wchar_t **' (aka '{{.+}}')}}
/// \endcode
///
/// Examples matching error: "variable has incomplete type 'struct s'"
///
/// \code
/// // expected-error {{variable has incomplete type 'struct s'}}
/// // expected-error {{variable has incomplete type}}
///
/// // expected-error-re {{variable has type 'struct {{.}}'}}
/// // expected-error-re {{variable has type 'struct {{.*}}'}}
/// // expected-error-re {{variable has type 'struct {{(.*)}}'}}
/// // expected-error-re {{variable has type 'struct{{[[:space:]](.*)}}'}}
/// \endcode
///
/// VerifyDiagnosticConsumer expects at least one expected-* directive to
/// be found inside the source code. If no diagnostics are expected the
/// following directive can be used to indicate this:
///
/// \code
/// // expected-no-diagnostics
/// \endcode
///
class VerifyDiagnosticConsumer: public DiagnosticConsumer,
public CommentHandler {
public:
/// Directive - Abstract class representing a parsed verify directive.
///
class Directive {
public:
static std::unique_ptr<Directive> create(bool RegexKind,
SourceLocation DirectiveLoc,
SourceLocation DiagnosticLoc,
bool MatchAnyLine, StringRef Text,
unsigned Min, unsigned Max);
public:
/// Constant representing n or more matches.
static const unsigned MaxCount = std::numeric_limits<unsigned>::max();
SourceLocation DirectiveLoc;
SourceLocation DiagnosticLoc;
const std::string Text;
unsigned Min, Max;
bool MatchAnyLine;
Directive(const Directive &) = delete;
Directive &operator=(const Directive &) = delete;
virtual ~Directive() = default;
// Returns true if directive text is valid.
// Otherwise returns false and populates E.
virtual bool isValid(std::string &Error) = 0;
// Returns true on match.
virtual bool match(StringRef S) = 0;
protected:
Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)
: DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc),
Text(Text), Min(Min), Max(Max), MatchAnyLine(MatchAnyLine) {
assert(!DirectiveLoc.isInvalid() && "DirectiveLoc is invalid!");
assert((!DiagnosticLoc.isInvalid() || MatchAnyLine) &&
"DiagnosticLoc is invalid!");
}
};
using DirectiveList = std::vector<std::unique_ptr<Directive>>;
/// ExpectedData - owns directive objects and deletes on destructor.
struct ExpectedData {
DirectiveList Errors;
DirectiveList Warnings;
DirectiveList Remarks;
DirectiveList Notes;
void Reset() {
Errors.clear();
Warnings.clear();
Remarks.clear();
Notes.clear();
}
};
enum DirectiveStatus {
HasNoDirectives,
HasNoDirectivesReported,
HasExpectedNoDiagnostics,
HasOtherExpectedDirectives
};
private:
DiagnosticsEngine &Diags;
DiagnosticConsumer *PrimaryClient;
std::unique_ptr<DiagnosticConsumer> PrimaryClientOwner;
std::unique_ptr<TextDiagnosticBuffer> Buffer;
const Preprocessor *CurrentPreprocessor = nullptr;
const LangOptions *LangOpts = nullptr;
SourceManager *SrcManager = nullptr;
unsigned ActiveSourceFiles = 0;
DirectiveStatus Status;
ExpectedData ED;
void CheckDiagnostics();
void setSourceManager(SourceManager &SM) {
assert((!SrcManager || SrcManager == &SM) && "SourceManager changed!");
SrcManager = &SM;
}
// These facilities are used for validation in debug builds.
class UnparsedFileStatus {
llvm::PointerIntPair<const FileEntry *, 1, bool> Data;
public:
UnparsedFileStatus(const FileEntry *File, bool FoundDirectives)
: Data(File, FoundDirectives) {}
const FileEntry *getFile() const { return Data.getPointer(); }
bool foundDirectives() const { return Data.getInt(); }
};
using ParsedFilesMap = llvm::DenseMap<FileID, const FileEntry *>;
using UnparsedFilesMap = llvm::DenseMap<FileID, UnparsedFileStatus>;
ParsedFilesMap ParsedFiles;
UnparsedFilesMap UnparsedFiles;
public:
/// Create a new verifying diagnostic client, which will issue errors to
/// the currently-attached diagnostic client when a diagnostic does not match
/// what is expected (as indicated in the source file).
VerifyDiagnosticConsumer(DiagnosticsEngine &Diags);
~VerifyDiagnosticConsumer() override;
void BeginSourceFile(const LangOptions &LangOpts,
const Preprocessor *PP) override;
void EndSourceFile() override;
enum ParsedStatus {
/// File has been processed via HandleComment.
IsParsed,
/// File has diagnostics and may have directives.
IsUnparsed,
/// File has diagnostics but guaranteed no directives.
IsUnparsedNoDirectives
};
/// Update lists of parsed and unparsed files.
void UpdateParsedFileStatus(SourceManager &SM, FileID FID, ParsedStatus PS);
bool HandleComment(Preprocessor &PP, SourceRange Comment) override;
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info) override;
};
} // namespace clang
#endif // LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
| {
"pile_set_name": "Github"
} |
#include "falclib.h"
#include "chandler.h"
#include "userids.h"
#include "PlayerOp.h"
#include <mmsystem.h>
#include "sim/include/stdhdr.h"
#include "sim/include/simio.h"
#include "Graphics/Include/render3d.h"
#include "Graphics/Include/renderow.h"
#include "Graphics/Include/drawBSP.h"
#include "Graphics/Include/matrix.h"
#include "Graphics/Include/loader.h"
#include "objectiv.h"
#include "cbsplist.h"
#include "c3dview.h"
#include "ui_setup.h"
#include "Graphics/Include/RViewPnt.h"
#include "dispcfg.h"
#include "f4find.h"
#include "Graphics/Include/draw2d.h"
#include "Graphics/Include/devmgr.h"
#include "dispopts.h"
#include "sim/include/sinput.h"
#include "classtbl.h"
#include "Campaign/include/Cmpclass.h"
#include "TimeMgr.h"
//JAM 18Nov03
#include "Weather.h"
#pragma warning(disable : 4706) // assignment within conditional expression
extern C_Handler *gMainHandler;
extern int GraphicSettingMult;
extern int HighResolutionHackFlag; // Used in WinMain.CPP
// M.N.
//extern int skycolortime;
//extern SkyColorDataType* skycolor;
extern int MainLastGroup;
extern bool g_bAlwaysAnisotropic; // to always turn on Anisotropic label (workaround for the GF 3)
extern bool g_bForceDXMultiThreadedCoopLevel;
extern bool g_bEnableNonPersistentTextures;
extern bool g_bEnableStaticTerrainTextures;
extern bool g_bCheckBltStatusBeforeFlip;
//extern bool g_bForceSoftwareGUI; // not switchable inside the game
extern bool g_bVoodoo12Compatible;
#ifdef _DEBUG
bool g_bEnumSoftwareDevices = true;
#else
bool g_bEnumSoftwareDevices = false;
#endif
C_3dViewer *SetupViewer = NULL;
RViewPoint *tmpVpoint = NULL;
ObjectPos *Objects = NULL;
FeaturePos *Features = NULL;
short NumObjects = 0, NumFeatures = 0;
extern const Trotation IMatrix;
//defined in this file
void ChangeViewpointCB(long ID, short hittype, C_Base *control);
//defined in another file
void PositandOrientSetData(float x, float y, float z, float pitch, float roll, float yaw,
Tpoint* simView, Trotation* viewRotation);
void STPSetupControls(void);
const int SMOKE = 1000;
Drawable2D *Smoke = NULL;
////////////////
/////GraphicsTab
////////////////
void STPEnterCrit()
{
F4EnterCriticalSection(SetupCritSection);
}
void STPLeaveCrit()
{
F4LeaveCriticalSection(SetupCritSection);
}
void STPMoveRendererCB(C_Window *win)
{
if (SetupViewer)
SetupViewer->Viewport(win, 2);
}//MoveRendererCB
void STPViewTimerCB(long, short, C_Base *control)
{
control->SetReady(1);
if (control->GetFlags() bitand C_BIT_ABSOLUTE)
{
control->Parent_->RefreshWindow();
}
else
control->Parent_->RefreshClient(control->GetClient());
}//ViewTimerCB
void STPDisplayCB(long, short, C_Base *)
{
F4EnterCriticalSection(SetupCritSection);
if (SetupViewer)
SetupViewer->ViewOTW();
F4LeaveCriticalSection(SetupCritSection);
}//DisplayCB
void InitializeViewer(C_Window *win, RenderOTW *renderer)
{
C_Slider *slider;
C_Button *button;
slider = (C_Slider *)win->FindControl(OBJECT_DETAIL);
if (slider not_eq NULL)
{
renderer->SetObjectDetail((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 1.5f + 0.5f);
}
/* slider=(C_Slider *)win->FindControl(TEXTURE_DISTANCE);
if(slider not_eq NULL)
{
float sliderPos;
sliderPos = (float)slider->GetSliderPos()/(slider->GetSliderMax()-slider->GetSliderMin());
renderer->SetTerrainTextureLevel( (int)floor(sliderPos * 4.0f) );
}
*/
/* button=(C_Button *)win->FindControl(OBJECT_TEXTURES);
if(button not_eq NULL)
{
renderer->SetObjectTextureState( button->GetState() );
}
*/
//JAM 16Jan04
button = (C_Button *)win->FindControl(SETUP_SPECULAR_LIGHTING);
if (button not_eq NULL)
{
if (button->GetState() == C_STATE_1)
DisplayOptions.bSpecularLighting = true;
else
DisplayOptions.bSpecularLighting = false;
}
//JAM 07Dec03
button = (C_Button *)win->FindControl(SETUP_REALWEATHER_SHADOWS);
if (button not_eq NULL)
{
if (button->GetState() == C_STATE_1)
PlayerOptions.SetDispFlag(DISP_SHADOWS);
else
PlayerOptions.ClearDispFlag(DISP_SHADOWS);
}
/*
button=(C_Button *)win->FindControl(BILINEAR_FILTERING);
if(button not_eq NULL)
{
renderer->SetFilteringMode( button->GetState() );
}
*/
button = (C_Button *)win->FindControl(HAZING);
if (button not_eq NULL)
{
renderer->SetHazeMode(button->GetState());
}
/* button=(C_Button *)win->FindControl(GOUROUD);
if(button not_eq NULL)
{
renderer->SetSmoothShadingMode(button->GetState());
}
button=(C_Button *)win->FindControl(ALPHA_BLENDING);
if(button not_eq NULL)
{
renderer->SetAlphaMode( button->GetState() );
}*/
}
void InsertSmokeCloud()
{
FILE *fp;
char filename[MAX_PATH];
sprintf(filename, "%s\\config\\viewer.dat", FalconDataDirectory);
fp = fopen(filename, "rb");
if (fp)
{
ViewPos View;
Trotation rot = IMatrix;
Tpoint pos = {0.0f};
float scale = 100.0F;
RViewPoint *VP;
fread(&View, sizeof(ViewPos), 1, fp);
fclose(fp);
fp = NULL;
VP = SetupViewer->GetVP();
PositandOrientSetData(View.Xpos * FEET_PER_KM + 300, View.Ypos * FEET_PER_KM - 100,
View.CamZ + View.Zpos + 100, 0, 0, 0, &pos, &rot);
Smoke = new Drawable2D(DRAW2D_SMOKECLOUD1, scale, &pos);
VP->InsertObject(Smoke);
}
}
void LoadObjects(ViewPos &View , C_Window *win)
{
FILE *fp;
BSPLIST *list;
float Temp;
Trotation rot = IMatrix;
Tpoint pos = {0.0f};
char filename[MAX_PATH];
float scale = 1.0F;
C_Slider *slider;
sprintf(filename, "%s\\config\\viewer.dat", FalconDataDirectory);
fp = fopen(filename, "rb");
if (fp)
{
fread(&View, sizeof(ViewPos), 1, fp);
fread(&Temp, sizeof(float), 1, fp);
if (Objects)
delete [] Objects;
NumObjects = static_cast<short>(FloatToInt32(Temp));
Objects = new ObjectPos[NumObjects];
fread(Objects, sizeof(ObjectPos), NumObjects, fp);
fread(&Temp, sizeof(float), 1, fp);
if (Features)
delete [] Features;
NumFeatures = static_cast<short>(FloatToInt32(Temp));
Features = new FeaturePos[NumFeatures];
fread(Features, sizeof(FeaturePos), NumFeatures, fp);
fclose(fp);
fp = NULL;
slider = (C_Slider *)win->FindControl(VEHICLE_SIZE);
if (slider not_eq NULL)
{
scale = ((float)slider->GetSliderPos() / (float)(slider->GetSliderMax() - slider->GetSliderMin()) * 4.0F + 1.0F);
}
if (NumObjects)
{
for (int i = 0; i < NumObjects; i++)
{
PositandOrientSetData(View.Xpos * FEET_PER_KM + Objects[i].Xpos , View.Ypos * FEET_PER_KM + Objects[i].Ypos,
Objects[i].Zpos, Objects[i].Pitch, Objects[i].Roll, Objects[i].Yaw, &pos, &rot);
list = SetupViewer->LoadBSP(i, FloatToInt32(Objects[i].VisID), TRUE);
((DrawableBSP*)list->object)->Update(&pos, &rot);
if (Objects[i].VisID == MapVisId(VIS_F16C))
((DrawableBSP*)list->object)->SetSwitchMask(10, TRUE);
list->object->SetScale(scale);
}
}
if (NumFeatures)
{
for (int i = 0; i < NumFeatures; i++)
{
PositandOrientSetData(View.Xpos * FEET_PER_KM + Features[i].Xpos , View.Ypos * FEET_PER_KM + Features[i].Ypos,
Features[i].Zpos, 0.0f, 0.0f, Features[i].Facing, &pos, &rot);
list = SetupViewer->LoadBuilding(i + 100, FloatToInt32(Features[i].VisID), &pos, 0.0f);
((DrawableBSP*)list->object)->Update(&pos, &rot);
}
}
}
}
void STPRender(C_Base *control)
{
C_Text *text = NULL;
if (SetupViewer == NULL)
{
SetCursor(gCursors[CRSR_WAIT]);
RenderOTW *renderer = NULL;
RViewPoint *viewpt = NULL;
ViewPos View = {0.0f};
C_Slider *slider = NULL;
Tpoint pos = {0.0F};
int objdetail = 0;
F4EnterCriticalSection(SetupCritSection);
SetupViewer = new C_3dViewer;
SetupViewer->Setup();
SetupViewer->Viewport(control->Parent_, 2); // use client 2 for this window
short terrlvl = 0;
float terrdist = 40.0F;
slider = (C_Slider *)control->Parent_->FindControl(TERRAIN_DETAIL);
if (slider not_eq NULL)
{
int mid;
mid = (slider->GetSliderMax() - slider->GetSliderMin()) / 2;
if (slider->GetSliderPos() > mid)
{
terrdist = (40.0f + ((float)slider->GetSliderPos() - mid) / mid * 40.0f);
terrlvl = 0;
}
else
{
terrdist = 40.0f;
terrlvl = static_cast<short>(FloatToInt32(2 - ((float)slider->GetSliderPos() / mid * 2)));
}
}
SetupViewer->SetTextureLevels(terrlvl, 4);
SetupViewer->SetViewDistance(terrdist * FEET_PER_KM);
LoadObjects(View, control->Parent_);
SetupViewer->SetPosition(View.Xpos * FEET_PER_KM, View.Ypos * FEET_PER_KM, View.Zpos);
SetupViewer->SetCamera(View.CamX, View.CamY, View.CamZ, View.CamYaw, View.CamPitch, View.CamRoll);
SetupViewer->InitOTW(30.0f, FALSE);
viewpt = SetupViewer->GetVP();
viewpt->GetPos(&pos);
renderer = SetupViewer->GetRendOTW();
InitializeViewer((C_Window *)control->Parent_, renderer);
slider = (C_Slider *)control->Parent_->FindControl(DISAGG_LEVEL);
if (slider not_eq NULL)
{
objdetail = FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 5 + 0.5F);
}
if (NumObjects)
{
for (int i = 0; i < NumObjects; i++)
{
SetupViewer->AddToView(i);
}
}
if (NumFeatures)
{
for (int i = 0; i < NumFeatures; i++)
{
if (Features[i].Priority <= objdetail)
SetupViewer->AddToView(i + 100);
}
}
InsertSmokeCloud();
TheLoader.WaitForLoader();
F4LeaveCriticalSection(SetupCritSection);
text = (C_Text *)control->Parent_->FindControl(LOADING);
if (text)
{
text->SetFlagBitOn(C_BIT_INVISIBLE);
text->Refresh();
}
if ( not tmpVpoint)
{
tmpVpoint = new RViewPoint;
tmpVpoint->Setup(80.0f * FEET_PER_KM, 0, 4, DisplayOptions.bZBuffering);
tmpVpoint->Update(&pos);
}
SetCursor(gCursors[CRSR_F16]);
control->Parent_->RefreshClient(2);
ready = TRUE;
}
}//STPRender
void RenderViewCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
C_Text *text;
if (((C_Button *)control)->GetState())
{
text = (C_Text *)control->Parent_->FindControl(LOADING);
if (text)
{
text->SetFlagBitOff(C_BIT_INVISIBLE);
text->Refresh();
}
//Sleep(100);
//STPRender(control);
PostMessage(gMainHandler->GetAppWnd(), FM_STP_START_RENDER, 0, (LPARAM)control);
}
else
{
if (SetupViewer)
{
if ( not ready)
{
((C_Button *)control)->SetState(C_STATE_1);
((C_Button *)control)->Refresh();
return;
}
ready = FALSE;
F4EnterCriticalSection(SetupCritSection);
RViewPoint *viewpt;
viewpt = SetupViewer->GetVP();
viewpt->RemoveObject(Smoke);
delete Smoke;
Smoke = NULL;
SetupViewer->Cleanup();
delete SetupViewer;
SetupViewer = NULL;
F4LeaveCriticalSection(SetupCritSection);
//control->Parent_->RefreshClient(2);
control->Parent_->RefreshWindow();
}
}
}
void ChangeViewpointCB(long, short, C_Base *)
{
static int count = 0;
C_Window *win;
if (ready)
{
// Update the Joystick control
GetJoystickInput();
if (IO.digital[0] or ((count %= 3) == 0))
{
win = gMainHandler->FindWindow(SETUP_WIN);
if (win not_eq NULL)
{
//Leave=UI_Enter(control->Parent_);
F4EnterCriticalSection(SetupCritSection);
if (SetupViewer == NULL)
{
F4LeaveCriticalSection(SetupCritSection);
//UI_Leave(Leave);
return;
}
float pitchChg = 0.0f, yawChg = 0.0f;
float altChg = 0.0f;
float newPitch = 0.0f, newYaw = 0.0f, newAlt;
//gMainHandler->EnterCriticalSection();
// Retro 31Dec2003
extern AxisMapping AxisMap;
if (AxisMap.FlightControlDevice not_eq -1)
if (IO.digital[(AxisMap.FlightControlDevice - SIM_JOYSTICK1)*SIMLIB_MAX_DIGITAL])
{
pitchChg = IO.analog[AXIS_PITCH].engrValue * PITCH_CHG;
yawChg = IO.analog[AXIS_ROLL].engrValue * YAW_CHG;
altChg = 1.0f - IO.analog[AXIS_THROTTLE].engrValue;
if (IO.digital[((AxisMap.FlightControlDevice - SIM_JOYSTICK1)*SIMLIB_MAX_DIGITAL) + 1])
{
altChg = altChg * altChg * ALT_CHG;
}
else
{
altChg = altChg * altChg * ALT_CHG * -1;
}
}
if (fabs(pitchChg) < 0.5)
pitchChg = 0.0f;
newPitch = SetupViewer->GetCameraPitch() + pitchChg;
if (newPitch > 90.0f)
newPitch = 90.0f;
else if (newPitch < -90.0f)
newPitch = -90.0f;
if (fabs(yawChg) < 0.5)
yawChg = 0.0f;
newYaw = SetupViewer->GetCameraHeading() + yawChg;
if (fabs(altChg) < .5f)
altChg = 0.0f;
newAlt = altChg + SetupViewer->GetCameraZ();
if (newAlt > MIN_ALT)
newAlt = MIN_ALT;
else if (newAlt < MAX_ALT)
newAlt = MAX_ALT;
SetupViewer->SetCamera(SetupViewer->GetCameraX(), SetupViewer->GetCameraY(),
newAlt, newYaw, newPitch, 0.0f);
//win->RefreshClient(2);
F4LeaveCriticalSection(SetupCritSection);
//UI_Leave(Leave);
win->RefreshWindow();
}
}
count++;
}
}//ChangeViewpointCB
void ScalingCB(long, short hittype, C_Base *)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
}
void GouraudCB(long, short hittype, C_Base *control)
{
/* if(hittype not_eq C_TYPE_LMOUSEUP)
return;
if(SetupViewer == NULL)
return;
RenderOTW *renderer;
renderer = SetupViewer->GetRendOTW();
if(((C_Button *)control)->GetState())
renderer->SetSmoothShadingMode( 1 );
else
renderer->SetSmoothShadingMode( 0 );
control->Parent_->RefreshClient(2);
control->Parent_->RefreshClient(2);
//have the rendered view update with new settings
*/
}//GouraudCB
void HazingCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
if (SetupViewer == NULL)
return;
RenderOTW *renderer;
renderer = SetupViewer->GetRendOTW();
if (((C_Button *)control)->GetState())
renderer->SetHazeMode(1);
else
renderer->SetHazeMode(0);
control->Parent_->RefreshClient(2);
//have the rendered view update with new settings
}//HazingCB
//JAM 07Dec03
void RealWeatherShadowsCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
if (SetupViewer == NULL)
return;
RenderOTW *renderer;
renderer = SetupViewer->GetRendOTW();
if (((C_Button *)control)->GetState())
PlayerOptions.SetDispFlag(DISP_SHADOWS);
else
PlayerOptions.ClearDispFlag(DISP_SHADOWS);
control->Parent_->RefreshClient(2);
}
void BilinearFilterCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
if (SetupViewer == NULL)
return;
RenderOTW *renderer;
renderer = SetupViewer->GetRendOTW();
if (((C_Button *)control)->GetState())
renderer->SetFilteringMode(TRUE);
else
renderer->SetFilteringMode(FALSE);
control->Parent_->RefreshClient(2);
//have the rendered view update with new settings
}//BilinearFilterCB
/*void ObjectTextureCB(long,short hittype,C_Base *control)
{
if(hittype not_eq C_TYPE_LMOUSEUP)
return;
if(SetupViewer == NULL)
return;
RenderOTW *renderer;
renderer = SetupViewer->GetRendOTW();
if(((C_Button *)control)->GetState())
renderer->SetObjectTextureState( TRUE );
else
renderer->SetObjectTextureState( FALSE );
control->Parent_->RefreshClient(2);
//have the rendered view update with new settings
}//ObjectTextureCB
*/
void RemoveObjFromView(int objID)
{
C_BSPList *bsplist;
BSPLIST *list;
F4EnterCriticalSection(SetupCritSection);
bsplist = SetupViewer->GetBSPList();
// I don't think this will happen, but time is short so lets be safe...
if ( not bsplist) return;
list = bsplist->Root_;
while (list)
{
if (list->ID == objID)
break;
list = list->Next;
}
if (list)
{
RViewPoint *tVP;
tVP = SetupViewer->GetVP();
tVP->RemoveObject(list->object);
}
F4LeaveCriticalSection(SetupCritSection);
}
void BuildingDetailCB(long, short hittype, C_Base *control)
{
C_Slider *slider;
int objdetail;
static int prevdetail = -1;
if (hittype not_eq C_TYPE_MOUSEMOVE)
return;
slider = (C_Slider *)control;
objdetail = FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 5 + 0.5F);
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if (ebox)
{
ebox->SetInteger(objdetail + 1);
ebox->Refresh();
}
F4EnterCriticalSection(SetupCritSection);
if (SetupViewer == NULL)
{
F4LeaveCriticalSection(SetupCritSection);
return;
}
if (NumFeatures)
{
if (prevdetail < objdetail)
{
if (NumFeatures)
{
for (int i = 0; i < NumFeatures; i++)
{
if ((Features[i].Priority <= objdetail) and (Features[i].Priority > prevdetail))
SetupViewer->AddToView(i + 100);
}
}
}
else if (prevdetail > objdetail)
{
for (int i = 0; i < NumFeatures; i++)
{
if ((Features[i].Priority > objdetail) and (Features[i].Priority <= prevdetail))
RemoveObjFromView(i + 100);
}
}
prevdetail = objdetail;
}
control->Parent_->RefreshWindow();
F4LeaveCriticalSection(SetupCritSection);
}//BuildingDetailCB
void PlayerBubbleCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_MOUSEMOVE)
return;
C_Slider *slider;
slider = (C_Slider *)control;
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if (ebox)
{
ebox->SetInteger(FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 6 * GraphicSettingMult + 1.5f));
ebox->Refresh();
}
}
void ObjectDetailCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_MOUSEMOVE)
return;
float detail;
C_Slider *slider;
slider = (C_Slider *)control;
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if (ebox)
{
ebox->SetInteger(FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 6 * GraphicSettingMult + 1.5f));
ebox->Refresh();
}
if (SetupViewer == NULL)
return;
RenderOTW *renderer;
renderer = SetupViewer->GetRendOTW();
detail = ((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 1.5f * GraphicSettingMult);
renderer->SetObjectDetail(detail);
//have the rendered view update with new settings
control->Parent_->RefreshWindow();
}//VehicleDetailCB
void VehicleSizeCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_MOUSEMOVE)
return;
C_Slider *slider;
BSPLIST *list;
int scale;
slider = (C_Slider *)control;
scale = FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 4 + 1);
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if (ebox)
{
ebox->SetInteger(scale);
ebox->Refresh();
}
if (SetupViewer == NULL)
return;
static int prevscale;
if (prevscale not_eq scale)
{
list = ((C_BSPList *)SetupViewer->GetBSPList())->Root_;
while (list)
{
if (list->ID < 100)
list->object->SetScale((float)scale);
list = list->Next;
}
prevscale = scale;
}
//have the rendered view update with new settings
control->Parent_->RefreshWindow();
}//VehicleSizeCB
void TerrainDetailCB(long, short hittype, C_Base *control)
{
C_Slider *slider;
static int prevpos = -1;
if (hittype not_eq C_TYPE_MOUSEMOVE)
return;
slider = (C_Slider *)control;
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if (ebox)
{
ebox->SetInteger(FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 6.0F * GraphicSettingMult + 1.5F));
ebox->Refresh();
}
if (SetupViewer == NULL)
return;
int step;
step = (slider->GetSliderMax() - slider->GetSliderMin()) / (6 * GraphicSettingMult);
if (abs(slider->GetSliderPos() - prevpos) > step - 1)
{
SetCursor(gCursors[CRSR_WAIT]);
int disagglvl;
short terrlvl;
float terrdist;
RenderOTW *renderer;
RViewPoint *viewpt;
C_BSPList *bsplist;
BSPLIST *cur;
Tpoint pos;
prevpos = slider->GetSliderPos();
if (slider->GetSliderPos() > 2 * step)
{
terrdist = 40.0f + ((float)slider->GetSliderPos() / step - 2) * 10.0f;
terrlvl = 0;
}
else
{
terrdist = 40.0f;
terrlvl = static_cast<short>(FloatToInt32(2.0F - ((float)slider->GetSliderPos() / step)));
}
F4EnterCriticalSection(SetupCritSection);
if (SetupViewer)
{
C_Slider *tslider;
C_Button *button;
renderer = SetupViewer->GetRendOTW();
viewpt = SetupViewer->GetVP();
viewpt->GetPos(&pos);
//SetupViewer->Cleanup();
bsplist = SetupViewer->GetBSPList();
cur = bsplist->GetFirst();
while (cur)
{
if (((DrawableBSP*)cur->object)->InDisplayList())
viewpt->RemoveObject(cur->object);
cur = cur->Next;
}
viewpt->RemoveObject(Smoke);
delete Smoke;
Smoke = NULL;
viewpt->Cleanup();
//viewpt = new RViewPoint;
viewpt->Setup(terrdist * FEET_PER_KM, terrlvl, 4, DisplayOptions.bZBuffering);
viewpt->Update(&pos);
renderer->Cleanup();
renderer->Setup(gMainHandler->GetFront(), viewpt);
//reset all values for new renderer
tslider = (C_Slider *)control->Parent_->FindControl(OBJECT_DETAIL);
if (tslider)
{
renderer->SetObjectDetail((float)tslider->GetSliderPos() / (tslider->GetSliderMax() - tslider->GetSliderMin()) * 1.5f + 0.5f);
}
/* tslider = (C_Slider *)control->Parent_->FindControl(TEXTURE_DISTANCE);
if(tslider)
{
renderer->SetTerrainTextureLevel(FloatToInt32((float)tslider->GetSliderPos()/(tslider->GetSliderMax()-tslider->GetSliderMin())* 4.0f));
}
button = (C_Button *)control->Parent_->FindControl(OBJECT_TEXTURES);
if(button)
{
if(button->GetState())
renderer->SetObjectTextureState( TRUE );
else
renderer->SetObjectTextureState( FALSE );
}
button = (C_Button *)control->Parent_->FindControl(BILINEAR_FILTERING);
if(button)
{
if(button->GetState())
renderer->SetFilteringMode( TRUE );
else
renderer->SetFilteringMode( FALSE );
}
*/
/* button = (C_Button *)control->Parent_->FindControl(ALPHA_BLENDING);
if(button)
{
if(button->GetState())
renderer->SetAlphaMode( TRUE );
else
renderer->SetAlphaMode( FALSE );
}
*/
button = (C_Button *)control->Parent_->FindControl(HAZING);
if (button)
{
if (button->GetState())
renderer->SetHazeMode(TRUE);
else
renderer->SetHazeMode(FALSE);
}
/* button = (C_Button *)control->Parent_->FindControl(GOUROUD);
if(button)
{
if(button->GetState())
renderer->SetSmoothShadingMode( TRUE );
else
renderer->SetSmoothShadingMode( FALSE );
}
*/
InitializeViewer((C_Window *)control->Parent_, renderer);
SetupViewer->Viewport((C_Window *)control->Parent_, 2);
slider = (C_Slider *)control->Parent_->FindControl(DISAGG_LEVEL);
if (slider not_eq NULL)
{
disagglvl = FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 5 + 0.5F);
if (NumFeatures)
{
for (int i = 0; i < NumFeatures; i++)
{
if (Features[i].Priority <= disagglvl)
SetupViewer->AddToView(i + 100);
}
}
}
if (NumObjects)
{
for (int i = 0; i < NumObjects; i++)
{
SetupViewer->AddToView(i);
}
}
InsertSmokeCloud();
SetCursor(gCursors[CRSR_F16]);
}
F4LeaveCriticalSection(SetupCritSection);
control->Parent_->RefreshWindow();
}
}
/*void TextureDistanceCB(long,short hittype,C_Base *control)
{
if(hittype not_eq C_TYPE_MOUSEMOVE)
return;
C_Slider *slider;
slider = (C_Slider *)control;
int pos;
pos = FloatToInt32((float)slider->GetSliderPos()/(slider->GetSliderMax()-slider->GetSliderMin()) * 4.0f);
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if(ebox)
{
ebox->SetInteger(pos + 1);
ebox->Refresh();
}
if(SetupViewer)
{
RenderOTW *renderer;
int TexLev;
renderer = SetupViewer->GetRendOTW();
TexLev = renderer->GetTerrainTextureLevel();
//have the rendered view update with new settings
if(pos not_eq TexLev)
{
renderer->SetTerrainTextureLevel(pos);
//control->Parent_->RefreshClient(2);
}
control->Parent_->RefreshWindow();
}
}//TextureDistanceCB
*/
void SfxLevelCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_MOUSEMOVE)
return;
C_Slider *slider;
slider = (C_Slider *)control;
int pos;
pos = FloatToInt32((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin()) * 4.0f);
C_EditBox *ebox;
ebox = (C_EditBox *)control->Parent_->FindControl(slider->GetUserNumber(0));
if (ebox)
{
ebox->SetInteger(pos + 1);
ebox->Refresh();
}
}//SfxLevelCB
void BuildVideoCardList(C_ListBox *lbox)
{
const char *buf;
int i = 0;
int Driver;
char buf2[256];
long value;
C_ListBox *VidCardList = (C_ListBox *)lbox->Parent_->FindControl(SET_VIDEO_DRIVER);
Driver = VidCardList->GetTextID() - 1;
DeviceManager::DDDriverInfo *pDI = FalconDisplay.devmgr.GetDriver(Driver);
if ( not pDI) return;
value = lbox->GetTextID();
lbox->RemoveAllItems();
while (buf = FalconDisplay.devmgr.GetDeviceName(Driver, i))
{
if ( not g_bEnumSoftwareDevices)
{
// check for software device
DeviceManager::DDDriverInfo::D3DDeviceInfo *pD3DDI = pDI->GetDevice(i);
if (pD3DDI and not pD3DDI->IsHardware())
{
i++;
continue;
}
}
strcpy(buf2, buf);
i++;
lbox->AddItem(i, C_TYPE_ITEM, buf2);
}
ShiAssert(i > 0);
lbox->SetValue(value);
lbox->Refresh();
}
void BuildVideoDriverList(C_ListBox *lbox)
{
char buf2[256];
const char *buf;
int i = 0;
lbox->RemoveAllItems();
while (buf = FalconDisplay.devmgr.GetDriverName(i))
{
if (FalconDisplay.devmgr.GetDeviceName(i, 0))
{
strcpy(buf2, buf);
lbox->AddItem(i + 1, C_TYPE_ITEM, buf2);
}
i++;
}
ShiAssert(i > 0);
lbox->Refresh();
}
void BuildResolutionList(C_ListBox *lbox)
{
int i = 0, Card, Driver;
char buf2[256];
long value;
UINT width, height, depth;
int isel = -1;
int nNumItems = 0;
C_ListBox *VidDriverList = (C_ListBox *)lbox->Parent_->FindControl(SET_VIDEO_DRIVER);
Driver = VidDriverList->GetTextID() - 1;
C_ListBox *VidCardList = (C_ListBox *)lbox->Parent_->FindControl(SET_VIDEO_CARD);
Card = VidCardList->GetTextID() - 1;
value = lbox->GetTextID();
lbox->RemoveAllItems();
DeviceManager::DDDriverInfo *pDI = FalconDisplay.devmgr.GetDriver(Driver);
if ( not pDI) return;
DeviceManager::DDDriverInfo::D3DDeviceInfo *pD3DDI = pDI->GetDevice(Card);
if ( not pD3DDI) return;
// OW
#if 1
while (FalconDisplay.devmgr.GetMode(Driver, Card, i++, &width, &height, &depth))
{
// For now we only allow 640x480, 800x600, 1280x960, 1600x1200
// (MPR already does the 4:3 aspect ratio check for us)
if (height > 400 and ((width == 640 or width == 800 or width == 1024 or
(width == 1280 and height == 960) or width == 1600 or HighResolutionHackFlag)))
{
if (depth == 8 or depth == 24)
continue;
// if(depth == 16 and not (pD3DDI->m_devDesc.dwDeviceRenderBitDepth bitand DDBD_16))
if (depth == 16)
continue;
else if (depth == 32 and not (pD3DDI->m_devDesc.dwDeviceRenderBitDepth bitand DDBD_32))
continue;
sprintf(buf2, "%0dx%0d - %d Bit", width, height, depth);
lbox->AddItem(i - 1, C_TYPE_ITEM, buf2);
// remember index for current mode
if (width == DisplayOptions.DispWidth and height == DisplayOptions.DispHeight and depth == DisplayOptions.DispDepth)
isel = i - 1;
nNumItems++;
}
}
ShiAssert(i > 0);
if (isel not_eq -1) lbox->SetValue(isel);
else lbox->SetValue(value);
lbox->Refresh();
#else
while (buf = FalconDisplay.devmgr.GetModeName(Driver, Card, i))
{
strcpy(buf2, buf);
i++;
sscanf(buf2, "%d x %d", &width, &height);
//sscanf(buf2,"%d",&width);
lbox->AddItem(width, C_TYPE_ITEM, buf2);
}
ShiAssert(i > 0);
lbox->SetValue(value);
lbox->Refresh();
#endif
}
void DisableEnableDrivers(C_ListBox *)
{
}
void DisableEnableResolutions(C_ListBox*)
{
}
void SetAdvanced()
{
C_Window *win;
C_Button *button;
C_ListBox *lbox;
win = gMainHandler->FindWindow(SETUP_WIN);
if (win == NULL) return;
lbox = (C_ListBox *)win->FindControl(SET_VIDEO_DRIVER);
if ( not lbox) return;
int nDriver = lbox->GetTextID() - 1;
lbox = (C_ListBox *)win->FindControl(SET_VIDEO_CARD);
if ( not lbox) return;
int nDevice = lbox->GetTextID() - 1;
DeviceManager::DDDriverInfo *pDI = FalconDisplay.devmgr.GetDriver(nDriver);
if ( not pDI) return;
DeviceManager::DDDriverInfo::D3DDeviceInfo *pD3DDI = pDI->GetDevice(nDevice);
if ( not pD3DDI) return;
win = gMainHandler->FindWindow(SETUP_ADVANCED_WIN);
if ( not win) return;
//========================================
// FRB - Force Z-Buffering
DisplayOptions.bZBuffering = TRUE;
// FRB - Force Specular Lighting
// DisplayOptions.bSpecularLighting = TRUE;
// DDS textures only
// DisplayOptions.m_texMode = TEX_MODE_DDS;
//========================================
//JAM 12Oct03
button = (C_Button *) win->FindControl(SETUP_ADVANCED_ANISOTROPIC_FILTERING);
if (button) button->SetState(DisplayOptions.bAnisotropicFiltering ? C_STATE_1 : C_STATE_0);
button = (C_Button *) win->FindControl(SETUP_ADVANCED_LINEAR_MIPMAP_FILTERING);
if (button) button->SetState(DisplayOptions.bLinearMipFiltering ? C_STATE_1 : C_STATE_0);
button = (C_Button *) win->FindControl(SETUP_ADVANCED_RENDER_2DCOCKPIT);
if (button) button->SetState(DisplayOptions.bRender2DCockpit ? C_STATE_1 : C_STATE_0);
button = (C_Button *) win->FindControl(SETUP_ADVANCED_SCREEN_COORD_BIAS_FIX);
if (button) button->SetState(DisplayOptions.bScreenCoordinateBiasFix ? C_STATE_1 : C_STATE_0); //Wombat778 4-01-04
button = (C_Button *) win->FindControl(SETUP_ADVANCED_MIPMAPPING);
if (button) button->SetState(DisplayOptions.bMipmapping ? C_STATE_1 : C_STATE_0);
button = (C_Button *) win->FindControl(SETUP_ADVANCED_RENDER_TO_TEXTURE);
if (button)
{
if (pDI->SupportsSRT()) button->SetFlagBitOn(C_BIT_ENABLED);
else
{
button->SetFlagBitOff(C_BIT_ENABLED);
DisplayOptions.bRender2Texture = false;
}
button->SetState(DisplayOptions.bRender2Texture ? C_STATE_1 : C_STATE_0);
}
// lbox = (C_ListBox *)win->FindControl(SETUP_ADVANCED_TEXTURE_MODE);
// if(lbox) lbox->SetValue(DisplayOptions.m_texMode);
//JAM
}
static void LoadBitmap(long ID, C_Button *btn, char filename[])
{
char file[MAX_PATH];
btn->ClearImage(0, ID);
gImageMgr->RemoveImage(ID);
strcpy(file, filename);
strcat(file, ".tga");
gImageMgr->LoadImage(ID, file, 0, 0);
btn->Refresh();
btn->SetImage(0, ID);
btn->Refresh();
}
//M.N.
/*void SetSkyColor()
{
C_Window *win;
C_Button *btn;
C_ListBox *lbox;
win=gMainHandler->FindWindow(SETUP_SKY_WIN);
if( not win) return;
lbox=(C_ListBox *)win->FindControl(SETUP_SKY_COLOR);
if (lbox)
{
lbox->SetValue(PlayerOptions.skycol);
lbox->Refresh();
}
btn=(C_Button*)win->FindControl(SKY_COLOR_PIC);
if(btn)
{
switch(skycolortime)
{
case 0:
LoadBitmap(SKYCOLOR_BITMAP_ID,btn,skycolor[PlayerOptions.skycol-1].image1);
break;
case 1:
LoadBitmap(SKYCOLOR_BITMAP_ID,btn,skycolor[PlayerOptions.skycol-1].image2);
break;
case 2:
LoadBitmap(SKYCOLOR_BITMAP_ID,btn,skycolor[PlayerOptions.skycol-1].image3);
break;
case 3:
LoadBitmap(SKYCOLOR_BITMAP_ID,btn,skycolor[PlayerOptions.skycol-1].image4);
break;
default:
MonoPrint("Not allowed skycolortime found ");
break;
}
}
win->RefreshWindow();
}
void SelectSkyColorCB(long ID,short hittype,C_Base *control)
{
C_ListBox *lbox=(C_ListBox*)control;
if(hittype not_eq C_TYPE_SELECT)
return;
ID=lbox->GetTextID();
PlayerOptions.skycol = lbox->GetTextID();
SetSkyColor();
}
void SkyColTimeCB(long ID,short hittype,C_Base *control)
{
if(hittype not_eq C_TYPE_LMOUSEUP)
return;
if( not control)
return;
switch(control->GetID())
{
case SKY_COLOR_TIME_1: // 7:00
skycolortime = 0;
break;
case SKY_COLOR_TIME_2: // 12:00
skycolortime = 1;
break;
case SKY_COLOR_TIME_3: // 19:00
skycolortime = 2;
break;
case SKY_COLOR_TIME_4: // 0:00
skycolortime = 3;
break;
default:
MonoPrint("Not allowed button type");
}
SetSkyColor();
}
*/
void VideoCardCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_SELECT)
return;
C_ListBox *lbox;
lbox = (C_ListBox *)control->Parent_->FindControl(SET_RESOLUTION);
if (lbox)
BuildResolutionList(lbox);
//DisableEnableDrivers //SET_VIDEO_DRIVER
//DisableEnableResolutions //SET_RESOLUTION
SetAdvanced();
}
void VideoDriverCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_SELECT)
return;
C_ListBox *lbox = (C_ListBox *)control->Parent_->FindControl(SET_VIDEO_CARD);
if (lbox)
BuildVideoCardList(lbox);
lbox = (C_ListBox *)control->Parent_->FindControl(SET_RESOLUTION);
if (lbox)
BuildResolutionList(lbox);
//DisableEnableResolutions //SET_RESOLUTION
// JB 011124 No relevance for the DX7 engine
/*
C_Button *button;
if( ((C_ListBox*)control)->GetTextID() > 1)
{
button=(C_Button *)control->Parent_->FindControl(ALPHA_BLENDING);
if(button not_eq NULL)
{
button->SetState(C_STATE_1);
button->Refresh();
}
button=(C_Button *)control->Parent_->FindControl(BILINEAR_FILTERING);
if(button not_eq NULL)
{
button->SetState(C_STATE_1);
button->Refresh();
}
}
else
{
button=(C_Button *)control->Parent_->FindControl(ALPHA_BLENDING);
if(button not_eq NULL)
{
button->SetState(C_STATE_0);
button->Refresh();
}
button=(C_Button *)control->Parent_->FindControl(BILINEAR_FILTERING);
if(button not_eq NULL)
{
button->SetState(C_STATE_0);
button->Refresh();
}
}
*/
}
void ResolutionCB(long, short hittype, C_Base *)
{
if (hittype not_eq C_TYPE_SELECT)
return;
}
//JAM 21Nov03
void RealWeatherCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_SELECT) return;
C_ListBox *lbox = (C_ListBox*)control;
if (TheCampaign.InMainUI or not ((WeatherClass *)realWeather)->lockedCondition)
{
PlayerOptions.weatherCondition = lbox->GetTextID() - 70207;
((WeatherClass *)realWeather)->UpdateCondition(PlayerOptions.weatherCondition, true);
((WeatherClass *)realWeather)->Init(true);
}
else if (((WeatherClass *)realWeather)->unlockableCondition == 0)
{
if (lbox->GetTextID() == 70213)
{
lbox->RemoveAllItems();
lbox->AddItem(70208, C_TYPE_ITEM, "Sunny");
lbox->AddItem(70209, C_TYPE_ITEM, "Fair");
lbox->AddItem(70210, C_TYPE_ITEM, "Poor");
lbox->AddItem(70211, C_TYPE_ITEM, "Inclement");
lbox->SetValue(realWeather->weatherCondition + 70207);
lbox->Refresh();
((WeatherClass *)realWeather)->lockedCondition = FALSE;
}
}
else if (lbox->GetTextID() == 70213)
{
lbox->RemoveAllItems();
lbox->AddItem(70208, C_TYPE_ITEM, "Sunny");
lbox->AddItem(70209, C_TYPE_ITEM, "Fair");
lbox->AddItem(70210, C_TYPE_ITEM, "Poor");
lbox->AddItem(70211, C_TYPE_ITEM, "Inclement");
lbox->SetValue(realWeather->weatherCondition + 70207);
lbox->Refresh();
((WeatherClass *)realWeather)->lockedCondition = FALSE;
}
}
//JAM
//THW 2004-01-17
void SeasonCB(long, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_SELECT) return;
C_ListBox *lbox = (C_ListBox*)control;
PlayerOptions.Season = lbox->GetTextID() - 70313;
//lbox->AddItem(70313,C_TYPE_ITEM,"Summer");
//lbox->AddItem(70314,C_TYPE_ITEM,"Fall");
//lbox->AddItem(70315,C_TYPE_ITEM,"Winter");
//lbox->AddItem(70316,C_TYPE_ITEM,"Spring");
//lbox->SetValue(PlayerOptions.Season+70313);
//lbox->Refresh();
}
//THW
void SetupGraphicsControls(void)
{
C_Window *win;
C_Button *button;
C_ListBox *lbox;
C_Slider *slider;
C_EditBox *ebox;
win = gMainHandler->FindWindow(SETUP_WIN);
if (win == NULL)
return;
lbox = (C_ListBox *)win->FindControl(SET_VIDEO_CARD);
if (lbox not_eq NULL)
{
BuildVideoCardList(lbox);
lbox->SetValue(DisplayOptions.DispVideoCard + 1);
lbox->Refresh();
}
lbox = (C_ListBox *)win->FindControl(SET_VIDEO_DRIVER);
if (lbox not_eq NULL)
{
BuildVideoDriverList(lbox);
DisableEnableDrivers(lbox);
lbox->SetValue(DisplayOptions.DispVideoDriver + 1);
lbox->Refresh();
}
lbox = (C_ListBox *)win->FindControl(SET_RESOLUTION);
if (lbox not_eq NULL)
{
DisableEnableResolutions(lbox);
lbox->SetValueText(DisplayOptions.DispWidth);
lbox->Refresh();
}
button = (C_Button *)win->FindControl(70136); //GOUROUD
if (button not_eq NULL)
{
if (PlayerOptions.GouraudOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
button = (C_Button *)win->FindControl(HAZING);
if (button not_eq NULL)
{
if (PlayerOptions.HazingOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
//JAM 16Jan04
button = (C_Button *)win->FindControl(SETUP_SPECULAR_LIGHTING);
if (button not_eq NULL)
{
if (DisplayOptions.bSpecularLighting)
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
//JAM 07Dec03
button = (C_Button *)win->FindControl(SETUP_REALWEATHER_SHADOWS);
if (button not_eq NULL)
{
if (PlayerOptions.ShadowsOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
/*
button=(C_Button *)win->FindControl(BILINEAR_FILTERING);
if(button not_eq NULL)
{
if(PlayerOptions.FilteringOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
*/
/* button=(C_Button *)win->FindControl(OBJECT_TEXTURES);
if(button not_eq NULL)
{
if(PlayerOptions.ObjectTexturesOn())
button->SetState(C_STATE_1);
else
button->SetState(C_STATE_0);
button->Refresh();
}
*/
slider = (C_Slider *)win->FindControl(OBJECT_DETAIL);
if (slider not_eq NULL)
{
slider->Refresh();
ebox = (C_EditBox *)win->FindControl(OBJECT_DETAIL_READOUT);
if (ebox)
{
ebox->SetInteger(FloatToInt32(PlayerOptions.ObjDetailLevel * 4.0F - 1.0F));
ebox->Refresh();
slider->SetUserNumber(0, OBJECT_DETAIL_READOUT);
}
slider->SetSliderPos(FloatToInt32((slider->GetSliderMax() - slider->GetSliderMin()) * (PlayerOptions.ObjDetailLevel - 0.5f) / 1.5f));
slider->Refresh();
}
slider = (C_Slider *)win->FindControl(DISAGG_LEVEL);
if (slider not_eq NULL)
{
slider->Refresh();
ebox = (C_EditBox *)win->FindControl(DISAGG_LEVEL_READOUT);
if (ebox)
{
// 2001-11-10 M.N. Added "+ 1" -> BldDeaggLevel = 0-5, display = 1-6
ebox->SetInteger(PlayerOptions.BldDeaggLevel + 1);
ebox->Refresh();
slider->SetUserNumber(0, DISAGG_LEVEL_READOUT);
}
slider->SetSliderPos((slider->GetSliderMax() - slider->GetSliderMin())*PlayerOptions.ObjDeaggLevel / 100);
slider->Refresh();
}
slider = (C_Slider *)win->FindControl(VEHICLE_SIZE);
if (slider not_eq NULL)
{
slider->Refresh();
slider->SetSliderPos(FloatToInt32((slider->GetSliderMax() - slider->GetSliderMin()) * (PlayerOptions.ObjMagnification - 1.0F) / 4.0F));
ebox = (C_EditBox *)win->FindControl(VEHICLE_SIZE_READOUT);
if (ebox)
{
ebox->SetInteger(FloatToInt32(PlayerOptions.ObjMagnification));
ebox->Refresh();
slider->SetUserNumber(0, VEHICLE_SIZE_READOUT);
}
slider->Refresh();
}
/* slider=(C_Slider *)win->FindControl(TEXTURE_DISTANCE);
if(slider not_eq NULL)
{
slider->Refresh();
ebox = (C_EditBox *)win->FindControl(TEX_DISTANCE_READOUT);
if(ebox)
{
ebox->SetInteger(PlayerOptions.DispTextureLevel + 1);
ebox->Refresh();
slider->SetUserNumber(0,TEX_DISTANCE_READOUT);
}
slider->SetSliderPos((slider->GetSliderMax()-slider->GetSliderMin())*(PlayerOptions.DispTextureLevel)/4);
slider->Refresh();
}
*/
slider = (C_Slider *)win->FindControl(TERRAIN_DETAIL);
if (slider not_eq NULL)
{
int step;
step = (slider->GetSliderMax() - slider->GetSliderMin()) / 6;
slider->Refresh();
if (PlayerOptions.DispTerrainDist > 40)
slider->SetSliderPos(FloatToInt32(step * (2 + (PlayerOptions.DispTerrainDist - 40.0F) / 10.0F)));
else
slider->SetSliderPos((2 - PlayerOptions.DispMaxTerrainLevel)*step);
slider->Refresh();
ebox = (C_EditBox *)win->FindControl(TEX_DETAIL_READOUT);
if (ebox)
{
ebox->SetInteger(FloatToInt32(((float)slider->GetSliderPos() / (slider->GetSliderMax() - slider->GetSliderMin())) * 6.0F + 1.5F));
ebox->Refresh();
slider->SetUserNumber(0, TEX_DETAIL_READOUT);
}
}
win = gMainHandler->FindWindow(SETUP_ADVANCED_WIN);
if ( not win) return;
// M.N. SkyColor stuff
// win = gMainHandler->FindWindow(SETUP_SKY_WIN);
// if (win) { // JPO conditional
// lbox = (C_ListBox *) win->FindControl(SETUP_SKY_COLOR);
// if (lbox) lbox->SetValue(PlayerOptions.skycol);
// }
// M.N. end SkyColor stuff
}
void GraphicsDefaultsCB(long, short hittype, C_Base *)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
PlayerOptionsClass Player;
DisplayOptionsClass Display;
//if(Display.LoadOptions("default"))
if (Display.LoadOptions("display")) // JB 011124 Why load the wrong file?
{
DisplayOptions.DispWidth = Display.DispWidth;
DisplayOptions.DispHeight = Display.DispHeight;
DisplayOptions.DispDepth = Display.DispDepth; // OW
DisplayOptions.DispVideoCard = Display.DispVideoCard;
DisplayOptions.DispVideoDriver = Display.DispVideoDriver;
DisplayOptions.DispDepth = 32; // Cobra - Always use 32-bit
}
else
{
DisplayOptions.DispWidth = 1024; // JB 011124
DisplayOptions.DispHeight = 768; // JB 011124
DisplayOptions.DispDepth = 32; // Cobra - Always use 32-bit
DisplayOptions.DispVideoCard = 0;
DisplayOptions.DispVideoDriver = 0;
}
if (Player.LoadOptions("default"))
{
/* PlayerOptions.DispFlags = DISP_HAZING|DISP_GOURAUD|DISP_SHADOWS;
// PlayerOptions.DispTextureLevel = 4;
//PlayerOptions.DispTerrainDist = 64.0;
PlayerOptions.DispTerrainDist = 80.0; // JB 011124
PlayerOptions.DispMaxTerrainLevel = 0;
PlayerOptions.ObjFlags = DISP_OBJ_TEXTURES;
//PlayerOptions.SfxLevel = 4.0F;
PlayerOptions.SfxLevel = 5.0F; // JB 011124
//PlayerOptions.ObjDetailLevel = 1;
PlayerOptions.ObjDetailLevel = 2; // JB 011124
PlayerOptions.ObjMagnification = 1;
PlayerOptions.ObjDeaggLevel = 100; // 2001-11-09 M.N. from 60
PlayerOptions.BldDeaggLevel = 5; // 2001-11-09 M.N. from 3, Realism Patch default
PlayerOptions.PlayerBubble = 1.0F;
DisplayOptions.bRender2Texture = false;
DisplayOptions.bAnisotropicFiltering = false;
DisplayOptions.bLinearMipFiltering = false;
DisplayOptions.bMipmapping = false;
DisplayOptions.bZBuffering = false;
DisplayOptions.bRender2DCockpit = false;
DisplayOptions.bFontTexelAlignment = false;
DisplayOptions.m_texMode = DisplayOptionsClass::TEX_MODE_DDS;*/
}
SetupGraphicsControls();
}
// OW
void AdvancedCB(long ID, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
C_Window *win;
win = gMainHandler->FindWindow(SETUP_ADVANCED_WIN);
if ( not win) return;
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
}
// JPO - select advanced features
void AdvancedGameCB(long ID, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
C_Window *win;
win = gMainHandler->FindWindow(ADVANCED_GAME_OPTIONS_WIN); // JPOLOOK - not finished yet
if ( not win) return;
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
}
// M.N. Skyfix
void SkyColorCB(long ID, short hittype, C_Base *control)
{
if (hittype not_eq C_TYPE_LMOUSEUP)
return;
C_Window *win;
win = gMainHandler->FindWindow(SETUP_SKY_WIN);
if ( not win) return;
gMainHandler->ShowWindow(win);
gMainHandler->WindowToFront(win);
}
| {
"pile_set_name": "Github"
} |
// Copyright 2009 the Sputnik authors. All rights reserved.
/**
* No matter how control leaves the embedded 'Statement',
* the scope chain is always restored to its former state
*
* @path ch12/12.10/S12.10_A3.2_T2.js
* @description Declaring "with" statement within a function body, leading to normal completion by "return"
* @noStrict
*/
this.p1 = 1;
var result = "result";
var myObj = {
p1: 'a',
value: 'myObj_value',
valueOf : function(){return 'obj_valueOf';}
}
var f = function(){
with(myObj){
p1 = 'x1';
return value;
}
};
f();
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if(p1 !== 1){
$ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
}
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if(myObj.p1 !== "x1"){
$ERROR('#1: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 );
}
//
//////////////////////////////////////////////////////////////////////////////
| {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.